Plugin Directory

Changeset 3364232


Ignore:
Timestamp:
09/18/2025 09:36:31 PM (3 months ago)
Author:
RavanH
Message:

commit v.7

Location:
xml-sitemaps-manager/trunk
Files:
16 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • xml-sitemaps-manager/trunk/readme.txt

    r3061149 r3364232  
    55Requires at least: 5.5
    66Requires PHP: 5.6
    7 Tested up to: 6.5
    8 Stable tag: 0.6
     7Tested up to: 6.8
     8Stable tag: 0.7
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7272== Upgrade Notice ==
    7373
    74 = 0.6 =
     74= 0.7 =
    7575
    76 Lastmod for tax term and Polylang compatibility improvements, stylesheet, bugfixes.
     76Improved multisite compatibility.
    7777
    7878== Changelog ==
     79
     80= 0.7 =
     81* Improved multisite compatibility
    7982
    8083= 0.6 =
  • xml-sitemaps-manager/trunk/uninstall.php

    r3061149 r3364232  
    1111
    1212// Exit if uninstall not called from WordPress.
    13 defined( '\WP_UNINSTALL_PLUGIN' ) || exit();
     13defined( 'WP_UNINSTALL_PLUGIN' ) || exit();
    1414
    1515// Check if it is a multisite and not a large one.
    1616if ( \is_multisite() ) {
    17     if ( \defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     17    if ( WP_DEBUG && WP_DEBUG_LOG ) {
    1818        \error_log( 'Clearing XML Sitemaps Manager settings from each site before uninstall:' );
    1919    }
    2020
    21     if ( wp_is_large_network() ) {
    22         if ( \defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     21    if ( \wp_is_large_network() ) {
     22        if ( WP_DEBUG && WP_DEBUG_LOG ) {
    2323            \error_log( 'Aborting multisite uninstall. Too many sites in your network.' );
    2424        }
     
    5656     * Remove metadata.
    5757     */
    58     // Terms meta.
    59     delete_metadata( 'term', 0, 'term_modified_gmt', '', true );
    60     // User meta.
    61     delete_metadata( 'user', 0, 'user_modified_gmt', '', true );
    62     // TODO: add Polylang metadata removal.
     58    // Already done on plugin deactivation.
    6359
    6460    /**
     
    6662     */
    6763    \delete_option( 'xmlsm_version' );
    68     \delete_option( 'xmlsm_sitemaps_enabled' );
    6964    \delete_option( 'xmlsm_sitemaps_fixes' );
    7065    \delete_option( 'xmlsm_max_urls' );
     
    7469
    7570    // Kilroy was here.
    76     if ( \defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     71    if ( WP_DEBUG && WP_DEBUG_LOG ) {
    7772        if ( $_id ) {
    7873            \error_log( 'XML Sitemaps Manager settings cleared for blog ID:' . $_id );
  • xml-sitemaps-manager/trunk/xml-sitemaps-manager.php

    r3061149 r3364232  
    77 * Description:       Fix some bugs and add new options to manage the WordPress core XML Sitemaps. Happy with the results? Please leave me a <strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemaps%20Manager">tip</a></strong> for continued development and support. Thanks :)
    88 * Text Domain:       xml-sitemaps-manager
    9  * Version:           0.6
     9 * Version:           0.7
    1010 * Requires at least: 5.5
    1111 * Requires PHP:      5.6
     
    1818defined( 'WPINC' ) || die;
    1919
    20 define( 'XMLSM_VERSION', '0.6' );
     20define( 'XMLSM_VERSION', '0.7' );
    2121define( 'XMLSM_BASENAME', plugin_basename( __FILE__ ) );
    2222
    23 /**
    24  * Plugin intitialization.
    25  *
    26  * Must run before priority 10 for the wp_sitemaps_add_provider filter to work.
    27  * Can be disabled with remove_action('init','xmlsm_init',9).
    28  *
    29  * @since 0.3
    30  */
    31 function xmlsm_init() {
    32     global $wp_version;
     23add_action( 'init', array( 'XMLSitemapsManager\Load', 'front' ), 9 );
     24add_action( 'admin_init', array( 'XMLSitemapsManager\Load', 'admin' ) );
    3325
    34     // Skip this if we're in the admin.
    35     if ( is_admin() ) {
    36         return;
    37     }
    38 
    39     if ( ! get_option( 'xmlsm_sitemaps_enabled', true ) ) {
    40         // Disable all sitemaps.
    41         add_action( 'wp_sitemaps_enabled', '__return_false' );
    42 
    43         // And skip the rest.
    44         return;
    45     }
    46 
    47     /**
    48      * XML Sitemaps Manager: Fixes
    49      *
    50      * Patch bugs:
    51      * - 404 response code on certain sitemaps. @see https://core.trac.wordpress.org/ticket/51912
    52      * - don't set is_home() true. @see https://core.trac.wordpress.org/ticket/51542
    53      * - don't execute main query. @see https://core.trac.wordpress.org/ticket/51117
    54      * - ignore stickyness. @see https://core.trac.wordpress.org/ticket/55633 (pre-6.1)
    55      *
    56      * Add features:
    57      * - is_sitemap() conditional tag. @see https://core.trac.wordpress.org/ticket/51543
    58      * - is_sitemap_stylesheet() conditional tag for good measure.
    59      *
    60      * Improve performance:
    61      * - Shave off 4 database queries from post type sitemap requests.
    62      * - Shave off 5 database queries from the sitemap index request.
    63      * - Shave off N database queries from taxonomy sitemap requests, where N is the number of terms in that taxonomy.
    64      *   See https://core.trac.wordpress.org/ticket/55239 (pre-6.0)
    65      * - Shave off 12 database queries from user sitemap requests.
    66      *
    67      * @package XML Sitemaps Manager
    68      * @since 1.0
    69      */
    70     if ( get_option( 'xmlsm_sitemaps_fixes', true ) ) {
    71         // Include pluggable functions.
    72         include __DIR__ . '/src/pluggable.php';
    73 
    74         add_action( 'parse_request', 'wp_sitemaps_loaded' );
    75 
    76         if ( version_compare( $wp_version, '6.1', '<' ) ) {
    77             add_filter( 'wp_sitemaps_posts_query_args', array( 'XMLSitemapsManager\Fixes', 'posts_query_args' ) );
    78         }
    79         if ( version_compare( $wp_version, '6.0', '<' ) ) {
    80             add_filter( 'wp_sitemaps_taxonomies_query_args', array( 'XMLSitemapsManager\Fixes', 'taxonomies_query_args' ) );
    81         }
    82     }
    83 
    84     // Maximum URLs per sitemap.
    85     add_filter( 'wp_sitemaps_max_urls', array( 'XMLSitemapsManager\Core', 'max_urls' ), 10, 2 );
    86     // Exclude sitemap providers.
    87     add_filter( 'wp_sitemaps_add_provider', array( 'XMLSitemapsManager\Core', 'exclude_providers' ), 10, 2 );
    88     // Exclude post types. TODO Fix.
    89     add_filter( 'wp_sitemaps_post_types', array( 'XMLSitemapsManager\Core', 'exclude_post_types' ) );
    90     // Exclude taxonomies. TODO Fix.
    91     add_filter( 'wp_sitemaps_taxonomies', array( 'XMLSitemapsManager\Core', 'exclude_taxonomies' ) );
    92     // Filter stylesheet.
    93     add_filter( 'wp_sitemaps_stylesheet_css', array( 'XMLSitemapsManager\Core', 'stylesheet' ) );
    94 
    95     // Usage info for debugging.
    96     if ( WP_DEBUG ) {
    97         include_once __DIR__ . '/src/debugging.php';
    98     }
    99 
    100     /**
    101      * Add sitemaps.
    102      */
    103 
    104     // TODO.
    105 
    106     /**
    107      * Add lastmod.
    108      */
    109     if ( get_option( 'xmlsm_lastmod' ) ) {
    110         // Add lastmod to the index.
    111         add_filter( 'wp_sitemaps_index_entry', array( 'XMLSitemapsManager\Lastmod', 'index_entry' ), 10, 4 );
    112         add_filter( 'wp_sitemaps_posts_query_args', array( 'XMLSitemapsManager\Lastmod', 'posts_query_args' ) );
    113         // To post entries.
    114         add_filter( 'wp_sitemaps_posts_entry', array( 'XMLSitemapsManager\Lastmod', 'posts_entry' ), 10, 3 );
    115         add_filter( 'wp_sitemaps_posts_show_on_front_entry', array( 'XMLSitemapsManager\Lastmod', 'posts_show_on_front_entry' ) );
    116         // To term entries.
    117         add_filter( 'wp_sitemaps_taxonomies_entry', array( 'XMLSitemapsManager\Lastmod', 'taxonomies_entry' ), 10, 4 );
    118         add_action( 'transition_post_status', array( 'XMLSitemapsManager\Lastmod', 'update_term_modified_meta' ), 10, 3 );
    119         add_filter( 'wp_sitemaps_taxonomies_query_args', array( 'XMLSitemapsManager\Lastmod', 'taxonomies_query_args' ) );
    120         // To user entries.
    121         add_filter( 'wp_sitemaps_users_entry', array( 'XMLSitemapsManager\Lastmod', 'users_entry' ), 10, 2 );
    122         add_action( 'transition_post_status', array( 'XMLSitemapsManager\Lastmod', 'update_user_modified_meta' ), 10, 3 );
    123         add_filter( 'wp_sitemaps_users_query_args', array( 'XMLSitemapsManager\Lastmod', 'users_query_args' ) );
    124         // Compatibility.
    125         if ( function_exists( 'pll_languages_list' ) ) {
    126             add_filter( 'xmlsm_index_entry_subtype', array( 'XMLSitemapsManager\Compat\Polylang', 'index_entry_subtype' ) );
    127             add_filter( 'xmlsm_lastmod_user_meta_key', array( 'XMLSitemapsManager\Compat\Polylang', 'lastmod_meta_key' ), 10, 2 );
    128             add_filter( 'xmlsm_lastmod_index_entry', array( 'XMLSitemapsManager\Compat\Polylang', 'lastmod_index_entry' ), 10, 3 );
    129         }
    130     }
    131 }
    132 
    133 add_action( 'init', 'xmlsm_init', 9 );
    134 
    135 /**
    136  * Plugin admin intitialization.
    137  *
    138  * Can be disabled with remove_action('admin_init','xmlsm_admin_init').
    139  *
    140  * @since 0.3
    141  */
    142 function xmlsm_admin_init() {
    143     /**
    144      * Register settings.
    145      */
    146     XMLSitemapsManager\Admin::register_settings();
    147 
    148     /**
    149      * Tools actions.
    150      */
    151     // Compatibility.
    152     if ( function_exists( 'pll_languages_list' ) ) {
    153         add_action( 'xmlsm_clear_lastmod_meta', array( 'XMLSitemapsManager\Compat\Polylang', 'clear_lastmod_meta' ) );
    154     }
    155     XMLSitemapsManager\Admin::tools_actions();
    156 
    157     /**
    158      * Plugin action links.
    159      */
    160     add_filter( 'plugin_action_links_' . XMLSM_BASENAME, array( 'XMLSitemapsManager\Admin', 'add_action_link' ) );
    161     add_filter( 'plugin_row_meta', array( 'XMLSitemapsManager\Admin', 'plugin_meta_links' ), 10, 2 );
    162 }
    163 
    164 add_action( 'admin_init', 'xmlsm_admin_init' );
    165 
    166 /**
    167  * Plugin updater.
    168  *
    169  * @since 0.3
    170  */
    171 function xmlsm_maybe_upgrade() {
    172     // Maybe upgrade or install.
    173     $db_version = get_option( 'xmlsm_version', '0' );
    174     if ( 0 !== version_compare( XMLSM_VERSION, $db_version ) ) {
    175         include_once __DIR__ . '/upgrade.php';
    176     }
    177 }
    178 
    179 add_action( 'init', 'xmlsm_maybe_upgrade', 8 );
     26register_deactivation_hook( __FILE__, array( 'XMLSitemapsManager\Admin', 'deactivate' ) );
    18027
    18128/**
     
    18835 * @return void
    18936 */
    190 function xmlsm_autoloader( $class_name ) {
    191     // Skip this if not in our namespace.
    192     if ( 0 !== strpos( $class_name, 'XMLSitemapsManager' ) ) {
    193         return;
    194     }
     37\spl_autoload_register(
     38    function ( $class_name ) {
     39        // Skip this if not in our namespace.
     40        if ( 0 !== \strpos( $class_name, 'XMLSitemapsManager\\' ) ) {
     41            return;
     42        }
    19543
    196     // Replace namespace separators with directory separators in the relative
    197     // class name, prepend with class-, append with .php, build our file path.
    198     $class_name = str_replace( 'XMLSitemapsManager', 'src', $class_name );
    199     $class_name = strtolower( $class_name );
    200     $path_array = explode( '\\', $class_name );
    201     $file_name  = array_pop( $path_array );
    202     $file_name  = 'class-' . $file_name . '.php';
    203     $file       = __DIR__ . DIRECTORY_SEPARATOR . implode( DIRECTORY_SEPARATOR, $path_array ) . DIRECTORY_SEPARATOR . $file_name;
     44        // Replace namespace separators with directory separators in the relative
     45        // class name, prepend with class-, append with .php, build our file path.
     46        $class_name = \str_replace( 'XMLSitemapsManager', 'includes', $class_name );
     47        $class_name = \strtolower( $class_name );
     48        $path_array = \explode( '\\', $class_name );
     49        $file_name  = 'class-' . \array_pop( $path_array ) . '.php';
     50        $file       = __DIR__ .\DIRECTORY_SEPARATOR . \implode( \DIRECTORY_SEPARATOR, $path_array ) . \DIRECTORY_SEPARATOR . $file_name;
    20451
    205     // If the file exists, inlcude it.
    206     if ( file_exists( $file ) ) {
    207         include $file;
    208     }
    209 }
    210 
    211 spl_autoload_register( 'xmlsm_autoloader' );
     52        // If the file exists, inlcude it.
     53        if ( \file_exists( $file ) ) {
     54            include $file;
     55        }
     56    }
     57);
Note: See TracChangeset for help on using the changeset viewer.