Skip to content

Commit

Permalink
Closes #256
Browse files Browse the repository at this point in the history
  • Loading branch information
sybrew committed Jul 30, 2018
1 parent 281c4fa commit 80c713d
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 38 deletions.
2 changes: 1 addition & 1 deletion autodescription.php
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: The SEO Framework
* Plugin URI: https://theseoframework.com/
* Description: An automated, advanced, accessible, unbranded and extremely fast SEO solution for any WordPress website.
* Version: 3.1.0-dev-2018.07.30.0
* Version: 3.1.0-dev-2018.07.30.1
* Author: Sybre Waaijer
* Author URI: https://theseoframework.com/
* License: GPLv3
Expand Down
9 changes: 5 additions & 4 deletions bootstrap/upgrade.php
Expand Up @@ -299,12 +299,11 @@ function the_seo_framework_do_upgrade_3101() {

$tsf->update_option( 'title_separator', $tsf->get_option( 'title_seperator' ) );

$tsf->update_option( 'sitemap_query_limit', 1200 );

// Prevent database lookups when checking for cache.
add_option( THE_SEO_FRAMEWORK_SITE_CACHE, [] );

// Might they've missed it half a year ago, here it is again.
the_seo_framework_prepare_extension_manager_suggestion();

if ( $tsf->get_option( 'attachment_noindex' ) ) {
$_option = $tsf->get_robots_post_type_option_id( 'noindex' );
$_value = $tsf->get_option( $_option ) ?: [];
Expand All @@ -316,7 +315,6 @@ function the_seo_framework_do_upgrade_3101() {
$_value = $tsf->get_option( $_option ) ?: [];
$_value['attachment'] = 1;
$tsf->update_option( $_option, $_value );

}
if ( $tsf->get_option( 'attachment_noarchive' ) ) {
$_option = $tsf->get_robots_post_type_option_id( 'noarchive' );
Expand All @@ -325,5 +323,8 @@ function the_seo_framework_do_upgrade_3101() {
$tsf->update_option( $_option, $_value );
}

// Might they've missed it half a year ago, here it is again.
the_seo_framework_prepare_extension_manager_suggestion();

update_option( 'the_seo_framework_upgraded_db_version', '3101' );
}
35 changes: 34 additions & 1 deletion inc/classes/sanitize.class.php
Expand Up @@ -206,7 +206,7 @@ public function init_sanitizer_filters() {
[
'homepage_title',
'homepage_title_tagline',
'homepage_og_description',
'homepage_og_title',
'homepage_twitter_title',
]
);
Expand Down Expand Up @@ -471,6 +471,14 @@ public function init_sanitizer_filters() {
]
);

$this->add_option_filter(
's_min_max_sitemap',
$this->settings_field,
[
'sitemap_query_limit',
]
);

$init = true;
}

Expand Down Expand Up @@ -642,6 +650,7 @@ protected function get_available_filters() {
's_twitter_name' => [ $this, 's_twitter_name' ],
's_twitter_card' => [ $this, 's_twitter_card' ],
's_canonical_scheme' => [ $this, 's_canonical_scheme' ],
's_min_max_sitemap' => [ $this, 's_min_max_sitemap' ],
];

/**
Expand Down Expand Up @@ -1459,6 +1468,30 @@ public function s_canonical_scheme( $new_value ) {
return 'automatic';
}

/**
* Sanitizes sitemap's min/max post value.
*
* @since 3.1.0
*
* @param int $new_value Integer with potentially unwanted values.
* @return int A limited integer 1<=R<=20000.
*/
public function s_min_max_sitemap( $new_value ) {

$new_value = $this->s_absint( $new_value );

if ( ! $new_value ) {
// We assume something's wrong. Return default value.
$new_value = $this->get_default_option( 'sitemap_query_limit' );
} elseif ( $new_value < 1 ) {
$new_value = 1;
} elseif ( $new_value > 20000 ) {
$new_value = 20000;
}

return $new_value;
}

/**
* Sanitizeses ID. Mainly removing spaces and coding characters.
*
Expand Down
21 changes: 13 additions & 8 deletions inc/classes/site-options.class.php
Expand Up @@ -255,14 +255,19 @@ public function get_default_site_options() {
'knowledge_tumblr' => '', // Tumblr Account

// Sitemaps.
'sitemaps_output' => 1, // Output of sitemaps
'sitemaps_modified' => 1, // Add sitemaps modified time
'sitemaps_robots' => 1, // Add sitemaps location to robots.txt
'ping_google' => 1, // Ping Google
'ping_bing' => 1, // Ping Bing
'ping_yandex' => 1, // Ping Yandex
'sitemap_styles' => 1, // Whether to style the sitemap
'sitemap_logo' => 1, // Whether to add logo to sitemap
'sitemaps_output' => 1, // Output of sitemap
'sitemap_query_limit' => 1200, // Sitemap post limit.

'sitemaps_modified' => 1, // Add sitemap modified time

'sitemaps_robots' => 1, // Add sitemap location to robots.txt

'ping_google' => 1, // Ping Google
'ping_bing' => 1, // Ping Bing
'ping_yandex' => 1, // Ping Yandex

'sitemap_styles' => 1, // Whether to style the sitemap
'sitemap_logo' => 1, // Whether to add logo to sitemap
'sitemap_color_main' => '333', // Sitemap main color
'sitemap_color_accent' => '00cd98', // Sitemap accent color

Expand Down
6 changes: 2 additions & 4 deletions inc/classes/sitemaps.class.php
Expand Up @@ -623,12 +623,10 @@ protected function generate_sitemap() {
/**
* @since 2.2.9
* @since 2.8.0 Increased to 1200 from 700.
* @since 3.1.0 1. Now acts as a cumulative limit, rather than an individual limit (TODO)
* 2. Increased to 3600 from 1200 (TODO)
* 3. Now listens to an option. (TODO)
* @since 3.1.0 Now returns an option value.
* @param int $total_post_limit
*/
$total_post_limit = (int) \apply_filters( 'the_seo_framework_sitemap_post_limit', 1200 );
$total_post_limit = (int) \apply_filters( 'the_seo_framework_sitemap_post_limit', $this->get_option( 'sitemap_query_limit' ) );

/**
* Maximum pages and posts to fetch.
Expand Down
21 changes: 19 additions & 2 deletions inc/views/metaboxes/sitemaps-metabox.php
Expand Up @@ -81,8 +81,7 @@
echo '<hr>';
endif;

$this->description( __( 'The Sitemap is an XML file that lists pages and posts for your website along with optional metadata about each post or page. This helps search engines crawl your website more easily.', 'autodescription' ) );
$this->description( __( 'The optional metadata include the post and page modified time and a page priority indication, which is automated.', 'autodescription' ) );
$this->description( __( 'The sitemap is an XML file that lists posts from your website along with additional metadata. This helps search engines crawl your website more easily.', 'autodescription' ) );
?>
<hr>

Expand All @@ -104,6 +103,24 @@
/* translators: %s = here */
$this->description_noesc( sprintf( esc_html__( 'The sitemap can be found %s.', 'autodescription' ), $here ) );
}

?>
<hr>

<p>
<label for="<?php $this->field_id( 'sitemap_query_limit' ); ?>">
<strong><?php esc_html_e( 'Sitemap Query Limit', 'autodescription' ); ?></strong>
</label>
</p>
<?php
$this->description( __( 'The sitemap is generated with three queries: Pages, Posts, and other Post Types. This setting affects how many posts are requested from the database per query. The home and blog pages are included separately.', 'autodescription' ) );
?>
<p>
<input type="number" min=1 max=20000 name="<?php $this->field_name( 'sitemap_query_limit' ); ?>" id="<?php $this->field_id( 'sitemap_query_limit' ); ?>" placeholder="<?php echo $this->get_default_option( 'sitemap_query_limit' ); ?>" value="<?php echo absint( $this->get_option( 'sitemap_query_limit' ) ); ?>" />
</p>
<?php
$this->description( __( 'Consider lowering this value when the sitemap fails to generate.', 'autodescription' ) );

break;

case 'the_seo_framework_sitemaps_metabox_robots':
Expand Down
29 changes: 11 additions & 18 deletions readme.txt
Expand Up @@ -334,11 +334,6 @@ TODO: Regression: HTML tags are now stripped from singular post types. This is d
* Open Graph description.
* Twitter Title.
* Twitter description.
* TODO A title check is added next to every title field. (or the SEO bar... a red title tsunami)
* TODO It informs you when your theme uses outdated standards, and that you should use the Title Fix extension.
* TODO consider using methods that are used in Theme Check.
* TODO make sure it's in a non-expiring transient that might store a md5 checksum value of the theme file, which is cleared on theme switch or update. TODO rethink this... we shouldn't hinder performance, and not all PHP installations allow file reading.
* TODO make sure it checks for Title Fix' presence.
* New robots options that allow setting robots for each post type.
* These robots settings are applied to the whole custom post type, including its terms.
* The "noindex" settings also remove the post type from the sitemap.
Expand All @@ -349,12 +344,15 @@ TODO: Regression: HTML tags are now stripped from singular post types. This is d
* Pages that are protected now correctly state their indexing status.
* When the Blog Page is empty, and when it's not the home page, it'll show a "noindex" notification.
* Post types that have robots settings applied, now show them via appropriate notifications.
* Post Type Settings:
* New post type settings:
* Found in the General Settings meta box, they'll prevent The SEO Framework from interacting.
* These settings should only be used on conflicting post types, like which offer their own SEO settings, or are otherwise incorrectly registered.
* New sitemap settings:
* Set the maximum posts queried per type.
* The sitemap stylesheet now outputs favicon meta tags.
* When you activate any plugin, a check will be performed for conflicting SEO plugins; when found, a single dismissible warning notification will be outputted.
* Only users with plugin activation capabilities can see this message.
* Breadcrumbs are now rendered on non-hierarchival pages, too.
* **Improved:**
* The plugin can now downgrade its database version to the currently installed version automatically. This makes sure necessary future upgrade procedures are reinstated when you choose to downgrade (for any reason).
* Since TSF v3.0.6 this happens when a user saved the options, but this could lead to inconsistent behavior on WordPress Multisite installations.
Expand All @@ -363,10 +361,10 @@ TODO: Regression: HTML tags are now stripped from singular post types. This is d
* Code and URL input types (Twitter profile, Webmasters' verification codes) now always flow from left to right, even if your site's written language setting is otherwise.
* Tooltip arrows now always follow your mouse, for a more natural look.
* Tooltips now support RTL screens without the arrow overflowing.
* Canonical, redirect, and image URLs are no longer uselessly suggested by the browser.
* Canonical, redirect, and image URLs are no longer uselessly suggested by the browser for the administrative input fields.
* The Facebook Business page URL description has been updated, to be in line with the current behavior.
* TODO Open Graph data validation (e.g. missing descriptions).
* The main plugin's cache is now flushed after the SEO settings are requested to be updated, even when the options didn't change.
* The main plugin's cache is now flushed after the SEO settings are requested to be updated, even when the options aren't changed.
* The automated scheme detection can now prevent the sitemap from using, and caching, the wrong scheme.
* A lot of verbatim regarding various settings, to make it more clear what they do, and when they do it.
* The sitemap and stylesheet URLs should no longer be shown in the search results of search engines.
Expand All @@ -386,8 +384,7 @@ TODO: Regression: HTML tags are now stripped from singular post types. This is d
* The primary term selector tooltip now states the human readible and translatable name, instead of the static code name.
* WC Shop and Blog Pages now have "rel=prev/next" canonical URLs added when link relationship tags are enabled for archives.
* WC Shop and Blog Pages now listen to the global pagination robots' "noindex" settings.
* Long URLs are now truncated in the sitemap stylesheet. This does not affect the sitemap.
* Breadcrumbs are now rendered on non-hierarchival pages, too.
* Long URLs are now truncated in the sitemap stylesheet. This does not affect the sitemap itself, nor how search engines see the URLs.
* "Plausibly" embeddable URLs are now removed from the autogenerated descriptions. "Plausibly" because we don't extensively test the URLs for embeddability.
* Plugin conflict notices are now shown in red.
* Home page setting notifications are now always showing when applicable.
Expand Down Expand Up @@ -487,11 +484,12 @@ TODO: Regression: HTML tags are now stripped from singular post types. This is d
* `(string) homepage_og_description`
* `(string) homepage_twitter_title`
* `(string) homepage_twitter_description`
* `(int) sitemap_query_limit`
* The sitemap xsl stylesheet now has its colors defined in various `xsl:variable` elements. It's also completely reconfigurable via hooks.
* The plugin now initializes options cache. For instance, when the plugin's activated a temporarily value will be set that it did.
* **Improved:**
* A "doing it wrong" notice is now supplied when calling `the_seo_framework()` too early.
* Fixed all "non-passive event listener" warnings caused by jQuery, by using our own event handlers.
* Fixed all "non-passive event listener" warnings caused by jQuery, by using our improved own event handlers.
* The "doing it wrong" notice on "too early" query calls now shows the query-class method called.
* **Changed:**
* The title generation has been overhauled.
Expand All @@ -500,7 +498,6 @@ TODO: Regression: HTML tags are now stripped from singular post types. This is d
* The auto-invoked API still works as intended, via CSS.
* [JavaScript]: Media handlers are now instanced via their own object named `window.tsfMedia`, eliminating the previous JS API.
* [JavaScript]: Primary Term handlers are now instanced via their own object named `window.tsfPT`, eliminating the previous JS API.
* TODO Open Graph and Twitter meta rendering has been compressed into a single function, so we can apply conditions more easily.
* The WordPress filter `pre_ent2ncr` can now run on filter `the_seo_framework_sitemap_additional_urls`.
* The WordPress filter `single_post_title` is now used for singular post titles.
* Query caching is now disabled in WP_CLI.
Expand Down Expand Up @@ -634,6 +631,7 @@ TODO: Regression: HTML tags are now stripped from singular post types. This is d
* `sanitize_field_id()`
* `s_disabled_post_types()`
* `s_post_types()`
* `s_min_max_sitemap()`
* `strip_newline_urls()`
* `strip_paragraph_urls()`
* In class `\The_SEO_Framework\Site_Options` -- Factory: `the_seo_framework()`
Expand Down Expand Up @@ -844,8 +842,6 @@ TODO: Regression: HTML tags are now stripped from singular post types. This is d
* `css_name`
* `js_name`
* `page_base_file`
* In class: `\The_SEO_Framework\Admin_Pages` -- Factory: `the_seo_framework()`
* TODO `page_defaults`
* In class: `\The_SEO_Framework\Cache` -- Factory: `the_seo_framework()`
* `theme_doing_it_right_transient`
* In class: `\The_SEO_Framework\Load` -- Factory: `the_seo_framework()`
Expand Down Expand Up @@ -876,10 +872,7 @@ TODO: Regression: HTML tags are now stripped from singular post types. This is d
* `the_seo_framework_detect_page_builder`
1. Now returns `null` by default.
2. Now, when a boolean (either true or false) is defined, it'll short-circuit this function. See [this comment](https://github.com/sybrew/the-seo-framework/issues/279#issuecomment-392735509) for more information.
* TODO `the_seo_framework_sitemap_post_limit` TODO it's already documented in the code...
1. Now affects all posts.
2. Increased to 3600 from 1200
3. Now listens to an option.
* `the_seo_framework_sitemap_post_limit` now returns an option value.
* `the_seo_framework_custom_post_type_support` is now checked on presence. This is cached. If your filter is added too late, it won't work.
* `the_seo_framework_sitemap_color_main`, it now reflects the main color, instead of the accent color.
* `the_seo_framework_sitemap_color_accent`, it now reflects the accent color, instead of the main color.
Expand Down

0 comments on commit 80c713d

Please sign in to comment.