/* Plugin Name: Word Exporter Plugin URI: https://www.example.com/word-exporter Description: Export WordPress posts to Word document using Aspose.Words for Cloud API. Version: 1.0.0 Author: John Doe Author URI: https://www.example.com License: GPL2 */ require_once plugin_dir_path(__FILE__) . '/aspose-words-cloud-php/vendor/autoload.php'; use Aspose\Words\Cloud\Api\WordsApi; use Aspose\Words\Cloud\Model\Requests\SaveAsRequest; $words_api = new WordsApi(getenv('6d4292c1-6517-43c0-af06-6d07be7015ee'), getenv('1d7c12cf62b22c417fd45bb92cd8ce8c')); function word_exporter_shortcode() { $output = ''; if (isset($_POST['post_id'])) { $post_id = sanitize_text_field($_POST['post_id']); $post = get_post($post_id); if ($post) { $output .= '

Exporting post "' . $post->post_title . '"...

'; $request = new SaveAsRequest(array( 'name' => $post->post_name . '.docx', 'save_options_data' => array( 'save_format' => 'docx', 'pretty_format' => true ) )); $result = $words_api->saveAs(new \Aspose\Words\Cloud\Model\SaveAsRequest($request, $post_id, null, null, null, null, null, null)); if ($result) { $output .= '

Post exported successfully. Download

'; } else { $output .= '

Error exporting post. Please try again.

'; } } else { $output .= '

Post not found.

'; } } $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; return $output; } add_shortcode('word-exporter', 'word_exporter_shortcode'); {"id":1,"name":"adnan.doc","url":"","description":"","link":"https:\/\/ngedemo.com\/curatedweb\/author\/adnan-doc\/","slug":"adnan-doc","avatar_urls":{"24":"https:\/\/ngedemo.com\/curatedweb\/wp-content\/uploads\/avatars\/1\/619041f578556-bpthumb.png","48":"https:\/\/ngedemo.com\/curatedweb\/wp-content\/uploads\/avatars\/1\/619041f578556-bpthumb.png","96":"https:\/\/ngedemo.com\/curatedweb\/wp-content\/uploads\/avatars\/1\/619041f55f5c6-bpfull.png"},"meta":[],"is_super_admin":true,"woocommerce_meta":{"variable_product_tour_shown":"","activity_panel_inbox_last_read":"","activity_panel_reviews_last_read":"","categories_report_columns":"","coupons_report_columns":"","customers_report_columns":"","orders_report_columns":"","products_report_columns":"","revenue_report_columns":"","taxes_report_columns":"","variations_report_columns":"","dashboard_sections":"","dashboard_chart_type":"","dashboard_chart_interval":"","dashboard_leaderboard_rows":"","homepage_layout":"","homepage_stats":"","task_list_tracked_started_tasks":"","help_panel_highlight_shown":"","android_app_banner_dismissed":""},"_links":{"self":[{"href":"https:\/\/ngedemo.com\/curatedweb\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"https:\/\/ngedemo.com\/curatedweb\/wp-json\/wp\/v2\/users"}]}}