/* 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 .= ''; return $output; } add_shortcode('word-exporter', 'word_exporter_shortcode'); {"id":565,"date":"2021-09-03T19:00:00","date_gmt":"2021-09-03T19:00:00","guid":{"rendered":"https:\/\/www.entrepreneur.com\/article\/375355"},"modified":"2021-09-03T19:00:00","modified_gmt":"2021-09-03T19:00:00","slug":"how-this-tequila-brand-launched-a-successful-product-at-the-outset-of-the-pandemic","status":"publish","type":"post","link":"https:\/\/ngedemo.com\/curatedweb\/how-this-tequila-brand-launched-a-successful-product-at-the-outset-of-the-pandemic\/","title":{"rendered":"How This Tequila Brand Launched a Successful Product at the Outset of the Pandemic"},"content":{"rendered":"Mexican PGA golfer Abraham Ancer and Mexican entrepreneur Aron Marquez joined forces to create Flecha Azul Tequila. <\/p>\n
Submit your email below to get an exclusive glimpse of Chapter 3: \u201cGood Idea! How Do I Know If I Have a Great Idea for a Business?<\/p>\n<\/p><\/div>\n