| @@ -9,10 +9,10 @@ | ||
| 9 | 9 | * |
| 10 | 10 | * @wordpress-plugin |
| 11 | 11 | * Plugin Name: Parse.ly |
| 12 | 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.2.0 | |
| 13 | + * Description: This plugin makes it a snap to add Parse.ly tracking code to your WordPress blog. | |
| 14 | + * Version: 2.5.1 | |
| 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,181 +17,58 @@ | ||
| 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.1 | |
| 22 | - * Requires WP: 5.0.0 | |
| 21 | + * Requires PHP: 5.6 | |
| 22 | + * Requires WP: 4.0.0 | |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | -declare(strict_types=1); | |
| 25 | +// If this file is called directly, abort. | |
| 26 | +if ( ! defined( 'WPINC' ) ) { | |
| 27 | + die; | |
| 28 | +} | |
| 26 | 29 | |
| 27 | -namespace Parsely; | |
| 28 | - | |
| 29 | -use Parsely\Endpoints\Related_API_Proxy; | |
| 30 | -use Parsely\Endpoints\GraphQL_Metadata; | |
| 31 | -use Parsely\Endpoints\Rest_Metadata; | |
| 32 | -use Parsely\Integrations\Amp; | |
| 33 | -use Parsely\Integrations\Facebook_Instant_Articles; | |
| 34 | -use Parsely\Integrations\Google_Web_Stories; | |
| 35 | -use Parsely\Integrations\Integrations; | |
| 36 | -use Parsely\RemoteAPI\Cached_Proxy; | |
| 37 | -use Parsely\RemoteAPI\Related_Proxy; | |
| 38 | -use Parsely\RemoteAPI\WordPress_Cache; | |
| 39 | -use Parsely\UI\Admin_Bar; | |
| 40 | -use Parsely\UI\Admin_Warning; | |
| 41 | -use Parsely\UI\Plugins_Actions; | |
| 42 | -use Parsely\UI\Network_Admin_Sites_List; | |
| 43 | -use Parsely\UI\Recommended_Widget; | |
| 44 | -use Parsely\UI\Row_Actions; | |
| 45 | -use Parsely\UI\Settings_Page; | |
| 46 | - | |
| 47 | -if ( class_exists( Parsely::class ) ) { | |
| 30 | +if ( class_exists( 'Parsely' ) ) { | |
| 48 | 31 | return; |
| 49 | 32 | } |
| 50 | 33 | |
| 51 | -const PARSELY_VERSION = '3.2.0'; | |
| 52 | -const PARSELY_FILE = __FILE__; | |
| 34 | +define( 'PARSELY_VERSION', '2.5.1' ); | |
| 53 | 35 | |
| 54 | -require __DIR__ . '/src/class-parsely.php'; | |
| 55 | -require __DIR__ . '/src/class-scripts.php'; | |
| 56 | -require __DIR__ . '/src/class-dashboard-link.php'; | |
| 57 | -require __DIR__ . '/src/UI/class-admin-bar.php'; | |
| 58 | -require __DIR__ . '/src/Endpoints/class-metadata-endpoint.php'; | |
| 59 | -require __DIR__ . '/src/Endpoints/class-graphql-metadata.php'; | |
| 60 | - | |
| 61 | -add_action( 'plugins_loaded', __NAMESPACE__ . '\\parsely_initialize_plugin' ); | |
| 62 | -/** | |
| 63 | - * Register the basic classes to initialize the plugin. | |
| 64 | - * | |
| 65 | - * @return void | |
| 66 | - */ | |
| 67 | -function parsely_initialize_plugin(): void { | |
| 68 | - $GLOBALS['parsely'] = new Parsely(); | |
| 69 | - $GLOBALS['parsely']->run(); | |
| 70 | - | |
| 71 | - if ( class_exists( 'WPGraphQL' ) ) { | |
| 72 | - $graphql = new GraphQL_Metadata( $GLOBALS['parsely'] ); | |
| 73 | - $graphql->run(); | |
| 74 | - } | |
| 75 | - | |
| 76 | - $scripts = new Scripts( $GLOBALS['parsely'] ); | |
| 77 | - $scripts->run(); | |
| 78 | - | |
| 79 | - $admin_bar = new Admin_Bar( $GLOBALS['parsely'] ); | |
| 80 | - $admin_bar->run(); | |
| 36 | +if ( ! defined( 'PARSELY_PLUGIN_BASENAME' ) ) { | |
| 37 | + define( 'PARSELY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); | |
| 81 | 38 | } |
| 82 | - | |
| 83 | -require __DIR__ . '/src/UI/class-admin-warning.php'; | |
| 84 | -require __DIR__ . '/src/UI/class-plugins-actions.php'; | |
| 85 | -require __DIR__ . '/src/UI/class-row-actions.php'; | |
| 86 | - | |
| 87 | -add_action( 'admin_init', __NAMESPACE__ . '\\parsely_admin_init_register' ); | |
| 88 | -/** | |
| 89 | - * Register the Parse.ly wp-admin warnings, plugin actions and row actions. | |
| 90 | - * | |
| 91 | - * @return void | |
| 92 | - */ | |
| 93 | -function parsely_admin_init_register(): void { | |
| 94 | - $admin_warning = new Admin_Warning( $GLOBALS['parsely'] ); | |
| 95 | - $admin_warning->run(); | |
| 96 | - | |
| 97 | - $plugins_actions = new Plugins_Actions(); | |
| 98 | - $plugins_actions->run(); | |
| 99 | - | |
| 100 | - $row_actions = new Row_Actions( $GLOBALS['parsely'] ); | |
| 101 | - $row_actions->run(); | |
| 39 | +if ( ! defined( 'PARSELY_PLUGIN_DIR' ) ) { | |
| 40 | + define( 'PARSELY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); | |
| 102 | 41 | } |
| 103 | - | |
| 104 | -require __DIR__ . '/src/UI/class-settings-page.php'; | |
| 105 | -require __DIR__ . '/src/UI/class-network-admin-sites-list.php'; | |
| 106 | - | |
| 107 | -add_action( 'init', __NAMESPACE__ . '\\parsely_wp_admin_early_register' ); | |
| 108 | -/** | |
| 109 | - * Register the additions the Parse.ly wp-admin settings page and Multisite Network Admin Sites List table. | |
| 110 | - * | |
| 111 | - * @return void | |
| 112 | - */ | |
| 113 | -function parsely_wp_admin_early_register(): void { | |
| 114 | - $settings_page = new Settings_Page( $GLOBALS['parsely'] ); | |
| 115 | - $settings_page->run(); | |
| 116 | - | |
| 117 | - $network_admin_sites_list = new Network_Admin_Sites_List( $GLOBALS['parsely'] ); | |
| 118 | - $network_admin_sites_list->run(); | |
| 42 | +if ( ! defined( 'PARSELY_PLUGIN_URL' ) ) { | |
| 43 | + define( 'PARSELY_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); | |
| 119 | 44 | } |
| 120 | 45 | |
| 121 | -require __DIR__ . '/src/RemoteAPI/interface-cache.php'; | |
| 122 | -require __DIR__ . '/src/RemoteAPI/interface-proxy.php'; | |
| 123 | -require __DIR__ . '/src/RemoteAPI/class-base-proxy.php'; | |
| 124 | -require __DIR__ . '/src/RemoteAPI/class-cached-proxy.php'; | |
| 125 | -require __DIR__ . '/src/RemoteAPI/class-related-proxy.php'; | |
| 126 | -require __DIR__ . '/src/RemoteAPI/class-wordpress-cache.php'; | |
| 127 | -require __DIR__ . '/src/Endpoints/class-related-api-proxy.php'; | |
| 128 | -require __DIR__ . '/src/Endpoints/class-rest-metadata.php'; | |
| 46 | +require PARSELY_PLUGIN_DIR . 'src/class-parsely.php'; | |
| 129 | 47 | |
| 130 | -add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_rest_api_init' ); | |
| 131 | -/** | |
| 132 | - * Register REST Endpoints that act as a proxy to the Parse.ly API. | |
| 133 | - * This is needed to get around a CORS issues with Firefox. | |
| 134 | - * | |
| 135 | - * @since 3.2.0 | |
| 136 | - * | |
| 137 | - * @return void | |
| 138 | - */ | |
| 139 | -function parsely_rest_api_init(): void { | |
| 140 | - $rest = new Rest_Metadata( $GLOBALS['parsely'] ); | |
| 141 | - $rest->run(); | |
| 48 | +$GLOBALS['parsely'] = new Parsely(); | |
| 142 | 49 | |
| 143 | - $proxy = new Related_Proxy( $GLOBALS['parsely'] ); | |
| 144 | - $cached_proxy = new Cached_Proxy( $proxy, new WordPress_Cache( $GLOBALS['wp_object_cache'] ) ); | |
| 145 | - $endpoint = new Related_API_Proxy( $GLOBALS['parsely'], $cached_proxy ); | |
| 146 | - $endpoint->run(); | |
| 147 | -} | |
| 50 | +require PARSELY_PLUGIN_DIR . 'src/class-parsely-recommended-widget.php'; | |
| 148 | 51 | |
| 149 | -require __DIR__ . '/src/blocks/recommendations/class-recommendations-block.php'; | |
| 150 | - | |
| 151 | -add_action( 'init', __NAMESPACE__ . '\\init_recommendations_block' ); | |
| 52 | +add_action( 'widgets_init', 'parsely_recommended_widget_register' ); | |
| 152 | 53 | /** |
| 153 | - * Register the Recommendations Block. | |
| 154 | - * | |
| 155 | - * @return void | |
| 54 | + * Register the Parse.ly Recommended widget. | |
| 156 | 55 | */ |
| 157 | -function init_recommendations_block(): void { | |
| 158 | - $recommendations_block = new Recommendations_Block(); | |
| 159 | - $recommendations_block->run(); | |
| 56 | +function parsely_recommended_widget_register() { | |
| 57 | + register_widget( 'Parsely_Recommended_Widget' ); | |
| 160 | 58 | } |
| 161 | 59 | |
| 162 | -require __DIR__ . '/src/UI/class-recommended-widget.php'; | |
| 163 | - | |
| 164 | -add_action( 'widgets_init', __NAMESPACE__ . '\\parsely_recommended_widget_register' ); | |
| 60 | +add_action( 'init', 'parsely_load_textdomain' ); | |
| 165 | 61 | /** |
| 166 | - * Register the Parse.ly Recommended widget. | |
| 62 | + * Load plugin textdomain. | |
| 167 | 63 | * |
| 168 | - * @return void | |
| 169 | - */ | |
| 170 | -function parsely_recommended_widget_register(): void { | |
| 171 | - register_widget( Recommended_Widget::class ); | |
| 172 | -} | |
| 173 | - | |
| 174 | -require __DIR__ . '/src/Integrations/class-integration.php'; | |
| 175 | -require __DIR__ . '/src/Integrations/class-integrations.php'; | |
| 176 | -require __DIR__ . '/src/Integrations/class-amp.php'; | |
| 177 | -require __DIR__ . '/src/Integrations/class-facebook-instant-articles.php'; | |
| 178 | -require __DIR__ . '/src/Integrations/class-google-web-stories.php'; | |
| 179 | - | |
| 180 | -add_action( 'init', __NAMESPACE__ . '\\parsely_integrations' ); | |
| 181 | -/** | |
| 182 | - * Instantiate Integrations collection and register built-in integrations. | |
| 64 | + * Only look for WP_LANG_DIR . '/plugins/wp-parsely-' . $locale . '.mo'. | |
| 65 | + * WP_LANG_DIR is usually WP_CONTENT_DIR . '/languages/'. | |
| 66 | + * No other fallback location is supported. | |
| 183 | 67 | * |
| 184 | - * @since 2.6.0 | |
| 68 | + * This can be removed once minimum supported WordPress is 4.6 or later. | |
| 185 | 69 | * |
| 186 | - * @return Integrations | |
| 70 | + * @since 2.5.0 | |
| 187 | 71 | */ |
| 188 | -function parsely_integrations(): Integrations { | |
| 189 | - $parsely_integrations = new Integrations(); | |
| 190 | - $parsely_integrations->register( 'amp', Amp::class ); | |
| 191 | - $parsely_integrations->register( 'fbia', Facebook_Instant_Articles::class ); | |
| 192 | - $parsely_integrations->register( 'webstories', Google_Web_Stories::class ); | |
| 193 | - $parsely_integrations = apply_filters( 'wp_parsely_add_integration', $parsely_integrations ); | |
| 194 | - $parsely_integrations->integrate(); | |
| 195 | - | |
| 196 | - return $parsely_integrations; | |
| 72 | +function parsely_load_textdomain() { | |
| 73 | + load_plugin_textdomain( 'wp-parsely' ); | |
| 197 | 74 | } |