sanitize_text_field( $filename ), 'post_content' => '', 'post_status' => 'inherit', 'post_author' => $user->ID, ); $attachment_id = wp_insert_attachment( $attachment, $file_path ); if (is_wp_error($attachment_id)) { return new WP_Error( 'attachment_failed', 'Could not create Media Library attachment.', array('status' => 500) ); } $metadata = wp_generate_attachment_metadata( $attachment_id, $file_path ); if ($metadata) { wp_update_attachment_metadata( $attachment_id, $metadata ); } return array( 'success' => true, 'attachment_id' => (int) $attachment_id, 'url' => $file_url, 'message' => 'Image uploaded successfully.', ); }, 'permission_callback' => '__return_true', ) ); /* |-------------------------------------------------------------------------- | DEBUG ROUTES |-------------------------------------------------------------------------- */ register_rest_route( 'shoptek-api/v1', '/debug/routes', array( 'methods' => 'GET', 'callback' => function () { return array( 'success' => true, 'message' => 'Shoptek API routes are registered.', 'version' => '1.6', 'routes' => array( 'PING' => '/shoptek-api/v1/ping', 'LOGIN' => '/shoptek-api/v1/vendor/login', 'GET' => '/shoptek-api/v1/vendor/products', 'POST' => '/shoptek-api/v1/vendor/products', 'GET_CATEGORIES' => '/shoptek-api/v1/vendor/categories', 'CREATE_CATEGORY' => '/shoptek-api/v1/vendor/categories', 'UPLOAD' => '/shoptek-api/v1/vendor/upload', ), ); }, 'permission_callback' => '__return_true', ) ); }); Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/shoptgvzup/wp-content/plugins/shoptek-api/shoptek-api.php:1) in /usr/www/users/shoptgvzup/wp-includes/sitemaps/class-wp-sitemaps-renderer.php on line 126 https://shoptek.co.za/wp-sitemap-posts-post-1.xmlhttps://shoptek.co.za/wp-sitemap-posts-page-1.xmlhttps://shoptek.co.za/wp-sitemap-posts-product-1.xmlhttps://shoptek.co.za/wp-sitemap-taxonomies-category-1.xmlhttps://shoptek.co.za/wp-sitemap-taxonomies-product_cat-1.xmlhttps://shoptek.co.za/wp-sitemap-users-1.xml