| 1 |
<?php |
| 2 |
/** |
| 3 |
* Parse.ly |
| 4 |
* |
| 5 |
* @package Parsely |
| 6 |
* @author Parse.ly |
| 7 |
* @copyright 2012 Parse.ly |
| 8 |
* @license GPL-2.0-or-later |
| 9 |
* |
| 10 |
* @wordpress-plugin |
| 11 |
* Plugin Name: Parse.ly |
| 12 |
* Plugin URI: https://www.parse.ly/help/integration/wordpress |
| 13 |
* Description: This plugin makes it a snap to add Parse.ly tracking code and metadata to your WordPress blog. |
| 14 |
* Version: 3.5.0 |
| 15 |
* Author: Parse.ly |
| 16 |
* Author URI: https://www.parse.ly |
| 17 |
* Text Domain: wp-parsely |
| 18 |
* License: GPL-2.0-or-later |
| 19 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 20 |
* GitHub Plugin URI: https://github.com/Parsely/wp-parsely |
| 21 |
* Requires PHP: 7.1 |
| 22 |
* Requires WP: 5.0.0 |
| 23 |
*/ |
| 24 |
|
| 25 |
declare(strict_types=1); |
| 26 |
|
| 27 |
namespace Parsely; |
| 28 |
|
| 29 |
use Parsely\Endpoints\Related_API_Proxy; |
| 30 |
use Parsely\Endpoints\Analytics_Posts_API_Proxy; |
| 31 |
use Parsely\Endpoints\GraphQL_Metadata; |
| 32 |
use Parsely\Endpoints\Rest_Metadata; |
| 33 |
use Parsely\Integrations\Amp; |
| 34 |
use Parsely\Integrations\Facebook_Instant_Articles; |
| 35 |
use Parsely\Integrations\Google_Web_Stories; |
| 36 |
use Parsely\Integrations\Integrations; |
| 37 |
use Parsely\RemoteAPI\Cached_Proxy; |
| 38 |
use Parsely\RemoteAPI\Related_Proxy; |
| 39 |
use Parsely\RemoteAPI\Analytics_Posts_Proxy; |
| 40 |
use Parsely\RemoteAPI\WordPress_Cache; |
| 41 |
use Parsely\UI\Admin_Bar; |
| 42 |
use Parsely\UI\Admin_Warning; |
| 43 |
use Parsely\UI\Metadata_Renderer; |
| 44 |
use Parsely\UI\Plugins_Actions; |
| 45 |
use Parsely\UI\Network_Admin_Sites_List; |
| 46 |
use Parsely\UI\Recommended_Widget; |
| 47 |
use Parsely\UI\Row_Actions; |
| 48 |
use Parsely\UI\Settings_Page; |
| 49 |
use Parsely\UI\Site_Health; |
| 50 |
|
| 51 |
if ( class_exists( Parsely::class ) ) { |
| 52 |
return; |
| 53 |
} |
| 54 |
|
| 55 |
const PARSELY_VERSION = '3.5.0'; |
| 56 |
const PARSELY_FILE = __FILE__; |
| 57 |
|
| 58 |
require __DIR__ . '/src/class-parsely.php'; |
| 59 |
require __DIR__ . '/src/class-scripts.php'; |
| 60 |
require __DIR__ . '/src/class-dashboard-link.php'; |
| 61 |
require __DIR__ . '/src/UI/class-admin-bar.php'; |
| 62 |
require __DIR__ . '/src/UI/class-metadata-renderer.php'; |
| 63 |
require __DIR__ . '/src/Endpoints/class-metadata-endpoint.php'; |
| 64 |
require __DIR__ . '/src/Endpoints/class-graphql-metadata.php'; |
| 65 |
|
| 66 |
require __DIR__ . '/src/class-metadata.php'; |
| 67 |
require __DIR__ . '/src/Metadata/class-metadata-builder.php'; |
| 68 |
require __DIR__ . '/src/Metadata/class-author-archive-builder.php'; |
| 69 |
require __DIR__ . '/src/Metadata/class-category-builder.php'; |
| 70 |
require __DIR__ . '/src/Metadata/class-date-builder.php'; |
| 71 |
require __DIR__ . '/src/Metadata/class-front-page-builder.php'; |
| 72 |
require __DIR__ . '/src/Metadata/class-page-builder.php'; |
| 73 |
require __DIR__ . '/src/Metadata/class-page-for-posts-builder.php'; |
| 74 |
require __DIR__ . '/src/Metadata/class-paginated-front-page-builder.php'; |
| 75 |
require __DIR__ . '/src/Metadata/class-post-builder.php'; |
| 76 |
require __DIR__ . '/src/Metadata/class-tag-builder.php'; |
| 77 |
|
| 78 |
add_action( 'plugins_loaded', __NAMESPACE__ . '\\parsely_initialize_plugin' ); |
| 79 |
/** |
| 80 |
* Registers the basic classes to initialize the plugin. |
| 81 |
*/ |
| 82 |
function parsely_initialize_plugin(): void { |
| 83 |
$GLOBALS['parsely'] = new Parsely(); |
| 84 |
$GLOBALS['parsely']->run(); |
| 85 |
|
| 86 |
if ( class_exists( 'WPGraphQL' ) ) { |
| 87 |
$graphql = new GraphQL_Metadata( $GLOBALS['parsely'] ); |
| 88 |
$graphql->run(); |
| 89 |
} |
| 90 |
|
| 91 |
$scripts = new Scripts( $GLOBALS['parsely'] ); |
| 92 |
$scripts->run(); |
| 93 |
|
| 94 |
$admin_bar = new Admin_Bar( $GLOBALS['parsely'] ); |
| 95 |
$admin_bar->run(); |
| 96 |
|
| 97 |
$metadata_renderer = new Metadata_Renderer( $GLOBALS['parsely'] ); |
| 98 |
$metadata_renderer->run(); |
| 99 |
} |
| 100 |
|
| 101 |
require __DIR__ . '/src/UI/class-admin-warning.php'; |
| 102 |
require __DIR__ . '/src/UI/class-plugins-actions.php'; |
| 103 |
require __DIR__ . '/src/UI/class-row-actions.php'; |
| 104 |
require __DIR__ . '/src/UI/class-site-health.php'; |
| 105 |
|
| 106 |
add_action( 'admin_init', __NAMESPACE__ . '\\parsely_admin_init_register' ); |
| 107 |
/** |
| 108 |
* Registers the Parse.ly wp-admin warnings, plugin actions and row actions. |
| 109 |
*/ |
| 110 |
function parsely_admin_init_register(): void { |
| 111 |
$admin_warning = new Admin_Warning( $GLOBALS['parsely'] ); |
| 112 |
$admin_warning->run(); |
| 113 |
|
| 114 |
$plugins_actions = new Plugins_Actions(); |
| 115 |
$plugins_actions->run(); |
| 116 |
|
| 117 |
$row_actions = new Row_Actions( $GLOBALS['parsely'] ); |
| 118 |
$row_actions->run(); |
| 119 |
|
| 120 |
$site_health = new Site_Health( $GLOBALS['parsely'] ); |
| 121 |
$site_health->run(); |
| 122 |
} |
| 123 |
|
| 124 |
require __DIR__ . '/src/UI/class-settings-page.php'; |
| 125 |
require __DIR__ . '/src/UI/class-network-admin-sites-list.php'; |
| 126 |
|
| 127 |
add_action( 'init', __NAMESPACE__ . '\\parsely_wp_admin_early_register' ); |
| 128 |
/** |
| 129 |
* Registers the additions the Parse.ly wp-admin settings page and Multisite |
| 130 |
* Network Admin Sites List table. |
| 131 |
*/ |
| 132 |
function parsely_wp_admin_early_register(): void { |
| 133 |
$settings_page = new Settings_Page( $GLOBALS['parsely'] ); |
| 134 |
$settings_page->run(); |
| 135 |
|
| 136 |
$network_admin_sites_list = new Network_Admin_Sites_List( $GLOBALS['parsely'] ); |
| 137 |
$network_admin_sites_list->run(); |
| 138 |
} |
| 139 |
|
| 140 |
require __DIR__ . '/src/RemoteAPI/interface-cache.php'; |
| 141 |
require __DIR__ . '/src/RemoteAPI/interface-proxy.php'; |
| 142 |
require __DIR__ . '/src/RemoteAPI/class-base-proxy.php'; |
| 143 |
require __DIR__ . '/src/RemoteAPI/class-cached-proxy.php'; |
| 144 |
require __DIR__ . '/src/RemoteAPI/class-related-proxy.php'; |
| 145 |
require __DIR__ . '/src/RemoteAPI/class-analytics-posts-proxy.php'; |
| 146 |
require __DIR__ . '/src/RemoteAPI/class-wordpress-cache.php'; |
| 147 |
require __DIR__ . '/src/Endpoints/class-base-api-proxy.php'; |
| 148 |
require __DIR__ . '/src/Endpoints/class-related-api-proxy.php'; |
| 149 |
require __DIR__ . '/src/Endpoints/class-analytics-posts-api-proxy.php'; |
| 150 |
require __DIR__ . '/src/Endpoints/class-rest-metadata.php'; |
| 151 |
|
| 152 |
add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_rest_api_init' ); |
| 153 |
/** |
| 154 |
* Registers REST Endpoints that act as a proxy to the Parse.ly API. |
| 155 |
* This is needed to get around a CORS issues with Firefox. |
| 156 |
* |
| 157 |
* @since 3.2.0 |
| 158 |
*/ |
| 159 |
function parsely_rest_api_init(): void { |
| 160 |
$rest = new Rest_Metadata( $GLOBALS['parsely'] ); |
| 161 |
$rest->run(); |
| 162 |
|
| 163 |
$related_proxy = new Related_Proxy( $GLOBALS['parsely'] ); |
| 164 |
$related_cached_proxy = new Cached_Proxy( $related_proxy, new WordPress_Cache() ); |
| 165 |
$related_endpoint = new Related_API_Proxy( $GLOBALS['parsely'], $related_cached_proxy ); |
| 166 |
$related_endpoint->run(); |
| 167 |
|
| 168 |
$analytics_posts_proxy = new Analytics_Posts_Proxy( $GLOBALS['parsely'] ); |
| 169 |
$analytics_posts_cached_proxy = new Cached_Proxy( $analytics_posts_proxy, new WordPress_Cache() ); |
| 170 |
$analytics_posts_endpoint = new Analytics_Posts_API_Proxy( $GLOBALS['parsely'], $analytics_posts_cached_proxy ); |
| 171 |
$analytics_posts_endpoint->run(); |
| 172 |
} |
| 173 |
|
| 174 |
require __DIR__ . '/src/blocks/recommendations/class-recommendations-block.php'; |
| 175 |
|
| 176 |
add_action( 'init', __NAMESPACE__ . '\\init_recommendations_block' ); |
| 177 |
/** |
| 178 |
* Registers the Recommendations Block. |
| 179 |
*/ |
| 180 |
function init_recommendations_block(): void { |
| 181 |
$recommendations_block = new Recommendations_Block(); |
| 182 |
$recommendations_block->run(); |
| 183 |
} |
| 184 |
|
| 185 |
require __DIR__ . '/src/blocks/content-helper/class-content-helper.php'; |
| 186 |
add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\init_content_helper' ); |
| 187 |
/** |
| 188 |
* Inserts the Content Helper into the WordPress Post Editor. |
| 189 |
* |
| 190 |
* @since 3.5.0 Moved from Parsely\Scripts\enqueue_block_editor_assets() |
| 191 |
*/ |
| 192 |
function init_content_helper(): void { |
| 193 |
( new Content_Helper() )->run(); |
| 194 |
} |
| 195 |
|
| 196 |
require __DIR__ . '/src/UI/class-recommended-widget.php'; |
| 197 |
|
| 198 |
add_action( 'widgets_init', __NAMESPACE__ . '\\parsely_recommended_widget_register' ); |
| 199 |
/** |
| 200 |
* Registers the Parse.ly Recommended widget. |
| 201 |
*/ |
| 202 |
function parsely_recommended_widget_register(): void { |
| 203 |
register_widget( Recommended_Widget::class ); |
| 204 |
} |
| 205 |
|
| 206 |
require __DIR__ . '/src/Integrations/class-integration.php'; |
| 207 |
require __DIR__ . '/src/Integrations/class-integrations.php'; |
| 208 |
require __DIR__ . '/src/Integrations/class-amp.php'; |
| 209 |
require __DIR__ . '/src/Integrations/class-facebook-instant-articles.php'; |
| 210 |
require __DIR__ . '/src/Integrations/class-google-web-stories.php'; |
| 211 |
|
| 212 |
add_action( 'init', __NAMESPACE__ . '\\parsely_integrations' ); |
| 213 |
/** |
| 214 |
* Instantiates Integrations collection and registers built-in integrations. |
| 215 |
* |
| 216 |
* @since 2.6.0 |
| 217 |
* |
| 218 |
* @return Integrations |
| 219 |
*/ |
| 220 |
function parsely_integrations(): Integrations { |
| 221 |
$parsely_integrations = new Integrations(); |
| 222 |
$parsely_integrations->register( 'amp', Amp::class ); |
| 223 |
$parsely_integrations->register( 'fbia', Facebook_Instant_Articles::class ); |
| 224 |
$parsely_integrations->register( 'webstories', Google_Web_Stories::class ); |
| 225 |
$parsely_integrations = apply_filters( 'wp_parsely_add_integration', $parsely_integrations ); |
| 226 |
$parsely_integrations->integrate(); |
| 227 |
|
| 228 |
return $parsely_integrations; |
| 229 |
} |
| 230 |
|