Markdown v3

Home » Snippets » Markdown v3

Created with:



Creator: Cameron

Customize with WPTurbo AI

Add Snippet To Project

New Project
Add To Existing Project
Plugin Name: Word To Markdown
Description: Convert Word file to markdown and create new post
Version: 1.0
Author: Your Name
License: GPL2

// Add menu item to the admin menu
add_action('admin_menu', 'wpturbo_add_menu');
function wpturbo_add_menu() {
  add_menu_page('Word To Markdown', 'Word To Markdown', 'manage_options', 'wpturbo_word_to_markdown', 'wpturbo_word_to_markdown_page');

// Display the admin page
function wpturbo_word_to_markdown_page() {
  if (isset($_FILES['word_file'])) {
    $upload_dir = wp_upload_dir();
    $file_path = $upload_dir['path'] . '/' . $_FILES['word_file']['name'];
    move_uploaded_file($_FILES['word_file']['tmp_name'], $file_path);

    // Convert Word file to markdown
    $content = wpturbo_convert_word_to_markdown($file_path);

    // Create new post
    $post_id = wp_insert_post(array(
      'post_title' => $content['title'],
      'post_content' => $content['content'],
      'post_status' => 'publish',
      'post_author' => get_current_user_id(),

    // SEO suggestions
    if (function_exists('rank_math')) {
      // Use RankMath SEO suggestions
      $seo_suggestions = rank_math()->get_seo()->get_analysis()->get_seo_data($post_id);
    } else {
      // Use ChatGPT API for SEO suggestions
      $seo_suggestions = wpturbo_get_seo_suggestions($content['content']);

    // Display SEO suggestions
    echo '<h2>SEO Suggestions</h2>';
    foreach ($seo_suggestions as $suggestion) {
      echo '<p>' . $suggestion . '</p>';
  } else {
    echo '<form method="post" enctype="multipart/form-data">';
    echo '<input type="file" name="word_file" accept=".doc,.docx">';
    echo '<input type="submit" value="Convert and Create Post">';
    echo '</form>';

// Convert Word file to markdown
function wpturbo_convert_word_to_markdown($file_path) {
  // Logic to convert Word file to markdown
  // ...

  // Placeholder data
  $title = 'Sample Post Title';
  $content = 'Sample post content';

  return array(
    'title' => $title,
    'content' => $content,

// Get SEO suggestions using ChatGPT API
function wpturbo_get_seo_suggestions($content) {
  // Logic to get SEO suggestions using ChatGPT API
  // ...

  // Placeholder data
  $suggestions = array(
    'Improve your meta description',
    'Add relevant keywords in your content',
    'Optimize your headings',

  return $suggestions;


Please note that some parts of the code, such as the Word to markdown conversion and the ChatGPT API integration, are currently placeholders and will need to be implemented based on your specific requirements and existing plugins or APIs that you plan to use.

Register an account to save your snippets or go Pro to get more features.