Plugin Directory

Changeset 3464114


Ignore:
Timestamp:
02/18/2026 09:29:50 AM (2 days ago)
Author:
contentpen
Message:

feat: add support for Rank Math and AIO SEO plugins

Location:
contentpen
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • contentpen/tags/1.0.11/README.txt

    r3463958 r3464114  
    44Requires at least: 5.8
    55Tested up to: 6.9.1
    6 Stable tag: 1.0.10
     6Stable tag: 1.0.11
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    5555== Changelog ==
    5656
     57= 1.0.11 =
     58* Added support for Rank Math and All in One SEO plugins
     59
    5760= 1.0.10 =
    5861* Removed unused GET /posts endpoint that caused route conflicts in some wordpress versions.
     
    7679== Upgrade Notice ==
    7780
     81= 1.0.11 =
     82* Added support for Rank Math and All in One SEO plugins
     83
    7884= 1.0.10 =
    7985* Removed unused GET /posts endpoint that caused route conflicts in some wordpress versions.
  • contentpen/tags/1.0.11/contentpen-plugin.php

    r3463958 r3464114  
    55 * Plugin URI: https://contentpen.ai
    66 * Description: Contentpen is an AI-powered content writing assistant designed to help businesses create, optimize, and publish SEO-friendly blog posts at scale. By combining deep research with your brand's unique voice, Contentpen crafts high-impact articles that outperform your competition.
    7  * Version: 1.0.10
     7 * Version: 1.0.11
    88 * Requires at least: 5.8
    99 * Requires PHP: 7.4
     
    2020}
    2121
    22 define('CONTENTPEN_VERSION', '1.0.10');
     22define('CONTENTPEN_VERSION', '1.0.11');
    2323define('CONTENTPEN_PLUGIN_DIR', plugin_dir_path(__FILE__));
    2424define('CONTENTPEN_PLUGIN_URL', plugin_dir_url(__FILE__));
  • contentpen/tags/1.0.11/includes/class-contentpen-api.php

    r3463958 r3464114  
    220220    $this->set_post_slug($post_id, isset($params['custom_slug']) ? $params['custom_slug'] : null);
    221221
    222     // Handle Yoast SEO if active
    223     if ($this->is_yoast_active()) {
    224       $this->set_yoast_seo($post_id, $params);
    225     }
    226 
    227     // Handle All in One SEO if active
    228     if ($this->is_all_in_one_seo_active()) {
    229       $this->set_all_in_one_seo($post_id, $params);
    230     }
     222    // Handle SEO plugins
     223    $this->set_seo_meta($post_id, $params);
    231224
    232225    // Handle featured image
     
    275268  private function is_yoast_active()
    276269  {
    277     $active_plugins = apply_filters('active_plugins', get_option('active_plugins'));
    278     foreach ($active_plugins as $plugin) {
    279       if (strpos($plugin, 'wp-seo')) {
    280         return true;
    281       }
    282     }
    283     return false;
     270    return defined('WPSEO_VERSION') || class_exists('WPSEO_Meta');
     271  }
     272
     273  private function is_rankmath_active()
     274  {
     275    return class_exists('RankMath') || defined('RANK_MATH_VERSION');
    284276  }
    285277
    286278  private function is_all_in_one_seo_active()
    287279  {
    288     $active_plugins = apply_filters('active_plugins', get_option('active_plugins'));
    289     foreach ($active_plugins as $plugin) {
    290       if (strpos($plugin, 'all_in_one_seo_pack')) {
    291         return true;
    292       }
    293     }
    294     return false;
    295   }
    296 
    297   private function set_yoast_seo($post_id, $params)
    298   {
    299     // Check if Yoast SEO meta entry exists and create if needed
    300     // Using WordPress functions instead of direct database queries
     280    return defined('AIOSEO_VERSION') || class_exists('AIOSEO\\Plugin\\AIOSEO');
     281  }
     282
     283  private function set_seo_meta($post_id, $params)
     284  {
     285    $meta_title = !empty($params['meta_title']) ? sanitize_text_field($params['meta_title']) : '';
     286    $meta_description = !empty($params['meta_description']) ? sanitize_text_field($params['meta_description']) : '';
     287
     288    if (empty($meta_title) && empty($meta_description)) {
     289      return;
     290    }
     291
     292    if ($this->is_yoast_active()) {
     293      $this->set_yoast_seo($post_id, $meta_title, $meta_description);
     294    }
     295
     296    if ($this->is_rankmath_active()) {
     297      $this->set_rankmath_seo($post_id, $meta_title, $meta_description);
     298    }
     299
     300    if ($this->is_all_in_one_seo_active()) {
     301      $this->set_all_in_one_seo($post_id, $meta_title, $meta_description);
     302    }
     303  }
     304
     305  private function set_yoast_seo($post_id, $meta_title, $meta_description)
     306  {
    301307    $internal_link_count = get_post_meta($post_id, '_yoast_wpseo_internal_link_count', true);
    302308    if ($internal_link_count === '') {
    303       // Initialize Yoast SEO meta values if they don't exist
    304309      update_post_meta($post_id, '_yoast_wpseo_internal_link_count', 0);
    305310      update_post_meta($post_id, '_yoast_wpseo_incoming_link_count', 0);
    306311    }
    307312
    308     // Add title and description
    309     if (!empty($params['meta_title'])) {
    310       update_post_meta($post_id, '_yoast_wpseo_title', sanitize_text_field($params['meta_title']));
    311     }
    312     if (!empty($params['meta_description'])) {
    313       update_post_meta($post_id, '_yoast_wpseo_metadesc', sanitize_text_field($params['meta_description']));
     313    if (!empty($meta_title)) {
     314      update_post_meta($post_id, '_yoast_wpseo_title', $meta_title);
     315    }
     316    if (!empty($meta_description)) {
     317      update_post_meta($post_id, '_yoast_wpseo_metadesc', $meta_description);
     318    }
     319  }
     320
     321  private function set_rankmath_seo($post_id, $meta_title, $meta_description)
     322  {
     323    if (!empty($meta_title)) {
     324      update_post_meta($post_id, 'rank_math_title', $meta_title);
     325    }
     326    if (!empty($meta_description)) {
     327      update_post_meta($post_id, 'rank_math_description', $meta_description);
    314328    }
    315329  }
     
    496510  }
    497511
    498   private function set_all_in_one_seo($post_id, $params)
    499   {
    500     if (!empty($params['meta_title'])) {
    501       update_post_meta($post_id, '_aioseop_title', sanitize_text_field($params['meta_title']));
    502     }
    503     if (!empty($params['meta_description'])) {
    504       update_post_meta($post_id, '_aioseop_description', sanitize_text_field($params['meta_description']));
     512  private function set_all_in_one_seo($post_id, $meta_title, $meta_description)
     513  {
     514    // AIOSEO v4+ stores data in custom table (wp_aioseo_posts), not postmeta
     515    if (class_exists('AIOSEO\\Plugin\\Models\\Post')) {
     516      $aioseo_post = \AIOSEO\Plugin\Models\Post::getPost($post_id);
     517     
     518      if (!empty($meta_title)) {
     519        $aioseo_post->title = $meta_title;
     520      }
     521      if (!empty($meta_description)) {
     522        $aioseo_post->description = $meta_description;
     523      }
     524     
     525      $aioseo_post->save();
     526      return;
     527    }
     528
     529    // Fallback: Direct database insert/update for AIOSEO v4+
     530    if (defined('AIOSEO_VERSION')) {
     531      global $wpdb;
     532      $table_name = $wpdb->prefix . 'aioseo_posts';
     533     
     534      if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") === $table_name) {
     535        $existing = $wpdb->get_row($wpdb->prepare(
     536          "SELECT id FROM $table_name WHERE post_id = %d",
     537          $post_id
     538        ));
     539
     540        $data = array(
     541          'post_id' => $post_id,
     542          'title' => $meta_title ?: null,
     543          'description' => $meta_description ?: null,
     544          'updated' => current_time('mysql')
     545        );
     546
     547        if ($existing) {
     548          $wpdb->update($table_name, $data, array('post_id' => $post_id));
     549        } else {
     550          $data['created'] = current_time('mysql');
     551          $wpdb->insert($table_name, $data);
     552        }
     553        return;
     554      }
     555    }
     556
     557    // Legacy AIOSEO (pre v4) fallback using postmeta
     558    if (!empty($meta_title)) {
     559      update_post_meta($post_id, '_aioseop_title', $meta_title);
     560    }
     561    if (!empty($meta_description)) {
     562      update_post_meta($post_id, '_aioseop_description', $meta_description);
    505563    }
    506564  }
     
    668726    $this->set_post_slug($post_id, isset($params['custom_slug']) ? $params['custom_slug'] : null);
    669727
    670     // Handle Yoast SEO if active
    671     if ($this->is_yoast_active()) {
    672       $this->set_yoast_seo($post_id, $params);
    673     }
    674 
    675     // Handle All in One SEO if active
    676     if ($this->is_all_in_one_seo_active()) {
    677       $this->set_all_in_one_seo($post_id, $params);
    678     }
     728    // Handle SEO plugins
     729    $this->set_seo_meta($post_id, $params);
    679730
    680731    // Handle featured image
  • contentpen/trunk/README.txt

    r3463958 r3464114  
    44Requires at least: 5.8
    55Tested up to: 6.9.1
    6 Stable tag: 1.0.10
     6Stable tag: 1.0.11
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    5555== Changelog ==
    5656
     57= 1.0.11 =
     58* Added support for Rank Math and All in One SEO plugins
     59
    5760= 1.0.10 =
    5861* Removed unused GET /posts endpoint that caused route conflicts in some wordpress versions.
     
    7679== Upgrade Notice ==
    7780
     81= 1.0.11 =
     82* Added support for Rank Math and All in One SEO plugins
     83
    7884= 1.0.10 =
    7985* Removed unused GET /posts endpoint that caused route conflicts in some wordpress versions.
  • contentpen/trunk/contentpen-plugin.php

    r3463958 r3464114  
    55 * Plugin URI: https://contentpen.ai
    66 * Description: Contentpen is an AI-powered content writing assistant designed to help businesses create, optimize, and publish SEO-friendly blog posts at scale. By combining deep research with your brand's unique voice, Contentpen crafts high-impact articles that outperform your competition.
    7  * Version: 1.0.10
     7 * Version: 1.0.11
    88 * Requires at least: 5.8
    99 * Requires PHP: 7.4
     
    2020}
    2121
    22 define('CONTENTPEN_VERSION', '1.0.10');
     22define('CONTENTPEN_VERSION', '1.0.11');
    2323define('CONTENTPEN_PLUGIN_DIR', plugin_dir_path(__FILE__));
    2424define('CONTENTPEN_PLUGIN_URL', plugin_dir_url(__FILE__));
  • contentpen/trunk/includes/class-contentpen-api.php

    r3463958 r3464114  
    220220    $this->set_post_slug($post_id, isset($params['custom_slug']) ? $params['custom_slug'] : null);
    221221
    222     // Handle Yoast SEO if active
    223     if ($this->is_yoast_active()) {
    224       $this->set_yoast_seo($post_id, $params);
    225     }
    226 
    227     // Handle All in One SEO if active
    228     if ($this->is_all_in_one_seo_active()) {
    229       $this->set_all_in_one_seo($post_id, $params);
    230     }
     222    // Handle SEO plugins
     223    $this->set_seo_meta($post_id, $params);
    231224
    232225    // Handle featured image
     
    275268  private function is_yoast_active()
    276269  {
    277     $active_plugins = apply_filters('active_plugins', get_option('active_plugins'));
    278     foreach ($active_plugins as $plugin) {
    279       if (strpos($plugin, 'wp-seo')) {
    280         return true;
    281       }
    282     }
    283     return false;
     270    return defined('WPSEO_VERSION') || class_exists('WPSEO_Meta');
     271  }
     272
     273  private function is_rankmath_active()
     274  {
     275    return class_exists('RankMath') || defined('RANK_MATH_VERSION');
    284276  }
    285277
    286278  private function is_all_in_one_seo_active()
    287279  {
    288     $active_plugins = apply_filters('active_plugins', get_option('active_plugins'));
    289     foreach ($active_plugins as $plugin) {
    290       if (strpos($plugin, 'all_in_one_seo_pack')) {
    291         return true;
    292       }
    293     }
    294     return false;
    295   }
    296 
    297   private function set_yoast_seo($post_id, $params)
    298   {
    299     // Check if Yoast SEO meta entry exists and create if needed
    300     // Using WordPress functions instead of direct database queries
     280    return defined('AIOSEO_VERSION') || class_exists('AIOSEO\\Plugin\\AIOSEO');
     281  }
     282
     283  private function set_seo_meta($post_id, $params)
     284  {
     285    $meta_title = !empty($params['meta_title']) ? sanitize_text_field($params['meta_title']) : '';
     286    $meta_description = !empty($params['meta_description']) ? sanitize_text_field($params['meta_description']) : '';
     287
     288    if (empty($meta_title) && empty($meta_description)) {
     289      return;
     290    }
     291
     292    if ($this->is_yoast_active()) {
     293      $this->set_yoast_seo($post_id, $meta_title, $meta_description);
     294    }
     295
     296    if ($this->is_rankmath_active()) {
     297      $this->set_rankmath_seo($post_id, $meta_title, $meta_description);
     298    }
     299
     300    if ($this->is_all_in_one_seo_active()) {
     301      $this->set_all_in_one_seo($post_id, $meta_title, $meta_description);
     302    }
     303  }
     304
     305  private function set_yoast_seo($post_id, $meta_title, $meta_description)
     306  {
    301307    $internal_link_count = get_post_meta($post_id, '_yoast_wpseo_internal_link_count', true);
    302308    if ($internal_link_count === '') {
    303       // Initialize Yoast SEO meta values if they don't exist
    304309      update_post_meta($post_id, '_yoast_wpseo_internal_link_count', 0);
    305310      update_post_meta($post_id, '_yoast_wpseo_incoming_link_count', 0);
    306311    }
    307312
    308     // Add title and description
    309     if (!empty($params['meta_title'])) {
    310       update_post_meta($post_id, '_yoast_wpseo_title', sanitize_text_field($params['meta_title']));
    311     }
    312     if (!empty($params['meta_description'])) {
    313       update_post_meta($post_id, '_yoast_wpseo_metadesc', sanitize_text_field($params['meta_description']));
     313    if (!empty($meta_title)) {
     314      update_post_meta($post_id, '_yoast_wpseo_title', $meta_title);
     315    }
     316    if (!empty($meta_description)) {
     317      update_post_meta($post_id, '_yoast_wpseo_metadesc', $meta_description);
     318    }
     319  }
     320
     321  private function set_rankmath_seo($post_id, $meta_title, $meta_description)
     322  {
     323    if (!empty($meta_title)) {
     324      update_post_meta($post_id, 'rank_math_title', $meta_title);
     325    }
     326    if (!empty($meta_description)) {
     327      update_post_meta($post_id, 'rank_math_description', $meta_description);
    314328    }
    315329  }
     
    496510  }
    497511
    498   private function set_all_in_one_seo($post_id, $params)
    499   {
    500     if (!empty($params['meta_title'])) {
    501       update_post_meta($post_id, '_aioseop_title', sanitize_text_field($params['meta_title']));
    502     }
    503     if (!empty($params['meta_description'])) {
    504       update_post_meta($post_id, '_aioseop_description', sanitize_text_field($params['meta_description']));
     512  private function set_all_in_one_seo($post_id, $meta_title, $meta_description)
     513  {
     514    // AIOSEO v4+ stores data in custom table (wp_aioseo_posts), not postmeta
     515    if (class_exists('AIOSEO\\Plugin\\Models\\Post')) {
     516      $aioseo_post = \AIOSEO\Plugin\Models\Post::getPost($post_id);
     517     
     518      if (!empty($meta_title)) {
     519        $aioseo_post->title = $meta_title;
     520      }
     521      if (!empty($meta_description)) {
     522        $aioseo_post->description = $meta_description;
     523      }
     524     
     525      $aioseo_post->save();
     526      return;
     527    }
     528
     529    // Fallback: Direct database insert/update for AIOSEO v4+
     530    if (defined('AIOSEO_VERSION')) {
     531      global $wpdb;
     532      $table_name = $wpdb->prefix . 'aioseo_posts';
     533     
     534      if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") === $table_name) {
     535        $existing = $wpdb->get_row($wpdb->prepare(
     536          "SELECT id FROM $table_name WHERE post_id = %d",
     537          $post_id
     538        ));
     539
     540        $data = array(
     541          'post_id' => $post_id,
     542          'title' => $meta_title ?: null,
     543          'description' => $meta_description ?: null,
     544          'updated' => current_time('mysql')
     545        );
     546
     547        if ($existing) {
     548          $wpdb->update($table_name, $data, array('post_id' => $post_id));
     549        } else {
     550          $data['created'] = current_time('mysql');
     551          $wpdb->insert($table_name, $data);
     552        }
     553        return;
     554      }
     555    }
     556
     557    // Legacy AIOSEO (pre v4) fallback using postmeta
     558    if (!empty($meta_title)) {
     559      update_post_meta($post_id, '_aioseop_title', $meta_title);
     560    }
     561    if (!empty($meta_description)) {
     562      update_post_meta($post_id, '_aioseop_description', $meta_description);
    505563    }
    506564  }
     
    668726    $this->set_post_slug($post_id, isset($params['custom_slug']) ? $params['custom_slug'] : null);
    669727
    670     // Handle Yoast SEO if active
    671     if ($this->is_yoast_active()) {
    672       $this->set_yoast_seo($post_id, $params);
    673     }
    674 
    675     // Handle All in One SEO if active
    676     if ($this->is_all_in_one_seo_active()) {
    677       $this->set_all_in_one_seo($post_id, $params);
    678     }
     728    // Handle SEO plugins
     729    $this->set_seo_meta($post_id, $params);
    679730
    680731    // Handle featured image
Note: See TracChangeset for help on using the changeset viewer.