Файловый менеджер - Редактировать - /home/barrin16/ilaaup.org/saiga/classic-maintenance.tar
Назад
LICENSE 0000644 00000043254 14740033413 0005560 0 ustar 00 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. readme.txt 0000644 00000020474 14740033413 0006550 0 ustar 00 === Core Sitemaps === Contributors: joemcgill, pacifika, kburgoine, tweetythierry, swissspidy, pbiron Tags: seo, sitemaps Requires at least: 5.4 Tested up to: 5.5 Requires PHP: 5.6 Stable tag: 0.4.3 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html A feature plugin to integrate basic XML Sitemaps in WordPress Core. == Description == **Note: This feature has been integrated into WordPress 5.5. If you run WordPress 5.5, you can freely disable this plugin.** As [originally proposed in June 2019](https://make.wordpress.org/core/2019/06/12/xml-sitemaps-feature-project-proposal/), this feature plugin seeks to integrate basic XML Sitemaps functionality in WordPress Core. A short explanation of how this plugin works can be found on [this make/core blog post](https://make.wordpress.org/core/2020/01/27/feature-plugin-xml-sitemaps/). Interested in contributing to this plugin? Feel free to [join us on GitHub](https://github.com/GoogleChromeLabs/wp-sitemaps) and the [#core-sitemaps](https://wordpress.slack.com/archives/CTKTGNJJW) Slack channel. === Available Hooks and Filters === **General:** * `wp_sitemaps_enabled` - Filters whether XML Sitemaps are enabled or not. * `wp_sitemaps_max_urls` - Filters the maximum number of URLs displayed on a sitemap. * `wp_sitemaps_register_providers` - Filters the list of registered sitemap providers. * `wp_sitemaps_init` - Fires when initializing sitemaps. * `wp_sitemaps_index_entry` - Filters the sitemap entry for the sitemap index. **Providers:** * `wp_sitemaps_post_types` - Filters the list of post types to include in the sitemaps. * `wp_sitemaps_posts_entry` - Filters the sitemap entry for an individual post. * `wp_sitemaps_posts_show_on_front_entry` - Filters the sitemap entry for the home page when the 'show_on_front' option equals 'posts'. * `wp_sitemaps_posts_query_args` - Filters the query arguments for post type sitemap queries. * `wp_sitemaps_posts_pre_url_list` - Filters the posts URL list before it is generated (short-circuit). * `wp_sitemaps_posts_pre_max_num_pages` - Filters the max number of pages before it is generated (short-circuit). * `wp_sitemaps_taxonomies` - Filters the list of taxonomies to include in the sitemaps. * `wp_sitemaps_taxonomies_entry` - Filters the sitemap entry for an individual term. * `wp_sitemaps_taxonomies_query_args` - Filters the query arguments for taxonomy terms sitemap queries. * `wp_sitemaps_taxonomies_pre_url_list` - Filters the taxonomies URL list before it is generated (short-circuit). * `wp_sitemaps_taxonomies_pre_max_num_pages` - Filters the max number of pages before it is generated (short-circuit). * `wp_sitemaps_users_entry` - Filters the sitemap entry for an individual user. * `wp_sitemaps_users_query_args` - Filters the query arguments for user sitemap queries. * `wp_sitemaps_users_pre_url_list` - Filters the users URL list before it is generated (short-circuit). * `wp_sitemaps_users_pre_max_num_pages` - Filters the max number of pages before it is generated (short-circuit). **Stylesheets:** * `wp_sitemaps_stylesheet_css` - Filters the CSS for the sitemap stylesheet. * `wp_sitemaps_stylesheet_url` - Filters the URL for the sitemap stylesheet. * `wp_sitemaps_stylesheet_content` - Filters the content of the sitemap stylesheet. * `wp_sitemaps_stylesheet_index_url` - Filters the URL for the sitemap index stylesheet. * `wp_sitemaps_stylesheet_index_content` - Filters the content of the sitemap index stylesheet. == Installation == = Installation from within WordPress = 1. Visit **Plugins > Add New**. 2. Search for **Core Sitemaps**. 3. Install and activate the Core Sitemaps plugin. = Manual installation = 1. Upload the entire `core-sitemaps` folder to the `/wp-content/plugins/` directory. 2. Visit **Plugins**. 3. Activate the Core Sitemaps plugin. == Frequently Asked Questions == = How can I fully disable sitemap generation? = If you update the WordPress settings to discourage search engines from indexing your site, sitemaps will be disabled. Alternatively, use the `wp_sitemaps_enabled` filter, or use `remove_action( 'init', 'wp_sitemaps_get_server' );` to disable initialization of any sitemap functionality. = How can I disable sitemaps for a certain object type? = You can use the `wp_sitemaps_register_providers` filter to disable sitemap generation for posts, users, or taxonomies. = How can I disable sitemaps for a certain post type or taxonomy? = You can use the `wp_sitemaps_post_types` filter to disable sitemap generation for posts of a certain post type. By default, only public posts will be represented in the sitemap. Similarly, the `wp_sitemaps_taxonomies` filter can be used to disable sitemap generation for certain taxonomies. **Example: Disabling sitemaps for the "page" post type** ` add_filter( 'wp_sitemaps_post_types', function( $post_types ) { unset( $post_types['page'] ); return $post_types; } ); ` **Example: Disabling sitemaps for the "post_tag" taxonomy** ` add_filter( 'wp_sitemaps_taxonomies', function( $taxonomies ) { unset( $taxonomies['post_tag'] ); return $taxonomies; } ); ` = How can I exclude certain posts / taxonomies / users from the sitemap or add custom ones? = The `wp_sitemaps_posts_query_args`, `wp_sitemaps_taxonomies_query_args`, and `wp_sitemaps_users_query_args` filters can be used to modify the underlying queries. Using these queries, certain items can be excluded. **Example: Ensuring the page with ID 42 is not included** ` add_filter( 'wp_sitemaps_posts_query_args', function( $args ) { $args['post__not_in'] = isset( $args['post__not_in'] ) ? $args['post__not_in'] : array(); $args['post__not_in'][] = 42; return $args; } ); ` **Example: Ensuring the category with ID 7 is not included** ` add_filter( 'wp_sitemaps_taxonomies_query_args', function( $args ) { $args['exclude'] = isset( $args['exclude'] ) ? $args['exclude'] : array(); $args['exclude'][] = 7; return $args; } ); ` **Example: Ensuring the user with ID 1 is not included** ` add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $args['exclude'] = isset( $args['exclude'] ) ? $args['exclude'] : array(); $args['exclude'][] = 1; return $args; } ); ` = How can I add `changefreq`, `priority`, or `lastmod` to a sitemap? = You can use the `wp_sitemaps_posts_entry` / `wp_sitemaps_users_entry` / `wp_sitemaps_taxonomies_entry` filters to add additional attributes like `changefreq`, `priority`, or `lastmod` to single item in the sitemap. **Example: Adding the last modified date for posts** ` add_filter( 'wp_sitemaps_posts_entry', function( $entry, $post ) { $entry['lastmod'] = $post->post_modified_gmt; return $entry; }, 10, 2 ); ` Similarly, you can use the `wp_sitemaps_index_entry` filter to add `lastmod` on the sitemap index. Note: `changefreq` and `priority` are not supported on the sitemap index. = How can I add image sitemaps? = Adding image sitemaps are not supported yet, but support will be added in the future so that plugin developers can add them if needed. = How can I change the number of URLs per sitemap? = Use the `wp_sitemaps_max_urls` filter to adjust the maximum number of URLs included in a sitemap. The default value is 2000 URLs. = How can I change the appearance of the XML sitemaps in the browser using XSL? = A variety of filters exist to allow you to adjust the styling: * `wp_sitemaps_stylesheet_url` - Filter the URL for the sitemap stylesheet. * `wp_sitemaps_stylesheet_index_url` - Filter the URL for the sitemap index stylesheet. * `wp_sitemaps_stylesheet_content` - Filter the content of the sitemap stylesheet. * `wp_sitemaps_index_stylesheet_content` - Filter the content of the sitemap index stylesheet. * `wp_sitemaps_stylesheet_css` - Filter the CSS only for the sitemap stylesheet. = Does this plugin support `changefreq` and `priority` attributes for sitemaps? = No. Those are optional fields in the sitemaps protocol and not typically consumed by search engines. Developers can still add those fields if they really want to. = Why is there no last modified date shown in the sitemap? = XML sitemaps are first and foremost a discovery mechanism for content. Exposing the date the content was last modified is not needed for the majority of sites. == Changelog == For the plugin's changelog, please check out the full list of changes [on GitHub](https://github.com/GoogleChromeLabs/wp-sitemaps/blob/master/CHANGELOG.md). inc/class-wp-sitemaps-provider.php 0000644 00000010622 14740033413 0013232 0 ustar 00 <?php /** * Sitemaps: WP_Sitemaps_Provider class * * This class is a base class for other sitemap providers to extend and contains shared functionality. * * @package WordPress * @subpackage Sitemaps * @since 5.5.0 */ /** * Class WP_Sitemaps_Provider. * * @since 5.5.0 */ abstract class WP_Sitemaps_Provider { /** * Provider name. * * This will also be used as the public-facing name in URLs. * * @since 5.5.0 * * @var string */ protected $name = ''; /** * Object type name (e.g. 'post', 'term', 'user'). * * @since 5.5.0 * * @var string */ protected $object_type = ''; /** * Gets a URL list for a sitemap. * * @since 5.5.0 * * @param int $page_num Page of results. * @param string $object_subtype Optional. Object subtype name. Default empty. * @return array $url_list Array of URLs for a sitemap. */ abstract public function get_url_list( $page_num, $object_subtype = '' ); /** * Gets the max number of pages available for the object type. * * @since 5.5.0 * * @param string $object_subtype Optional. Object subtype. Default empty. * @return int Total number of pages. */ abstract public function get_max_num_pages( $object_subtype = '' ); /** * Gets data about each sitemap type. * * @since 5.5.0 * * @return array List of sitemap types including object subtype name and number of pages. */ public function get_sitemap_type_data() { $sitemap_data = array(); $object_subtypes = $this->get_object_subtypes(); // If there are no object subtypes, include a single sitemap for the // entire object type. if ( empty( $object_subtypes ) ) { $sitemap_data[] = array( 'name' => '', 'pages' => $this->get_max_num_pages(), ); return $sitemap_data; } // Otherwise, include individual sitemaps for every object subtype. foreach ( $object_subtypes as $object_subtype_name => $data ) { $object_subtype_name = (string) $object_subtype_name; $sitemap_data[] = array( 'name' => $object_subtype_name, 'pages' => $this->get_max_num_pages( $object_subtype_name ), ); } return $sitemap_data; } /** * Lists sitemap pages exposed by this provider. * * The returned data is used to populate the sitemap entries of the index. * * @since 5.5.0 * * @return array List of sitemaps. */ public function get_sitemap_entries() { $sitemaps = array(); $sitemap_types = $this->get_sitemap_type_data(); foreach ( $sitemap_types as $type ) { for ( $page = 1; $page <= $type['pages']; $page ++ ) { $sitemap_entry = array( 'loc' => $this->get_sitemap_url( $type['name'], $page ), ); /** * Filters the sitemap entry for the sitemap index. * * @since 5.5.0 * * @param array $sitemap_entry Sitemap entry for the post. * @param string $object_type Object empty name. * @param string $object_subtype Object subtype name. * Empty string if the object type does not support subtypes. * @param string $page Page of results. */ $sitemap_entry = apply_filters( 'wp_sitemaps_index_entry', $sitemap_entry, $this->object_type, $type['name'], $page ); $sitemaps[] = $sitemap_entry; } } return $sitemaps; } /** * Gets the URL of a sitemap entry. * * @since 5.5.0 * * @param string $name The name of the sitemap. * @param int $page The page of the sitemap. * @return string The composed URL for a sitemap entry. */ public function get_sitemap_url( $name, $page ) { /* @var WP_Rewrite $wp_rewrite */ global $wp_rewrite; if ( ! $wp_rewrite->using_permalinks() ) { return add_query_arg( // Accounts for cases where name is not included, ex: sitemaps-users-1.xml. array_filter( array( 'sitemap' => $this->name, 'sitemap-sub-type' => $name, 'paged' => $page, ) ), home_url( '/' ) ); } $basename = sprintf( '/wp-sitemap-%1$s.xml', implode( '-', // Accounts for cases where name is not included, ex: sitemaps-users-1.xml. array_filter( array( $this->name, $name, (string) $page, ) ) ) ); return home_url( $basename ); } /** * Returns the list of supported object subtypes exposed by the provider. * * @since 5.5.0 * * @return array List of object subtypes objects keyed by their name. */ public function get_object_subtypes() { return array(); } } inc/class-wp-sitemaps.php 0000644 00000016106 14740033413 0011405 0 ustar 00 <?php /** * Sitemaps: WP_Sitemaps class * * This is the main class integrating all other classes. * * @package WordPress * @subpackage Sitemaps * @since 5.5.0 */ /** * Class WP_Sitemaps. * * @since 5.5.0 */ class WP_Sitemaps { /** * The main index of supported sitemaps. * * @since 5.5.0 * * @var WP_Sitemaps_Index */ public $index; /** * The main registry of supported sitemaps. * * @since 5.5.0 * * @var WP_Sitemaps_Registry */ public $registry; /** * An instance of the renderer class. * * @since 5.5.0 * * @var WP_Sitemaps_Renderer */ public $renderer; /** * WP_Sitemaps constructor. * * @since 5.5.0 */ public function __construct() { $this->registry = new WP_Sitemaps_Registry(); $this->renderer = new WP_Sitemaps_Renderer(); $this->index = new WP_Sitemaps_Index( $this->registry ); } /** * Initiates all sitemap functionality. * * @since 5.5.0 */ public function init() { // These will all fire on the init hook. $this->register_sitemaps(); // Add additional action callbacks. add_action( 'wp_sitemaps_init', array( $this, 'register_rewrites' ) ); add_action( 'template_redirect', array( $this, 'render_sitemaps' ) ); add_action( 'wp_loaded', array( $this, 'maybe_flush_rewrites' ) ); add_filter( 'pre_handle_404', array( $this, 'redirect_sitemapxml' ), 10, 2 ); add_filter( 'robots_txt', array( $this, 'add_robots' ), 0, 2 ); add_filter( 'redirect_canonical', array( $this, 'redirect_canonical' ) ); } /** * Registers and sets up the functionality for all supported sitemaps. * * @since 5.5.0 */ public function register_sitemaps() { /** * Filters the list of registered sitemap providers. * * @since 5.5.0 * * @param array $providers { * Array of WP_Sitemaps_Provider objects keyed by their name. * * @type object $posts The WP_Sitemaps_Posts object. * @type object $taxonomies The WP_Sitemaps_Taxonomies object. * @type object $users The WP_Sitemaps_Users object. * } */ $providers = apply_filters( 'wp_sitemaps_register_providers', array( 'posts' => new WP_Sitemaps_Posts(), 'taxonomies' => new WP_Sitemaps_Taxonomies(), 'users' => new WP_Sitemaps_Users(), ) ); // Register each supported provider. /* @var WP_Sitemaps_Provider $provider */ foreach ( $providers as $name => $provider ) { $this->registry->add_sitemap( $name, $provider ); } } /** * Registers sitemap rewrite tags and routing rules. * * @since 5.5.0 */ public function register_rewrites() { // Add rewrite tags. add_rewrite_tag( '%sitemap%', '([^?]+)' ); add_rewrite_tag( '%sitemap-sub-type%', '([^?]+)' ); // Register index route. add_rewrite_rule( '^wp-sitemap\.xml$', 'index.php?sitemap=index', 'top' ); // Register rewrites for the XSL stylesheet. add_rewrite_tag( '%sitemap-stylesheet%', '([^?]+)' ); add_rewrite_rule( '^wp-sitemap\.xsl$', 'index.php?sitemap-stylesheet=sitemap', 'top' ); add_rewrite_rule( '^wp-sitemap-index\.xsl$', 'index.php?sitemap-stylesheet=index', 'top' ); // Register routes for providers. add_rewrite_rule( '^wp-sitemap-([a-z]+?)-([a-z\d_-]+?)-(\d+?)\.xml$', 'index.php?sitemap=$matches[1]&sitemap-sub-type=$matches[2]&paged=$matches[3]', 'top' ); add_rewrite_rule( '^wp-sitemap-([a-z]+?)-(\d+?)\.xml$', 'index.php?sitemap=$matches[1]&paged=$matches[2]', 'top' ); } /** * Un-registers sitemap rewrite tags and routing rules. * * @since 5.5.0 */ public function unregister_rewrites() { /* @var WP_Rewrite $wp_rewrite */ global $wp_rewrite; // Unregister index route. unset( $wp_rewrite->extra_rules_top['^wp-sitemap\.xml$'] ); // Unregister rewrites for the XSL stylesheet. unset( $wp_rewrite->extra_rules_top['^wp-sitemap\.xsl$'] ); unset( $wp_rewrite->extra_rules_top['^wp-sitemap-index\.xsl$'] ); // Unregister routes for providers. unset( $wp_rewrite->extra_rules_top['^wp-sitemap-([a-z]+?)-([a-z\d-]+?)-(\d+?)\.xml$'] ); unset( $wp_rewrite->extra_rules_top['^wp-sitemap-([a-z]+?)-(\d+?)\.xml$'] ); } /** * Flushes rewrite rules if developers updated them. * * @since 5.5.0 */ public function maybe_flush_rewrites() { if ( update_option( 'wp_sitemaps_rewrite_version', WP_SITEMAPS_REWRITE_VERSION ) ) { flush_rewrite_rules( false ); } } /** * Renders sitemap templates based on rewrite rules. * * @since 5.5.0 */ public function render_sitemaps() { global $wp_query; $sitemap = sanitize_text_field( get_query_var( 'sitemap' ) ); $object_subtype = sanitize_text_field( get_query_var( 'sitemap-sub-type' ) ); $stylesheet_type = sanitize_text_field( get_query_var( 'sitemap-stylesheet' ) ); $paged = absint( get_query_var( 'paged' ) ); // Bail early if this isn't a sitemap or stylesheet route. if ( ! ( $sitemap || $stylesheet_type ) ) { return; } // Render stylesheet if this is stylesheet route. if ( $stylesheet_type ) { $stylesheet = new WP_Sitemaps_Stylesheet(); $stylesheet->render_stylesheet( $stylesheet_type ); exit; } // Render the index. if ( 'index' === $sitemap ) { $sitemap_list = $this->index->get_sitemap_list(); $this->renderer->render_index( $sitemap_list ); exit; } $provider = $this->registry->get_sitemap( $sitemap ); if ( ! $provider ) { return; } if ( empty( $paged ) ) { $paged = 1; } $url_list = $provider->get_url_list( $paged, $object_subtype ); // Force a 404 and bail early if no URLs are present. if ( empty( $url_list ) ) { $wp_query->set_404(); return; } $this->renderer->render_sitemap( $url_list ); exit; } /** * Redirects a URL to the wp-sitemap.xml * * @since 5.5.0 * * @param bool $bypass Pass-through of the pre_handle_404 filter value. * @param WP_Query $query The WP_Query object. * @return bool Bypass value. */ public function redirect_sitemapxml( $bypass, $query ) { // If a plugin has already utilized the pre_handle_404 function, return without action to avoid conflicts. if ( $bypass ) { return $bypass; } // 'pagename' is for most permalink types, name is for when the %postname% is used as a top-level field. if ( 'sitemap-xml' === $query->get( 'pagename' ) || 'sitemap-xml' === $query->get( 'name' ) ) { wp_safe_redirect( $this->index->get_index_url() ); exit(); } return $bypass; } /** * Adds the sitemap index to robots.txt. * * @since 5.5.0 * * @param string $output robots.txt output. * @param bool $public Whether the site is public or not. * @return string The robots.txt output. */ public function add_robots( $output, $public ) { if ( $public ) { $output .= "\nSitemap: " . esc_url( $this->index->get_index_url() ) . "\n"; } return $output; } /** * Prevent trailing slashes. * * @since 5.5.0 * * @param string $redirect The redirect URL currently determined. * @return bool|string $redirect The canonical redirect URL. */ public function redirect_canonical( $redirect ) { if ( get_query_var( 'sitemap' ) || get_query_var( 'sitemap-stylesheet' ) ) { return false; } return $redirect; } } inc/class-wp-sitemaps-renderer.php 0000644 00000015270 14740033413 0013212 0 ustar 00 <?php /** * Sitemaps: WP_Sitemaps_Renderer class * * Responsible for rendering Sitemaps data to XML in accordance with sitemap protocol. * * @package WordPress * @subpackage Sitemaps * @since 5.5.0 */ /** * Class WP_Sitemaps_Renderer * * @since 5.5.0 */ class WP_Sitemaps_Renderer { /** * XSL stylesheet for styling a sitemap for web browsers. * * @since 5.5.0 * * @var string */ protected $stylesheet = ''; /** * XSL stylesheet for styling a sitemap for web browsers. * * @since 5.5.0 * * @var string */ protected $stylesheet_index = ''; /** * WP_Sitemaps_Renderer constructor. * * @since 5.5.0 */ public function __construct() { $stylesheet_url = $this->get_sitemap_stylesheet_url(); if ( $stylesheet_url ) { $this->stylesheet = '<?xml-stylesheet type="text/xsl" href="' . esc_url( $stylesheet_url ) . '" ?>'; } $stylesheet_index_url = $this->get_sitemap_index_stylesheet_url(); if ( $stylesheet_index_url ) { $this->stylesheet_index = '<?xml-stylesheet type="text/xsl" href="' . esc_url( $stylesheet_index_url ) . '" ?>'; } } /** * Gets the URL for the sitemap stylesheet. * * @since 5.5.0 * * @return string The sitemap stylesheet url. */ public function get_sitemap_stylesheet_url() { /* @var WP_Rewrite $wp_rewrite */ global $wp_rewrite; $sitemap_url = home_url( '/wp-sitemap.xsl' ); if ( ! $wp_rewrite->using_permalinks() ) { $sitemap_url = add_query_arg( 'sitemap-stylesheet', 'sitemap', home_url( '/' ) ); } /** * Filters the URL for the sitemap stylesheet. * * If a falsy value is returned, no stylesheet will be used and * the "raw" XML of the sitemap will be displayed. * * @since 5.5.0 * * @param string $sitemap_url Full URL for the sitemaps xsl file. */ return apply_filters( 'wp_sitemaps_stylesheet_url', $sitemap_url ); } /** * Gets the URL for the sitemap index stylesheet. * * @since 5.5.0 * * @return string The sitemap index stylesheet url. */ public function get_sitemap_index_stylesheet_url() { /* @var WP_Rewrite $wp_rewrite */ global $wp_rewrite; $sitemap_url = home_url( '/wp-sitemap-index.xsl' ); if ( ! $wp_rewrite->using_permalinks() ) { $sitemap_url = add_query_arg( 'sitemap-stylesheet', 'index', home_url( '/' ) ); } /** * Filters the URL for the sitemap index stylesheet. * * If a falsy value is returned, no stylesheet will be used and * the "raw" XML of the sitemap index will be displayed. * * @since 5.5.0 * * @param string $sitemap_url Full URL for the sitemaps index xsl file. */ return apply_filters( 'wp_sitemaps_stylesheet_index_url', $sitemap_url ); } /** * Renders a sitemap index. * * @since 5.5.0 * * @param array $sitemaps Array of sitemap URLs. */ public function render_index( $sitemaps ) { header( 'Content-type: application/xml; charset=UTF-8' ); $this->check_for_simple_xml_availability(); $index_xml = $this->get_sitemap_index_xml( $sitemaps ); if ( ! empty( $index_xml ) ) { // All output is escaped within get_sitemap_index_xml(). // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $index_xml; } } /** * Gets XML for a sitemap index. * * @since 5.5.0 * * @param array $sitemaps Array of sitemap URLs. * @return string|false A well-formed XML string for a sitemap index. False on error. */ public function get_sitemap_index_xml( $sitemaps ) { $sitemap_index = new SimpleXMLElement( sprintf( '%1$s%2$s%3$s', '<?xml version="1.0" encoding="UTF-8" ?>', $this->stylesheet_index, '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />' ) ); foreach ( $sitemaps as $entry ) { $sitemap = $sitemap_index->addChild( 'sitemap' ); // Add each element as a child node to the <sitemap> entry. foreach ( $entry as $name => $value ) { if ( 'loc' === $name ) { $sitemap->addChild( $name, esc_url( $value ) ); } elseif ( 'lastmod' === $name ) { $sitemap->addChild( $name, esc_xml( $value ) ); } else { _doing_it_wrong( __METHOD__, /* translators: %s: list of element names */ sprintf( __( 'Fields other than %s are not currently supported for the sitemap index.', 'core-sitemaps' ), implode( ',', array( 'loc', 'lastmod' ) ) ), '5.5.0' ); } } } return $sitemap_index->asXML(); } /** * Renders a sitemap. * * @since 5.5.0 * * @param array $url_list Array of URLs for a sitemap. */ public function render_sitemap( $url_list ) { header( 'Content-type: application/xml; charset=UTF-8' ); $this->check_for_simple_xml_availability(); $sitemap_xml = $this->get_sitemap_xml( $url_list ); if ( ! empty( $sitemap_xml ) ) { // All output is escaped within get_sitemap_xml(). // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $sitemap_xml; } } /** * Gets XML for a sitemap. * * @since 5.5.0 * * @param array $url_list Array of URLs for a sitemap. * @return string|false A well-formed XML string for a sitemap index. False on error. */ public function get_sitemap_xml( $url_list ) { $urlset = new SimpleXMLElement( sprintf( '%1$s%2$s%3$s', '<?xml version="1.0" encoding="UTF-8" ?>', $this->stylesheet, '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />' ) ); foreach ( $url_list as $url_item ) { $url = $urlset->addChild( 'url' ); // Add each element as a child node to the <url> entry. foreach ( $url_item as $name => $value ) { if ( 'loc' === $name ) { $url->addChild( $name, esc_url( $value ) ); } elseif ( in_array( $name, array( 'lastmod', 'changefreq', 'priority' ), true ) ) { $url->addChild( $name, esc_xml( $value ) ); } else { _doing_it_wrong( __METHOD__, /* translators: %s: list of element names */ sprintf( __( 'Fields other than %s are not currently supported for sitemaps.', 'core-sitemaps' ), implode( ',', array( 'loc', 'lastmod', 'changefreq', 'priority' ) ) ), '5.5.0' ); } } } return $urlset->asXML(); } /** * Checks for the availability of the SimpleXML extension and errors if missing. * * @since 5.5.0 */ private function check_for_simple_xml_availability() { if ( ! class_exists( 'SimpleXMLElement' ) ) { add_filter( 'wp_die_handler', static function () { return '_xml_wp_die_handler'; } ); wp_die( sprintf( /* translators: %s: SimpleXML */ esc_xml( __( 'Could not generate XML sitemap due to missing %s extension', 'core-sitemaps' ) ), 'SimpleXML' ), esc_xml( __( 'WordPress › Error', 'core-sitemaps' ) ), array( 'response' => 501, // "Not implemented". ) ); } } } inc/class-wp-sitemaps-registry.php 0000644 00000003104 14740033413 0013245 0 ustar 00 <?php /** * Sitemaps: WP_Sitemaps_Registry class * * Handles registering sitemaps. * * @package WordPress * @subpackage Sitemaps * @since 5.5.0 */ /** * Class WP_Sitemaps_Registry. * * @since 5.5.0 */ class WP_Sitemaps_Registry { /** * Registered sitemaps. * * @since 5.5.0 * * @var array Array of registered sitemaps. */ private $sitemaps = array(); /** * Adds a sitemap with route to the registry. * * @since 5.5.0 * * @param string $name Name of the sitemap. * @param WP_Sitemaps_Provider $provider Instance of a WP_Sitemaps_Provider. * @return bool True if the sitemap was added, false if it is already registered. */ public function add_sitemap( $name, WP_Sitemaps_Provider $provider ) { if ( isset( $this->sitemaps[ $name ] ) ) { return false; } $this->sitemaps[ $name ] = $provider; return true; } /** * Returns a single registered sitemaps provider. * * @since 5.5.0 * * @param string $name Sitemap provider name. * @return WP_Sitemaps_Provider|null Sitemaps provider if it exists, null otherwise. */ public function get_sitemap( $name ) { if ( ! isset( $this->sitemaps[ $name ] ) ) { return null; } return $this->sitemaps[ $name ]; } /** * Lists all registered sitemaps. * * @since 5.5.0 * * @return array List of sitemaps. */ public function get_sitemaps() { $total_sitemaps = count( $this->sitemaps ); if ( $total_sitemaps > WP_SITEMAPS_MAX_SITEMAPS ) { return array_slice( $this->sitemaps, 0, WP_SITEMAPS_MAX_SITEMAPS, true ); } return $this->sitemaps; } } inc/providers/class-wp-sitemaps-taxonomies.php 0000644 00000011606 14740033413 0015606 0 ustar 00 <?php /** * Sitemaps: WP_Sitemaps_Taxonomies class * * Builds the sitemaps for the 'taxonomy' object type. * * @package WordPress * @subpackage Sitemaps * @since 5.5.0 */ /** * Taxonomies XML sitemap provider. * * @since 5.5.0 */ class WP_Sitemaps_Taxonomies extends WP_Sitemaps_Provider { /** * WP_Sitemaps_Taxonomies constructor. * * @since 5.5.0 */ public function __construct() { $this->name = 'taxonomies'; $this->object_type = 'term'; } /** * Returns all public, registered taxonomies. * * @since 5.5.0 * * @return array Map of registered taxonomy objects keyed by their name. */ public function get_object_subtypes() { $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' ); /** * Filter the list of taxonomy object subtypes available within the sitemap. * * @since 5.5.0 * * @param array $taxonomies Map of registered taxonomy objects keyed by their name. */ return apply_filters( 'wp_sitemaps_taxonomies', $taxonomies ); } /** * Gets a URL list for a taxonomy sitemap. * * @since 5.5.0 * * @param int $page_num Page of results. * @param string $taxonomy Optional. Taxonomy name. Default empty. * @return array $url_list Array of URLs for a sitemap. */ public function get_url_list( $page_num, $taxonomy = '' ) { $supported_types = $this->get_object_subtypes(); // Bail early if the queried taxonomy is not supported. if ( ! isset( $supported_types[ $taxonomy ] ) ) { return array(); } /** * Filters the taxonomies URL list before it is generated. * * Passing a non-null value will effectively short-circuit the generation, * returning that value instead. * * @since 5.5.0 * * @param array $url_list The URL list. Default null. * @param string $taxonomy Taxonomy name. * @param int $page_num Page of results. */ $url_list = apply_filters( 'wp_sitemaps_taxonomies_pre_url_list', null, $taxonomy, $page_num ); if ( null !== $url_list ) { return $url_list; } $url_list = array(); // Offset by how many terms should be included in previous pages. $offset = ( $page_num - 1 ) * wp_sitemaps_get_max_urls( $this->object_type ); $args = $this->get_taxonomies_query_args( $taxonomy ); $args['offset'] = $offset; $taxonomy_terms = new WP_Term_Query( $args ); if ( ! empty( $taxonomy_terms->terms ) ) { foreach ( $taxonomy_terms->terms as $term ) { $sitemap_entry = array( 'loc' => get_term_link( $term ), ); /** * Filters the sitemap entry for an individual term. * * @since 5.5.0 * * @param array $sitemap_entry Sitemap entry for the term. * @param WP_Term $term Term object. * @param string $taxonomy Taxonomy name. */ $sitemap_entry = apply_filters( 'wp_sitemaps_taxonomies_entry', $sitemap_entry, $term, $taxonomy ); $url_list[] = $sitemap_entry; } } return $url_list; } /** * Gets the max number of pages available for the object type. * * @since 5.5.0 * * @param string $taxonomy Taxonomy name. * @return int Total number of pages. */ public function get_max_num_pages( $taxonomy = '' ) { if ( empty( $taxonomy ) ) { return 0; } /** * Filters the max number of pages before it is generated. * * Passing a non-null value will effectively short-circuit the generation, * returning that value instead. * * @since 5.5.0 * * @param int $max_num_pages The maximum number of pages. Default null. * @param string $taxonomy Taxonomy name. */ $max_num_pages = apply_filters( 'wp_sitemaps_taxonomies_pre_max_num_pages', null, $taxonomy ); if ( null !== $max_num_pages ) { return $max_num_pages; } $term_count = wp_count_terms( $taxonomy, $this->get_taxonomies_query_args( $taxonomy ) ); return (int) ceil( $term_count / wp_sitemaps_get_max_urls( $this->object_type ) ); } /** * Returns the query args for retrieving taxonomy terms to list in the sitemap. * * @since 5.5.0 * * @param string $taxonomy Taxonomy name. * @return array $args Array of WP_Term_Query arguments. */ protected function get_taxonomies_query_args( $taxonomy ) { /** * Filters the taxonomy terms query arguments. * * Allows modification of the taxonomy query arguments before querying. * * @see WP_Term_Query for a full list of arguments * * @since 5.5.0 * * @param array $args Array of WP_Term_Query arguments. * @param string $taxonomy Taxonomy name. */ $args = apply_filters( 'wp_sitemaps_taxonomies_query_args', array( 'fields' => 'ids', 'taxonomy' => $taxonomy, 'orderby' => 'term_order', 'number' => wp_sitemaps_get_max_urls( $this->object_type ), 'hide_empty' => true, 'hierarchical' => false, 'update_term_meta_cache' => false, ), $taxonomy ); return $args; } } inc/providers/class-wp-sitemaps-posts.php 0000644 00000013225 14740033413 0014567 0 ustar 00 <?php /** * Sitemaps: WP_Sitemaps_Posts class * * Builds the sitemaps for the 'post' object type. * * @package WordPress * @subpackage Sitemaps * @since 5.5.0 */ /** * Posts XML sitemap provider. * * @since 5.5.0 */ class WP_Sitemaps_Posts extends WP_Sitemaps_Provider { /** * WP_Sitemaps_Posts constructor. * * @since 5.5.0 */ public function __construct() { $this->name = 'posts'; $this->object_type = 'post'; } /** * Returns the public post types, which excludes nav_items and similar types. * Attachments are also excluded. This includes custom post types with public = true. * * @since 5.5.0 * * @return array Map of registered post type objects (WP_Post_Type) keyed by their name. */ public function get_object_subtypes() { $post_types = get_post_types( array( 'public' => true ), 'objects' ); unset( $post_types['attachment'] ); /** * Filters the list of post object subtypes available within the sitemap. * * @since 5.5.0 * * @param array $post_types Map of registered post type objects (WP_Post_Type) keyed by their name. */ return apply_filters( 'wp_sitemaps_post_types', $post_types ); } /** * Gets a URL list for a post type sitemap. * * @since 5.5.0 * * @param int $page_num Page of results. * @param string $post_type Optional. Post type name. Default empty. * @return array $url_list Array of URLs for a sitemap. */ public function get_url_list( $page_num, $post_type = '' ) { // Bail early if the queried post type is not supported. $supported_types = $this->get_object_subtypes(); if ( ! isset( $supported_types[ $post_type ] ) ) { return array(); } /** * Filters the posts URL list before it is generated. * * Passing a non-null value will effectively short-circuit the generation, * returning that value instead. * * @since 5.5.0 * * @param array $url_list The URL list. Default null. * @param string $post_type Post type name. * @param int $page_num Page of results. */ $url_list = apply_filters( 'wp_sitemaps_posts_pre_url_list', null, $post_type, $page_num ); if ( null !== $url_list ) { return $url_list; } $args = $this->get_posts_query_args( $post_type ); $args['paged'] = $page_num; $query = new WP_Query( $args ); /** * Returns an array of posts. * * @var array<int, \WP_Post> $posts */ $posts = $query->get_posts(); $url_list = array(); /* * Add a URL for the homepage in the pages sitemap. * Shows only on the first page if the reading settings are set to display latest posts. */ if ( 'page' === $post_type && 1 === $page_num && 'posts' === get_option( 'show_on_front' ) ) { // Extract the data needed for home URL to add to the array. $sitemap_entry = array( 'loc' => home_url(), ); /** * Filters the sitemap entry for the home page when the 'show_on_front' option equals 'posts'. * * @since 5.5.0 * * @param array $sitemap_entry Sitemap entry for the home page. */ $sitemap_entry = apply_filters( 'wp_sitemaps_posts_show_on_front_entry', $sitemap_entry ); $url_list[] = $sitemap_entry; } foreach ( $posts as $post ) { $sitemap_entry = array( 'loc' => get_permalink( $post ), ); /** * Filters the sitemap entry for an individual post. * * @since 5.5.0 * * @param array $sitemap_entry Sitemap entry for the post. * @param WP_Post $post Post object. * @param string $post_type Name of the post_type. */ $sitemap_entry = apply_filters( 'wp_sitemaps_posts_entry', $sitemap_entry, $post, $post_type ); $url_list[] = $sitemap_entry; } return $url_list; } /** * Gets the max number of pages available for the object type. * * @since 5.5.0 * * @param string $post_type Optional. Post type name. Default empty. * @return int Total number of pages. */ public function get_max_num_pages( $post_type = '' ) { if ( empty( $post_type ) ) { return 0; } /** * Filters the max number of pages before it is generated. * * Passing a non-null value will effectively short-circuit the generation, * returning that value instead. * * @since 5.5.0 * * @param int $max_num_pages The maximum number of pages. Default null. * @param string $post_type Post type name. */ $max_num_pages = apply_filters( 'wp_sitemaps_posts_pre_max_num_pages', null, $post_type ); if ( null !== $max_num_pages ) { return $max_num_pages; } $args = $this->get_posts_query_args( $post_type ); $args['fields'] = 'ids'; $args['no_found_rows'] = false; $query = new WP_Query( $args ); return isset( $query->max_num_pages ) ? $query->max_num_pages : 1; } /** * Returns the query args for retrieving posts to list in the sitemap. * * @since 5.5.0 * * @param string $post_type Post type name. * @return array $args Array of WP_Query arguments. */ protected function get_posts_query_args( $post_type ) { /** * Filters the query arguments for post type sitemap queries. * * @see WP_Query for a full list of arguments. * * @since 5.5.0 * * @param array $args Array of WP_Query arguments. * @param string $post_type Post type name. */ $args = apply_filters( 'wp_sitemaps_posts_query_args', array( 'orderby' => 'ID', 'order' => 'ASC', 'post_type' => $post_type, 'posts_per_page' => wp_sitemaps_get_max_urls( $this->object_type ), 'post_status' => array( 'publish' ), 'no_found_rows' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, ), $post_type ); return $args; } } inc/providers/class-wp-sitemaps-users.php 0000644 00000007771 14740033413 0014571 0 ustar 00 <?php /** * Sitemaps: WP_Sitemaps_Users class * * Builds the sitemaps for the 'user' object type. * * @package WordPress * @subpackage Sitemaps * @since 5.5.0 */ /** * Users XML sitemap provider. * * @since 5.5.0 */ class WP_Sitemaps_Users extends WP_Sitemaps_Provider { /** * WP_Sitemaps_Users constructor. * * @since 5.5.0 */ public function __construct() { $this->name = 'users'; $this->object_type = 'user'; } /** * Gets a URL list for a user sitemap. * * @since 5.5.0 * * @param int $page_num Page of results. * @param string $object_subtype Optional. Not applicable for Users but * required for compatibility with the parent * provider class. Default empty. * @return array $url_list Array of URLs for a sitemap. */ public function get_url_list( $page_num, $object_subtype = '' ) { /** * Filters the users URL list before it is generated. * * Passing a non-null value will effectively short-circuit the generation, * returning that value instead. * * @since 5.5.0 * * @param array $url_list The URL list. Default null. * @param int $page_num Page of results. */ $url_list = apply_filters( 'wp_sitemaps_users_pre_url_list', null, $page_num ); if ( null !== $url_list ) { return $url_list; } $args = $this->get_users_query_args(); $args['paged'] = $page_num; $query = new WP_User_Query( $args ); $users = $query->get_results(); $url_list = array(); foreach ( $users as $user ) { $sitemap_entry = array( 'loc' => get_author_posts_url( $user->ID ), ); /** * Filters the sitemap entry for an individual user. * * @since 5.5.0 * * @param array $sitemap_entry Sitemap entry for the user. * @param WP_User $user User object. */ $sitemap_entry = apply_filters( 'wp_sitemaps_users_entry', $sitemap_entry, $user ); $url_list[] = $sitemap_entry; } return $url_list; } /** * Gets the max number of pages available for the object type. * * @since 5.5.0 * * @see WP_Sitemaps_Provider::max_num_pages * * @param string $object_subtype Optional. Not applicable for Users but * required for compatibility with the parent * provider class. Default empty. * @return int Total page count. */ public function get_max_num_pages( $object_subtype = '' ) { /** * Filters the max number of pages before it is generated. * * Passing a non-null value will effectively short-circuit the generation, * returning that value instead. * * @since 5.5.0 * * @param int $max_num_pages The maximum number of pages. Default null. */ $max_num_pages = apply_filters( 'wp_sitemaps_users_pre_max_num_pages', null ); if ( null !== $max_num_pages ) { return $max_num_pages; } $args = $this->get_users_query_args(); $query = new WP_User_Query( $args ); $total_users = $query->get_total(); return (int) ceil( $total_users / wp_sitemaps_get_max_urls( $this->object_type ) ); } /** * Returns the query args for retrieving users to list in the sitemap. * * @since 5.5.0 * * @return array $args Array of WP_User_Query arguments. */ protected function get_users_query_args() { $public_post_types = get_post_types( array( 'public' => true, ) ); // We're not supporting sitemaps for author pages for attachments. unset( $public_post_types['attachment'] ); /** * Filters the query arguments for authors with public posts. * * Allows modification of the authors query arguments before querying. * * @see WP_User_Query for a full list of arguments * * @since 5.5.0 * * @param array $args Array of WP_User_Query arguments. */ $args = apply_filters( 'wp_sitemaps_users_query_args', array( 'has_published_posts' => array_keys( $public_post_types ), 'number' => wp_sitemaps_get_max_urls( $this->object_type ), ) ); return $args; } } inc/class-wp-sitemaps-index.php 0000644 00000003244 14740033413 0012511 0 ustar 00 <?php /** * Sitemaps: WP_Sitemaps_Index class. * * Generates the sitemap index. * * @package WordPress * @subpackage Sitemaps * @since 5.5.0 */ /** * Class WP_Sitemaps_Index. * Builds the sitemap index page that lists the links to all of the sitemaps. * * @since 5.5.0 */ class WP_Sitemaps_Index { /** * The main registry of supported sitemaps. * * @since 5.5.0 * @var WP_Sitemaps_Registry */ protected $registry; /** * WP_Sitemaps_Index constructor. * * @since 5.5.0 * * @param WP_Sitemaps_Registry $registry Sitemap provider registry. */ public function __construct( WP_Sitemaps_Registry $registry ) { $this->registry = $registry; } /** * Gets a sitemap list for the index. * * @since 5.5.0 * * @return array List of all sitemaps. */ public function get_sitemap_list() { $sitemaps = array(); $providers = $this->registry->get_sitemaps(); /* @var WP_Sitemaps_Provider $provider */ foreach ( $providers as $provider ) { $sitemap_entries = $provider->get_sitemap_entries(); // Prevent issues with array_push and empty arrays on PHP < 7.3. if ( ! $sitemap_entries ) { continue; } // Using array_push is more efficient than array_merge in a loop. array_push( $sitemaps, ...$sitemap_entries ); } return $sitemaps; } /** * Builds the URL for the sitemap index. * * @since 5.5.0 * * @return string The sitemap index url. */ public function get_index_url() { /* @var WP_Rewrite $wp_rewrite */ global $wp_rewrite; $url = home_url( '/wp-sitemap.xml' ); if ( ! $wp_rewrite->using_permalinks() ) { $url = add_query_arg( 'sitemap', 'index', home_url( '/' ) ); } return $url; } } inc/functions.php 0000644 00000012660 14740033413 0010042 0 ustar 00 <?php /** * Sitemaps: Public functions * * This file contains a variety of public functions developers can use to interact with * the XML Sitemaps API. * * @package WordPress * @subpackage Sitemaps * @since 5.5.0 */ /** * Retrieves the current Sitemaps server instance. * * @since 5.5.0 * * @return WP_Sitemaps|null Sitemaps instance, or null if sitemaps are disabled. */ function wp_sitemaps_get_server() { /** * Global Core Sitemaps instance. * * @since 5.5.0 * * @var WP_Sitemaps $wp_sitemaps */ global $wp_sitemaps; $is_enabled = (bool) get_option( 'blog_public' ); /** * Filters whether XML Sitemaps are enabled or not. * * @since 5.5.0 * * @param bool $is_enabled Whether XML Sitemaps are enabled or not. Defaults to true for public sites. */ $is_enabled = (bool) apply_filters( 'wp_sitemaps_enabled', $is_enabled ); if ( ! $is_enabled ) { return null; } // If there isn't a global instance, set and bootstrap the sitemaps system. if ( empty( $wp_sitemaps ) ) { $wp_sitemaps = new WP_Sitemaps(); $wp_sitemaps->init(); /** * Fires when initializing the Sitemaps object. * * Additional sitemaps should be registered on this hook. * * @since 5.5.0 * * @param WP_Sitemaps $sitemaps Server object. */ do_action( 'wp_sitemaps_init', $wp_sitemaps ); } return $wp_sitemaps; } /** * Gets a list of sitemap providers. * * @since 5.5.0 * * @return array $sitemaps A list of registered sitemap providers. */ function wp_get_sitemaps() { $sitemaps = wp_sitemaps_get_server(); if ( ! $sitemaps ) { return array(); } return $sitemaps->registry->get_sitemaps(); } /** * Registers a new sitemap provider. * * @since 5.5.0 * * @param string $name Unique name for the sitemap provider. * @param WP_Sitemaps_Provider $provider The `Sitemaps_Provider` instance implementing the sitemap. * @return bool Returns true if the sitemap was added. False on failure. */ function wp_register_sitemap( $name, WP_Sitemaps_Provider $provider ) { $sitemaps = wp_sitemaps_get_server(); if ( ! $sitemaps ) { return false; } return $sitemaps->registry->add_sitemap( $name, $provider ); } /** * Gets the maximum number of URLs for a sitemap. * * @since 5.5.0 * * @param string $object_type Object type for sitemap to be filtered (e.g. 'post', 'term', 'user'). * @return int The maximum number of URLs. */ function wp_sitemaps_get_max_urls( $object_type ) { /** * Filters the maximum number of URLs displayed on a sitemap. * * @since 5.5.0 * * @param int $max_urls The maximum number of URLs included in a sitemap. Default 2000. * @param string $object_type Object type for sitemap to be filtered (e.g. 'post', 'term', 'user'). */ return apply_filters( 'wp_sitemaps_max_urls', WP_SITEMAPS_MAX_URLS, $object_type ); } if ( ! function_exists( 'esc_xml' ) ) : /** * Escaping for XML blocks. * * @since 5.5.0 * * @param string $text Text to escape. * @return string */ function esc_xml( $text ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals $safe_text = wp_check_invalid_utf8( $text ); $cdata_regex = '\<\!\[CDATA\[.*?\]\]\>'; $regex = <<<EOF / (?=.*?{$cdata_regex}) # lookahead that will match anything followed by a CDATA Section (?<non_cdata_followed_by_cdata>(.*?)) # the "anything" matched by the lookahead (?<cdata>({$cdata_regex})) # the CDATA Section matched by the lookahead | # alternative (?<non_cdata>(.*)) # non-CDATA Section /sx EOF; $safe_text = (string) preg_replace_callback( $regex, function( $matches ) { if ( ! $matches[0] ) { return ''; } elseif ( ! empty( $matches['non_cdata'] ) ) { // escape HTML entities in the non-CDATA Section. return _esc_xml_non_cdata_section( $matches['non_cdata'] ); } // Return the CDATA Section unchanged, escape HTML entities in the rest. return _esc_xml_non_cdata_section( $matches['non_cdata_followed_by_cdata'] ) . $matches['cdata']; }, $safe_text ); /** * Filters a string cleaned and escaped for output in XML. * * Text passed to esc_xml() is stripped of invalid or special characters * before output. HTML named character references are converted to their * equivalent code points. * * @since 5.5.0 * * @param string $safe_text The text after it has been escaped. * @param string $text The text prior to being escaped. */ return apply_filters( 'esc_xml', $safe_text, $text ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals } endif; if ( ! function_exists( '_esc_xml_non_cdata_section' ) ) : /** * Escaping for non-CDATA Section XML blocks. * * @access private * @since 5.5.0 * * @param string $text Text to escape. * @return string */ function _esc_xml_non_cdata_section( $text ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals global $allowedentitynames; $safe_text = _wp_specialchars( $text, ENT_QUOTES ); // Replace HTML entities with their Unicode codepoints, // without doing the same for the 5 XML entities. $html_only_entities = array_diff( $allowedentitynames, array( 'amp', 'lt', 'gt', 'apos', 'quot' ) ); $safe_text = (string) preg_replace_callback( '/&(' . implode( '|', $html_only_entities ) . ');/', function( $matches ) { return html_entity_decode( $matches[0], ENT_HTML5 ); }, $safe_text ); return $safe_text; } endif; inc/class-wp-sitemaps-stylesheet.php 0000644 00000020125 14740033413 0013570 0 ustar 00 <?php /** * Sitemaps: WP_Sitemaps_Stylesheet class * * This class provides the XSL stylesheets to style all sitemaps. * * @package WordPress * @subpackage Sitemaps * @since 5.5.0 */ /** * Stylesheet provider class. * * @since 5.5.0 */ class WP_Sitemaps_Stylesheet { /** * Renders the xsl stylesheet depending on whether its the sitemap index or not. * * @param string $type Stylesheet type. Either 'sitemap' or 'index'. */ public function render_stylesheet( $type ) { header( 'Content-type: application/xml; charset=UTF-8' ); if ( 'sitemap' === $type ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- All content escaped below. echo $this->get_sitemap_stylesheet(); } if ( 'index' === $type ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- All content escaped below. echo $this->get_sitemap_index_stylesheet(); } exit; } /** * Returns the escaped xsl for all sitemaps, except index. * * @since 5.5.0 */ public function get_sitemap_stylesheet() { $css = $this->get_stylesheet_css(); $title = esc_xml( __( 'XML Sitemap', 'core-sitemaps' ) ); $description = esc_xml( __( 'This XML Sitemap is generated by WordPress to make your content more visible for search engines.', 'core-sitemaps' ) ); $learn_more = sprintf( '<a href="%s">%s</a>', esc_url( __( 'https://www.sitemaps.org/', 'core-sitemaps' ) ), esc_xml( __( 'Learn more about XML sitemaps.', 'core-sitemaps' ) ) ); $text = sprintf( /* translators: %s: number of URLs. */ esc_xml( __( 'Number of URLs in this XML Sitemap: %s.', 'core-sitemaps' ) ), '<xsl:value-of select="count( sitemap:urlset/sitemap:url )" />' ); $lang = get_language_attributes( 'html' ); $url = esc_xml( __( 'URL', 'core-sitemaps' ) ); $lastmod = esc_xml( __( 'Last Modified', 'core-sitemaps' ) ); $changefreq = esc_xml( __( 'Change Frequency', 'core-sitemaps' ) ); $priority = esc_xml( __( 'Priority', 'core-sitemaps' ) ); $xsl_content = <<<XSL <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" exclude-result-prefixes="sitemap" > <xsl:output method="html" encoding="UTF-8" indent="yes"/> <!-- Set variables for whether lastmod, changefreq or priority occur for any url in the sitemap. We do this up front because it can be expensive in a large sitemap. --> <xsl:variable name="has-lastmod" select="count( /sitemap:urlset/sitemap:url/sitemap:lastmod )" /> <xsl:variable name="has-changefreq" select="count( /sitemap:urlset/sitemap:url/sitemap:changefreq )" /> <xsl:variable name="has-priority" select="count( /sitemap:urlset/sitemap:url/sitemap:priority )" /> <xsl:template match="/"> <html {$lang}> <head> <title>{$title}</title> <style>{$css}</style> </head> <body> <div id="sitemap__header"> <h1>{$title}</h1> <p>{$description}</p> <p>{$learn_more}</p> </div> <div id="sitemap__content"> <p class="text">{$text}</p> <table id="sitemap__table"> <thead> <tr> <th class="loc">{$url}</th> <xsl:if test="\$has-lastmod"> <th class="lastmod">{$lastmod}</th> </xsl:if> <xsl:if test="\$has-changefreq"> <th class="changefreq">{$changefreq}</th> </xsl:if> <xsl:if test="\$has-priority"> <th class="priority">{$priority}</th> </xsl:if> </tr> </thead> <tbody> <xsl:for-each select="sitemap:urlset/sitemap:url"> <tr> <td class="loc"><a href="{sitemap:loc}"><xsl:value-of select="sitemap:loc" /></a></td> <xsl:if test="\$has-lastmod"> <td class="lastmod"><xsl:value-of select="sitemap:lastmod" /></td> </xsl:if> <xsl:if test="\$has-changefreq"> <td class="changefreq"><xsl:value-of select="sitemap:changefreq" /></td> </xsl:if> <xsl:if test="\$has-priority"> <td class="priority"><xsl:value-of select="sitemap:priority" /></td> </xsl:if> </tr> </xsl:for-each> </tbody> </table> </div> </body> </html> </xsl:template> </xsl:stylesheet> XSL; /** * Filters the content of the sitemap stylesheet. * * @since 5.5.0 * * @param string $xsl Full content for the xml stylesheet. */ return apply_filters( 'wp_sitemaps_stylesheet_content', $xsl_content ); } /** * Returns the escaped xsl for the index sitemaps. * * @since 5.5.0 */ public function get_sitemap_index_stylesheet() { $css = $this->get_stylesheet_css(); $title = esc_xml( __( 'XML Sitemap', 'core-sitemaps' ) ); $description = esc_xml( __( 'This XML Sitemap is generated by WordPress to make your content more visible for search engines.', 'core-sitemaps' ) ); $learn_more = sprintf( '<a href="%s">%s</a>', esc_url( __( 'https://www.sitemaps.org/', 'core-sitemaps' ) ), esc_xml( __( 'Learn more about XML sitemaps.', 'core-sitemaps' ) ) ); $text = sprintf( /* translators: %s: number of URLs. */ esc_xml( __( 'Number of URLs in this XML Sitemap: %s.', 'core-sitemaps' ) ), '<xsl:value-of select="count( sitemap:sitemapindex/sitemap:sitemap )" />' ); $lang = get_language_attributes( 'html' ); $url = esc_xml( __( 'URL', 'core-sitemaps' ) ); $lastmod = esc_xml( __( 'Last Modified', 'core-sitemaps' ) ); $xsl_content = <<<XSL <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" exclude-result-prefixes="sitemap" > <xsl:output method="html" encoding="UTF-8" indent="yes" /> <!-- Set variables for whether lastmod occurs for any sitemap in the index. We do this up front because it can be expensive in a large sitemap. --> <xsl:variable name="has-lastmod" select="count( /sitemap:sitemapindex/sitemap:sitemap/sitemap:lastmod )" /> <xsl:template match="/"> <html {$lang}> <head> <title>{$title}</title> <style>{$css}</style> </head> <body> <div id="sitemap__header"> <h1>{$title}</h1> <p>{$description}</p> <p>{$learn_more}</p> </div> <div id="sitemap__content"> <p class="text">{$text}</p> <table id="sitemap__table"> <thead> <tr> <th class="loc">{$url}</th> <xsl:if test="\$has-lastmod"> <th class="lastmod">{$lastmod}</th> </xsl:if> </tr> </thead> <tbody> <xsl:for-each select="sitemap:sitemapindex/sitemap:sitemap"> <tr> <td class="loc"><a href="{sitemap:loc}"><xsl:value-of select="sitemap:loc" /></a></td> <xsl:if test="\$has-lastmod"> <td class="lastmod"><xsl:value-of select="sitemap:lastmod" /></td> </xsl:if> </tr> </xsl:for-each> </tbody> </table> </div> </body> </html> </xsl:template> </xsl:stylesheet> XSL; /** * Filters the content of the sitemap index stylesheet. * * @since 5.5.0 * * @param string $xsl Full content for the xml stylesheet. */ return apply_filters( 'wp_sitemaps_stylesheet_index_content', $xsl_content ); } /** * Gets the CSS to be included in sitemap XSL stylesheets. * * @since 5.5.0 * * @return string The CSS. */ public function get_stylesheet_css() { $css = ' body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; color: #444; } #sitemap__table { border: solid 1px #ccc; border-collapse: collapse; } #sitemap__table tr th { text-align: left; } #sitemap__table tr td, #sitemap__table tr th { padding: 10px; } #sitemap__table tr:nth-child(odd) td { background-color: #eee; } a:hover { text-decoration: none; }'; /** * Filters the css only for the sitemap stylesheet. * * @since 5.5.0 * * @param string $css CSS to be applied to default xsl file. */ return apply_filters( 'wp_sitemaps_stylesheet_css', $css ); } } core-sitemaps.php 0000644 00000004700 14740033413 0010030 0 ustar 00 <?php /** * Core Sitemaps Plugin. * * @package WordPress * @subpackage Sitemaps * @copyright 2019 The Core Sitemaps Contributors * @license GNU General Public License, version 2 * @link https://github.com/GoogleChromeLabs/wp-sitemaps * * Plugin Name: Core Sitemaps * Plugin URI: https://github.com/GoogleChromeLabs/wp-sitemaps * Description: A feature plugin to integrate basic XML Sitemaps in WordPress Core * Author: Core Sitemaps Plugin Contributors * Author URI: https://github.com/GoogleChromeLabs/wp-sitemaps/graphs/contributors * Text Domain: core-sitemaps * Domain Path: /languages * Requires at least: 5.4 * Requires PHP: 5.6 * Version: 0.4.3 */ // Do not load plugin if WordPress core already has sitemap support. if ( function_exists( 'wp_get_sitemaps' ) || function_exists( 'wp_get_sitemap_providers' ) ) { return; } // The limit for how many sitemaps to include in an index. const WP_SITEMAPS_MAX_SITEMAPS = 50000; const WP_SITEMAPS_REWRITE_VERSION = '2020-04-29'; // Limit the number of URLs included in a sitemap. if ( ! defined( 'WP_SITEMAPS_MAX_URLS' ) ) { define( 'WP_SITEMAPS_MAX_URLS', 2000 ); } require_once __DIR__ . '/inc/class-wp-sitemaps.php'; require_once __DIR__ . '/inc/class-wp-sitemaps-provider.php'; require_once __DIR__ . '/inc/class-wp-sitemaps-index.php'; require_once __DIR__ . '/inc/class-wp-sitemaps-registry.php'; require_once __DIR__ . '/inc/class-wp-sitemaps-renderer.php'; require_once __DIR__ . '/inc/class-wp-sitemaps-stylesheet.php'; require_once __DIR__ . '/inc/providers/class-wp-sitemaps-posts.php'; require_once __DIR__ . '/inc/providers/class-wp-sitemaps-taxonomies.php'; require_once __DIR__ . '/inc/providers/class-wp-sitemaps-users.php'; require_once __DIR__ . '/inc/functions.php'; // Boot the sitemaps system. add_action( 'init', 'wp_sitemaps_get_server' ); /** * Plugin activation hook. * * Adds and flushes rewrite rules. */ function wp_sitemaps_plugin_activation() { $sitemaps = new WP_Sitemaps(); $sitemaps->register_rewrites(); flush_rewrite_rules( false ); } register_activation_hook( __FILE__, 'wp_sitemaps_plugin_activation' ); /** * Plugin deactivation hook. * * Adds and flushes rewrite rules. */ function wp_sitemaps_plugin_deactivation() { $sitemaps = new WP_Sitemaps(); $sitemaps->unregister_rewrites(); flush_rewrite_rules( false ); } register_deactivation_hook( __FILE__, 'wp_sitemaps_plugin_deactivation' );
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка