@@ -29,396 +29,396 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class Wordlift { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | - * the plugin. |
|
| 35 | - * |
|
| 36 | - * @since 1.0.0 |
|
| 37 | - * @access protected |
|
| 38 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | - */ |
|
| 40 | - protected $loader; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The unique identifier of this plugin. |
|
| 44 | - * |
|
| 45 | - * @since 1.0.0 |
|
| 46 | - * @access protected |
|
| 47 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | - */ |
|
| 49 | - protected $plugin_name; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * The current version of the plugin. |
|
| 53 | - * |
|
| 54 | - * @since 1.0.0 |
|
| 55 | - * @access protected |
|
| 56 | - * @var string $version The current version of the plugin. |
|
| 57 | - */ |
|
| 58 | - protected $version; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * The Thumbnail service. |
|
| 62 | - * |
|
| 63 | - * @since 3.1.5 |
|
| 64 | - * @access private |
|
| 65 | - * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 66 | - */ |
|
| 67 | - private $thumbnail_service; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * The UI service. |
|
| 71 | - * |
|
| 72 | - * @since 3.2.0 |
|
| 73 | - * @access private |
|
| 74 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 75 | - */ |
|
| 76 | - private $ui_service; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * The Entity service. |
|
| 80 | - * |
|
| 81 | - * @since 3.1.0 |
|
| 82 | - * @access private |
|
| 83 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 84 | - */ |
|
| 85 | - private $entity_service; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * The User service. |
|
| 89 | - * |
|
| 90 | - * @since 3.1.7 |
|
| 91 | - * @access private |
|
| 92 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 93 | - */ |
|
| 94 | - private $user_service; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * The Timeline service. |
|
| 98 | - * |
|
| 99 | - * @since 3.1.0 |
|
| 100 | - * @access private |
|
| 101 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 102 | - */ |
|
| 103 | - private $timeline_service; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * The Redirect service. |
|
| 107 | - * |
|
| 108 | - * @since 3.2.0 |
|
| 109 | - * @access private |
|
| 110 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 111 | - */ |
|
| 112 | - private $redirect_service; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * The Entity Types Taxonomy Walker. |
|
| 116 | - * |
|
| 117 | - * @since 3.1.0 |
|
| 118 | - * @access private |
|
| 119 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 120 | - */ |
|
| 121 | - private $entity_types_taxonomy_walker; |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * The ShareThis service. |
|
| 125 | - * |
|
| 126 | - * @since 3.2.0 |
|
| 127 | - * @access private |
|
| 128 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 129 | - */ |
|
| 130 | - private $sharethis_service; |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Define the core functionality of the plugin. |
|
| 134 | - * |
|
| 135 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 136 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 137 | - * the public-facing side of the site. |
|
| 138 | - * |
|
| 139 | - * @since 1.0.0 |
|
| 140 | - */ |
|
| 141 | - public function __construct() { |
|
| 142 | - |
|
| 143 | - $this->plugin_name = 'wordlift'; |
|
| 144 | - |
|
| 145 | - $this->version = '3.2.1'; |
|
| 146 | - |
|
| 147 | - $this->load_dependencies(); |
|
| 148 | - $this->set_locale(); |
|
| 149 | - $this->define_admin_hooks(); |
|
| 150 | - $this->define_public_hooks(); |
|
| 151 | - |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Load the required dependencies for this plugin. |
|
| 156 | - * |
|
| 157 | - * Include the following files that make up the plugin: |
|
| 158 | - * |
|
| 159 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 160 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 161 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 162 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 163 | - * |
|
| 164 | - * Create an instance of the loader which will be used to register the hooks |
|
| 165 | - * with WordPress. |
|
| 166 | - * |
|
| 167 | - * @since 1.0.0 |
|
| 168 | - * @access private |
|
| 169 | - */ |
|
| 170 | - private function load_dependencies() { |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * The class responsible for orchestrating the actions and filters of the |
|
| 174 | - * core plugin. |
|
| 175 | - */ |
|
| 176 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * The class responsible for defining internationalization functionality |
|
| 180 | - * of the plugin. |
|
| 181 | - */ |
|
| 182 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * The Redirect service. |
|
| 186 | - */ |
|
| 187 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * The Log service. |
|
| 191 | - */ |
|
| 192 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * The Query builder. |
|
| 196 | - */ |
|
| 197 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * The Schema service. |
|
| 201 | - */ |
|
| 202 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * The UI service. |
|
| 206 | - */ |
|
| 207 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * The Thumbnail service. |
|
| 211 | - */ |
|
| 212 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * The Entity Types Taxonomy service. |
|
| 216 | - */ |
|
| 217 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * The Entity service. |
|
| 221 | - */ |
|
| 222 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * The User service. |
|
| 226 | - */ |
|
| 227 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * The Timeline service. |
|
| 231 | - */ |
|
| 232 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 236 | - */ |
|
| 237 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 241 | - */ |
|
| 242 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * The Notice service. |
|
| 246 | - */ |
|
| 247 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 251 | - * side of the site. |
|
| 252 | - */ |
|
| 253 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * The Timeline shortcode. |
|
| 257 | - */ |
|
| 258 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * The ShareThis service. |
|
| 262 | - */ |
|
| 263 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 264 | - |
|
| 265 | - $this->loader = new Wordlift_Loader(); |
|
| 266 | - |
|
| 267 | - // Instantiate a global logger. |
|
| 268 | - global $wl_logger; |
|
| 269 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 270 | - |
|
| 271 | - // Create an instance of the UI service. |
|
| 272 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 273 | - |
|
| 274 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 275 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 276 | - |
|
| 277 | - // Create an instance of the Schema service. |
|
| 278 | - new Wordlift_Schema_Service(); |
|
| 279 | - |
|
| 280 | - // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 281 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service ); |
|
| 282 | - |
|
| 283 | - // Create an instance of the User service. |
|
| 284 | - $this->user_service = new Wordlift_User_Service(); |
|
| 285 | - |
|
| 286 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 287 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 288 | - |
|
| 289 | - // Create a new instance of the Redirect service. |
|
| 290 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 291 | - |
|
| 292 | - // Create an instance of the Timeline shortcode. |
|
| 293 | - new Wordlift_Timeline_Shortcode(); |
|
| 294 | - |
|
| 295 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 296 | - |
|
| 297 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 298 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 299 | - |
|
| 300 | - // Create an instance of the Notice service. |
|
| 301 | - new Wordlift_Notice_Service(); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Define the locale for this plugin for internationalization. |
|
| 306 | - * |
|
| 307 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 308 | - * with WordPress. |
|
| 309 | - * |
|
| 310 | - * @since 1.0.0 |
|
| 311 | - * @access private |
|
| 312 | - */ |
|
| 313 | - private function set_locale() { |
|
| 314 | - |
|
| 315 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 316 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 317 | - |
|
| 318 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 319 | - |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * Register all of the hooks related to the admin area functionality |
|
| 324 | - * of the plugin. |
|
| 325 | - * |
|
| 326 | - * @since 1.0.0 |
|
| 327 | - * @access private |
|
| 328 | - */ |
|
| 329 | - private function define_admin_hooks() { |
|
| 330 | - |
|
| 331 | - $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 332 | - |
|
| 333 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 334 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 335 | - |
|
| 336 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 337 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 338 | - |
|
| 339 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 340 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_post_meta', 10, 4 ); |
|
| 341 | - |
|
| 342 | - // Hook posts inserts (or updates) to the user service. |
|
| 343 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 344 | - |
|
| 345 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 346 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 347 | - |
|
| 348 | - // Register custom allowed redirect hosts. |
|
| 349 | - $this->loader->add_filter( 'allowed_redirect_hosts' , $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 350 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 351 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 352 | - |
|
| 353 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 354 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 355 | - $this->loader->add_filter( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 356 | - $this->loader->add_filter( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 357 | - |
|
| 358 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 359 | - |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * Register all of the hooks related to the public-facing functionality |
|
| 364 | - * of the plugin. |
|
| 365 | - * |
|
| 366 | - * @since 1.0.0 |
|
| 367 | - * @access private |
|
| 368 | - */ |
|
| 369 | - private function define_public_hooks() { |
|
| 370 | - |
|
| 371 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 372 | - |
|
| 373 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 374 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 375 | - |
|
| 376 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 377 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 378 | - |
|
| 379 | - // Hook the ShareThis service. |
|
| 380 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 381 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 386 | - * |
|
| 387 | - * @since 1.0.0 |
|
| 388 | - */ |
|
| 389 | - public function run() { |
|
| 390 | - $this->loader->run(); |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 395 | - * WordPress and to define internationalization functionality. |
|
| 396 | - * |
|
| 397 | - * @since 1.0.0 |
|
| 398 | - * @return string The name of the plugin. |
|
| 399 | - */ |
|
| 400 | - public function get_plugin_name() { |
|
| 401 | - return $this->plugin_name; |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - /** |
|
| 405 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 406 | - * |
|
| 407 | - * @since 1.0.0 |
|
| 408 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 409 | - */ |
|
| 410 | - public function get_loader() { |
|
| 411 | - return $this->loader; |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * Retrieve the version number of the plugin. |
|
| 416 | - * |
|
| 417 | - * @since 1.0.0 |
|
| 418 | - * @return string The version number of the plugin. |
|
| 419 | - */ |
|
| 420 | - public function get_version() { |
|
| 421 | - return $this->version; |
|
| 422 | - } |
|
| 32 | + /** |
|
| 33 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | + * the plugin. |
|
| 35 | + * |
|
| 36 | + * @since 1.0.0 |
|
| 37 | + * @access protected |
|
| 38 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | + */ |
|
| 40 | + protected $loader; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The unique identifier of this plugin. |
|
| 44 | + * |
|
| 45 | + * @since 1.0.0 |
|
| 46 | + * @access protected |
|
| 47 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | + */ |
|
| 49 | + protected $plugin_name; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * The current version of the plugin. |
|
| 53 | + * |
|
| 54 | + * @since 1.0.0 |
|
| 55 | + * @access protected |
|
| 56 | + * @var string $version The current version of the plugin. |
|
| 57 | + */ |
|
| 58 | + protected $version; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * The Thumbnail service. |
|
| 62 | + * |
|
| 63 | + * @since 3.1.5 |
|
| 64 | + * @access private |
|
| 65 | + * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 66 | + */ |
|
| 67 | + private $thumbnail_service; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The UI service. |
|
| 71 | + * |
|
| 72 | + * @since 3.2.0 |
|
| 73 | + * @access private |
|
| 74 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 75 | + */ |
|
| 76 | + private $ui_service; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * The Entity service. |
|
| 80 | + * |
|
| 81 | + * @since 3.1.0 |
|
| 82 | + * @access private |
|
| 83 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 84 | + */ |
|
| 85 | + private $entity_service; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * The User service. |
|
| 89 | + * |
|
| 90 | + * @since 3.1.7 |
|
| 91 | + * @access private |
|
| 92 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 93 | + */ |
|
| 94 | + private $user_service; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * The Timeline service. |
|
| 98 | + * |
|
| 99 | + * @since 3.1.0 |
|
| 100 | + * @access private |
|
| 101 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 102 | + */ |
|
| 103 | + private $timeline_service; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * The Redirect service. |
|
| 107 | + * |
|
| 108 | + * @since 3.2.0 |
|
| 109 | + * @access private |
|
| 110 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 111 | + */ |
|
| 112 | + private $redirect_service; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * The Entity Types Taxonomy Walker. |
|
| 116 | + * |
|
| 117 | + * @since 3.1.0 |
|
| 118 | + * @access private |
|
| 119 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 120 | + */ |
|
| 121 | + private $entity_types_taxonomy_walker; |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * The ShareThis service. |
|
| 125 | + * |
|
| 126 | + * @since 3.2.0 |
|
| 127 | + * @access private |
|
| 128 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 129 | + */ |
|
| 130 | + private $sharethis_service; |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Define the core functionality of the plugin. |
|
| 134 | + * |
|
| 135 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 136 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 137 | + * the public-facing side of the site. |
|
| 138 | + * |
|
| 139 | + * @since 1.0.0 |
|
| 140 | + */ |
|
| 141 | + public function __construct() { |
|
| 142 | + |
|
| 143 | + $this->plugin_name = 'wordlift'; |
|
| 144 | + |
|
| 145 | + $this->version = '3.2.1'; |
|
| 146 | + |
|
| 147 | + $this->load_dependencies(); |
|
| 148 | + $this->set_locale(); |
|
| 149 | + $this->define_admin_hooks(); |
|
| 150 | + $this->define_public_hooks(); |
|
| 151 | + |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Load the required dependencies for this plugin. |
|
| 156 | + * |
|
| 157 | + * Include the following files that make up the plugin: |
|
| 158 | + * |
|
| 159 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 160 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 161 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 162 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 163 | + * |
|
| 164 | + * Create an instance of the loader which will be used to register the hooks |
|
| 165 | + * with WordPress. |
|
| 166 | + * |
|
| 167 | + * @since 1.0.0 |
|
| 168 | + * @access private |
|
| 169 | + */ |
|
| 170 | + private function load_dependencies() { |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * The class responsible for orchestrating the actions and filters of the |
|
| 174 | + * core plugin. |
|
| 175 | + */ |
|
| 176 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * The class responsible for defining internationalization functionality |
|
| 180 | + * of the plugin. |
|
| 181 | + */ |
|
| 182 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * The Redirect service. |
|
| 186 | + */ |
|
| 187 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * The Log service. |
|
| 191 | + */ |
|
| 192 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * The Query builder. |
|
| 196 | + */ |
|
| 197 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * The Schema service. |
|
| 201 | + */ |
|
| 202 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * The UI service. |
|
| 206 | + */ |
|
| 207 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * The Thumbnail service. |
|
| 211 | + */ |
|
| 212 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * The Entity Types Taxonomy service. |
|
| 216 | + */ |
|
| 217 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * The Entity service. |
|
| 221 | + */ |
|
| 222 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * The User service. |
|
| 226 | + */ |
|
| 227 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * The Timeline service. |
|
| 231 | + */ |
|
| 232 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 236 | + */ |
|
| 237 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 241 | + */ |
|
| 242 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * The Notice service. |
|
| 246 | + */ |
|
| 247 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 251 | + * side of the site. |
|
| 252 | + */ |
|
| 253 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * The Timeline shortcode. |
|
| 257 | + */ |
|
| 258 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * The ShareThis service. |
|
| 262 | + */ |
|
| 263 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 264 | + |
|
| 265 | + $this->loader = new Wordlift_Loader(); |
|
| 266 | + |
|
| 267 | + // Instantiate a global logger. |
|
| 268 | + global $wl_logger; |
|
| 269 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 270 | + |
|
| 271 | + // Create an instance of the UI service. |
|
| 272 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 273 | + |
|
| 274 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 275 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 276 | + |
|
| 277 | + // Create an instance of the Schema service. |
|
| 278 | + new Wordlift_Schema_Service(); |
|
| 279 | + |
|
| 280 | + // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 281 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service ); |
|
| 282 | + |
|
| 283 | + // Create an instance of the User service. |
|
| 284 | + $this->user_service = new Wordlift_User_Service(); |
|
| 285 | + |
|
| 286 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 287 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 288 | + |
|
| 289 | + // Create a new instance of the Redirect service. |
|
| 290 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 291 | + |
|
| 292 | + // Create an instance of the Timeline shortcode. |
|
| 293 | + new Wordlift_Timeline_Shortcode(); |
|
| 294 | + |
|
| 295 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 296 | + |
|
| 297 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 298 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 299 | + |
|
| 300 | + // Create an instance of the Notice service. |
|
| 301 | + new Wordlift_Notice_Service(); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * Define the locale for this plugin for internationalization. |
|
| 306 | + * |
|
| 307 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 308 | + * with WordPress. |
|
| 309 | + * |
|
| 310 | + * @since 1.0.0 |
|
| 311 | + * @access private |
|
| 312 | + */ |
|
| 313 | + private function set_locale() { |
|
| 314 | + |
|
| 315 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 316 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 317 | + |
|
| 318 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 319 | + |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * Register all of the hooks related to the admin area functionality |
|
| 324 | + * of the plugin. |
|
| 325 | + * |
|
| 326 | + * @since 1.0.0 |
|
| 327 | + * @access private |
|
| 328 | + */ |
|
| 329 | + private function define_admin_hooks() { |
|
| 330 | + |
|
| 331 | + $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 332 | + |
|
| 333 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 334 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 335 | + |
|
| 336 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 337 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 338 | + |
|
| 339 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 340 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_post_meta', 10, 4 ); |
|
| 341 | + |
|
| 342 | + // Hook posts inserts (or updates) to the user service. |
|
| 343 | + $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 344 | + |
|
| 345 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 346 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 347 | + |
|
| 348 | + // Register custom allowed redirect hosts. |
|
| 349 | + $this->loader->add_filter( 'allowed_redirect_hosts' , $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 350 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 351 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 352 | + |
|
| 353 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 354 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 355 | + $this->loader->add_filter( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 356 | + $this->loader->add_filter( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 357 | + |
|
| 358 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 359 | + |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * Register all of the hooks related to the public-facing functionality |
|
| 364 | + * of the plugin. |
|
| 365 | + * |
|
| 366 | + * @since 1.0.0 |
|
| 367 | + * @access private |
|
| 368 | + */ |
|
| 369 | + private function define_public_hooks() { |
|
| 370 | + |
|
| 371 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 372 | + |
|
| 373 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 374 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 375 | + |
|
| 376 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 377 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 378 | + |
|
| 379 | + // Hook the ShareThis service. |
|
| 380 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 381 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 386 | + * |
|
| 387 | + * @since 1.0.0 |
|
| 388 | + */ |
|
| 389 | + public function run() { |
|
| 390 | + $this->loader->run(); |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 395 | + * WordPress and to define internationalization functionality. |
|
| 396 | + * |
|
| 397 | + * @since 1.0.0 |
|
| 398 | + * @return string The name of the plugin. |
|
| 399 | + */ |
|
| 400 | + public function get_plugin_name() { |
|
| 401 | + return $this->plugin_name; |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + /** |
|
| 405 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 406 | + * |
|
| 407 | + * @since 1.0.0 |
|
| 408 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 409 | + */ |
|
| 410 | + public function get_loader() { |
|
| 411 | + return $this->loader; |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * Retrieve the version number of the plugin. |
|
| 416 | + * |
|
| 417 | + * @since 1.0.0 |
|
| 418 | + * @return string The version number of the plugin. |
|
| 419 | + */ |
|
| 420 | + public function get_version() { |
|
| 421 | + return $this->version; |
|
| 422 | + } |
|
| 423 | 423 | |
| 424 | 424 | } |