Plugin Directory

Changeset 3267631


Ignore:
Timestamp:
04/07/2025 05:16:31 AM (12 months ago)
Author:
developer1998
Message:
  • URLs will correctly trigger your sitemap generator instead of redirecting to the homepage.
  • Performance is improved by avoiding unnecessary flush operations.
  • Query variables are correctly registered.
Location:
image-video-xml-sitemap/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • image-video-xml-sitemap/trunk/image-video-xml-sitemap.php

    r3224078 r3267631  
    33Plugin Name: Image & Video XML Sitemap
    44Description: Enhance your website's media SEO by creating separate sitemaps for images and videos. Fully compatible with Yoast SEO, with advanced customization options.
    5 Version: 1.0.0
     5Version: 1.0.1
    66Requires at least: 5.2
    77Requires PHP: 7.4
     
    2727
    2828//Activation hook
    29 register_activation_hook(__FILE__, 'ivxy_plugin_activation');
    30 function ivxy_plugin_activation() {
     29register_activation_hook(__FILE__, function() {
     30    (new ivxs_ImageVideoSitemap())->ivxs_add_sitemap_rewrites();
    3131    flush_rewrite_rules();
    32 }
     32});
    3333
    3434//Deactivation hook
    35 register_deactivation_hook(__FILE__, 'ivxs_plugin_deactivation');
    36 function ivxs_plugin_deactivation() {
     35register_deactivation_hook(__FILE__, function() {
    3736    flush_rewrite_rules();
    38 }
     37});
    3938
    4039// Hook into WordPress admin initialization to check for SEO plugin.
  • image-video-xml-sitemap/trunk/includes/class-image-video-xml-sitemap.php

    r3224078 r3267631  
    9494                        <?php submit_button(); ?>
    9595                    </form>
     96                    <p><em><strong>Note</strong>: Please visit Settings → Permalinks in your WordPress dashboard and simply click 'Save Changes' if the image or video XML sitemap URL is not working.</em></p>
    9697                </div>
    9798                <div class="ivxs-col-4">
     
    115116
    116117    public function ivxs_save_settings() {
    117         if (!current_user_can('manage_options') || !check_admin_referer('ivxs_save_settings', 'ivxs_nonce')) {
     118        if (!is_admin() || !current_user_can('manage_options') || !check_admin_referer('ivxs_save_settings', 'ivxs_nonce')) {
    118119            wp_die(esc_html(__('You are not allowed to perform this action.', 'image-video-xml-sitemap')));
    119120        }
     
    233234    }
    234235
    235     public function ivxs_add_sitemap_rewrites(){
    236         $image_sitemap_filename = get_option( 'ivxs_image_sitemap_filename', '' );
    237         $video_sitemap_filename = get_option( 'ivxs_video_sitemap_filename', '' );
    238 
    239         add_rewrite_rule( '^'.$image_sitemap_filename.'.xml$', 'index.php?custom_sitemap=image', 'top' );
    240         add_rewrite_rule( '^'.$video_sitemap_filename.'.xml$', 'index.php?custom_sitemap=video', 'top' );
    241 
    242         flush_rewrite_rules();
    243     }
    244 
    245     public function ivxs_add_query_vars(){
     236    public function ivxs_add_sitemap_rewrites() {
     237        $image_sitemap_filename = get_option('ivxs_image_sitemap_filename', 'image');
     238        $video_sitemap_filename = get_option('ivxs_video_sitemap_filename', 'video');
     239   
     240        if (!empty($image_sitemap_filename)) {
     241            add_rewrite_rule('^' . preg_quote($image_sitemap_filename) . '\.xml$', 'index.php?custom_sitemap=image', 'top');
     242        }
     243   
     244        if (!empty($video_sitemap_filename)) {
     245            add_rewrite_rule('^' . preg_quote($video_sitemap_filename) . '\.xml$', 'index.php?custom_sitemap=video', 'top');
     246        }
     247    }
     248   
     249    public function ivxs_add_query_vars($vars) {
    246250        $vars[] = 'custom_sitemap';
    247251        return $vars;
    248252    }
    249 
     253   
    250254    public function ivxs_generate_custom_sitemap() {
    251255        $custom_sitemap = get_query_var( 'custom_sitemap' );
  • image-video-xml-sitemap/trunk/readme.txt

    r3224081 r3267631  
    55Tested up to: 6.7 
    66Requires PHP: 7.4 
    7 Stable tag: 1.0.0 
     7Stable tag: 1.0.1 
    88License: GPLv2 or later 
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    3333### Advanced Feature:
    3434Even with Yoast SEO's media sitemap options enabled, this plugin generates independent sitemaps for better control and optimization of your media assets.
     35
     36### Extra Notes:
     37Please visit **Settings → Permalinks** in your WordPress dashboard and simply click "Save Changes". This will flush and refresh the rewrite rules so that the custom sitemap URLs start working properly.
    3538
    3639== Installation ==
     
    7679== Changelog ==
    7780
    78 = 1.0 =
     81= 1.0.1 =
     82- URLs will correctly trigger your sitemap generator instead of redirecting to the homepage.
     83- Performance is improved by avoiding unnecessary flush operations.
     84- Query variables are correctly registered.
     85
     86= 1.0.0 =
    7987- Initial release.
    8088- Added support for separate sitemaps for images and videos.
     
    8492== Upgrade Notice ==
    8593
    86 = 1.0 =
     94= 1.0.1 =
     95Performance is improved by avoiding unnecessary flush operations.
     96
     97= 1.0.0 =
    8798Initial release. Ensure you have Yoast SEO installed and activated to use this plugin.
    8899
Note: See TracChangeset for help on using the changeset viewer.