| @@ -8,11 +8,11 @@ | ||
| 8 | 8 | * @license GPL-2.0-or-later |
| 9 | 9 | * |
| 10 | 10 | * @wordpress-plugin |
| 11 | 11 | * Plugin Name: Parse.ly |
| 12 | - * Plugin URI: https://docs.parse.ly/wordpress | |
| 12 | + * Plugin URI: https://www.parse.ly/help/integration/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.18.0 | |
| 14 | + * Version: 3.8.4 | |
| 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 |
| @@ -25,19 +25,27 @@ | ||
| 25 | 25 | declare(strict_types=1); |
| 26 | 26 | |
| 27 | 27 | namespace Parsely; |
| 28 | 28 | |
| 29 | -use Parsely\Content_Helper\Dashboard_Widget; | |
| 30 | -use Parsely\Content_Helper\Editor_Sidebar; | |
| 31 | -use Parsely\Content_Helper\Excerpt_Suggestions; | |
| 32 | -use Parsely\Content_Helper\Post_List_Stats; | |
| 29 | +use Parsely\ContentHelper\Dashboard_Widget; | |
| 30 | +use Parsely\Endpoints\Analytics_Post_Detail_API_Proxy; | |
| 31 | +use Parsely\Endpoints\Analytics_Posts_API_Proxy; | |
| 33 | 32 | use Parsely\Endpoints\GraphQL_Metadata; |
| 33 | +use Parsely\Endpoints\Referrers_Post_Detail_API_Proxy; | |
| 34 | +use Parsely\Endpoints\Related_API_Proxy; | |
| 34 | 35 | use Parsely\Endpoints\Rest_Metadata; |
| 35 | 36 | use Parsely\Integrations\Amp; |
| 37 | +use Parsely\Integrations\Facebook_Instant_Articles; | |
| 36 | 38 | use Parsely\Integrations\Google_Web_Stories; |
| 37 | 39 | use Parsely\Integrations\Integrations; |
| 38 | -use Parsely\REST_API\REST_API_Controller; | |
| 40 | +use Parsely\RemoteAPI\Analytics_Post_Detail_API; | |
| 41 | +use Parsely\RemoteAPI\Analytics_Posts_API; | |
| 42 | +use Parsely\RemoteAPI\Remote_API_Cache; | |
| 43 | +use Parsely\RemoteAPI\Referrers_Post_Detail_API; | |
| 44 | +use Parsely\RemoteAPI\Related_API; | |
| 45 | +use Parsely\RemoteAPI\WordPress_Cache; | |
| 39 | 46 | use Parsely\UI\Admin_Bar; |
| 47 | +use Parsely\UI\Admin_Columns_Parsely_Stats; | |
| 40 | 48 | use Parsely\UI\Admin_Warning; |
| 41 | 49 | use Parsely\UI\Metadata_Renderer; |
| 42 | 50 | use Parsely\UI\Network_Admin_Sites_List; |
| 43 | 51 | use Parsely\UI\Plugins_Actions; |
| @@ -45,21 +53,36 @@ | ||
| 45 | 53 | use Parsely\UI\Row_Actions; |
| 46 | 54 | use Parsely\UI\Settings_Page; |
| 47 | 55 | use Parsely\UI\Site_Health; |
| 48 | 56 | |
| 57 | +require_once __DIR__ . '/src/Utils/utils.php'; | |
| 58 | + | |
| 49 | 59 | if ( class_exists( Parsely::class ) ) { |
| 50 | 60 | return; |
| 51 | 61 | } |
| 52 | 62 | |
| 53 | -const PARSELY_VERSION = '3.18.0'; | |
| 63 | +const PARSELY_VERSION = '3.8.4'; | |
| 54 | 64 | const PARSELY_FILE = __FILE__; |
| 55 | 65 | |
| 56 | -if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { | |
| 57 | - require_once __DIR__ . '/vendor/autoload.php'; | |
| 58 | -} | |
| 66 | +require_once __DIR__ . '/src/class-parsely.php'; | |
| 67 | +require_once __DIR__ . '/src/class-scripts.php'; | |
| 68 | +require_once __DIR__ . '/src/class-dashboard-link.php'; | |
| 69 | +require_once __DIR__ . '/src/UI/class-admin-bar.php'; | |
| 70 | +require_once __DIR__ . '/src/UI/class-metadata-renderer.php'; | |
| 71 | +require_once __DIR__ . '/src/Endpoints/class-metadata-endpoint.php'; | |
| 72 | +require_once __DIR__ . '/src/Endpoints/class-graphql-metadata.php'; | |
| 59 | 73 | |
| 60 | -// Load Telemetry classes. | |
| 61 | -require_once __DIR__ . '/src/Telemetry/telemetry-init.php'; | |
| 74 | +require_once __DIR__ . '/src/class-metadata.php'; | |
| 75 | +require_once __DIR__ . '/src/Metadata/class-metadata-builder.php'; | |
| 76 | +require_once __DIR__ . '/src/Metadata/class-author-archive-builder.php'; | |
| 77 | +require_once __DIR__ . '/src/Metadata/class-category-builder.php'; | |
| 78 | +require_once __DIR__ . '/src/Metadata/class-date-builder.php'; | |
| 79 | +require_once __DIR__ . '/src/Metadata/class-front-page-builder.php'; | |
| 80 | +require_once __DIR__ . '/src/Metadata/class-page-builder.php'; | |
| 81 | +require_once __DIR__ . '/src/Metadata/class-page-for-posts-builder.php'; | |
| 82 | +require_once __DIR__ . '/src/Metadata/class-paginated-front-page-builder.php'; | |
| 83 | +require_once __DIR__ . '/src/Metadata/class-post-builder.php'; | |
| 84 | +require_once __DIR__ . '/src/Metadata/class-tag-builder.php'; | |
| 62 | 85 | |
| 63 | 86 | add_action( 'plugins_loaded', __NAMESPACE__ . '\\parsely_initialize_plugin' ); |
| 64 | 87 | /** |
| 65 | 88 | * Registers the basic classes to initialize the plugin. |
| @@ -82,8 +105,15 @@ | ||
| 82 | 105 | $metadata_renderer = new Metadata_Renderer( $GLOBALS['parsely'] ); |
| 83 | 106 | $metadata_renderer->run(); |
| 84 | 107 | } |
| 85 | 108 | |
| 109 | +require_once __DIR__ . '/src/UI/class-admin-columns-parsely-stats.php'; | |
| 110 | +require_once __DIR__ . '/src/UI/class-admin-warning.php'; | |
| 111 | +require_once __DIR__ . '/src/UI/class-plugins-actions.php'; | |
| 112 | +require_once __DIR__ . '/src/UI/class-row-actions.php'; | |
| 113 | +require_once __DIR__ . '/src/UI/class-site-health.php'; | |
| 114 | +require_once __DIR__ . '/src/content-helper/dashboard-widget/class-dashboard-widget.php'; | |
| 115 | + | |
| 86 | 116 | add_action( 'admin_init', __NAMESPACE__ . '\\parsely_admin_init_register' ); |
| 87 | 117 | /** |
| 88 | 118 | * Registers the Parse.ly wp-admin warnings, plugin actions and row actions. |
| 89 | 119 | */ |
| @@ -92,13 +122,16 @@ | ||
| 92 | 122 | |
| 93 | 123 | ( new Admin_Warning( $parsely ) )->run(); |
| 94 | 124 | ( new Plugins_Actions() )->run(); |
| 95 | 125 | ( new Row_Actions( $parsely ) )->run(); |
| 96 | - ( new Post_List_Stats( $parsely ) )->run(); | |
| 126 | + ( new Admin_Columns_Parsely_Stats( $parsely ) )->run(); | |
| 97 | 127 | ( new Site_Health( $parsely ) )->run(); |
| 98 | - ( new Dashboard_Widget( $parsely ) )->run(); | |
| 128 | + ( new Dashboard_Widget() )->run(); | |
| 99 | 129 | } |
| 100 | 130 | |
| 131 | +require_once __DIR__ . '/src/UI/class-settings-page.php'; | |
| 132 | +require_once __DIR__ . '/src/UI/class-network-admin-sites-list.php'; | |
| 133 | + | |
| 101 | 134 | add_action( 'init', __NAMESPACE__ . '\\parsely_wp_admin_early_register' ); |
| 102 | 135 | /** |
| 103 | 136 | * Registers the additions the Parse.ly wp-admin settings page and Multisite |
| 104 | 137 | * Network Admin Sites List table. |
| @@ -108,14 +141,27 @@ | ||
| 108 | 141 | $GLOBALS['parsely_settings_page']->run(); |
| 109 | 142 | |
| 110 | 143 | $network_admin_sites_list = new Network_Admin_Sites_List( $GLOBALS['parsely'] ); |
| 111 | 144 | $network_admin_sites_list->run(); |
| 145 | +} | |
| 112 | 146 | |
| 113 | - // Initialize the REST API Controller. | |
| 114 | - $rest_api_controller = $GLOBALS['parsely']->get_rest_api_controller(); | |
| 115 | - $rest_api_controller->init(); | |
| 116 | -} | |
| 147 | +require_once __DIR__ . '/src/RemoteAPI/interface-cache.php'; | |
| 148 | +require_once __DIR__ . '/src/RemoteAPI/interface-remote-api.php'; | |
| 149 | +require_once __DIR__ . '/src/RemoteAPI/class-remote-api-base.php'; | |
| 150 | +require_once __DIR__ . '/src/RemoteAPI/class-remote-api-cache.php'; | |
| 151 | +require_once __DIR__ . '/src/RemoteAPI/class-related-api.php'; | |
| 152 | +require_once __DIR__ . '/src/RemoteAPI/class-analytics-posts-api.php'; | |
| 153 | +require_once __DIR__ . '/src/RemoteAPI/class-analytics-post-detail-api.php'; | |
| 154 | +require_once __DIR__ . '/src/RemoteAPI/class-referrers-post-detail-api.php'; | |
| 155 | +require_once __DIR__ . '/src/RemoteAPI/class-wordpress-cache.php'; | |
| 117 | 156 | |
| 157 | +require_once __DIR__ . '/src/Endpoints/class-base-api-proxy.php'; | |
| 158 | +require_once __DIR__ . '/src/Endpoints/class-related-api-proxy.php'; | |
| 159 | +require_once __DIR__ . '/src/Endpoints/class-analytics-posts-api-proxy.php'; | |
| 160 | +require_once __DIR__ . '/src/Endpoints/class-analytics-post-detail-api-proxy.php'; | |
| 161 | +require_once __DIR__ . '/src/Endpoints/class-referrers-post-detail-api-proxy.php'; | |
| 162 | +require_once __DIR__ . '/src/Endpoints/class-rest-metadata.php'; | |
| 163 | + | |
| 118 | 164 | add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_rest_api_init' ); |
| 119 | 165 | /** |
| 120 | 166 | * Registers REST Endpoints that act as a proxy to the Parse.ly API. |
| 121 | 167 | * This is needed to get around CORS issues with Firefox. |
| @@ -122,12 +168,39 @@ | ||
| 122 | 168 | * |
| 123 | 169 | * @since 3.2.0 |
| 124 | 170 | */ |
| 125 | 171 | function parsely_rest_api_init(): void { |
| 126 | - $rest = new Rest_Metadata( $GLOBALS['parsely'] ); | |
| 172 | + $wp_cache = new WordPress_Cache(); | |
| 173 | + $rest = new Rest_Metadata( $GLOBALS['parsely'] ); | |
| 127 | 174 | $rest->run(); |
| 175 | + | |
| 176 | + parsely_run_rest_api_endpoint( | |
| 177 | + Related_API::class, | |
| 178 | + Related_API_Proxy::class, | |
| 179 | + $wp_cache | |
| 180 | + ); | |
| 181 | + | |
| 182 | + parsely_run_rest_api_endpoint( | |
| 183 | + Analytics_Posts_API::class, | |
| 184 | + Analytics_Posts_API_Proxy::class, | |
| 185 | + $wp_cache | |
| 186 | + ); | |
| 187 | + | |
| 188 | + parsely_run_rest_api_endpoint( | |
| 189 | + Analytics_Post_Detail_API::class, | |
| 190 | + Analytics_Post_Detail_API_Proxy::class, | |
| 191 | + $wp_cache | |
| 192 | + ); | |
| 193 | + | |
| 194 | + parsely_run_rest_api_endpoint( | |
| 195 | + Referrers_Post_Detail_API::class, | |
| 196 | + Referrers_Post_Detail_API_Proxy::class, | |
| 197 | + $wp_cache | |
| 198 | + ); | |
| 128 | 199 | } |
| 129 | 200 | |
| 201 | +require_once __DIR__ . '/src/blocks/recommendations/class-recommendations-block.php'; | |
| 202 | + | |
| 130 | 203 | add_action( 'init', __NAMESPACE__ . '\\init_recommendations_block' ); |
| 131 | 204 | /** |
| 132 | 205 | * Registers the Recommendations Block. |
| 133 | 206 | */ |
| @@ -135,38 +208,21 @@ | ||
| 135 | 208 | $recommendations_block = new Recommendations_Block(); |
| 136 | 209 | $recommendations_block->run(); |
| 137 | 210 | } |
| 138 | 211 | |
| 139 | -add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\init_content_helper_editor_sidebar' ); | |
| 212 | +require_once __DIR__ . '/src/blocks/content-helper/class-content-helper.php'; | |
| 213 | + | |
| 214 | +add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\init_content_helper' ); | |
| 140 | 215 | /** |
| 141 | 216 | * Inserts the PCH Editor Sidebar. |
| 142 | 217 | * |
| 143 | - * @since 3.5.0 Moved from Parsely\Scripts\enqueue_block_editor_assets(). | |
| 144 | - * @since 3.9.0 Renamed from init_content_helper(). | |
| 218 | + * @since 3.5.0 Moved from Parsely\Scripts\enqueue_block_editor_assets() | |
| 145 | 219 | */ |
| 146 | -function init_content_helper_editor_sidebar(): void { | |
| 147 | - $GLOBALS['parsely_editor_sidebar']->run(); | |
| 220 | +function init_content_helper(): void { | |
| 221 | + ( new Content_Helper() )->run(); | |
| 148 | 222 | } |
| 149 | 223 | |
| 150 | -add_action( 'admin_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' ); | |
| 151 | -add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_content_helper_editor_sidebar_features' ); | |
| 152 | -/** | |
| 153 | - * Initializes the PCH Editor Sidebar features. | |
| 154 | - * | |
| 155 | - * @since 3.16.0 | |
| 156 | - */ | |
| 157 | -function parsely_content_helper_editor_sidebar_features(): void { | |
| 158 | - if ( ! isset( $GLOBALS['parsely_editor_sidebar'] ) ) { | |
| 159 | - /** | |
| 160 | - * The Editor Sidebar instance. | |
| 161 | - * | |
| 162 | - * @since 3.16.0 | |
| 163 | - * @var Editor_Sidebar $GLOBALS['parsely_editor_sidebar'] | |
| 164 | - */ | |
| 165 | - $GLOBALS['parsely_editor_sidebar'] = new Editor_Sidebar( $GLOBALS['parsely'] ); | |
| 166 | - $GLOBALS['parsely_editor_sidebar']->init_features(); | |
| 167 | - } | |
| 168 | -} | |
| 224 | +require_once __DIR__ . '/src/UI/class-recommended-widget.php'; | |
| 169 | 225 | |
| 170 | 226 | add_action( 'widgets_init', __NAMESPACE__ . '\\parsely_recommended_widget_register' ); |
| 171 | 227 | /** |
| 172 | 228 | * Registers the Parse.ly Recommended widget. |
| @@ -174,8 +230,14 @@ | ||
| 174 | 230 | function parsely_recommended_widget_register(): void { |
| 175 | 231 | register_widget( new Recommended_Widget( $GLOBALS['parsely'] ) ); |
| 176 | 232 | } |
| 177 | 233 | |
| 234 | +require_once __DIR__ . '/src/Integrations/class-integration.php'; | |
| 235 | +require_once __DIR__ . '/src/Integrations/class-integrations.php'; | |
| 236 | +require_once __DIR__ . '/src/Integrations/class-amp.php'; | |
| 237 | +require_once __DIR__ . '/src/Integrations/class-facebook-instant-articles.php'; | |
| 238 | +require_once __DIR__ . '/src/Integrations/class-google-web-stories.php'; | |
| 239 | + | |
| 178 | 240 | add_action( 'init', __NAMESPACE__ . '\\parsely_integrations' ); // @phpstan-ignore-line |
| 179 | 241 | /** |
| 180 | 242 | * Instantiates Integrations collection and registers built-in integrations. |
| 181 | 243 | * |
| @@ -193,10 +255,42 @@ | ||
| 193 | 255 | } |
| 194 | 256 | |
| 195 | 257 | $parsely_integrations = new Integrations( $parsely ); |
| 196 | 258 | $parsely_integrations->register( 'amp', Amp::class ); |
| 259 | + $parsely_integrations->register( 'fbia', Facebook_Instant_Articles::class ); | |
| 197 | 260 | $parsely_integrations->register( 'webstories', Google_Web_Stories::class ); |
| 198 | 261 | $parsely_integrations = apply_filters( 'wp_parsely_add_integration', $parsely_integrations ); |
| 199 | 262 | $parsely_integrations->integrate(); |
| 200 | 263 | |
| 201 | 264 | return $parsely_integrations; |
| 265 | +} | |
| 266 | + | |
| 267 | +/** | |
| 268 | + * Instantiates and runs the specified API endpoint. | |
| 269 | + * | |
| 270 | + * @since 3.6.0 | |
| 271 | + * | |
| 272 | + * @param string $api_class_name The proxy class to instantiate. | |
| 273 | + * @param string $proxy_api_class_name The API proxy class to instantiate and run. | |
| 274 | + * @param WordPress_Cache $wp_cache The WordPress cache instance to be used. | |
| 275 | + */ | |
| 276 | +function parsely_run_rest_api_endpoint( | |
| 277 | + string $api_class_name, | |
| 278 | + string $proxy_api_class_name, | |
| 279 | + WordPress_Cache &$wp_cache | |
| 280 | +): void { | |
| 281 | + /** | |
| 282 | + * Internal Variable. | |
| 283 | + * | |
| 284 | + * @var RemoteAPI\Remote_API_Base | |
| 285 | + */ | |
| 286 | + $remote_api = new $api_class_name( $GLOBALS['parsely'] ); | |
| 287 | + $remote_api_cache = new Remote_API_Cache( $remote_api, $wp_cache ); | |
| 288 | + | |
| 289 | + /** | |
| 290 | + * Internal Variable. | |
| 291 | + * | |
| 292 | + * @var Endpoints\Base_API_Proxy | |
| 293 | + */ | |
| 294 | + $remote_api_proxy = new $proxy_api_class_name( $GLOBALS['parsely'], $remote_api_cache ); | |
| 295 | + $remote_api_proxy->run(); | |
| 202 | 296 | } |