Skip to content

Commit

Permalink
Now work with default values instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
sybrew committed Jul 16, 2024
1 parent 6e33186 commit 5bf612f
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 13 deletions.
2 changes: 1 addition & 1 deletion autodescription.php
Original file line number Diff line number Diff line change
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 your WordPress website.
* Version: 5.0.7-dev-11
* Version: 5.0.7-dev-12
* Author: The SEO Framework Team
* Author URI: https://theseoframework.com/
* License: GPLv3
Expand Down
6 changes: 3 additions & 3 deletions inc/classes/admin/script/ajax.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static function update_counter_type() {

Helper\Headers::clean_response_header();

// phpcs:disable, WordPress.Security.NonceVerification -- check_ajax_referer() does this.
// phpcs:disable, WordPress.Security.NonceVerification -- check_ajax_capability_referer() does this.
Utils::check_ajax_capability_referer( 'edit_posts' );

/**
Expand Down Expand Up @@ -150,7 +150,7 @@ public static function crop_image() {

Helper\Headers::clean_response_header();

// phpcs:disable, WordPress.Security.NonceVerification -- check_ajax_referer does this.
// phpcs:disable, WordPress.Security.NonceVerification -- check_ajax_capability_referer does this.
Utils::check_ajax_capability_referer( 'upload_files' );

if ( ! isset( $_POST['id'], $_POST['context'], $_POST['cropDetails'] ) )
Expand Down Expand Up @@ -267,7 +267,7 @@ public static function get_post_data() {

Helper\Headers::clean_response_header();

// phpcs:disable, WordPress.Security.NonceVerification -- check_ajax_referer() does this.
// phpcs:disable, WordPress.Security.NonceVerification -- check_ajax_capability_referer() does this.
Utils::check_ajax_capability_referer( 'edit_posts' );

$post_id = \absint( $_POST['post_id'] );
Expand Down
3 changes: 2 additions & 1 deletion inc/classes/data/plugin/post.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public static function get_meta_item( $item, $post_id = 0 ) {
* @since 5.0.0 1. Removed the third `$use_cache` parameter.
* 2. Moved from `\The_SEO_Framework\Load`.
* 3. Renamed from `get_post_meta`.
* @since 5.0.7 Now returns the default meta if the post type isn't supported.
*
* @param int $post_id The post ID.
* @return array The post meta.
Expand All @@ -108,7 +109,7 @@ public static function get_meta( $post_id = 0 ) {

// We test post type support for "post_query"-queries might get past this point.
if ( empty( $post_id ) || ! Post_Type::is_supported( \get_post( $post_id )->post_type ) )
return static::$meta_memo[ $post_id ] = [];
return static::$meta_memo[ $post_id ] = static::get_default_meta( $post_id );

// Keep lucky first when exceeding nice numbers. This way, we won't overload memory in memoization.
if ( \count( static::$meta_memo ) > 69 )
Expand Down
3 changes: 2 additions & 1 deletion inc/classes/data/plugin/pta.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public static function get_meta_item( $item, $post_type = '' ) {
* 2. Removed the second `$use_cache` parameter.
* 3. Moved from `\The_SEO_Framework\Load`.
* 4. Renamed from `get_post_type_archive_meta`.
* @since 5.0.7 Now returns the default meta if the PTA isn't supported.
*
* @param string $post_type The post type.
* @return array The post type archive's meta item's values.
Expand All @@ -105,7 +106,7 @@ public static function get_meta( $post_type = '' ) {

// We test post type support for "post_query"-queries might get past this point.
if ( empty( $post_type ) || ! Post_Type::is_supported( $post_type ) )
return static::$meta_memo[ $post_type ] = [];
return static::$meta_memo[ $post_type ] = static::get_default_meta( $post_type );

// Keep lucky first when exceeding nice numbers. This way, we won't overload memory in memoization.
if ( \count( static::$meta_memo ) > 69 )
Expand Down
3 changes: 2 additions & 1 deletion inc/classes/data/plugin/term.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public static function get_meta_item( $item, $term_id = 0 ) {
* @since 5.0.0 1. Removed the second `$use_cache` parameter.
* 2. Moved from `\The_SEO_Framework\Load`.
* 3. Renamed from `get_term_meta`.
* @since 5.0.7 Now returns the default meta if the term's taxonomy isn't supported.
*
* @param int $term_id The Term ID.
* @return array The term meta data.
Expand All @@ -100,7 +101,7 @@ public static function get_meta( $term_id = 0 ) {

// We test taxonomy support to be consistent with `get_post_meta()`.
if ( empty( $term_id ) || ! Taxonomy::is_supported( \get_term( $term_id )->taxonomy ?? '' ) )
return static::$meta_memo[ $term_id ] = [];
return static::$meta_memo[ $term_id ] = static::get_default_meta( $term_id );

// Keep lucky first when exceeding nice numbers. This way, we won't overload memory in memoization.
if ( \count( static::$meta_memo ) > 69 )
Expand Down
6 changes: 5 additions & 1 deletion inc/classes/data/plugin/user.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public static function get_meta_item( $item, $user_id = 0 ) {
* @since 5.0.0 1. Removed the second `$depr` and third `$use_cache` parameter.
* 2. Moved from `\The_SEO_Framework\Load`.
* 3. Renamed from `get_user_meta`.
* @since 5.0.7 Now returns the default meta if the user ID is empty.
*
* @param int $user_id The user ID.
* @return array The user SEO meta data.
Expand All @@ -131,8 +132,11 @@ public static function get_meta( $user_id = 0 ) {
if ( isset( static::$meta_memo[ $user_id ] ) )
return static::$meta_memo[ $user_id ];

// TODO test if user exists via get_userdata()?
// That is expensive; the user object is not created when fetching meta.
// But we might as well have a user already when we reach this point.
if ( empty( $user_id ) )
return static::$meta_memo[ $user_id ] = [];
return static::$meta_memo[ $user_id ] = static::get_default_meta( $user_id );

// Keep lucky first when exceeding nice numbers. This way, we won't overload memory in memoization.
if ( \count( static::$meta_memo ) > 69 )
Expand Down
4 changes: 2 additions & 2 deletions inc/classes/helper/headers.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
* Holds a collection of helper methods for HTTP Headers.
*
* @since 5.0.0
* @access private
* @access protected
* Use tsf()->headers() instead.
*/
class Headers {

Expand Down Expand Up @@ -60,7 +61,6 @@ public static function clean_response_header() {
* @hook do_robots 10
* @hook the_seo_framework_sitemap_header 10
* @since 5.0.0
* @access private
*/
public static function output_robots_noindex_headers() {
/**
Expand Down
4 changes: 2 additions & 2 deletions inc/traits/internal/static-deprecator.trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ final public function __call( $name, $arguments ) {
if ( $fallback )
return \call_user_func_array( $fallback, $arguments );
} else {
\tsf()->_inaccessible_p_or_m( \esc_html( "{$this->colloquial_handle}->$name()" ) );
\tsf()->_inaccessible_p_or_m( "{$this->colloquial_handle}->$name()" );
}
}

Expand All @@ -179,7 +179,7 @@ final public function __call( $name, $arguments ) {
* @param array $arguments The method arguments.
* @return void
*/
final public static function __callStatic( $name, $arguments ) {
final public static function __callStatic( $name, $arguments ) { // phpcs:ignore, VariableAnalysis.CodeAnalysis -- __callStatic must take 2 args.
\tsf()->_inaccessible_p_or_m(
\esc_html( "$name()" ),
'Method is of unknown pool. Do not call pool methods statically! A fatal error might follow.',
Expand Down
2 changes: 1 addition & 1 deletion inc/views/settings/wrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
</form>
</div>
<script>
window.addEventListener( 'load', () => {
addEventListener( 'load', () => {
postboxes.add_postbox_toggles( '<?= \esc_js( $hook_name ) ?>' );
} );
</script>
Expand Down
18 changes: 18 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,19 @@ TODO theoretical bug: The markdown search/replace could replace links incorrectl
TODO when zooming in with Chromium, the floating title for terms is vertically misaligned.
-> Only 125% seems to be affected, 150~225 not.

TODO add robots.txt settings
-> Specifically, to block ChatGPT bot.

TODO move tsf.debounce to tsfUtils.debounce?
-> Also add tsfUtils.delay?
function delay ( ms ) {
return new Promise( resolve => setTimeout( resolve, ms ) );
}

TODO to the snippets zipper, wrap the plugin inside its namesake folder so that WordPress won't assume the location based on filename, which can be appended (1) to if downloaded for a second time.

TODO test image type support and warn users about Facebook not supporting webp (etc.)?

### 5.0.7

**For everyone:**
Expand All @@ -322,6 +335,11 @@ TODO when zooming in with Chromium, the floating title for terms is vertically m
* Filter `the_seo_framework_schema_queued_graph_data` is now available. It's used to allow creating graph references.
* Method `tsf()->image()->generate_custom_image_details_from_query()` is now public.
* Method `tsf()->image()->generate_custom_image_details_from_args()` is now public.
* **Changed:**
* `The_SEO_Framework\Data\Plugin\Post::get_meta()` now returns the default meta if the post type isn't supported.
* `The_SEO_Framework\Data\Plugin\PTA::get_meta()` now returns the default meta if the PTA isn't supported.
* `The_SEO_Framework\Data\Plugin\Term::get_meta()` now returns the default meta if the term's taxonomy isn't supported.
* `The_SEO_Framework\Data\Plugin\User::get_meta()` now returns the default meta if the user ID is empty.
* **Improved:**
* Improved the Markdown parser's performance by using fewer memory operations.
* **Other:**
Expand Down

0 comments on commit 5bf612f

Please sign in to comment.