| @@ -10,9 +10,9 @@ | ||
| 10 | 10 | * @wordpress-plugin |
| 11 | 11 | * Plugin Name: Parse.ly |
| 12 | 12 | * Plugin URI: https://docs.parse.ly/wordpress |
| 13 | 13 | * Description: This plugin makes it a snap to add Parse.ly tracking code and metadata to your WordPress blog. |
| 14 | - * Version: 3.19.0 | |
| 14 | + * Version: 3.24.2 | |
| 15 | 15 | * Author: Parse.ly |
| 16 | 16 | * Author URI: https://www.parse.ly |
| 17 | 17 | * Text Domain: wp-parsely |
| 18 | 18 | * License: GPL-2.0-or-later |
| @@ -17,10 +17,10 @@ | ||
| 17 | 17 | * Text Domain: wp-parsely |
| 18 | 18 | * License: GPL-2.0-or-later |
| 19 | 19 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 20 | 20 | * GitHub Plugin URI: https://github.com/Parsely/wp-parsely |
| 21 | - * Requires PHP: 7.2 | |
| 22 | - * Requires WP: 6.0.0 | |
| 21 | + * Requires PHP: 7.4 | |
| 22 | + * Requires WP: 6.1.0 | |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | 25 | declare(strict_types=1); |
| 26 | 26 | |
| @@ -30,8 +30,9 @@ | ||
| 30 | 30 | use Parsely\Content_Helper\Editor_Sidebar; |
| 31 | 31 | use Parsely\Content_Helper\Post_List_Stats; |
| 32 | 32 | use Parsely\Endpoints\GraphQL_Metadata; |
| 33 | 33 | use Parsely\Endpoints\Rest_Metadata; |
| 34 | +use Parsely\Headline_Testing; | |
| 34 | 35 | use Parsely\Integrations\Amp; |
| 35 | 36 | use Parsely\Integrations\Google_Web_Stories; |
| 36 | 37 | use Parsely\Integrations\Integrations; |
| 37 | 38 | use Parsely\UI\Admin_Bar; |
| @@ -48,9 +49,9 @@ | ||
| 48 | 49 | if ( class_exists( Parsely::class ) ) { |
| 49 | 50 | return; |
| 50 | 51 | } |
| 51 | 52 | |
| 52 | -const PARSELY_VERSION = '3.19.0'; | |
| 53 | +const PARSELY_VERSION = '3.24.2'; | |
| 53 | 54 | const PARSELY_FILE = __FILE__; |
| 54 | 55 | const PARSELY_DATA_SCHEMA_VERSION = '1'; |
| 55 | 56 | const PARSELY_CACHE_GROUP = 'wp-parsely'; |
| 56 | 57 | |
| @@ -96,8 +97,12 @@ | ||
| 96 | 97 | $admin_bar->run(); |
| 97 | 98 | |
| 98 | 99 | $metadata_renderer = new Metadata_Renderer( $parsely ); |
| 99 | 100 | $metadata_renderer->run(); |
| 101 | + | |
| 102 | + // Initialize Headline Testing feature. | |
| 103 | + $headline_testing = new Headline_Testing( $parsely ); | |
| 104 | + $headline_testing->run(); | |
| 100 | 105 | } |
| 101 | 106 | |
| 102 | 107 | add_action( 'admin_init', __NAMESPACE__ . '\\parsely_admin_init_register' ); |
| 103 | 108 | /** |
| @@ -113,8 +118,56 @@ | ||
| 113 | 118 | ( new Site_Health( $parsely ) )->run(); |
| 114 | 119 | ( new Dashboard_Widget( $parsely ) )->run(); |
| 115 | 120 | } |
| 116 | 121 | |
| 122 | +add_action( 'admin_init', __NAMESPACE__ . '\\create_engagement_boost_changeset_post' ); | |
| 123 | +/** | |
| 124 | + * Creates a predefined changeset post in order to make the Engagement Boost | |
| 125 | + * preview work for non-administrator user roles. | |
| 126 | + * | |
| 127 | + * When the Engagement Boost preview iframe is loaded, it calls the WordPress | |
| 128 | + * Customizer in the `iFrameSrc()` function. The Customizer requires the current | |
| 129 | + * user to have the `customize` capability (available to Administrators), or the | |
| 130 | + * passed UUID to have a corresponding changeset post in the database. Otherwise | |
| 131 | + * it fails with -1 ("Non-existent changeset UUID") around line 561 in | |
| 132 | + * `class-wp-customize-manager.php` and prevents preview, displaying "-1". | |
| 133 | + * | |
| 134 | + * By creating a predefined changeset post with a known UUID that we use in | |
| 135 | + * `iFrameSrc()`, we guarantee that the preview will work for all authorized | |
| 136 | + * user roles. | |
| 137 | + * | |
| 138 | + * @since 3.20.7 | |
| 139 | + */ | |
| 140 | +function create_engagement_boost_changeset_post(): void { | |
| 141 | + if ( ! function_exists( 'post_exists' ) ) { | |
| 142 | + return; | |
| 143 | + } | |
| 144 | + | |
| 145 | + $parsely = get_parsely(); | |
| 146 | + | |
| 147 | + if ( ! $parsely->api_secret_is_set() || ! Permissions::current_user_can_use_pch_feature( | |
| 148 | + 'traffic_boost', | |
| 149 | + $parsely->get_options()['content_helper'] | |
| 150 | + ) ) { | |
| 151 | + return; | |
| 152 | + } | |
| 153 | + | |
| 154 | + // Needs to match the UUID in `iFrameSrc()` in `preview-iframe.tsx`. | |
| 155 | + $uuid = '905b130b-4129-4416-919c-9e31433a6f65'; | |
| 156 | + $post_id = post_exists( "wp-parsely-$uuid", '', '', 'customize_changeset', 'private' ); | |
| 157 | + | |
| 158 | + if ( 0 === $post_id ) { | |
| 159 | + wp_insert_post( | |
| 160 | + array( | |
| 161 | + 'post_type' => 'customize_changeset', | |
| 162 | + 'post_name' => $uuid, | |
| 163 | + 'post_title' => "wp-parsely-$uuid", | |
| 164 | + 'post_status' => 'private', | |
| 165 | + ) | |
| 166 | + ); | |
| 167 | + } | |
| 168 | +} | |
| 169 | + | |
| 117 | 170 | add_action( 'init', __NAMESPACE__ . '\\parsely_wp_admin_early_register' ); |
| 118 | 171 | /** |
| 119 | 172 | * Registers the additions the Parse.ly wp-admin settings page and Multisite |
| 120 | 173 | * Network Admin Sites List table. |
| @@ -171,8 +224,22 @@ | ||
| 171 | 224 | function init_content_helper_editor_sidebar(): void { |
| 172 | 225 | $GLOBALS['parsely_editor_sidebar']->run(); |
| 173 | 226 | } |
| 174 | 227 | |
| 228 | +add_action( 'enqueue_block_assets', __NAMESPACE__ . '\\init_content_helper_canvas_styles' ); | |
| 229 | +/** | |
| 230 | + * Inserts the PCH Editor Sidebar styles that need to reach the Editor canvas. | |
| 231 | + * | |
| 232 | + * @since 3.24.0 | |
| 233 | + */ | |
| 234 | +function init_content_helper_canvas_styles(): void { | |
| 235 | + if ( ! isset( $GLOBALS['parsely_editor_sidebar'] ) ) { | |
| 236 | + return; | |
| 237 | + } | |
| 238 | + | |
| 239 | + $GLOBALS['parsely_editor_sidebar']->run_canvas_styles(); | |
| 240 | +} | |
| 241 | + | |
| 175 | 242 | add_action( 'admin_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' ); |
| 176 | 243 | add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' ); |
| 177 | 244 | /** |
| 178 | 245 | * Initializes the PCH Editor Sidebar features. |
| @@ -260,9 +327,9 @@ | ||
| 260 | 327 | // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts |
| 261 | 328 | $smart_links_without_status = get_posts( |
| 262 | 329 | array( |
| 263 | 330 | 'post_type' => 'parsely_smart_link', |
| 264 | - 'posts_per_page' => -1, | |
| 331 | + 'posts_per_page' => -1, // phpcs:ignore WordPressVIPMinimum.Performance.NoPaging.posts_per_page_posts_per_page | |
| 265 | 332 | 'fields' => 'ids', |
| 266 | 333 | // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query |
| 267 | 334 | 'tax_query' => array( |
| 268 | 335 | array( |