Plugin Directory

Changeset 3350061


Ignore:
Timestamp:
08/26/2025 05:35:33 AM (7 months ago)
Author:
developer1998
Message:

Fixed some issues and improve the code

Location:
image-video-xml-sitemap
Files:
32 added
3 edited

Legend:

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

    r3344069 r3350061  
    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.5
     5Version: 1.0.6
    66Requires at least: 5.2
    77Requires PHP: 7.4
  • image-video-xml-sitemap/trunk/includes/class-image-video-xml-sitemap.php

    r3344069 r3350061  
    1414        add_filter('query_vars', [$this, 'ivxs_add_query_vars']);
    1515        add_action('template_redirect', [$this, 'ivxs_generate_custom_sitemap']);
     16        add_filter('redirect_canonical', [$this, 'ivxs_disable_trailing_slash_redirect'], 10, 2);
    1617    }
    1718
     
    312313            while ( $query->have_posts() ) {
    313314                $query->the_post();
    314                 $url = wp_get_attachment_url(get_the_ID());
     315                $attachment_id = get_the_ID();
     316                $url = wp_get_attachment_url( $attachment_id );
     317                $page_url = get_attachment_link(  $attachment_id  );
    315318                $lastmod = $this->ivxs_get_post_datetime_string( get_the_ID() );
    316319
    317320                echo '<url>';
    318                 echo '<loc>' . esc_url( $url ) . '</loc>';
     321                echo '<loc>' . esc_url( $page_url ) . '</loc>';
    319322                if ( $lastmod ) {
    320323                    echo '<lastmod>' . esc_html( $lastmod ) . '</lastmod>';
     
    323326                    echo '<image:image><image:loc>' . esc_url( $url ) . '</image:loc></image:image>';
    324327                } elseif ( $media_type === 'video' ) {
    325                     $thumbnail = esc_url( wp_get_attachment_url( get_post_thumbnail_id() ) );
    326                     $attachment_id = get_the_ID();
     328               
     329                    $thumbnail = esc_url( wp_get_attachment_url( get_post_thumbnail_id( $attachment_id ) ) );
    327330
    328331                    // Title fallback
     
    347350                    echo '<video:thumbnail_loc>' . esc_url( $thumbnail ) . '</video:thumbnail_loc>';
    348351                    echo '<video:title>' . esc_html( $title ) . '</video:title>';
    349                     echo '<video:description>' . esc_html($description) . '</video:description>';
     352                    echo '<video:description>' . esc_html( $description ) . '</video:description>';
    350353                    echo '<video:content_loc>' . esc_url( $url ) . '</video:content_loc>';
    351354                    echo '</video:video>';
    352355                }
     356
    353357                echo '</url>';
    354358            }
     
    359363        exit;
    360364    }
     365
     366    public function ivxs_disable_trailing_slash_redirect($redirect_url, $requested_url) {
     367        $image_sitemap_filename = get_option('ivxs_image_sitemap_filename', 'image');
     368        $video_sitemap_filename = get_option('ivxs_video_sitemap_filename', 'video');
     369
     370        if (preg_match('/(' . preg_quote($image_sitemap_filename, '/') . '|' . preg_quote($video_sitemap_filename, '/') . ')\.xml$/', $requested_url)) {
     371            return false;
     372        }
     373        return $redirect_url;
     374    }
     375
    361376}
    362377?>
  • image-video-xml-sitemap/trunk/readme.txt

    r3344069 r3350061  
    55Tested up to: 6.8.2
    66Requires PHP: 7.4 
    7 Stable tag: 1.0.5
     7Stable tag: 1.0.6
    88License: GPLv2 or later 
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7979== Changelog ==
    8080
     81= 1.0.6 =
     82- Fixed: Trailing slash issue on custom image and video sitemap URLs.
     83- Improved: Prevented unnecessary redirects to ensure faster sitemap loading.
     84- Updated: Added clarification that filenames must not contain the word sitemap due to conflicts with SEO plugins (Yoast, RankMath, etc.).
     85- Enhanced: Translation-ready error notice for invalid sitemap filename usage.
     86
    8187= 1.0.5 =
    8288- Fixed: Sitemap generation was unintentionally triggering on non-sitemap URLs when only one sitemap type was enabled.
     
    118124== Upgrade Notice ==
    119125
     126= 1.0.6 =
     127- Fixed: Trailing slash issue on custom image and video sitemap URLs.
     128- Improved: Prevented unnecessary redirects to ensure faster sitemap loading.
     129- Updated: Added clarification that filenames must not contain the word sitemap due to conflicts with SEO plugins (Yoast, RankMath, etc.).
     130- Enhanced: Translation-ready error notice for invalid sitemap filename usage.
     131
    120132= 1.0.5 =
    121133- Fixed: Sitemap generation was unintentionally triggering on non-sitemap URLs when only one sitemap type was enabled.
Note: See TracChangeset for help on using the changeset viewer.