Plugin Directory

Changeset 3463890


Ignore:
Timestamp:
02/17/2026 11:09:10 PM (6 weeks ago)
Author:
rankauthority
Message:

Added: geo category / template / slug

Location:
rank-authority
Files:
10 added
3 edited

Legend:

Unmodified
Added
Removed
  • rank-authority/trunk/rank-authority.php

    r3459448 r3463890  
    44 * Plugin URI: https://rankauthority.com/plugins/rankauthority
    55 * Description: Secure API connector to publish posts / overwrite posts from the RA Dashboard to WordPress. Token reset now available to all administrators.
    6  * Version: 1.0.16
     6 * Version: 1.0.17
    77 * Author: Rank Authority
    88 * Author URI: https://rankauthority.com
     
    2323    private $option_website_id = 'ra_wp_connector_website_id';
    2424    private $option_script_enabled = 'ra_wp_connector_script_enabled';
     25    private $option_geo_category_id = 'ra_geo_category_id';
     26    private $option_version = 'ra_plugin_version';
    2527
    2628    public function __construct() {
    2729        register_activation_hook(__FILE__, [$this, 'activate']);
     30        add_action('init', [$this, 'maybe_run_upgrade'], 5);
     31        add_filter('template_include', [$this, 'geo_category_template'], 99);
    2832        add_action('admin_menu', [$this, 'admin_menu']);
    2933        add_action('admin_enqueue_scripts', [$this, 'admin_enqueue_scripts']);
     
    5660            update_option($this->option_script_enabled, '0');
    5761        }
     62
     63        $this->ensure_geo_category();
     64        $this->update_plugin_version();
     65    }
     66
     67    /** Run upgrade logic when plugin version changes */
     68    public function maybe_run_upgrade() {
     69        $current_version = get_file_data(__FILE__, array('Version' => 'Version'), false)['Version'] ?? '1.0.0';
     70        $saved_version = get_option($this->option_version, '0');
     71        if (version_compare($saved_version, $current_version, '<')) {
     72            $this->ensure_geo_category();
     73            $this->update_plugin_version();
     74        }
     75    }
     76
     77    /** Update stored plugin version */
     78    private function update_plugin_version() {
     79        $version = get_file_data(__FILE__, array('Version' => 'Version'), false)['Version'] ?? '1.0.0';
     80        update_option($this->option_version, $version);
     81    }
     82
     83    /** Create Geo category for GEO (Generative Engine Optimization) content if not exists */
     84    private function ensure_geo_category() {
     85        $existing_id = get_option($this->option_geo_category_id);
     86        if ($existing_id) {
     87            $term = get_term($existing_id, 'category');
     88            if ($term && !is_wp_error($term)) {
     89                return (int) $existing_id;
     90            }
     91        }
     92        $term = get_term_by('slug', 'geo', 'category');
     93        if ($term && !is_wp_error($term)) {
     94            update_option($this->option_geo_category_id, $term->term_id);
     95            return (int) $term->term_id;
     96        }
     97        $result = wp_insert_term(
     98            'Geo',
     99            'category',
     100            array(
     101                'slug' => 'geo',
     102                'description' => __('AI-optimized content (Generative Engine Optimization). Text-focused posts without featured images.', 'rank-authority')
     103            )
     104        );
     105        if (!is_wp_error($result)) {
     106            update_option($this->option_geo_category_id, $result['term_id']);
     107            return (int) $result['term_id'];
     108        }
     109        return 0;
     110    }
     111
     112    /** Use custom template for Geo category archive (no thumbnails) */
     113    public function geo_category_template($template) {
     114        if (is_category('geo')) {
     115            $plugin_template = plugin_dir_path(__FILE__) . 'templates/category-geo.php';
     116            if (file_exists($plugin_template)) {
     117                return $plugin_template;
     118            }
     119        }
     120        return $template;
    58121    }
    59122
     
    10261089            'callback' => [$this, 'disconnect'],
    10271090            'permission_callback' => [$this, 'authenticate'],
     1091        ]);
     1092
     1093        register_rest_route('ra/v1', '/geo-category', [
     1094            'methods'  => 'GET',
     1095            'callback' => [$this, 'get_geo_category'],
     1096            'permission_callback' => [$this, 'authenticate'],
     1097        ]);
     1098    }
     1099
     1100    /** Return Geo category ID for GEO (Generative Engine Optimization) content */
     1101    public function get_geo_category() {
     1102        $id = get_option($this->option_geo_category_id);
     1103        if (!$id) {
     1104            $id = $this->ensure_geo_category();
     1105        }
     1106        return rest_ensure_response([
     1107            'category_id' => $id ? (int) $id : null,
     1108            'slug' => 'geo',
     1109            'name' => 'Geo',
    10281110        ]);
    10291111    }
  • rank-authority/trunk/readme.txt

    r3459448 r3463890  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.16
     7Stable tag: 1.0.17
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    137137
    138138== Changelog ==
     139
     140= 1.0.17 =
     141* Added Geo category for Generative Engine Optimization (GEO) content
     142* Auto-creates "Geo" category on plugin install and update
     143* Geo category archive uses custom template - text-only list without thumbnails
     144* Added GET /ra/v1/geo-category API endpoint to fetch Geo category ID for Dashboard
     145* Use Geo category for AI-optimized posts without featured images
    139146
    140147= 1.0.16 =
  • rank-authority/trunk/uninstall.php

    r3438857 r3463890  
    77delete_option('ra_wp_connector_website_id');
    88delete_option('ra_wp_connector_script_enabled');
     9delete_option('ra_geo_category_id');
     10delete_option('ra_plugin_version');
Note: See TracChangeset for help on using the changeset viewer.