From ea869c4710539ecd4a7dfe559dc8eb9fe5bea059 Mon Sep 17 00:00:00 2001 From: SIMONE FIORAVANTI Date: Wed, 24 May 2023 14:36:06 +0200 Subject: [PATCH] Fix deprecations and errors (multiple changes) (#155) - Replace deprecated single_month_title function - Updated Update Client - Update filters for UpdateClient - Remove some remaining block code - Fix an issue with get_file_content getting the menu icon - Fix an action that was triggered when not necessary --- CHANGES.md | 3 ++ classicpress-seo.php | 16 ++------- includes/admin/class-admin-helper.php | 3 +- includes/class-update-client-tweaks.php | 36 +++++++++++++++++++ includes/class-update-client.php | 23 +++++++----- .../modules/redirections/class-redirector.php | 5 +-- .../rich-snippet/class-snippet-shortcode.php | 17 --------- .../class-post-variables.php | 29 ++++++++++++++- readme.txt | 5 ++- 9 files changed, 93 insertions(+), 44 deletions(-) create mode 100644 includes/class-update-client-tweaks.php diff --git a/CHANGES.md b/CHANGES.md index 006812f..cdb71db 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,6 @@ +####v 2.1.3 / 2023-05-25 +* FIXED: SSL issues, deprecations + #### v 2.1.2 / 2023-02-03 * REMOVED: Remove REST API /disconnectSite endpoint (#150) diff --git a/classicpress-seo.php b/classicpress-seo.php index 83ba849..949fa8f 100644 --- a/classicpress-seo.php +++ b/classicpress-seo.php @@ -3,7 +3,7 @@ * Plugin Name: Classic SEO * Plugin URI: https://github.com/ClassicPress/classicpress-seo * Description: Classic SEO is the first SEO plugin built specifically to work with ClassicPress. The plugin contains many essential SEO tools to help optimize your website. - * Version: 2.1.2 + * Version: 2.1.3 * Author: ClassicPress * Author URI: https://github.com/ClassicPress * License: GPL v2 or later @@ -34,7 +34,7 @@ class Classic_SEO { * * @var string */ - public $version = '2.1.2'; + public $version = '2.1.3'; /** * Classic SEO database version. @@ -265,6 +265,7 @@ public function activation_error() { private function includes() { include dirname( __FILE__ ) . '/vendor/autoload.php'; require_once( dirname( __FILE__ ) . '/includes/class-update-client.php' ); + require_once( dirname( __FILE__ ) . '/includes/class-update-client-tweaks.php' ); } /** @@ -321,10 +322,6 @@ private function init_actions() { add_action( 'plugins_loaded', [ $this, 'init_wp_cli' ], 20 ); } - // Fix images folder for Update Manager. - add_filter( 'codepotent_update_manager_image_path', [ $this, 'fix_update_manager_images' ] ); - add_filter( 'codepotent_update_manager_image_url', [ $this, 'fix_update_manager_images' ] ); - } /** @@ -364,13 +361,6 @@ public function init_wp_cli() { WP_CLI::add_command( 'cpseo sitemap generate', [ '\Classic_SEO\CLI\Commands', 'sitemap_generate' ] ); } - /** - * Fix images folder for Update Manager. - */ - public function fix_update_manager_images( $folder ) { - return preg_replace( '/' . basename( CPSEO_PATH ) . '\/images$/', basename( CPSEO_PATH ) . '/assets/images', $folder ); - } - /** * Show action links on the plugin screen. * diff --git a/includes/admin/class-admin-helper.php b/includes/admin/class-admin-helper.php index 1c93fc6..ef86c54 100644 --- a/includes/admin/class-admin-helper.php +++ b/includes/admin/class-admin-helper.php @@ -41,8 +41,7 @@ public static function get_tooltip( $message ) { * @return string */ public static function get_icon() { - $icon_svg = file_get_contents( CPSEO()->plugin_url() . '/assets/admin/img/classic-seo-dashicon-white-on-transparent.svg' ); - return $icon_svg; + return ''; } /** diff --git a/includes/class-update-client-tweaks.php b/includes/class-update-client-tweaks.php new file mode 100644 index 0000000..4cf74c4 --- /dev/null +++ b/includes/class-update-client-tweaks.php @@ -0,0 +1,36 @@ +=')) { + return; +} /** * Remote updater class for ClassicPress plugin and themes. @@ -71,6 +80,9 @@ class UpdateClient { */ private $component_data = ''; + private $identifier = null; + private $server_slug = null; + /** * Constructor. * @@ -582,11 +594,6 @@ private function get_component_data($action, $component='') { // Initialize the data to be posted. $body = apply_filters('codepotent_update_manager_filter_'.$this->config['id'].'_client_request', $this->config['post']); - // Add opt out data tracking - Stats for Update manager - if( ! Helper::get_settings( 'general.cpseo_usage_tracking' ) ) { - $body['sfum'] = 'no-log'; - } - if ($action === 'plugin_information') { // If querying a single plugin, assign it to the post body. diff --git a/includes/modules/redirections/class-redirector.php b/includes/modules/redirections/class-redirector.php index 396dc4b..e564e62 100644 --- a/includes/modules/redirections/class-redirector.php +++ b/includes/modules/redirections/class-redirector.php @@ -139,7 +139,9 @@ private function redirect() { } // Debug if on. - $this->do_debugging(); + if ( array() !== $this->matched ) { + $this->do_debugging(); + } // @codeCoverageIgnoreStart if ( true === $this->do_filter( 'redirection/add_query_string', true ) && Str::is_non_empty( $this->query_string ) ) { @@ -224,7 +226,6 @@ private function pre_filter() { if ( null === $pre || ! is_array( $pre ) ) { return; } - $this->matched = $pre; $this->redirect_to = $pre['url_to']; } diff --git a/includes/modules/rich-snippet/class-snippet-shortcode.php b/includes/modules/rich-snippet/class-snippet-shortcode.php index c2755ac..2e41ba6 100644 --- a/includes/modules/rich-snippet/class-snippet-shortcode.php +++ b/includes/modules/rich-snippet/class-snippet-shortcode.php @@ -35,23 +35,6 @@ public function __construct() { if ( ! is_admin() ) { $this->filter( 'the_content', 'add_review_to_content', 11 ); } - - if ( ! function_exists( 'register_block_type' ) ) { - return; - } - - register_block_type( - 'cpseo/rich-snippet', - [ - 'render_callback' => [ $this, 'rich_snippet' ], - 'attributes' => [ - 'id' => [ - 'default' => '', - 'type' => 'integer', - ], - ], - ] - ); } /** diff --git a/includes/replace-variables/class-post-variables.php b/includes/replace-variables/class-post-variables.php index 1c92c19..a274271 100644 --- a/includes/replace-variables/class-post-variables.php +++ b/includes/replace-variables/class-post-variables.php @@ -317,6 +317,33 @@ public function get_excerpt_only() { return $has ? wp_strip_all_tags( $this->args->post_excerpt ) : null; } + /** + * Replace single_month_title deprecated function. + * + * @return string|false|void False if there's no valid title for the month. Title when retrieving. + */ + private function single_month_title( $prefix = '', $display = true ) { + global $wp_locale; + + $m = get_query_var( 'm' ); + $year = get_query_var( 'year' ); + $monthnum = get_query_var( 'monthnum' ); + + if ( ! empty( $monthnum ) && ! empty( $year ) ) { + $my_year = $year; + $my_month = $wp_locale->get_month( $monthnum ); + } elseif ( ! empty( $m ) ) { + $my_year = substr( $m, 0, 4 ); + $my_month = $wp_locale->get_month( substr( $m, 4, 2 ) ); + } + + if ( empty( $my_month ) ) { + return false; + } + + return ' ' . $my_month . $prefix . $my_year; + } + /** * Get the date of the post to use as a replacement. * @@ -337,7 +364,7 @@ public function get_date( $format = '' ) { return get_the_date( $format ); } - $replacement = single_month_title( ' ', false ); + $replacement = $this->single_month_title(); if ( Str::is_non_empty( $replacement ) ) { return $replacement; } diff --git a/readme.txt b/readme.txt index 91a5eb4..040aef5 100644 --- a/readme.txt +++ b/readme.txt @@ -1,7 +1,7 @@ == Classic SEO == Description: Classic SEO is the first SEO plugin built specifically to work with ClassicPress. The plugin contains many essential SEO tools to help optimize your website. -Version: 2.1.2 +Version: 2.1.3 Text Domain: cpseo Domain Path: /languages Requires PHP: 7.0 @@ -57,6 +57,9 @@ If you need support for Classic SEO or find a bug, you have threee choices: == Changelog == +**v 2.1.3 / 2023-05-25** +* FIXED: SSL issues, deprecations + **v 2.1.2 / 2023-02-03** * REMOVED: Remove REST API /disconnectSite endpoint (#150)