@@ -3,20 +3,20 @@ |
||
| 3 | 3 | |
| 4 | 4 | class Terms_Compat { |
| 5 | 5 | |
| 6 | - public static function get_terms( $taxonomy, $args ) { |
|
| 7 | - global $wp_version; |
|
| 6 | + public static function get_terms( $taxonomy, $args ) { |
|
| 7 | + global $wp_version; |
|
| 8 | 8 | |
| 9 | - if ( version_compare( $wp_version, '4.5', '<' ) ) { |
|
| 10 | - return get_terms( $taxonomy, $args ); |
|
| 11 | - } else { |
|
| 12 | - $args['taxonomy'] = $taxonomy; |
|
| 13 | - return get_terms( $args ); |
|
| 14 | - } |
|
| 15 | - } |
|
| 9 | + if ( version_compare( $wp_version, '4.5', '<' ) ) { |
|
| 10 | + return get_terms( $taxonomy, $args ); |
|
| 11 | + } else { |
|
| 12 | + $args['taxonomy'] = $taxonomy; |
|
| 13 | + return get_terms( $args ); |
|
| 14 | + } |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public static function get_public_taxonomies() { |
|
| 18 | - return get_taxonomies( array( 'public' => true ) ); |
|
| 19 | - } |
|
| 17 | + public static function get_public_taxonomies() { |
|
| 18 | + return get_taxonomies( array( 'public' => true ) ); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | } |
| 23 | 23 | \ No newline at end of file |
@@ -3,19 +3,19 @@ |
||
| 3 | 3 | |
| 4 | 4 | class Terms_Compat { |
| 5 | 5 | |
| 6 | - public static function get_terms( $taxonomy, $args ) { |
|
| 6 | + public static function get_terms($taxonomy, $args) { |
|
| 7 | 7 | global $wp_version; |
| 8 | 8 | |
| 9 | - if ( version_compare( $wp_version, '4.5', '<' ) ) { |
|
| 10 | - return get_terms( $taxonomy, $args ); |
|
| 9 | + if (version_compare($wp_version, '4.5', '<')) { |
|
| 10 | + return get_terms($taxonomy, $args); |
|
| 11 | 11 | } else { |
| 12 | 12 | $args['taxonomy'] = $taxonomy; |
| 13 | - return get_terms( $args ); |
|
| 13 | + return get_terms($args); |
|
| 14 | 14 | } |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public static function get_public_taxonomies() { |
| 18 | - return get_taxonomies( array( 'public' => true ) ); |
|
| 18 | + return get_taxonomies(array('public' => true)); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
@@ -84,1649 +84,1649 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | class Wordlift { |
| 86 | 86 | |
| 87 | - //<editor-fold desc="## FIELDS"> |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 91 | - * the plugin. |
|
| 92 | - * |
|
| 93 | - * @since 1.0.0 |
|
| 94 | - * @access protected |
|
| 95 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 96 | - */ |
|
| 97 | - protected $loader; |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * The unique identifier of this plugin. |
|
| 101 | - * |
|
| 102 | - * @since 1.0.0 |
|
| 103 | - * @access protected |
|
| 104 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 105 | - */ |
|
| 106 | - protected $plugin_name; |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * The current version of the plugin. |
|
| 110 | - * |
|
| 111 | - * @since 1.0.0 |
|
| 112 | - * @access protected |
|
| 113 | - * @var string $version The current version of the plugin. |
|
| 114 | - */ |
|
| 115 | - protected $version; |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 119 | - * |
|
| 120 | - * @since 3.12.0 |
|
| 121 | - * @access protected |
|
| 122 | - * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 123 | - */ |
|
| 124 | - protected $tinymce_adapter; |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * The {@link Faq_Tinymce_Adapter} instance |
|
| 128 | - * @since 3.26.0 |
|
| 129 | - * @access protected |
|
| 130 | - * @var Faq_Tinymce_Adapter $faq_tinymce_adapter . |
|
| 131 | - */ |
|
| 132 | - //protected $faq_tinymce_adapter; |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * The Thumbnail service. |
|
| 136 | - * |
|
| 137 | - * @since 3.1.5 |
|
| 138 | - * @access private |
|
| 139 | - * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 140 | - */ |
|
| 141 | - private $thumbnail_service; |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * The UI service. |
|
| 145 | - * |
|
| 146 | - * @since 3.2.0 |
|
| 147 | - * @access private |
|
| 148 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 149 | - */ |
|
| 150 | - private $ui_service; |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * The Schema service. |
|
| 154 | - * |
|
| 155 | - * @since 3.3.0 |
|
| 156 | - * @access protected |
|
| 157 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 158 | - */ |
|
| 159 | - protected $schema_service; |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * The Entity service. |
|
| 163 | - * |
|
| 164 | - * @since 3.1.0 |
|
| 165 | - * @access protected |
|
| 166 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 167 | - */ |
|
| 168 | - protected $entity_service; |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * The Topic Taxonomy service. |
|
| 172 | - * |
|
| 173 | - * @since 3.5.0 |
|
| 174 | - * @access private |
|
| 175 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 176 | - */ |
|
| 177 | - private $topic_taxonomy_service; |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * The Entity Types Taxonomy service. |
|
| 181 | - * |
|
| 182 | - * @since 3.18.0 |
|
| 183 | - * @access private |
|
| 184 | - * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 185 | - */ |
|
| 186 | - private $entity_types_taxonomy_service; |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * The User service. |
|
| 190 | - * |
|
| 191 | - * @since 3.1.7 |
|
| 192 | - * @access protected |
|
| 193 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 194 | - */ |
|
| 195 | - protected $user_service; |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * The Timeline service. |
|
| 199 | - * |
|
| 200 | - * @since 3.1.0 |
|
| 201 | - * @access private |
|
| 202 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 203 | - */ |
|
| 204 | - private $timeline_service; |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * The Redirect service. |
|
| 208 | - * |
|
| 209 | - * @since 3.2.0 |
|
| 210 | - * @access private |
|
| 211 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 212 | - */ |
|
| 213 | - private $redirect_service; |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * The Notice service. |
|
| 217 | - * |
|
| 218 | - * @since 3.3.0 |
|
| 219 | - * @access private |
|
| 220 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 221 | - */ |
|
| 222 | - private $notice_service; |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * The Entity list customization. |
|
| 226 | - * |
|
| 227 | - * @since 3.3.0 |
|
| 228 | - * @access protected |
|
| 229 | - * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 230 | - */ |
|
| 231 | - protected $entity_list_service; |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * The Entity Types Taxonomy Walker. |
|
| 235 | - * |
|
| 236 | - * @since 3.1.0 |
|
| 237 | - * @access private |
|
| 238 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 239 | - */ |
|
| 240 | - private $entity_types_taxonomy_walker; |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * The ShareThis service. |
|
| 244 | - * |
|
| 245 | - * @since 3.2.0 |
|
| 246 | - * @access private |
|
| 247 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 248 | - */ |
|
| 249 | - private $sharethis_service; |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * The PrimaShop adapter. |
|
| 253 | - * |
|
| 254 | - * @since 3.2.3 |
|
| 255 | - * @access private |
|
| 256 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 257 | - */ |
|
| 258 | - private $primashop_adapter; |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * The WordLift Dashboard adapter. |
|
| 262 | - * |
|
| 263 | - * @since 3.4.0 |
|
| 264 | - * @access private |
|
| 265 | - * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 266 | - */ |
|
| 267 | - private $dashboard_service; |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * The entity type service. |
|
| 271 | - * |
|
| 272 | - * @since 3.6.0 |
|
| 273 | - * @access private |
|
| 274 | - * @var \Wordlift_Entity_Post_Type_Service |
|
| 275 | - */ |
|
| 276 | - private $entity_post_type_service; |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 280 | - * |
|
| 281 | - * @since 3.6.0 |
|
| 282 | - * @access private |
|
| 283 | - * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 284 | - */ |
|
| 285 | - private $entity_link_service; |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 289 | - * |
|
| 290 | - * @since 3.6.0 |
|
| 291 | - * @access protected |
|
| 292 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 293 | - */ |
|
| 294 | - protected $sparql_service; |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * A {@link Wordlift_Import_Service} instance. |
|
| 298 | - * |
|
| 299 | - * @since 3.6.0 |
|
| 300 | - * @access private |
|
| 301 | - * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 302 | - */ |
|
| 303 | - private $import_service; |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * A {@link Wordlift_Rebuild_Service} instance. |
|
| 307 | - * |
|
| 308 | - * @since 3.6.0 |
|
| 309 | - * @access private |
|
| 310 | - * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 311 | - */ |
|
| 312 | - private $rebuild_service; |
|
| 313 | - |
|
| 314 | - /** |
|
| 315 | - * A {@link Wordlift_Jsonld_Service} instance. |
|
| 316 | - * |
|
| 317 | - * @since 3.7.0 |
|
| 318 | - * @access protected |
|
| 319 | - * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 320 | - */ |
|
| 321 | - protected $jsonld_service; |
|
| 322 | - |
|
| 323 | - /** |
|
| 324 | - * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 325 | - * |
|
| 326 | - * @since 3.14.0 |
|
| 327 | - * @access protected |
|
| 328 | - * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 329 | - */ |
|
| 330 | - protected $jsonld_website_converter; |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * A {@link Wordlift_Property_Factory} instance. |
|
| 334 | - * |
|
| 335 | - * @since 3.7.0 |
|
| 336 | - * @access private |
|
| 337 | - * @var \Wordlift_Property_Factory $property_factory |
|
| 338 | - */ |
|
| 339 | - private $property_factory; |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * The 'Download Your Data' page. |
|
| 343 | - * |
|
| 344 | - * @since 3.6.0 |
|
| 345 | - * @access private |
|
| 346 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 347 | - */ |
|
| 348 | - private $download_your_data_page; |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * The 'WordLift Settings' page. |
|
| 352 | - * |
|
| 353 | - * @since 3.11.0 |
|
| 354 | - * @access protected |
|
| 355 | - * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 356 | - */ |
|
| 357 | - protected $settings_page; |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * The install wizard page. |
|
| 361 | - * |
|
| 362 | - * @since 3.9.0 |
|
| 363 | - * @access private |
|
| 364 | - * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 365 | - */ |
|
| 366 | - public $admin_setup; |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 370 | - * linking of entities to their pages. |
|
| 371 | - * |
|
| 372 | - * @since 3.8.0 |
|
| 373 | - * @access private |
|
| 374 | - * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 375 | - */ |
|
| 376 | - private $content_filter_service; |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * The Faq Content filter service |
|
| 380 | - * @since 3.26.0 |
|
| 381 | - * @access private |
|
| 382 | - * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 383 | - */ |
|
| 384 | - private $faq_content_filter_service; |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 388 | - * |
|
| 389 | - * @since 3.9.0 |
|
| 390 | - * @access private |
|
| 391 | - * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 392 | - */ |
|
| 393 | - private $key_validation_service; |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * A {@link Wordlift_Rating_Service} instance. |
|
| 397 | - * |
|
| 398 | - * @since 3.10.0 |
|
| 399 | - * @access private |
|
| 400 | - * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 401 | - */ |
|
| 402 | - private $rating_service; |
|
| 403 | - |
|
| 404 | - /** |
|
| 405 | - * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 406 | - * |
|
| 407 | - * @since 3.10.0 |
|
| 408 | - * @access protected |
|
| 409 | - * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 410 | - */ |
|
| 411 | - protected $post_to_jsonld_converter; |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 415 | - * |
|
| 416 | - * @since 3.10.0 |
|
| 417 | - * @access protected |
|
| 418 | - * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 419 | - */ |
|
| 420 | - protected $configuration_service; |
|
| 421 | - |
|
| 422 | - /** |
|
| 423 | - * A {@link Wordlift_Install_Service} instance. |
|
| 424 | - * |
|
| 425 | - * @since 3.18.0 |
|
| 426 | - * @access protected |
|
| 427 | - * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 428 | - */ |
|
| 429 | - protected $install_service; |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 433 | - * |
|
| 434 | - * @since 3.10.0 |
|
| 435 | - * @access protected |
|
| 436 | - * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 437 | - */ |
|
| 438 | - protected $entity_type_service; |
|
| 439 | - |
|
| 440 | - /** |
|
| 441 | - * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 442 | - * |
|
| 443 | - * @since 3.10.0 |
|
| 444 | - * @access protected |
|
| 445 | - * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 446 | - */ |
|
| 447 | - protected $entity_post_to_jsonld_converter; |
|
| 448 | - |
|
| 449 | - /** |
|
| 450 | - * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 451 | - * |
|
| 452 | - * @since 3.10.0 |
|
| 453 | - * @access protected |
|
| 454 | - * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 455 | - */ |
|
| 456 | - protected $postid_to_jsonld_converter; |
|
| 457 | - |
|
| 458 | - /** |
|
| 459 | - * The {@link Wordlift_Admin_Status_Page} class. |
|
| 460 | - * |
|
| 461 | - * @since 3.9.8 |
|
| 462 | - * @access private |
|
| 463 | - * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 464 | - */ |
|
| 465 | - private $status_page; |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 469 | - * |
|
| 470 | - * @since 3.11.0 |
|
| 471 | - * @access protected |
|
| 472 | - * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 473 | - */ |
|
| 474 | - protected $category_taxonomy_service; |
|
| 475 | - |
|
| 476 | - /** |
|
| 477 | - * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 478 | - * |
|
| 479 | - * @since 3.11.0 |
|
| 480 | - * @access protected |
|
| 481 | - * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 482 | - */ |
|
| 483 | - protected $entity_page_service; |
|
| 484 | - |
|
| 485 | - /** |
|
| 486 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 487 | - * |
|
| 488 | - * @since 3.11.0 |
|
| 489 | - * @access protected |
|
| 490 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 491 | - */ |
|
| 492 | - protected $settings_page_action_link; |
|
| 493 | - |
|
| 494 | - /** |
|
| 495 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 496 | - * |
|
| 497 | - * @since 3.11.0 |
|
| 498 | - * @access protected |
|
| 499 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 500 | - */ |
|
| 501 | - protected $analytics_settings_page_action_link; |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * The {@link Wordlift_Analytics_Connect} class. |
|
| 505 | - * |
|
| 506 | - * @since 3.11.0 |
|
| 507 | - * @access protected |
|
| 508 | - * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 509 | - */ |
|
| 510 | - protected $analytics_connect; |
|
| 511 | - |
|
| 512 | - /** |
|
| 513 | - * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 514 | - * |
|
| 515 | - * @since 3.11.0 |
|
| 516 | - * @access protected |
|
| 517 | - * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 518 | - */ |
|
| 519 | - protected $publisher_ajax_adapter; |
|
| 520 | - |
|
| 521 | - /** |
|
| 522 | - * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 523 | - * |
|
| 524 | - * @since 3.11.0 |
|
| 525 | - * @access protected |
|
| 526 | - * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 527 | - */ |
|
| 528 | - protected $input_element; |
|
| 529 | - |
|
| 530 | - /** |
|
| 531 | - * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 532 | - * |
|
| 533 | - * @since 3.13.0 |
|
| 534 | - * @access protected |
|
| 535 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 536 | - */ |
|
| 537 | - protected $radio_input_element; |
|
| 538 | - |
|
| 539 | - /** |
|
| 540 | - * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 541 | - * |
|
| 542 | - * @since 3.11.0 |
|
| 543 | - * @access protected |
|
| 544 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 545 | - */ |
|
| 546 | - protected $language_select_element; |
|
| 547 | - |
|
| 548 | - /** |
|
| 549 | - * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 550 | - * |
|
| 551 | - * @since 3.18.0 |
|
| 552 | - * @access protected |
|
| 553 | - * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 554 | - */ |
|
| 555 | - protected $country_select_element; |
|
| 556 | - |
|
| 557 | - /** |
|
| 558 | - * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 559 | - * |
|
| 560 | - * @since 3.11.0 |
|
| 561 | - * @access protected |
|
| 562 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 563 | - */ |
|
| 564 | - protected $publisher_element; |
|
| 565 | - |
|
| 566 | - /** |
|
| 567 | - * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 568 | - * |
|
| 569 | - * @since 3.11.0 |
|
| 570 | - * @access protected |
|
| 571 | - * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 572 | - */ |
|
| 573 | - protected $select2_element; |
|
| 574 | - |
|
| 575 | - /** |
|
| 576 | - * The controller for the entity type list admin page |
|
| 577 | - * |
|
| 578 | - * @since 3.11.0 |
|
| 579 | - * @access private |
|
| 580 | - * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 581 | - */ |
|
| 582 | - private $entity_type_admin_page; |
|
| 583 | - |
|
| 584 | - /** |
|
| 585 | - * The controller for the entity type settings admin page |
|
| 586 | - * |
|
| 587 | - * @since 3.11.0 |
|
| 588 | - * @access private |
|
| 589 | - * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 590 | - */ |
|
| 591 | - private $entity_type_settings_admin_page; |
|
| 592 | - |
|
| 593 | - /** |
|
| 594 | - * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 595 | - * |
|
| 596 | - * @since 3.11.0 |
|
| 597 | - * @access protected |
|
| 598 | - * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 599 | - */ |
|
| 600 | - protected $related_entities_cloud_widget; |
|
| 601 | - |
|
| 602 | - /** |
|
| 603 | - * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 604 | - * |
|
| 605 | - * @since 3.14.0 |
|
| 606 | - * @access protected |
|
| 607 | - * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 608 | - */ |
|
| 609 | - protected $author_element; |
|
| 610 | - |
|
| 611 | - /** |
|
| 612 | - * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 613 | - * |
|
| 614 | - * @since 3.12.0 |
|
| 615 | - * @access protected |
|
| 616 | - * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 617 | - */ |
|
| 618 | - protected $sample_data_service; |
|
| 619 | - |
|
| 620 | - /** |
|
| 621 | - * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 622 | - * |
|
| 623 | - * @since 3.12.0 |
|
| 624 | - * @access protected |
|
| 625 | - * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 626 | - */ |
|
| 627 | - protected $sample_data_ajax_adapter; |
|
| 628 | - |
|
| 629 | - /** |
|
| 630 | - * The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 631 | - * |
|
| 632 | - * @since 3.14.3 |
|
| 633 | - * @access private |
|
| 634 | - * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 635 | - */ |
|
| 636 | - private $relation_rebuild_service; |
|
| 637 | - |
|
| 638 | - /** |
|
| 639 | - * The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 640 | - * |
|
| 641 | - * @since 3.14.3 |
|
| 642 | - * @access private |
|
| 643 | - * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 644 | - */ |
|
| 645 | - private $relation_rebuild_adapter; |
|
| 646 | - |
|
| 647 | - /** |
|
| 648 | - * The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 649 | - * |
|
| 650 | - * @since 3.18.0 |
|
| 651 | - * @access private |
|
| 652 | - * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 653 | - */ |
|
| 654 | - private $reference_rebuild_service; |
|
| 655 | - |
|
| 656 | - /** |
|
| 657 | - * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 658 | - * |
|
| 659 | - * @since 3.16.0 |
|
| 660 | - * @access protected |
|
| 661 | - * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 662 | - */ |
|
| 663 | - protected $google_analytics_export_service; |
|
| 664 | - |
|
| 665 | - /** |
|
| 666 | - * {@link Wordlift}'s singleton instance. |
|
| 667 | - * |
|
| 668 | - * @since 3.15.0 |
|
| 669 | - * @access protected |
|
| 670 | - * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 671 | - */ |
|
| 672 | - protected $entity_type_adapter; |
|
| 673 | - |
|
| 674 | - /** |
|
| 675 | - * The {@link Wordlift_Storage_Factory} instance. |
|
| 676 | - * |
|
| 677 | - * @since 3.15.0 |
|
| 678 | - * @access protected |
|
| 679 | - * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 680 | - */ |
|
| 681 | - protected $storage_factory; |
|
| 682 | - |
|
| 683 | - /** |
|
| 684 | - * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 685 | - * |
|
| 686 | - * @since 3.15.0 |
|
| 687 | - * @access protected |
|
| 688 | - * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 689 | - */ |
|
| 690 | - protected $rendition_factory; |
|
| 691 | - |
|
| 692 | - /** |
|
| 693 | - * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 694 | - * |
|
| 695 | - * @since 3.15.0 |
|
| 696 | - * @access private |
|
| 697 | - * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 698 | - */ |
|
| 699 | - private $autocomplete_adapter; |
|
| 700 | - |
|
| 701 | - /** |
|
| 702 | - * The {@link Wordlift_Relation_Service} instance. |
|
| 703 | - * |
|
| 704 | - * @since 3.15.0 |
|
| 705 | - * @access protected |
|
| 706 | - * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance. |
|
| 707 | - */ |
|
| 708 | - protected $relation_service; |
|
| 709 | - |
|
| 710 | - /** |
|
| 711 | - * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 712 | - * |
|
| 713 | - * @since 3.16.0 |
|
| 714 | - * @access protected |
|
| 715 | - * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 716 | - * |
|
| 717 | - */ |
|
| 718 | - protected $cached_postid_to_jsonld_converter; |
|
| 719 | - |
|
| 720 | - /** |
|
| 721 | - * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 722 | - * |
|
| 723 | - * @since 3.16.3 |
|
| 724 | - * @access protected |
|
| 725 | - * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 726 | - */ |
|
| 727 | - protected $entity_uri_service; |
|
| 728 | - |
|
| 729 | - /** |
|
| 730 | - * The {@link Wordlift_Publisher_Service} instance. |
|
| 731 | - * |
|
| 732 | - * @since 3.19.0 |
|
| 733 | - * @access protected |
|
| 734 | - * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 735 | - */ |
|
| 736 | - protected $publisher_service; |
|
| 737 | - |
|
| 738 | - /** |
|
| 739 | - * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 740 | - * |
|
| 741 | - * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 742 | - */ |
|
| 743 | - protected $context_cards_service; |
|
| 744 | - |
|
| 745 | - /** |
|
| 746 | - * {@link Wordlift}'s singleton instance. |
|
| 747 | - * |
|
| 748 | - * @since 3.11.2 |
|
| 749 | - * @access private |
|
| 750 | - * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 751 | - */ |
|
| 752 | - private static $instance; |
|
| 753 | - |
|
| 754 | - /** |
|
| 755 | - * A singleton instance of features registry. |
|
| 756 | - * @since 3.30.0 |
|
| 757 | - * @var Features_Registry |
|
| 758 | - */ |
|
| 759 | - private $features_registry; |
|
| 760 | - |
|
| 761 | - //</editor-fold> |
|
| 762 | - |
|
| 763 | - /** |
|
| 764 | - * Define the core functionality of the plugin. |
|
| 765 | - * |
|
| 766 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 767 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 768 | - * the public-facing side of the site. |
|
| 769 | - * |
|
| 770 | - * @since 1.0.0 |
|
| 771 | - */ |
|
| 772 | - public function __construct() { |
|
| 773 | - |
|
| 774 | - self::$instance = $this; |
|
| 775 | - |
|
| 776 | - $this->plugin_name = 'wordlift'; |
|
| 777 | - $this->version = '3.32.0'; |
|
| 778 | - $this->load_dependencies(); |
|
| 779 | - $this->set_locale(); |
|
| 780 | - $this->define_admin_hooks(); |
|
| 781 | - $this->define_public_hooks(); |
|
| 782 | - |
|
| 783 | - // If we're in `WP_CLI` load the related files. |
|
| 784 | - if ( class_exists( 'WP_CLI' ) ) { |
|
| 785 | - $this->load_cli_dependencies(); |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - } |
|
| 789 | - |
|
| 790 | - /** |
|
| 791 | - * Get the singleton instance. |
|
| 792 | - * |
|
| 793 | - * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 794 | - * @since 3.11.2 |
|
| 795 | - * |
|
| 796 | - */ |
|
| 797 | - public static function get_instance() { |
|
| 798 | - |
|
| 799 | - return self::$instance; |
|
| 800 | - } |
|
| 801 | - |
|
| 802 | - /** |
|
| 803 | - * Load the required dependencies for this plugin. |
|
| 804 | - * |
|
| 805 | - * Include the following files that make up the plugin: |
|
| 806 | - * |
|
| 807 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 808 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 809 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 810 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 811 | - * |
|
| 812 | - * Create an instance of the loader which will be used to register the hooks |
|
| 813 | - * with WordPress. |
|
| 814 | - * |
|
| 815 | - * @throws Exception |
|
| 816 | - * @since 1.0.0 |
|
| 817 | - * @access private |
|
| 818 | - */ |
|
| 819 | - private function load_dependencies() { |
|
| 820 | - |
|
| 821 | - /** |
|
| 822 | - * The class responsible for orchestrating the actions and filters of the |
|
| 823 | - * core plugin. |
|
| 824 | - */ |
|
| 825 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 826 | - |
|
| 827 | - // The class responsible for plugin uninstall. |
|
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 829 | - |
|
| 830 | - /** |
|
| 831 | - * The class responsible for defining internationalization functionality |
|
| 832 | - * of the plugin. |
|
| 833 | - */ |
|
| 834 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 835 | - |
|
| 836 | - /** |
|
| 837 | - * WordLift's supported languages. |
|
| 838 | - */ |
|
| 839 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 840 | - |
|
| 841 | - /** |
|
| 842 | - * WordLift's supported countries. |
|
| 843 | - */ |
|
| 844 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 845 | - |
|
| 846 | - /** |
|
| 847 | - * Provide support functions to sanitize data. |
|
| 848 | - */ |
|
| 849 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 850 | - |
|
| 851 | - /** Services. */ |
|
| 852 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 853 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 854 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 855 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 856 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 857 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 858 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 859 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 860 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 861 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 862 | - |
|
| 863 | - /** |
|
| 864 | - * The Query builder. |
|
| 865 | - */ |
|
| 866 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 867 | - |
|
| 868 | - /** |
|
| 869 | - * The Schema service. |
|
| 870 | - */ |
|
| 871 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 872 | - |
|
| 873 | - /** |
|
| 874 | - * The schema:url property service. |
|
| 875 | - */ |
|
| 876 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 877 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 878 | - |
|
| 879 | - /** |
|
| 880 | - * The UI service. |
|
| 881 | - */ |
|
| 882 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 883 | - |
|
| 884 | - /** |
|
| 885 | - * The Thumbnail service. |
|
| 886 | - */ |
|
| 887 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 888 | - |
|
| 889 | - /** |
|
| 890 | - * The Entity Types Taxonomy service. |
|
| 891 | - */ |
|
| 892 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 893 | - |
|
| 894 | - /** |
|
| 895 | - * The Entity service. |
|
| 896 | - */ |
|
| 897 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 898 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 899 | - |
|
| 900 | - // Add the entity rating service. |
|
| 901 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 902 | - |
|
| 903 | - /** |
|
| 904 | - * The User service. |
|
| 905 | - */ |
|
| 906 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 907 | - |
|
| 908 | - /** |
|
| 909 | - * The Timeline service. |
|
| 910 | - */ |
|
| 911 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 912 | - |
|
| 913 | - /** |
|
| 914 | - * The Topic Taxonomy service. |
|
| 915 | - */ |
|
| 916 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 917 | - |
|
| 918 | - /** |
|
| 919 | - * The SPARQL service. |
|
| 920 | - */ |
|
| 921 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 922 | - |
|
| 923 | - /** |
|
| 924 | - * The WordLift import service. |
|
| 925 | - */ |
|
| 926 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 927 | - |
|
| 928 | - /** |
|
| 929 | - * The WordLift URI service. |
|
| 930 | - */ |
|
| 931 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 932 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 933 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 934 | - |
|
| 935 | - /** |
|
| 936 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 937 | - */ |
|
| 938 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php'; |
|
| 939 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 940 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 941 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 942 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 943 | - |
|
| 944 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 945 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 946 | - |
|
| 947 | - /** |
|
| 948 | - * Load the converters. |
|
| 949 | - */ |
|
| 950 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 951 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 952 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 953 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 954 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 955 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 956 | - |
|
| 957 | - /** |
|
| 958 | - * Load cache-related files. |
|
| 959 | - */ |
|
| 960 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 961 | - |
|
| 962 | - /** |
|
| 963 | - * Load the content filter. |
|
| 964 | - */ |
|
| 965 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 966 | - |
|
| 967 | - /* |
|
| 87 | + //<editor-fold desc="## FIELDS"> |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 91 | + * the plugin. |
|
| 92 | + * |
|
| 93 | + * @since 1.0.0 |
|
| 94 | + * @access protected |
|
| 95 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 96 | + */ |
|
| 97 | + protected $loader; |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * The unique identifier of this plugin. |
|
| 101 | + * |
|
| 102 | + * @since 1.0.0 |
|
| 103 | + * @access protected |
|
| 104 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 105 | + */ |
|
| 106 | + protected $plugin_name; |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * The current version of the plugin. |
|
| 110 | + * |
|
| 111 | + * @since 1.0.0 |
|
| 112 | + * @access protected |
|
| 113 | + * @var string $version The current version of the plugin. |
|
| 114 | + */ |
|
| 115 | + protected $version; |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 119 | + * |
|
| 120 | + * @since 3.12.0 |
|
| 121 | + * @access protected |
|
| 122 | + * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 123 | + */ |
|
| 124 | + protected $tinymce_adapter; |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * The {@link Faq_Tinymce_Adapter} instance |
|
| 128 | + * @since 3.26.0 |
|
| 129 | + * @access protected |
|
| 130 | + * @var Faq_Tinymce_Adapter $faq_tinymce_adapter . |
|
| 131 | + */ |
|
| 132 | + //protected $faq_tinymce_adapter; |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * The Thumbnail service. |
|
| 136 | + * |
|
| 137 | + * @since 3.1.5 |
|
| 138 | + * @access private |
|
| 139 | + * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 140 | + */ |
|
| 141 | + private $thumbnail_service; |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * The UI service. |
|
| 145 | + * |
|
| 146 | + * @since 3.2.0 |
|
| 147 | + * @access private |
|
| 148 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 149 | + */ |
|
| 150 | + private $ui_service; |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * The Schema service. |
|
| 154 | + * |
|
| 155 | + * @since 3.3.0 |
|
| 156 | + * @access protected |
|
| 157 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 158 | + */ |
|
| 159 | + protected $schema_service; |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * The Entity service. |
|
| 163 | + * |
|
| 164 | + * @since 3.1.0 |
|
| 165 | + * @access protected |
|
| 166 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 167 | + */ |
|
| 168 | + protected $entity_service; |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * The Topic Taxonomy service. |
|
| 172 | + * |
|
| 173 | + * @since 3.5.0 |
|
| 174 | + * @access private |
|
| 175 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 176 | + */ |
|
| 177 | + private $topic_taxonomy_service; |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * The Entity Types Taxonomy service. |
|
| 181 | + * |
|
| 182 | + * @since 3.18.0 |
|
| 183 | + * @access private |
|
| 184 | + * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 185 | + */ |
|
| 186 | + private $entity_types_taxonomy_service; |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * The User service. |
|
| 190 | + * |
|
| 191 | + * @since 3.1.7 |
|
| 192 | + * @access protected |
|
| 193 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 194 | + */ |
|
| 195 | + protected $user_service; |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * The Timeline service. |
|
| 199 | + * |
|
| 200 | + * @since 3.1.0 |
|
| 201 | + * @access private |
|
| 202 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 203 | + */ |
|
| 204 | + private $timeline_service; |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * The Redirect service. |
|
| 208 | + * |
|
| 209 | + * @since 3.2.0 |
|
| 210 | + * @access private |
|
| 211 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 212 | + */ |
|
| 213 | + private $redirect_service; |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * The Notice service. |
|
| 217 | + * |
|
| 218 | + * @since 3.3.0 |
|
| 219 | + * @access private |
|
| 220 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 221 | + */ |
|
| 222 | + private $notice_service; |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * The Entity list customization. |
|
| 226 | + * |
|
| 227 | + * @since 3.3.0 |
|
| 228 | + * @access protected |
|
| 229 | + * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 230 | + */ |
|
| 231 | + protected $entity_list_service; |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * The Entity Types Taxonomy Walker. |
|
| 235 | + * |
|
| 236 | + * @since 3.1.0 |
|
| 237 | + * @access private |
|
| 238 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 239 | + */ |
|
| 240 | + private $entity_types_taxonomy_walker; |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * The ShareThis service. |
|
| 244 | + * |
|
| 245 | + * @since 3.2.0 |
|
| 246 | + * @access private |
|
| 247 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 248 | + */ |
|
| 249 | + private $sharethis_service; |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * The PrimaShop adapter. |
|
| 253 | + * |
|
| 254 | + * @since 3.2.3 |
|
| 255 | + * @access private |
|
| 256 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 257 | + */ |
|
| 258 | + private $primashop_adapter; |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * The WordLift Dashboard adapter. |
|
| 262 | + * |
|
| 263 | + * @since 3.4.0 |
|
| 264 | + * @access private |
|
| 265 | + * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 266 | + */ |
|
| 267 | + private $dashboard_service; |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * The entity type service. |
|
| 271 | + * |
|
| 272 | + * @since 3.6.0 |
|
| 273 | + * @access private |
|
| 274 | + * @var \Wordlift_Entity_Post_Type_Service |
|
| 275 | + */ |
|
| 276 | + private $entity_post_type_service; |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 280 | + * |
|
| 281 | + * @since 3.6.0 |
|
| 282 | + * @access private |
|
| 283 | + * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 284 | + */ |
|
| 285 | + private $entity_link_service; |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 289 | + * |
|
| 290 | + * @since 3.6.0 |
|
| 291 | + * @access protected |
|
| 292 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 293 | + */ |
|
| 294 | + protected $sparql_service; |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * A {@link Wordlift_Import_Service} instance. |
|
| 298 | + * |
|
| 299 | + * @since 3.6.0 |
|
| 300 | + * @access private |
|
| 301 | + * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 302 | + */ |
|
| 303 | + private $import_service; |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * A {@link Wordlift_Rebuild_Service} instance. |
|
| 307 | + * |
|
| 308 | + * @since 3.6.0 |
|
| 309 | + * @access private |
|
| 310 | + * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 311 | + */ |
|
| 312 | + private $rebuild_service; |
|
| 313 | + |
|
| 314 | + /** |
|
| 315 | + * A {@link Wordlift_Jsonld_Service} instance. |
|
| 316 | + * |
|
| 317 | + * @since 3.7.0 |
|
| 318 | + * @access protected |
|
| 319 | + * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 320 | + */ |
|
| 321 | + protected $jsonld_service; |
|
| 322 | + |
|
| 323 | + /** |
|
| 324 | + * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 325 | + * |
|
| 326 | + * @since 3.14.0 |
|
| 327 | + * @access protected |
|
| 328 | + * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 329 | + */ |
|
| 330 | + protected $jsonld_website_converter; |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * A {@link Wordlift_Property_Factory} instance. |
|
| 334 | + * |
|
| 335 | + * @since 3.7.0 |
|
| 336 | + * @access private |
|
| 337 | + * @var \Wordlift_Property_Factory $property_factory |
|
| 338 | + */ |
|
| 339 | + private $property_factory; |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * The 'Download Your Data' page. |
|
| 343 | + * |
|
| 344 | + * @since 3.6.0 |
|
| 345 | + * @access private |
|
| 346 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 347 | + */ |
|
| 348 | + private $download_your_data_page; |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * The 'WordLift Settings' page. |
|
| 352 | + * |
|
| 353 | + * @since 3.11.0 |
|
| 354 | + * @access protected |
|
| 355 | + * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 356 | + */ |
|
| 357 | + protected $settings_page; |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * The install wizard page. |
|
| 361 | + * |
|
| 362 | + * @since 3.9.0 |
|
| 363 | + * @access private |
|
| 364 | + * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 365 | + */ |
|
| 366 | + public $admin_setup; |
|
| 367 | + |
|
| 368 | + /** |
|
| 369 | + * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 370 | + * linking of entities to their pages. |
|
| 371 | + * |
|
| 372 | + * @since 3.8.0 |
|
| 373 | + * @access private |
|
| 374 | + * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 375 | + */ |
|
| 376 | + private $content_filter_service; |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * The Faq Content filter service |
|
| 380 | + * @since 3.26.0 |
|
| 381 | + * @access private |
|
| 382 | + * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 383 | + */ |
|
| 384 | + private $faq_content_filter_service; |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 388 | + * |
|
| 389 | + * @since 3.9.0 |
|
| 390 | + * @access private |
|
| 391 | + * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 392 | + */ |
|
| 393 | + private $key_validation_service; |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * A {@link Wordlift_Rating_Service} instance. |
|
| 397 | + * |
|
| 398 | + * @since 3.10.0 |
|
| 399 | + * @access private |
|
| 400 | + * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 401 | + */ |
|
| 402 | + private $rating_service; |
|
| 403 | + |
|
| 404 | + /** |
|
| 405 | + * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 406 | + * |
|
| 407 | + * @since 3.10.0 |
|
| 408 | + * @access protected |
|
| 409 | + * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 410 | + */ |
|
| 411 | + protected $post_to_jsonld_converter; |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 415 | + * |
|
| 416 | + * @since 3.10.0 |
|
| 417 | + * @access protected |
|
| 418 | + * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 419 | + */ |
|
| 420 | + protected $configuration_service; |
|
| 421 | + |
|
| 422 | + /** |
|
| 423 | + * A {@link Wordlift_Install_Service} instance. |
|
| 424 | + * |
|
| 425 | + * @since 3.18.0 |
|
| 426 | + * @access protected |
|
| 427 | + * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 428 | + */ |
|
| 429 | + protected $install_service; |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 433 | + * |
|
| 434 | + * @since 3.10.0 |
|
| 435 | + * @access protected |
|
| 436 | + * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 437 | + */ |
|
| 438 | + protected $entity_type_service; |
|
| 439 | + |
|
| 440 | + /** |
|
| 441 | + * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 442 | + * |
|
| 443 | + * @since 3.10.0 |
|
| 444 | + * @access protected |
|
| 445 | + * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 446 | + */ |
|
| 447 | + protected $entity_post_to_jsonld_converter; |
|
| 448 | + |
|
| 449 | + /** |
|
| 450 | + * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 451 | + * |
|
| 452 | + * @since 3.10.0 |
|
| 453 | + * @access protected |
|
| 454 | + * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 455 | + */ |
|
| 456 | + protected $postid_to_jsonld_converter; |
|
| 457 | + |
|
| 458 | + /** |
|
| 459 | + * The {@link Wordlift_Admin_Status_Page} class. |
|
| 460 | + * |
|
| 461 | + * @since 3.9.8 |
|
| 462 | + * @access private |
|
| 463 | + * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 464 | + */ |
|
| 465 | + private $status_page; |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 469 | + * |
|
| 470 | + * @since 3.11.0 |
|
| 471 | + * @access protected |
|
| 472 | + * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 473 | + */ |
|
| 474 | + protected $category_taxonomy_service; |
|
| 475 | + |
|
| 476 | + /** |
|
| 477 | + * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 478 | + * |
|
| 479 | + * @since 3.11.0 |
|
| 480 | + * @access protected |
|
| 481 | + * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 482 | + */ |
|
| 483 | + protected $entity_page_service; |
|
| 484 | + |
|
| 485 | + /** |
|
| 486 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 487 | + * |
|
| 488 | + * @since 3.11.0 |
|
| 489 | + * @access protected |
|
| 490 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 491 | + */ |
|
| 492 | + protected $settings_page_action_link; |
|
| 493 | + |
|
| 494 | + /** |
|
| 495 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 496 | + * |
|
| 497 | + * @since 3.11.0 |
|
| 498 | + * @access protected |
|
| 499 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 500 | + */ |
|
| 501 | + protected $analytics_settings_page_action_link; |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * The {@link Wordlift_Analytics_Connect} class. |
|
| 505 | + * |
|
| 506 | + * @since 3.11.0 |
|
| 507 | + * @access protected |
|
| 508 | + * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 509 | + */ |
|
| 510 | + protected $analytics_connect; |
|
| 511 | + |
|
| 512 | + /** |
|
| 513 | + * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 514 | + * |
|
| 515 | + * @since 3.11.0 |
|
| 516 | + * @access protected |
|
| 517 | + * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 518 | + */ |
|
| 519 | + protected $publisher_ajax_adapter; |
|
| 520 | + |
|
| 521 | + /** |
|
| 522 | + * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 523 | + * |
|
| 524 | + * @since 3.11.0 |
|
| 525 | + * @access protected |
|
| 526 | + * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 527 | + */ |
|
| 528 | + protected $input_element; |
|
| 529 | + |
|
| 530 | + /** |
|
| 531 | + * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 532 | + * |
|
| 533 | + * @since 3.13.0 |
|
| 534 | + * @access protected |
|
| 535 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 536 | + */ |
|
| 537 | + protected $radio_input_element; |
|
| 538 | + |
|
| 539 | + /** |
|
| 540 | + * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 541 | + * |
|
| 542 | + * @since 3.11.0 |
|
| 543 | + * @access protected |
|
| 544 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 545 | + */ |
|
| 546 | + protected $language_select_element; |
|
| 547 | + |
|
| 548 | + /** |
|
| 549 | + * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 550 | + * |
|
| 551 | + * @since 3.18.0 |
|
| 552 | + * @access protected |
|
| 553 | + * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 554 | + */ |
|
| 555 | + protected $country_select_element; |
|
| 556 | + |
|
| 557 | + /** |
|
| 558 | + * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 559 | + * |
|
| 560 | + * @since 3.11.0 |
|
| 561 | + * @access protected |
|
| 562 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 563 | + */ |
|
| 564 | + protected $publisher_element; |
|
| 565 | + |
|
| 566 | + /** |
|
| 567 | + * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 568 | + * |
|
| 569 | + * @since 3.11.0 |
|
| 570 | + * @access protected |
|
| 571 | + * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 572 | + */ |
|
| 573 | + protected $select2_element; |
|
| 574 | + |
|
| 575 | + /** |
|
| 576 | + * The controller for the entity type list admin page |
|
| 577 | + * |
|
| 578 | + * @since 3.11.0 |
|
| 579 | + * @access private |
|
| 580 | + * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 581 | + */ |
|
| 582 | + private $entity_type_admin_page; |
|
| 583 | + |
|
| 584 | + /** |
|
| 585 | + * The controller for the entity type settings admin page |
|
| 586 | + * |
|
| 587 | + * @since 3.11.0 |
|
| 588 | + * @access private |
|
| 589 | + * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 590 | + */ |
|
| 591 | + private $entity_type_settings_admin_page; |
|
| 592 | + |
|
| 593 | + /** |
|
| 594 | + * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 595 | + * |
|
| 596 | + * @since 3.11.0 |
|
| 597 | + * @access protected |
|
| 598 | + * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 599 | + */ |
|
| 600 | + protected $related_entities_cloud_widget; |
|
| 601 | + |
|
| 602 | + /** |
|
| 603 | + * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 604 | + * |
|
| 605 | + * @since 3.14.0 |
|
| 606 | + * @access protected |
|
| 607 | + * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 608 | + */ |
|
| 609 | + protected $author_element; |
|
| 610 | + |
|
| 611 | + /** |
|
| 612 | + * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 613 | + * |
|
| 614 | + * @since 3.12.0 |
|
| 615 | + * @access protected |
|
| 616 | + * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 617 | + */ |
|
| 618 | + protected $sample_data_service; |
|
| 619 | + |
|
| 620 | + /** |
|
| 621 | + * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 622 | + * |
|
| 623 | + * @since 3.12.0 |
|
| 624 | + * @access protected |
|
| 625 | + * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 626 | + */ |
|
| 627 | + protected $sample_data_ajax_adapter; |
|
| 628 | + |
|
| 629 | + /** |
|
| 630 | + * The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 631 | + * |
|
| 632 | + * @since 3.14.3 |
|
| 633 | + * @access private |
|
| 634 | + * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 635 | + */ |
|
| 636 | + private $relation_rebuild_service; |
|
| 637 | + |
|
| 638 | + /** |
|
| 639 | + * The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 640 | + * |
|
| 641 | + * @since 3.14.3 |
|
| 642 | + * @access private |
|
| 643 | + * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 644 | + */ |
|
| 645 | + private $relation_rebuild_adapter; |
|
| 646 | + |
|
| 647 | + /** |
|
| 648 | + * The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 649 | + * |
|
| 650 | + * @since 3.18.0 |
|
| 651 | + * @access private |
|
| 652 | + * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 653 | + */ |
|
| 654 | + private $reference_rebuild_service; |
|
| 655 | + |
|
| 656 | + /** |
|
| 657 | + * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 658 | + * |
|
| 659 | + * @since 3.16.0 |
|
| 660 | + * @access protected |
|
| 661 | + * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 662 | + */ |
|
| 663 | + protected $google_analytics_export_service; |
|
| 664 | + |
|
| 665 | + /** |
|
| 666 | + * {@link Wordlift}'s singleton instance. |
|
| 667 | + * |
|
| 668 | + * @since 3.15.0 |
|
| 669 | + * @access protected |
|
| 670 | + * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 671 | + */ |
|
| 672 | + protected $entity_type_adapter; |
|
| 673 | + |
|
| 674 | + /** |
|
| 675 | + * The {@link Wordlift_Storage_Factory} instance. |
|
| 676 | + * |
|
| 677 | + * @since 3.15.0 |
|
| 678 | + * @access protected |
|
| 679 | + * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 680 | + */ |
|
| 681 | + protected $storage_factory; |
|
| 682 | + |
|
| 683 | + /** |
|
| 684 | + * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 685 | + * |
|
| 686 | + * @since 3.15.0 |
|
| 687 | + * @access protected |
|
| 688 | + * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 689 | + */ |
|
| 690 | + protected $rendition_factory; |
|
| 691 | + |
|
| 692 | + /** |
|
| 693 | + * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 694 | + * |
|
| 695 | + * @since 3.15.0 |
|
| 696 | + * @access private |
|
| 697 | + * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 698 | + */ |
|
| 699 | + private $autocomplete_adapter; |
|
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * The {@link Wordlift_Relation_Service} instance. |
|
| 703 | + * |
|
| 704 | + * @since 3.15.0 |
|
| 705 | + * @access protected |
|
| 706 | + * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance. |
|
| 707 | + */ |
|
| 708 | + protected $relation_service; |
|
| 709 | + |
|
| 710 | + /** |
|
| 711 | + * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 712 | + * |
|
| 713 | + * @since 3.16.0 |
|
| 714 | + * @access protected |
|
| 715 | + * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 716 | + * |
|
| 717 | + */ |
|
| 718 | + protected $cached_postid_to_jsonld_converter; |
|
| 719 | + |
|
| 720 | + /** |
|
| 721 | + * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 722 | + * |
|
| 723 | + * @since 3.16.3 |
|
| 724 | + * @access protected |
|
| 725 | + * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 726 | + */ |
|
| 727 | + protected $entity_uri_service; |
|
| 728 | + |
|
| 729 | + /** |
|
| 730 | + * The {@link Wordlift_Publisher_Service} instance. |
|
| 731 | + * |
|
| 732 | + * @since 3.19.0 |
|
| 733 | + * @access protected |
|
| 734 | + * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 735 | + */ |
|
| 736 | + protected $publisher_service; |
|
| 737 | + |
|
| 738 | + /** |
|
| 739 | + * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 740 | + * |
|
| 741 | + * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 742 | + */ |
|
| 743 | + protected $context_cards_service; |
|
| 744 | + |
|
| 745 | + /** |
|
| 746 | + * {@link Wordlift}'s singleton instance. |
|
| 747 | + * |
|
| 748 | + * @since 3.11.2 |
|
| 749 | + * @access private |
|
| 750 | + * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 751 | + */ |
|
| 752 | + private static $instance; |
|
| 753 | + |
|
| 754 | + /** |
|
| 755 | + * A singleton instance of features registry. |
|
| 756 | + * @since 3.30.0 |
|
| 757 | + * @var Features_Registry |
|
| 758 | + */ |
|
| 759 | + private $features_registry; |
|
| 760 | + |
|
| 761 | + //</editor-fold> |
|
| 762 | + |
|
| 763 | + /** |
|
| 764 | + * Define the core functionality of the plugin. |
|
| 765 | + * |
|
| 766 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 767 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 768 | + * the public-facing side of the site. |
|
| 769 | + * |
|
| 770 | + * @since 1.0.0 |
|
| 771 | + */ |
|
| 772 | + public function __construct() { |
|
| 773 | + |
|
| 774 | + self::$instance = $this; |
|
| 775 | + |
|
| 776 | + $this->plugin_name = 'wordlift'; |
|
| 777 | + $this->version = '3.32.0'; |
|
| 778 | + $this->load_dependencies(); |
|
| 779 | + $this->set_locale(); |
|
| 780 | + $this->define_admin_hooks(); |
|
| 781 | + $this->define_public_hooks(); |
|
| 782 | + |
|
| 783 | + // If we're in `WP_CLI` load the related files. |
|
| 784 | + if ( class_exists( 'WP_CLI' ) ) { |
|
| 785 | + $this->load_cli_dependencies(); |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + } |
|
| 789 | + |
|
| 790 | + /** |
|
| 791 | + * Get the singleton instance. |
|
| 792 | + * |
|
| 793 | + * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 794 | + * @since 3.11.2 |
|
| 795 | + * |
|
| 796 | + */ |
|
| 797 | + public static function get_instance() { |
|
| 798 | + |
|
| 799 | + return self::$instance; |
|
| 800 | + } |
|
| 801 | + |
|
| 802 | + /** |
|
| 803 | + * Load the required dependencies for this plugin. |
|
| 804 | + * |
|
| 805 | + * Include the following files that make up the plugin: |
|
| 806 | + * |
|
| 807 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 808 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 809 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 810 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 811 | + * |
|
| 812 | + * Create an instance of the loader which will be used to register the hooks |
|
| 813 | + * with WordPress. |
|
| 814 | + * |
|
| 815 | + * @throws Exception |
|
| 816 | + * @since 1.0.0 |
|
| 817 | + * @access private |
|
| 818 | + */ |
|
| 819 | + private function load_dependencies() { |
|
| 820 | + |
|
| 821 | + /** |
|
| 822 | + * The class responsible for orchestrating the actions and filters of the |
|
| 823 | + * core plugin. |
|
| 824 | + */ |
|
| 825 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 826 | + |
|
| 827 | + // The class responsible for plugin uninstall. |
|
| 828 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 829 | + |
|
| 830 | + /** |
|
| 831 | + * The class responsible for defining internationalization functionality |
|
| 832 | + * of the plugin. |
|
| 833 | + */ |
|
| 834 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 835 | + |
|
| 836 | + /** |
|
| 837 | + * WordLift's supported languages. |
|
| 838 | + */ |
|
| 839 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 840 | + |
|
| 841 | + /** |
|
| 842 | + * WordLift's supported countries. |
|
| 843 | + */ |
|
| 844 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 845 | + |
|
| 846 | + /** |
|
| 847 | + * Provide support functions to sanitize data. |
|
| 848 | + */ |
|
| 849 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 850 | + |
|
| 851 | + /** Services. */ |
|
| 852 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 853 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 854 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 855 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 856 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 857 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 858 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 859 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 860 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 861 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 862 | + |
|
| 863 | + /** |
|
| 864 | + * The Query builder. |
|
| 865 | + */ |
|
| 866 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 867 | + |
|
| 868 | + /** |
|
| 869 | + * The Schema service. |
|
| 870 | + */ |
|
| 871 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 872 | + |
|
| 873 | + /** |
|
| 874 | + * The schema:url property service. |
|
| 875 | + */ |
|
| 876 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 877 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 878 | + |
|
| 879 | + /** |
|
| 880 | + * The UI service. |
|
| 881 | + */ |
|
| 882 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 883 | + |
|
| 884 | + /** |
|
| 885 | + * The Thumbnail service. |
|
| 886 | + */ |
|
| 887 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 888 | + |
|
| 889 | + /** |
|
| 890 | + * The Entity Types Taxonomy service. |
|
| 891 | + */ |
|
| 892 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 893 | + |
|
| 894 | + /** |
|
| 895 | + * The Entity service. |
|
| 896 | + */ |
|
| 897 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 898 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 899 | + |
|
| 900 | + // Add the entity rating service. |
|
| 901 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 902 | + |
|
| 903 | + /** |
|
| 904 | + * The User service. |
|
| 905 | + */ |
|
| 906 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 907 | + |
|
| 908 | + /** |
|
| 909 | + * The Timeline service. |
|
| 910 | + */ |
|
| 911 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 912 | + |
|
| 913 | + /** |
|
| 914 | + * The Topic Taxonomy service. |
|
| 915 | + */ |
|
| 916 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 917 | + |
|
| 918 | + /** |
|
| 919 | + * The SPARQL service. |
|
| 920 | + */ |
|
| 921 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 922 | + |
|
| 923 | + /** |
|
| 924 | + * The WordLift import service. |
|
| 925 | + */ |
|
| 926 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 927 | + |
|
| 928 | + /** |
|
| 929 | + * The WordLift URI service. |
|
| 930 | + */ |
|
| 931 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 932 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 933 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 934 | + |
|
| 935 | + /** |
|
| 936 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 937 | + */ |
|
| 938 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php'; |
|
| 939 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 940 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 941 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 942 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 943 | + |
|
| 944 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 945 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 946 | + |
|
| 947 | + /** |
|
| 948 | + * Load the converters. |
|
| 949 | + */ |
|
| 950 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 951 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 952 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 953 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 954 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 955 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 956 | + |
|
| 957 | + /** |
|
| 958 | + * Load cache-related files. |
|
| 959 | + */ |
|
| 960 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 961 | + |
|
| 962 | + /** |
|
| 963 | + * Load the content filter. |
|
| 964 | + */ |
|
| 965 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 966 | + |
|
| 967 | + /* |
|
| 968 | 968 | * Load the excerpt helper. |
| 969 | 969 | */ |
| 970 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 971 | - |
|
| 972 | - /** |
|
| 973 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 974 | - * |
|
| 975 | - * @since 3.8.0 |
|
| 976 | - */ |
|
| 977 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 978 | - |
|
| 979 | - // The Publisher Service and the AJAX adapter. |
|
| 980 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 981 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 982 | - |
|
| 983 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 984 | - |
|
| 985 | - /** |
|
| 986 | - * Load the WordLift key validation service. |
|
| 987 | - */ |
|
| 988 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 989 | - |
|
| 990 | - // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 991 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 992 | - |
|
| 993 | - // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 994 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 995 | - |
|
| 996 | - /** Linked Data. */ |
|
| 997 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 998 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 999 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 1000 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 1001 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 1002 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 1003 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 1004 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 1005 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 1006 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 1007 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 1008 | - |
|
| 1009 | - /** Linked Data Rendition. */ |
|
| 1010 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 1011 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 1012 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 1013 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 1014 | - |
|
| 1015 | - /** Services. */ |
|
| 1016 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 1017 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 1018 | - |
|
| 1019 | - /** Adapters. */ |
|
| 1020 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 1021 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 1022 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 1023 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 1024 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 1025 | - |
|
| 1026 | - /** Async Tasks. */ |
|
| 1027 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1028 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1029 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1030 | - |
|
| 1031 | - /** Autocomplete. */ |
|
| 1032 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1033 | - |
|
| 1034 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 1035 | - |
|
| 1036 | - /** Analytics */ |
|
| 1037 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1038 | - |
|
| 1039 | - /** |
|
| 1040 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 1041 | - */ |
|
| 1042 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 1043 | - |
|
| 1044 | - /** |
|
| 1045 | - * The class to customize the entity list admin page. |
|
| 1046 | - */ |
|
| 1047 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 1048 | - |
|
| 1049 | - /** |
|
| 1050 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 1051 | - */ |
|
| 1052 | - global $wp_version; |
|
| 1053 | - if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 1054 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1055 | - } else { |
|
| 1056 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1057 | - } |
|
| 1058 | - |
|
| 1059 | - /** |
|
| 1060 | - * The Notice service. |
|
| 1061 | - */ |
|
| 1062 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 1063 | - |
|
| 1064 | - /** |
|
| 1065 | - * The PrimaShop adapter. |
|
| 1066 | - */ |
|
| 1067 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 1068 | - |
|
| 1069 | - /** |
|
| 1070 | - * The WordLift Dashboard service. |
|
| 1071 | - */ |
|
| 1072 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 1073 | - |
|
| 1074 | - /** |
|
| 1075 | - * The admin 'Install wizard' page. |
|
| 1076 | - */ |
|
| 1077 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 1078 | - |
|
| 1079 | - /** |
|
| 1080 | - * The WordLift entity type list admin page controller. |
|
| 1081 | - */ |
|
| 1082 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1083 | - |
|
| 1084 | - /** |
|
| 1085 | - * The WordLift entity type settings admin page controller. |
|
| 1086 | - */ |
|
| 1087 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 1088 | - |
|
| 1089 | - /** |
|
| 1090 | - * The admin 'Download Your Data' page. |
|
| 1091 | - */ |
|
| 1092 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 1093 | - |
|
| 1094 | - /** |
|
| 1095 | - * The admin 'WordLift Settings' page. |
|
| 1096 | - */ |
|
| 1097 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1098 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1099 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1100 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1101 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1102 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1103 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1104 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1105 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1106 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1107 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 1108 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 1109 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1110 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1111 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1112 | - |
|
| 1113 | - /** Admin Pages */ |
|
| 1114 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1115 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 1116 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1117 | - |
|
| 1118 | - /** |
|
| 1119 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 1120 | - * side of the site. |
|
| 1121 | - */ |
|
| 1122 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 1123 | - |
|
| 1124 | - /** |
|
| 1125 | - * The shortcode abstract class. |
|
| 1126 | - */ |
|
| 1127 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 1128 | - |
|
| 1129 | - /** |
|
| 1130 | - * The Timeline shortcode. |
|
| 1131 | - */ |
|
| 1132 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 1133 | - |
|
| 1134 | - /** |
|
| 1135 | - * The Navigator shortcode. |
|
| 1136 | - */ |
|
| 1137 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1138 | - |
|
| 1139 | - /** |
|
| 1140 | - * The Products Navigator shortcode. |
|
| 1141 | - */ |
|
| 1142 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1143 | - |
|
| 1144 | - /** |
|
| 1145 | - * The chord shortcode. |
|
| 1146 | - */ |
|
| 1147 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1148 | - |
|
| 1149 | - /** |
|
| 1150 | - * The geomap shortcode. |
|
| 1151 | - */ |
|
| 1152 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1153 | - |
|
| 1154 | - /** |
|
| 1155 | - * The entity cloud shortcode. |
|
| 1156 | - */ |
|
| 1157 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1158 | - |
|
| 1159 | - /** |
|
| 1160 | - * The entity glossary shortcode. |
|
| 1161 | - */ |
|
| 1162 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 1163 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1164 | - |
|
| 1165 | - /** |
|
| 1166 | - * Faceted Search shortcode. |
|
| 1167 | - */ |
|
| 1168 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1169 | - |
|
| 1170 | - /** |
|
| 1171 | - * The ShareThis service. |
|
| 1172 | - */ |
|
| 1173 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1174 | - |
|
| 1175 | - /** |
|
| 1176 | - * The SEO service. |
|
| 1177 | - */ |
|
| 1178 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1179 | - |
|
| 1180 | - /** |
|
| 1181 | - * The AMP service. |
|
| 1182 | - */ |
|
| 1183 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1184 | - |
|
| 1185 | - /** Widgets */ |
|
| 1186 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1187 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1188 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1189 | - |
|
| 1190 | - /* |
|
| 970 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 971 | + |
|
| 972 | + /** |
|
| 973 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 974 | + * |
|
| 975 | + * @since 3.8.0 |
|
| 976 | + */ |
|
| 977 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 978 | + |
|
| 979 | + // The Publisher Service and the AJAX adapter. |
|
| 980 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 981 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 982 | + |
|
| 983 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 984 | + |
|
| 985 | + /** |
|
| 986 | + * Load the WordLift key validation service. |
|
| 987 | + */ |
|
| 988 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 989 | + |
|
| 990 | + // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 991 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 992 | + |
|
| 993 | + // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 994 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 995 | + |
|
| 996 | + /** Linked Data. */ |
|
| 997 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 998 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 999 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 1000 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 1001 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 1002 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 1003 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 1004 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 1005 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 1006 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 1007 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 1008 | + |
|
| 1009 | + /** Linked Data Rendition. */ |
|
| 1010 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 1011 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 1012 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 1013 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 1014 | + |
|
| 1015 | + /** Services. */ |
|
| 1016 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 1017 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 1018 | + |
|
| 1019 | + /** Adapters. */ |
|
| 1020 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 1021 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 1022 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 1023 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 1024 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 1025 | + |
|
| 1026 | + /** Async Tasks. */ |
|
| 1027 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1028 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1029 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1030 | + |
|
| 1031 | + /** Autocomplete. */ |
|
| 1032 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1033 | + |
|
| 1034 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 1035 | + |
|
| 1036 | + /** Analytics */ |
|
| 1037 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1038 | + |
|
| 1039 | + /** |
|
| 1040 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 1041 | + */ |
|
| 1042 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 1043 | + |
|
| 1044 | + /** |
|
| 1045 | + * The class to customize the entity list admin page. |
|
| 1046 | + */ |
|
| 1047 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 1048 | + |
|
| 1049 | + /** |
|
| 1050 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 1051 | + */ |
|
| 1052 | + global $wp_version; |
|
| 1053 | + if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 1054 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1055 | + } else { |
|
| 1056 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1057 | + } |
|
| 1058 | + |
|
| 1059 | + /** |
|
| 1060 | + * The Notice service. |
|
| 1061 | + */ |
|
| 1062 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 1063 | + |
|
| 1064 | + /** |
|
| 1065 | + * The PrimaShop adapter. |
|
| 1066 | + */ |
|
| 1067 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 1068 | + |
|
| 1069 | + /** |
|
| 1070 | + * The WordLift Dashboard service. |
|
| 1071 | + */ |
|
| 1072 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 1073 | + |
|
| 1074 | + /** |
|
| 1075 | + * The admin 'Install wizard' page. |
|
| 1076 | + */ |
|
| 1077 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 1078 | + |
|
| 1079 | + /** |
|
| 1080 | + * The WordLift entity type list admin page controller. |
|
| 1081 | + */ |
|
| 1082 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1083 | + |
|
| 1084 | + /** |
|
| 1085 | + * The WordLift entity type settings admin page controller. |
|
| 1086 | + */ |
|
| 1087 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 1088 | + |
|
| 1089 | + /** |
|
| 1090 | + * The admin 'Download Your Data' page. |
|
| 1091 | + */ |
|
| 1092 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 1093 | + |
|
| 1094 | + /** |
|
| 1095 | + * The admin 'WordLift Settings' page. |
|
| 1096 | + */ |
|
| 1097 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1098 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1099 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1100 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1101 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1102 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1103 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1104 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1105 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1106 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1107 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 1108 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 1109 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1110 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1111 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1112 | + |
|
| 1113 | + /** Admin Pages */ |
|
| 1114 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1115 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 1116 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1117 | + |
|
| 1118 | + /** |
|
| 1119 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 1120 | + * side of the site. |
|
| 1121 | + */ |
|
| 1122 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 1123 | + |
|
| 1124 | + /** |
|
| 1125 | + * The shortcode abstract class. |
|
| 1126 | + */ |
|
| 1127 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 1128 | + |
|
| 1129 | + /** |
|
| 1130 | + * The Timeline shortcode. |
|
| 1131 | + */ |
|
| 1132 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 1133 | + |
|
| 1134 | + /** |
|
| 1135 | + * The Navigator shortcode. |
|
| 1136 | + */ |
|
| 1137 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1138 | + |
|
| 1139 | + /** |
|
| 1140 | + * The Products Navigator shortcode. |
|
| 1141 | + */ |
|
| 1142 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1143 | + |
|
| 1144 | + /** |
|
| 1145 | + * The chord shortcode. |
|
| 1146 | + */ |
|
| 1147 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1148 | + |
|
| 1149 | + /** |
|
| 1150 | + * The geomap shortcode. |
|
| 1151 | + */ |
|
| 1152 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1153 | + |
|
| 1154 | + /** |
|
| 1155 | + * The entity cloud shortcode. |
|
| 1156 | + */ |
|
| 1157 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1158 | + |
|
| 1159 | + /** |
|
| 1160 | + * The entity glossary shortcode. |
|
| 1161 | + */ |
|
| 1162 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 1163 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1164 | + |
|
| 1165 | + /** |
|
| 1166 | + * Faceted Search shortcode. |
|
| 1167 | + */ |
|
| 1168 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1169 | + |
|
| 1170 | + /** |
|
| 1171 | + * The ShareThis service. |
|
| 1172 | + */ |
|
| 1173 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1174 | + |
|
| 1175 | + /** |
|
| 1176 | + * The SEO service. |
|
| 1177 | + */ |
|
| 1178 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1179 | + |
|
| 1180 | + /** |
|
| 1181 | + * The AMP service. |
|
| 1182 | + */ |
|
| 1183 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1184 | + |
|
| 1185 | + /** Widgets */ |
|
| 1186 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1187 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1188 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1189 | + |
|
| 1190 | + /* |
|
| 1191 | 1191 | * Schema.org Services. |
| 1192 | 1192 | * |
| 1193 | 1193 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1194 | 1194 | */ |
| 1195 | - if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1196 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1197 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1198 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1199 | - new Wordlift_Schemaorg_Sync_Service(); |
|
| 1200 | - $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service(); |
|
| 1201 | - new Wordlift_Schemaorg_Class_Service(); |
|
| 1202 | - } else { |
|
| 1203 | - $schemaorg_property_service = null; |
|
| 1204 | - } |
|
| 1205 | - |
|
| 1206 | - $this->loader = new Wordlift_Loader(); |
|
| 1207 | - /** |
|
| 1208 | - * @since 3.30.0 |
|
| 1209 | - */ |
|
| 1210 | - $this->features_registry = Features_Registry::get_instance(); |
|
| 1195 | + if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1196 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1197 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1198 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1199 | + new Wordlift_Schemaorg_Sync_Service(); |
|
| 1200 | + $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service(); |
|
| 1201 | + new Wordlift_Schemaorg_Class_Service(); |
|
| 1202 | + } else { |
|
| 1203 | + $schemaorg_property_service = null; |
|
| 1204 | + } |
|
| 1205 | + |
|
| 1206 | + $this->loader = new Wordlift_Loader(); |
|
| 1207 | + /** |
|
| 1208 | + * @since 3.30.0 |
|
| 1209 | + */ |
|
| 1210 | + $this->features_registry = Features_Registry::get_instance(); |
|
| 1211 | 1211 | |
| 1212 | - // Instantiate a global logger. |
|
| 1213 | - global $wl_logger; |
|
| 1214 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1212 | + // Instantiate a global logger. |
|
| 1213 | + global $wl_logger; |
|
| 1214 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1215 | 1215 | |
| 1216 | - // Load the `wl-api` end-point. |
|
| 1217 | - new Wordlift_Http_Api(); |
|
| 1216 | + // Load the `wl-api` end-point. |
|
| 1217 | + new Wordlift_Http_Api(); |
|
| 1218 | 1218 | |
| 1219 | - // Load the Install Service. |
|
| 1220 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1221 | - $this->install_service = new Wordlift_Install_Service(); |
|
| 1219 | + // Load the Install Service. |
|
| 1220 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1221 | + $this->install_service = new Wordlift_Install_Service(); |
|
| 1222 | 1222 | |
| 1223 | - /** Services. */ |
|
| 1224 | - // Create the configuration service. |
|
| 1225 | - $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 1226 | - $api_service = new Wordlift_Api_Service( $this->configuration_service ); |
|
| 1223 | + /** Services. */ |
|
| 1224 | + // Create the configuration service. |
|
| 1225 | + $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 1226 | + $api_service = new Wordlift_Api_Service( $this->configuration_service ); |
|
| 1227 | 1227 | |
| 1228 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1229 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1228 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1229 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1230 | 1230 | |
| 1231 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1232 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1231 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1232 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1233 | 1233 | |
| 1234 | - // Create an instance of the UI service. |
|
| 1235 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 1234 | + // Create an instance of the UI service. |
|
| 1235 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 1236 | 1236 | |
| 1237 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 1238 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 1237 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 1238 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 1239 | 1239 | |
| 1240 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 1241 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1242 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1243 | - $this->relation_service = new Wordlift_Relation_Service(); |
|
| 1240 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 1241 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1242 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1243 | + $this->relation_service = new Wordlift_Relation_Service(); |
|
| 1244 | 1244 | |
| 1245 | - $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' ); |
|
| 1246 | - $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service ); |
|
| 1247 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service ); |
|
| 1248 | - $this->user_service = new Wordlift_User_Service( $this->sparql_service, $this->entity_service ); |
|
| 1245 | + $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' ); |
|
| 1246 | + $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service ); |
|
| 1247 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service ); |
|
| 1248 | + $this->user_service = new Wordlift_User_Service( $this->sparql_service, $this->entity_service ); |
|
| 1249 | 1249 | |
| 1250 | - // Instantiate the JSON-LD service. |
|
| 1251 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1250 | + // Instantiate the JSON-LD service. |
|
| 1251 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1252 | 1252 | |
| 1253 | - /** Linked Data. */ |
|
| 1254 | - $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1255 | - $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1253 | + /** Linked Data. */ |
|
| 1254 | + $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1255 | + $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1256 | 1256 | |
| 1257 | - $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1257 | + $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1258 | 1258 | |
| 1259 | - // Create a new instance of the Redirect service. |
|
| 1260 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_uri_service ); |
|
| 1261 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1259 | + // Create a new instance of the Redirect service. |
|
| 1260 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_uri_service ); |
|
| 1261 | + $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1262 | 1262 | |
| 1263 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1264 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1263 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1264 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1265 | 1265 | |
| 1266 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1266 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1267 | 1267 | |
| 1268 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1269 | - $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1268 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1269 | + $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1270 | 1270 | |
| 1271 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1272 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1271 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1272 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1273 | 1273 | |
| 1274 | - // Create an instance of the PrimaShop adapter. |
|
| 1275 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1274 | + // Create an instance of the PrimaShop adapter. |
|
| 1275 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1276 | 1276 | |
| 1277 | - // Create an import service instance to hook later to WP's import function. |
|
| 1278 | - $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() ); |
|
| 1277 | + // Create an import service instance to hook later to WP's import function. |
|
| 1278 | + $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() ); |
|
| 1279 | 1279 | |
| 1280 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1280 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1281 | 1281 | |
| 1282 | - // Create the entity rating service. |
|
| 1283 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1282 | + // Create the entity rating service. |
|
| 1283 | + $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1284 | 1284 | |
| 1285 | - // Create entity list customization (wp-admin/edit.php). |
|
| 1286 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1285 | + // Create entity list customization (wp-admin/edit.php). |
|
| 1286 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1287 | 1287 | |
| 1288 | - // Create a new instance of the Redirect service. |
|
| 1289 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1288 | + // Create a new instance of the Redirect service. |
|
| 1289 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1290 | 1290 | |
| 1291 | - // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1292 | - $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service ); |
|
| 1293 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1294 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1291 | + // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1292 | + $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service ); |
|
| 1293 | + $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1294 | + $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1295 | 1295 | |
| 1296 | - $attachment_service = new Wordlift_Attachment_Service(); |
|
| 1296 | + $attachment_service = new Wordlift_Attachment_Service(); |
|
| 1297 | 1297 | |
| 1298 | - // Instantiate the JSON-LD service. |
|
| 1299 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1300 | - $this->post_to_jsonld_converter = new Wordlift_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1301 | - $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter ); |
|
| 1302 | - $this->postid_to_jsonld_converter = new Wordlift_Postid_To_Jsonld_Converter( $this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter ); |
|
| 1303 | - $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1298 | + // Instantiate the JSON-LD service. |
|
| 1299 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1300 | + $this->post_to_jsonld_converter = new Wordlift_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1301 | + $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter ); |
|
| 1302 | + $this->postid_to_jsonld_converter = new Wordlift_Postid_To_Jsonld_Converter( $this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter ); |
|
| 1303 | + $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1304 | 1304 | |
| 1305 | - $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1306 | - $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache ); |
|
| 1307 | - /* |
|
| 1305 | + $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1306 | + $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache ); |
|
| 1307 | + /* |
|
| 1308 | 1308 | * Load the `Wordlift_Term_JsonLd_Adapter`. |
| 1309 | 1309 | * |
| 1310 | 1310 | * @see https://github.com/insideout10/wordlift-plugin/issues/892 |
| 1311 | 1311 | * |
| 1312 | 1312 | * @since 3.20.0 |
| 1313 | 1313 | */ |
| 1314 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1315 | - $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service ); |
|
| 1316 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter, $term_jsonld_adapter ); |
|
| 1317 | - |
|
| 1318 | - |
|
| 1319 | - $jsonld_service = new Jsonld_Service( |
|
| 1320 | - $this->jsonld_service, |
|
| 1321 | - $term_jsonld_adapter, |
|
| 1322 | - new Jsonld_User_Service( $this->user_service ) ); |
|
| 1323 | - new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service ); |
|
| 1324 | - |
|
| 1325 | - // Prints the JSON-LD in the head. |
|
| 1326 | - new Jsonld_Adapter( $this->jsonld_service ); |
|
| 1327 | - |
|
| 1328 | - new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service ); |
|
| 1329 | - |
|
| 1330 | - $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1331 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service ); |
|
| 1332 | - // Creating Faq Content filter service. |
|
| 1333 | - $this->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1334 | - $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1335 | - $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service ); |
|
| 1336 | - $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1337 | - $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->entity_service ); |
|
| 1338 | - |
|
| 1339 | - $this->loader->add_action( 'enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks' ); |
|
| 1340 | - $this->loader->add_action( 'admin_enqueue_scripts', $this, 'add_wl_enabled_blocks' ); |
|
| 1341 | - |
|
| 1342 | - /** |
|
| 1343 | - * Filter: wl_feature__enable__blocks. |
|
| 1344 | - * |
|
| 1345 | - * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1346 | - * |
|
| 1347 | - * @return bool |
|
| 1348 | - * @since 3.27.6 |
|
| 1349 | - */ |
|
| 1350 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1351 | - // Initialize the short-codes. |
|
| 1352 | - new Async_Template_Decorator( new Wordlift_Navigator_Shortcode() ); |
|
| 1353 | - new Wordlift_Chord_Shortcode(); |
|
| 1354 | - new Wordlift_Geomap_Shortcode(); |
|
| 1355 | - new Wordlift_Timeline_Shortcode(); |
|
| 1356 | - new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service, $this->entity_service ); |
|
| 1357 | - new Wordlift_Vocabulary_Shortcode( $this->configuration_service ); |
|
| 1358 | - new Async_Template_Decorator( new Wordlift_Faceted_Search_Shortcode() ); |
|
| 1359 | - } |
|
| 1360 | - |
|
| 1361 | - new Wordlift_Products_Navigator_Shortcode(); |
|
| 1362 | - |
|
| 1363 | - |
|
| 1364 | - // Initialize the Context Cards Service |
|
| 1365 | - $this->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1366 | - |
|
| 1367 | - // Initialize the SEO service. |
|
| 1368 | - new Wordlift_Seo_Service(); |
|
| 1369 | - |
|
| 1370 | - // Initialize the AMP service. |
|
| 1371 | - new Wordlift_AMP_Service( $this->jsonld_service ); |
|
| 1372 | - |
|
| 1373 | - /** Services. */ |
|
| 1374 | - $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1375 | - new Wordlift_Image_Service(); |
|
| 1376 | - |
|
| 1377 | - /** Adapters. */ |
|
| 1378 | - $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1379 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service ); |
|
| 1380 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1381 | - //$this->faq_tinymce_adapter = new Faq_Tinymce_Adapter(); |
|
| 1382 | - $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1383 | - |
|
| 1384 | - /* |
|
| 1314 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1315 | + $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service ); |
|
| 1316 | + $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter, $term_jsonld_adapter ); |
|
| 1317 | + |
|
| 1318 | + |
|
| 1319 | + $jsonld_service = new Jsonld_Service( |
|
| 1320 | + $this->jsonld_service, |
|
| 1321 | + $term_jsonld_adapter, |
|
| 1322 | + new Jsonld_User_Service( $this->user_service ) ); |
|
| 1323 | + new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service ); |
|
| 1324 | + |
|
| 1325 | + // Prints the JSON-LD in the head. |
|
| 1326 | + new Jsonld_Adapter( $this->jsonld_service ); |
|
| 1327 | + |
|
| 1328 | + new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service ); |
|
| 1329 | + |
|
| 1330 | + $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1331 | + $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service ); |
|
| 1332 | + // Creating Faq Content filter service. |
|
| 1333 | + $this->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1334 | + $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1335 | + $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service ); |
|
| 1336 | + $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1337 | + $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->entity_service ); |
|
| 1338 | + |
|
| 1339 | + $this->loader->add_action( 'enqueue_block_editor_assets', $this, 'add_wl_enabled_blocks' ); |
|
| 1340 | + $this->loader->add_action( 'admin_enqueue_scripts', $this, 'add_wl_enabled_blocks' ); |
|
| 1341 | + |
|
| 1342 | + /** |
|
| 1343 | + * Filter: wl_feature__enable__blocks. |
|
| 1344 | + * |
|
| 1345 | + * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1346 | + * |
|
| 1347 | + * @return bool |
|
| 1348 | + * @since 3.27.6 |
|
| 1349 | + */ |
|
| 1350 | + if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1351 | + // Initialize the short-codes. |
|
| 1352 | + new Async_Template_Decorator( new Wordlift_Navigator_Shortcode() ); |
|
| 1353 | + new Wordlift_Chord_Shortcode(); |
|
| 1354 | + new Wordlift_Geomap_Shortcode(); |
|
| 1355 | + new Wordlift_Timeline_Shortcode(); |
|
| 1356 | + new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service, $this->entity_service ); |
|
| 1357 | + new Wordlift_Vocabulary_Shortcode( $this->configuration_service ); |
|
| 1358 | + new Async_Template_Decorator( new Wordlift_Faceted_Search_Shortcode() ); |
|
| 1359 | + } |
|
| 1360 | + |
|
| 1361 | + new Wordlift_Products_Navigator_Shortcode(); |
|
| 1362 | + |
|
| 1363 | + |
|
| 1364 | + // Initialize the Context Cards Service |
|
| 1365 | + $this->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1366 | + |
|
| 1367 | + // Initialize the SEO service. |
|
| 1368 | + new Wordlift_Seo_Service(); |
|
| 1369 | + |
|
| 1370 | + // Initialize the AMP service. |
|
| 1371 | + new Wordlift_AMP_Service( $this->jsonld_service ); |
|
| 1372 | + |
|
| 1373 | + /** Services. */ |
|
| 1374 | + $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1375 | + new Wordlift_Image_Service(); |
|
| 1376 | + |
|
| 1377 | + /** Adapters. */ |
|
| 1378 | + $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1379 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service ); |
|
| 1380 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1381 | + //$this->faq_tinymce_adapter = new Faq_Tinymce_Adapter(); |
|
| 1382 | + $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1383 | + |
|
| 1384 | + /* |
|
| 1385 | 1385 | * Exclude our public js from WP-Rocket. |
| 1386 | 1386 | * |
| 1387 | 1387 | * @since 3.19.4 |
| 1388 | 1388 | * |
| 1389 | 1389 | * @see https://github.com/insideout10/wordlift-plugin/issues/842. |
| 1390 | 1390 | */ |
| 1391 | - new Wordlift_WpRocket_Adapter(); |
|
| 1392 | - |
|
| 1393 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 1394 | - $this->rebuild_service = new Wordlift_Rebuild_Service( |
|
| 1395 | - $this->sparql_service, |
|
| 1396 | - $uri_service |
|
| 1397 | - ); |
|
| 1398 | - |
|
| 1399 | - $that = $this; |
|
| 1400 | - add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1401 | - if ( ! apply_filters( 'wl_feature__enable__dataset-ng', false ) ) { |
|
| 1402 | - new Wordlift_Linked_Data_Service( $that->entity_service, $that->entity_type_service, $that->schema_service, $that->sparql_service ); |
|
| 1403 | - new Wordlift_Sparql_Query_Async_Task(); |
|
| 1404 | - new Wordlift_Push_References_Async_Task(); |
|
| 1405 | - } |
|
| 1406 | - } ); |
|
| 1407 | - |
|
| 1408 | - /** WordPress Admin UI. */ |
|
| 1409 | - |
|
| 1410 | - // UI elements. |
|
| 1411 | - $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1412 | - $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1413 | - $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1414 | - $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1415 | - $this->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1416 | - $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1417 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element ); |
|
| 1418 | - $this->author_element = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element ); |
|
| 1419 | - |
|
| 1420 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1421 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1422 | - |
|
| 1423 | - $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element ); |
|
| 1424 | - $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page ); |
|
| 1425 | - $this->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1426 | - |
|
| 1427 | - // Pages. |
|
| 1428 | - /* |
|
| 1391 | + new Wordlift_WpRocket_Adapter(); |
|
| 1392 | + |
|
| 1393 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 1394 | + $this->rebuild_service = new Wordlift_Rebuild_Service( |
|
| 1395 | + $this->sparql_service, |
|
| 1396 | + $uri_service |
|
| 1397 | + ); |
|
| 1398 | + |
|
| 1399 | + $that = $this; |
|
| 1400 | + add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1401 | + if ( ! apply_filters( 'wl_feature__enable__dataset-ng', false ) ) { |
|
| 1402 | + new Wordlift_Linked_Data_Service( $that->entity_service, $that->entity_type_service, $that->schema_service, $that->sparql_service ); |
|
| 1403 | + new Wordlift_Sparql_Query_Async_Task(); |
|
| 1404 | + new Wordlift_Push_References_Async_Task(); |
|
| 1405 | + } |
|
| 1406 | + } ); |
|
| 1407 | + |
|
| 1408 | + /** WordPress Admin UI. */ |
|
| 1409 | + |
|
| 1410 | + // UI elements. |
|
| 1411 | + $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1412 | + $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1413 | + $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1414 | + $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1415 | + $this->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1416 | + $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1417 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element ); |
|
| 1418 | + $this->author_element = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element ); |
|
| 1419 | + |
|
| 1420 | + $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1421 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1422 | + |
|
| 1423 | + $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element ); |
|
| 1424 | + $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page ); |
|
| 1425 | + $this->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1426 | + |
|
| 1427 | + // Pages. |
|
| 1428 | + /* |
|
| 1429 | 1429 | * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box. |
| 1430 | 1430 | * |
| 1431 | 1431 | * @since 3.20.3 |
| 1432 | 1432 | * |
| 1433 | 1433 | * @see https://github.com/insideout10/wordlift-plugin/issues/914 |
| 1434 | 1434 | */ |
| 1435 | - if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1436 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1437 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1438 | - } |
|
| 1439 | - new Wordlift_Entity_Type_Admin_Service(); |
|
| 1435 | + if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1436 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1437 | + new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1438 | + } |
|
| 1439 | + new Wordlift_Entity_Type_Admin_Service(); |
|
| 1440 | 1440 | |
| 1441 | - // create an instance of the entity type list admin page controller. |
|
| 1442 | - $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1441 | + // create an instance of the entity type list admin page controller. |
|
| 1442 | + $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1443 | 1443 | |
| 1444 | - // create an instance of the entity type setting admin page controller. |
|
| 1445 | - $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1444 | + // create an instance of the entity type setting admin page controller. |
|
| 1445 | + $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1446 | 1446 | |
| 1447 | - /** Widgets */ |
|
| 1448 | - $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1447 | + /** Widgets */ |
|
| 1448 | + $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1449 | 1449 | |
| 1450 | - /* WordPress Admin. */ |
|
| 1451 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1452 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1450 | + /* WordPress Admin. */ |
|
| 1451 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1452 | + $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1453 | 1453 | |
| 1454 | - // Create an instance of the install wizard. |
|
| 1455 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element ); |
|
| 1454 | + // Create an instance of the install wizard. |
|
| 1455 | + $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element ); |
|
| 1456 | 1456 | |
| 1457 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1457 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1458 | 1458 | |
| 1459 | - // User Profile. |
|
| 1460 | - new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1459 | + // User Profile. |
|
| 1460 | + new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1461 | 1461 | |
| 1462 | - $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1462 | + $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1463 | 1463 | |
| 1464 | - // Load the debug service if WP is in debug mode. |
|
| 1465 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1466 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1467 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1468 | - } |
|
| 1464 | + // Load the debug service if WP is in debug mode. |
|
| 1465 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1466 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1467 | + new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1468 | + } |
|
| 1469 | 1469 | |
| 1470 | - // Remote Image Service. |
|
| 1471 | - new Wordlift_Remote_Image_Service(); |
|
| 1470 | + // Remote Image Service. |
|
| 1471 | + new Wordlift_Remote_Image_Service(); |
|
| 1472 | 1472 | |
| 1473 | - /* |
|
| 1473 | + /* |
|
| 1474 | 1474 | * Provides mappings between post types and entity types. |
| 1475 | 1475 | * |
| 1476 | 1476 | * @since 3.20.0 |
| 1477 | 1477 | * |
| 1478 | 1478 | * @see https://github.com/insideout10/wordlift-plugin/issues/852. |
| 1479 | 1479 | */ |
| 1480 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1481 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1482 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1480 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1481 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1482 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1483 | 1483 | |
| 1484 | - // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1485 | - new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1484 | + // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1485 | + new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1486 | 1486 | |
| 1487 | - /* |
|
| 1487 | + /* |
|
| 1488 | 1488 | * Batch Operations. They're similar to Batch Actions but do not require working on post types. |
| 1489 | 1489 | * |
| 1490 | 1490 | * Eventually Batch Actions will become Batch Operations. |
| 1491 | 1491 | * |
| 1492 | 1492 | * @since 3.20.0 |
| 1493 | 1493 | */ |
| 1494 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1495 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1496 | - /* |
|
| 1494 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1495 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1496 | + /* |
|
| 1497 | 1497 | * Load the Mappings JSON-LD post processing. |
| 1498 | 1498 | * |
| 1499 | 1499 | * @since 3.25.0 |
| 1500 | 1500 | */ |
| 1501 | 1501 | |
| 1502 | - $mappings_dbo = new Mappings_DBO(); |
|
| 1503 | - $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1504 | - new Post_Type_Rule_Validator(); |
|
| 1505 | - // Taxonomy term rule validator for validating rules for term pages. |
|
| 1506 | - new Taxonomy_Term_Rule_Validator(); |
|
| 1507 | - new Post_Taxonomy_Term_Rule_Validator(); |
|
| 1508 | - $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1509 | - $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1510 | - $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1511 | - |
|
| 1512 | - new Url_To_Entity_Transform_Function( $this->entity_uri_service ); |
|
| 1513 | - new Taxonomy_To_Terms_Transform_Function(); |
|
| 1514 | - new Post_Id_To_Entity_Transform_Function(); |
|
| 1515 | - $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1516 | - |
|
| 1517 | - /** |
|
| 1518 | - * @since 3.27.1 |
|
| 1519 | - * Intiailize the acf group data formatter. |
|
| 1520 | - */ |
|
| 1521 | - new Acf_Group_Formatter(); |
|
| 1522 | - new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1523 | - |
|
| 1524 | - /** |
|
| 1525 | - * @since 3.26.0 |
|
| 1526 | - * Initialize the Faq JSON LD converter here - disabled. |
|
| 1527 | - */ |
|
| 1528 | - // new Faq_To_Jsonld_Converter(); |
|
| 1529 | - /* |
|
| 1502 | + $mappings_dbo = new Mappings_DBO(); |
|
| 1503 | + $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1504 | + new Post_Type_Rule_Validator(); |
|
| 1505 | + // Taxonomy term rule validator for validating rules for term pages. |
|
| 1506 | + new Taxonomy_Term_Rule_Validator(); |
|
| 1507 | + new Post_Taxonomy_Term_Rule_Validator(); |
|
| 1508 | + $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1509 | + $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1510 | + $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1511 | + |
|
| 1512 | + new Url_To_Entity_Transform_Function( $this->entity_uri_service ); |
|
| 1513 | + new Taxonomy_To_Terms_Transform_Function(); |
|
| 1514 | + new Post_Id_To_Entity_Transform_Function(); |
|
| 1515 | + $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1516 | + |
|
| 1517 | + /** |
|
| 1518 | + * @since 3.27.1 |
|
| 1519 | + * Intiailize the acf group data formatter. |
|
| 1520 | + */ |
|
| 1521 | + new Acf_Group_Formatter(); |
|
| 1522 | + new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1523 | + |
|
| 1524 | + /** |
|
| 1525 | + * @since 3.26.0 |
|
| 1526 | + * Initialize the Faq JSON LD converter here - disabled. |
|
| 1527 | + */ |
|
| 1528 | + // new Faq_To_Jsonld_Converter(); |
|
| 1529 | + /* |
|
| 1530 | 1530 | * Use the Templates Ajax Endpoint to load HTML templates for the legacy Angular app via admin-ajax.php |
| 1531 | 1531 | * end-point. |
| 1532 | 1532 | * |
| 1533 | 1533 | * @see https://github.com/insideout10/wordlift-plugin/issues/834 |
| 1534 | 1534 | * @since 3.24.4 |
| 1535 | 1535 | */ |
| 1536 | - new Templates_Ajax_Endpoint(); |
|
| 1537 | - // Call this static method to register FAQ routes to rest api - disabled |
|
| 1538 | - //Faq_Rest_Controller::register_routes(); |
|
| 1536 | + new Templates_Ajax_Endpoint(); |
|
| 1537 | + // Call this static method to register FAQ routes to rest api - disabled |
|
| 1538 | + //Faq_Rest_Controller::register_routes(); |
|
| 1539 | 1539 | |
| 1540 | - /* |
|
| 1540 | + /* |
|
| 1541 | 1541 | * Create a singleton for the Analysis_Response_Ops_Factory. |
| 1542 | 1542 | */ |
| 1543 | - $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service ); |
|
| 1544 | - /** |
|
| 1545 | - * @since 3.32.0 |
|
| 1546 | - * Initialize a local entity provider which acts as an abstraction layer |
|
| 1547 | - * between the different types of objects in wordpress. |
|
| 1548 | - */ |
|
| 1549 | - $entity_provider_registry = new Entity_Provider_Registry(); |
|
| 1550 | - |
|
| 1551 | - /** |
|
| 1552 | - * @since 3.32.0 |
|
| 1553 | - * The post entity provider has the legacy code which provides the entity |
|
| 1554 | - * if the object is post {@link \Wordlift\Object_Type_Enum::POST} |
|
| 1555 | - */ |
|
| 1556 | - new Post_Entity_Provider($this->entity_uri_service, |
|
| 1557 | - $this->entity_type_service, $this->storage_factory->post_images() ); |
|
| 1558 | - /** |
|
| 1559 | - * @since 3.32.0 |
|
| 1560 | - * The term entity provider provides the entity |
|
| 1561 | - * if the object is term {@link \Wordlift\Object_Type_Enum::POST} |
|
| 1562 | - */ |
|
| 1563 | - new Term_Entity_Provider(); |
|
| 1564 | - |
|
| 1565 | - new Analysis_Response_Ops_Factory( |
|
| 1566 | - $this->entity_uri_service, |
|
| 1567 | - $entity_helper, |
|
| 1568 | - $entity_provider_registry |
|
| 1569 | - ); |
|
| 1570 | - |
|
| 1571 | - /** WL Autocomplete. */ |
|
| 1572 | - $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1573 | - new Local_Autocomplete_Service(), |
|
| 1574 | - new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ), |
|
| 1575 | - ) ); |
|
| 1576 | - $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1577 | - |
|
| 1578 | - /** |
|
| 1579 | - * @since 3.27.2 |
|
| 1580 | - * Integrate the recipe maker jsonld & set recipe |
|
| 1581 | - * as default entity type to the wprm_recipe CPT. |
|
| 1582 | - */ |
|
| 1583 | - new Recipe_Maker_Post_Type_Hook(); |
|
| 1584 | - $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1585 | - new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1586 | - new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1587 | - new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1588 | - new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1589 | - |
|
| 1590 | - /** |
|
| 1591 | - * @since 3.27.4 |
|
| 1592 | - * Add the faq duplicate markup hook. |
|
| 1593 | - */ |
|
| 1594 | - new Faq_Duplicate_Markup_Remover(); |
|
| 1595 | - /** |
|
| 1596 | - * @since 3.27.8 |
|
| 1597 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1248 |
|
| 1598 | - */ |
|
| 1599 | - new Key_Validation_Notice( $this->key_validation_service, $this->configuration_service ); |
|
| 1600 | - /** |
|
| 1601 | - * @since 3.28.0 |
|
| 1602 | - * @see https://github.com/insideout10/wordlift-plugin/issues?q=assignee%3Anaveen17797+is%3Aopen |
|
| 1603 | - */ |
|
| 1604 | - new Entity_No_Index_Flag(); |
|
| 1605 | - |
|
| 1606 | - /** |
|
| 1607 | - * @since 3.29.0 |
|
| 1608 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1304 |
|
| 1609 | - */ |
|
| 1610 | - new Entity_Rest_Service( $this->entity_type_service ); |
|
| 1611 | - |
|
| 1612 | - /** |
|
| 1613 | - * Expand author in to references. |
|
| 1614 | - * @since 3.30.0 |
|
| 1615 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1318 |
|
| 1616 | - */ |
|
| 1617 | - |
|
| 1618 | - add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1619 | - |
|
| 1620 | - if ( apply_filters( 'wl_feature__enable__article-wrapper', false ) ) { |
|
| 1621 | - new Jsonld_Article_Wrapper( Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter ); |
|
| 1622 | - } |
|
| 1623 | - |
|
| 1624 | - if ( apply_filters( 'wl_feature__enable__match-terms', false ) ) { |
|
| 1625 | - $vocabulary_loader = new Vocabulary_Loader(); |
|
| 1626 | - $vocabulary_loader->init_vocabulary(); |
|
| 1627 | - } |
|
| 1628 | - |
|
| 1629 | - } ); |
|
| 1630 | - |
|
| 1631 | - /** |
|
| 1632 | - * @since 3.30.0 |
|
| 1633 | - * Add a checkbox to user option screen for wordlift admin. |
|
| 1634 | - */ |
|
| 1635 | - $wordlift_admin_checkbox = new Admin_User_Option(); |
|
| 1636 | - $wordlift_admin_checkbox->connect_hook(); |
|
| 1637 | - /** |
|
| 1638 | - * @since 3.31.0 |
|
| 1639 | - * Init loader class for videoobject. |
|
| 1640 | - */ |
|
| 1641 | - $videoobject_loader = new Loader(); |
|
| 1642 | - $videoobject_loader->init_feature(); |
|
| 1643 | - /** |
|
| 1644 | - * @since 3.31.5 |
|
| 1645 | - * Create configuration endpoint for webapp to configure. |
|
| 1646 | - */ |
|
| 1647 | - new Config( $this->admin_setup, $this->key_validation_service, $this->configuration_service ); |
|
| 1648 | - /** |
|
| 1649 | - * @since 3.31.7 |
|
| 1650 | - * Remove duplicate videoobject. |
|
| 1651 | - */ |
|
| 1652 | - new Videoobject_Duplicate_Remover(); |
|
| 1653 | - $synonym_loader = new \Wordlift\Synonym\Loader(); |
|
| 1654 | - $synonym_loader->init_feature(); |
|
| 1655 | - /** |
|
| 1656 | - * @since 3.32.0 |
|
| 1657 | - * Create loader for vocabulary terms. |
|
| 1658 | - */ |
|
| 1659 | - $vocabulary_terms_loader = new Vocabulary_Terms_Loader( $this->entity_type_service, $property_getter ); |
|
| 1660 | - $vocabulary_terms_loader->init_feature(); |
|
| 1661 | - |
|
| 1662 | - new Entity_Type_Change_Handler( |
|
| 1663 | - $this->entity_service, |
|
| 1664 | - $this->entity_type_service |
|
| 1665 | - ); |
|
| 1666 | - |
|
| 1667 | - new Entity_Type_Setter(); |
|
| 1668 | - } |
|
| 1669 | - |
|
| 1670 | - /** |
|
| 1671 | - * Define the locale for this plugin for internationalization. |
|
| 1672 | - * |
|
| 1673 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1674 | - * with WordPress. |
|
| 1675 | - * |
|
| 1676 | - * @since 1.0.0 |
|
| 1677 | - * @access private |
|
| 1678 | - */ |
|
| 1679 | - private function set_locale() { |
|
| 1680 | - |
|
| 1681 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 1682 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1683 | - |
|
| 1684 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1685 | - |
|
| 1686 | - } |
|
| 1687 | - |
|
| 1688 | - /** |
|
| 1689 | - * Register all of the hooks related to the admin area functionality |
|
| 1690 | - * of the plugin. |
|
| 1691 | - * |
|
| 1692 | - * @since 1.0.0 |
|
| 1693 | - * @access private |
|
| 1694 | - */ |
|
| 1695 | - private function define_admin_hooks() { |
|
| 1696 | - $that = $this; |
|
| 1697 | - $plugin_admin = new Wordlift_Admin( |
|
| 1698 | - $this->get_plugin_name(), |
|
| 1699 | - $this->get_version(), |
|
| 1700 | - $this->configuration_service, |
|
| 1701 | - $this->notice_service, |
|
| 1702 | - $this->user_service |
|
| 1703 | - ); |
|
| 1704 | - |
|
| 1705 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1706 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1707 | - |
|
| 1708 | - // Hook the init action to taxonomy services. |
|
| 1709 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1710 | - $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1711 | - |
|
| 1712 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1713 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1714 | - |
|
| 1715 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 1716 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1717 | - |
|
| 1718 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1719 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1720 | - |
|
| 1721 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1722 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1723 | - |
|
| 1724 | - // Register custom allowed redirect hosts. |
|
| 1725 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1726 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1727 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1728 | - |
|
| 1729 | - /* |
|
| 1543 | + $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service ); |
|
| 1544 | + /** |
|
| 1545 | + * @since 3.32.0 |
|
| 1546 | + * Initialize a local entity provider which acts as an abstraction layer |
|
| 1547 | + * between the different types of objects in wordpress. |
|
| 1548 | + */ |
|
| 1549 | + $entity_provider_registry = new Entity_Provider_Registry(); |
|
| 1550 | + |
|
| 1551 | + /** |
|
| 1552 | + * @since 3.32.0 |
|
| 1553 | + * The post entity provider has the legacy code which provides the entity |
|
| 1554 | + * if the object is post {@link \Wordlift\Object_Type_Enum::POST} |
|
| 1555 | + */ |
|
| 1556 | + new Post_Entity_Provider($this->entity_uri_service, |
|
| 1557 | + $this->entity_type_service, $this->storage_factory->post_images() ); |
|
| 1558 | + /** |
|
| 1559 | + * @since 3.32.0 |
|
| 1560 | + * The term entity provider provides the entity |
|
| 1561 | + * if the object is term {@link \Wordlift\Object_Type_Enum::POST} |
|
| 1562 | + */ |
|
| 1563 | + new Term_Entity_Provider(); |
|
| 1564 | + |
|
| 1565 | + new Analysis_Response_Ops_Factory( |
|
| 1566 | + $this->entity_uri_service, |
|
| 1567 | + $entity_helper, |
|
| 1568 | + $entity_provider_registry |
|
| 1569 | + ); |
|
| 1570 | + |
|
| 1571 | + /** WL Autocomplete. */ |
|
| 1572 | + $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1573 | + new Local_Autocomplete_Service(), |
|
| 1574 | + new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ), |
|
| 1575 | + ) ); |
|
| 1576 | + $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1577 | + |
|
| 1578 | + /** |
|
| 1579 | + * @since 3.27.2 |
|
| 1580 | + * Integrate the recipe maker jsonld & set recipe |
|
| 1581 | + * as default entity type to the wprm_recipe CPT. |
|
| 1582 | + */ |
|
| 1583 | + new Recipe_Maker_Post_Type_Hook(); |
|
| 1584 | + $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1585 | + new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1586 | + new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1587 | + new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1588 | + new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1589 | + |
|
| 1590 | + /** |
|
| 1591 | + * @since 3.27.4 |
|
| 1592 | + * Add the faq duplicate markup hook. |
|
| 1593 | + */ |
|
| 1594 | + new Faq_Duplicate_Markup_Remover(); |
|
| 1595 | + /** |
|
| 1596 | + * @since 3.27.8 |
|
| 1597 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1248 |
|
| 1598 | + */ |
|
| 1599 | + new Key_Validation_Notice( $this->key_validation_service, $this->configuration_service ); |
|
| 1600 | + /** |
|
| 1601 | + * @since 3.28.0 |
|
| 1602 | + * @see https://github.com/insideout10/wordlift-plugin/issues?q=assignee%3Anaveen17797+is%3Aopen |
|
| 1603 | + */ |
|
| 1604 | + new Entity_No_Index_Flag(); |
|
| 1605 | + |
|
| 1606 | + /** |
|
| 1607 | + * @since 3.29.0 |
|
| 1608 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1304 |
|
| 1609 | + */ |
|
| 1610 | + new Entity_Rest_Service( $this->entity_type_service ); |
|
| 1611 | + |
|
| 1612 | + /** |
|
| 1613 | + * Expand author in to references. |
|
| 1614 | + * @since 3.30.0 |
|
| 1615 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1318 |
|
| 1616 | + */ |
|
| 1617 | + |
|
| 1618 | + add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1619 | + |
|
| 1620 | + if ( apply_filters( 'wl_feature__enable__article-wrapper', false ) ) { |
|
| 1621 | + new Jsonld_Article_Wrapper( Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter ); |
|
| 1622 | + } |
|
| 1623 | + |
|
| 1624 | + if ( apply_filters( 'wl_feature__enable__match-terms', false ) ) { |
|
| 1625 | + $vocabulary_loader = new Vocabulary_Loader(); |
|
| 1626 | + $vocabulary_loader->init_vocabulary(); |
|
| 1627 | + } |
|
| 1628 | + |
|
| 1629 | + } ); |
|
| 1630 | + |
|
| 1631 | + /** |
|
| 1632 | + * @since 3.30.0 |
|
| 1633 | + * Add a checkbox to user option screen for wordlift admin. |
|
| 1634 | + */ |
|
| 1635 | + $wordlift_admin_checkbox = new Admin_User_Option(); |
|
| 1636 | + $wordlift_admin_checkbox->connect_hook(); |
|
| 1637 | + /** |
|
| 1638 | + * @since 3.31.0 |
|
| 1639 | + * Init loader class for videoobject. |
|
| 1640 | + */ |
|
| 1641 | + $videoobject_loader = new Loader(); |
|
| 1642 | + $videoobject_loader->init_feature(); |
|
| 1643 | + /** |
|
| 1644 | + * @since 3.31.5 |
|
| 1645 | + * Create configuration endpoint for webapp to configure. |
|
| 1646 | + */ |
|
| 1647 | + new Config( $this->admin_setup, $this->key_validation_service, $this->configuration_service ); |
|
| 1648 | + /** |
|
| 1649 | + * @since 3.31.7 |
|
| 1650 | + * Remove duplicate videoobject. |
|
| 1651 | + */ |
|
| 1652 | + new Videoobject_Duplicate_Remover(); |
|
| 1653 | + $synonym_loader = new \Wordlift\Synonym\Loader(); |
|
| 1654 | + $synonym_loader->init_feature(); |
|
| 1655 | + /** |
|
| 1656 | + * @since 3.32.0 |
|
| 1657 | + * Create loader for vocabulary terms. |
|
| 1658 | + */ |
|
| 1659 | + $vocabulary_terms_loader = new Vocabulary_Terms_Loader( $this->entity_type_service, $property_getter ); |
|
| 1660 | + $vocabulary_terms_loader->init_feature(); |
|
| 1661 | + |
|
| 1662 | + new Entity_Type_Change_Handler( |
|
| 1663 | + $this->entity_service, |
|
| 1664 | + $this->entity_type_service |
|
| 1665 | + ); |
|
| 1666 | + |
|
| 1667 | + new Entity_Type_Setter(); |
|
| 1668 | + } |
|
| 1669 | + |
|
| 1670 | + /** |
|
| 1671 | + * Define the locale for this plugin for internationalization. |
|
| 1672 | + * |
|
| 1673 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1674 | + * with WordPress. |
|
| 1675 | + * |
|
| 1676 | + * @since 1.0.0 |
|
| 1677 | + * @access private |
|
| 1678 | + */ |
|
| 1679 | + private function set_locale() { |
|
| 1680 | + |
|
| 1681 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 1682 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1683 | + |
|
| 1684 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1685 | + |
|
| 1686 | + } |
|
| 1687 | + |
|
| 1688 | + /** |
|
| 1689 | + * Register all of the hooks related to the admin area functionality |
|
| 1690 | + * of the plugin. |
|
| 1691 | + * |
|
| 1692 | + * @since 1.0.0 |
|
| 1693 | + * @access private |
|
| 1694 | + */ |
|
| 1695 | + private function define_admin_hooks() { |
|
| 1696 | + $that = $this; |
|
| 1697 | + $plugin_admin = new Wordlift_Admin( |
|
| 1698 | + $this->get_plugin_name(), |
|
| 1699 | + $this->get_version(), |
|
| 1700 | + $this->configuration_service, |
|
| 1701 | + $this->notice_service, |
|
| 1702 | + $this->user_service |
|
| 1703 | + ); |
|
| 1704 | + |
|
| 1705 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1706 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1707 | + |
|
| 1708 | + // Hook the init action to taxonomy services. |
|
| 1709 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1710 | + $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1711 | + |
|
| 1712 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1713 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1714 | + |
|
| 1715 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 1716 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1717 | + |
|
| 1718 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1719 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1720 | + |
|
| 1721 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1722 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1723 | + |
|
| 1724 | + // Register custom allowed redirect hosts. |
|
| 1725 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1726 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1727 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1728 | + |
|
| 1729 | + /* |
|
| 1730 | 1730 | * The old dashboard is replaced with dashboard v2. |
| 1731 | 1731 | * |
| 1732 | 1732 | * The old dashboard service is still loaded because its functions are used. |
@@ -1735,391 +1735,391 @@ discard block |
||
| 1735 | 1735 | * |
| 1736 | 1736 | * @since 3.20.0 |
| 1737 | 1737 | */ |
| 1738 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1739 | - // $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1740 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1741 | - // $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1742 | - |
|
| 1743 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1744 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1745 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1746 | - $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1747 | - |
|
| 1748 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1749 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1750 | - |
|
| 1751 | - // Entity listing customization (wp-admin/edit.php) |
|
| 1752 | - // Add custom columns. |
|
| 1753 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1754 | - // no explicit entity as it prevents handling of other post types. |
|
| 1755 | - $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1756 | - // Add 4W selection. |
|
| 1757 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1758 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1759 | - $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1760 | - $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1761 | - |
|
| 1762 | - /* |
|
| 1738 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1739 | + // $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1740 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1741 | + // $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1742 | + |
|
| 1743 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1744 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1745 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1746 | + $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1747 | + |
|
| 1748 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1749 | + $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1750 | + |
|
| 1751 | + // Entity listing customization (wp-admin/edit.php) |
|
| 1752 | + // Add custom columns. |
|
| 1753 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1754 | + // no explicit entity as it prevents handling of other post types. |
|
| 1755 | + $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1756 | + // Add 4W selection. |
|
| 1757 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1758 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1759 | + $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1760 | + $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1761 | + |
|
| 1762 | + /* |
|
| 1763 | 1763 | * If `All Entity Types` is disable, use the radio button Walker. |
| 1764 | 1764 | * |
| 1765 | 1765 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1766 | 1766 | */ |
| 1767 | - if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1768 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1769 | - } |
|
| 1770 | - |
|
| 1771 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1772 | - // entities. |
|
| 1773 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1774 | - |
|
| 1775 | - // Filter imported post meta. |
|
| 1776 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1777 | - |
|
| 1778 | - // Notify the import service when an import starts and ends. |
|
| 1779 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1780 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1781 | - |
|
| 1782 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1783 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1784 | - $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' ); |
|
| 1785 | - |
|
| 1786 | - /** |
|
| 1787 | - * Filter: wl_feature__enable__settings-download. |
|
| 1788 | - * |
|
| 1789 | - * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1790 | - * |
|
| 1791 | - * @return bool |
|
| 1792 | - * @since 3.27.6 |
|
| 1793 | - */ |
|
| 1794 | - $this->features_registry->register_feature_from_slug( 'settings-download', true, array( |
|
| 1795 | - $this, |
|
| 1796 | - 'register_screens' |
|
| 1797 | - ) ); |
|
| 1798 | - |
|
| 1799 | - |
|
| 1800 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1801 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1802 | - |
|
| 1803 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1804 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1805 | - $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1806 | - $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1807 | - |
|
| 1808 | - // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1809 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1810 | - |
|
| 1811 | - // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1812 | - $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' ); |
|
| 1813 | - |
|
| 1814 | - // Hook the `admin_init` function to the Admin Setup. |
|
| 1815 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1816 | - |
|
| 1817 | - // Hook the admin_init to the settings page. |
|
| 1818 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1819 | - $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' ); |
|
| 1820 | - |
|
| 1821 | - $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' ); |
|
| 1822 | - |
|
| 1823 | - // Hook the menu creation on the general wordlift menu creation. |
|
| 1824 | - /** |
|
| 1825 | - * Filter: wl_feature__enable__screens. |
|
| 1826 | - * |
|
| 1827 | - * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1828 | - * |
|
| 1829 | - * @return bool |
|
| 1830 | - * @since 3.27.6 |
|
| 1831 | - * |
|
| 1832 | - * Since 3.30.0 this feature is registered using registry. |
|
| 1833 | - */ |
|
| 1834 | - add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1835 | - if ( apply_filters( 'wl_feature__enable__settings-screen', true ) || Admin_User_Option::is_wordlift_admin() ) { |
|
| 1836 | - add_action( 'wl_admin_menu', array( $that->settings_page, 'admin_menu' ), 10, 2 ); |
|
| 1837 | - } |
|
| 1838 | - } ); |
|
| 1839 | - |
|
| 1840 | - // Hook key update. |
|
| 1841 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1842 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1843 | - |
|
| 1844 | - // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1845 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1846 | - |
|
| 1847 | - /* |
|
| 1767 | + if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1768 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1769 | + } |
|
| 1770 | + |
|
| 1771 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1772 | + // entities. |
|
| 1773 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1774 | + |
|
| 1775 | + // Filter imported post meta. |
|
| 1776 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1777 | + |
|
| 1778 | + // Notify the import service when an import starts and ends. |
|
| 1779 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1780 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1781 | + |
|
| 1782 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1783 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1784 | + $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' ); |
|
| 1785 | + |
|
| 1786 | + /** |
|
| 1787 | + * Filter: wl_feature__enable__settings-download. |
|
| 1788 | + * |
|
| 1789 | + * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1790 | + * |
|
| 1791 | + * @return bool |
|
| 1792 | + * @since 3.27.6 |
|
| 1793 | + */ |
|
| 1794 | + $this->features_registry->register_feature_from_slug( 'settings-download', true, array( |
|
| 1795 | + $this, |
|
| 1796 | + 'register_screens' |
|
| 1797 | + ) ); |
|
| 1798 | + |
|
| 1799 | + |
|
| 1800 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1801 | + $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1802 | + |
|
| 1803 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1804 | + $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1805 | + $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1806 | + $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1807 | + |
|
| 1808 | + // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1809 | + $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1810 | + |
|
| 1811 | + // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1812 | + $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' ); |
|
| 1813 | + |
|
| 1814 | + // Hook the `admin_init` function to the Admin Setup. |
|
| 1815 | + $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1816 | + |
|
| 1817 | + // Hook the admin_init to the settings page. |
|
| 1818 | + $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1819 | + $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' ); |
|
| 1820 | + |
|
| 1821 | + $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' ); |
|
| 1822 | + |
|
| 1823 | + // Hook the menu creation on the general wordlift menu creation. |
|
| 1824 | + /** |
|
| 1825 | + * Filter: wl_feature__enable__screens. |
|
| 1826 | + * |
|
| 1827 | + * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1828 | + * |
|
| 1829 | + * @return bool |
|
| 1830 | + * @since 3.27.6 |
|
| 1831 | + * |
|
| 1832 | + * Since 3.30.0 this feature is registered using registry. |
|
| 1833 | + */ |
|
| 1834 | + add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 1835 | + if ( apply_filters( 'wl_feature__enable__settings-screen', true ) || Admin_User_Option::is_wordlift_admin() ) { |
|
| 1836 | + add_action( 'wl_admin_menu', array( $that->settings_page, 'admin_menu' ), 10, 2 ); |
|
| 1837 | + } |
|
| 1838 | + } ); |
|
| 1839 | + |
|
| 1840 | + // Hook key update. |
|
| 1841 | + $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1842 | + $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1843 | + |
|
| 1844 | + // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1845 | + $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1846 | + |
|
| 1847 | + /* |
|
| 1848 | 1848 | * Remove the Analytics Settings link from the plugin page. |
| 1849 | 1849 | * |
| 1850 | 1850 | * @see https://github.com/insideout10/wordlift-plugin/issues/932 |
| 1851 | 1851 | * @since 3.21.1 |
| 1852 | 1852 | */ |
| 1853 | - // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1854 | - |
|
| 1855 | - // Hook the AJAX `wl_publisher` action name. |
|
| 1856 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1857 | - |
|
| 1858 | - // Hook row actions for the entity type list admin. |
|
| 1859 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1860 | - |
|
| 1861 | - /** Ajax actions. */ |
|
| 1862 | - $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1863 | - |
|
| 1864 | - // Hook capabilities manipulation to allow access to entity type admin |
|
| 1865 | - // page on WordPress versions before 4.7. |
|
| 1866 | - global $wp_version; |
|
| 1867 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1868 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1869 | - } |
|
| 1870 | - |
|
| 1871 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1872 | - |
|
| 1873 | - /** Adapters. */ |
|
| 1874 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1875 | - /** |
|
| 1876 | - * Disabling Faq temporarily. |
|
| 1877 | - * Load the tinymce editor button on the tool bar. |
|
| 1878 | - * @since 3.26.0 |
|
| 1879 | - */ |
|
| 1880 | - //$this->loader->add_filter( 'tiny_mce_before_init', $this->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1881 | - //$this->loader->add_filter( 'mce_buttons', $this->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1882 | - //$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1883 | - |
|
| 1884 | - |
|
| 1885 | - $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' ); |
|
| 1886 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1887 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1888 | - /** |
|
| 1889 | - * @since 3.26.0 |
|
| 1890 | - */ |
|
| 1891 | - $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1892 | - $this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1893 | - // Adding Rest route for the post excerpt |
|
| 1894 | - Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1895 | - |
|
| 1896 | - $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 ); |
|
| 1897 | - $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 ); |
|
| 1898 | - |
|
| 1899 | - // Handle the autocomplete request. |
|
| 1900 | - add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1901 | - $this->autocomplete_adapter, |
|
| 1902 | - 'wl_autocomplete', |
|
| 1903 | - ) ); |
|
| 1904 | - add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1905 | - $this->autocomplete_adapter, |
|
| 1906 | - 'wl_autocomplete', |
|
| 1907 | - ) ); |
|
| 1908 | - |
|
| 1909 | - // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1910 | - if ( is_multisite() ) { |
|
| 1911 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1912 | - } |
|
| 1913 | - |
|
| 1914 | - $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service ); |
|
| 1915 | - |
|
| 1916 | - add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1917 | - add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1918 | - add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) ); |
|
| 1919 | - |
|
| 1920 | - /** |
|
| 1921 | - * Always allow the `wordlift/classification` block. |
|
| 1922 | - * |
|
| 1923 | - * @since 3.23.0 |
|
| 1924 | - */ |
|
| 1925 | - add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1926 | - |
|
| 1927 | - if ( true === $value ) { |
|
| 1928 | - return $value; |
|
| 1929 | - } |
|
| 1930 | - |
|
| 1931 | - return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1932 | - }, PHP_INT_MAX ); |
|
| 1933 | - |
|
| 1934 | - /** |
|
| 1935 | - * @since 3.27.7 |
|
| 1936 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 1937 | - */ |
|
| 1938 | - new Top_Entities(); |
|
| 1939 | - } |
|
| 1940 | - |
|
| 1941 | - /** |
|
| 1942 | - * Register all of the hooks related to the public-facing functionality |
|
| 1943 | - * of the plugin. |
|
| 1944 | - * |
|
| 1945 | - * @since 1.0.0 |
|
| 1946 | - * @access private |
|
| 1947 | - */ |
|
| 1948 | - private function define_public_hooks() { |
|
| 1949 | - |
|
| 1950 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1951 | - |
|
| 1952 | - // Register the entity post type. |
|
| 1953 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1954 | - |
|
| 1955 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 1956 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1957 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1958 | - // $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 1959 | - // $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 1960 | - |
|
| 1961 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1962 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1963 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' ); |
|
| 1964 | - |
|
| 1965 | - // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1966 | - $this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1967 | - // Hook the content filter service to add entity links. |
|
| 1968 | - if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1969 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1970 | - } |
|
| 1971 | - |
|
| 1972 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1973 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1974 | - |
|
| 1975 | - // Hook the ShareThis service. |
|
| 1976 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1977 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1978 | - |
|
| 1979 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1980 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1981 | - |
|
| 1982 | - // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1983 | - // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1984 | - // to categories. |
|
| 1985 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1986 | - |
|
| 1987 | - /* |
|
| 1853 | + // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1854 | + |
|
| 1855 | + // Hook the AJAX `wl_publisher` action name. |
|
| 1856 | + $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1857 | + |
|
| 1858 | + // Hook row actions for the entity type list admin. |
|
| 1859 | + $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1860 | + |
|
| 1861 | + /** Ajax actions. */ |
|
| 1862 | + $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1863 | + |
|
| 1864 | + // Hook capabilities manipulation to allow access to entity type admin |
|
| 1865 | + // page on WordPress versions before 4.7. |
|
| 1866 | + global $wp_version; |
|
| 1867 | + if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1868 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1869 | + } |
|
| 1870 | + |
|
| 1871 | + $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1872 | + |
|
| 1873 | + /** Adapters. */ |
|
| 1874 | + $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1875 | + /** |
|
| 1876 | + * Disabling Faq temporarily. |
|
| 1877 | + * Load the tinymce editor button on the tool bar. |
|
| 1878 | + * @since 3.26.0 |
|
| 1879 | + */ |
|
| 1880 | + //$this->loader->add_filter( 'tiny_mce_before_init', $this->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1881 | + //$this->loader->add_filter( 'mce_buttons', $this->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1882 | + //$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1883 | + |
|
| 1884 | + |
|
| 1885 | + $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' ); |
|
| 1886 | + $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1887 | + $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1888 | + /** |
|
| 1889 | + * @since 3.26.0 |
|
| 1890 | + */ |
|
| 1891 | + $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1892 | + $this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1893 | + // Adding Rest route for the post excerpt |
|
| 1894 | + Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1895 | + |
|
| 1896 | + $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 ); |
|
| 1897 | + $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 ); |
|
| 1898 | + |
|
| 1899 | + // Handle the autocomplete request. |
|
| 1900 | + add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1901 | + $this->autocomplete_adapter, |
|
| 1902 | + 'wl_autocomplete', |
|
| 1903 | + ) ); |
|
| 1904 | + add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1905 | + $this->autocomplete_adapter, |
|
| 1906 | + 'wl_autocomplete', |
|
| 1907 | + ) ); |
|
| 1908 | + |
|
| 1909 | + // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1910 | + if ( is_multisite() ) { |
|
| 1911 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1912 | + } |
|
| 1913 | + |
|
| 1914 | + $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service ); |
|
| 1915 | + |
|
| 1916 | + add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1917 | + add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1918 | + add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) ); |
|
| 1919 | + |
|
| 1920 | + /** |
|
| 1921 | + * Always allow the `wordlift/classification` block. |
|
| 1922 | + * |
|
| 1923 | + * @since 3.23.0 |
|
| 1924 | + */ |
|
| 1925 | + add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1926 | + |
|
| 1927 | + if ( true === $value ) { |
|
| 1928 | + return $value; |
|
| 1929 | + } |
|
| 1930 | + |
|
| 1931 | + return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1932 | + }, PHP_INT_MAX ); |
|
| 1933 | + |
|
| 1934 | + /** |
|
| 1935 | + * @since 3.27.7 |
|
| 1936 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 1937 | + */ |
|
| 1938 | + new Top_Entities(); |
|
| 1939 | + } |
|
| 1940 | + |
|
| 1941 | + /** |
|
| 1942 | + * Register all of the hooks related to the public-facing functionality |
|
| 1943 | + * of the plugin. |
|
| 1944 | + * |
|
| 1945 | + * @since 1.0.0 |
|
| 1946 | + * @access private |
|
| 1947 | + */ |
|
| 1948 | + private function define_public_hooks() { |
|
| 1949 | + |
|
| 1950 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1951 | + |
|
| 1952 | + // Register the entity post type. |
|
| 1953 | + $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1954 | + |
|
| 1955 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 1956 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1957 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1958 | + // $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 1959 | + // $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 1960 | + |
|
| 1961 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1962 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1963 | + $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' ); |
|
| 1964 | + |
|
| 1965 | + // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1966 | + $this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1967 | + // Hook the content filter service to add entity links. |
|
| 1968 | + if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1969 | + $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1970 | + } |
|
| 1971 | + |
|
| 1972 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1973 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1974 | + |
|
| 1975 | + // Hook the ShareThis service. |
|
| 1976 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1977 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1978 | + |
|
| 1979 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1980 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1981 | + |
|
| 1982 | + // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1983 | + // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1984 | + // to categories. |
|
| 1985 | + $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1986 | + |
|
| 1987 | + /* |
|
| 1988 | 1988 | * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service` |
| 1989 | 1989 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1990 | 1990 | * order of start time. |
| 1991 | 1991 | */ |
| 1992 | - $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1993 | - |
|
| 1994 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1995 | - |
|
| 1996 | - // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1997 | - $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1998 | - |
|
| 1999 | - // Analytics Script Frontend. |
|
| 2000 | - if ( $this->configuration_service->is_analytics_enable() ) { |
|
| 2001 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 2002 | - } |
|
| 2003 | - |
|
| 2004 | - } |
|
| 2005 | - |
|
| 2006 | - /** |
|
| 2007 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 2008 | - * |
|
| 2009 | - * @since 1.0.0 |
|
| 2010 | - */ |
|
| 2011 | - public function run() { |
|
| 2012 | - $this->loader->run(); |
|
| 2013 | - } |
|
| 2014 | - |
|
| 2015 | - /** |
|
| 2016 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 2017 | - * WordPress and to define internationalization functionality. |
|
| 2018 | - * |
|
| 2019 | - * @return string The name of the plugin. |
|
| 2020 | - * @since 1.0.0 |
|
| 2021 | - */ |
|
| 2022 | - public function get_plugin_name() { |
|
| 2023 | - return $this->plugin_name; |
|
| 2024 | - } |
|
| 2025 | - |
|
| 2026 | - /** |
|
| 2027 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 2028 | - * |
|
| 2029 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 2030 | - * @since 1.0.0 |
|
| 2031 | - */ |
|
| 2032 | - public function get_loader() { |
|
| 2033 | - return $this->loader; |
|
| 2034 | - } |
|
| 2035 | - |
|
| 2036 | - /** |
|
| 2037 | - * Retrieve the version number of the plugin. |
|
| 2038 | - * |
|
| 2039 | - * @return string The version number of the plugin. |
|
| 2040 | - * @since 1.0.0 |
|
| 2041 | - */ |
|
| 2042 | - public function get_version() { |
|
| 2043 | - return $this->version; |
|
| 2044 | - } |
|
| 2045 | - |
|
| 2046 | - /** |
|
| 2047 | - * Load dependencies for WP-CLI. |
|
| 2048 | - * |
|
| 2049 | - * @throws Exception |
|
| 2050 | - * @since 3.18.0 |
|
| 2051 | - */ |
|
| 2052 | - private function load_cli_dependencies() { |
|
| 2053 | - |
|
| 2054 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php'; |
|
| 2055 | - |
|
| 2056 | - $push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service ); |
|
| 2057 | - |
|
| 2058 | - WP_CLI::add_command( 'wl references push', $push_reference_data_command ); |
|
| 2059 | - |
|
| 2060 | - } |
|
| 2061 | - |
|
| 2062 | - /** |
|
| 2063 | - * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions. |
|
| 2064 | - * |
|
| 2065 | - * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance. |
|
| 2066 | - * @since 3.20.0 |
|
| 2067 | - */ |
|
| 2068 | - public function get_dashboard_service() { |
|
| 2069 | - |
|
| 2070 | - return $this->dashboard_service; |
|
| 2071 | - } |
|
| 2072 | - |
|
| 2073 | - public function add_wl_enabled_blocks() { |
|
| 2074 | - /** |
|
| 2075 | - * Filter: wl_feature__enable__blocks. |
|
| 2076 | - * |
|
| 2077 | - * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 2078 | - * |
|
| 2079 | - * @return bool |
|
| 2080 | - * @since 3.27.6 |
|
| 2081 | - */ |
|
| 2082 | - |
|
| 2083 | - wp_register_script( 'wl_enabled_blocks', false ); |
|
| 2084 | - |
|
| 2085 | - $enabled_blocks = array(); |
|
| 2086 | - |
|
| 2087 | - /** |
|
| 2088 | - * Filter name: wl_feature_enable__product_navigator |
|
| 2089 | - * @since 3.30.0 |
|
| 2090 | - */ |
|
| 2091 | - if ( apply_filters( 'wl_feature_enable__product-navigator', true ) ) { |
|
| 2092 | - $enabled_blocks[] = 'wordlift/products-navigator'; |
|
| 2093 | - } |
|
| 2094 | - |
|
| 2095 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 2096 | - // To intimate JS |
|
| 2097 | - $enabled_blocks = array_merge( $enabled_blocks, array( |
|
| 2098 | - 'wordlift/navigator', |
|
| 2099 | - 'wordlift/chord', |
|
| 2100 | - 'wordlift/geomap', |
|
| 2101 | - 'wordlift/timeline', |
|
| 2102 | - 'wordlift/cloud', |
|
| 2103 | - 'wordlift/vocabulary', |
|
| 2104 | - 'wordlift/faceted-search' |
|
| 2105 | - ) ); |
|
| 2106 | - } |
|
| 2107 | - |
|
| 2108 | - wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
| 2109 | - wp_enqueue_script( 'wl_enabled_blocks' ); |
|
| 2110 | - } |
|
| 2111 | - |
|
| 2112 | - /** |
|
| 2113 | - * Register screens based on the filter. |
|
| 2114 | - */ |
|
| 2115 | - public function register_screens() { |
|
| 2116 | - // Hook the menu to the Download Your Data page. |
|
| 2117 | - if ( apply_filters( 'wl_feature__enable__settings-download', true ) ) { |
|
| 2118 | - add_action( 'admin_menu', array( $this->download_your_data_page, 'admin_menu' ), 100, 0 ); |
|
| 2119 | - } |
|
| 2120 | - add_action( 'admin_menu', array( $this->status_page, 'admin_menu' ), 100, 0 ); |
|
| 2121 | - add_action( 'admin_menu', array( $this->entity_type_settings_admin_page, 'admin_menu' ), 100, 0 ); |
|
| 2122 | - |
|
| 2123 | - } |
|
| 1992 | + $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1993 | + |
|
| 1994 | + $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1995 | + |
|
| 1996 | + // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1997 | + $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1998 | + |
|
| 1999 | + // Analytics Script Frontend. |
|
| 2000 | + if ( $this->configuration_service->is_analytics_enable() ) { |
|
| 2001 | + $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 2002 | + } |
|
| 2003 | + |
|
| 2004 | + } |
|
| 2005 | + |
|
| 2006 | + /** |
|
| 2007 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 2008 | + * |
|
| 2009 | + * @since 1.0.0 |
|
| 2010 | + */ |
|
| 2011 | + public function run() { |
|
| 2012 | + $this->loader->run(); |
|
| 2013 | + } |
|
| 2014 | + |
|
| 2015 | + /** |
|
| 2016 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 2017 | + * WordPress and to define internationalization functionality. |
|
| 2018 | + * |
|
| 2019 | + * @return string The name of the plugin. |
|
| 2020 | + * @since 1.0.0 |
|
| 2021 | + */ |
|
| 2022 | + public function get_plugin_name() { |
|
| 2023 | + return $this->plugin_name; |
|
| 2024 | + } |
|
| 2025 | + |
|
| 2026 | + /** |
|
| 2027 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 2028 | + * |
|
| 2029 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 2030 | + * @since 1.0.0 |
|
| 2031 | + */ |
|
| 2032 | + public function get_loader() { |
|
| 2033 | + return $this->loader; |
|
| 2034 | + } |
|
| 2035 | + |
|
| 2036 | + /** |
|
| 2037 | + * Retrieve the version number of the plugin. |
|
| 2038 | + * |
|
| 2039 | + * @return string The version number of the plugin. |
|
| 2040 | + * @since 1.0.0 |
|
| 2041 | + */ |
|
| 2042 | + public function get_version() { |
|
| 2043 | + return $this->version; |
|
| 2044 | + } |
|
| 2045 | + |
|
| 2046 | + /** |
|
| 2047 | + * Load dependencies for WP-CLI. |
|
| 2048 | + * |
|
| 2049 | + * @throws Exception |
|
| 2050 | + * @since 3.18.0 |
|
| 2051 | + */ |
|
| 2052 | + private function load_cli_dependencies() { |
|
| 2053 | + |
|
| 2054 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php'; |
|
| 2055 | + |
|
| 2056 | + $push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service ); |
|
| 2057 | + |
|
| 2058 | + WP_CLI::add_command( 'wl references push', $push_reference_data_command ); |
|
| 2059 | + |
|
| 2060 | + } |
|
| 2061 | + |
|
| 2062 | + /** |
|
| 2063 | + * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions. |
|
| 2064 | + * |
|
| 2065 | + * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance. |
|
| 2066 | + * @since 3.20.0 |
|
| 2067 | + */ |
|
| 2068 | + public function get_dashboard_service() { |
|
| 2069 | + |
|
| 2070 | + return $this->dashboard_service; |
|
| 2071 | + } |
|
| 2072 | + |
|
| 2073 | + public function add_wl_enabled_blocks() { |
|
| 2074 | + /** |
|
| 2075 | + * Filter: wl_feature__enable__blocks. |
|
| 2076 | + * |
|
| 2077 | + * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 2078 | + * |
|
| 2079 | + * @return bool |
|
| 2080 | + * @since 3.27.6 |
|
| 2081 | + */ |
|
| 2082 | + |
|
| 2083 | + wp_register_script( 'wl_enabled_blocks', false ); |
|
| 2084 | + |
|
| 2085 | + $enabled_blocks = array(); |
|
| 2086 | + |
|
| 2087 | + /** |
|
| 2088 | + * Filter name: wl_feature_enable__product_navigator |
|
| 2089 | + * @since 3.30.0 |
|
| 2090 | + */ |
|
| 2091 | + if ( apply_filters( 'wl_feature_enable__product-navigator', true ) ) { |
|
| 2092 | + $enabled_blocks[] = 'wordlift/products-navigator'; |
|
| 2093 | + } |
|
| 2094 | + |
|
| 2095 | + if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 2096 | + // To intimate JS |
|
| 2097 | + $enabled_blocks = array_merge( $enabled_blocks, array( |
|
| 2098 | + 'wordlift/navigator', |
|
| 2099 | + 'wordlift/chord', |
|
| 2100 | + 'wordlift/geomap', |
|
| 2101 | + 'wordlift/timeline', |
|
| 2102 | + 'wordlift/cloud', |
|
| 2103 | + 'wordlift/vocabulary', |
|
| 2104 | + 'wordlift/faceted-search' |
|
| 2105 | + ) ); |
|
| 2106 | + } |
|
| 2107 | + |
|
| 2108 | + wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
| 2109 | + wp_enqueue_script( 'wl_enabled_blocks' ); |
|
| 2110 | + } |
|
| 2111 | + |
|
| 2112 | + /** |
|
| 2113 | + * Register screens based on the filter. |
|
| 2114 | + */ |
|
| 2115 | + public function register_screens() { |
|
| 2116 | + // Hook the menu to the Download Your Data page. |
|
| 2117 | + if ( apply_filters( 'wl_feature__enable__settings-download', true ) ) { |
|
| 2118 | + add_action( 'admin_menu', array( $this->download_your_data_page, 'admin_menu' ), 100, 0 ); |
|
| 2119 | + } |
|
| 2120 | + add_action( 'admin_menu', array( $this->status_page, 'admin_menu' ), 100, 0 ); |
|
| 2121 | + add_action( 'admin_menu', array( $this->entity_type_settings_admin_page, 'admin_menu' ), 100, 0 ); |
|
| 2122 | + |
|
| 2123 | + } |
|
| 2124 | 2124 | |
| 2125 | 2125 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use Wordlift\Api\Default_Api_Service; |
| 14 | 14 | |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -23,720 +23,720 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class Wordlift_Configuration_Service { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * The entity base path option name. |
|
| 28 | - * |
|
| 29 | - * @since 3.6.0 |
|
| 30 | - */ |
|
| 31 | - const ENTITY_BASE_PATH_KEY = 'wl_entity_base_path'; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * The skip wizard (admin installation wizard) option name. |
|
| 35 | - * |
|
| 36 | - * @since 3.9.0 |
|
| 37 | - */ |
|
| 38 | - const SKIP_WIZARD = 'wl_skip_wizard'; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * WordLift's key option name. |
|
| 42 | - * |
|
| 43 | - * @since 3.9.0 |
|
| 44 | - */ |
|
| 45 | - const KEY = 'key'; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * WordLift's configured language option name. |
|
| 49 | - * |
|
| 50 | - * @since 3.9.0 |
|
| 51 | - */ |
|
| 52 | - const LANGUAGE = 'site_language'; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * WordLift's configured country code. |
|
| 56 | - * |
|
| 57 | - * @since 3.18.0 |
|
| 58 | - */ |
|
| 59 | - const COUNTRY_CODE = 'country_code'; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * The publisher entity post ID option name. |
|
| 63 | - * |
|
| 64 | - * @since 3.9.0 |
|
| 65 | - */ |
|
| 66 | - const PUBLISHER_ID = 'publisher_id'; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * The dataset URI option name |
|
| 70 | - * |
|
| 71 | - * @since 3.10.0 |
|
| 72 | - */ |
|
| 73 | - const DATASET_URI = 'redlink_dataset_uri'; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * The link by default option name. |
|
| 77 | - * |
|
| 78 | - * @since 3.11.0 |
|
| 79 | - */ |
|
| 80 | - const LINK_BY_DEFAULT = 'link_by_default'; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * The analytics enable option. |
|
| 84 | - * |
|
| 85 | - * @since 3.21.0 |
|
| 86 | - */ |
|
| 87 | - const ANALYTICS_ENABLE = 'analytics_enable'; |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * The analytics entity uri dimension option. |
|
| 91 | - * |
|
| 92 | - * @since 3.21.0 |
|
| 93 | - */ |
|
| 94 | - const ANALYTICS_ENTITY_URI_DIMENSION = 'analytics_entity_uri_dimension'; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * The analytics entity type dimension option. |
|
| 98 | - * |
|
| 99 | - * @since 3.21.0 |
|
| 100 | - */ |
|
| 101 | - const ANALYTICS_ENTITY_TYPE_DIMENSION = 'analytics_entity_type_dimension'; |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * The user preferences about sharing data option. |
|
| 105 | - * |
|
| 106 | - * @since 3.19.0 |
|
| 107 | - */ |
|
| 108 | - const SEND_DIAGNOSTIC = 'send_diagnostic'; |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * The package type configuration key. |
|
| 112 | - * |
|
| 113 | - * @since 3.20.0 |
|
| 114 | - */ |
|
| 115 | - const PACKAGE_TYPE = 'package_type'; |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * The {@link Wordlift_Log_Service} instance. |
|
| 119 | - * |
|
| 120 | - * @since 3.16.0 |
|
| 121 | - * |
|
| 122 | - * @var \Wordlift_Log_Service $log The {@link Wordlift_Log_Service} instance. |
|
| 123 | - */ |
|
| 124 | - private $log; |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * The Wordlift_Configuration_Service's singleton instance. |
|
| 128 | - * |
|
| 129 | - * @since 3.6.0 |
|
| 130 | - * |
|
| 131 | - * @access private |
|
| 132 | - * @var \Wordlift_Configuration_Service $instance Wordlift_Configuration_Service's singleton instance. |
|
| 133 | - */ |
|
| 134 | - private static $instance; |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Create a Wordlift_Configuration_Service's instance. |
|
| 138 | - * |
|
| 139 | - * @since 3.6.0 |
|
| 140 | - */ |
|
| 141 | - public function __construct() { |
|
| 142 | - |
|
| 143 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 144 | - |
|
| 145 | - self::$instance = $this; |
|
| 146 | - |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Get the singleton instance. |
|
| 151 | - * |
|
| 152 | - * @return \Wordlift_Configuration_Service |
|
| 153 | - * @since 3.6.0 |
|
| 154 | - * |
|
| 155 | - */ |
|
| 156 | - public static function get_instance() { |
|
| 157 | - |
|
| 158 | - return self::$instance; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Get a configuration given the option name and a key. The option value is |
|
| 163 | - * expected to be an array. |
|
| 164 | - * |
|
| 165 | - * @param string $option The option name. |
|
| 166 | - * @param string $key A key in the option value array. |
|
| 167 | - * @param string $default The default value in case the key is not found (by default an empty string). |
|
| 168 | - * |
|
| 169 | - * @return mixed The configuration value or the default value if not found. |
|
| 170 | - * @since 3.6.0 |
|
| 171 | - * |
|
| 172 | - */ |
|
| 173 | - private function get( $option, $key, $default = '' ) { |
|
| 174 | - |
|
| 175 | - $options = get_option( $option, array() ); |
|
| 176 | - |
|
| 177 | - return isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * Set a configuration parameter. |
|
| 182 | - * |
|
| 183 | - * @param string $option Name of option to retrieve. Expected to not be SQL-escaped. |
|
| 184 | - * @param string $key The value key. |
|
| 185 | - * @param mixed $value The value. |
|
| 186 | - * |
|
| 187 | - * @since 3.9.0 |
|
| 188 | - * |
|
| 189 | - */ |
|
| 190 | - private function set( $option, $key, $value ) { |
|
| 191 | - |
|
| 192 | - $values = get_option( $option ); |
|
| 193 | - $values = isset( $values ) ? $values : array(); |
|
| 194 | - $values[ $key ] = $value; |
|
| 195 | - update_option( $option, $values ); |
|
| 196 | - |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * Get the entity base path, by default 'entity'. |
|
| 201 | - * |
|
| 202 | - * @return string The entity base path. |
|
| 203 | - * @since 3.6.0 |
|
| 204 | - * |
|
| 205 | - */ |
|
| 206 | - public function get_entity_base_path() { |
|
| 207 | - |
|
| 208 | - return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' ); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * Get the entity base path. |
|
| 213 | - * |
|
| 214 | - * @param string $value The entity base path. |
|
| 215 | - * |
|
| 216 | - * @since 3.9.0 |
|
| 217 | - * |
|
| 218 | - */ |
|
| 219 | - public function set_entity_base_path( $value ) { |
|
| 220 | - |
|
| 221 | - $this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value ); |
|
| 222 | - |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * Whether the installation skip wizard should be skipped. |
|
| 227 | - * |
|
| 228 | - * @return bool True if it should be skipped otherwise false. |
|
| 229 | - * @since 3.9.0 |
|
| 230 | - * |
|
| 231 | - */ |
|
| 232 | - public function is_skip_wizard() { |
|
| 233 | - |
|
| 234 | - return $this->get( 'wl_general_settings', self::SKIP_WIZARD, false ); |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Set the skip wizard parameter. |
|
| 239 | - * |
|
| 240 | - * @param bool $value True to skip the wizard. We expect a boolean value. |
|
| 241 | - * |
|
| 242 | - * @since 3.9.0 |
|
| 243 | - * |
|
| 244 | - */ |
|
| 245 | - public function set_skip_wizard( $value ) { |
|
| 246 | - |
|
| 247 | - $this->set( 'wl_general_settings', self::SKIP_WIZARD, true === $value ); |
|
| 248 | - |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * Get WordLift's key. |
|
| 253 | - * |
|
| 254 | - * @return string WordLift's key or an empty string if not set. |
|
| 255 | - * @since 3.9.0 |
|
| 256 | - * |
|
| 257 | - */ |
|
| 258 | - public function get_key() { |
|
| 259 | - |
|
| 260 | - return $this->get( 'wl_general_settings', self::KEY, '' ); |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * Set WordLift's key. |
|
| 265 | - * |
|
| 266 | - * @param string $value WordLift's key. |
|
| 267 | - * |
|
| 268 | - * @since 3.9.0 |
|
| 269 | - * |
|
| 270 | - */ |
|
| 271 | - public function set_key( $value ) { |
|
| 272 | - |
|
| 273 | - $this->set( 'wl_general_settings', self::KEY, $value ); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * Get WordLift's configured language, by default 'en'. |
|
| 278 | - * |
|
| 279 | - * Note that WordLift's language is used when writing strings to the Linked Data dataset, not for the analysis. |
|
| 280 | - * |
|
| 281 | - * @return string WordLift's configured language code ('en' by default). |
|
| 282 | - * @since 3.9.0 |
|
| 283 | - * |
|
| 284 | - */ |
|
| 285 | - public function get_language_code() { |
|
| 286 | - |
|
| 287 | - return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' ); |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * Set WordLift's language code, used when storing strings to the Linked Data dataset. |
|
| 292 | - * |
|
| 293 | - * @param string $value WordLift's language code. |
|
| 294 | - * |
|
| 295 | - * @since 3.9.0 |
|
| 296 | - * |
|
| 297 | - */ |
|
| 298 | - public function set_language_code( $value ) { |
|
| 299 | - |
|
| 300 | - $this->set( 'wl_general_settings', self::LANGUAGE, $value ); |
|
| 301 | - |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Set the user preferences about sharing diagnostic with us. |
|
| 306 | - * |
|
| 307 | - * @param string $value The user preferences(yes/no). |
|
| 308 | - * |
|
| 309 | - * @since 3.19.0 |
|
| 310 | - * |
|
| 311 | - */ |
|
| 312 | - public function set_diagnostic_preferences( $value ) { |
|
| 313 | - |
|
| 314 | - $this->set( 'wl_general_settings', self::SEND_DIAGNOSTIC, $value ); |
|
| 315 | - |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * Get the user preferences about sharing diagnostic. |
|
| 320 | - * |
|
| 321 | - * @since 3.19.0 |
|
| 322 | - */ |
|
| 323 | - public function get_diagnostic_preferences() { |
|
| 324 | - |
|
| 325 | - return $this->get( 'wl_general_settings', self::SEND_DIAGNOSTIC, 'no' ); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * Get WordLift's configured country code, by default 'us'. |
|
| 330 | - * |
|
| 331 | - * @return string WordLift's configured country code ('us' by default). |
|
| 332 | - * @since 3.18.0 |
|
| 333 | - * |
|
| 334 | - */ |
|
| 335 | - public function get_country_code() { |
|
| 336 | - |
|
| 337 | - return $this->get( 'wl_general_settings', self::COUNTRY_CODE, 'us' ); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * Set WordLift's country code. |
|
| 342 | - * |
|
| 343 | - * @param string $value WordLift's country code. |
|
| 344 | - * |
|
| 345 | - * @since 3.18.0 |
|
| 346 | - * |
|
| 347 | - */ |
|
| 348 | - public function set_country_code( $value ) { |
|
| 349 | - |
|
| 350 | - $this->set( 'wl_general_settings', self::COUNTRY_CODE, $value ); |
|
| 351 | - |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - /** |
|
| 355 | - * Get the publisher entity post id. |
|
| 356 | - * |
|
| 357 | - * The publisher entity post id points to an entity post which contains the data for the publisher used in schema.org |
|
| 358 | - * Article markup. |
|
| 359 | - * |
|
| 360 | - * @return int|NULL The publisher entity post id or NULL if not set. |
|
| 361 | - * @since 3.9.0 |
|
| 362 | - * |
|
| 363 | - */ |
|
| 364 | - public function get_publisher_id() { |
|
| 365 | - |
|
| 366 | - return $this->get( 'wl_general_settings', self::PUBLISHER_ID, null ); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * Set the publisher entity post id. |
|
| 371 | - * |
|
| 372 | - * @param int $value The publisher entity post id. |
|
| 373 | - * |
|
| 374 | - * @since 3.9.0 |
|
| 375 | - * |
|
| 376 | - */ |
|
| 377 | - public function set_publisher_id( $value ) { |
|
| 378 | - |
|
| 379 | - $this->set( 'wl_general_settings', self::PUBLISHER_ID, $value ); |
|
| 380 | - |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - /** |
|
| 384 | - * Get the dataset URI. |
|
| 385 | - * |
|
| 386 | - * @return string The dataset URI or an empty string if not set. |
|
| 387 | - * @since 3.10.0 |
|
| 388 | - * @since 3.27.7 Always return null if `wl_features__enable__dataset` is disabled. |
|
| 389 | - * |
|
| 390 | - */ |
|
| 391 | - public function get_dataset_uri() { |
|
| 392 | - |
|
| 393 | - if ( apply_filters( 'wl_features__enable__dataset', true ) ) { |
|
| 394 | - return $this->get( 'wl_advanced_settings', self::DATASET_URI, null ); |
|
| 395 | - } else { |
|
| 396 | - return null; |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * Set the dataset URI. |
|
| 402 | - * |
|
| 403 | - * @param string $value The dataset URI. |
|
| 404 | - * |
|
| 405 | - * @since 3.10.0 |
|
| 406 | - * |
|
| 407 | - */ |
|
| 408 | - public function set_dataset_uri( $value ) { |
|
| 409 | - |
|
| 410 | - $this->set( 'wl_advanced_settings', self::DATASET_URI, $value ); |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * Get the package type. |
|
| 415 | - * |
|
| 416 | - * @return string The package type or an empty string if not set. |
|
| 417 | - * @since 3.20.0 |
|
| 418 | - * |
|
| 419 | - */ |
|
| 420 | - public function get_package_type() { |
|
| 421 | - |
|
| 422 | - return $this->get( 'wl_advanced_settings', self::PACKAGE_TYPE, null ); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * Set the package type. |
|
| 427 | - * |
|
| 428 | - * @param string $value The package type. |
|
| 429 | - * |
|
| 430 | - * @since 3.20.0 |
|
| 431 | - * |
|
| 432 | - */ |
|
| 433 | - public function set_package_type( $value ) { |
|
| 434 | - $this->set( 'wl_advanced_settings', self::PACKAGE_TYPE, $value ); |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - /** |
|
| 438 | - * Intercept the change of the WordLift key in order to set the dataset URI. |
|
| 439 | - * |
|
| 440 | - * |
|
| 441 | - * @since 3.20.0 as of #761, we save settings every time a key is set, not only when the key changes, so to |
|
| 442 | - * store the configuration parameters such as country or language. |
|
| 443 | - * @since 3.11.0 |
|
| 444 | - * |
|
| 445 | - * @see https://github.com/insideout10/wordlift-plugin/issues/761 |
|
| 446 | - * |
|
| 447 | - * @param array $old_value The old settings. |
|
| 448 | - * @param array $new_value The new settings. |
|
| 449 | - */ |
|
| 450 | - public function update_key( $old_value, $new_value ) { |
|
| 451 | - |
|
| 452 | - // Check the old key value and the new one. We're going to ask for the dataset URI only if the key has changed. |
|
| 453 | - // $old_key = isset( $old_value['key'] ) ? $old_value['key'] : ''; |
|
| 454 | - $new_key = isset( $new_value['key'] ) ? $new_value['key'] : ''; |
|
| 455 | - |
|
| 456 | - // If the key hasn't changed, don't do anything. |
|
| 457 | - // WARN The 'update_option' hook is fired only if the new and old value are not equal. |
|
| 458 | - // if ( $old_key === $new_key ) { |
|
| 459 | - // return; |
|
| 460 | - // } |
|
| 461 | - |
|
| 462 | - // If the key is empty, empty the dataset URI. |
|
| 463 | - if ( '' === $new_key ) { |
|
| 464 | - $this->set_dataset_uri( '' ); |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - // make the request to the remote server. |
|
| 468 | - $this->get_remote_dataset_uri( $new_key ); |
|
| 469 | - |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - /** |
|
| 473 | - * Handle retrieving the dataset uri from the remote server. |
|
| 474 | - * |
|
| 475 | - * If a valid dataset uri is returned it is stored in the appropriate option, |
|
| 476 | - * otherwise the option is set to empty string. |
|
| 477 | - * |
|
| 478 | - * @param string $key The key to be used. |
|
| 479 | - * |
|
| 480 | - * @since 3.12.0 |
|
| 481 | - * |
|
| 482 | - * @since 3.17.0 send the site URL and get the dataset URI. |
|
| 483 | - */ |
|
| 484 | - public function get_remote_dataset_uri( $key ) { |
|
| 485 | - |
|
| 486 | - $this->log->trace( 'Getting the remote dataset URI and package type...' ); |
|
| 487 | - |
|
| 488 | - if ( empty( $key ) ) { |
|
| 489 | - $this->log->warn( 'Key set to empty value.' ); |
|
| 490 | - |
|
| 491 | - $this->set_dataset_uri( '' ); |
|
| 492 | - $this->set_package_type( null ); |
|
| 493 | - |
|
| 494 | - return; |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - /** |
|
| 498 | - * Allow 3rd parties to change the site_url. |
|
| 499 | - * |
|
| 500 | - * @param string $site_url The site url. |
|
| 501 | - * |
|
| 502 | - * @see https://github.com/insideout10/wordlift-plugin/issues/850 |
|
| 503 | - * |
|
| 504 | - * @since 3.20.0 |
|
| 505 | - * |
|
| 506 | - */ |
|
| 507 | - $home_url = get_option( 'home' ); |
|
| 508 | - $site_url = apply_filters( 'wl_production_site_url', untrailingslashit( $home_url ) ); |
|
| 509 | - |
|
| 510 | - // Build the URL. |
|
| 511 | - $url = '/accounts' |
|
| 512 | - . '?key=' . rawurlencode( $key ) |
|
| 513 | - . '&url=' . rawurlencode( $site_url ) |
|
| 514 | - . '&country=' . $this->get_country_code() |
|
| 515 | - . '&language=' . $this->get_language_code(); |
|
| 516 | - |
|
| 517 | - $api_service = Default_Api_Service::get_instance(); |
|
| 518 | - /** |
|
| 519 | - * @since 3.27.7.1 |
|
| 520 | - * The Key should be passed to headers, otherwise api would return null. |
|
| 521 | - */ |
|
| 522 | - $headers = array( |
|
| 523 | - 'Authorization' => "Key $key", |
|
| 524 | - ); |
|
| 525 | - $response = $api_service->request( 'PUT', $url, $headers )->get_response(); |
|
| 526 | - |
|
| 527 | - // The response is an error. |
|
| 528 | - if ( is_wp_error( $response ) ) { |
|
| 529 | - $this->log->error( 'An error occurred setting the dataset URI: ' . $response->get_error_message() ); |
|
| 530 | - |
|
| 531 | - $this->set_dataset_uri( '' ); |
|
| 532 | - $this->set_package_type( null ); |
|
| 533 | - |
|
| 534 | - return; |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - // The response is not OK. |
|
| 538 | - if ( ! is_array( $response ) || 200 !== (int) $response['response']['code'] ) { |
|
| 539 | - $base_url = $api_service->get_base_url(); |
|
| 540 | - |
|
| 541 | - if ( ! is_array( $response ) ) { |
|
| 542 | - $this->log->error( "Unexpected response when opening URL $base_url$url: " . var_export( $response, true ) ); |
|
| 543 | - } else { |
|
| 544 | - $this->log->error( "Unexpected status code when opening URL $base_url$url: " . $response['response']['code'] . "\n" . var_export( $response, true ) ); |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - |
|
| 548 | - $this->set_dataset_uri( '' ); |
|
| 549 | - $this->set_package_type( null ); |
|
| 550 | - |
|
| 551 | - return; |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - /* |
|
| 26 | + /** |
|
| 27 | + * The entity base path option name. |
|
| 28 | + * |
|
| 29 | + * @since 3.6.0 |
|
| 30 | + */ |
|
| 31 | + const ENTITY_BASE_PATH_KEY = 'wl_entity_base_path'; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * The skip wizard (admin installation wizard) option name. |
|
| 35 | + * |
|
| 36 | + * @since 3.9.0 |
|
| 37 | + */ |
|
| 38 | + const SKIP_WIZARD = 'wl_skip_wizard'; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * WordLift's key option name. |
|
| 42 | + * |
|
| 43 | + * @since 3.9.0 |
|
| 44 | + */ |
|
| 45 | + const KEY = 'key'; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * WordLift's configured language option name. |
|
| 49 | + * |
|
| 50 | + * @since 3.9.0 |
|
| 51 | + */ |
|
| 52 | + const LANGUAGE = 'site_language'; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * WordLift's configured country code. |
|
| 56 | + * |
|
| 57 | + * @since 3.18.0 |
|
| 58 | + */ |
|
| 59 | + const COUNTRY_CODE = 'country_code'; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * The publisher entity post ID option name. |
|
| 63 | + * |
|
| 64 | + * @since 3.9.0 |
|
| 65 | + */ |
|
| 66 | + const PUBLISHER_ID = 'publisher_id'; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * The dataset URI option name |
|
| 70 | + * |
|
| 71 | + * @since 3.10.0 |
|
| 72 | + */ |
|
| 73 | + const DATASET_URI = 'redlink_dataset_uri'; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * The link by default option name. |
|
| 77 | + * |
|
| 78 | + * @since 3.11.0 |
|
| 79 | + */ |
|
| 80 | + const LINK_BY_DEFAULT = 'link_by_default'; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * The analytics enable option. |
|
| 84 | + * |
|
| 85 | + * @since 3.21.0 |
|
| 86 | + */ |
|
| 87 | + const ANALYTICS_ENABLE = 'analytics_enable'; |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * The analytics entity uri dimension option. |
|
| 91 | + * |
|
| 92 | + * @since 3.21.0 |
|
| 93 | + */ |
|
| 94 | + const ANALYTICS_ENTITY_URI_DIMENSION = 'analytics_entity_uri_dimension'; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * The analytics entity type dimension option. |
|
| 98 | + * |
|
| 99 | + * @since 3.21.0 |
|
| 100 | + */ |
|
| 101 | + const ANALYTICS_ENTITY_TYPE_DIMENSION = 'analytics_entity_type_dimension'; |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * The user preferences about sharing data option. |
|
| 105 | + * |
|
| 106 | + * @since 3.19.0 |
|
| 107 | + */ |
|
| 108 | + const SEND_DIAGNOSTIC = 'send_diagnostic'; |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * The package type configuration key. |
|
| 112 | + * |
|
| 113 | + * @since 3.20.0 |
|
| 114 | + */ |
|
| 115 | + const PACKAGE_TYPE = 'package_type'; |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * The {@link Wordlift_Log_Service} instance. |
|
| 119 | + * |
|
| 120 | + * @since 3.16.0 |
|
| 121 | + * |
|
| 122 | + * @var \Wordlift_Log_Service $log The {@link Wordlift_Log_Service} instance. |
|
| 123 | + */ |
|
| 124 | + private $log; |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * The Wordlift_Configuration_Service's singleton instance. |
|
| 128 | + * |
|
| 129 | + * @since 3.6.0 |
|
| 130 | + * |
|
| 131 | + * @access private |
|
| 132 | + * @var \Wordlift_Configuration_Service $instance Wordlift_Configuration_Service's singleton instance. |
|
| 133 | + */ |
|
| 134 | + private static $instance; |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Create a Wordlift_Configuration_Service's instance. |
|
| 138 | + * |
|
| 139 | + * @since 3.6.0 |
|
| 140 | + */ |
|
| 141 | + public function __construct() { |
|
| 142 | + |
|
| 143 | + $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 144 | + |
|
| 145 | + self::$instance = $this; |
|
| 146 | + |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Get the singleton instance. |
|
| 151 | + * |
|
| 152 | + * @return \Wordlift_Configuration_Service |
|
| 153 | + * @since 3.6.0 |
|
| 154 | + * |
|
| 155 | + */ |
|
| 156 | + public static function get_instance() { |
|
| 157 | + |
|
| 158 | + return self::$instance; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Get a configuration given the option name and a key. The option value is |
|
| 163 | + * expected to be an array. |
|
| 164 | + * |
|
| 165 | + * @param string $option The option name. |
|
| 166 | + * @param string $key A key in the option value array. |
|
| 167 | + * @param string $default The default value in case the key is not found (by default an empty string). |
|
| 168 | + * |
|
| 169 | + * @return mixed The configuration value or the default value if not found. |
|
| 170 | + * @since 3.6.0 |
|
| 171 | + * |
|
| 172 | + */ |
|
| 173 | + private function get( $option, $key, $default = '' ) { |
|
| 174 | + |
|
| 175 | + $options = get_option( $option, array() ); |
|
| 176 | + |
|
| 177 | + return isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * Set a configuration parameter. |
|
| 182 | + * |
|
| 183 | + * @param string $option Name of option to retrieve. Expected to not be SQL-escaped. |
|
| 184 | + * @param string $key The value key. |
|
| 185 | + * @param mixed $value The value. |
|
| 186 | + * |
|
| 187 | + * @since 3.9.0 |
|
| 188 | + * |
|
| 189 | + */ |
|
| 190 | + private function set( $option, $key, $value ) { |
|
| 191 | + |
|
| 192 | + $values = get_option( $option ); |
|
| 193 | + $values = isset( $values ) ? $values : array(); |
|
| 194 | + $values[ $key ] = $value; |
|
| 195 | + update_option( $option, $values ); |
|
| 196 | + |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * Get the entity base path, by default 'entity'. |
|
| 201 | + * |
|
| 202 | + * @return string The entity base path. |
|
| 203 | + * @since 3.6.0 |
|
| 204 | + * |
|
| 205 | + */ |
|
| 206 | + public function get_entity_base_path() { |
|
| 207 | + |
|
| 208 | + return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' ); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * Get the entity base path. |
|
| 213 | + * |
|
| 214 | + * @param string $value The entity base path. |
|
| 215 | + * |
|
| 216 | + * @since 3.9.0 |
|
| 217 | + * |
|
| 218 | + */ |
|
| 219 | + public function set_entity_base_path( $value ) { |
|
| 220 | + |
|
| 221 | + $this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value ); |
|
| 222 | + |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * Whether the installation skip wizard should be skipped. |
|
| 227 | + * |
|
| 228 | + * @return bool True if it should be skipped otherwise false. |
|
| 229 | + * @since 3.9.0 |
|
| 230 | + * |
|
| 231 | + */ |
|
| 232 | + public function is_skip_wizard() { |
|
| 233 | + |
|
| 234 | + return $this->get( 'wl_general_settings', self::SKIP_WIZARD, false ); |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Set the skip wizard parameter. |
|
| 239 | + * |
|
| 240 | + * @param bool $value True to skip the wizard. We expect a boolean value. |
|
| 241 | + * |
|
| 242 | + * @since 3.9.0 |
|
| 243 | + * |
|
| 244 | + */ |
|
| 245 | + public function set_skip_wizard( $value ) { |
|
| 246 | + |
|
| 247 | + $this->set( 'wl_general_settings', self::SKIP_WIZARD, true === $value ); |
|
| 248 | + |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * Get WordLift's key. |
|
| 253 | + * |
|
| 254 | + * @return string WordLift's key or an empty string if not set. |
|
| 255 | + * @since 3.9.0 |
|
| 256 | + * |
|
| 257 | + */ |
|
| 258 | + public function get_key() { |
|
| 259 | + |
|
| 260 | + return $this->get( 'wl_general_settings', self::KEY, '' ); |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * Set WordLift's key. |
|
| 265 | + * |
|
| 266 | + * @param string $value WordLift's key. |
|
| 267 | + * |
|
| 268 | + * @since 3.9.0 |
|
| 269 | + * |
|
| 270 | + */ |
|
| 271 | + public function set_key( $value ) { |
|
| 272 | + |
|
| 273 | + $this->set( 'wl_general_settings', self::KEY, $value ); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * Get WordLift's configured language, by default 'en'. |
|
| 278 | + * |
|
| 279 | + * Note that WordLift's language is used when writing strings to the Linked Data dataset, not for the analysis. |
|
| 280 | + * |
|
| 281 | + * @return string WordLift's configured language code ('en' by default). |
|
| 282 | + * @since 3.9.0 |
|
| 283 | + * |
|
| 284 | + */ |
|
| 285 | + public function get_language_code() { |
|
| 286 | + |
|
| 287 | + return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' ); |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * Set WordLift's language code, used when storing strings to the Linked Data dataset. |
|
| 292 | + * |
|
| 293 | + * @param string $value WordLift's language code. |
|
| 294 | + * |
|
| 295 | + * @since 3.9.0 |
|
| 296 | + * |
|
| 297 | + */ |
|
| 298 | + public function set_language_code( $value ) { |
|
| 299 | + |
|
| 300 | + $this->set( 'wl_general_settings', self::LANGUAGE, $value ); |
|
| 301 | + |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * Set the user preferences about sharing diagnostic with us. |
|
| 306 | + * |
|
| 307 | + * @param string $value The user preferences(yes/no). |
|
| 308 | + * |
|
| 309 | + * @since 3.19.0 |
|
| 310 | + * |
|
| 311 | + */ |
|
| 312 | + public function set_diagnostic_preferences( $value ) { |
|
| 313 | + |
|
| 314 | + $this->set( 'wl_general_settings', self::SEND_DIAGNOSTIC, $value ); |
|
| 315 | + |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * Get the user preferences about sharing diagnostic. |
|
| 320 | + * |
|
| 321 | + * @since 3.19.0 |
|
| 322 | + */ |
|
| 323 | + public function get_diagnostic_preferences() { |
|
| 324 | + |
|
| 325 | + return $this->get( 'wl_general_settings', self::SEND_DIAGNOSTIC, 'no' ); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * Get WordLift's configured country code, by default 'us'. |
|
| 330 | + * |
|
| 331 | + * @return string WordLift's configured country code ('us' by default). |
|
| 332 | + * @since 3.18.0 |
|
| 333 | + * |
|
| 334 | + */ |
|
| 335 | + public function get_country_code() { |
|
| 336 | + |
|
| 337 | + return $this->get( 'wl_general_settings', self::COUNTRY_CODE, 'us' ); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * Set WordLift's country code. |
|
| 342 | + * |
|
| 343 | + * @param string $value WordLift's country code. |
|
| 344 | + * |
|
| 345 | + * @since 3.18.0 |
|
| 346 | + * |
|
| 347 | + */ |
|
| 348 | + public function set_country_code( $value ) { |
|
| 349 | + |
|
| 350 | + $this->set( 'wl_general_settings', self::COUNTRY_CODE, $value ); |
|
| 351 | + |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + /** |
|
| 355 | + * Get the publisher entity post id. |
|
| 356 | + * |
|
| 357 | + * The publisher entity post id points to an entity post which contains the data for the publisher used in schema.org |
|
| 358 | + * Article markup. |
|
| 359 | + * |
|
| 360 | + * @return int|NULL The publisher entity post id or NULL if not set. |
|
| 361 | + * @since 3.9.0 |
|
| 362 | + * |
|
| 363 | + */ |
|
| 364 | + public function get_publisher_id() { |
|
| 365 | + |
|
| 366 | + return $this->get( 'wl_general_settings', self::PUBLISHER_ID, null ); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * Set the publisher entity post id. |
|
| 371 | + * |
|
| 372 | + * @param int $value The publisher entity post id. |
|
| 373 | + * |
|
| 374 | + * @since 3.9.0 |
|
| 375 | + * |
|
| 376 | + */ |
|
| 377 | + public function set_publisher_id( $value ) { |
|
| 378 | + |
|
| 379 | + $this->set( 'wl_general_settings', self::PUBLISHER_ID, $value ); |
|
| 380 | + |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + /** |
|
| 384 | + * Get the dataset URI. |
|
| 385 | + * |
|
| 386 | + * @return string The dataset URI or an empty string if not set. |
|
| 387 | + * @since 3.10.0 |
|
| 388 | + * @since 3.27.7 Always return null if `wl_features__enable__dataset` is disabled. |
|
| 389 | + * |
|
| 390 | + */ |
|
| 391 | + public function get_dataset_uri() { |
|
| 392 | + |
|
| 393 | + if ( apply_filters( 'wl_features__enable__dataset', true ) ) { |
|
| 394 | + return $this->get( 'wl_advanced_settings', self::DATASET_URI, null ); |
|
| 395 | + } else { |
|
| 396 | + return null; |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * Set the dataset URI. |
|
| 402 | + * |
|
| 403 | + * @param string $value The dataset URI. |
|
| 404 | + * |
|
| 405 | + * @since 3.10.0 |
|
| 406 | + * |
|
| 407 | + */ |
|
| 408 | + public function set_dataset_uri( $value ) { |
|
| 409 | + |
|
| 410 | + $this->set( 'wl_advanced_settings', self::DATASET_URI, $value ); |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * Get the package type. |
|
| 415 | + * |
|
| 416 | + * @return string The package type or an empty string if not set. |
|
| 417 | + * @since 3.20.0 |
|
| 418 | + * |
|
| 419 | + */ |
|
| 420 | + public function get_package_type() { |
|
| 421 | + |
|
| 422 | + return $this->get( 'wl_advanced_settings', self::PACKAGE_TYPE, null ); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * Set the package type. |
|
| 427 | + * |
|
| 428 | + * @param string $value The package type. |
|
| 429 | + * |
|
| 430 | + * @since 3.20.0 |
|
| 431 | + * |
|
| 432 | + */ |
|
| 433 | + public function set_package_type( $value ) { |
|
| 434 | + $this->set( 'wl_advanced_settings', self::PACKAGE_TYPE, $value ); |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + /** |
|
| 438 | + * Intercept the change of the WordLift key in order to set the dataset URI. |
|
| 439 | + * |
|
| 440 | + * |
|
| 441 | + * @since 3.20.0 as of #761, we save settings every time a key is set, not only when the key changes, so to |
|
| 442 | + * store the configuration parameters such as country or language. |
|
| 443 | + * @since 3.11.0 |
|
| 444 | + * |
|
| 445 | + * @see https://github.com/insideout10/wordlift-plugin/issues/761 |
|
| 446 | + * |
|
| 447 | + * @param array $old_value The old settings. |
|
| 448 | + * @param array $new_value The new settings. |
|
| 449 | + */ |
|
| 450 | + public function update_key( $old_value, $new_value ) { |
|
| 451 | + |
|
| 452 | + // Check the old key value and the new one. We're going to ask for the dataset URI only if the key has changed. |
|
| 453 | + // $old_key = isset( $old_value['key'] ) ? $old_value['key'] : ''; |
|
| 454 | + $new_key = isset( $new_value['key'] ) ? $new_value['key'] : ''; |
|
| 455 | + |
|
| 456 | + // If the key hasn't changed, don't do anything. |
|
| 457 | + // WARN The 'update_option' hook is fired only if the new and old value are not equal. |
|
| 458 | + // if ( $old_key === $new_key ) { |
|
| 459 | + // return; |
|
| 460 | + // } |
|
| 461 | + |
|
| 462 | + // If the key is empty, empty the dataset URI. |
|
| 463 | + if ( '' === $new_key ) { |
|
| 464 | + $this->set_dataset_uri( '' ); |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + // make the request to the remote server. |
|
| 468 | + $this->get_remote_dataset_uri( $new_key ); |
|
| 469 | + |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + /** |
|
| 473 | + * Handle retrieving the dataset uri from the remote server. |
|
| 474 | + * |
|
| 475 | + * If a valid dataset uri is returned it is stored in the appropriate option, |
|
| 476 | + * otherwise the option is set to empty string. |
|
| 477 | + * |
|
| 478 | + * @param string $key The key to be used. |
|
| 479 | + * |
|
| 480 | + * @since 3.12.0 |
|
| 481 | + * |
|
| 482 | + * @since 3.17.0 send the site URL and get the dataset URI. |
|
| 483 | + */ |
|
| 484 | + public function get_remote_dataset_uri( $key ) { |
|
| 485 | + |
|
| 486 | + $this->log->trace( 'Getting the remote dataset URI and package type...' ); |
|
| 487 | + |
|
| 488 | + if ( empty( $key ) ) { |
|
| 489 | + $this->log->warn( 'Key set to empty value.' ); |
|
| 490 | + |
|
| 491 | + $this->set_dataset_uri( '' ); |
|
| 492 | + $this->set_package_type( null ); |
|
| 493 | + |
|
| 494 | + return; |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + /** |
|
| 498 | + * Allow 3rd parties to change the site_url. |
|
| 499 | + * |
|
| 500 | + * @param string $site_url The site url. |
|
| 501 | + * |
|
| 502 | + * @see https://github.com/insideout10/wordlift-plugin/issues/850 |
|
| 503 | + * |
|
| 504 | + * @since 3.20.0 |
|
| 505 | + * |
|
| 506 | + */ |
|
| 507 | + $home_url = get_option( 'home' ); |
|
| 508 | + $site_url = apply_filters( 'wl_production_site_url', untrailingslashit( $home_url ) ); |
|
| 509 | + |
|
| 510 | + // Build the URL. |
|
| 511 | + $url = '/accounts' |
|
| 512 | + . '?key=' . rawurlencode( $key ) |
|
| 513 | + . '&url=' . rawurlencode( $site_url ) |
|
| 514 | + . '&country=' . $this->get_country_code() |
|
| 515 | + . '&language=' . $this->get_language_code(); |
|
| 516 | + |
|
| 517 | + $api_service = Default_Api_Service::get_instance(); |
|
| 518 | + /** |
|
| 519 | + * @since 3.27.7.1 |
|
| 520 | + * The Key should be passed to headers, otherwise api would return null. |
|
| 521 | + */ |
|
| 522 | + $headers = array( |
|
| 523 | + 'Authorization' => "Key $key", |
|
| 524 | + ); |
|
| 525 | + $response = $api_service->request( 'PUT', $url, $headers )->get_response(); |
|
| 526 | + |
|
| 527 | + // The response is an error. |
|
| 528 | + if ( is_wp_error( $response ) ) { |
|
| 529 | + $this->log->error( 'An error occurred setting the dataset URI: ' . $response->get_error_message() ); |
|
| 530 | + |
|
| 531 | + $this->set_dataset_uri( '' ); |
|
| 532 | + $this->set_package_type( null ); |
|
| 533 | + |
|
| 534 | + return; |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + // The response is not OK. |
|
| 538 | + if ( ! is_array( $response ) || 200 !== (int) $response['response']['code'] ) { |
|
| 539 | + $base_url = $api_service->get_base_url(); |
|
| 540 | + |
|
| 541 | + if ( ! is_array( $response ) ) { |
|
| 542 | + $this->log->error( "Unexpected response when opening URL $base_url$url: " . var_export( $response, true ) ); |
|
| 543 | + } else { |
|
| 544 | + $this->log->error( "Unexpected status code when opening URL $base_url$url: " . $response['response']['code'] . "\n" . var_export( $response, true ) ); |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + |
|
| 548 | + $this->set_dataset_uri( '' ); |
|
| 549 | + $this->set_package_type( null ); |
|
| 550 | + |
|
| 551 | + return; |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + /* |
|
| 555 | 555 | * We also store the package type. |
| 556 | 556 | * |
| 557 | 557 | * @since 3.20.0 |
| 558 | 558 | */ |
| 559 | - $json = json_decode( $response['body'] ); |
|
| 560 | - /** |
|
| 561 | - * @since 3.27.7 |
|
| 562 | - * Remove the trailing slash returned from the new platform api. |
|
| 563 | - */ |
|
| 564 | - $dataset_uri = untrailingslashit( $json->datasetURI ); |
|
| 565 | - $package_type = isset( $json->packageType ) ? $json->packageType : null; |
|
| 566 | - |
|
| 567 | - $this->log->info( "Updating [ dataset uri :: $dataset_uri ][ package type :: $package_type ]..." ); |
|
| 568 | - |
|
| 569 | - $this->set_dataset_uri( $dataset_uri ); |
|
| 570 | - $this->set_package_type( $package_type ); |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - /** |
|
| 574 | - * Handle the edge case where a user submits the same key again |
|
| 575 | - * when he does not have the dataset uri to regain it. |
|
| 576 | - * |
|
| 577 | - * This can not be handled in the normal option update hook because |
|
| 578 | - * it is not being triggered when the save value equals to the one already |
|
| 579 | - * in the DB. |
|
| 580 | - * |
|
| 581 | - * @param mixed $value The new, unserialized option value. |
|
| 582 | - * @param mixed $old_value The old option value. |
|
| 583 | - * |
|
| 584 | - * @return mixed The same value in the $value parameter |
|
| 585 | - * @since 3.12.0 |
|
| 586 | - * |
|
| 587 | - */ |
|
| 588 | - function maybe_update_dataset_uri( $value, $old_value ) { |
|
| 589 | - |
|
| 590 | - // Check the old key value and the new one. Here we're only handling the |
|
| 591 | - // case where the key hasn't changed and the dataset URI isn't set. The |
|
| 592 | - // other case, i.e. a new key is inserted, is handled at `update_key`. |
|
| 593 | - $old_key = isset( $old_value['key'] ) ? $old_value['key'] : ''; |
|
| 594 | - $new_key = isset( $value['key'] ) ? $value['key'] : ''; |
|
| 595 | - |
|
| 596 | - $dataset_uri = $this->get_dataset_uri(); |
|
| 597 | - |
|
| 598 | - if ( ! empty( $new_key ) && $new_key === $old_key && empty( $dataset_uri ) ) { |
|
| 599 | - |
|
| 600 | - // make the request to the remote server to try to get the dataset uri. |
|
| 601 | - $this->get_remote_dataset_uri( $new_key ); |
|
| 602 | - } |
|
| 603 | - |
|
| 604 | - return $value; |
|
| 605 | - } |
|
| 606 | - |
|
| 607 | - /** |
|
| 608 | - * Get the API URI to retrieve the dataset URI using the WordLift Key. |
|
| 609 | - * |
|
| 610 | - * @param string $key The WordLift key to use. |
|
| 611 | - * |
|
| 612 | - * @return string The API URI. |
|
| 613 | - * @since 3.11.0 |
|
| 614 | - * |
|
| 615 | - */ |
|
| 616 | - public function get_accounts_by_key_dataset_uri( $key ) { |
|
| 617 | - |
|
| 618 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . "accounts/key=$key/dataset_uri"; |
|
| 619 | - } |
|
| 620 | - |
|
| 621 | - /** |
|
| 622 | - * Get the `accounts` end point. |
|
| 623 | - * |
|
| 624 | - * @return string The `accounts` end point. |
|
| 625 | - * @since 3.16.0 |
|
| 626 | - * |
|
| 627 | - */ |
|
| 628 | - public function get_accounts() { |
|
| 629 | - |
|
| 630 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'accounts'; |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - /** |
|
| 634 | - * Get the `link by default` option. |
|
| 635 | - * |
|
| 636 | - * @return bool True if entities must be linked by default otherwise false. |
|
| 637 | - * @since 3.13.0 |
|
| 638 | - * |
|
| 639 | - */ |
|
| 640 | - public function is_link_by_default() { |
|
| 641 | - |
|
| 642 | - return 'yes' === $this->get( 'wl_general_settings', self::LINK_BY_DEFAULT, 'yes' ); |
|
| 643 | - } |
|
| 644 | - |
|
| 645 | - /** |
|
| 646 | - * Set the `link by default` option. |
|
| 647 | - * |
|
| 648 | - * @param bool $value True to enabling linking by default, otherwise false. |
|
| 649 | - * |
|
| 650 | - * @since 3.13.0 |
|
| 651 | - * |
|
| 652 | - */ |
|
| 653 | - public function set_link_by_default( $value ) { |
|
| 654 | - |
|
| 655 | - $this->set( 'wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no' ); |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - /** |
|
| 659 | - * Get the 'analytics-enable' option. |
|
| 660 | - * |
|
| 661 | - * @return string 'no' or 'yes' representing bool. |
|
| 662 | - * @since 3.21.0 |
|
| 663 | - * |
|
| 664 | - */ |
|
| 665 | - public function is_analytics_enable() { |
|
| 666 | - return 'yes' === $this->get( 'wl_analytics_settings', self::ANALYTICS_ENABLE, 'no' ); |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - /** |
|
| 670 | - * Set the `analytics-enable` option. |
|
| 671 | - * |
|
| 672 | - * @param bool $value True to enabling analytics, otherwise false. |
|
| 673 | - * |
|
| 674 | - * @since 3.21.0 |
|
| 675 | - * |
|
| 676 | - */ |
|
| 677 | - public function set_is_analytics_enable( $value ) { |
|
| 678 | - |
|
| 679 | - $this->set( 'wl_general_settings', self::ANALYTICS_ENABLE, true === $value ? 'yes' : 'no' ); |
|
| 680 | - } |
|
| 681 | - |
|
| 682 | - /** |
|
| 683 | - * Get the 'analytics-entity-uri-dimention' option. |
|
| 684 | - * |
|
| 685 | - * @return int |
|
| 686 | - * @since 3.21.0 |
|
| 687 | - * |
|
| 688 | - */ |
|
| 689 | - public function get_analytics_entity_uri_dimension() { |
|
| 690 | - return (int) $this->get( 'wl_analytics_settings', self::ANALYTICS_ENTITY_URI_DIMENSION, 1 ); |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - /** |
|
| 694 | - * Get the 'analytics-entity-type-dimension' option. |
|
| 695 | - * |
|
| 696 | - * @return int |
|
| 697 | - * @since 3.21.0 |
|
| 698 | - * |
|
| 699 | - */ |
|
| 700 | - public function get_analytics_entity_type_dimension() { |
|
| 701 | - return $this->get( 'wl_analytics_settings', self::ANALYTICS_ENTITY_TYPE_DIMENSION, 2 ); |
|
| 702 | - } |
|
| 703 | - |
|
| 704 | - /** |
|
| 705 | - * Get the URL to perform autocomplete request. |
|
| 706 | - * |
|
| 707 | - * @return string The URL to call to perform the autocomplete request. |
|
| 708 | - * @since 3.15.0 |
|
| 709 | - * |
|
| 710 | - */ |
|
| 711 | - public function get_autocomplete_url() { |
|
| 712 | - |
|
| 713 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'autocomplete'; |
|
| 714 | - |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - /** |
|
| 718 | - * Get the URL to perform feedback deactivation request. |
|
| 719 | - * |
|
| 720 | - * @return string The URL to call to perform the feedback deactivation request. |
|
| 721 | - * @since 3.19.0 |
|
| 722 | - * |
|
| 723 | - */ |
|
| 724 | - public function get_deactivation_feedback_url() { |
|
| 725 | - |
|
| 726 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'feedbacks'; |
|
| 727 | - |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * Get the base API URL. |
|
| 732 | - * |
|
| 733 | - * @return string The base API URL. |
|
| 734 | - * @since 3.20.0 |
|
| 735 | - * |
|
| 736 | - */ |
|
| 737 | - public function get_api_url() { |
|
| 738 | - |
|
| 739 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE; |
|
| 740 | - } |
|
| 559 | + $json = json_decode( $response['body'] ); |
|
| 560 | + /** |
|
| 561 | + * @since 3.27.7 |
|
| 562 | + * Remove the trailing slash returned from the new platform api. |
|
| 563 | + */ |
|
| 564 | + $dataset_uri = untrailingslashit( $json->datasetURI ); |
|
| 565 | + $package_type = isset( $json->packageType ) ? $json->packageType : null; |
|
| 566 | + |
|
| 567 | + $this->log->info( "Updating [ dataset uri :: $dataset_uri ][ package type :: $package_type ]..." ); |
|
| 568 | + |
|
| 569 | + $this->set_dataset_uri( $dataset_uri ); |
|
| 570 | + $this->set_package_type( $package_type ); |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + /** |
|
| 574 | + * Handle the edge case where a user submits the same key again |
|
| 575 | + * when he does not have the dataset uri to regain it. |
|
| 576 | + * |
|
| 577 | + * This can not be handled in the normal option update hook because |
|
| 578 | + * it is not being triggered when the save value equals to the one already |
|
| 579 | + * in the DB. |
|
| 580 | + * |
|
| 581 | + * @param mixed $value The new, unserialized option value. |
|
| 582 | + * @param mixed $old_value The old option value. |
|
| 583 | + * |
|
| 584 | + * @return mixed The same value in the $value parameter |
|
| 585 | + * @since 3.12.0 |
|
| 586 | + * |
|
| 587 | + */ |
|
| 588 | + function maybe_update_dataset_uri( $value, $old_value ) { |
|
| 589 | + |
|
| 590 | + // Check the old key value and the new one. Here we're only handling the |
|
| 591 | + // case where the key hasn't changed and the dataset URI isn't set. The |
|
| 592 | + // other case, i.e. a new key is inserted, is handled at `update_key`. |
|
| 593 | + $old_key = isset( $old_value['key'] ) ? $old_value['key'] : ''; |
|
| 594 | + $new_key = isset( $value['key'] ) ? $value['key'] : ''; |
|
| 595 | + |
|
| 596 | + $dataset_uri = $this->get_dataset_uri(); |
|
| 597 | + |
|
| 598 | + if ( ! empty( $new_key ) && $new_key === $old_key && empty( $dataset_uri ) ) { |
|
| 599 | + |
|
| 600 | + // make the request to the remote server to try to get the dataset uri. |
|
| 601 | + $this->get_remote_dataset_uri( $new_key ); |
|
| 602 | + } |
|
| 603 | + |
|
| 604 | + return $value; |
|
| 605 | + } |
|
| 606 | + |
|
| 607 | + /** |
|
| 608 | + * Get the API URI to retrieve the dataset URI using the WordLift Key. |
|
| 609 | + * |
|
| 610 | + * @param string $key The WordLift key to use. |
|
| 611 | + * |
|
| 612 | + * @return string The API URI. |
|
| 613 | + * @since 3.11.0 |
|
| 614 | + * |
|
| 615 | + */ |
|
| 616 | + public function get_accounts_by_key_dataset_uri( $key ) { |
|
| 617 | + |
|
| 618 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . "accounts/key=$key/dataset_uri"; |
|
| 619 | + } |
|
| 620 | + |
|
| 621 | + /** |
|
| 622 | + * Get the `accounts` end point. |
|
| 623 | + * |
|
| 624 | + * @return string The `accounts` end point. |
|
| 625 | + * @since 3.16.0 |
|
| 626 | + * |
|
| 627 | + */ |
|
| 628 | + public function get_accounts() { |
|
| 629 | + |
|
| 630 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'accounts'; |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + /** |
|
| 634 | + * Get the `link by default` option. |
|
| 635 | + * |
|
| 636 | + * @return bool True if entities must be linked by default otherwise false. |
|
| 637 | + * @since 3.13.0 |
|
| 638 | + * |
|
| 639 | + */ |
|
| 640 | + public function is_link_by_default() { |
|
| 641 | + |
|
| 642 | + return 'yes' === $this->get( 'wl_general_settings', self::LINK_BY_DEFAULT, 'yes' ); |
|
| 643 | + } |
|
| 644 | + |
|
| 645 | + /** |
|
| 646 | + * Set the `link by default` option. |
|
| 647 | + * |
|
| 648 | + * @param bool $value True to enabling linking by default, otherwise false. |
|
| 649 | + * |
|
| 650 | + * @since 3.13.0 |
|
| 651 | + * |
|
| 652 | + */ |
|
| 653 | + public function set_link_by_default( $value ) { |
|
| 654 | + |
|
| 655 | + $this->set( 'wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no' ); |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + /** |
|
| 659 | + * Get the 'analytics-enable' option. |
|
| 660 | + * |
|
| 661 | + * @return string 'no' or 'yes' representing bool. |
|
| 662 | + * @since 3.21.0 |
|
| 663 | + * |
|
| 664 | + */ |
|
| 665 | + public function is_analytics_enable() { |
|
| 666 | + return 'yes' === $this->get( 'wl_analytics_settings', self::ANALYTICS_ENABLE, 'no' ); |
|
| 667 | + } |
|
| 668 | + |
|
| 669 | + /** |
|
| 670 | + * Set the `analytics-enable` option. |
|
| 671 | + * |
|
| 672 | + * @param bool $value True to enabling analytics, otherwise false. |
|
| 673 | + * |
|
| 674 | + * @since 3.21.0 |
|
| 675 | + * |
|
| 676 | + */ |
|
| 677 | + public function set_is_analytics_enable( $value ) { |
|
| 678 | + |
|
| 679 | + $this->set( 'wl_general_settings', self::ANALYTICS_ENABLE, true === $value ? 'yes' : 'no' ); |
|
| 680 | + } |
|
| 681 | + |
|
| 682 | + /** |
|
| 683 | + * Get the 'analytics-entity-uri-dimention' option. |
|
| 684 | + * |
|
| 685 | + * @return int |
|
| 686 | + * @since 3.21.0 |
|
| 687 | + * |
|
| 688 | + */ |
|
| 689 | + public function get_analytics_entity_uri_dimension() { |
|
| 690 | + return (int) $this->get( 'wl_analytics_settings', self::ANALYTICS_ENTITY_URI_DIMENSION, 1 ); |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + /** |
|
| 694 | + * Get the 'analytics-entity-type-dimension' option. |
|
| 695 | + * |
|
| 696 | + * @return int |
|
| 697 | + * @since 3.21.0 |
|
| 698 | + * |
|
| 699 | + */ |
|
| 700 | + public function get_analytics_entity_type_dimension() { |
|
| 701 | + return $this->get( 'wl_analytics_settings', self::ANALYTICS_ENTITY_TYPE_DIMENSION, 2 ); |
|
| 702 | + } |
|
| 703 | + |
|
| 704 | + /** |
|
| 705 | + * Get the URL to perform autocomplete request. |
|
| 706 | + * |
|
| 707 | + * @return string The URL to call to perform the autocomplete request. |
|
| 708 | + * @since 3.15.0 |
|
| 709 | + * |
|
| 710 | + */ |
|
| 711 | + public function get_autocomplete_url() { |
|
| 712 | + |
|
| 713 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'autocomplete'; |
|
| 714 | + |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + /** |
|
| 718 | + * Get the URL to perform feedback deactivation request. |
|
| 719 | + * |
|
| 720 | + * @return string The URL to call to perform the feedback deactivation request. |
|
| 721 | + * @since 3.19.0 |
|
| 722 | + * |
|
| 723 | + */ |
|
| 724 | + public function get_deactivation_feedback_url() { |
|
| 725 | + |
|
| 726 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'feedbacks'; |
|
| 727 | + |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * Get the base API URL. |
|
| 732 | + * |
|
| 733 | + * @return string The base API URL. |
|
| 734 | + * @since 3.20.0 |
|
| 735 | + * |
|
| 736 | + */ |
|
| 737 | + public function get_api_url() { |
|
| 738 | + |
|
| 739 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE; |
|
| 740 | + } |
|
| 741 | 741 | |
| 742 | 742 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | use Wordlift\Api\Default_Api_Service; |
| 14 | 14 | |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function __construct() { |
| 142 | 142 | |
| 143 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 143 | + $this->log = Wordlift_Log_Service::get_logger(get_class()); |
|
| 144 | 144 | |
| 145 | 145 | self::$instance = $this; |
| 146 | 146 | |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | * @since 3.6.0 |
| 171 | 171 | * |
| 172 | 172 | */ |
| 173 | - private function get( $option, $key, $default = '' ) { |
|
| 173 | + private function get($option, $key, $default = '') { |
|
| 174 | 174 | |
| 175 | - $options = get_option( $option, array() ); |
|
| 175 | + $options = get_option($option, array()); |
|
| 176 | 176 | |
| 177 | - return isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
| 177 | + return isset($options[$key]) ? $options[$key] : $default; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | * @since 3.9.0 |
| 188 | 188 | * |
| 189 | 189 | */ |
| 190 | - private function set( $option, $key, $value ) { |
|
| 190 | + private function set($option, $key, $value) { |
|
| 191 | 191 | |
| 192 | - $values = get_option( $option ); |
|
| 193 | - $values = isset( $values ) ? $values : array(); |
|
| 194 | - $values[ $key ] = $value; |
|
| 195 | - update_option( $option, $values ); |
|
| 192 | + $values = get_option($option); |
|
| 193 | + $values = isset($values) ? $values : array(); |
|
| 194 | + $values[$key] = $value; |
|
| 195 | + update_option($option, $values); |
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function get_entity_base_path() { |
| 207 | 207 | |
| 208 | - return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' ); |
|
| 208 | + return $this->get('wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity'); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | * @since 3.9.0 |
| 217 | 217 | * |
| 218 | 218 | */ |
| 219 | - public function set_entity_base_path( $value ) { |
|
| 219 | + public function set_entity_base_path($value) { |
|
| 220 | 220 | |
| 221 | - $this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value ); |
|
| 221 | + $this->set('wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value); |
|
| 222 | 222 | |
| 223 | 223 | } |
| 224 | 224 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function is_skip_wizard() { |
| 233 | 233 | |
| 234 | - return $this->get( 'wl_general_settings', self::SKIP_WIZARD, false ); |
|
| 234 | + return $this->get('wl_general_settings', self::SKIP_WIZARD, false); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -242,9 +242,9 @@ discard block |
||
| 242 | 242 | * @since 3.9.0 |
| 243 | 243 | * |
| 244 | 244 | */ |
| 245 | - public function set_skip_wizard( $value ) { |
|
| 245 | + public function set_skip_wizard($value) { |
|
| 246 | 246 | |
| 247 | - $this->set( 'wl_general_settings', self::SKIP_WIZARD, true === $value ); |
|
| 247 | + $this->set('wl_general_settings', self::SKIP_WIZARD, true === $value); |
|
| 248 | 248 | |
| 249 | 249 | } |
| 250 | 250 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | public function get_key() { |
| 259 | 259 | |
| 260 | - return $this->get( 'wl_general_settings', self::KEY, '' ); |
|
| 260 | + return $this->get('wl_general_settings', self::KEY, ''); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | * @since 3.9.0 |
| 269 | 269 | * |
| 270 | 270 | */ |
| 271 | - public function set_key( $value ) { |
|
| 271 | + public function set_key($value) { |
|
| 272 | 272 | |
| 273 | - $this->set( 'wl_general_settings', self::KEY, $value ); |
|
| 273 | + $this->set('wl_general_settings', self::KEY, $value); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function get_language_code() { |
| 286 | 286 | |
| 287 | - return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' ); |
|
| 287 | + return $this->get('wl_general_settings', self::LANGUAGE, 'en'); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -295,9 +295,9 @@ discard block |
||
| 295 | 295 | * @since 3.9.0 |
| 296 | 296 | * |
| 297 | 297 | */ |
| 298 | - public function set_language_code( $value ) { |
|
| 298 | + public function set_language_code($value) { |
|
| 299 | 299 | |
| 300 | - $this->set( 'wl_general_settings', self::LANGUAGE, $value ); |
|
| 300 | + $this->set('wl_general_settings', self::LANGUAGE, $value); |
|
| 301 | 301 | |
| 302 | 302 | } |
| 303 | 303 | |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | * @since 3.19.0 |
| 310 | 310 | * |
| 311 | 311 | */ |
| 312 | - public function set_diagnostic_preferences( $value ) { |
|
| 312 | + public function set_diagnostic_preferences($value) { |
|
| 313 | 313 | |
| 314 | - $this->set( 'wl_general_settings', self::SEND_DIAGNOSTIC, $value ); |
|
| 314 | + $this->set('wl_general_settings', self::SEND_DIAGNOSTIC, $value); |
|
| 315 | 315 | |
| 316 | 316 | } |
| 317 | 317 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | public function get_diagnostic_preferences() { |
| 324 | 324 | |
| 325 | - return $this->get( 'wl_general_settings', self::SEND_DIAGNOSTIC, 'no' ); |
|
| 325 | + return $this->get('wl_general_settings', self::SEND_DIAGNOSTIC, 'no'); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | public function get_country_code() { |
| 336 | 336 | |
| 337 | - return $this->get( 'wl_general_settings', self::COUNTRY_CODE, 'us' ); |
|
| 337 | + return $this->get('wl_general_settings', self::COUNTRY_CODE, 'us'); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -345,9 +345,9 @@ discard block |
||
| 345 | 345 | * @since 3.18.0 |
| 346 | 346 | * |
| 347 | 347 | */ |
| 348 | - public function set_country_code( $value ) { |
|
| 348 | + public function set_country_code($value) { |
|
| 349 | 349 | |
| 350 | - $this->set( 'wl_general_settings', self::COUNTRY_CODE, $value ); |
|
| 350 | + $this->set('wl_general_settings', self::COUNTRY_CODE, $value); |
|
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | public function get_publisher_id() { |
| 365 | 365 | |
| 366 | - return $this->get( 'wl_general_settings', self::PUBLISHER_ID, null ); |
|
| 366 | + return $this->get('wl_general_settings', self::PUBLISHER_ID, null); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
@@ -374,9 +374,9 @@ discard block |
||
| 374 | 374 | * @since 3.9.0 |
| 375 | 375 | * |
| 376 | 376 | */ |
| 377 | - public function set_publisher_id( $value ) { |
|
| 377 | + public function set_publisher_id($value) { |
|
| 378 | 378 | |
| 379 | - $this->set( 'wl_general_settings', self::PUBLISHER_ID, $value ); |
|
| 379 | + $this->set('wl_general_settings', self::PUBLISHER_ID, $value); |
|
| 380 | 380 | |
| 381 | 381 | } |
| 382 | 382 | |
@@ -390,8 +390,8 @@ discard block |
||
| 390 | 390 | */ |
| 391 | 391 | public function get_dataset_uri() { |
| 392 | 392 | |
| 393 | - if ( apply_filters( 'wl_features__enable__dataset', true ) ) { |
|
| 394 | - return $this->get( 'wl_advanced_settings', self::DATASET_URI, null ); |
|
| 393 | + if (apply_filters('wl_features__enable__dataset', true)) { |
|
| 394 | + return $this->get('wl_advanced_settings', self::DATASET_URI, null); |
|
| 395 | 395 | } else { |
| 396 | 396 | return null; |
| 397 | 397 | } |
@@ -405,9 +405,9 @@ discard block |
||
| 405 | 405 | * @since 3.10.0 |
| 406 | 406 | * |
| 407 | 407 | */ |
| 408 | - public function set_dataset_uri( $value ) { |
|
| 408 | + public function set_dataset_uri($value) { |
|
| 409 | 409 | |
| 410 | - $this->set( 'wl_advanced_settings', self::DATASET_URI, $value ); |
|
| 410 | + $this->set('wl_advanced_settings', self::DATASET_URI, $value); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | */ |
| 420 | 420 | public function get_package_type() { |
| 421 | 421 | |
| 422 | - return $this->get( 'wl_advanced_settings', self::PACKAGE_TYPE, null ); |
|
| 422 | + return $this->get('wl_advanced_settings', self::PACKAGE_TYPE, null); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | /** |
@@ -430,8 +430,8 @@ discard block |
||
| 430 | 430 | * @since 3.20.0 |
| 431 | 431 | * |
| 432 | 432 | */ |
| 433 | - public function set_package_type( $value ) { |
|
| 434 | - $this->set( 'wl_advanced_settings', self::PACKAGE_TYPE, $value ); |
|
| 433 | + public function set_package_type($value) { |
|
| 434 | + $this->set('wl_advanced_settings', self::PACKAGE_TYPE, $value); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -447,11 +447,11 @@ discard block |
||
| 447 | 447 | * @param array $old_value The old settings. |
| 448 | 448 | * @param array $new_value The new settings. |
| 449 | 449 | */ |
| 450 | - public function update_key( $old_value, $new_value ) { |
|
| 450 | + public function update_key($old_value, $new_value) { |
|
| 451 | 451 | |
| 452 | 452 | // Check the old key value and the new one. We're going to ask for the dataset URI only if the key has changed. |
| 453 | 453 | // $old_key = isset( $old_value['key'] ) ? $old_value['key'] : ''; |
| 454 | - $new_key = isset( $new_value['key'] ) ? $new_value['key'] : ''; |
|
| 454 | + $new_key = isset($new_value['key']) ? $new_value['key'] : ''; |
|
| 455 | 455 | |
| 456 | 456 | // If the key hasn't changed, don't do anything. |
| 457 | 457 | // WARN The 'update_option' hook is fired only if the new and old value are not equal. |
@@ -460,12 +460,12 @@ discard block |
||
| 460 | 460 | // } |
| 461 | 461 | |
| 462 | 462 | // If the key is empty, empty the dataset URI. |
| 463 | - if ( '' === $new_key ) { |
|
| 464 | - $this->set_dataset_uri( '' ); |
|
| 463 | + if ('' === $new_key) { |
|
| 464 | + $this->set_dataset_uri(''); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | // make the request to the remote server. |
| 468 | - $this->get_remote_dataset_uri( $new_key ); |
|
| 468 | + $this->get_remote_dataset_uri($new_key); |
|
| 469 | 469 | |
| 470 | 470 | } |
| 471 | 471 | |
@@ -481,15 +481,15 @@ discard block |
||
| 481 | 481 | * |
| 482 | 482 | * @since 3.17.0 send the site URL and get the dataset URI. |
| 483 | 483 | */ |
| 484 | - public function get_remote_dataset_uri( $key ) { |
|
| 484 | + public function get_remote_dataset_uri($key) { |
|
| 485 | 485 | |
| 486 | - $this->log->trace( 'Getting the remote dataset URI and package type...' ); |
|
| 486 | + $this->log->trace('Getting the remote dataset URI and package type...'); |
|
| 487 | 487 | |
| 488 | - if ( empty( $key ) ) { |
|
| 489 | - $this->log->warn( 'Key set to empty value.' ); |
|
| 488 | + if (empty($key)) { |
|
| 489 | + $this->log->warn('Key set to empty value.'); |
|
| 490 | 490 | |
| 491 | - $this->set_dataset_uri( '' ); |
|
| 492 | - $this->set_package_type( null ); |
|
| 491 | + $this->set_dataset_uri(''); |
|
| 492 | + $this->set_package_type(null); |
|
| 493 | 493 | |
| 494 | 494 | return; |
| 495 | 495 | } |
@@ -504,15 +504,15 @@ discard block |
||
| 504 | 504 | * @since 3.20.0 |
| 505 | 505 | * |
| 506 | 506 | */ |
| 507 | - $home_url = get_option( 'home' ); |
|
| 508 | - $site_url = apply_filters( 'wl_production_site_url', untrailingslashit( $home_url ) ); |
|
| 507 | + $home_url = get_option('home'); |
|
| 508 | + $site_url = apply_filters('wl_production_site_url', untrailingslashit($home_url)); |
|
| 509 | 509 | |
| 510 | 510 | // Build the URL. |
| 511 | 511 | $url = '/accounts' |
| 512 | - . '?key=' . rawurlencode( $key ) |
|
| 513 | - . '&url=' . rawurlencode( $site_url ) |
|
| 514 | - . '&country=' . $this->get_country_code() |
|
| 515 | - . '&language=' . $this->get_language_code(); |
|
| 512 | + . '?key='.rawurlencode($key) |
|
| 513 | + . '&url='.rawurlencode($site_url) |
|
| 514 | + . '&country='.$this->get_country_code() |
|
| 515 | + . '&language='.$this->get_language_code(); |
|
| 516 | 516 | |
| 517 | 517 | $api_service = Default_Api_Service::get_instance(); |
| 518 | 518 | /** |
@@ -522,31 +522,31 @@ discard block |
||
| 522 | 522 | $headers = array( |
| 523 | 523 | 'Authorization' => "Key $key", |
| 524 | 524 | ); |
| 525 | - $response = $api_service->request( 'PUT', $url, $headers )->get_response(); |
|
| 525 | + $response = $api_service->request('PUT', $url, $headers)->get_response(); |
|
| 526 | 526 | |
| 527 | 527 | // The response is an error. |
| 528 | - if ( is_wp_error( $response ) ) { |
|
| 529 | - $this->log->error( 'An error occurred setting the dataset URI: ' . $response->get_error_message() ); |
|
| 528 | + if (is_wp_error($response)) { |
|
| 529 | + $this->log->error('An error occurred setting the dataset URI: '.$response->get_error_message()); |
|
| 530 | 530 | |
| 531 | - $this->set_dataset_uri( '' ); |
|
| 532 | - $this->set_package_type( null ); |
|
| 531 | + $this->set_dataset_uri(''); |
|
| 532 | + $this->set_package_type(null); |
|
| 533 | 533 | |
| 534 | 534 | return; |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | // The response is not OK. |
| 538 | - if ( ! is_array( $response ) || 200 !== (int) $response['response']['code'] ) { |
|
| 538 | + if ( ! is_array($response) || 200 !== (int) $response['response']['code']) { |
|
| 539 | 539 | $base_url = $api_service->get_base_url(); |
| 540 | 540 | |
| 541 | - if ( ! is_array( $response ) ) { |
|
| 542 | - $this->log->error( "Unexpected response when opening URL $base_url$url: " . var_export( $response, true ) ); |
|
| 541 | + if ( ! is_array($response)) { |
|
| 542 | + $this->log->error("Unexpected response when opening URL $base_url$url: ".var_export($response, true)); |
|
| 543 | 543 | } else { |
| 544 | - $this->log->error( "Unexpected status code when opening URL $base_url$url: " . $response['response']['code'] . "\n" . var_export( $response, true ) ); |
|
| 544 | + $this->log->error("Unexpected status code when opening URL $base_url$url: ".$response['response']['code']."\n".var_export($response, true)); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | |
| 548 | - $this->set_dataset_uri( '' ); |
|
| 549 | - $this->set_package_type( null ); |
|
| 548 | + $this->set_dataset_uri(''); |
|
| 549 | + $this->set_package_type(null); |
|
| 550 | 550 | |
| 551 | 551 | return; |
| 552 | 552 | } |
@@ -556,18 +556,18 @@ discard block |
||
| 556 | 556 | * |
| 557 | 557 | * @since 3.20.0 |
| 558 | 558 | */ |
| 559 | - $json = json_decode( $response['body'] ); |
|
| 559 | + $json = json_decode($response['body']); |
|
| 560 | 560 | /** |
| 561 | 561 | * @since 3.27.7 |
| 562 | 562 | * Remove the trailing slash returned from the new platform api. |
| 563 | 563 | */ |
| 564 | - $dataset_uri = untrailingslashit( $json->datasetURI ); |
|
| 565 | - $package_type = isset( $json->packageType ) ? $json->packageType : null; |
|
| 564 | + $dataset_uri = untrailingslashit($json->datasetURI); |
|
| 565 | + $package_type = isset($json->packageType) ? $json->packageType : null; |
|
| 566 | 566 | |
| 567 | - $this->log->info( "Updating [ dataset uri :: $dataset_uri ][ package type :: $package_type ]..." ); |
|
| 567 | + $this->log->info("Updating [ dataset uri :: $dataset_uri ][ package type :: $package_type ]..."); |
|
| 568 | 568 | |
| 569 | - $this->set_dataset_uri( $dataset_uri ); |
|
| 570 | - $this->set_package_type( $package_type ); |
|
| 569 | + $this->set_dataset_uri($dataset_uri); |
|
| 570 | + $this->set_package_type($package_type); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /** |
@@ -585,20 +585,20 @@ discard block |
||
| 585 | 585 | * @since 3.12.0 |
| 586 | 586 | * |
| 587 | 587 | */ |
| 588 | - function maybe_update_dataset_uri( $value, $old_value ) { |
|
| 588 | + function maybe_update_dataset_uri($value, $old_value) { |
|
| 589 | 589 | |
| 590 | 590 | // Check the old key value and the new one. Here we're only handling the |
| 591 | 591 | // case where the key hasn't changed and the dataset URI isn't set. The |
| 592 | 592 | // other case, i.e. a new key is inserted, is handled at `update_key`. |
| 593 | - $old_key = isset( $old_value['key'] ) ? $old_value['key'] : ''; |
|
| 594 | - $new_key = isset( $value['key'] ) ? $value['key'] : ''; |
|
| 593 | + $old_key = isset($old_value['key']) ? $old_value['key'] : ''; |
|
| 594 | + $new_key = isset($value['key']) ? $value['key'] : ''; |
|
| 595 | 595 | |
| 596 | 596 | $dataset_uri = $this->get_dataset_uri(); |
| 597 | 597 | |
| 598 | - if ( ! empty( $new_key ) && $new_key === $old_key && empty( $dataset_uri ) ) { |
|
| 598 | + if ( ! empty($new_key) && $new_key === $old_key && empty($dataset_uri)) { |
|
| 599 | 599 | |
| 600 | 600 | // make the request to the remote server to try to get the dataset uri. |
| 601 | - $this->get_remote_dataset_uri( $new_key ); |
|
| 601 | + $this->get_remote_dataset_uri($new_key); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | return $value; |
@@ -613,9 +613,9 @@ discard block |
||
| 613 | 613 | * @since 3.11.0 |
| 614 | 614 | * |
| 615 | 615 | */ |
| 616 | - public function get_accounts_by_key_dataset_uri( $key ) { |
|
| 616 | + public function get_accounts_by_key_dataset_uri($key) { |
|
| 617 | 617 | |
| 618 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . "accounts/key=$key/dataset_uri"; |
|
| 618 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE."accounts/key=$key/dataset_uri"; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | */ |
| 628 | 628 | public function get_accounts() { |
| 629 | 629 | |
| 630 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'accounts'; |
|
| 630 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE.'accounts'; |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | /** |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | */ |
| 640 | 640 | public function is_link_by_default() { |
| 641 | 641 | |
| 642 | - return 'yes' === $this->get( 'wl_general_settings', self::LINK_BY_DEFAULT, 'yes' ); |
|
| 642 | + return 'yes' === $this->get('wl_general_settings', self::LINK_BY_DEFAULT, 'yes'); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | /** |
@@ -650,9 +650,9 @@ discard block |
||
| 650 | 650 | * @since 3.13.0 |
| 651 | 651 | * |
| 652 | 652 | */ |
| 653 | - public function set_link_by_default( $value ) { |
|
| 653 | + public function set_link_by_default($value) { |
|
| 654 | 654 | |
| 655 | - $this->set( 'wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no' ); |
|
| 655 | + $this->set('wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no'); |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | /** |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | * |
| 664 | 664 | */ |
| 665 | 665 | public function is_analytics_enable() { |
| 666 | - return 'yes' === $this->get( 'wl_analytics_settings', self::ANALYTICS_ENABLE, 'no' ); |
|
| 666 | + return 'yes' === $this->get('wl_analytics_settings', self::ANALYTICS_ENABLE, 'no'); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | /** |
@@ -674,9 +674,9 @@ discard block |
||
| 674 | 674 | * @since 3.21.0 |
| 675 | 675 | * |
| 676 | 676 | */ |
| 677 | - public function set_is_analytics_enable( $value ) { |
|
| 677 | + public function set_is_analytics_enable($value) { |
|
| 678 | 678 | |
| 679 | - $this->set( 'wl_general_settings', self::ANALYTICS_ENABLE, true === $value ? 'yes' : 'no' ); |
|
| 679 | + $this->set('wl_general_settings', self::ANALYTICS_ENABLE, true === $value ? 'yes' : 'no'); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | /** |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | * |
| 688 | 688 | */ |
| 689 | 689 | public function get_analytics_entity_uri_dimension() { |
| 690 | - return (int) $this->get( 'wl_analytics_settings', self::ANALYTICS_ENTITY_URI_DIMENSION, 1 ); |
|
| 690 | + return (int) $this->get('wl_analytics_settings', self::ANALYTICS_ENTITY_URI_DIMENSION, 1); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | /** |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | * |
| 699 | 699 | */ |
| 700 | 700 | public function get_analytics_entity_type_dimension() { |
| 701 | - return $this->get( 'wl_analytics_settings', self::ANALYTICS_ENTITY_TYPE_DIMENSION, 2 ); |
|
| 701 | + return $this->get('wl_analytics_settings', self::ANALYTICS_ENTITY_TYPE_DIMENSION, 2); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | /** |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | */ |
| 711 | 711 | public function get_autocomplete_url() { |
| 712 | 712 | |
| 713 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'autocomplete'; |
|
| 713 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE.'autocomplete'; |
|
| 714 | 714 | |
| 715 | 715 | } |
| 716 | 716 | |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | */ |
| 724 | 724 | public function get_deactivation_feedback_url() { |
| 725 | 725 | |
| 726 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'feedbacks'; |
|
| 726 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE.'feedbacks'; |
|
| 727 | 727 | |
| 728 | 728 | } |
| 729 | 729 | |
@@ -18,433 +18,433 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Admin_Settings_Page extends Wordlift_Admin_Page { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * A singleton instance of the Notice service. |
|
| 23 | - * |
|
| 24 | - * @since 3.2.0 |
|
| 25 | - * @access private |
|
| 26 | - * @var \Wordlift_Notice_Service $instance A singleton instance of the Notice service. |
|
| 27 | - */ |
|
| 28 | - private static $instance; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * A {@link Wordlift_Entity_Service} instance. |
|
| 32 | - * |
|
| 33 | - * @since 3.11.0 |
|
| 34 | - * @access private |
|
| 35 | - * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 36 | - */ |
|
| 37 | - private $entity_service; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 41 | - * |
|
| 42 | - * @since 3.11.0 |
|
| 43 | - * @access private |
|
| 44 | - * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 45 | - */ |
|
| 46 | - private $configuration_service; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * A {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 50 | - * |
|
| 51 | - * @since 3.11.0 |
|
| 52 | - * @access private |
|
| 53 | - * @var \Wordlift_Admin_Input_Element $input_element An {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 54 | - */ |
|
| 55 | - private $input_element; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 59 | - * |
|
| 60 | - * @since 3.13.0 |
|
| 61 | - * @access protected |
|
| 62 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 63 | - */ |
|
| 64 | - private $radio_input_element; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 68 | - * |
|
| 69 | - * @since 3.11.0 |
|
| 70 | - * @access private |
|
| 71 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 72 | - */ |
|
| 73 | - private $language_select_element; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 77 | - * |
|
| 78 | - * @since 3.18.0 |
|
| 79 | - * @access private |
|
| 80 | - * @var \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 81 | - */ |
|
| 82 | - private $country_select_element; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 86 | - * |
|
| 87 | - * @since 3.11.0 |
|
| 88 | - * @access private |
|
| 89 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 90 | - */ |
|
| 91 | - private $publisher_element; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Create a {@link Wordlift_Admin_Settings_Page} instance. |
|
| 95 | - * |
|
| 96 | - * @param \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 97 | - * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 98 | - * @param \Wordlift_Admin_Input_Element $input_element A {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 99 | - * @param \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 100 | - * @param \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 101 | - * @param \Wordlift_Admin_Publisher_Element $publisher_element A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 102 | - * @param \Wordlift_Admin_Radio_Input_Element $radio_input_element A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 103 | - * |
|
| 104 | - * @since 3.11.0 |
|
| 105 | - * |
|
| 106 | - */ |
|
| 107 | - function __construct( $configuration_service, $entity_service, $input_element, $language_select_element, $country_select_element, $publisher_element, $radio_input_element ) { |
|
| 108 | - |
|
| 109 | - $this->configuration_service = $configuration_service; |
|
| 110 | - $this->entity_service = $entity_service; |
|
| 111 | - |
|
| 112 | - // Set a reference to the UI elements. |
|
| 113 | - $this->input_element = $input_element; |
|
| 114 | - $this->radio_input_element = $radio_input_element; |
|
| 115 | - $this->language_select_element = $language_select_element; |
|
| 116 | - $this->country_select_element = $country_select_element; |
|
| 117 | - $this->publisher_element = $publisher_element; |
|
| 118 | - |
|
| 119 | - self::$instance = $this; |
|
| 120 | - |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Get the singleton instance of the Notice service. |
|
| 125 | - * |
|
| 126 | - * @return \Wordlift_Admin_Settings_Page The singleton instance of the settings page service. |
|
| 127 | - * @since 3.14.0 |
|
| 128 | - */ |
|
| 129 | - public static function get_instance() { |
|
| 130 | - |
|
| 131 | - return self::$instance; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @inheritdoc |
|
| 136 | - */ |
|
| 137 | - function get_parent_slug() { |
|
| 138 | - |
|
| 139 | - return 'wl_admin_menu'; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @inheritdoc |
|
| 144 | - */ |
|
| 145 | - function get_capability() { |
|
| 146 | - |
|
| 147 | - return 'manage_options'; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @inheritdoc |
|
| 152 | - */ |
|
| 153 | - function get_page_title() { |
|
| 154 | - |
|
| 155 | - return 'WordLift Settings'; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @inheritdoc |
|
| 160 | - */ |
|
| 161 | - function get_menu_title() { |
|
| 162 | - |
|
| 163 | - return 'Settings'; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * @inheritdoc |
|
| 168 | - */ |
|
| 169 | - function get_menu_slug() { |
|
| 170 | - |
|
| 171 | - return 'wl_configuration_admin_menu'; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * @inheritdoc |
|
| 176 | - */ |
|
| 177 | - function get_partial_name() { |
|
| 178 | - |
|
| 179 | - return 'wordlift-admin-settings-page.php'; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * @inheritdoc |
|
| 184 | - */ |
|
| 185 | - public function enqueue_scripts() { |
|
| 186 | - |
|
| 187 | - // Enqueue the media scripts to be used for the publisher's logo selection. |
|
| 188 | - wp_enqueue_media(); |
|
| 189 | - |
|
| 190 | - // JavaScript required for the settings page. |
|
| 191 | - // @todo: try to move to the `wordlift-admin.bundle.js`. |
|
| 192 | - wp_enqueue_script( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.js', array( 'wp-util' ) ); |
|
| 193 | - wp_enqueue_style( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.css' ); |
|
| 194 | - |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * Configure all the configuration parameters. |
|
| 199 | - * |
|
| 200 | - * Called by the *admin_init* hook. |
|
| 201 | - * |
|
| 202 | - * @since 3.11.0 |
|
| 203 | - */ |
|
| 204 | - function admin_init() { |
|
| 205 | - // Register WordLift's general settings, providing our own sanitize callback |
|
| 206 | - // which will also check whether the user filled the WL Publisher form. |
|
| 207 | - register_setting( |
|
| 208 | - 'wl_general_settings', |
|
| 209 | - 'wl_general_settings', |
|
| 210 | - array( $this, 'sanitize_callback' ) |
|
| 211 | - ); |
|
| 212 | - |
|
| 213 | - // Add the general settings section. |
|
| 214 | - add_settings_section( |
|
| 215 | - 'wl_general_settings_section', // ID used to identify this section and with which to register options. |
|
| 216 | - '', // Section header. |
|
| 217 | - '', // Callback used to render the description of the section. |
|
| 218 | - 'wl_general_settings' // Page on which to add this section of options. |
|
| 219 | - ); |
|
| 220 | - |
|
| 221 | - $key_args = array( |
|
| 222 | - 'id' => 'wl-key', |
|
| 223 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::KEY . ']', |
|
| 224 | - 'value' => $this->configuration_service->get_key(), |
|
| 225 | - 'description' => __( 'Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift' ) |
|
| 226 | - . ' [' . get_option( 'home' ) . ']', |
|
| 227 | - ); |
|
| 228 | - |
|
| 229 | - // Before we were used to validate the key beforehand, but this means |
|
| 230 | - // an http call whenever a page is opened in the admin area. Therefore |
|
| 231 | - // we now leave the input `untouched`, leaving to the client to update |
|
| 232 | - // the `css_class`. |
|
| 233 | - // |
|
| 234 | - // See https://github.com/insideout10/wordlift-plugin/issues/669. |
|
| 235 | - $key_args['css_class'] = 'untouched'; |
|
| 236 | - |
|
| 237 | - // Add the `key` field. |
|
| 238 | - add_settings_field( |
|
| 239 | - 'wl-key', // Element id used to identify the field throughout the theme. |
|
| 240 | - __( 'WordLift Key', 'wordlift' ), // The label to the left of the option interface element. |
|
| 241 | - // The name of the function responsible for rendering the option interface. |
|
| 242 | - array( $this->input_element, 'render' ), |
|
| 243 | - 'wl_general_settings', // The page on which this option will be displayed. |
|
| 244 | - 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
| 245 | - $key_args // The array of arguments to pass to the callback. In this case, just a description. |
|
| 246 | - ); |
|
| 247 | - |
|
| 248 | - // Entity Base Path input. |
|
| 249 | - $entity_base_path_args = array( |
|
| 250 | - // The array of arguments to pass to the callback. In this case, just a description. |
|
| 251 | - 'id' => 'wl-entity-base-path', |
|
| 252 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY . ']', |
|
| 253 | - 'value' => $this->configuration_service->get_entity_base_path(), |
|
| 254 | - /* translators: Placeholders: %s - a link to FAQ's page. */ |
|
| 255 | - 'description' => sprintf( __( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift' ), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary' ), |
|
| 256 | - ); |
|
| 257 | - |
|
| 258 | - // The following call is very heavy on large web sites and is always run |
|
| 259 | - // also when not needed: |
|
| 260 | - // $entity_base_path_args['readonly'] = 0 < $this->entity_service->count(); |
|
| 261 | - // |
|
| 262 | - // It is now replaced by a filter to add the `readonly` flag to the |
|
| 263 | - // input element when this is actually rendered. |
|
| 264 | - add_filter( 'wl_admin_input_element_params', array( |
|
| 265 | - $this, |
|
| 266 | - 'entity_path_input_element_params', |
|
| 267 | - ) ); |
|
| 268 | - |
|
| 269 | - // Add the `wl_entity_base_path` field. |
|
| 270 | - add_settings_field( |
|
| 271 | - 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
| 272 | - __( 'Entity Base Path', 'wordlift' ), // The label to the left of the option interface element |
|
| 273 | - // The name of the function responsible for rendering the option interface |
|
| 274 | - array( $this->input_element, 'render', ), |
|
| 275 | - 'wl_general_settings', // The page on which this option will be displayed |
|
| 276 | - 'wl_general_settings_section', // The name of the section to which this field belongs |
|
| 277 | - $entity_base_path_args |
|
| 278 | - ); |
|
| 279 | - |
|
| 280 | - // Add the `language_name` field. |
|
| 281 | - add_settings_field( |
|
| 282 | - 'wl-site-language', |
|
| 283 | - __( 'Site Language', 'wordlift' ), |
|
| 284 | - array( $this->language_select_element, 'render' ), |
|
| 285 | - 'wl_general_settings', |
|
| 286 | - 'wl_general_settings_section', |
|
| 287 | - array( |
|
| 288 | - // The array of arguments to pass to the callback. In this case, just a description. |
|
| 289 | - 'id' => 'wl-site-language', |
|
| 290 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LANGUAGE . ']', |
|
| 291 | - 'value' => $this->configuration_service->get_language_code(), |
|
| 292 | - 'description' => __( 'Each WordLift Key can be used only in one language. Pick yours.', 'wordlift' ), |
|
| 293 | - ) |
|
| 294 | - ); |
|
| 295 | - |
|
| 296 | - // Add the `country_code` field. |
|
| 297 | - add_settings_field( |
|
| 298 | - 'wl-country-code', |
|
| 299 | - _x( 'Country', 'wordlift' ), |
|
| 300 | - array( $this->country_select_element, 'render' ), |
|
| 301 | - 'wl_general_settings', |
|
| 302 | - 'wl_general_settings_section', |
|
| 303 | - array( |
|
| 304 | - 'id' => 'wl-country-code', |
|
| 305 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::COUNTRY_CODE . ']', |
|
| 306 | - 'value' => $this->configuration_service->get_country_code(), |
|
| 307 | - 'description' => __( 'Please select a country.', 'wordlift' ), |
|
| 308 | - 'notice' => __( 'The selected language is not supported in this country.</br>Please choose another country or language.', 'wordlift' ), |
|
| 309 | - ) |
|
| 310 | - ); |
|
| 311 | - |
|
| 312 | - // Add the `publisher` field. |
|
| 313 | - add_settings_field( |
|
| 314 | - 'wl-publisher-id', |
|
| 315 | - __( 'Publisher', 'wordlift' ), |
|
| 316 | - array( $this->publisher_element, 'render' ), |
|
| 317 | - 'wl_general_settings', |
|
| 318 | - 'wl_general_settings_section', |
|
| 319 | - array( |
|
| 320 | - 'id' => 'wl-publisher-id', |
|
| 321 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::PUBLISHER_ID . ']', |
|
| 322 | - ) |
|
| 323 | - ); |
|
| 324 | - |
|
| 325 | - // Add the `link by default` field. |
|
| 326 | - add_settings_field( |
|
| 327 | - 'wl-link-by-default', |
|
| 328 | - __( 'Link by Default', 'wordlift' ), |
|
| 329 | - array( $this->radio_input_element, 'render' ), |
|
| 330 | - 'wl_general_settings', |
|
| 331 | - 'wl_general_settings_section', |
|
| 332 | - array( |
|
| 333 | - 'id' => 'wl-link-by-default', |
|
| 334 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LINK_BY_DEFAULT . ']', |
|
| 335 | - 'value' => $this->configuration_service->is_link_by_default() ? 'yes' : 'no', |
|
| 336 | - 'description' => __( 'Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift' ), |
|
| 337 | - ) |
|
| 338 | - ); |
|
| 339 | - |
|
| 340 | - // Add the `diagnostic data` field. |
|
| 341 | - add_settings_field( |
|
| 342 | - 'wl-send-diagnostic', |
|
| 343 | - __( 'Send Diagnostic Data', 'wordlift' ), |
|
| 344 | - array( $this->radio_input_element, 'render' ), |
|
| 345 | - 'wl_general_settings', |
|
| 346 | - 'wl_general_settings_section', |
|
| 347 | - array( |
|
| 348 | - 'id' => 'wl-send-diagnostic', |
|
| 349 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::SEND_DIAGNOSTIC . ']', |
|
| 350 | - 'value' => 'yes' === $this->configuration_service->get_diagnostic_preferences() ? 'yes' : 'no', |
|
| 351 | - 'description' => __( 'Whether to send diagnostic data or not.', 'wordlift' ), |
|
| 352 | - ) |
|
| 353 | - ); |
|
| 354 | - |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * Filter the {@link Wordlift_Admin_Input_Element} in order to add the |
|
| 359 | - * `readonly` flag to the `wl-entity-base-path` input. |
|
| 360 | - * |
|
| 361 | - * @param array $args An array of {@link Wordlift_Admin_Input_Element} parameters. |
|
| 362 | - * |
|
| 363 | - * @return array The updated array. |
|
| 364 | - * @since 3.17.0 |
|
| 365 | - * |
|
| 366 | - */ |
|
| 367 | - public function entity_path_input_element_params( $args ) { |
|
| 368 | - |
|
| 369 | - // Bail out if it's not the `wl-entity-base-path`). |
|
| 370 | - if ( 'wl-entity-base-path' !== $args['id'] ) { |
|
| 371 | - return $args; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - // Set the readonly flag according to the entities count. |
|
| 375 | - $args['readonly'] = 0 < $this->entity_service->count(); |
|
| 376 | - |
|
| 377 | - // Return the updated args. |
|
| 378 | - return $args; |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * Sanitize the configuration settings to be stored. |
|
| 383 | - * |
|
| 384 | - * If a new entity is being created for the publisher, create it and set The |
|
| 385 | - * publisher setting. |
|
| 386 | - * |
|
| 387 | - * @param array $input The configuration settings array. |
|
| 388 | - * |
|
| 389 | - * @return array The sanitized input array. |
|
| 390 | - * @since 3.11.0 |
|
| 391 | - * |
|
| 392 | - */ |
|
| 393 | - function sanitize_callback( $input ) { |
|
| 394 | - |
|
| 395 | - // Validate the selected country. |
|
| 396 | - $this->validate_country(); |
|
| 397 | - |
|
| 398 | - // Check whether a publisher name has been set. |
|
| 399 | - if ( isset( $_POST['wl_publisher'] ) && ! empty( $_POST['wl_publisher']['name'] ) ) { // WPCS: CSRF, input var, sanitization ok. |
|
| 400 | - $name = $_POST['wl_publisher']['name']; // WPCS: CSRF, input var, sanitization ok. |
|
| 401 | - $type = $_POST['wl_publisher']['type']; // WPCS: CSRF, input var, sanitization ok. |
|
| 402 | - $thumbnail_id = $_POST['wl_publisher']['thumbnail_id'] ?: null; // WPCS: CSRF, input var, sanitization ok. |
|
| 403 | - |
|
| 404 | - // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 405 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person' ); |
|
| 406 | - |
|
| 407 | - // Create an entity for the publisher and assign it to the input |
|
| 408 | - // parameter which WordPress automatically saves into the settings. |
|
| 409 | - $input['publisher_id'] = $this->entity_service->create( $name, $type_uri, $thumbnail_id, 'publish' ); |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - return $input; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - /** |
|
| 416 | - * Check whether the currently selected country supports the site language. |
|
| 417 | - * |
|
| 418 | - * @since 3.18.0 |
|
| 419 | - */ |
|
| 420 | - private function validate_country() { |
|
| 421 | - |
|
| 422 | - // Bail out if for some reason the country and language are not set. |
|
| 423 | - if ( |
|
| 424 | - empty( $_POST['wl_general_settings']['site_language'] ) && // WPCS: CSRF, input var, sanitization ok. |
|
| 425 | - empty( $_POST['wl_general_settings']['country_code'] ) // WPCS: CSRF, input var, sanitization ok. |
|
| 426 | - ) { |
|
| 427 | - return; |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - // Get the values. |
|
| 431 | - $language = $_POST['wl_general_settings']['site_language']; // WPCS: CSRF, input var, sanitization ok. |
|
| 432 | - $country = $_POST['wl_general_settings']['country_code']; // WPCS: CSRF, input var, sanitization ok. |
|
| 433 | - $codes = Wordlift_Countries::get_codes(); |
|
| 434 | - |
|
| 435 | - // Check whether the chosen country has language limitations |
|
| 436 | - // and whether the chosen language is supported for that country. |
|
| 437 | - if ( |
|
| 438 | - ! empty( $codes[ $country ] ) && |
|
| 439 | - ! in_array( $language, $codes[ $country ] ) |
|
| 440 | - ) { |
|
| 441 | - // Otherwise add an error. |
|
| 442 | - add_settings_error( |
|
| 443 | - 'wl-country-code', |
|
| 444 | - esc_attr( 'settings_updated' ), |
|
| 445 | - _x( 'The selected language is not supported for the currently chosen country. Please choose another country or language.', 'wordlift' ) |
|
| 446 | - ); |
|
| 447 | - } |
|
| 448 | - } |
|
| 21 | + /** |
|
| 22 | + * A singleton instance of the Notice service. |
|
| 23 | + * |
|
| 24 | + * @since 3.2.0 |
|
| 25 | + * @access private |
|
| 26 | + * @var \Wordlift_Notice_Service $instance A singleton instance of the Notice service. |
|
| 27 | + */ |
|
| 28 | + private static $instance; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * A {@link Wordlift_Entity_Service} instance. |
|
| 32 | + * |
|
| 33 | + * @since 3.11.0 |
|
| 34 | + * @access private |
|
| 35 | + * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 36 | + */ |
|
| 37 | + private $entity_service; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 41 | + * |
|
| 42 | + * @since 3.11.0 |
|
| 43 | + * @access private |
|
| 44 | + * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 45 | + */ |
|
| 46 | + private $configuration_service; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * A {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 50 | + * |
|
| 51 | + * @since 3.11.0 |
|
| 52 | + * @access private |
|
| 53 | + * @var \Wordlift_Admin_Input_Element $input_element An {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 54 | + */ |
|
| 55 | + private $input_element; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 59 | + * |
|
| 60 | + * @since 3.13.0 |
|
| 61 | + * @access protected |
|
| 62 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 63 | + */ |
|
| 64 | + private $radio_input_element; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 68 | + * |
|
| 69 | + * @since 3.11.0 |
|
| 70 | + * @access private |
|
| 71 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 72 | + */ |
|
| 73 | + private $language_select_element; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 77 | + * |
|
| 78 | + * @since 3.18.0 |
|
| 79 | + * @access private |
|
| 80 | + * @var \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 81 | + */ |
|
| 82 | + private $country_select_element; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 86 | + * |
|
| 87 | + * @since 3.11.0 |
|
| 88 | + * @access private |
|
| 89 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 90 | + */ |
|
| 91 | + private $publisher_element; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Create a {@link Wordlift_Admin_Settings_Page} instance. |
|
| 95 | + * |
|
| 96 | + * @param \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 97 | + * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 98 | + * @param \Wordlift_Admin_Input_Element $input_element A {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 99 | + * @param \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 100 | + * @param \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 101 | + * @param \Wordlift_Admin_Publisher_Element $publisher_element A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 102 | + * @param \Wordlift_Admin_Radio_Input_Element $radio_input_element A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 103 | + * |
|
| 104 | + * @since 3.11.0 |
|
| 105 | + * |
|
| 106 | + */ |
|
| 107 | + function __construct( $configuration_service, $entity_service, $input_element, $language_select_element, $country_select_element, $publisher_element, $radio_input_element ) { |
|
| 108 | + |
|
| 109 | + $this->configuration_service = $configuration_service; |
|
| 110 | + $this->entity_service = $entity_service; |
|
| 111 | + |
|
| 112 | + // Set a reference to the UI elements. |
|
| 113 | + $this->input_element = $input_element; |
|
| 114 | + $this->radio_input_element = $radio_input_element; |
|
| 115 | + $this->language_select_element = $language_select_element; |
|
| 116 | + $this->country_select_element = $country_select_element; |
|
| 117 | + $this->publisher_element = $publisher_element; |
|
| 118 | + |
|
| 119 | + self::$instance = $this; |
|
| 120 | + |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Get the singleton instance of the Notice service. |
|
| 125 | + * |
|
| 126 | + * @return \Wordlift_Admin_Settings_Page The singleton instance of the settings page service. |
|
| 127 | + * @since 3.14.0 |
|
| 128 | + */ |
|
| 129 | + public static function get_instance() { |
|
| 130 | + |
|
| 131 | + return self::$instance; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @inheritdoc |
|
| 136 | + */ |
|
| 137 | + function get_parent_slug() { |
|
| 138 | + |
|
| 139 | + return 'wl_admin_menu'; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @inheritdoc |
|
| 144 | + */ |
|
| 145 | + function get_capability() { |
|
| 146 | + |
|
| 147 | + return 'manage_options'; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @inheritdoc |
|
| 152 | + */ |
|
| 153 | + function get_page_title() { |
|
| 154 | + |
|
| 155 | + return 'WordLift Settings'; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @inheritdoc |
|
| 160 | + */ |
|
| 161 | + function get_menu_title() { |
|
| 162 | + |
|
| 163 | + return 'Settings'; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * @inheritdoc |
|
| 168 | + */ |
|
| 169 | + function get_menu_slug() { |
|
| 170 | + |
|
| 171 | + return 'wl_configuration_admin_menu'; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * @inheritdoc |
|
| 176 | + */ |
|
| 177 | + function get_partial_name() { |
|
| 178 | + |
|
| 179 | + return 'wordlift-admin-settings-page.php'; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * @inheritdoc |
|
| 184 | + */ |
|
| 185 | + public function enqueue_scripts() { |
|
| 186 | + |
|
| 187 | + // Enqueue the media scripts to be used for the publisher's logo selection. |
|
| 188 | + wp_enqueue_media(); |
|
| 189 | + |
|
| 190 | + // JavaScript required for the settings page. |
|
| 191 | + // @todo: try to move to the `wordlift-admin.bundle.js`. |
|
| 192 | + wp_enqueue_script( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.js', array( 'wp-util' ) ); |
|
| 193 | + wp_enqueue_style( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.css' ); |
|
| 194 | + |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * Configure all the configuration parameters. |
|
| 199 | + * |
|
| 200 | + * Called by the *admin_init* hook. |
|
| 201 | + * |
|
| 202 | + * @since 3.11.0 |
|
| 203 | + */ |
|
| 204 | + function admin_init() { |
|
| 205 | + // Register WordLift's general settings, providing our own sanitize callback |
|
| 206 | + // which will also check whether the user filled the WL Publisher form. |
|
| 207 | + register_setting( |
|
| 208 | + 'wl_general_settings', |
|
| 209 | + 'wl_general_settings', |
|
| 210 | + array( $this, 'sanitize_callback' ) |
|
| 211 | + ); |
|
| 212 | + |
|
| 213 | + // Add the general settings section. |
|
| 214 | + add_settings_section( |
|
| 215 | + 'wl_general_settings_section', // ID used to identify this section and with which to register options. |
|
| 216 | + '', // Section header. |
|
| 217 | + '', // Callback used to render the description of the section. |
|
| 218 | + 'wl_general_settings' // Page on which to add this section of options. |
|
| 219 | + ); |
|
| 220 | + |
|
| 221 | + $key_args = array( |
|
| 222 | + 'id' => 'wl-key', |
|
| 223 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::KEY . ']', |
|
| 224 | + 'value' => $this->configuration_service->get_key(), |
|
| 225 | + 'description' => __( 'Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift' ) |
|
| 226 | + . ' [' . get_option( 'home' ) . ']', |
|
| 227 | + ); |
|
| 228 | + |
|
| 229 | + // Before we were used to validate the key beforehand, but this means |
|
| 230 | + // an http call whenever a page is opened in the admin area. Therefore |
|
| 231 | + // we now leave the input `untouched`, leaving to the client to update |
|
| 232 | + // the `css_class`. |
|
| 233 | + // |
|
| 234 | + // See https://github.com/insideout10/wordlift-plugin/issues/669. |
|
| 235 | + $key_args['css_class'] = 'untouched'; |
|
| 236 | + |
|
| 237 | + // Add the `key` field. |
|
| 238 | + add_settings_field( |
|
| 239 | + 'wl-key', // Element id used to identify the field throughout the theme. |
|
| 240 | + __( 'WordLift Key', 'wordlift' ), // The label to the left of the option interface element. |
|
| 241 | + // The name of the function responsible for rendering the option interface. |
|
| 242 | + array( $this->input_element, 'render' ), |
|
| 243 | + 'wl_general_settings', // The page on which this option will be displayed. |
|
| 244 | + 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
| 245 | + $key_args // The array of arguments to pass to the callback. In this case, just a description. |
|
| 246 | + ); |
|
| 247 | + |
|
| 248 | + // Entity Base Path input. |
|
| 249 | + $entity_base_path_args = array( |
|
| 250 | + // The array of arguments to pass to the callback. In this case, just a description. |
|
| 251 | + 'id' => 'wl-entity-base-path', |
|
| 252 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY . ']', |
|
| 253 | + 'value' => $this->configuration_service->get_entity_base_path(), |
|
| 254 | + /* translators: Placeholders: %s - a link to FAQ's page. */ |
|
| 255 | + 'description' => sprintf( __( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift' ), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary' ), |
|
| 256 | + ); |
|
| 257 | + |
|
| 258 | + // The following call is very heavy on large web sites and is always run |
|
| 259 | + // also when not needed: |
|
| 260 | + // $entity_base_path_args['readonly'] = 0 < $this->entity_service->count(); |
|
| 261 | + // |
|
| 262 | + // It is now replaced by a filter to add the `readonly` flag to the |
|
| 263 | + // input element when this is actually rendered. |
|
| 264 | + add_filter( 'wl_admin_input_element_params', array( |
|
| 265 | + $this, |
|
| 266 | + 'entity_path_input_element_params', |
|
| 267 | + ) ); |
|
| 268 | + |
|
| 269 | + // Add the `wl_entity_base_path` field. |
|
| 270 | + add_settings_field( |
|
| 271 | + 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
| 272 | + __( 'Entity Base Path', 'wordlift' ), // The label to the left of the option interface element |
|
| 273 | + // The name of the function responsible for rendering the option interface |
|
| 274 | + array( $this->input_element, 'render', ), |
|
| 275 | + 'wl_general_settings', // The page on which this option will be displayed |
|
| 276 | + 'wl_general_settings_section', // The name of the section to which this field belongs |
|
| 277 | + $entity_base_path_args |
|
| 278 | + ); |
|
| 279 | + |
|
| 280 | + // Add the `language_name` field. |
|
| 281 | + add_settings_field( |
|
| 282 | + 'wl-site-language', |
|
| 283 | + __( 'Site Language', 'wordlift' ), |
|
| 284 | + array( $this->language_select_element, 'render' ), |
|
| 285 | + 'wl_general_settings', |
|
| 286 | + 'wl_general_settings_section', |
|
| 287 | + array( |
|
| 288 | + // The array of arguments to pass to the callback. In this case, just a description. |
|
| 289 | + 'id' => 'wl-site-language', |
|
| 290 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LANGUAGE . ']', |
|
| 291 | + 'value' => $this->configuration_service->get_language_code(), |
|
| 292 | + 'description' => __( 'Each WordLift Key can be used only in one language. Pick yours.', 'wordlift' ), |
|
| 293 | + ) |
|
| 294 | + ); |
|
| 295 | + |
|
| 296 | + // Add the `country_code` field. |
|
| 297 | + add_settings_field( |
|
| 298 | + 'wl-country-code', |
|
| 299 | + _x( 'Country', 'wordlift' ), |
|
| 300 | + array( $this->country_select_element, 'render' ), |
|
| 301 | + 'wl_general_settings', |
|
| 302 | + 'wl_general_settings_section', |
|
| 303 | + array( |
|
| 304 | + 'id' => 'wl-country-code', |
|
| 305 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::COUNTRY_CODE . ']', |
|
| 306 | + 'value' => $this->configuration_service->get_country_code(), |
|
| 307 | + 'description' => __( 'Please select a country.', 'wordlift' ), |
|
| 308 | + 'notice' => __( 'The selected language is not supported in this country.</br>Please choose another country or language.', 'wordlift' ), |
|
| 309 | + ) |
|
| 310 | + ); |
|
| 311 | + |
|
| 312 | + // Add the `publisher` field. |
|
| 313 | + add_settings_field( |
|
| 314 | + 'wl-publisher-id', |
|
| 315 | + __( 'Publisher', 'wordlift' ), |
|
| 316 | + array( $this->publisher_element, 'render' ), |
|
| 317 | + 'wl_general_settings', |
|
| 318 | + 'wl_general_settings_section', |
|
| 319 | + array( |
|
| 320 | + 'id' => 'wl-publisher-id', |
|
| 321 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::PUBLISHER_ID . ']', |
|
| 322 | + ) |
|
| 323 | + ); |
|
| 324 | + |
|
| 325 | + // Add the `link by default` field. |
|
| 326 | + add_settings_field( |
|
| 327 | + 'wl-link-by-default', |
|
| 328 | + __( 'Link by Default', 'wordlift' ), |
|
| 329 | + array( $this->radio_input_element, 'render' ), |
|
| 330 | + 'wl_general_settings', |
|
| 331 | + 'wl_general_settings_section', |
|
| 332 | + array( |
|
| 333 | + 'id' => 'wl-link-by-default', |
|
| 334 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LINK_BY_DEFAULT . ']', |
|
| 335 | + 'value' => $this->configuration_service->is_link_by_default() ? 'yes' : 'no', |
|
| 336 | + 'description' => __( 'Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift' ), |
|
| 337 | + ) |
|
| 338 | + ); |
|
| 339 | + |
|
| 340 | + // Add the `diagnostic data` field. |
|
| 341 | + add_settings_field( |
|
| 342 | + 'wl-send-diagnostic', |
|
| 343 | + __( 'Send Diagnostic Data', 'wordlift' ), |
|
| 344 | + array( $this->radio_input_element, 'render' ), |
|
| 345 | + 'wl_general_settings', |
|
| 346 | + 'wl_general_settings_section', |
|
| 347 | + array( |
|
| 348 | + 'id' => 'wl-send-diagnostic', |
|
| 349 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::SEND_DIAGNOSTIC . ']', |
|
| 350 | + 'value' => 'yes' === $this->configuration_service->get_diagnostic_preferences() ? 'yes' : 'no', |
|
| 351 | + 'description' => __( 'Whether to send diagnostic data or not.', 'wordlift' ), |
|
| 352 | + ) |
|
| 353 | + ); |
|
| 354 | + |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * Filter the {@link Wordlift_Admin_Input_Element} in order to add the |
|
| 359 | + * `readonly` flag to the `wl-entity-base-path` input. |
|
| 360 | + * |
|
| 361 | + * @param array $args An array of {@link Wordlift_Admin_Input_Element} parameters. |
|
| 362 | + * |
|
| 363 | + * @return array The updated array. |
|
| 364 | + * @since 3.17.0 |
|
| 365 | + * |
|
| 366 | + */ |
|
| 367 | + public function entity_path_input_element_params( $args ) { |
|
| 368 | + |
|
| 369 | + // Bail out if it's not the `wl-entity-base-path`). |
|
| 370 | + if ( 'wl-entity-base-path' !== $args['id'] ) { |
|
| 371 | + return $args; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + // Set the readonly flag according to the entities count. |
|
| 375 | + $args['readonly'] = 0 < $this->entity_service->count(); |
|
| 376 | + |
|
| 377 | + // Return the updated args. |
|
| 378 | + return $args; |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * Sanitize the configuration settings to be stored. |
|
| 383 | + * |
|
| 384 | + * If a new entity is being created for the publisher, create it and set The |
|
| 385 | + * publisher setting. |
|
| 386 | + * |
|
| 387 | + * @param array $input The configuration settings array. |
|
| 388 | + * |
|
| 389 | + * @return array The sanitized input array. |
|
| 390 | + * @since 3.11.0 |
|
| 391 | + * |
|
| 392 | + */ |
|
| 393 | + function sanitize_callback( $input ) { |
|
| 394 | + |
|
| 395 | + // Validate the selected country. |
|
| 396 | + $this->validate_country(); |
|
| 397 | + |
|
| 398 | + // Check whether a publisher name has been set. |
|
| 399 | + if ( isset( $_POST['wl_publisher'] ) && ! empty( $_POST['wl_publisher']['name'] ) ) { // WPCS: CSRF, input var, sanitization ok. |
|
| 400 | + $name = $_POST['wl_publisher']['name']; // WPCS: CSRF, input var, sanitization ok. |
|
| 401 | + $type = $_POST['wl_publisher']['type']; // WPCS: CSRF, input var, sanitization ok. |
|
| 402 | + $thumbnail_id = $_POST['wl_publisher']['thumbnail_id'] ?: null; // WPCS: CSRF, input var, sanitization ok. |
|
| 403 | + |
|
| 404 | + // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 405 | + $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person' ); |
|
| 406 | + |
|
| 407 | + // Create an entity for the publisher and assign it to the input |
|
| 408 | + // parameter which WordPress automatically saves into the settings. |
|
| 409 | + $input['publisher_id'] = $this->entity_service->create( $name, $type_uri, $thumbnail_id, 'publish' ); |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + return $input; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + /** |
|
| 416 | + * Check whether the currently selected country supports the site language. |
|
| 417 | + * |
|
| 418 | + * @since 3.18.0 |
|
| 419 | + */ |
|
| 420 | + private function validate_country() { |
|
| 421 | + |
|
| 422 | + // Bail out if for some reason the country and language are not set. |
|
| 423 | + if ( |
|
| 424 | + empty( $_POST['wl_general_settings']['site_language'] ) && // WPCS: CSRF, input var, sanitization ok. |
|
| 425 | + empty( $_POST['wl_general_settings']['country_code'] ) // WPCS: CSRF, input var, sanitization ok. |
|
| 426 | + ) { |
|
| 427 | + return; |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + // Get the values. |
|
| 431 | + $language = $_POST['wl_general_settings']['site_language']; // WPCS: CSRF, input var, sanitization ok. |
|
| 432 | + $country = $_POST['wl_general_settings']['country_code']; // WPCS: CSRF, input var, sanitization ok. |
|
| 433 | + $codes = Wordlift_Countries::get_codes(); |
|
| 434 | + |
|
| 435 | + // Check whether the chosen country has language limitations |
|
| 436 | + // and whether the chosen language is supported for that country. |
|
| 437 | + if ( |
|
| 438 | + ! empty( $codes[ $country ] ) && |
|
| 439 | + ! in_array( $language, $codes[ $country ] ) |
|
| 440 | + ) { |
|
| 441 | + // Otherwise add an error. |
|
| 442 | + add_settings_error( |
|
| 443 | + 'wl-country-code', |
|
| 444 | + esc_attr( 'settings_updated' ), |
|
| 445 | + _x( 'The selected language is not supported for the currently chosen country. Please choose another country or language.', 'wordlift' ) |
|
| 446 | + ); |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | 450 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @since 3.11.0 |
| 105 | 105 | * |
| 106 | 106 | */ |
| 107 | - function __construct( $configuration_service, $entity_service, $input_element, $language_select_element, $country_select_element, $publisher_element, $radio_input_element ) { |
|
| 107 | + function __construct($configuration_service, $entity_service, $input_element, $language_select_element, $country_select_element, $publisher_element, $radio_input_element) { |
|
| 108 | 108 | |
| 109 | 109 | $this->configuration_service = $configuration_service; |
| 110 | 110 | $this->entity_service = $entity_service; |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | // JavaScript required for the settings page. |
| 191 | 191 | // @todo: try to move to the `wordlift-admin.bundle.js`. |
| 192 | - wp_enqueue_script( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.js', array( 'wp-util' ) ); |
|
| 193 | - wp_enqueue_style( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.css' ); |
|
| 192 | + wp_enqueue_script('wordlift-admin-settings-page', plugin_dir_url(dirname(__FILE__)).'admin/js/1/settings.js', array('wp-util')); |
|
| 193 | + wp_enqueue_style('wordlift-admin-settings-page', plugin_dir_url(dirname(__FILE__)).'admin/js/1/settings.css'); |
|
| 194 | 194 | |
| 195 | 195 | } |
| 196 | 196 | |
@@ -207,23 +207,23 @@ discard block |
||
| 207 | 207 | register_setting( |
| 208 | 208 | 'wl_general_settings', |
| 209 | 209 | 'wl_general_settings', |
| 210 | - array( $this, 'sanitize_callback' ) |
|
| 210 | + array($this, 'sanitize_callback') |
|
| 211 | 211 | ); |
| 212 | 212 | |
| 213 | 213 | // Add the general settings section. |
| 214 | 214 | add_settings_section( |
| 215 | 215 | 'wl_general_settings_section', // ID used to identify this section and with which to register options. |
| 216 | - '', // Section header. |
|
| 217 | - '', // Callback used to render the description of the section. |
|
| 216 | + '', // Section header. |
|
| 217 | + '', // Callback used to render the description of the section. |
|
| 218 | 218 | 'wl_general_settings' // Page on which to add this section of options. |
| 219 | 219 | ); |
| 220 | 220 | |
| 221 | 221 | $key_args = array( |
| 222 | 222 | 'id' => 'wl-key', |
| 223 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::KEY . ']', |
|
| 223 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::KEY.']', |
|
| 224 | 224 | 'value' => $this->configuration_service->get_key(), |
| 225 | - 'description' => __( 'Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift' ) |
|
| 226 | - . ' [' . get_option( 'home' ) . ']', |
|
| 225 | + 'description' => __('Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift') |
|
| 226 | + . ' ['.get_option('home').']', |
|
| 227 | 227 | ); |
| 228 | 228 | |
| 229 | 229 | // Before we were used to validate the key beforehand, but this means |
@@ -236,12 +236,12 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | // Add the `key` field. |
| 238 | 238 | add_settings_field( |
| 239 | - 'wl-key', // Element id used to identify the field throughout the theme. |
|
| 240 | - __( 'WordLift Key', 'wordlift' ), // The label to the left of the option interface element. |
|
| 239 | + 'wl-key', // Element id used to identify the field throughout the theme. |
|
| 240 | + __('WordLift Key', 'wordlift'), // The label to the left of the option interface element. |
|
| 241 | 241 | // The name of the function responsible for rendering the option interface. |
| 242 | - array( $this->input_element, 'render' ), |
|
| 243 | - 'wl_general_settings', // The page on which this option will be displayed. |
|
| 244 | - 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
| 242 | + array($this->input_element, 'render'), |
|
| 243 | + 'wl_general_settings', // The page on which this option will be displayed. |
|
| 244 | + 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
| 245 | 245 | $key_args // The array of arguments to pass to the callback. In this case, just a description. |
| 246 | 246 | ); |
| 247 | 247 | |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | $entity_base_path_args = array( |
| 250 | 250 | // The array of arguments to pass to the callback. In this case, just a description. |
| 251 | 251 | 'id' => 'wl-entity-base-path', |
| 252 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY . ']', |
|
| 252 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY.']', |
|
| 253 | 253 | 'value' => $this->configuration_service->get_entity_base_path(), |
| 254 | 254 | /* translators: Placeholders: %s - a link to FAQ's page. */ |
| 255 | - 'description' => sprintf( __( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift' ), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary' ), |
|
| 255 | + 'description' => sprintf(__('All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift'), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary'), |
|
| 256 | 256 | ); |
| 257 | 257 | |
| 258 | 258 | // The following call is very heavy on large web sites and is always run |
@@ -261,94 +261,94 @@ discard block |
||
| 261 | 261 | // |
| 262 | 262 | // It is now replaced by a filter to add the `readonly` flag to the |
| 263 | 263 | // input element when this is actually rendered. |
| 264 | - add_filter( 'wl_admin_input_element_params', array( |
|
| 264 | + add_filter('wl_admin_input_element_params', array( |
|
| 265 | 265 | $this, |
| 266 | 266 | 'entity_path_input_element_params', |
| 267 | - ) ); |
|
| 267 | + )); |
|
| 268 | 268 | |
| 269 | 269 | // Add the `wl_entity_base_path` field. |
| 270 | 270 | add_settings_field( |
| 271 | - 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
| 272 | - __( 'Entity Base Path', 'wordlift' ), // The label to the left of the option interface element |
|
| 271 | + 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
| 272 | + __('Entity Base Path', 'wordlift'), // The label to the left of the option interface element |
|
| 273 | 273 | // The name of the function responsible for rendering the option interface |
| 274 | - array( $this->input_element, 'render', ), |
|
| 275 | - 'wl_general_settings', // The page on which this option will be displayed |
|
| 276 | - 'wl_general_settings_section', // The name of the section to which this field belongs |
|
| 274 | + array($this->input_element, 'render',), |
|
| 275 | + 'wl_general_settings', // The page on which this option will be displayed |
|
| 276 | + 'wl_general_settings_section', // The name of the section to which this field belongs |
|
| 277 | 277 | $entity_base_path_args |
| 278 | 278 | ); |
| 279 | 279 | |
| 280 | 280 | // Add the `language_name` field. |
| 281 | 281 | add_settings_field( |
| 282 | 282 | 'wl-site-language', |
| 283 | - __( 'Site Language', 'wordlift' ), |
|
| 284 | - array( $this->language_select_element, 'render' ), |
|
| 283 | + __('Site Language', 'wordlift'), |
|
| 284 | + array($this->language_select_element, 'render'), |
|
| 285 | 285 | 'wl_general_settings', |
| 286 | 286 | 'wl_general_settings_section', |
| 287 | 287 | array( |
| 288 | 288 | // The array of arguments to pass to the callback. In this case, just a description. |
| 289 | 289 | 'id' => 'wl-site-language', |
| 290 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LANGUAGE . ']', |
|
| 290 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::LANGUAGE.']', |
|
| 291 | 291 | 'value' => $this->configuration_service->get_language_code(), |
| 292 | - 'description' => __( 'Each WordLift Key can be used only in one language. Pick yours.', 'wordlift' ), |
|
| 292 | + 'description' => __('Each WordLift Key can be used only in one language. Pick yours.', 'wordlift'), |
|
| 293 | 293 | ) |
| 294 | 294 | ); |
| 295 | 295 | |
| 296 | 296 | // Add the `country_code` field. |
| 297 | 297 | add_settings_field( |
| 298 | 298 | 'wl-country-code', |
| 299 | - _x( 'Country', 'wordlift' ), |
|
| 300 | - array( $this->country_select_element, 'render' ), |
|
| 299 | + _x('Country', 'wordlift'), |
|
| 300 | + array($this->country_select_element, 'render'), |
|
| 301 | 301 | 'wl_general_settings', |
| 302 | 302 | 'wl_general_settings_section', |
| 303 | 303 | array( |
| 304 | 304 | 'id' => 'wl-country-code', |
| 305 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::COUNTRY_CODE . ']', |
|
| 305 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::COUNTRY_CODE.']', |
|
| 306 | 306 | 'value' => $this->configuration_service->get_country_code(), |
| 307 | - 'description' => __( 'Please select a country.', 'wordlift' ), |
|
| 308 | - 'notice' => __( 'The selected language is not supported in this country.</br>Please choose another country or language.', 'wordlift' ), |
|
| 307 | + 'description' => __('Please select a country.', 'wordlift'), |
|
| 308 | + 'notice' => __('The selected language is not supported in this country.</br>Please choose another country or language.', 'wordlift'), |
|
| 309 | 309 | ) |
| 310 | 310 | ); |
| 311 | 311 | |
| 312 | 312 | // Add the `publisher` field. |
| 313 | 313 | add_settings_field( |
| 314 | 314 | 'wl-publisher-id', |
| 315 | - __( 'Publisher', 'wordlift' ), |
|
| 316 | - array( $this->publisher_element, 'render' ), |
|
| 315 | + __('Publisher', 'wordlift'), |
|
| 316 | + array($this->publisher_element, 'render'), |
|
| 317 | 317 | 'wl_general_settings', |
| 318 | 318 | 'wl_general_settings_section', |
| 319 | 319 | array( |
| 320 | 320 | 'id' => 'wl-publisher-id', |
| 321 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::PUBLISHER_ID . ']', |
|
| 321 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::PUBLISHER_ID.']', |
|
| 322 | 322 | ) |
| 323 | 323 | ); |
| 324 | 324 | |
| 325 | 325 | // Add the `link by default` field. |
| 326 | 326 | add_settings_field( |
| 327 | 327 | 'wl-link-by-default', |
| 328 | - __( 'Link by Default', 'wordlift' ), |
|
| 329 | - array( $this->radio_input_element, 'render' ), |
|
| 328 | + __('Link by Default', 'wordlift'), |
|
| 329 | + array($this->radio_input_element, 'render'), |
|
| 330 | 330 | 'wl_general_settings', |
| 331 | 331 | 'wl_general_settings_section', |
| 332 | 332 | array( |
| 333 | 333 | 'id' => 'wl-link-by-default', |
| 334 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LINK_BY_DEFAULT . ']', |
|
| 334 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::LINK_BY_DEFAULT.']', |
|
| 335 | 335 | 'value' => $this->configuration_service->is_link_by_default() ? 'yes' : 'no', |
| 336 | - 'description' => __( 'Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift' ), |
|
| 336 | + 'description' => __('Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift'), |
|
| 337 | 337 | ) |
| 338 | 338 | ); |
| 339 | 339 | |
| 340 | 340 | // Add the `diagnostic data` field. |
| 341 | 341 | add_settings_field( |
| 342 | 342 | 'wl-send-diagnostic', |
| 343 | - __( 'Send Diagnostic Data', 'wordlift' ), |
|
| 344 | - array( $this->radio_input_element, 'render' ), |
|
| 343 | + __('Send Diagnostic Data', 'wordlift'), |
|
| 344 | + array($this->radio_input_element, 'render'), |
|
| 345 | 345 | 'wl_general_settings', |
| 346 | 346 | 'wl_general_settings_section', |
| 347 | 347 | array( |
| 348 | 348 | 'id' => 'wl-send-diagnostic', |
| 349 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::SEND_DIAGNOSTIC . ']', |
|
| 349 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::SEND_DIAGNOSTIC.']', |
|
| 350 | 350 | 'value' => 'yes' === $this->configuration_service->get_diagnostic_preferences() ? 'yes' : 'no', |
| 351 | - 'description' => __( 'Whether to send diagnostic data or not.', 'wordlift' ), |
|
| 351 | + 'description' => __('Whether to send diagnostic data or not.', 'wordlift'), |
|
| 352 | 352 | ) |
| 353 | 353 | ); |
| 354 | 354 | |
@@ -364,10 +364,10 @@ discard block |
||
| 364 | 364 | * @since 3.17.0 |
| 365 | 365 | * |
| 366 | 366 | */ |
| 367 | - public function entity_path_input_element_params( $args ) { |
|
| 367 | + public function entity_path_input_element_params($args) { |
|
| 368 | 368 | |
| 369 | 369 | // Bail out if it's not the `wl-entity-base-path`). |
| 370 | - if ( 'wl-entity-base-path' !== $args['id'] ) { |
|
| 370 | + if ('wl-entity-base-path' !== $args['id']) { |
|
| 371 | 371 | return $args; |
| 372 | 372 | } |
| 373 | 373 | |
@@ -390,23 +390,23 @@ discard block |
||
| 390 | 390 | * @since 3.11.0 |
| 391 | 391 | * |
| 392 | 392 | */ |
| 393 | - function sanitize_callback( $input ) { |
|
| 393 | + function sanitize_callback($input) { |
|
| 394 | 394 | |
| 395 | 395 | // Validate the selected country. |
| 396 | 396 | $this->validate_country(); |
| 397 | 397 | |
| 398 | 398 | // Check whether a publisher name has been set. |
| 399 | - if ( isset( $_POST['wl_publisher'] ) && ! empty( $_POST['wl_publisher']['name'] ) ) { // WPCS: CSRF, input var, sanitization ok. |
|
| 399 | + if (isset($_POST['wl_publisher']) && ! empty($_POST['wl_publisher']['name'])) { // WPCS: CSRF, input var, sanitization ok. |
|
| 400 | 400 | $name = $_POST['wl_publisher']['name']; // WPCS: CSRF, input var, sanitization ok. |
| 401 | 401 | $type = $_POST['wl_publisher']['type']; // WPCS: CSRF, input var, sanitization ok. |
| 402 | 402 | $thumbnail_id = $_POST['wl_publisher']['thumbnail_id'] ?: null; // WPCS: CSRF, input var, sanitization ok. |
| 403 | 403 | |
| 404 | 404 | // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
| 405 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person' ); |
|
| 405 | + $type_uri = sprintf('http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person'); |
|
| 406 | 406 | |
| 407 | 407 | // Create an entity for the publisher and assign it to the input |
| 408 | 408 | // parameter which WordPress automatically saves into the settings. |
| 409 | - $input['publisher_id'] = $this->entity_service->create( $name, $type_uri, $thumbnail_id, 'publish' ); |
|
| 409 | + $input['publisher_id'] = $this->entity_service->create($name, $type_uri, $thumbnail_id, 'publish'); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | return $input; |
@@ -421,8 +421,8 @@ discard block |
||
| 421 | 421 | |
| 422 | 422 | // Bail out if for some reason the country and language are not set. |
| 423 | 423 | if ( |
| 424 | - empty( $_POST['wl_general_settings']['site_language'] ) && // WPCS: CSRF, input var, sanitization ok. |
|
| 425 | - empty( $_POST['wl_general_settings']['country_code'] ) // WPCS: CSRF, input var, sanitization ok. |
|
| 424 | + empty($_POST['wl_general_settings']['site_language']) && // WPCS: CSRF, input var, sanitization ok. |
|
| 425 | + empty($_POST['wl_general_settings']['country_code']) // WPCS: CSRF, input var, sanitization ok. |
|
| 426 | 426 | ) { |
| 427 | 427 | return; |
| 428 | 428 | } |
@@ -435,14 +435,14 @@ discard block |
||
| 435 | 435 | // Check whether the chosen country has language limitations |
| 436 | 436 | // and whether the chosen language is supported for that country. |
| 437 | 437 | if ( |
| 438 | - ! empty( $codes[ $country ] ) && |
|
| 439 | - ! in_array( $language, $codes[ $country ] ) |
|
| 438 | + ! empty($codes[$country]) && |
|
| 439 | + ! in_array($language, $codes[$country]) |
|
| 440 | 440 | ) { |
| 441 | 441 | // Otherwise add an error. |
| 442 | 442 | add_settings_error( |
| 443 | 443 | 'wl-country-code', |
| 444 | - esc_attr( 'settings_updated' ), |
|
| 445 | - _x( 'The selected language is not supported for the currently chosen country. Please choose another country or language.', 'wordlift' ) |
|
| 444 | + esc_attr('settings_updated'), |
|
| 445 | + _x('The selected language is not supported for the currently chosen country. Please choose another country or language.', 'wordlift') |
|
| 446 | 446 | ); |
| 447 | 447 | } |
| 448 | 448 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -28,140 +28,140 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | class Wordlift_Admin_Setup { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 33 | - * |
|
| 34 | - * @since 3.9.0 |
|
| 35 | - * @access private |
|
| 36 | - * @var Wordlift_Configuration_Service A {@link Wordlift_Configuration_Service} instance. |
|
| 37 | - */ |
|
| 38 | - private $configuration_service; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 42 | - * |
|
| 43 | - * @since 3.9.0 |
|
| 44 | - * @access private |
|
| 45 | - * @var Wordlift_Key_Validation_Service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 46 | - */ |
|
| 47 | - private $key_validation_service; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * A {@link Wordlift_Entity_Service} instance. |
|
| 51 | - * |
|
| 52 | - * @since 3.9.0 |
|
| 53 | - * @access private |
|
| 54 | - * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 55 | - */ |
|
| 56 | - private $entity_service; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 60 | - * |
|
| 61 | - * @since 3.20.0 |
|
| 62 | - * @access private |
|
| 63 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 64 | - */ |
|
| 65 | - private $language_select_element; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 69 | - * |
|
| 70 | - * @since 3.20.0 |
|
| 71 | - * @access private |
|
| 72 | - * @var \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 73 | - */ |
|
| 74 | - private $country_select_element; |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Initialize the class and set its properties. |
|
| 78 | - * |
|
| 79 | - * @param \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 80 | - * @param \Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 81 | - * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 82 | - * @param \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 83 | - * @param \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 84 | - * |
|
| 85 | - * @since 3.9.0 |
|
| 86 | - * |
|
| 87 | - */ |
|
| 88 | - public function __construct( $configuration_service, $key_validation_service, $entity_service, $language_select_element, $country_select_element ) { |
|
| 89 | - |
|
| 90 | - // Set a reference to the configuration service. |
|
| 91 | - $this->configuration_service = $configuration_service; |
|
| 92 | - |
|
| 93 | - // Set a reference to the key validation service. |
|
| 94 | - $this->key_validation_service = $key_validation_service; |
|
| 95 | - |
|
| 96 | - // Set a reference to the entity service. |
|
| 97 | - $this->entity_service = $entity_service; |
|
| 98 | - |
|
| 99 | - // Set a reference to the UI elements language and country. |
|
| 100 | - $this->language_select_element = $language_select_element; |
|
| 101 | - $this->country_select_element = $country_select_element; |
|
| 102 | - |
|
| 103 | - // Hook to some WP's events: |
|
| 104 | - // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up. |
|
| 105 | - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
| 106 | - |
|
| 107 | - // Hook to `admin_menu` in order to add our own setup wizard page. |
|
| 108 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 109 | - |
|
| 110 | - // Triggered when the user accesses the admin area, we decide whether to show our own wizard. |
|
| 111 | - add_action( 'admin_init', array( $this, 'show_page' ) ); |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Filter: wl_feature__enable__notices. |
|
| 115 | - * |
|
| 116 | - * @param bool whether the notices needs to be enabled or not. |
|
| 117 | - * |
|
| 118 | - * @return bool |
|
| 119 | - * @since 3.27.6 |
|
| 120 | - */ |
|
| 121 | - if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
| 122 | - // Hook to `admin_notices` to display our notices. |
|
| 123 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Hook to `admin_init` and redirect to WordLift's setup page if the `_wl_activation_redirect` transient flag is set. |
|
| 129 | - * |
|
| 130 | - * @since 3.9.0 |
|
| 131 | - */ |
|
| 132 | - public function admin_init() { |
|
| 133 | - |
|
| 134 | - // If the `_wl_activation_redirect` is set, the redirect to the setup page. |
|
| 135 | - if ( get_transient( '_wl_activation_redirect' ) ) { |
|
| 136 | - delete_transient( '_wl_activation_redirect' ); |
|
| 137 | - |
|
| 138 | - // If the user asked to skip the wizard then comply. |
|
| 139 | - if ( $this->configuration_service->is_skip_wizard() ) { |
|
| 140 | - return; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // If we're already on the page or the user doesn't have permissions, return. |
|
| 144 | - if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { |
|
| 145 | - return; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - // Finally redirect to the setup page. |
|
| 149 | - wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) ); |
|
| 150 | - |
|
| 151 | - exit; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Generate an admin notice suggesting to start the wizard if there is no configuration. |
|
| 158 | - * |
|
| 159 | - * @since 3.9.0 |
|
| 160 | - */ |
|
| 161 | - public function admin_notices() { |
|
| 162 | - |
|
| 163 | - // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard. |
|
| 164 | - if ( '' === $this->configuration_service->get_key() && ! $this->configuration_service->is_skip_wizard() ) { ?> |
|
| 31 | + /** |
|
| 32 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 33 | + * |
|
| 34 | + * @since 3.9.0 |
|
| 35 | + * @access private |
|
| 36 | + * @var Wordlift_Configuration_Service A {@link Wordlift_Configuration_Service} instance. |
|
| 37 | + */ |
|
| 38 | + private $configuration_service; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 42 | + * |
|
| 43 | + * @since 3.9.0 |
|
| 44 | + * @access private |
|
| 45 | + * @var Wordlift_Key_Validation_Service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 46 | + */ |
|
| 47 | + private $key_validation_service; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * A {@link Wordlift_Entity_Service} instance. |
|
| 51 | + * |
|
| 52 | + * @since 3.9.0 |
|
| 53 | + * @access private |
|
| 54 | + * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 55 | + */ |
|
| 56 | + private $entity_service; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 60 | + * |
|
| 61 | + * @since 3.20.0 |
|
| 62 | + * @access private |
|
| 63 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 64 | + */ |
|
| 65 | + private $language_select_element; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 69 | + * |
|
| 70 | + * @since 3.20.0 |
|
| 71 | + * @access private |
|
| 72 | + * @var \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 73 | + */ |
|
| 74 | + private $country_select_element; |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Initialize the class and set its properties. |
|
| 78 | + * |
|
| 79 | + * @param \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 80 | + * @param \Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 81 | + * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 82 | + * @param \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 83 | + * @param \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 84 | + * |
|
| 85 | + * @since 3.9.0 |
|
| 86 | + * |
|
| 87 | + */ |
|
| 88 | + public function __construct( $configuration_service, $key_validation_service, $entity_service, $language_select_element, $country_select_element ) { |
|
| 89 | + |
|
| 90 | + // Set a reference to the configuration service. |
|
| 91 | + $this->configuration_service = $configuration_service; |
|
| 92 | + |
|
| 93 | + // Set a reference to the key validation service. |
|
| 94 | + $this->key_validation_service = $key_validation_service; |
|
| 95 | + |
|
| 96 | + // Set a reference to the entity service. |
|
| 97 | + $this->entity_service = $entity_service; |
|
| 98 | + |
|
| 99 | + // Set a reference to the UI elements language and country. |
|
| 100 | + $this->language_select_element = $language_select_element; |
|
| 101 | + $this->country_select_element = $country_select_element; |
|
| 102 | + |
|
| 103 | + // Hook to some WP's events: |
|
| 104 | + // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up. |
|
| 105 | + add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
| 106 | + |
|
| 107 | + // Hook to `admin_menu` in order to add our own setup wizard page. |
|
| 108 | + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 109 | + |
|
| 110 | + // Triggered when the user accesses the admin area, we decide whether to show our own wizard. |
|
| 111 | + add_action( 'admin_init', array( $this, 'show_page' ) ); |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Filter: wl_feature__enable__notices. |
|
| 115 | + * |
|
| 116 | + * @param bool whether the notices needs to be enabled or not. |
|
| 117 | + * |
|
| 118 | + * @return bool |
|
| 119 | + * @since 3.27.6 |
|
| 120 | + */ |
|
| 121 | + if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
| 122 | + // Hook to `admin_notices` to display our notices. |
|
| 123 | + add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Hook to `admin_init` and redirect to WordLift's setup page if the `_wl_activation_redirect` transient flag is set. |
|
| 129 | + * |
|
| 130 | + * @since 3.9.0 |
|
| 131 | + */ |
|
| 132 | + public function admin_init() { |
|
| 133 | + |
|
| 134 | + // If the `_wl_activation_redirect` is set, the redirect to the setup page. |
|
| 135 | + if ( get_transient( '_wl_activation_redirect' ) ) { |
|
| 136 | + delete_transient( '_wl_activation_redirect' ); |
|
| 137 | + |
|
| 138 | + // If the user asked to skip the wizard then comply. |
|
| 139 | + if ( $this->configuration_service->is_skip_wizard() ) { |
|
| 140 | + return; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // If we're already on the page or the user doesn't have permissions, return. |
|
| 144 | + if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { |
|
| 145 | + return; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + // Finally redirect to the setup page. |
|
| 149 | + wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) ); |
|
| 150 | + |
|
| 151 | + exit; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Generate an admin notice suggesting to start the wizard if there is no configuration. |
|
| 158 | + * |
|
| 159 | + * @since 3.9.0 |
|
| 160 | + */ |
|
| 161 | + public function admin_notices() { |
|
| 162 | + |
|
| 163 | + // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard. |
|
| 164 | + if ( '' === $this->configuration_service->get_key() && ! $this->configuration_service->is_skip_wizard() ) { ?> |
|
| 165 | 165 | <div id="wl-message" class="updated"> |
| 166 | 166 | <p><?php esc_html_e( 'Welcome to WordLift – You‘re almost ready to start', 'wordlift' ); ?></p> |
| 167 | 167 | <p class="submit"> |
@@ -173,140 +173,140 @@ discard block |
||
| 173 | 173 | </div> |
| 174 | 174 | <?php } |
| 175 | 175 | |
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Handle hiding the wizard notices by user request. |
|
| 180 | - * |
|
| 181 | - * @since 3.9.0 |
|
| 182 | - */ |
|
| 183 | - public function hide_notices() { |
|
| 184 | - |
|
| 185 | - // If it's not a `wl-hide-notice` or the nonce is not set, return. |
|
| 186 | - if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) { |
|
| 187 | - return; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // If the nonce is invalid, return an error. |
|
| 191 | - if ( ! wp_verify_nonce( $_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce' ) ) { |
|
| 192 | - wp_die( __( 'Action failed. Please refresh the page and retry.', 'wordlift' ) ); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - // If the user doesn't have the right privileges, return an error. |
|
| 196 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 197 | - wp_die( __( 'Cheatin’ huh?', 'wordlift' ) ); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - // Store a flag telling to skip the wizard. |
|
| 201 | - $this->configuration_service->set_skip_wizard( true ); |
|
| 202 | - |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * Register the wizard page to be able to access it. |
|
| 207 | - * |
|
| 208 | - * @since 3.9.0 |
|
| 209 | - */ |
|
| 210 | - public function admin_menu() { |
|
| 211 | - /** |
|
| 212 | - * |
|
| 213 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1209 |
|
| 214 | - * @since 3.27.7 |
|
| 215 | - */ |
|
| 216 | - // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu. |
|
| 217 | - add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' ); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Displays the wizard page. |
|
| 222 | - * |
|
| 223 | - * @since 3.9.0 |
|
| 224 | - */ |
|
| 225 | - public function show_page() { |
|
| 226 | - |
|
| 227 | - // First check if we are in the wizard page at all, if not do nothing. |
|
| 228 | - if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) { |
|
| 229 | - return; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - // If it's a POST and the `wl-save-configuration` action is set, save the configuration. |
|
| 233 | - if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) { |
|
| 234 | - |
|
| 235 | - // Check the nonce and the user capabilities. |
|
| 236 | - check_admin_referer( 'wl-save-configuration' ); |
|
| 237 | - |
|
| 238 | - // Check if the user has the right privileges. |
|
| 239 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 240 | - wp_die( __( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) ); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - // Save the configuration. |
|
| 244 | - $this->save_configuration( $_POST ); |
|
| 245 | - |
|
| 246 | - // Redirect to the admin's page. |
|
| 247 | - wp_redirect( admin_url() ); |
|
| 248 | - |
|
| 249 | - exit; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - $language_select = $this->language_select_element; |
|
| 253 | - $country_select = $this->country_select_element; |
|
| 254 | - |
|
| 255 | - include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-setup.php'; |
|
| 256 | - |
|
| 257 | - exit; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * Save WordLift's configuration using the provided parameters. |
|
| 262 | - * |
|
| 263 | - * @param array $params An array of configuration parameters. |
|
| 264 | - * |
|
| 265 | - * @since 3.9.0 |
|
| 266 | - * |
|
| 267 | - */ |
|
| 268 | - public function save_configuration( $params ) { |
|
| 269 | - |
|
| 270 | - // We have the following parameters: |
|
| 271 | - // `key`, holding WL's key, |
|
| 272 | - // `vocabulary`, holding the vocabulary path, |
|
| 273 | - // `wl-site-language`, with the language code (e.g. `en`), |
|
| 274 | - // `wl-country-code` with the country code (e.g. `us`), |
|
| 275 | - // `share-diagnostic`, the user preferences about sharing data with us. |
|
| 276 | - // `user_type`, the user type either `personal` or `company`, |
|
| 277 | - // `name`, with the `personal` or `company`'s name, |
|
| 278 | - // `logo`, the attachment id for the `personal` or `company` entity. |
|
| 279 | - |
|
| 280 | - // Store the key: |
|
| 281 | - $this->configuration_service->set_key( $params['key'] ); |
|
| 282 | - |
|
| 283 | - // Store the vocabulary path: |
|
| 284 | - $this->configuration_service->set_entity_base_path( $params['vocabulary'] ); |
|
| 285 | - |
|
| 286 | - // Store the site's language: |
|
| 287 | - $this->configuration_service->set_language_code( $params['wl-site-language'] ); |
|
| 288 | - |
|
| 289 | - // Store the site's country: |
|
| 290 | - $this->configuration_service->set_country_code( $params['wl-country-code'] ); |
|
| 291 | - |
|
| 292 | - // Store the preferences in variable, because if the checkbox is not checked |
|
| 293 | - // the `share-diagnostic` will not exists in `$params` array. |
|
| 294 | - $share_diagnostic_preferences = empty( $params['share-diagnostic'] ) ? 'no' : 'yes'; |
|
| 295 | - |
|
| 296 | - // Store the diagnostic preferences: |
|
| 297 | - $this->configuration_service->set_diagnostic_preferences( $share_diagnostic_preferences ); |
|
| 298 | - |
|
| 299 | - // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 300 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' ); |
|
| 301 | - |
|
| 302 | - // Create an entity for the publisher. |
|
| 303 | - $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' ); |
|
| 304 | - |
|
| 305 | - // Store the publisher entity post id in the configuration. |
|
| 306 | - $this->configuration_service->set_publisher_id( $publisher_post_id ); |
|
| 307 | - |
|
| 308 | - flush_rewrite_rules(); // Needed because of possible change to the entity base path. |
|
| 309 | - |
|
| 310 | - } |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Handle hiding the wizard notices by user request. |
|
| 180 | + * |
|
| 181 | + * @since 3.9.0 |
|
| 182 | + */ |
|
| 183 | + public function hide_notices() { |
|
| 184 | + |
|
| 185 | + // If it's not a `wl-hide-notice` or the nonce is not set, return. |
|
| 186 | + if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) { |
|
| 187 | + return; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // If the nonce is invalid, return an error. |
|
| 191 | + if ( ! wp_verify_nonce( $_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce' ) ) { |
|
| 192 | + wp_die( __( 'Action failed. Please refresh the page and retry.', 'wordlift' ) ); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + // If the user doesn't have the right privileges, return an error. |
|
| 196 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 197 | + wp_die( __( 'Cheatin’ huh?', 'wordlift' ) ); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + // Store a flag telling to skip the wizard. |
|
| 201 | + $this->configuration_service->set_skip_wizard( true ); |
|
| 202 | + |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * Register the wizard page to be able to access it. |
|
| 207 | + * |
|
| 208 | + * @since 3.9.0 |
|
| 209 | + */ |
|
| 210 | + public function admin_menu() { |
|
| 211 | + /** |
|
| 212 | + * |
|
| 213 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1209 |
|
| 214 | + * @since 3.27.7 |
|
| 215 | + */ |
|
| 216 | + // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu. |
|
| 217 | + add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' ); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Displays the wizard page. |
|
| 222 | + * |
|
| 223 | + * @since 3.9.0 |
|
| 224 | + */ |
|
| 225 | + public function show_page() { |
|
| 226 | + |
|
| 227 | + // First check if we are in the wizard page at all, if not do nothing. |
|
| 228 | + if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) { |
|
| 229 | + return; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + // If it's a POST and the `wl-save-configuration` action is set, save the configuration. |
|
| 233 | + if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) { |
|
| 234 | + |
|
| 235 | + // Check the nonce and the user capabilities. |
|
| 236 | + check_admin_referer( 'wl-save-configuration' ); |
|
| 237 | + |
|
| 238 | + // Check if the user has the right privileges. |
|
| 239 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 240 | + wp_die( __( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) ); |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + // Save the configuration. |
|
| 244 | + $this->save_configuration( $_POST ); |
|
| 245 | + |
|
| 246 | + // Redirect to the admin's page. |
|
| 247 | + wp_redirect( admin_url() ); |
|
| 248 | + |
|
| 249 | + exit; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + $language_select = $this->language_select_element; |
|
| 253 | + $country_select = $this->country_select_element; |
|
| 254 | + |
|
| 255 | + include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-setup.php'; |
|
| 256 | + |
|
| 257 | + exit; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * Save WordLift's configuration using the provided parameters. |
|
| 262 | + * |
|
| 263 | + * @param array $params An array of configuration parameters. |
|
| 264 | + * |
|
| 265 | + * @since 3.9.0 |
|
| 266 | + * |
|
| 267 | + */ |
|
| 268 | + public function save_configuration( $params ) { |
|
| 269 | + |
|
| 270 | + // We have the following parameters: |
|
| 271 | + // `key`, holding WL's key, |
|
| 272 | + // `vocabulary`, holding the vocabulary path, |
|
| 273 | + // `wl-site-language`, with the language code (e.g. `en`), |
|
| 274 | + // `wl-country-code` with the country code (e.g. `us`), |
|
| 275 | + // `share-diagnostic`, the user preferences about sharing data with us. |
|
| 276 | + // `user_type`, the user type either `personal` or `company`, |
|
| 277 | + // `name`, with the `personal` or `company`'s name, |
|
| 278 | + // `logo`, the attachment id for the `personal` or `company` entity. |
|
| 279 | + |
|
| 280 | + // Store the key: |
|
| 281 | + $this->configuration_service->set_key( $params['key'] ); |
|
| 282 | + |
|
| 283 | + // Store the vocabulary path: |
|
| 284 | + $this->configuration_service->set_entity_base_path( $params['vocabulary'] ); |
|
| 285 | + |
|
| 286 | + // Store the site's language: |
|
| 287 | + $this->configuration_service->set_language_code( $params['wl-site-language'] ); |
|
| 288 | + |
|
| 289 | + // Store the site's country: |
|
| 290 | + $this->configuration_service->set_country_code( $params['wl-country-code'] ); |
|
| 291 | + |
|
| 292 | + // Store the preferences in variable, because if the checkbox is not checked |
|
| 293 | + // the `share-diagnostic` will not exists in `$params` array. |
|
| 294 | + $share_diagnostic_preferences = empty( $params['share-diagnostic'] ) ? 'no' : 'yes'; |
|
| 295 | + |
|
| 296 | + // Store the diagnostic preferences: |
|
| 297 | + $this->configuration_service->set_diagnostic_preferences( $share_diagnostic_preferences ); |
|
| 298 | + |
|
| 299 | + // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 300 | + $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' ); |
|
| 301 | + |
|
| 302 | + // Create an entity for the publisher. |
|
| 303 | + $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' ); |
|
| 304 | + |
|
| 305 | + // Store the publisher entity post id in the configuration. |
|
| 306 | + $this->configuration_service->set_publisher_id( $publisher_post_id ); |
|
| 307 | + |
|
| 308 | + flush_rewrite_rules(); // Needed because of possible change to the entity base path. |
|
| 309 | + |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | 312 | } |
@@ -4,54 +4,54 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Features_Registry { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * @var array<Feature> |
|
| 9 | - */ |
|
| 10 | - private $features = array(); |
|
| 11 | - |
|
| 12 | - private static $instance = null; |
|
| 13 | - |
|
| 14 | - public static function get_instance() { |
|
| 15 | - if ( self::$instance === null ) { |
|
| 16 | - self::$instance = new Features_Registry(); |
|
| 17 | - } |
|
| 18 | - |
|
| 19 | - return self::$instance; |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @param $feature Feature |
|
| 24 | - */ |
|
| 25 | - public function register_feature( $feature ) { |
|
| 26 | - $this->features[] = $feature; |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @param $feature_slug string |
|
| 31 | - * @param $default_value bool |
|
| 32 | - * @param $callback callable |
|
| 33 | - */ |
|
| 34 | - public function register_feature_from_slug( $feature_slug, $default_value, $callback ) { |
|
| 35 | - $this->features[] = new Feature( |
|
| 36 | - $feature_slug, |
|
| 37 | - $default_value, |
|
| 38 | - $callback |
|
| 39 | - ); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - public function initialize_all_features() { |
|
| 43 | - foreach ( $this->features as $feature ) { |
|
| 44 | - /** |
|
| 45 | - * @var $feature Feature |
|
| 46 | - */ |
|
| 47 | - $feature_slug = $feature->feature_slug; |
|
| 48 | - if ( apply_filters( "wl_feature__enable__${feature_slug}", $feature->default_value ) ) { |
|
| 49 | - call_user_func( $feature->callback ); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - public function clear_all() { |
|
| 55 | - $this->features = array(); |
|
| 56 | - } |
|
| 7 | + /** |
|
| 8 | + * @var array<Feature> |
|
| 9 | + */ |
|
| 10 | + private $features = array(); |
|
| 11 | + |
|
| 12 | + private static $instance = null; |
|
| 13 | + |
|
| 14 | + public static function get_instance() { |
|
| 15 | + if ( self::$instance === null ) { |
|
| 16 | + self::$instance = new Features_Registry(); |
|
| 17 | + } |
|
| 18 | + |
|
| 19 | + return self::$instance; |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @param $feature Feature |
|
| 24 | + */ |
|
| 25 | + public function register_feature( $feature ) { |
|
| 26 | + $this->features[] = $feature; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @param $feature_slug string |
|
| 31 | + * @param $default_value bool |
|
| 32 | + * @param $callback callable |
|
| 33 | + */ |
|
| 34 | + public function register_feature_from_slug( $feature_slug, $default_value, $callback ) { |
|
| 35 | + $this->features[] = new Feature( |
|
| 36 | + $feature_slug, |
|
| 37 | + $default_value, |
|
| 38 | + $callback |
|
| 39 | + ); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + public function initialize_all_features() { |
|
| 43 | + foreach ( $this->features as $feature ) { |
|
| 44 | + /** |
|
| 45 | + * @var $feature Feature |
|
| 46 | + */ |
|
| 47 | + $feature_slug = $feature->feature_slug; |
|
| 48 | + if ( apply_filters( "wl_feature__enable__${feature_slug}", $feature->default_value ) ) { |
|
| 49 | + call_user_func( $feature->callback ); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + public function clear_all() { |
|
| 55 | + $this->features = array(); |
|
| 56 | + } |
|
| 57 | 57 | } |
| 58 | 58 | \ No newline at end of file |
@@ -3,115 +3,115 @@ |
||
| 3 | 3 | namespace Wordlift\Features; |
| 4 | 4 | |
| 5 | 5 | class Response_Adapter { |
| 6 | - const WL_FEATURES = '_wl_features'; |
|
| 7 | - const WL_1 = 'wl1'; |
|
| 6 | + const WL_FEATURES = '_wl_features'; |
|
| 7 | + const WL_1 = 'wl1'; |
|
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * @var \Wordlift_Log_Service |
|
| 11 | - */ |
|
| 12 | - private $log; |
|
| 9 | + /** |
|
| 10 | + * @var \Wordlift_Log_Service |
|
| 11 | + */ |
|
| 12 | + private $log; |
|
| 13 | 13 | |
| 14 | - function __construct() { |
|
| 14 | + function __construct() { |
|
| 15 | 15 | |
| 16 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 16 | + $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 17 | 17 | |
| 18 | - // Filter responses from the API calls to update the enabled features. |
|
| 19 | - add_filter( 'wl_api_service__response', array( $this, 'response' ), 10, 1 ); |
|
| 18 | + // Filter responses from the API calls to update the enabled features. |
|
| 19 | + add_filter( 'wl_api_service__response', array( $this, 'response' ), 10, 1 ); |
|
| 20 | 20 | |
| 21 | - // Initialize from `$_ENV`: this is currently required for Unit Tests, since `tests/bootstrap.php` loads WordLift |
|
| 22 | - // before it can actually query the enabled features via HTTP (mock), which would prevent files from being included. |
|
| 21 | + // Initialize from `$_ENV`: this is currently required for Unit Tests, since `tests/bootstrap.php` loads WordLift |
|
| 22 | + // before it can actually query the enabled features via HTTP (mock), which would prevent files from being included. |
|
| 23 | 23 | // $this->init_from_env(); |
| 24 | 24 | |
| 25 | - // Register the `wl_features__enable__{feature-name}` filters. |
|
| 26 | - $this->register_filters(); |
|
| 25 | + // Register the `wl_features__enable__{feature-name}` filters. |
|
| 26 | + $this->register_filters(); |
|
| 27 | 27 | |
| 28 | - // Hook to updates to the features setting to refresh the features' filters. |
|
| 29 | - add_action( 'update_option_' . self::WL_FEATURES, array( $this, 'register_filters' ), 10, 0 ); |
|
| 28 | + // Hook to updates to the features setting to refresh the features' filters. |
|
| 29 | + add_action( 'update_option_' . self::WL_FEATURES, array( $this, 'register_filters' ), 10, 0 ); |
|
| 30 | 30 | |
| 31 | - } |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - function response( $response ) { |
|
| 33 | + function response( $response ) { |
|
| 34 | 34 | |
| 35 | - $headers = wp_remote_retrieve_headers( $response ); |
|
| 35 | + $headers = wp_remote_retrieve_headers( $response ); |
|
| 36 | 36 | |
| 37 | - // Bail out if the `wl1` header isn't defined. |
|
| 38 | - if ( ! isset( $headers[ self::WL_1 ] ) ) { |
|
| 39 | - return $response; |
|
| 40 | - } |
|
| 41 | - $wl1_as_base64_string = $headers[ self::WL_1 ]; |
|
| 42 | - $wl1 = json_decode( base64_decode( $wl1_as_base64_string ), true ); |
|
| 37 | + // Bail out if the `wl1` header isn't defined. |
|
| 38 | + if ( ! isset( $headers[ self::WL_1 ] ) ) { |
|
| 39 | + return $response; |
|
| 40 | + } |
|
| 41 | + $wl1_as_base64_string = $headers[ self::WL_1 ]; |
|
| 42 | + $wl1 = json_decode( base64_decode( $wl1_as_base64_string ), true ); |
|
| 43 | 43 | |
| 44 | - $this->log->debug( "WL1 [ encoded :: $wl1_as_base64_string ] " . var_export( $wl1, true ) ); |
|
| 44 | + $this->log->debug( "WL1 [ encoded :: $wl1_as_base64_string ] " . var_export( $wl1, true ) ); |
|
| 45 | 45 | |
| 46 | 46 | |
| 47 | - $updated_features = $wl1['features']; |
|
| 47 | + $updated_features = $wl1['features']; |
|
| 48 | 48 | |
| 49 | - $existing_features = get_option( self::WL_FEATURES, array() ); |
|
| 49 | + $existing_features = get_option( self::WL_FEATURES, array() ); |
|
| 50 | 50 | |
| 51 | - // Loop through updated features. |
|
| 52 | - foreach ( $updated_features as $feature_slug => $new_value ) { |
|
| 51 | + // Loop through updated features. |
|
| 52 | + foreach ( $updated_features as $feature_slug => $new_value ) { |
|
| 53 | 53 | |
| 54 | - // We cant pass false because that indicates if the feature is active or not, null is used to represent the features which are |
|
| 55 | - // not set before. |
|
| 56 | - $old_value = array_key_exists( $feature_slug, $existing_features ) ? $existing_features[ $feature_slug ] : null; |
|
| 54 | + // We cant pass false because that indicates if the feature is active or not, null is used to represent the features which are |
|
| 55 | + // not set before. |
|
| 56 | + $old_value = array_key_exists( $feature_slug, $existing_features ) ? $existing_features[ $feature_slug ] : null; |
|
| 57 | 57 | |
| 58 | - if ( $old_value !== $new_value ) { |
|
| 59 | - /** |
|
| 60 | - * @param $feature_slug string The feature slug. |
|
| 61 | - * @param $old_value null | boolean Null represents the feature flag was not set before. |
|
| 62 | - * @param $new_value boolean True or false. |
|
| 63 | - * |
|
| 64 | - * @since 3.32.1 |
|
| 65 | - * Hook : `wl_feature__change__{feature_slug}` |
|
| 66 | - * Action hook to be fired when there is a change in feature state. |
|
| 67 | - */ |
|
| 68 | - do_action( "wl_feature__change__${feature_slug}", $new_value, $old_value, $feature_slug ); |
|
| 69 | - } |
|
| 58 | + if ( $old_value !== $new_value ) { |
|
| 59 | + /** |
|
| 60 | + * @param $feature_slug string The feature slug. |
|
| 61 | + * @param $old_value null | boolean Null represents the feature flag was not set before. |
|
| 62 | + * @param $new_value boolean True or false. |
|
| 63 | + * |
|
| 64 | + * @since 3.32.1 |
|
| 65 | + * Hook : `wl_feature__change__{feature_slug}` |
|
| 66 | + * Action hook to be fired when there is a change in feature state. |
|
| 67 | + */ |
|
| 68 | + do_action( "wl_feature__change__${feature_slug}", $new_value, $old_value, $feature_slug ); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | - if ( isset( $updated_features ) ) { |
|
| 74 | + if ( isset( $updated_features ) ) { |
|
| 75 | 75 | |
| 76 | - if ( update_option( self::WL_FEATURES, (array) $updated_features, true ) ) { |
|
| 77 | - $this->register_filters(); |
|
| 78 | - } |
|
| 79 | - } |
|
| 76 | + if ( update_option( self::WL_FEATURES, (array) $updated_features, true ) ) { |
|
| 77 | + $this->register_filters(); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - return $response; |
|
| 82 | - } |
|
| 81 | + return $response; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Registers the feature filters. |
|
| 86 | - */ |
|
| 87 | - function register_filters() { |
|
| 84 | + /** |
|
| 85 | + * Registers the feature filters. |
|
| 86 | + */ |
|
| 87 | + function register_filters() { |
|
| 88 | 88 | |
| 89 | - $this->log->debug( 'Registering feature filters...' ); |
|
| 89 | + $this->log->debug( 'Registering feature filters...' ); |
|
| 90 | 90 | |
| 91 | - foreach ( (array) get_option( self::WL_FEATURES, array() ) as $name => $enabled ) { |
|
| 92 | - // Remove previous filters. |
|
| 93 | - remove_filter( "wl_feature__enable__${name}", '__return_true' ); |
|
| 94 | - remove_filter( "wl_feature__enable__${name}", '__return_false' ); |
|
| 91 | + foreach ( (array) get_option( self::WL_FEATURES, array() ) as $name => $enabled ) { |
|
| 92 | + // Remove previous filters. |
|
| 93 | + remove_filter( "wl_feature__enable__${name}", '__return_true' ); |
|
| 94 | + remove_filter( "wl_feature__enable__${name}", '__return_false' ); |
|
| 95 | 95 | |
| 96 | - $callback = ( $enabled ? '__return_true' : '__return_false' ); |
|
| 97 | - add_filter( "wl_feature__enable__${name}", $callback ); |
|
| 98 | - } |
|
| 96 | + $callback = ( $enabled ? '__return_true' : '__return_false' ); |
|
| 97 | + add_filter( "wl_feature__enable__${name}", $callback ); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - private function init_from_env() { |
|
| 103 | - $features = array_reduce( array_filter( array_keys( $_ENV ), function ( $key ) { |
|
| 104 | - return preg_match( '~^WL_FEATURES__.*~', $key ); |
|
| 105 | - } ), function ( $features, $env ) { |
|
| 106 | - $name = strtolower( str_replace( '_', '-', substr( $env, strlen( 'WL_FEATURES__' ) ) ) ); |
|
| 107 | - $value = wp_validate_boolean( getenv( $env ) ); |
|
| 108 | - $features[ $name ] = $value; |
|
| 102 | + private function init_from_env() { |
|
| 103 | + $features = array_reduce( array_filter( array_keys( $_ENV ), function ( $key ) { |
|
| 104 | + return preg_match( '~^WL_FEATURES__.*~', $key ); |
|
| 105 | + } ), function ( $features, $env ) { |
|
| 106 | + $name = strtolower( str_replace( '_', '-', substr( $env, strlen( 'WL_FEATURES__' ) ) ) ); |
|
| 107 | + $value = wp_validate_boolean( getenv( $env ) ); |
|
| 108 | + $features[ $name ] = $value; |
|
| 109 | 109 | |
| 110 | - return $features; |
|
| 111 | - }, array() ); |
|
| 110 | + return $features; |
|
| 111 | + }, array() ); |
|
| 112 | 112 | |
| 113 | - update_option( self::WL_FEATURES, (array) $features, true ); |
|
| 113 | + update_option( self::WL_FEATURES, (array) $features, true ); |
|
| 114 | 114 | |
| 115 | - } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | } |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | function __construct() { |
| 15 | 15 | |
| 16 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 16 | + $this->log = \Wordlift_Log_Service::get_logger(get_class()); |
|
| 17 | 17 | |
| 18 | 18 | // Filter responses from the API calls to update the enabled features. |
| 19 | - add_filter( 'wl_api_service__response', array( $this, 'response' ), 10, 1 ); |
|
| 19 | + add_filter('wl_api_service__response', array($this, 'response'), 10, 1); |
|
| 20 | 20 | |
| 21 | 21 | // Initialize from `$_ENV`: this is currently required for Unit Tests, since `tests/bootstrap.php` loads WordLift |
| 22 | 22 | // before it can actually query the enabled features via HTTP (mock), which would prevent files from being included. |
@@ -26,36 +26,36 @@ discard block |
||
| 26 | 26 | $this->register_filters(); |
| 27 | 27 | |
| 28 | 28 | // Hook to updates to the features setting to refresh the features' filters. |
| 29 | - add_action( 'update_option_' . self::WL_FEATURES, array( $this, 'register_filters' ), 10, 0 ); |
|
| 29 | + add_action('update_option_'.self::WL_FEATURES, array($this, 'register_filters'), 10, 0); |
|
| 30 | 30 | |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - function response( $response ) { |
|
| 33 | + function response($response) { |
|
| 34 | 34 | |
| 35 | - $headers = wp_remote_retrieve_headers( $response ); |
|
| 35 | + $headers = wp_remote_retrieve_headers($response); |
|
| 36 | 36 | |
| 37 | 37 | // Bail out if the `wl1` header isn't defined. |
| 38 | - if ( ! isset( $headers[ self::WL_1 ] ) ) { |
|
| 38 | + if ( ! isset($headers[self::WL_1])) { |
|
| 39 | 39 | return $response; |
| 40 | 40 | } |
| 41 | - $wl1_as_base64_string = $headers[ self::WL_1 ]; |
|
| 42 | - $wl1 = json_decode( base64_decode( $wl1_as_base64_string ), true ); |
|
| 41 | + $wl1_as_base64_string = $headers[self::WL_1]; |
|
| 42 | + $wl1 = json_decode(base64_decode($wl1_as_base64_string), true); |
|
| 43 | 43 | |
| 44 | - $this->log->debug( "WL1 [ encoded :: $wl1_as_base64_string ] " . var_export( $wl1, true ) ); |
|
| 44 | + $this->log->debug("WL1 [ encoded :: $wl1_as_base64_string ] ".var_export($wl1, true)); |
|
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | $updated_features = $wl1['features']; |
| 48 | 48 | |
| 49 | - $existing_features = get_option( self::WL_FEATURES, array() ); |
|
| 49 | + $existing_features = get_option(self::WL_FEATURES, array()); |
|
| 50 | 50 | |
| 51 | 51 | // Loop through updated features. |
| 52 | - foreach ( $updated_features as $feature_slug => $new_value ) { |
|
| 52 | + foreach ($updated_features as $feature_slug => $new_value) { |
|
| 53 | 53 | |
| 54 | 54 | // We cant pass false because that indicates if the feature is active or not, null is used to represent the features which are |
| 55 | 55 | // not set before. |
| 56 | - $old_value = array_key_exists( $feature_slug, $existing_features ) ? $existing_features[ $feature_slug ] : null; |
|
| 56 | + $old_value = array_key_exists($feature_slug, $existing_features) ? $existing_features[$feature_slug] : null; |
|
| 57 | 57 | |
| 58 | - if ( $old_value !== $new_value ) { |
|
| 58 | + if ($old_value !== $new_value) { |
|
| 59 | 59 | /** |
| 60 | 60 | * @param $feature_slug string The feature slug. |
| 61 | 61 | * @param $old_value null | boolean Null represents the feature flag was not set before. |
@@ -65,15 +65,15 @@ discard block |
||
| 65 | 65 | * Hook : `wl_feature__change__{feature_slug}` |
| 66 | 66 | * Action hook to be fired when there is a change in feature state. |
| 67 | 67 | */ |
| 68 | - do_action( "wl_feature__change__${feature_slug}", $new_value, $old_value, $feature_slug ); |
|
| 68 | + do_action("wl_feature__change__${feature_slug}", $new_value, $old_value, $feature_slug); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | |
| 74 | - if ( isset( $updated_features ) ) { |
|
| 74 | + if (isset($updated_features)) { |
|
| 75 | 75 | |
| 76 | - if ( update_option( self::WL_FEATURES, (array) $updated_features, true ) ) { |
|
| 76 | + if (update_option(self::WL_FEATURES, (array) $updated_features, true)) { |
|
| 77 | 77 | $this->register_filters(); |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -86,31 +86,31 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | function register_filters() { |
| 88 | 88 | |
| 89 | - $this->log->debug( 'Registering feature filters...' ); |
|
| 89 | + $this->log->debug('Registering feature filters...'); |
|
| 90 | 90 | |
| 91 | - foreach ( (array) get_option( self::WL_FEATURES, array() ) as $name => $enabled ) { |
|
| 91 | + foreach ((array) get_option(self::WL_FEATURES, array()) as $name => $enabled) { |
|
| 92 | 92 | // Remove previous filters. |
| 93 | - remove_filter( "wl_feature__enable__${name}", '__return_true' ); |
|
| 94 | - remove_filter( "wl_feature__enable__${name}", '__return_false' ); |
|
| 93 | + remove_filter("wl_feature__enable__${name}", '__return_true'); |
|
| 94 | + remove_filter("wl_feature__enable__${name}", '__return_false'); |
|
| 95 | 95 | |
| 96 | - $callback = ( $enabled ? '__return_true' : '__return_false' ); |
|
| 97 | - add_filter( "wl_feature__enable__${name}", $callback ); |
|
| 96 | + $callback = ($enabled ? '__return_true' : '__return_false'); |
|
| 97 | + add_filter("wl_feature__enable__${name}", $callback); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | private function init_from_env() { |
| 103 | - $features = array_reduce( array_filter( array_keys( $_ENV ), function ( $key ) { |
|
| 104 | - return preg_match( '~^WL_FEATURES__.*~', $key ); |
|
| 105 | - } ), function ( $features, $env ) { |
|
| 106 | - $name = strtolower( str_replace( '_', '-', substr( $env, strlen( 'WL_FEATURES__' ) ) ) ); |
|
| 107 | - $value = wp_validate_boolean( getenv( $env ) ); |
|
| 108 | - $features[ $name ] = $value; |
|
| 103 | + $features = array_reduce(array_filter(array_keys($_ENV), function($key) { |
|
| 104 | + return preg_match('~^WL_FEATURES__.*~', $key); |
|
| 105 | + } ), function($features, $env) { |
|
| 106 | + $name = strtolower(str_replace('_', '-', substr($env, strlen('WL_FEATURES__')))); |
|
| 107 | + $value = wp_validate_boolean(getenv($env)); |
|
| 108 | + $features[$name] = $value; |
|
| 109 | 109 | |
| 110 | 110 | return $features; |
| 111 | - }, array() ); |
|
| 111 | + }, array()); |
|
| 112 | 112 | |
| 113 | - update_option( self::WL_FEATURES, (array) $features, true ); |
|
| 113 | + update_option(self::WL_FEATURES, (array) $features, true); |
|
| 114 | 114 | |
| 115 | 115 | } |
| 116 | 116 | |
@@ -11,191 +11,191 @@ |
||
| 11 | 11 | class Entity_Type_Setter { |
| 12 | 12 | |
| 13 | 13 | |
| 14 | - const STARTER_PLAN = 'entity-types-starter'; |
|
| 15 | - |
|
| 16 | - const PROFESSIONAL_PLAN = 'entity-types-professional'; |
|
| 17 | - |
|
| 18 | - const BUSINESS_PLAN = 'entity-types-business'; |
|
| 19 | - |
|
| 20 | - public function __construct() { |
|
| 21 | - add_action( "wl_feature__change__entity-types-starter", array( $this, 'wl_entity_types_feature_changed' ), 10, 3 ); |
|
| 22 | - add_action( "wl_feature__change__entity-types-professional", array( $this, 'wl_entity_types_feature_changed' ), 10, 3 ); |
|
| 23 | - add_action( "wl_feature__change__entity-types-business", array( $this, 'wl_entity_types_feature_changed' ), 10, 3 ); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - public function wl_entity_types_feature_changed( $new_value, $old_value, $feature_slug ) { |
|
| 28 | - |
|
| 29 | - // If the entity types is not set by server, then return early. |
|
| 30 | - if ( ! $new_value ) { |
|
| 31 | - return; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - $entity_types_data = self::get_entity_types_by_feature_flag( $feature_slug ); |
|
| 36 | - |
|
| 37 | - // If we dont have entity types returned, then dont reset the entity types, return early. |
|
| 38 | - if ( ! $entity_types_data ) { |
|
| 39 | - return; |
|
| 40 | - } |
|
| 41 | - // Repopulate the ones returned by package type. |
|
| 42 | - foreach ( $entity_types_data as $entity_type_data ) { |
|
| 43 | - |
|
| 44 | - $schema_label = $entity_type_data['label']; |
|
| 45 | - |
|
| 46 | - $term_exists = get_term_by( 'name', $schema_label, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) instanceof \WP_Term; |
|
| 47 | - |
|
| 48 | - if ( $term_exists ) { |
|
| 49 | - // Dont create term if it already exists. |
|
| 50 | - continue; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - $term_data = wp_insert_term( |
|
| 55 | - $schema_label, |
|
| 56 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 57 | - array( |
|
| 58 | - 'description' => $entity_type_data['description'], |
|
| 59 | - 'slug' => $entity_type_data['slug'] |
|
| 60 | - ) |
|
| 61 | - ); |
|
| 62 | - |
|
| 63 | - $term_id = $term_data['term_id']; |
|
| 64 | - |
|
| 65 | - update_term_meta( $term_id, '_wl_uri', 'http://schema.org/' . $schema_label ); |
|
| 66 | - update_term_meta( $term_id, '_wl_name', $schema_label ); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - public static function get_starter_entity_types() { |
|
| 73 | - return array( |
|
| 74 | - array( |
|
| 75 | - 'label' => 'Person', |
|
| 76 | - 'description' => 'A person (or a music artist).', |
|
| 77 | - 'slug' => 'person' |
|
| 78 | - ), |
|
| 79 | - array( |
|
| 80 | - 'label' => 'Thing', |
|
| 81 | - 'description' => 'A generic thing (something that doesn\'t fit in the previous definitions.', |
|
| 82 | - 'slug' => 'thing' |
|
| 83 | - ), |
|
| 84 | - |
|
| 85 | - array( |
|
| 86 | - 'label' => 'Place', |
|
| 87 | - 'description' => 'A place.', |
|
| 88 | - 'slug' => 'place' |
|
| 89 | - ), |
|
| 90 | - |
|
| 91 | - array( |
|
| 92 | - 'label' => 'CreativeWork', |
|
| 93 | - 'description' => 'A creative work (or a Music Album).', |
|
| 94 | - 'slug' => 'creative-work' |
|
| 95 | - ), |
|
| 96 | - array( |
|
| 97 | - 'label' => 'Organization', |
|
| 98 | - 'description' => 'An organization, including a government or a newspaper.', |
|
| 99 | - 'slug' => 'organization' |
|
| 100 | - ), |
|
| 101 | - |
|
| 102 | - array( |
|
| 103 | - 'label' => 'Article', |
|
| 104 | - 'description' => 'An article, such as a news article or piece of investigative report. Newspapers and magazines have articles of many different types and this is intended to cover them all.', |
|
| 105 | - 'slug' => 'article' |
|
| 106 | - ), |
|
| 107 | - |
|
| 108 | - array( |
|
| 109 | - 'label' => 'WebSite', |
|
| 110 | - 'description' => 'A WebSite is a set of related web pages and other items typically served from a single web domain and accessible via URLs.', |
|
| 111 | - 'slug' => 'web-site' |
|
| 112 | - ), |
|
| 113 | - |
|
| 114 | - array( |
|
| 115 | - 'label' => 'NewsArticle', |
|
| 116 | - 'description' => 'A NewsArticle is an article whose content reports news, or provides background context and supporting materials for understanding the news.', |
|
| 117 | - 'slug' => 'news-article' |
|
| 118 | - ), |
|
| 119 | - |
|
| 120 | - array( |
|
| 121 | - 'label' => 'AboutPage', |
|
| 122 | - 'description' => 'An About page.', |
|
| 123 | - 'slug' => 'about-page' |
|
| 124 | - ), |
|
| 125 | - |
|
| 126 | - array( |
|
| 127 | - 'label' => 'ContactPage', |
|
| 128 | - 'description' => 'A Contact Page.', |
|
| 129 | - 'slug' => 'contact-page' |
|
| 130 | - ) |
|
| 131 | - |
|
| 132 | - ); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - public static function get_professional_entity_types() { |
|
| 137 | - return array( |
|
| 138 | - |
|
| 139 | - array( |
|
| 140 | - 'label' => 'FAQPage', |
|
| 141 | - 'description' => 'A FAQPage is a WebPage presenting one or more "Frequently asked questions".', |
|
| 142 | - 'slug' => 'faq-page' |
|
| 143 | - ), |
|
| 144 | - array( |
|
| 145 | - 'label' => 'LocalBusiness', |
|
| 146 | - 'description' => 'A particular physical business or branch of an organization. Examples of LocalBusiness include a restaurant, a particular branch of a restaurant chain, a branch of a bank, a medical practice, a club, a bowling alley, etc.', |
|
| 147 | - 'slug' => 'local-business' |
|
| 148 | - |
|
| 149 | - ), |
|
| 150 | - array( |
|
| 151 | - 'label' => 'Recipe', |
|
| 152 | - 'description' => 'A recipe', |
|
| 153 | - 'slug' => 'recipe' |
|
| 154 | - ), |
|
| 155 | - array( |
|
| 156 | - 'label' => 'PodcastEpisode', |
|
| 157 | - 'description' => 'A single episode of a podcast series.', |
|
| 158 | - 'slug' => 'podcast-episode' |
|
| 159 | - ), |
|
| 160 | - array( |
|
| 161 | - 'label' => 'Course', |
|
| 162 | - 'description' => 'A description of an educational course which may be offered as distinct instances at which take place at different times or take place at different locations, or be offered through different media or modes of study.', |
|
| 163 | - 'slug' => 'course' |
|
| 164 | - ), |
|
| 165 | - array( |
|
| 166 | - 'label' => 'Event', |
|
| 167 | - 'description' => 'An event happening at a certain time and location, such as a concert, lecture, or festival.', |
|
| 168 | - 'slug' => 'event' |
|
| 169 | - ), |
|
| 170 | - array( |
|
| 171 | - 'label' => 'Review', |
|
| 172 | - 'description' => 'A review of an item - for example, of a restaurant, movie, or store.', |
|
| 173 | - 'slug' => 'review' |
|
| 174 | - ), |
|
| 175 | - |
|
| 176 | - ); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - private static function get_entity_types_by_feature_flag( $package_type ) { |
|
| 181 | - |
|
| 182 | - switch ( $package_type ) { |
|
| 183 | - case self::STARTER_PLAN: |
|
| 184 | - return self::get_starter_entity_types(); |
|
| 185 | - case self::BUSINESS_PLAN: |
|
| 186 | - case self::PROFESSIONAL_PLAN: |
|
| 187 | - // We return same entity types for professional and business plans. |
|
| 188 | - // Business plan should have sync schema ui feature enabled, to sync all the entity types. |
|
| 189 | - return array_merge( |
|
| 190 | - self::get_starter_entity_types(), |
|
| 191 | - self::get_professional_entity_types() |
|
| 192 | - ); |
|
| 193 | - default: |
|
| 194 | - return array(); |
|
| 195 | - |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - } |
|
| 14 | + const STARTER_PLAN = 'entity-types-starter'; |
|
| 15 | + |
|
| 16 | + const PROFESSIONAL_PLAN = 'entity-types-professional'; |
|
| 17 | + |
|
| 18 | + const BUSINESS_PLAN = 'entity-types-business'; |
|
| 19 | + |
|
| 20 | + public function __construct() { |
|
| 21 | + add_action( "wl_feature__change__entity-types-starter", array( $this, 'wl_entity_types_feature_changed' ), 10, 3 ); |
|
| 22 | + add_action( "wl_feature__change__entity-types-professional", array( $this, 'wl_entity_types_feature_changed' ), 10, 3 ); |
|
| 23 | + add_action( "wl_feature__change__entity-types-business", array( $this, 'wl_entity_types_feature_changed' ), 10, 3 ); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + public function wl_entity_types_feature_changed( $new_value, $old_value, $feature_slug ) { |
|
| 28 | + |
|
| 29 | + // If the entity types is not set by server, then return early. |
|
| 30 | + if ( ! $new_value ) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + $entity_types_data = self::get_entity_types_by_feature_flag( $feature_slug ); |
|
| 36 | + |
|
| 37 | + // If we dont have entity types returned, then dont reset the entity types, return early. |
|
| 38 | + if ( ! $entity_types_data ) { |
|
| 39 | + return; |
|
| 40 | + } |
|
| 41 | + // Repopulate the ones returned by package type. |
|
| 42 | + foreach ( $entity_types_data as $entity_type_data ) { |
|
| 43 | + |
|
| 44 | + $schema_label = $entity_type_data['label']; |
|
| 45 | + |
|
| 46 | + $term_exists = get_term_by( 'name', $schema_label, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) instanceof \WP_Term; |
|
| 47 | + |
|
| 48 | + if ( $term_exists ) { |
|
| 49 | + // Dont create term if it already exists. |
|
| 50 | + continue; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + $term_data = wp_insert_term( |
|
| 55 | + $schema_label, |
|
| 56 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 57 | + array( |
|
| 58 | + 'description' => $entity_type_data['description'], |
|
| 59 | + 'slug' => $entity_type_data['slug'] |
|
| 60 | + ) |
|
| 61 | + ); |
|
| 62 | + |
|
| 63 | + $term_id = $term_data['term_id']; |
|
| 64 | + |
|
| 65 | + update_term_meta( $term_id, '_wl_uri', 'http://schema.org/' . $schema_label ); |
|
| 66 | + update_term_meta( $term_id, '_wl_name', $schema_label ); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + public static function get_starter_entity_types() { |
|
| 73 | + return array( |
|
| 74 | + array( |
|
| 75 | + 'label' => 'Person', |
|
| 76 | + 'description' => 'A person (or a music artist).', |
|
| 77 | + 'slug' => 'person' |
|
| 78 | + ), |
|
| 79 | + array( |
|
| 80 | + 'label' => 'Thing', |
|
| 81 | + 'description' => 'A generic thing (something that doesn\'t fit in the previous definitions.', |
|
| 82 | + 'slug' => 'thing' |
|
| 83 | + ), |
|
| 84 | + |
|
| 85 | + array( |
|
| 86 | + 'label' => 'Place', |
|
| 87 | + 'description' => 'A place.', |
|
| 88 | + 'slug' => 'place' |
|
| 89 | + ), |
|
| 90 | + |
|
| 91 | + array( |
|
| 92 | + 'label' => 'CreativeWork', |
|
| 93 | + 'description' => 'A creative work (or a Music Album).', |
|
| 94 | + 'slug' => 'creative-work' |
|
| 95 | + ), |
|
| 96 | + array( |
|
| 97 | + 'label' => 'Organization', |
|
| 98 | + 'description' => 'An organization, including a government or a newspaper.', |
|
| 99 | + 'slug' => 'organization' |
|
| 100 | + ), |
|
| 101 | + |
|
| 102 | + array( |
|
| 103 | + 'label' => 'Article', |
|
| 104 | + 'description' => 'An article, such as a news article or piece of investigative report. Newspapers and magazines have articles of many different types and this is intended to cover them all.', |
|
| 105 | + 'slug' => 'article' |
|
| 106 | + ), |
|
| 107 | + |
|
| 108 | + array( |
|
| 109 | + 'label' => 'WebSite', |
|
| 110 | + 'description' => 'A WebSite is a set of related web pages and other items typically served from a single web domain and accessible via URLs.', |
|
| 111 | + 'slug' => 'web-site' |
|
| 112 | + ), |
|
| 113 | + |
|
| 114 | + array( |
|
| 115 | + 'label' => 'NewsArticle', |
|
| 116 | + 'description' => 'A NewsArticle is an article whose content reports news, or provides background context and supporting materials for understanding the news.', |
|
| 117 | + 'slug' => 'news-article' |
|
| 118 | + ), |
|
| 119 | + |
|
| 120 | + array( |
|
| 121 | + 'label' => 'AboutPage', |
|
| 122 | + 'description' => 'An About page.', |
|
| 123 | + 'slug' => 'about-page' |
|
| 124 | + ), |
|
| 125 | + |
|
| 126 | + array( |
|
| 127 | + 'label' => 'ContactPage', |
|
| 128 | + 'description' => 'A Contact Page.', |
|
| 129 | + 'slug' => 'contact-page' |
|
| 130 | + ) |
|
| 131 | + |
|
| 132 | + ); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + public static function get_professional_entity_types() { |
|
| 137 | + return array( |
|
| 138 | + |
|
| 139 | + array( |
|
| 140 | + 'label' => 'FAQPage', |
|
| 141 | + 'description' => 'A FAQPage is a WebPage presenting one or more "Frequently asked questions".', |
|
| 142 | + 'slug' => 'faq-page' |
|
| 143 | + ), |
|
| 144 | + array( |
|
| 145 | + 'label' => 'LocalBusiness', |
|
| 146 | + 'description' => 'A particular physical business or branch of an organization. Examples of LocalBusiness include a restaurant, a particular branch of a restaurant chain, a branch of a bank, a medical practice, a club, a bowling alley, etc.', |
|
| 147 | + 'slug' => 'local-business' |
|
| 148 | + |
|
| 149 | + ), |
|
| 150 | + array( |
|
| 151 | + 'label' => 'Recipe', |
|
| 152 | + 'description' => 'A recipe', |
|
| 153 | + 'slug' => 'recipe' |
|
| 154 | + ), |
|
| 155 | + array( |
|
| 156 | + 'label' => 'PodcastEpisode', |
|
| 157 | + 'description' => 'A single episode of a podcast series.', |
|
| 158 | + 'slug' => 'podcast-episode' |
|
| 159 | + ), |
|
| 160 | + array( |
|
| 161 | + 'label' => 'Course', |
|
| 162 | + 'description' => 'A description of an educational course which may be offered as distinct instances at which take place at different times or take place at different locations, or be offered through different media or modes of study.', |
|
| 163 | + 'slug' => 'course' |
|
| 164 | + ), |
|
| 165 | + array( |
|
| 166 | + 'label' => 'Event', |
|
| 167 | + 'description' => 'An event happening at a certain time and location, such as a concert, lecture, or festival.', |
|
| 168 | + 'slug' => 'event' |
|
| 169 | + ), |
|
| 170 | + array( |
|
| 171 | + 'label' => 'Review', |
|
| 172 | + 'description' => 'A review of an item - for example, of a restaurant, movie, or store.', |
|
| 173 | + 'slug' => 'review' |
|
| 174 | + ), |
|
| 175 | + |
|
| 176 | + ); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + private static function get_entity_types_by_feature_flag( $package_type ) { |
|
| 181 | + |
|
| 182 | + switch ( $package_type ) { |
|
| 183 | + case self::STARTER_PLAN: |
|
| 184 | + return self::get_starter_entity_types(); |
|
| 185 | + case self::BUSINESS_PLAN: |
|
| 186 | + case self::PROFESSIONAL_PLAN: |
|
| 187 | + // We return same entity types for professional and business plans. |
|
| 188 | + // Business plan should have sync schema ui feature enabled, to sync all the entity types. |
|
| 189 | + return array_merge( |
|
| 190 | + self::get_starter_entity_types(), |
|
| 191 | + self::get_professional_entity_types() |
|
| 192 | + ); |
|
| 193 | + default: |
|
| 194 | + return array(); |
|
| 195 | + |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | 200 | |
| 201 | 201 | } |
| 202 | 202 | \ No newline at end of file |
@@ -18,34 +18,34 @@ discard block |
||
| 18 | 18 | const BUSINESS_PLAN = 'entity-types-business'; |
| 19 | 19 | |
| 20 | 20 | public function __construct() { |
| 21 | - add_action( "wl_feature__change__entity-types-starter", array( $this, 'wl_entity_types_feature_changed' ), 10, 3 ); |
|
| 22 | - add_action( "wl_feature__change__entity-types-professional", array( $this, 'wl_entity_types_feature_changed' ), 10, 3 ); |
|
| 23 | - add_action( "wl_feature__change__entity-types-business", array( $this, 'wl_entity_types_feature_changed' ), 10, 3 ); |
|
| 21 | + add_action("wl_feature__change__entity-types-starter", array($this, 'wl_entity_types_feature_changed'), 10, 3); |
|
| 22 | + add_action("wl_feature__change__entity-types-professional", array($this, 'wl_entity_types_feature_changed'), 10, 3); |
|
| 23 | + add_action("wl_feature__change__entity-types-business", array($this, 'wl_entity_types_feature_changed'), 10, 3); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - public function wl_entity_types_feature_changed( $new_value, $old_value, $feature_slug ) { |
|
| 27 | + public function wl_entity_types_feature_changed($new_value, $old_value, $feature_slug) { |
|
| 28 | 28 | |
| 29 | 29 | // If the entity types is not set by server, then return early. |
| 30 | - if ( ! $new_value ) { |
|
| 30 | + if ( ! $new_value) { |
|
| 31 | 31 | return; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - $entity_types_data = self::get_entity_types_by_feature_flag( $feature_slug ); |
|
| 35 | + $entity_types_data = self::get_entity_types_by_feature_flag($feature_slug); |
|
| 36 | 36 | |
| 37 | 37 | // If we dont have entity types returned, then dont reset the entity types, return early. |
| 38 | - if ( ! $entity_types_data ) { |
|
| 38 | + if ( ! $entity_types_data) { |
|
| 39 | 39 | return; |
| 40 | 40 | } |
| 41 | 41 | // Repopulate the ones returned by package type. |
| 42 | - foreach ( $entity_types_data as $entity_type_data ) { |
|
| 42 | + foreach ($entity_types_data as $entity_type_data) { |
|
| 43 | 43 | |
| 44 | 44 | $schema_label = $entity_type_data['label']; |
| 45 | 45 | |
| 46 | - $term_exists = get_term_by( 'name', $schema_label, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) instanceof \WP_Term; |
|
| 46 | + $term_exists = get_term_by('name', $schema_label, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME) instanceof \WP_Term; |
|
| 47 | 47 | |
| 48 | - if ( $term_exists ) { |
|
| 48 | + if ($term_exists) { |
|
| 49 | 49 | // Dont create term if it already exists. |
| 50 | 50 | continue; |
| 51 | 51 | } |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $term_id = $term_data['term_id']; |
| 64 | 64 | |
| 65 | - update_term_meta( $term_id, '_wl_uri', 'http://schema.org/' . $schema_label ); |
|
| 66 | - update_term_meta( $term_id, '_wl_name', $schema_label ); |
|
| 65 | + update_term_meta($term_id, '_wl_uri', 'http://schema.org/'.$schema_label); |
|
| 66 | + update_term_meta($term_id, '_wl_name', $schema_label); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | } |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
| 180 | - private static function get_entity_types_by_feature_flag( $package_type ) { |
|
| 180 | + private static function get_entity_types_by_feature_flag($package_type) { |
|
| 181 | 181 | |
| 182 | - switch ( $package_type ) { |
|
| 182 | + switch ($package_type) { |
|
| 183 | 183 | case self::STARTER_PLAN: |
| 184 | 184 | return self::get_starter_entity_types(); |
| 185 | 185 | case self::BUSINESS_PLAN: |