@@ -29,1208 +29,1208 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class Wordlift { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | - * the plugin. |
|
| 35 | - * |
|
| 36 | - * @since 1.0.0 |
|
| 37 | - * @access protected |
|
| 38 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | - */ |
|
| 40 | - protected $loader; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The unique identifier of this plugin. |
|
| 44 | - * |
|
| 45 | - * @since 1.0.0 |
|
| 46 | - * @access protected |
|
| 47 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | - */ |
|
| 49 | - protected $plugin_name; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * The current version of the plugin. |
|
| 53 | - * |
|
| 54 | - * @since 1.0.0 |
|
| 55 | - * @access protected |
|
| 56 | - * @var string $version The current version of the plugin. |
|
| 57 | - */ |
|
| 58 | - protected $version; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 62 | - * |
|
| 63 | - * @since 3.12.0 |
|
| 64 | - * @access protected |
|
| 65 | - * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 66 | - */ |
|
| 67 | - protected $tinymce_adapter; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * The Thumbnail service. |
|
| 71 | - * |
|
| 72 | - * @since 3.1.5 |
|
| 73 | - * @access private |
|
| 74 | - * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 75 | - */ |
|
| 76 | - private $thumbnail_service; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * The UI service. |
|
| 80 | - * |
|
| 81 | - * @since 3.2.0 |
|
| 82 | - * @access private |
|
| 83 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 84 | - */ |
|
| 85 | - private $ui_service; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * The Schema service. |
|
| 89 | - * |
|
| 90 | - * @since 3.3.0 |
|
| 91 | - * @access private |
|
| 92 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 93 | - */ |
|
| 94 | - private $schema_service; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * The Entity service. |
|
| 98 | - * |
|
| 99 | - * @since 3.1.0 |
|
| 100 | - * @access protected |
|
| 101 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 102 | - */ |
|
| 103 | - protected $entity_service; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * The Topic Taxonomy service. |
|
| 107 | - * |
|
| 108 | - * @since 3.5.0 |
|
| 109 | - * @access private |
|
| 110 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 111 | - */ |
|
| 112 | - private $topic_taxonomy_service; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * The User service. |
|
| 116 | - * |
|
| 117 | - * @since 3.1.7 |
|
| 118 | - * @access protected |
|
| 119 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 120 | - */ |
|
| 121 | - protected $user_service; |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * The Timeline service. |
|
| 125 | - * |
|
| 126 | - * @since 3.1.0 |
|
| 127 | - * @access private |
|
| 128 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 129 | - */ |
|
| 130 | - private $timeline_service; |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * The Redirect service. |
|
| 134 | - * |
|
| 135 | - * @since 3.2.0 |
|
| 136 | - * @access private |
|
| 137 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 138 | - */ |
|
| 139 | - private $redirect_service; |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * The Notice service. |
|
| 143 | - * |
|
| 144 | - * @since 3.3.0 |
|
| 145 | - * @access private |
|
| 146 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 147 | - */ |
|
| 148 | - private $notice_service; |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * The Entity list customization. |
|
| 152 | - * |
|
| 153 | - * @since 3.3.0 |
|
| 154 | - * @access private |
|
| 155 | - * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 156 | - */ |
|
| 157 | - private $entity_list_service; |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * The Entity Types Taxonomy Walker. |
|
| 161 | - * |
|
| 162 | - * @since 3.1.0 |
|
| 163 | - * @access private |
|
| 164 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 165 | - */ |
|
| 166 | - private $entity_types_taxonomy_walker; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * The ShareThis service. |
|
| 170 | - * |
|
| 171 | - * @since 3.2.0 |
|
| 172 | - * @access private |
|
| 173 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 174 | - */ |
|
| 175 | - private $sharethis_service; |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * The PrimaShop adapter. |
|
| 179 | - * |
|
| 180 | - * @since 3.2.3 |
|
| 181 | - * @access private |
|
| 182 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 183 | - */ |
|
| 184 | - private $primashop_adapter; |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * The WordLift Dashboard adapter. |
|
| 188 | - * |
|
| 189 | - * @since 3.4.0 |
|
| 190 | - * @access private |
|
| 191 | - * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 192 | - */ |
|
| 193 | - private $dashboard_service; |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * The entity type service. |
|
| 197 | - * |
|
| 198 | - * @since 3.6.0 |
|
| 199 | - * @access private |
|
| 200 | - * @var \Wordlift_Entity_Post_Type_Service |
|
| 201 | - */ |
|
| 202 | - private $entity_post_type_service; |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 206 | - * |
|
| 207 | - * @since 3.6.0 |
|
| 208 | - * @access private |
|
| 209 | - * @var \Wordlift_Entity_Link_Service |
|
| 210 | - */ |
|
| 211 | - private $entity_link_service; |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 215 | - * |
|
| 216 | - * @var 3.6.0 |
|
| 217 | - * @access private |
|
| 218 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 219 | - */ |
|
| 220 | - private $sparql_service; |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * A {@link Wordlift_Import_Service} instance. |
|
| 224 | - * |
|
| 225 | - * @since 3.6.0 |
|
| 226 | - * @access private |
|
| 227 | - * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 228 | - */ |
|
| 229 | - private $import_service; |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * A {@link Wordlift_Rebuild_Service} instance. |
|
| 233 | - * |
|
| 234 | - * @since 3.6.0 |
|
| 235 | - * @access private |
|
| 236 | - * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 237 | - */ |
|
| 238 | - private $rebuild_service; |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * A {@link Wordlift_Jsonld_Service} instance. |
|
| 242 | - * |
|
| 243 | - * @since 3.7.0 |
|
| 244 | - * @access protected |
|
| 245 | - * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 246 | - */ |
|
| 247 | - protected $jsonld_service; |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * |
|
| 251 | - * @since 3.7.0 |
|
| 252 | - * @access private |
|
| 253 | - * @var \Wordlift_Property_Factory $property_factory |
|
| 254 | - */ |
|
| 255 | - private $property_factory; |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * The 'Download Your Data' page. |
|
| 259 | - * |
|
| 260 | - * @since 3.6.0 |
|
| 261 | - * @access private |
|
| 262 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 263 | - */ |
|
| 264 | - private $download_your_data_page; |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * The 'WordLift Settings' page. |
|
| 268 | - * |
|
| 269 | - * @since 3.11.0 |
|
| 270 | - * @access protected |
|
| 271 | - * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 272 | - */ |
|
| 273 | - protected $settings_page; |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * The install wizard page. |
|
| 277 | - * |
|
| 278 | - * @since 3.9.0 |
|
| 279 | - * @access private |
|
| 280 | - * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 281 | - */ |
|
| 282 | - private $admin_setup; |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 286 | - * linking of entities to their pages. |
|
| 287 | - * |
|
| 288 | - * @since 3.8.0 |
|
| 289 | - * @access private |
|
| 290 | - * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 291 | - */ |
|
| 292 | - private $content_filter_service; |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 296 | - * |
|
| 297 | - * @since 3.9.0 |
|
| 298 | - * @access private |
|
| 299 | - * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 300 | - */ |
|
| 301 | - private $key_validation_service; |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * A {@link Wordlift_Rating_Service} instance. |
|
| 305 | - * |
|
| 306 | - * @since 3.10.0 |
|
| 307 | - * @access private |
|
| 308 | - * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 309 | - */ |
|
| 310 | - private $rating_service; |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 314 | - * |
|
| 315 | - * @since 3.10.0 |
|
| 316 | - * @access protected |
|
| 317 | - * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 318 | - */ |
|
| 319 | - protected $post_to_jsonld_converter; |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 323 | - * |
|
| 324 | - * @since 3.10.0 |
|
| 325 | - * @access protected |
|
| 326 | - * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 327 | - */ |
|
| 328 | - protected $configuration_service; |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 332 | - * |
|
| 333 | - * @since 3.10.0 |
|
| 334 | - * @access protected |
|
| 335 | - * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 336 | - */ |
|
| 337 | - protected $entity_type_service; |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 341 | - * |
|
| 342 | - * @since 3.10.0 |
|
| 343 | - * @access protected |
|
| 344 | - * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 345 | - */ |
|
| 346 | - protected $entity_post_to_jsonld_converter; |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 350 | - * |
|
| 351 | - * @since 3.10.0 |
|
| 352 | - * @access protected |
|
| 353 | - * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 354 | - */ |
|
| 355 | - protected $postid_to_jsonld_converter; |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * The {@link Wordlift_Admin_Status_Page} class. |
|
| 359 | - * |
|
| 360 | - * @since 3.9.8 |
|
| 361 | - * @access private |
|
| 362 | - * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 363 | - */ |
|
| 364 | - private $status_page; |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 368 | - * |
|
| 369 | - * @since 3.11.0 |
|
| 370 | - * @access protected |
|
| 371 | - * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 372 | - */ |
|
| 373 | - protected $category_taxonomy_service; |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * The {@link Wordlift_Event_Entity_Page_Service} instance. |
|
| 377 | - * |
|
| 378 | - * @since 3.11.0 |
|
| 379 | - * @access protected |
|
| 380 | - * @var \Wordlift_Event_Entity_Page_Service $event_entity_page_service The {@link Wordlift_Event_Entity_Page_Service} instance. |
|
| 381 | - */ |
|
| 382 | - protected $event_entity_page_service; |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 386 | - * |
|
| 387 | - * @since 3.11.0 |
|
| 388 | - * @access protected |
|
| 389 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 390 | - */ |
|
| 391 | - protected $settings_page_action_link; |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 395 | - * |
|
| 396 | - * @since 3.11.0 |
|
| 397 | - * @access protected |
|
| 398 | - * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 399 | - */ |
|
| 400 | - protected $publisher_ajax_adapter; |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 404 | - * |
|
| 405 | - * @since 3.11.0 |
|
| 406 | - * @access protected |
|
| 407 | - * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 408 | - */ |
|
| 409 | - protected $input_element; |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 413 | - * |
|
| 414 | - * @since 3.13.0 |
|
| 415 | - * @access protected |
|
| 416 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 417 | - */ |
|
| 418 | - protected $radio_input_element; |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 422 | - * |
|
| 423 | - * @since 3.11.0 |
|
| 424 | - * @access protected |
|
| 425 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 426 | - */ |
|
| 427 | - protected $language_select_element; |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 431 | - * |
|
| 432 | - * @since 3.11.0 |
|
| 433 | - * @access protected |
|
| 434 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 435 | - */ |
|
| 436 | - protected $publisher_element; |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 440 | - * |
|
| 441 | - * @since 3.11.0 |
|
| 442 | - * @access protected |
|
| 443 | - * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 444 | - */ |
|
| 445 | - protected $select2_element; |
|
| 446 | - |
|
| 447 | - /** |
|
| 448 | - * The controller for the entity type list admin page |
|
| 449 | - * |
|
| 450 | - * @since 3.11.0 |
|
| 451 | - * @access private |
|
| 452 | - * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 453 | - */ |
|
| 454 | - private $entity_type_admin_page; |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * The controller for the entity type settings admin page |
|
| 458 | - * |
|
| 459 | - * @since 3.11.0 |
|
| 460 | - * @access private |
|
| 461 | - * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 462 | - */ |
|
| 463 | - private $entity_type_settings_admin_page; |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 467 | - * |
|
| 468 | - * @since 3.11.0 |
|
| 469 | - * @access protected |
|
| 470 | - * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 471 | - */ |
|
| 472 | - protected $related_entities_cloud_widget; |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * {@link Wordlift}'s singleton instance. |
|
| 476 | - * |
|
| 477 | - * @since 3.11.2 |
|
| 478 | - * |
|
| 479 | - * @since 3.11.2 |
|
| 480 | - * @access private |
|
| 481 | - * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 482 | - */ |
|
| 483 | - private static $instance; |
|
| 484 | - |
|
| 485 | - /** |
|
| 486 | - * Define the core functionality of the plugin. |
|
| 487 | - * |
|
| 488 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 489 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 490 | - * the public-facing side of the site. |
|
| 491 | - * |
|
| 492 | - * @since 1.0.0 |
|
| 493 | - */ |
|
| 494 | - public function __construct() { |
|
| 495 | - |
|
| 496 | - $this->plugin_name = 'wordlift'; |
|
| 497 | - $this->version = '3.13.0'; |
|
| 498 | - $this->load_dependencies(); |
|
| 499 | - $this->set_locale(); |
|
| 500 | - $this->define_admin_hooks(); |
|
| 501 | - $this->define_public_hooks(); |
|
| 502 | - |
|
| 503 | - self::$instance = $this; |
|
| 504 | - |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - /** |
|
| 508 | - * Get the singleton instance. |
|
| 509 | - * |
|
| 510 | - * @since 3.11.2 |
|
| 511 | - * |
|
| 512 | - * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 513 | - */ |
|
| 514 | - public static function get_instance() { |
|
| 515 | - |
|
| 516 | - return self::$instance; |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - /** |
|
| 520 | - * Load the required dependencies for this plugin. |
|
| 521 | - * |
|
| 522 | - * Include the following files that make up the plugin: |
|
| 523 | - * |
|
| 524 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 525 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 526 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 527 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 528 | - * |
|
| 529 | - * Create an instance of the loader which will be used to register the hooks |
|
| 530 | - * with WordPress. |
|
| 531 | - * |
|
| 532 | - * @since 1.0.0 |
|
| 533 | - * @access private |
|
| 534 | - */ |
|
| 535 | - private function load_dependencies() { |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * The class responsible for orchestrating the actions and filters of the |
|
| 539 | - * core plugin. |
|
| 540 | - */ |
|
| 541 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 542 | - |
|
| 543 | - /** |
|
| 544 | - * The class responsible for defining internationalization functionality |
|
| 545 | - * of the plugin. |
|
| 546 | - */ |
|
| 547 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 548 | - |
|
| 549 | - /** |
|
| 550 | - * WordLift's supported languages. |
|
| 551 | - */ |
|
| 552 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 553 | - |
|
| 554 | - /** |
|
| 555 | - * Provide support functions to sanitize data. |
|
| 556 | - */ |
|
| 557 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * The Redirect service. |
|
| 561 | - */ |
|
| 562 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 563 | - |
|
| 564 | - /** |
|
| 565 | - * The Log service. |
|
| 566 | - */ |
|
| 567 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 568 | - |
|
| 569 | - /** |
|
| 570 | - * The configuration service. |
|
| 571 | - */ |
|
| 572 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 573 | - |
|
| 574 | - /** |
|
| 575 | - * The entity post type service (this is the WordPress post type, not the entity schema type). |
|
| 576 | - */ |
|
| 577 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 578 | - |
|
| 579 | - /** |
|
| 580 | - * The entity type service (i.e. the schema type). |
|
| 581 | - */ |
|
| 582 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 583 | - |
|
| 584 | - /** |
|
| 585 | - * The entity link service. |
|
| 586 | - */ |
|
| 587 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 588 | - |
|
| 589 | - /** |
|
| 590 | - * The Query builder. |
|
| 591 | - */ |
|
| 592 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 593 | - |
|
| 594 | - /** |
|
| 595 | - * The Schema service. |
|
| 596 | - */ |
|
| 597 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 598 | - |
|
| 599 | - /** |
|
| 600 | - * The schema:url property service. |
|
| 601 | - */ |
|
| 602 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 603 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 604 | - |
|
| 605 | - /** |
|
| 606 | - * The UI service. |
|
| 607 | - */ |
|
| 608 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 609 | - |
|
| 610 | - /** |
|
| 611 | - * The Thumbnail service. |
|
| 612 | - */ |
|
| 613 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 614 | - |
|
| 615 | - /** |
|
| 616 | - * The Entity Types Taxonomy service. |
|
| 617 | - */ |
|
| 618 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 619 | - |
|
| 620 | - /** |
|
| 621 | - * The Entity service. |
|
| 622 | - */ |
|
| 623 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 624 | - |
|
| 625 | - // Add the entity rating service. |
|
| 626 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 627 | - |
|
| 628 | - /** |
|
| 629 | - * The User service. |
|
| 630 | - */ |
|
| 631 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 632 | - |
|
| 633 | - /** |
|
| 634 | - * The Timeline service. |
|
| 635 | - */ |
|
| 636 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 637 | - |
|
| 638 | - /** |
|
| 639 | - * The Topic Taxonomy service. |
|
| 640 | - */ |
|
| 641 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 642 | - |
|
| 643 | - /** |
|
| 644 | - * The SPARQL service. |
|
| 645 | - */ |
|
| 646 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 647 | - |
|
| 648 | - /** |
|
| 649 | - * The WordLift import service. |
|
| 650 | - */ |
|
| 651 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 652 | - |
|
| 653 | - /** |
|
| 654 | - * The WordLift URI service. |
|
| 655 | - */ |
|
| 656 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 657 | - |
|
| 658 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 659 | - |
|
| 660 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 661 | - |
|
| 662 | - /** |
|
| 663 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 664 | - */ |
|
| 665 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 666 | - |
|
| 667 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 668 | - |
|
| 669 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 670 | - |
|
| 671 | - /** |
|
| 672 | - * Load the converters. |
|
| 673 | - */ |
|
| 674 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 675 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 676 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 677 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 678 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 679 | - |
|
| 680 | - /** |
|
| 681 | - * Load the content filter. |
|
| 682 | - */ |
|
| 683 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 684 | - |
|
| 685 | - /* |
|
| 32 | + /** |
|
| 33 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | + * the plugin. |
|
| 35 | + * |
|
| 36 | + * @since 1.0.0 |
|
| 37 | + * @access protected |
|
| 38 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | + */ |
|
| 40 | + protected $loader; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The unique identifier of this plugin. |
|
| 44 | + * |
|
| 45 | + * @since 1.0.0 |
|
| 46 | + * @access protected |
|
| 47 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | + */ |
|
| 49 | + protected $plugin_name; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * The current version of the plugin. |
|
| 53 | + * |
|
| 54 | + * @since 1.0.0 |
|
| 55 | + * @access protected |
|
| 56 | + * @var string $version The current version of the plugin. |
|
| 57 | + */ |
|
| 58 | + protected $version; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 62 | + * |
|
| 63 | + * @since 3.12.0 |
|
| 64 | + * @access protected |
|
| 65 | + * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 66 | + */ |
|
| 67 | + protected $tinymce_adapter; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The Thumbnail service. |
|
| 71 | + * |
|
| 72 | + * @since 3.1.5 |
|
| 73 | + * @access private |
|
| 74 | + * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 75 | + */ |
|
| 76 | + private $thumbnail_service; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * The UI service. |
|
| 80 | + * |
|
| 81 | + * @since 3.2.0 |
|
| 82 | + * @access private |
|
| 83 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 84 | + */ |
|
| 85 | + private $ui_service; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * The Schema service. |
|
| 89 | + * |
|
| 90 | + * @since 3.3.0 |
|
| 91 | + * @access private |
|
| 92 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 93 | + */ |
|
| 94 | + private $schema_service; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * The Entity service. |
|
| 98 | + * |
|
| 99 | + * @since 3.1.0 |
|
| 100 | + * @access protected |
|
| 101 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 102 | + */ |
|
| 103 | + protected $entity_service; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * The Topic Taxonomy service. |
|
| 107 | + * |
|
| 108 | + * @since 3.5.0 |
|
| 109 | + * @access private |
|
| 110 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 111 | + */ |
|
| 112 | + private $topic_taxonomy_service; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * The User service. |
|
| 116 | + * |
|
| 117 | + * @since 3.1.7 |
|
| 118 | + * @access protected |
|
| 119 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 120 | + */ |
|
| 121 | + protected $user_service; |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * The Timeline service. |
|
| 125 | + * |
|
| 126 | + * @since 3.1.0 |
|
| 127 | + * @access private |
|
| 128 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 129 | + */ |
|
| 130 | + private $timeline_service; |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * The Redirect service. |
|
| 134 | + * |
|
| 135 | + * @since 3.2.0 |
|
| 136 | + * @access private |
|
| 137 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 138 | + */ |
|
| 139 | + private $redirect_service; |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * The Notice service. |
|
| 143 | + * |
|
| 144 | + * @since 3.3.0 |
|
| 145 | + * @access private |
|
| 146 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 147 | + */ |
|
| 148 | + private $notice_service; |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * The Entity list customization. |
|
| 152 | + * |
|
| 153 | + * @since 3.3.0 |
|
| 154 | + * @access private |
|
| 155 | + * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 156 | + */ |
|
| 157 | + private $entity_list_service; |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * The Entity Types Taxonomy Walker. |
|
| 161 | + * |
|
| 162 | + * @since 3.1.0 |
|
| 163 | + * @access private |
|
| 164 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 165 | + */ |
|
| 166 | + private $entity_types_taxonomy_walker; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * The ShareThis service. |
|
| 170 | + * |
|
| 171 | + * @since 3.2.0 |
|
| 172 | + * @access private |
|
| 173 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 174 | + */ |
|
| 175 | + private $sharethis_service; |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * The PrimaShop adapter. |
|
| 179 | + * |
|
| 180 | + * @since 3.2.3 |
|
| 181 | + * @access private |
|
| 182 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 183 | + */ |
|
| 184 | + private $primashop_adapter; |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * The WordLift Dashboard adapter. |
|
| 188 | + * |
|
| 189 | + * @since 3.4.0 |
|
| 190 | + * @access private |
|
| 191 | + * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 192 | + */ |
|
| 193 | + private $dashboard_service; |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * The entity type service. |
|
| 197 | + * |
|
| 198 | + * @since 3.6.0 |
|
| 199 | + * @access private |
|
| 200 | + * @var \Wordlift_Entity_Post_Type_Service |
|
| 201 | + */ |
|
| 202 | + private $entity_post_type_service; |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 206 | + * |
|
| 207 | + * @since 3.6.0 |
|
| 208 | + * @access private |
|
| 209 | + * @var \Wordlift_Entity_Link_Service |
|
| 210 | + */ |
|
| 211 | + private $entity_link_service; |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 215 | + * |
|
| 216 | + * @var 3.6.0 |
|
| 217 | + * @access private |
|
| 218 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 219 | + */ |
|
| 220 | + private $sparql_service; |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * A {@link Wordlift_Import_Service} instance. |
|
| 224 | + * |
|
| 225 | + * @since 3.6.0 |
|
| 226 | + * @access private |
|
| 227 | + * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 228 | + */ |
|
| 229 | + private $import_service; |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * A {@link Wordlift_Rebuild_Service} instance. |
|
| 233 | + * |
|
| 234 | + * @since 3.6.0 |
|
| 235 | + * @access private |
|
| 236 | + * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 237 | + */ |
|
| 238 | + private $rebuild_service; |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * A {@link Wordlift_Jsonld_Service} instance. |
|
| 242 | + * |
|
| 243 | + * @since 3.7.0 |
|
| 244 | + * @access protected |
|
| 245 | + * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 246 | + */ |
|
| 247 | + protected $jsonld_service; |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * |
|
| 251 | + * @since 3.7.0 |
|
| 252 | + * @access private |
|
| 253 | + * @var \Wordlift_Property_Factory $property_factory |
|
| 254 | + */ |
|
| 255 | + private $property_factory; |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * The 'Download Your Data' page. |
|
| 259 | + * |
|
| 260 | + * @since 3.6.0 |
|
| 261 | + * @access private |
|
| 262 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 263 | + */ |
|
| 264 | + private $download_your_data_page; |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * The 'WordLift Settings' page. |
|
| 268 | + * |
|
| 269 | + * @since 3.11.0 |
|
| 270 | + * @access protected |
|
| 271 | + * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 272 | + */ |
|
| 273 | + protected $settings_page; |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * The install wizard page. |
|
| 277 | + * |
|
| 278 | + * @since 3.9.0 |
|
| 279 | + * @access private |
|
| 280 | + * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 281 | + */ |
|
| 282 | + private $admin_setup; |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 286 | + * linking of entities to their pages. |
|
| 287 | + * |
|
| 288 | + * @since 3.8.0 |
|
| 289 | + * @access private |
|
| 290 | + * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 291 | + */ |
|
| 292 | + private $content_filter_service; |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 296 | + * |
|
| 297 | + * @since 3.9.0 |
|
| 298 | + * @access private |
|
| 299 | + * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 300 | + */ |
|
| 301 | + private $key_validation_service; |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * A {@link Wordlift_Rating_Service} instance. |
|
| 305 | + * |
|
| 306 | + * @since 3.10.0 |
|
| 307 | + * @access private |
|
| 308 | + * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 309 | + */ |
|
| 310 | + private $rating_service; |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 314 | + * |
|
| 315 | + * @since 3.10.0 |
|
| 316 | + * @access protected |
|
| 317 | + * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 318 | + */ |
|
| 319 | + protected $post_to_jsonld_converter; |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 323 | + * |
|
| 324 | + * @since 3.10.0 |
|
| 325 | + * @access protected |
|
| 326 | + * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 327 | + */ |
|
| 328 | + protected $configuration_service; |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 332 | + * |
|
| 333 | + * @since 3.10.0 |
|
| 334 | + * @access protected |
|
| 335 | + * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 336 | + */ |
|
| 337 | + protected $entity_type_service; |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 341 | + * |
|
| 342 | + * @since 3.10.0 |
|
| 343 | + * @access protected |
|
| 344 | + * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 345 | + */ |
|
| 346 | + protected $entity_post_to_jsonld_converter; |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 350 | + * |
|
| 351 | + * @since 3.10.0 |
|
| 352 | + * @access protected |
|
| 353 | + * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 354 | + */ |
|
| 355 | + protected $postid_to_jsonld_converter; |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * The {@link Wordlift_Admin_Status_Page} class. |
|
| 359 | + * |
|
| 360 | + * @since 3.9.8 |
|
| 361 | + * @access private |
|
| 362 | + * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 363 | + */ |
|
| 364 | + private $status_page; |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 368 | + * |
|
| 369 | + * @since 3.11.0 |
|
| 370 | + * @access protected |
|
| 371 | + * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 372 | + */ |
|
| 373 | + protected $category_taxonomy_service; |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * The {@link Wordlift_Event_Entity_Page_Service} instance. |
|
| 377 | + * |
|
| 378 | + * @since 3.11.0 |
|
| 379 | + * @access protected |
|
| 380 | + * @var \Wordlift_Event_Entity_Page_Service $event_entity_page_service The {@link Wordlift_Event_Entity_Page_Service} instance. |
|
| 381 | + */ |
|
| 382 | + protected $event_entity_page_service; |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 386 | + * |
|
| 387 | + * @since 3.11.0 |
|
| 388 | + * @access protected |
|
| 389 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 390 | + */ |
|
| 391 | + protected $settings_page_action_link; |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 395 | + * |
|
| 396 | + * @since 3.11.0 |
|
| 397 | + * @access protected |
|
| 398 | + * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 399 | + */ |
|
| 400 | + protected $publisher_ajax_adapter; |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 404 | + * |
|
| 405 | + * @since 3.11.0 |
|
| 406 | + * @access protected |
|
| 407 | + * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 408 | + */ |
|
| 409 | + protected $input_element; |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 413 | + * |
|
| 414 | + * @since 3.13.0 |
|
| 415 | + * @access protected |
|
| 416 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 417 | + */ |
|
| 418 | + protected $radio_input_element; |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 422 | + * |
|
| 423 | + * @since 3.11.0 |
|
| 424 | + * @access protected |
|
| 425 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 426 | + */ |
|
| 427 | + protected $language_select_element; |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 431 | + * |
|
| 432 | + * @since 3.11.0 |
|
| 433 | + * @access protected |
|
| 434 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 435 | + */ |
|
| 436 | + protected $publisher_element; |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 440 | + * |
|
| 441 | + * @since 3.11.0 |
|
| 442 | + * @access protected |
|
| 443 | + * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 444 | + */ |
|
| 445 | + protected $select2_element; |
|
| 446 | + |
|
| 447 | + /** |
|
| 448 | + * The controller for the entity type list admin page |
|
| 449 | + * |
|
| 450 | + * @since 3.11.0 |
|
| 451 | + * @access private |
|
| 452 | + * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 453 | + */ |
|
| 454 | + private $entity_type_admin_page; |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * The controller for the entity type settings admin page |
|
| 458 | + * |
|
| 459 | + * @since 3.11.0 |
|
| 460 | + * @access private |
|
| 461 | + * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 462 | + */ |
|
| 463 | + private $entity_type_settings_admin_page; |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 467 | + * |
|
| 468 | + * @since 3.11.0 |
|
| 469 | + * @access protected |
|
| 470 | + * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 471 | + */ |
|
| 472 | + protected $related_entities_cloud_widget; |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * {@link Wordlift}'s singleton instance. |
|
| 476 | + * |
|
| 477 | + * @since 3.11.2 |
|
| 478 | + * |
|
| 479 | + * @since 3.11.2 |
|
| 480 | + * @access private |
|
| 481 | + * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 482 | + */ |
|
| 483 | + private static $instance; |
|
| 484 | + |
|
| 485 | + /** |
|
| 486 | + * Define the core functionality of the plugin. |
|
| 487 | + * |
|
| 488 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 489 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 490 | + * the public-facing side of the site. |
|
| 491 | + * |
|
| 492 | + * @since 1.0.0 |
|
| 493 | + */ |
|
| 494 | + public function __construct() { |
|
| 495 | + |
|
| 496 | + $this->plugin_name = 'wordlift'; |
|
| 497 | + $this->version = '3.13.0'; |
|
| 498 | + $this->load_dependencies(); |
|
| 499 | + $this->set_locale(); |
|
| 500 | + $this->define_admin_hooks(); |
|
| 501 | + $this->define_public_hooks(); |
|
| 502 | + |
|
| 503 | + self::$instance = $this; |
|
| 504 | + |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + /** |
|
| 508 | + * Get the singleton instance. |
|
| 509 | + * |
|
| 510 | + * @since 3.11.2 |
|
| 511 | + * |
|
| 512 | + * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 513 | + */ |
|
| 514 | + public static function get_instance() { |
|
| 515 | + |
|
| 516 | + return self::$instance; |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + /** |
|
| 520 | + * Load the required dependencies for this plugin. |
|
| 521 | + * |
|
| 522 | + * Include the following files that make up the plugin: |
|
| 523 | + * |
|
| 524 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 525 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 526 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 527 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 528 | + * |
|
| 529 | + * Create an instance of the loader which will be used to register the hooks |
|
| 530 | + * with WordPress. |
|
| 531 | + * |
|
| 532 | + * @since 1.0.0 |
|
| 533 | + * @access private |
|
| 534 | + */ |
|
| 535 | + private function load_dependencies() { |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * The class responsible for orchestrating the actions and filters of the |
|
| 539 | + * core plugin. |
|
| 540 | + */ |
|
| 541 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 542 | + |
|
| 543 | + /** |
|
| 544 | + * The class responsible for defining internationalization functionality |
|
| 545 | + * of the plugin. |
|
| 546 | + */ |
|
| 547 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 548 | + |
|
| 549 | + /** |
|
| 550 | + * WordLift's supported languages. |
|
| 551 | + */ |
|
| 552 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 553 | + |
|
| 554 | + /** |
|
| 555 | + * Provide support functions to sanitize data. |
|
| 556 | + */ |
|
| 557 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * The Redirect service. |
|
| 561 | + */ |
|
| 562 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 563 | + |
|
| 564 | + /** |
|
| 565 | + * The Log service. |
|
| 566 | + */ |
|
| 567 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 568 | + |
|
| 569 | + /** |
|
| 570 | + * The configuration service. |
|
| 571 | + */ |
|
| 572 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 573 | + |
|
| 574 | + /** |
|
| 575 | + * The entity post type service (this is the WordPress post type, not the entity schema type). |
|
| 576 | + */ |
|
| 577 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 578 | + |
|
| 579 | + /** |
|
| 580 | + * The entity type service (i.e. the schema type). |
|
| 581 | + */ |
|
| 582 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 583 | + |
|
| 584 | + /** |
|
| 585 | + * The entity link service. |
|
| 586 | + */ |
|
| 587 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 588 | + |
|
| 589 | + /** |
|
| 590 | + * The Query builder. |
|
| 591 | + */ |
|
| 592 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 593 | + |
|
| 594 | + /** |
|
| 595 | + * The Schema service. |
|
| 596 | + */ |
|
| 597 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 598 | + |
|
| 599 | + /** |
|
| 600 | + * The schema:url property service. |
|
| 601 | + */ |
|
| 602 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 603 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 604 | + |
|
| 605 | + /** |
|
| 606 | + * The UI service. |
|
| 607 | + */ |
|
| 608 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 609 | + |
|
| 610 | + /** |
|
| 611 | + * The Thumbnail service. |
|
| 612 | + */ |
|
| 613 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 614 | + |
|
| 615 | + /** |
|
| 616 | + * The Entity Types Taxonomy service. |
|
| 617 | + */ |
|
| 618 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 619 | + |
|
| 620 | + /** |
|
| 621 | + * The Entity service. |
|
| 622 | + */ |
|
| 623 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 624 | + |
|
| 625 | + // Add the entity rating service. |
|
| 626 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 627 | + |
|
| 628 | + /** |
|
| 629 | + * The User service. |
|
| 630 | + */ |
|
| 631 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 632 | + |
|
| 633 | + /** |
|
| 634 | + * The Timeline service. |
|
| 635 | + */ |
|
| 636 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 637 | + |
|
| 638 | + /** |
|
| 639 | + * The Topic Taxonomy service. |
|
| 640 | + */ |
|
| 641 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 642 | + |
|
| 643 | + /** |
|
| 644 | + * The SPARQL service. |
|
| 645 | + */ |
|
| 646 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 647 | + |
|
| 648 | + /** |
|
| 649 | + * The WordLift import service. |
|
| 650 | + */ |
|
| 651 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 652 | + |
|
| 653 | + /** |
|
| 654 | + * The WordLift URI service. |
|
| 655 | + */ |
|
| 656 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 657 | + |
|
| 658 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 659 | + |
|
| 660 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 661 | + |
|
| 662 | + /** |
|
| 663 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 664 | + */ |
|
| 665 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 666 | + |
|
| 667 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 668 | + |
|
| 669 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 670 | + |
|
| 671 | + /** |
|
| 672 | + * Load the converters. |
|
| 673 | + */ |
|
| 674 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 675 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 676 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 677 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 678 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 679 | + |
|
| 680 | + /** |
|
| 681 | + * Load the content filter. |
|
| 682 | + */ |
|
| 683 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 684 | + |
|
| 685 | + /* |
|
| 686 | 686 | * Load the excerpt helper. |
| 687 | 687 | */ |
| 688 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 689 | - |
|
| 690 | - /** |
|
| 691 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 692 | - * |
|
| 693 | - * @since 3.8.0 |
|
| 694 | - */ |
|
| 695 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 696 | - |
|
| 697 | - // The Publisher Service and the AJAX adapter. |
|
| 698 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 699 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 700 | - |
|
| 701 | - /** |
|
| 702 | - * Load the WordLift key validation service. |
|
| 703 | - */ |
|
| 704 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 705 | - |
|
| 706 | - // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 707 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 708 | - |
|
| 709 | - // Load the `Wordlift_Event_Entity_Page_Service` class definition. |
|
| 710 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-event-entity-page-service.php'; |
|
| 711 | - |
|
| 712 | - /** Adapters. */ |
|
| 713 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 714 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 715 | - |
|
| 716 | - /** |
|
| 717 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 718 | - */ |
|
| 719 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 720 | - |
|
| 721 | - /** |
|
| 722 | - * The class to customize the entity list admin page. |
|
| 723 | - */ |
|
| 724 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 725 | - |
|
| 726 | - /** |
|
| 727 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 728 | - */ |
|
| 729 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 730 | - |
|
| 731 | - /** |
|
| 732 | - * The Notice service. |
|
| 733 | - */ |
|
| 734 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 735 | - |
|
| 736 | - /** |
|
| 737 | - * The PrimaShop adapter. |
|
| 738 | - */ |
|
| 739 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 740 | - |
|
| 741 | - /** |
|
| 742 | - * The WordLift Dashboard service. |
|
| 743 | - */ |
|
| 744 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 745 | - |
|
| 746 | - /** |
|
| 747 | - * The admin 'Install wizard' page. |
|
| 748 | - */ |
|
| 749 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 688 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 689 | + |
|
| 690 | + /** |
|
| 691 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 692 | + * |
|
| 693 | + * @since 3.8.0 |
|
| 694 | + */ |
|
| 695 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 696 | + |
|
| 697 | + // The Publisher Service and the AJAX adapter. |
|
| 698 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 699 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * Load the WordLift key validation service. |
|
| 703 | + */ |
|
| 704 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 705 | + |
|
| 706 | + // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 707 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 708 | + |
|
| 709 | + // Load the `Wordlift_Event_Entity_Page_Service` class definition. |
|
| 710 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-event-entity-page-service.php'; |
|
| 711 | + |
|
| 712 | + /** Adapters. */ |
|
| 713 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 714 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 715 | + |
|
| 716 | + /** |
|
| 717 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 718 | + */ |
|
| 719 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 720 | + |
|
| 721 | + /** |
|
| 722 | + * The class to customize the entity list admin page. |
|
| 723 | + */ |
|
| 724 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 725 | + |
|
| 726 | + /** |
|
| 727 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 728 | + */ |
|
| 729 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 730 | + |
|
| 731 | + /** |
|
| 732 | + * The Notice service. |
|
| 733 | + */ |
|
| 734 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 735 | + |
|
| 736 | + /** |
|
| 737 | + * The PrimaShop adapter. |
|
| 738 | + */ |
|
| 739 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 740 | + |
|
| 741 | + /** |
|
| 742 | + * The WordLift Dashboard service. |
|
| 743 | + */ |
|
| 744 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 745 | + |
|
| 746 | + /** |
|
| 747 | + * The admin 'Install wizard' page. |
|
| 748 | + */ |
|
| 749 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 750 | + |
|
| 751 | + /** |
|
| 752 | + * The WordLift entity type list admin page controller. |
|
| 753 | + */ |
|
| 754 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 755 | + |
|
| 756 | + /** |
|
| 757 | + * The WordLift entity type settings admin page controller. |
|
| 758 | + */ |
|
| 759 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 760 | + |
|
| 761 | + /** |
|
| 762 | + * The admin 'Download Your Data' page. |
|
| 763 | + */ |
|
| 764 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 765 | + |
|
| 766 | + /** |
|
| 767 | + * The admin 'Download Your Data' page. |
|
| 768 | + */ |
|
| 769 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 770 | + |
|
| 771 | + /** |
|
| 772 | + * The admin 'WordLift Settings' page. |
|
| 773 | + */ |
|
| 774 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 775 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 776 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 777 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 778 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 779 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 780 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 781 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 782 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 783 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 784 | + |
|
| 785 | + /** Admin Pages */ |
|
| 786 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 787 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 788 | + |
|
| 789 | + /** |
|
| 790 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 791 | + * side of the site. |
|
| 792 | + */ |
|
| 793 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 794 | + |
|
| 795 | + /** |
|
| 796 | + * The shortcode abstract class. |
|
| 797 | + */ |
|
| 798 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 799 | + |
|
| 800 | + /** |
|
| 801 | + * The Timeline shortcode. |
|
| 802 | + */ |
|
| 803 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 804 | + |
|
| 805 | + /** |
|
| 806 | + * The Navigator shortcode. |
|
| 807 | + */ |
|
| 808 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 809 | + |
|
| 810 | + /** |
|
| 811 | + * The chord shortcode. |
|
| 812 | + */ |
|
| 813 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 814 | + |
|
| 815 | + /** |
|
| 816 | + * The geomap shortcode. |
|
| 817 | + */ |
|
| 818 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 819 | + |
|
| 820 | + /** |
|
| 821 | + * The entity cloud shortcode. |
|
| 822 | + */ |
|
| 823 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 750 | 824 | |
| 751 | - /** |
|
| 752 | - * The WordLift entity type list admin page controller. |
|
| 753 | - */ |
|
| 754 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 755 | - |
|
| 756 | - /** |
|
| 757 | - * The WordLift entity type settings admin page controller. |
|
| 758 | - */ |
|
| 759 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 760 | - |
|
| 761 | - /** |
|
| 762 | - * The admin 'Download Your Data' page. |
|
| 763 | - */ |
|
| 764 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 765 | - |
|
| 766 | - /** |
|
| 767 | - * The admin 'Download Your Data' page. |
|
| 768 | - */ |
|
| 769 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 770 | - |
|
| 771 | - /** |
|
| 772 | - * The admin 'WordLift Settings' page. |
|
| 773 | - */ |
|
| 774 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 775 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 776 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 777 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 778 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 779 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 780 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 781 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 782 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 783 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 784 | - |
|
| 785 | - /** Admin Pages */ |
|
| 786 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 787 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 788 | - |
|
| 789 | - /** |
|
| 790 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 791 | - * side of the site. |
|
| 792 | - */ |
|
| 793 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 794 | - |
|
| 795 | - /** |
|
| 796 | - * The shortcode abstract class. |
|
| 797 | - */ |
|
| 798 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 799 | - |
|
| 800 | - /** |
|
| 801 | - * The Timeline shortcode. |
|
| 802 | - */ |
|
| 803 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 804 | - |
|
| 805 | - /** |
|
| 806 | - * The Navigator shortcode. |
|
| 807 | - */ |
|
| 808 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 825 | + /** |
|
| 826 | + * The ShareThis service. |
|
| 827 | + */ |
|
| 828 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 809 | 829 | |
| 810 | - /** |
|
| 811 | - * The chord shortcode. |
|
| 812 | - */ |
|
| 813 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 830 | + /** |
|
| 831 | + * The SEO service. |
|
| 832 | + */ |
|
| 833 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 814 | 834 | |
| 815 | - /** |
|
| 816 | - * The geomap shortcode. |
|
| 817 | - */ |
|
| 818 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 819 | - |
|
| 820 | - /** |
|
| 821 | - * The entity cloud shortcode. |
|
| 822 | - */ |
|
| 823 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 824 | - |
|
| 825 | - /** |
|
| 826 | - * The ShareThis service. |
|
| 827 | - */ |
|
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 829 | - |
|
| 830 | - /** |
|
| 831 | - * The SEO service. |
|
| 832 | - */ |
|
| 833 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 834 | - |
|
| 835 | - /** |
|
| 836 | - * The AMP service. |
|
| 837 | - */ |
|
| 838 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 835 | + /** |
|
| 836 | + * The AMP service. |
|
| 837 | + */ |
|
| 838 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 839 | 839 | |
| 840 | - /** Widgets */ |
|
| 841 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 842 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 840 | + /** Widgets */ |
|
| 841 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 842 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 843 | 843 | |
| 844 | - $this->loader = new Wordlift_Loader(); |
|
| 844 | + $this->loader = new Wordlift_Loader(); |
|
| 845 | 845 | |
| 846 | - // Instantiate a global logger. |
|
| 847 | - global $wl_logger; |
|
| 848 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 846 | + // Instantiate a global logger. |
|
| 847 | + global $wl_logger; |
|
| 848 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 849 | 849 | |
| 850 | - // Create the configuration service. |
|
| 851 | - $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 850 | + // Create the configuration service. |
|
| 851 | + $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 852 | 852 | |
| 853 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 854 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 853 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 854 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 855 | 855 | |
| 856 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 857 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 856 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 857 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 858 | 858 | |
| 859 | - // Create an instance of the UI service. |
|
| 860 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 859 | + // Create an instance of the UI service. |
|
| 860 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 861 | 861 | |
| 862 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 863 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 862 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 863 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 864 | 864 | |
| 865 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 865 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 866 | 866 | |
| 867 | - // Create an instance of the Schema service. |
|
| 868 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 869 | - $this->schema_service = new Wordlift_Schema_Service(); |
|
| 867 | + // Create an instance of the Schema service. |
|
| 868 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 869 | + $this->schema_service = new Wordlift_Schema_Service(); |
|
| 870 | 870 | |
| 871 | - // Create an instance of the Notice service. |
|
| 872 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 871 | + // Create an instance of the Notice service. |
|
| 872 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 873 | 873 | |
| 874 | - // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 875 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service ); |
|
| 874 | + // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 875 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service ); |
|
| 876 | 876 | |
| 877 | - // Create an instance of the User service. |
|
| 878 | - $this->user_service = new Wordlift_User_Service(); |
|
| 877 | + // Create an instance of the User service. |
|
| 878 | + $this->user_service = new Wordlift_User_Service(); |
|
| 879 | 879 | |
| 880 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 881 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 880 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 881 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 882 | 882 | |
| 883 | - // Create a new instance of the Redirect service. |
|
| 884 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 883 | + // Create a new instance of the Redirect service. |
|
| 884 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 885 | 885 | |
| 886 | - // Initialize the shortcodes. |
|
| 887 | - new Wordlift_Navigator_Shortcode(); |
|
| 888 | - new Wordlift_Chord_Shortcode(); |
|
| 889 | - new Wordlift_Geomap_Shortcode(); |
|
| 890 | - new Wordlift_Timeline_Shortcode(); |
|
| 891 | - new Wordlift_Related_Entities_Cloud_Shortcode(); |
|
| 886 | + // Initialize the shortcodes. |
|
| 887 | + new Wordlift_Navigator_Shortcode(); |
|
| 888 | + new Wordlift_Chord_Shortcode(); |
|
| 889 | + new Wordlift_Geomap_Shortcode(); |
|
| 890 | + new Wordlift_Timeline_Shortcode(); |
|
| 891 | + new Wordlift_Related_Entities_Cloud_Shortcode(); |
|
| 892 | 892 | |
| 893 | - // Initialize the SEO service. |
|
| 894 | - new Wordlift_Seo_Service(); |
|
| 893 | + // Initialize the SEO service. |
|
| 894 | + new Wordlift_Seo_Service(); |
|
| 895 | 895 | |
| 896 | - // Initialize the AMP service. |
|
| 897 | - new Wordlift_AMP_Service(); |
|
| 896 | + // Initialize the AMP service. |
|
| 897 | + new Wordlift_AMP_Service(); |
|
| 898 | 898 | |
| 899 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 899 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 900 | 900 | |
| 901 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 901 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 902 | 902 | |
| 903 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 904 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 903 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 904 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 905 | 905 | |
| 906 | - // Create an instance of the PrimaShop adapter. |
|
| 907 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 906 | + // Create an instance of the PrimaShop adapter. |
|
| 907 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 908 | 908 | |
| 909 | - // Create an import service instance to hook later to WP's import function. |
|
| 910 | - $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() ); |
|
| 909 | + // Create an import service instance to hook later to WP's import function. |
|
| 910 | + $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() ); |
|
| 911 | 911 | |
| 912 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 912 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 913 | 913 | |
| 914 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 915 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 914 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 915 | + $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 916 | 916 | |
| 917 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 917 | + $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 918 | 918 | |
| 919 | - // Create the entity rating service. |
|
| 920 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 919 | + // Create the entity rating service. |
|
| 920 | + $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 921 | 921 | |
| 922 | - // Create entity list customization (wp-admin/edit.php) |
|
| 923 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 922 | + // Create entity list customization (wp-admin/edit.php) |
|
| 923 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 924 | 924 | |
| 925 | - // Create a new instance of the Redirect service. |
|
| 926 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service ); |
|
| 925 | + // Create a new instance of the Redirect service. |
|
| 926 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service ); |
|
| 927 | 927 | |
| 928 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 929 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 928 | + $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 929 | + $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 930 | 930 | |
| 931 | - $attachment_service = new Wordlift_Attachment_Service(); |
|
| 931 | + $attachment_service = new Wordlift_Attachment_Service(); |
|
| 932 | 932 | |
| 933 | - // Instantiate the JSON-LD service. |
|
| 934 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 935 | - $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 ); |
|
| 936 | - $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 ); |
|
| 937 | - $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 ); |
|
| 938 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter ); |
|
| 933 | + // Instantiate the JSON-LD service. |
|
| 934 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 935 | + $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 ); |
|
| 936 | + $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 ); |
|
| 937 | + $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 ); |
|
| 938 | + $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter ); |
|
| 939 | 939 | |
| 940 | - // Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins). |
|
| 941 | - $this->key_validation_service = new Wordlift_Key_Validation_Service(); |
|
| 940 | + // Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins). |
|
| 941 | + $this->key_validation_service = new Wordlift_Key_Validation_Service(); |
|
| 942 | 942 | |
| 943 | - // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 944 | - $publisher_service = new Wordlift_Publisher_Service(); |
|
| 945 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 943 | + // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 944 | + $publisher_service = new Wordlift_Publisher_Service(); |
|
| 945 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 946 | 946 | |
| 947 | - /** Adapters. */ |
|
| 948 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 947 | + /** Adapters. */ |
|
| 948 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 949 | 949 | |
| 950 | - /** WordPress Admin UI. */ |
|
| 950 | + /** WordPress Admin UI. */ |
|
| 951 | 951 | |
| 952 | - // UI elements. |
|
| 953 | - $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 954 | - $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 955 | - $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 956 | - $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 957 | - $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 958 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 952 | + // UI elements. |
|
| 953 | + $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 954 | + $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 955 | + $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 956 | + $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 957 | + $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 958 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 959 | 959 | |
| 960 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 961 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 962 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 960 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 961 | + $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 962 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 963 | 963 | |
| 964 | - // Pages. |
|
| 965 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 964 | + // Pages. |
|
| 965 | + new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 966 | 966 | |
| 967 | - // create an instance of the entity type list admin page controller. |
|
| 968 | - $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 967 | + // create an instance of the entity type list admin page controller. |
|
| 968 | + $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 969 | 969 | |
| 970 | - // create an instance of the entity type etting admin page controller. |
|
| 971 | - $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 970 | + // create an instance of the entity type etting admin page controller. |
|
| 971 | + $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 972 | 972 | |
| 973 | - /** Widgets */ |
|
| 974 | - $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 973 | + /** Widgets */ |
|
| 974 | + $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 975 | 975 | |
| 976 | - //** WordPress Admin */ |
|
| 977 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 978 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 976 | + //** WordPress Admin */ |
|
| 977 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 978 | + $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 979 | 979 | |
| 980 | - // Create an instance of the install wizard. |
|
| 981 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 980 | + // Create an instance of the install wizard. |
|
| 981 | + $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 982 | 982 | |
| 983 | - // Create an instance of the content filter service. |
|
| 984 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service ); |
|
| 983 | + // Create an instance of the content filter service. |
|
| 984 | + $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service ); |
|
| 985 | 985 | |
| 986 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 986 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 987 | 987 | |
| 988 | - $this->event_entity_page_service = new Wordlift_Event_Entity_Page_Service(); |
|
| 988 | + $this->event_entity_page_service = new Wordlift_Event_Entity_Page_Service(); |
|
| 989 | 989 | |
| 990 | - // Load the debug service if WP is in debug mode. |
|
| 991 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 992 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 993 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 994 | - } |
|
| 990 | + // Load the debug service if WP is in debug mode. |
|
| 991 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 992 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 993 | + new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 994 | + } |
|
| 995 | 995 | |
| 996 | - } |
|
| 996 | + } |
|
| 997 | 997 | |
| 998 | - /** |
|
| 999 | - * Define the locale for this plugin for internationalization. |
|
| 1000 | - * |
|
| 1001 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1002 | - * with WordPress. |
|
| 1003 | - * |
|
| 1004 | - * @since 1.0.0 |
|
| 1005 | - * @access private |
|
| 1006 | - */ |
|
| 1007 | - private function set_locale() { |
|
| 998 | + /** |
|
| 999 | + * Define the locale for this plugin for internationalization. |
|
| 1000 | + * |
|
| 1001 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1002 | + * with WordPress. |
|
| 1003 | + * |
|
| 1004 | + * @since 1.0.0 |
|
| 1005 | + * @access private |
|
| 1006 | + */ |
|
| 1007 | + private function set_locale() { |
|
| 1008 | 1008 | |
| 1009 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 1010 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1009 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 1010 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1011 | 1011 | |
| 1012 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1012 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1013 | 1013 | |
| 1014 | - } |
|
| 1014 | + } |
|
| 1015 | 1015 | |
| 1016 | - /** |
|
| 1017 | - * Register all of the hooks related to the admin area functionality |
|
| 1018 | - * of the plugin. |
|
| 1019 | - * |
|
| 1020 | - * @since 1.0.0 |
|
| 1021 | - * @access private |
|
| 1022 | - */ |
|
| 1023 | - private function define_admin_hooks() { |
|
| 1016 | + /** |
|
| 1017 | + * Register all of the hooks related to the admin area functionality |
|
| 1018 | + * of the plugin. |
|
| 1019 | + * |
|
| 1020 | + * @since 1.0.0 |
|
| 1021 | + * @access private |
|
| 1022 | + */ |
|
| 1023 | + private function define_admin_hooks() { |
|
| 1024 | 1024 | |
| 1025 | - $plugin_admin = new Wordlift_Admin( |
|
| 1026 | - $this->get_plugin_name(), |
|
| 1027 | - $this->get_version(), |
|
| 1028 | - $this->configuration_service, |
|
| 1029 | - $this->notice_service |
|
| 1030 | - ); |
|
| 1025 | + $plugin_admin = new Wordlift_Admin( |
|
| 1026 | + $this->get_plugin_name(), |
|
| 1027 | + $this->get_version(), |
|
| 1028 | + $this->configuration_service, |
|
| 1029 | + $this->notice_service |
|
| 1030 | + ); |
|
| 1031 | 1031 | |
| 1032 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1033 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1032 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1033 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1034 | 1034 | |
| 1035 | - // Hook the init action to the Topic Taxonomy service. |
|
| 1036 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1035 | + // Hook the init action to the Topic Taxonomy service. |
|
| 1036 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1037 | 1037 | |
| 1038 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1039 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1038 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1039 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1040 | 1040 | |
| 1041 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 1042 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1041 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 1042 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1043 | 1043 | |
| 1044 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1045 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1044 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1045 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1046 | 1046 | |
| 1047 | - // Hook posts inserts (or updates) to the user service. |
|
| 1048 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 1047 | + // Hook posts inserts (or updates) to the user service. |
|
| 1048 | + $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 1049 | 1049 | |
| 1050 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1051 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1052 | - |
|
| 1053 | - // Register custom allowed redirect hosts. |
|
| 1054 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1055 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1056 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1057 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1058 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1059 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1060 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1050 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1051 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1052 | + |
|
| 1053 | + // Register custom allowed redirect hosts. |
|
| 1054 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1055 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1056 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1057 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1058 | + $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1059 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1060 | + $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1061 | 1061 | |
| 1062 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1063 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1064 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1065 | - $this->loader->add_action( 'save_post_entity', $this->rating_service, 'set_rating_for', 10, 1 ); |
|
| 1062 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1063 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1064 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1065 | + $this->loader->add_action( 'save_post_entity', $this->rating_service, 'set_rating_for', 10, 1 ); |
|
| 1066 | 1066 | |
| 1067 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1068 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1067 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1068 | + $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1069 | 1069 | |
| 1070 | - // Entity listing customization (wp-admin/edit.php) |
|
| 1071 | - // Add custom columns |
|
| 1072 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1073 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1074 | - // Add 4W selection |
|
| 1075 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1076 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1070 | + // Entity listing customization (wp-admin/edit.php) |
|
| 1071 | + // Add custom columns |
|
| 1072 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1073 | + $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1074 | + // Add 4W selection |
|
| 1075 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1076 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1077 | 1077 | |
| 1078 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1078 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1079 | 1079 | |
| 1080 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1081 | - // entities. |
|
| 1082 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1080 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1081 | + // entities. |
|
| 1082 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1083 | 1083 | |
| 1084 | - // Filter imported post meta. |
|
| 1085 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1084 | + // Filter imported post meta. |
|
| 1085 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1086 | 1086 | |
| 1087 | - // Notify the import service when an import starts and ends. |
|
| 1088 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1089 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1090 | - |
|
| 1091 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1092 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1087 | + // Notify the import service when an import starts and ends. |
|
| 1088 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1089 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1090 | + |
|
| 1091 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1092 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1093 | 1093 | |
| 1094 | - // Hook the menu to the Download Your Data page. |
|
| 1095 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1096 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1097 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1098 | - |
|
| 1099 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1100 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1094 | + // Hook the menu to the Download Your Data page. |
|
| 1095 | + $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1096 | + $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1097 | + $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1098 | + |
|
| 1099 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1100 | + $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1101 | 1101 | |
| 1102 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1103 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1102 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1103 | + $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1104 | 1104 | |
| 1105 | - // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1106 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1105 | + // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1106 | + $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1107 | 1107 | |
| 1108 | - // Hook the `admin_init` function to the Admin Setup. |
|
| 1109 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1108 | + // Hook the `admin_init` function to the Admin Setup. |
|
| 1109 | + $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1110 | 1110 | |
| 1111 | - // Hook the admin_init to the settings page. |
|
| 1112 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1111 | + // Hook the admin_init to the settings page. |
|
| 1112 | + $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1113 | 1113 | |
| 1114 | - // Hook the menu creation on the general wordlift menu creation |
|
| 1115 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1116 | - |
|
| 1117 | - // Hook key update. |
|
| 1118 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1119 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1114 | + // Hook the menu creation on the general wordlift menu creation |
|
| 1115 | + $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1116 | + |
|
| 1117 | + // Hook key update. |
|
| 1118 | + $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1119 | + $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1120 | 1120 | |
| 1121 | - // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1122 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1121 | + // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1122 | + $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1123 | 1123 | |
| 1124 | - // Hook the AJAX `wl_publisher` action name. |
|
| 1125 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1124 | + // Hook the AJAX `wl_publisher` action name. |
|
| 1125 | + $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1126 | 1126 | |
| 1127 | - // Hook row actions for the entity type list admin. |
|
| 1128 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1127 | + // Hook row actions for the entity type list admin. |
|
| 1128 | + $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1129 | 1129 | |
| 1130 | - // Hook capabilities manipulation to allow access to entity type admin |
|
| 1131 | - // page on wordpress versions before 4.7. |
|
| 1132 | - global $wp_version; |
|
| 1133 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1134 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1135 | - } |
|
| 1130 | + // Hook capabilities manipulation to allow access to entity type admin |
|
| 1131 | + // page on wordpress versions before 4.7. |
|
| 1132 | + global $wp_version; |
|
| 1133 | + if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1134 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1135 | + } |
|
| 1136 | 1136 | |
| 1137 | - /** Adapters. */ |
|
| 1138 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1137 | + /** Adapters. */ |
|
| 1138 | + $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1139 | 1139 | |
| 1140 | - // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1141 | - if ( is_multisite() ) { |
|
| 1142 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1143 | - } |
|
| 1144 | - } |
|
| 1140 | + // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1141 | + if ( is_multisite() ) { |
|
| 1142 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1143 | + } |
|
| 1144 | + } |
|
| 1145 | 1145 | |
| 1146 | - /** |
|
| 1147 | - * Register all of the hooks related to the public-facing functionality |
|
| 1148 | - * of the plugin. |
|
| 1149 | - * |
|
| 1150 | - * @since 1.0.0 |
|
| 1151 | - * @access private |
|
| 1152 | - */ |
|
| 1153 | - private function define_public_hooks() { |
|
| 1146 | + /** |
|
| 1147 | + * Register all of the hooks related to the public-facing functionality |
|
| 1148 | + * of the plugin. |
|
| 1149 | + * |
|
| 1150 | + * @since 1.0.0 |
|
| 1151 | + * @access private |
|
| 1152 | + */ |
|
| 1153 | + private function define_public_hooks() { |
|
| 1154 | 1154 | |
| 1155 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1155 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1156 | 1156 | |
| 1157 | - // Register the entity post type. |
|
| 1158 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1157 | + // Register the entity post type. |
|
| 1158 | + $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1159 | 1159 | |
| 1160 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 1161 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1162 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 1163 | - $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 ); |
|
| 1164 | - $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 ); |
|
| 1160 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 1161 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1162 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 1163 | + $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 ); |
|
| 1164 | + $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 ); |
|
| 1165 | 1165 | |
| 1166 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1167 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1166 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1167 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1168 | 1168 | |
| 1169 | - // Hook the content filter service to add entity links. |
|
| 1170 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1169 | + // Hook the content filter service to add entity links. |
|
| 1170 | + $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1171 | 1171 | |
| 1172 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1173 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1172 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1173 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1174 | 1174 | |
| 1175 | - // Hook the ShareThis service. |
|
| 1176 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1177 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1175 | + // Hook the ShareThis service. |
|
| 1176 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1177 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1178 | 1178 | |
| 1179 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1180 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1179 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1180 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1181 | 1181 | |
| 1182 | - // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1183 | - // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1184 | - // to categories. |
|
| 1185 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1182 | + // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1183 | + // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1184 | + // to categories. |
|
| 1185 | + $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1186 | 1186 | |
| 1187 | - /* |
|
| 1187 | + /* |
|
| 1188 | 1188 | * Hook the `pre_get_posts` action to the `Wordlift_Event_Entity_Page_Service` |
| 1189 | 1189 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1190 | 1190 | * order of start time. |
| 1191 | 1191 | */ |
| 1192 | - $this->loader->add_action( 'pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1193 | - |
|
| 1194 | - } |
|
| 1195 | - |
|
| 1196 | - /** |
|
| 1197 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 1198 | - * |
|
| 1199 | - * @since 1.0.0 |
|
| 1200 | - */ |
|
| 1201 | - public function run() { |
|
| 1202 | - $this->loader->run(); |
|
| 1203 | - } |
|
| 1204 | - |
|
| 1205 | - /** |
|
| 1206 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 1207 | - * WordPress and to define internationalization functionality. |
|
| 1208 | - * |
|
| 1209 | - * @since 1.0.0 |
|
| 1210 | - * @return string The name of the plugin. |
|
| 1211 | - */ |
|
| 1212 | - public function get_plugin_name() { |
|
| 1213 | - return $this->plugin_name; |
|
| 1214 | - } |
|
| 1215 | - |
|
| 1216 | - /** |
|
| 1217 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1218 | - * |
|
| 1219 | - * @since 1.0.0 |
|
| 1220 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1221 | - */ |
|
| 1222 | - public function get_loader() { |
|
| 1223 | - return $this->loader; |
|
| 1224 | - } |
|
| 1225 | - |
|
| 1226 | - /** |
|
| 1227 | - * Retrieve the version number of the plugin. |
|
| 1228 | - * |
|
| 1229 | - * @since 1.0.0 |
|
| 1230 | - * @return string The version number of the plugin. |
|
| 1231 | - */ |
|
| 1232 | - public function get_version() { |
|
| 1233 | - return $this->version; |
|
| 1234 | - } |
|
| 1192 | + $this->loader->add_action( 'pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1193 | + |
|
| 1194 | + } |
|
| 1195 | + |
|
| 1196 | + /** |
|
| 1197 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 1198 | + * |
|
| 1199 | + * @since 1.0.0 |
|
| 1200 | + */ |
|
| 1201 | + public function run() { |
|
| 1202 | + $this->loader->run(); |
|
| 1203 | + } |
|
| 1204 | + |
|
| 1205 | + /** |
|
| 1206 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 1207 | + * WordPress and to define internationalization functionality. |
|
| 1208 | + * |
|
| 1209 | + * @since 1.0.0 |
|
| 1210 | + * @return string The name of the plugin. |
|
| 1211 | + */ |
|
| 1212 | + public function get_plugin_name() { |
|
| 1213 | + return $this->plugin_name; |
|
| 1214 | + } |
|
| 1215 | + |
|
| 1216 | + /** |
|
| 1217 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1218 | + * |
|
| 1219 | + * @since 1.0.0 |
|
| 1220 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1221 | + */ |
|
| 1222 | + public function get_loader() { |
|
| 1223 | + return $this->loader; |
|
| 1224 | + } |
|
| 1225 | + |
|
| 1226 | + /** |
|
| 1227 | + * Retrieve the version number of the plugin. |
|
| 1228 | + * |
|
| 1229 | + * @since 1.0.0 |
|
| 1230 | + * @return string The version number of the plugin. |
|
| 1231 | + */ |
|
| 1232 | + public function get_version() { |
|
| 1233 | + return $this->version; |
|
| 1234 | + } |
|
| 1235 | 1235 | |
| 1236 | 1236 | } |
@@ -538,323 +538,323 @@ discard block |
||
| 538 | 538 | * The class responsible for orchestrating the actions and filters of the |
| 539 | 539 | * core plugin. |
| 540 | 540 | */ |
| 541 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 541 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php'; |
|
| 542 | 542 | |
| 543 | 543 | /** |
| 544 | 544 | * The class responsible for defining internationalization functionality |
| 545 | 545 | * of the plugin. |
| 546 | 546 | */ |
| 547 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 547 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php'; |
|
| 548 | 548 | |
| 549 | 549 | /** |
| 550 | 550 | * WordLift's supported languages. |
| 551 | 551 | */ |
| 552 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 552 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-languages.php'; |
|
| 553 | 553 | |
| 554 | 554 | /** |
| 555 | 555 | * Provide support functions to sanitize data. |
| 556 | 556 | */ |
| 557 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 557 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php'; |
|
| 558 | 558 | |
| 559 | 559 | /** |
| 560 | 560 | * The Redirect service. |
| 561 | 561 | */ |
| 562 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 562 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php'; |
|
| 563 | 563 | |
| 564 | 564 | /** |
| 565 | 565 | * The Log service. |
| 566 | 566 | */ |
| 567 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 567 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php'; |
|
| 568 | 568 | |
| 569 | 569 | /** |
| 570 | 570 | * The configuration service. |
| 571 | 571 | */ |
| 572 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 572 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php'; |
|
| 573 | 573 | |
| 574 | 574 | /** |
| 575 | 575 | * The entity post type service (this is the WordPress post type, not the entity schema type). |
| 576 | 576 | */ |
| 577 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 577 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-type-service.php'; |
|
| 578 | 578 | |
| 579 | 579 | /** |
| 580 | 580 | * The entity type service (i.e. the schema type). |
| 581 | 581 | */ |
| 582 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 582 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php'; |
|
| 583 | 583 | |
| 584 | 584 | /** |
| 585 | 585 | * The entity link service. |
| 586 | 586 | */ |
| 587 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 587 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php'; |
|
| 588 | 588 | |
| 589 | 589 | /** |
| 590 | 590 | * The Query builder. |
| 591 | 591 | */ |
| 592 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 592 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php'; |
|
| 593 | 593 | |
| 594 | 594 | /** |
| 595 | 595 | * The Schema service. |
| 596 | 596 | */ |
| 597 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 597 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php'; |
|
| 598 | 598 | |
| 599 | 599 | /** |
| 600 | 600 | * The schema:url property service. |
| 601 | 601 | */ |
| 602 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 603 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 602 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-service.php'; |
|
| 603 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-url-property-service.php'; |
|
| 604 | 604 | |
| 605 | 605 | /** |
| 606 | 606 | * The UI service. |
| 607 | 607 | */ |
| 608 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 608 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php'; |
|
| 609 | 609 | |
| 610 | 610 | /** |
| 611 | 611 | * The Thumbnail service. |
| 612 | 612 | */ |
| 613 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 613 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php'; |
|
| 614 | 614 | |
| 615 | 615 | /** |
| 616 | 616 | * The Entity Types Taxonomy service. |
| 617 | 617 | */ |
| 618 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 618 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 619 | 619 | |
| 620 | 620 | /** |
| 621 | 621 | * The Entity service. |
| 622 | 622 | */ |
| 623 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 623 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php'; |
|
| 624 | 624 | |
| 625 | 625 | // Add the entity rating service. |
| 626 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 626 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rating-service.php'; |
|
| 627 | 627 | |
| 628 | 628 | /** |
| 629 | 629 | * The User service. |
| 630 | 630 | */ |
| 631 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 631 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php'; |
|
| 632 | 632 | |
| 633 | 633 | /** |
| 634 | 634 | * The Timeline service. |
| 635 | 635 | */ |
| 636 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 636 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php'; |
|
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | 639 | * The Topic Taxonomy service. |
| 640 | 640 | */ |
| 641 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 641 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 642 | 642 | |
| 643 | 643 | /** |
| 644 | 644 | * The SPARQL service. |
| 645 | 645 | */ |
| 646 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 646 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php'; |
|
| 647 | 647 | |
| 648 | 648 | /** |
| 649 | 649 | * The WordLift import service. |
| 650 | 650 | */ |
| 651 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 651 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php'; |
|
| 652 | 652 | |
| 653 | 653 | /** |
| 654 | 654 | * The WordLift URI service. |
| 655 | 655 | */ |
| 656 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 656 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php'; |
|
| 657 | 657 | |
| 658 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 658 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-listable.php'; |
|
| 659 | 659 | |
| 660 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 660 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-factory.php'; |
|
| 661 | 661 | |
| 662 | 662 | /** |
| 663 | 663 | * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
| 664 | 664 | */ |
| 665 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 665 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rebuild-service.php'; |
|
| 666 | 666 | |
| 667 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 667 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 668 | 668 | |
| 669 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 669 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-attachment-service.php'; |
|
| 670 | 670 | |
| 671 | 671 | /** |
| 672 | 672 | * Load the converters. |
| 673 | 673 | */ |
| 674 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 675 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 676 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 677 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 678 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 674 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/intf-wordlift-post-converter.php'; |
|
| 675 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 676 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 677 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 678 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 679 | 679 | |
| 680 | 680 | /** |
| 681 | 681 | * Load the content filter. |
| 682 | 682 | */ |
| 683 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 683 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-content-filter-service.php'; |
|
| 684 | 684 | |
| 685 | 685 | /* |
| 686 | 686 | * Load the excerpt helper. |
| 687 | 687 | */ |
| 688 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 688 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 689 | 689 | |
| 690 | 690 | /** |
| 691 | 691 | * Load the JSON-LD service to publish entities using JSON-LD.s |
| 692 | 692 | * |
| 693 | 693 | * @since 3.8.0 |
| 694 | 694 | */ |
| 695 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 695 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-service.php'; |
|
| 696 | 696 | |
| 697 | 697 | // The Publisher Service and the AJAX adapter. |
| 698 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 699 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 698 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-service.php'; |
|
| 699 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 700 | 700 | |
| 701 | 701 | /** |
| 702 | 702 | * Load the WordLift key validation service. |
| 703 | 703 | */ |
| 704 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 704 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-key-validation-service.php'; |
|
| 705 | 705 | |
| 706 | 706 | // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
| 707 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 707 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 708 | 708 | |
| 709 | 709 | // Load the `Wordlift_Event_Entity_Page_Service` class definition. |
| 710 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-event-entity-page-service.php'; |
|
| 710 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-event-entity-page-service.php'; |
|
| 711 | 711 | |
| 712 | 712 | /** Adapters. */ |
| 713 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 714 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 713 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-tinymce-adapter.php'; |
|
| 714 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-newrelic-adapter.php'; |
|
| 715 | 715 | |
| 716 | 716 | /** |
| 717 | 717 | * The class responsible for defining all actions that occur in the admin area. |
| 718 | 718 | */ |
| 719 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 719 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php'; |
|
| 720 | 720 | |
| 721 | 721 | /** |
| 722 | 722 | * The class to customize the entity list admin page. |
| 723 | 723 | */ |
| 724 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 724 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php'; |
|
| 725 | 725 | |
| 726 | 726 | /** |
| 727 | 727 | * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
| 728 | 728 | */ |
| 729 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 729 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 730 | 730 | |
| 731 | 731 | /** |
| 732 | 732 | * The Notice service. |
| 733 | 733 | */ |
| 734 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 734 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php'; |
|
| 735 | 735 | |
| 736 | 736 | /** |
| 737 | 737 | * The PrimaShop adapter. |
| 738 | 738 | */ |
| 739 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 739 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php'; |
|
| 740 | 740 | |
| 741 | 741 | /** |
| 742 | 742 | * The WordLift Dashboard service. |
| 743 | 743 | */ |
| 744 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 744 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php'; |
|
| 745 | 745 | |
| 746 | 746 | /** |
| 747 | 747 | * The admin 'Install wizard' page. |
| 748 | 748 | */ |
| 749 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 749 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-setup.php'; |
|
| 750 | 750 | |
| 751 | 751 | /** |
| 752 | 752 | * The WordLift entity type list admin page controller. |
| 753 | 753 | */ |
| 754 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 754 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 755 | 755 | |
| 756 | 756 | /** |
| 757 | 757 | * The WordLift entity type settings admin page controller. |
| 758 | 758 | */ |
| 759 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 759 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-settings.php'; |
|
| 760 | 760 | |
| 761 | 761 | /** |
| 762 | 762 | * The admin 'Download Your Data' page. |
| 763 | 763 | */ |
| 764 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 764 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php'; |
|
| 765 | 765 | |
| 766 | 766 | /** |
| 767 | 767 | * The admin 'Download Your Data' page. |
| 768 | 768 | */ |
| 769 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 769 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php'; |
|
| 770 | 770 | |
| 771 | 771 | /** |
| 772 | 772 | * The admin 'WordLift Settings' page. |
| 773 | 773 | */ |
| 774 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 775 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 776 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 777 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 778 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 779 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 780 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 781 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 782 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 783 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 774 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/intf-wordlift-admin-element.php'; |
|
| 775 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-input-element.php'; |
|
| 776 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 777 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-select2-element.php'; |
|
| 778 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-language-select-element.php'; |
|
| 779 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-tabs-element.php'; |
|
| 780 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-publisher-element.php'; |
|
| 781 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-page.php'; |
|
| 782 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page.php'; |
|
| 783 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 784 | 784 | |
| 785 | 785 | /** Admin Pages */ |
| 786 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 787 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 786 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 787 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-status-page.php'; |
|
| 788 | 788 | |
| 789 | 789 | /** |
| 790 | 790 | * The class responsible for defining all actions that occur in the public-facing |
| 791 | 791 | * side of the site. |
| 792 | 792 | */ |
| 793 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 793 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php'; |
|
| 794 | 794 | |
| 795 | 795 | /** |
| 796 | 796 | * The shortcode abstract class. |
| 797 | 797 | */ |
| 798 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 798 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php'; |
|
| 799 | 799 | |
| 800 | 800 | /** |
| 801 | 801 | * The Timeline shortcode. |
| 802 | 802 | */ |
| 803 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 803 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php'; |
|
| 804 | 804 | |
| 805 | 805 | /** |
| 806 | 806 | * The Navigator shortcode. |
| 807 | 807 | */ |
| 808 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 808 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php'; |
|
| 809 | 809 | |
| 810 | 810 | /** |
| 811 | 811 | * The chord shortcode. |
| 812 | 812 | */ |
| 813 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 813 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php'; |
|
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | 816 | * The geomap shortcode. |
| 817 | 817 | */ |
| 818 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 818 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php'; |
|
| 819 | 819 | |
| 820 | 820 | /** |
| 821 | 821 | * The entity cloud shortcode. |
| 822 | 822 | */ |
| 823 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 823 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 824 | 824 | |
| 825 | 825 | /** |
| 826 | 826 | * The ShareThis service. |
| 827 | 827 | */ |
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 828 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php'; |
|
| 829 | 829 | |
| 830 | 830 | /** |
| 831 | 831 | * The SEO service. |
| 832 | 832 | */ |
| 833 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 833 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-seo-service.php'; |
|
| 834 | 834 | |
| 835 | 835 | /** |
| 836 | 836 | * The AMP service. |
| 837 | 837 | */ |
| 838 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 838 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-amp-service.php'; |
|
| 839 | 839 | |
| 840 | 840 | /** Widgets */ |
| 841 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 842 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 841 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-widget.php'; |
|
| 842 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 843 | 843 | |
| 844 | 844 | $this->loader = new Wordlift_Loader(); |
| 845 | 845 | |
| 846 | 846 | // Instantiate a global logger. |
| 847 | 847 | global $wl_logger; |
| 848 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 848 | + $wl_logger = Wordlift_Log_Service::get_logger('WordLift'); |
|
| 849 | 849 | |
| 850 | 850 | // Create the configuration service. |
| 851 | 851 | $this->configuration_service = new Wordlift_Configuration_Service(); |
| 852 | 852 | |
| 853 | 853 | // Create an entity type service instance. It'll be later bound to the init action. |
| 854 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 854 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path()); |
|
| 855 | 855 | |
| 856 | 856 | // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
| 857 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 857 | + $this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_post_type_service, $this->configuration_service->get_entity_base_path()); |
|
| 858 | 858 | |
| 859 | 859 | // Create an instance of the UI service. |
| 860 | 860 | $this->ui_service = new Wordlift_UI_Service(); |
@@ -865,23 +865,23 @@ discard block |
||
| 865 | 865 | $this->sparql_service = new Wordlift_Sparql_Service(); |
| 866 | 866 | |
| 867 | 867 | // Create an instance of the Schema service. |
| 868 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 868 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service($this->sparql_service); |
|
| 869 | 869 | $this->schema_service = new Wordlift_Schema_Service(); |
| 870 | 870 | |
| 871 | 871 | // Create an instance of the Notice service. |
| 872 | 872 | $this->notice_service = new Wordlift_Notice_Service(); |
| 873 | 873 | |
| 874 | 874 | // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
| 875 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service ); |
|
| 875 | + $this->entity_service = new Wordlift_Entity_Service($this->ui_service); |
|
| 876 | 876 | |
| 877 | 877 | // Create an instance of the User service. |
| 878 | 878 | $this->user_service = new Wordlift_User_Service(); |
| 879 | 879 | |
| 880 | 880 | // Create a new instance of the Timeline service and Timeline shortcode. |
| 881 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 881 | + $this->timeline_service = new Wordlift_Timeline_Service($this->entity_service); |
|
| 882 | 882 | |
| 883 | 883 | // Create a new instance of the Redirect service. |
| 884 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 884 | + $this->redirect_service = new Wordlift_Redirect_Service($this->entity_service); |
|
| 885 | 885 | |
| 886 | 886 | // Initialize the shortcodes. |
| 887 | 887 | new Wordlift_Navigator_Shortcode(); |
@@ -907,45 +907,45 @@ discard block |
||
| 907 | 907 | $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
| 908 | 908 | |
| 909 | 909 | // Create an import service instance to hook later to WP's import function. |
| 910 | - $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() ); |
|
| 910 | + $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()); |
|
| 911 | 911 | |
| 912 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 912 | + $uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']); |
|
| 913 | 913 | |
| 914 | 914 | // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
| 915 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 915 | + $this->rebuild_service = new Wordlift_Rebuild_Service($this->sparql_service, $uri_service); |
|
| 916 | 916 | |
| 917 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 917 | + $this->entity_type_service = new Wordlift_Entity_Type_Service($this->schema_service); |
|
| 918 | 918 | |
| 919 | 919 | // Create the entity rating service. |
| 920 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 920 | + $this->rating_service = new Wordlift_Rating_Service($this->entity_service, $this->entity_type_service, $this->notice_service); |
|
| 921 | 921 | |
| 922 | 922 | // Create entity list customization (wp-admin/edit.php) |
| 923 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 923 | + $this->entity_list_service = new Wordlift_Entity_List_Service($this->rating_service); |
|
| 924 | 924 | |
| 925 | 925 | // Create a new instance of the Redirect service. |
| 926 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service ); |
|
| 926 | + $this->dashboard_service = new Wordlift_Dashboard_Service($this->rating_service); |
|
| 927 | 927 | |
| 928 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 929 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 928 | + $this->property_factory = new Wordlift_Property_Factory($schema_url_property_service); |
|
| 929 | + $this->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service); |
|
| 930 | 930 | |
| 931 | 931 | $attachment_service = new Wordlift_Attachment_Service(); |
| 932 | 932 | |
| 933 | 933 | // Instantiate the JSON-LD service. |
| 934 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 935 | - $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 ); |
|
| 936 | - $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 ); |
|
| 937 | - $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 ); |
|
| 938 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter ); |
|
| 934 | + $property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service); |
|
| 935 | + $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); |
|
| 936 | + $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); |
|
| 937 | + $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); |
|
| 938 | + $this->jsonld_service = new Wordlift_Jsonld_Service($this->entity_service, $this->postid_to_jsonld_converter); |
|
| 939 | 939 | |
| 940 | 940 | // Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins). |
| 941 | 941 | $this->key_validation_service = new Wordlift_Key_Validation_Service(); |
| 942 | 942 | |
| 943 | 943 | // Create an instance of the Publisher Service and the AJAX Adapter. |
| 944 | 944 | $publisher_service = new Wordlift_Publisher_Service(); |
| 945 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 945 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter($publisher_service); |
|
| 946 | 946 | |
| 947 | 947 | /** Adapters. */ |
| 948 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 948 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter($this); |
|
| 949 | 949 | |
| 950 | 950 | /** WordPress Admin UI. */ |
| 951 | 951 | |
@@ -955,14 +955,14 @@ discard block |
||
| 955 | 955 | $this->select2_element = new Wordlift_Admin_Select2_Element(); |
| 956 | 956 | $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
| 957 | 957 | $tabs_element = new Wordlift_Admin_Tabs_Element(); |
| 958 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 958 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element($this->configuration_service, $publisher_service, $tabs_element, $this->select2_element); |
|
| 959 | 959 | |
| 960 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 961 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 962 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 960 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service); |
|
| 961 | + $this->settings_page = new Wordlift_Admin_Settings_Page($this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element); |
|
| 962 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link($this->settings_page); |
|
| 963 | 963 | |
| 964 | 964 | // Pages. |
| 965 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 965 | + new Wordlift_Admin_Post_Edit_Page($this); |
|
| 966 | 966 | |
| 967 | 967 | // create an instance of the entity type list admin page controller. |
| 968 | 968 | $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
@@ -974,23 +974,23 @@ discard block |
||
| 974 | 974 | $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
| 975 | 975 | |
| 976 | 976 | //** WordPress Admin */ |
| 977 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 978 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 977 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service); |
|
| 978 | + $this->status_page = new Wordlift_Admin_Status_Page($this->entity_service, $this->sparql_service); |
|
| 979 | 979 | |
| 980 | 980 | // Create an instance of the install wizard. |
| 981 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 981 | + $this->admin_setup = new Wordlift_Admin_Setup($this->configuration_service, $this->key_validation_service, $this->entity_service); |
|
| 982 | 982 | |
| 983 | 983 | // Create an instance of the content filter service. |
| 984 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service ); |
|
| 984 | + $this->content_filter_service = new Wordlift_Content_Filter_Service($this->entity_service, $this->configuration_service); |
|
| 985 | 985 | |
| 986 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 986 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service($this->entity_post_type_service); |
|
| 987 | 987 | |
| 988 | 988 | $this->event_entity_page_service = new Wordlift_Event_Entity_Page_Service(); |
| 989 | 989 | |
| 990 | 990 | // Load the debug service if WP is in debug mode. |
| 991 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 992 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 993 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 991 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
| 992 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-debug-service.php'; |
|
| 993 | + new Wordlift_Debug_Service($this->entity_service, $uri_service); |
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | } |
@@ -1007,9 +1007,9 @@ discard block |
||
| 1007 | 1007 | private function set_locale() { |
| 1008 | 1008 | |
| 1009 | 1009 | $plugin_i18n = new Wordlift_i18n(); |
| 1010 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1010 | + $plugin_i18n->set_domain($this->get_plugin_name()); |
|
| 1011 | 1011 | |
| 1012 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1012 | + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
| 1013 | 1013 | |
| 1014 | 1014 | } |
| 1015 | 1015 | |
@@ -1029,117 +1029,117 @@ discard block |
||
| 1029 | 1029 | $this->notice_service |
| 1030 | 1030 | ); |
| 1031 | 1031 | |
| 1032 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1033 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1032 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
| 1033 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); |
|
| 1034 | 1034 | |
| 1035 | 1035 | // Hook the init action to the Topic Taxonomy service. |
| 1036 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1036 | + $this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0); |
|
| 1037 | 1037 | |
| 1038 | 1038 | // Hook the deleted_post_meta action to the Thumbnail service. |
| 1039 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1039 | + $this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4); |
|
| 1040 | 1040 | |
| 1041 | 1041 | // Hook the added_post_meta action to the Thumbnail service. |
| 1042 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1042 | + $this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1043 | 1043 | |
| 1044 | 1044 | // Hook the updated_post_meta action to the Thumbnail service. |
| 1045 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1045 | + $this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1046 | 1046 | |
| 1047 | 1047 | // Hook posts inserts (or updates) to the user service. |
| 1048 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 1048 | + $this->loader->add_action('wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3); |
|
| 1049 | 1049 | |
| 1050 | 1050 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1051 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1051 | + $this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1052 | 1052 | |
| 1053 | 1053 | // Register custom allowed redirect hosts. |
| 1054 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1054 | + $this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts'); |
|
| 1055 | 1055 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1056 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1056 | + $this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect'); |
|
| 1057 | 1057 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1058 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1058 | + $this->loader->add_action('wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats'); |
|
| 1059 | 1059 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1060 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1060 | + $this->loader->add_action('wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets'); |
|
| 1061 | 1061 | |
| 1062 | 1062 | // Hook save_post to the entity service to update custom fields (such as alternate labels). |
| 1063 | 1063 | // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
| 1064 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1065 | - $this->loader->add_action( 'save_post_entity', $this->rating_service, 'set_rating_for', 10, 1 ); |
|
| 1064 | + $this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3); |
|
| 1065 | + $this->loader->add_action('save_post_entity', $this->rating_service, 'set_rating_for', 10, 1); |
|
| 1066 | 1066 | |
| 1067 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1068 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1067 | + $this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1); |
|
| 1068 | + $this->loader->add_action('in_admin_header', $this->rating_service, 'in_admin_header'); |
|
| 1069 | 1069 | |
| 1070 | 1070 | // Entity listing customization (wp-admin/edit.php) |
| 1071 | 1071 | // Add custom columns |
| 1072 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1073 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1072 | + $this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns'); |
|
| 1073 | + $this->loader->add_filter('manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2); |
|
| 1074 | 1074 | // Add 4W selection |
| 1075 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1076 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1075 | + $this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope'); |
|
| 1076 | + $this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope'); |
|
| 1077 | 1077 | |
| 1078 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1078 | + $this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args'); |
|
| 1079 | 1079 | |
| 1080 | 1080 | // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
| 1081 | 1081 | // entities. |
| 1082 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1082 | + $this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2); |
|
| 1083 | 1083 | |
| 1084 | 1084 | // Filter imported post meta. |
| 1085 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1085 | + $this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3); |
|
| 1086 | 1086 | |
| 1087 | 1087 | // Notify the import service when an import starts and ends. |
| 1088 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1089 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1088 | + $this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0); |
|
| 1089 | + $this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0); |
|
| 1090 | 1090 | |
| 1091 | 1091 | // Hook the AJAX wl_rebuild action to the Rebuild Service. |
| 1092 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1092 | + $this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild'); |
|
| 1093 | 1093 | |
| 1094 | 1094 | // Hook the menu to the Download Your Data page. |
| 1095 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1096 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1097 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1095 | + $this->loader->add_action('admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0); |
|
| 1096 | + $this->loader->add_action('admin_menu', $this->status_page, 'admin_menu', 100, 0); |
|
| 1097 | + $this->loader->add_action('admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0); |
|
| 1098 | 1098 | |
| 1099 | 1099 | // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
| 1100 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1100 | + $this->loader->add_action('wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10); |
|
| 1101 | 1101 | |
| 1102 | 1102 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1103 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1103 | + $this->loader->add_action('wp_ajax_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1104 | 1104 | |
| 1105 | 1105 | // Hook the AJAX wl_validate_key action to the Key Validation service. |
| 1106 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1106 | + $this->loader->add_action('wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key'); |
|
| 1107 | 1107 | |
| 1108 | 1108 | // Hook the `admin_init` function to the Admin Setup. |
| 1109 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1109 | + $this->loader->add_action('admin_init', $this->admin_setup, 'admin_init'); |
|
| 1110 | 1110 | |
| 1111 | 1111 | // Hook the admin_init to the settings page. |
| 1112 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1112 | + $this->loader->add_action('admin_init', $this->settings_page, 'admin_init'); |
|
| 1113 | 1113 | |
| 1114 | 1114 | // Hook the menu creation on the general wordlift menu creation |
| 1115 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1115 | + $this->loader->add_action('wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2); |
|
| 1116 | 1116 | |
| 1117 | 1117 | // Hook key update. |
| 1118 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1119 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1118 | + $this->loader->add_action('pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2); |
|
| 1119 | + $this->loader->add_action('update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2); |
|
| 1120 | 1120 | |
| 1121 | 1121 | // Add additional action links to the WordLift plugin in the plugins page. |
| 1122 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1122 | + $this->loader->add_filter('plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1); |
|
| 1123 | 1123 | |
| 1124 | 1124 | // Hook the AJAX `wl_publisher` action name. |
| 1125 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1125 | + $this->loader->add_action('wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher'); |
|
| 1126 | 1126 | |
| 1127 | 1127 | // Hook row actions for the entity type list admin. |
| 1128 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1128 | + $this->loader->add_filter('wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2); |
|
| 1129 | 1129 | |
| 1130 | 1130 | // Hook capabilities manipulation to allow access to entity type admin |
| 1131 | 1131 | // page on wordpress versions before 4.7. |
| 1132 | 1132 | global $wp_version; |
| 1133 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1134 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1133 | + if (version_compare($wp_version, '4.7', '<')) { |
|
| 1134 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4); |
|
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | 1137 | /** Adapters. */ |
| 1138 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1138 | + $this->loader->add_filter('mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1); |
|
| 1139 | 1139 | |
| 1140 | 1140 | // Hooks to restrict multisite super admin from manipulating entity types. |
| 1141 | - if ( is_multisite() ) { |
|
| 1142 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1141 | + if (is_multisite()) { |
|
| 1142 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4); |
|
| 1143 | 1143 | } |
| 1144 | 1144 | } |
| 1145 | 1145 | |
@@ -1152,44 +1152,44 @@ discard block |
||
| 1152 | 1152 | */ |
| 1153 | 1153 | private function define_public_hooks() { |
| 1154 | 1154 | |
| 1155 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1155 | + $plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version()); |
|
| 1156 | 1156 | |
| 1157 | 1157 | // Register the entity post type. |
| 1158 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1158 | + $this->loader->add_action('init', $this->entity_post_type_service, 'register'); |
|
| 1159 | 1159 | |
| 1160 | 1160 | // Bind the link generation and handling hooks to the entity link service. |
| 1161 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1162 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 1163 | - $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 ); |
|
| 1164 | - $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 ); |
|
| 1161 | + $this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4); |
|
| 1162 | + $this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1); |
|
| 1163 | + $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); |
|
| 1164 | + $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); |
|
| 1165 | 1165 | |
| 1166 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1167 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1166 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
| 1167 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
| 1168 | 1168 | |
| 1169 | 1169 | // Hook the content filter service to add entity links. |
| 1170 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1170 | + $this->loader->add_filter('the_content', $this->content_filter_service, 'the_content'); |
|
| 1171 | 1171 | |
| 1172 | 1172 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1173 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1173 | + $this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1174 | 1174 | |
| 1175 | 1175 | // Hook the ShareThis service. |
| 1176 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1177 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1176 | + $this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99); |
|
| 1177 | + $this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99); |
|
| 1178 | 1178 | |
| 1179 | 1179 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1180 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1180 | + $this->loader->add_action('wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1181 | 1181 | |
| 1182 | 1182 | // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
| 1183 | 1183 | // in order to tweak WP's `WP_Query` to include entities in queries related |
| 1184 | 1184 | // to categories. |
| 1185 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1185 | + $this->loader->add_action('pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1); |
|
| 1186 | 1186 | |
| 1187 | 1187 | /* |
| 1188 | 1188 | * Hook the `pre_get_posts` action to the `Wordlift_Event_Entity_Page_Service` |
| 1189 | 1189 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1190 | 1190 | * order of start time. |
| 1191 | 1191 | */ |
| 1192 | - $this->loader->add_action( 'pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1192 | + $this->loader->add_action('pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1); |
|
| 1193 | 1193 | |
| 1194 | 1194 | } |
| 1195 | 1195 | |
@@ -13,154 +13,154 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class Wordlift_Entity_Post_To_Jsonld_Converter extends Wordlift_Abstract_Post_To_Jsonld_Converter { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * A {@link Wordlift_Property_Getter} instance. |
|
| 18 | - * |
|
| 19 | - * @since 3.8.0 |
|
| 20 | - * @access private |
|
| 21 | - * @var \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 22 | - */ |
|
| 23 | - private $property_getter; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Wordlift_Entity_To_Jsonld_Converter constructor. |
|
| 27 | - * |
|
| 28 | - * @since 3.8.0 |
|
| 29 | - * |
|
| 30 | - * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 31 | - * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 32 | - * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 33 | - * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 34 | - * @param \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 35 | - */ |
|
| 36 | - public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service, $property_getter ) { |
|
| 37 | - parent::__construct( $entity_type_service, $entity_service, $user_service, $attachment_service ); |
|
| 38 | - |
|
| 39 | - $this->property_getter = $property_getter; |
|
| 40 | - |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 45 | - * found while processing the post is set in the $references array. |
|
| 46 | - * |
|
| 47 | - * @since 3.8.0 |
|
| 48 | - * |
|
| 49 | - * @param int $post_id The {@link WP_Post} id. |
|
| 50 | - * |
|
| 51 | - * @param array $references An array of entity references. |
|
| 52 | - * |
|
| 53 | - * @return array A JSON-LD array. |
|
| 54 | - */ |
|
| 55 | - public function convert( $post_id, &$references = array() ) { |
|
| 56 | - |
|
| 57 | - // Get the post instance. |
|
| 58 | - if ( null === $post = get_post( $post_id ) ) { |
|
| 59 | - // Post not found. |
|
| 60 | - return null; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // Get the base JSON-LD and the list of entities referenced by this entity. |
|
| 64 | - $jsonld = parent::convert( $post_id, $references ); |
|
| 65 | - |
|
| 66 | - // Get the entity name. |
|
| 67 | - $jsonld['name'] = $post->post_title; |
|
| 68 | - |
|
| 69 | - // 3.13.0, add alternate names. |
|
| 70 | - $alternative_labels = $this->entity_service->get_alternative_labels( $post_id ); |
|
| 71 | - if ( 0 < count( $alternative_labels ) ) { |
|
| 72 | - $jsonld['alternateName'] = $alternative_labels; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - // Get the entity @type. |
|
| 76 | - $type = $this->entity_type_service->get( $post_id ); |
|
| 77 | - |
|
| 78 | - // Get the configured type custom fields. |
|
| 79 | - $fields = $type['custom_fields']; |
|
| 80 | - |
|
| 81 | - // Set a reference to use in closures. |
|
| 82 | - $converter = $this; |
|
| 83 | - |
|
| 84 | - // Try each field on the entity. |
|
| 85 | - foreach ( $fields as $key => $value ) { |
|
| 86 | - |
|
| 87 | - // Get the predicate. |
|
| 88 | - $name = $this->relative_to_context( $value['predicate'] ); |
|
| 89 | - |
|
| 90 | - // Get the value, the property service will get the right extractor |
|
| 91 | - // for that property. |
|
| 92 | - $value = $this->property_getter->get( $post->ID, $key ); |
|
| 93 | - |
|
| 94 | - if ( 0 === count( $value ) ) { |
|
| 95 | - continue; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - // Map the value to the property name. |
|
| 99 | - // If we got an array with just one value, we return that one value. |
|
| 100 | - // If we got a Wordlift_Property_Entity_Reference we get the URL. |
|
| 101 | - $jsonld[ $name ] = $this->make_one( array_map( function ( $item ) use ( $converter, &$references ) { |
|
| 102 | - |
|
| 103 | - if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 104 | - |
|
| 105 | - $url = $item->getURL(); |
|
| 106 | - |
|
| 107 | - // The refactored converters require the entity id. |
|
| 108 | - $references[] = $item->getID(); |
|
| 109 | - |
|
| 110 | - return array( "@id" => $url ); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - return $converter->relative_to_context( $item ); |
|
| 114 | - }, $value ) ); |
|
| 115 | - |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - return $this->post_process( $jsonld ); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * If the provided array of values contains only one value, then one single |
|
| 123 | - * value is returned, otherwise the original array is returned. |
|
| 124 | - * |
|
| 125 | - * @since 3.8.0 |
|
| 126 | - * @access private |
|
| 127 | - * |
|
| 128 | - * @param array $value An array of values. |
|
| 129 | - * |
|
| 130 | - * @return mixed|array A single value or the original array. |
|
| 131 | - */ |
|
| 132 | - private function make_one( $value ) { |
|
| 133 | - |
|
| 134 | - return 1 === count( $value ) ? $value[0] : $value; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * Post process the generated JSON to reorganize values which are stored as 1st |
|
| 139 | - * level in WP but are really 2nd level. |
|
| 140 | - * |
|
| 141 | - * @since 3.8.0 |
|
| 142 | - * |
|
| 143 | - * @param array $jsonld An array of JSON-LD properties and values. |
|
| 144 | - * |
|
| 145 | - * @return array The array remapped. |
|
| 146 | - */ |
|
| 147 | - private function post_process( $jsonld ) { |
|
| 148 | - |
|
| 149 | - foreach ( $jsonld as $key => $value ) { |
|
| 150 | - if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 151 | - $jsonld['address']['@type'] = 'PostalAddress'; |
|
| 152 | - $jsonld['address'][ $key ] = $value; |
|
| 153 | - unset( $jsonld[ $key ] ); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 157 | - $jsonld['geo']['@type'] = 'GeoCoordinates'; |
|
| 158 | - $jsonld['geo'][ $key ] = $value; |
|
| 159 | - unset( $jsonld[ $key ] ); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - return $jsonld; |
|
| 164 | - } |
|
| 16 | + /** |
|
| 17 | + * A {@link Wordlift_Property_Getter} instance. |
|
| 18 | + * |
|
| 19 | + * @since 3.8.0 |
|
| 20 | + * @access private |
|
| 21 | + * @var \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 22 | + */ |
|
| 23 | + private $property_getter; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Wordlift_Entity_To_Jsonld_Converter constructor. |
|
| 27 | + * |
|
| 28 | + * @since 3.8.0 |
|
| 29 | + * |
|
| 30 | + * @param \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 31 | + * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 32 | + * @param \Wordlift_User_Service $user_service A {@link Wordlift_User_Service} instance. |
|
| 33 | + * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
|
| 34 | + * @param \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 35 | + */ |
|
| 36 | + public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service, $property_getter ) { |
|
| 37 | + parent::__construct( $entity_type_service, $entity_service, $user_service, $attachment_service ); |
|
| 38 | + |
|
| 39 | + $this->property_getter = $property_getter; |
|
| 40 | + |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 45 | + * found while processing the post is set in the $references array. |
|
| 46 | + * |
|
| 47 | + * @since 3.8.0 |
|
| 48 | + * |
|
| 49 | + * @param int $post_id The {@link WP_Post} id. |
|
| 50 | + * |
|
| 51 | + * @param array $references An array of entity references. |
|
| 52 | + * |
|
| 53 | + * @return array A JSON-LD array. |
|
| 54 | + */ |
|
| 55 | + public function convert( $post_id, &$references = array() ) { |
|
| 56 | + |
|
| 57 | + // Get the post instance. |
|
| 58 | + if ( null === $post = get_post( $post_id ) ) { |
|
| 59 | + // Post not found. |
|
| 60 | + return null; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // Get the base JSON-LD and the list of entities referenced by this entity. |
|
| 64 | + $jsonld = parent::convert( $post_id, $references ); |
|
| 65 | + |
|
| 66 | + // Get the entity name. |
|
| 67 | + $jsonld['name'] = $post->post_title; |
|
| 68 | + |
|
| 69 | + // 3.13.0, add alternate names. |
|
| 70 | + $alternative_labels = $this->entity_service->get_alternative_labels( $post_id ); |
|
| 71 | + if ( 0 < count( $alternative_labels ) ) { |
|
| 72 | + $jsonld['alternateName'] = $alternative_labels; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + // Get the entity @type. |
|
| 76 | + $type = $this->entity_type_service->get( $post_id ); |
|
| 77 | + |
|
| 78 | + // Get the configured type custom fields. |
|
| 79 | + $fields = $type['custom_fields']; |
|
| 80 | + |
|
| 81 | + // Set a reference to use in closures. |
|
| 82 | + $converter = $this; |
|
| 83 | + |
|
| 84 | + // Try each field on the entity. |
|
| 85 | + foreach ( $fields as $key => $value ) { |
|
| 86 | + |
|
| 87 | + // Get the predicate. |
|
| 88 | + $name = $this->relative_to_context( $value['predicate'] ); |
|
| 89 | + |
|
| 90 | + // Get the value, the property service will get the right extractor |
|
| 91 | + // for that property. |
|
| 92 | + $value = $this->property_getter->get( $post->ID, $key ); |
|
| 93 | + |
|
| 94 | + if ( 0 === count( $value ) ) { |
|
| 95 | + continue; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + // Map the value to the property name. |
|
| 99 | + // If we got an array with just one value, we return that one value. |
|
| 100 | + // If we got a Wordlift_Property_Entity_Reference we get the URL. |
|
| 101 | + $jsonld[ $name ] = $this->make_one( array_map( function ( $item ) use ( $converter, &$references ) { |
|
| 102 | + |
|
| 103 | + if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 104 | + |
|
| 105 | + $url = $item->getURL(); |
|
| 106 | + |
|
| 107 | + // The refactored converters require the entity id. |
|
| 108 | + $references[] = $item->getID(); |
|
| 109 | + |
|
| 110 | + return array( "@id" => $url ); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + return $converter->relative_to_context( $item ); |
|
| 114 | + }, $value ) ); |
|
| 115 | + |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + return $this->post_process( $jsonld ); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * If the provided array of values contains only one value, then one single |
|
| 123 | + * value is returned, otherwise the original array is returned. |
|
| 124 | + * |
|
| 125 | + * @since 3.8.0 |
|
| 126 | + * @access private |
|
| 127 | + * |
|
| 128 | + * @param array $value An array of values. |
|
| 129 | + * |
|
| 130 | + * @return mixed|array A single value or the original array. |
|
| 131 | + */ |
|
| 132 | + private function make_one( $value ) { |
|
| 133 | + |
|
| 134 | + return 1 === count( $value ) ? $value[0] : $value; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * Post process the generated JSON to reorganize values which are stored as 1st |
|
| 139 | + * level in WP but are really 2nd level. |
|
| 140 | + * |
|
| 141 | + * @since 3.8.0 |
|
| 142 | + * |
|
| 143 | + * @param array $jsonld An array of JSON-LD properties and values. |
|
| 144 | + * |
|
| 145 | + * @return array The array remapped. |
|
| 146 | + */ |
|
| 147 | + private function post_process( $jsonld ) { |
|
| 148 | + |
|
| 149 | + foreach ( $jsonld as $key => $value ) { |
|
| 150 | + if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 151 | + $jsonld['address']['@type'] = 'PostalAddress'; |
|
| 152 | + $jsonld['address'][ $key ] = $value; |
|
| 153 | + unset( $jsonld[ $key ] ); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 157 | + $jsonld['geo']['@type'] = 'GeoCoordinates'; |
|
| 158 | + $jsonld['geo'][ $key ] = $value; |
|
| 159 | + unset( $jsonld[ $key ] ); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + return $jsonld; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | 166 | } |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | * @param \Wordlift_Attachment_Service $attachment_service A {@link Wordlift_Attachment_Service} instance. |
| 34 | 34 | * @param \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
| 35 | 35 | */ |
| 36 | - public function __construct( $entity_type_service, $entity_service, $user_service, $attachment_service, $property_getter ) { |
|
| 37 | - parent::__construct( $entity_type_service, $entity_service, $user_service, $attachment_service ); |
|
| 36 | + public function __construct($entity_type_service, $entity_service, $user_service, $attachment_service, $property_getter) { |
|
| 37 | + parent::__construct($entity_type_service, $entity_service, $user_service, $attachment_service); |
|
| 38 | 38 | |
| 39 | 39 | $this->property_getter = $property_getter; |
| 40 | 40 | |
@@ -52,28 +52,28 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return array A JSON-LD array. |
| 54 | 54 | */ |
| 55 | - public function convert( $post_id, &$references = array() ) { |
|
| 55 | + public function convert($post_id, &$references = array()) { |
|
| 56 | 56 | |
| 57 | 57 | // Get the post instance. |
| 58 | - if ( null === $post = get_post( $post_id ) ) { |
|
| 58 | + if (null === $post = get_post($post_id)) { |
|
| 59 | 59 | // Post not found. |
| 60 | 60 | return null; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Get the base JSON-LD and the list of entities referenced by this entity. |
| 64 | - $jsonld = parent::convert( $post_id, $references ); |
|
| 64 | + $jsonld = parent::convert($post_id, $references); |
|
| 65 | 65 | |
| 66 | 66 | // Get the entity name. |
| 67 | 67 | $jsonld['name'] = $post->post_title; |
| 68 | 68 | |
| 69 | 69 | // 3.13.0, add alternate names. |
| 70 | - $alternative_labels = $this->entity_service->get_alternative_labels( $post_id ); |
|
| 71 | - if ( 0 < count( $alternative_labels ) ) { |
|
| 70 | + $alternative_labels = $this->entity_service->get_alternative_labels($post_id); |
|
| 71 | + if (0 < count($alternative_labels)) { |
|
| 72 | 72 | $jsonld['alternateName'] = $alternative_labels; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Get the entity @type. |
| 76 | - $type = $this->entity_type_service->get( $post_id ); |
|
| 76 | + $type = $this->entity_type_service->get($post_id); |
|
| 77 | 77 | |
| 78 | 78 | // Get the configured type custom fields. |
| 79 | 79 | $fields = $type['custom_fields']; |
@@ -82,40 +82,40 @@ discard block |
||
| 82 | 82 | $converter = $this; |
| 83 | 83 | |
| 84 | 84 | // Try each field on the entity. |
| 85 | - foreach ( $fields as $key => $value ) { |
|
| 85 | + foreach ($fields as $key => $value) { |
|
| 86 | 86 | |
| 87 | 87 | // Get the predicate. |
| 88 | - $name = $this->relative_to_context( $value['predicate'] ); |
|
| 88 | + $name = $this->relative_to_context($value['predicate']); |
|
| 89 | 89 | |
| 90 | 90 | // Get the value, the property service will get the right extractor |
| 91 | 91 | // for that property. |
| 92 | - $value = $this->property_getter->get( $post->ID, $key ); |
|
| 92 | + $value = $this->property_getter->get($post->ID, $key); |
|
| 93 | 93 | |
| 94 | - if ( 0 === count( $value ) ) { |
|
| 94 | + if (0 === count($value)) { |
|
| 95 | 95 | continue; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // Map the value to the property name. |
| 99 | 99 | // If we got an array with just one value, we return that one value. |
| 100 | 100 | // If we got a Wordlift_Property_Entity_Reference we get the URL. |
| 101 | - $jsonld[ $name ] = $this->make_one( array_map( function ( $item ) use ( $converter, &$references ) { |
|
| 101 | + $jsonld[$name] = $this->make_one(array_map(function($item) use ($converter, &$references) { |
|
| 102 | 102 | |
| 103 | - if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 103 | + if ($item instanceof Wordlift_Property_Entity_Reference) { |
|
| 104 | 104 | |
| 105 | 105 | $url = $item->getURL(); |
| 106 | 106 | |
| 107 | 107 | // The refactored converters require the entity id. |
| 108 | 108 | $references[] = $item->getID(); |
| 109 | 109 | |
| 110 | - return array( "@id" => $url ); |
|
| 110 | + return array("@id" => $url); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - return $converter->relative_to_context( $item ); |
|
| 114 | - }, $value ) ); |
|
| 113 | + return $converter->relative_to_context($item); |
|
| 114 | + }, $value)); |
|
| 115 | 115 | |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - return $this->post_process( $jsonld ); |
|
| 118 | + return $this->post_process($jsonld); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return mixed|array A single value or the original array. |
| 131 | 131 | */ |
| 132 | - private function make_one( $value ) { |
|
| 132 | + private function make_one($value) { |
|
| 133 | 133 | |
| 134 | - return 1 === count( $value ) ? $value[0] : $value; |
|
| 134 | + return 1 === count($value) ? $value[0] : $value; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -144,19 +144,19 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @return array The array remapped. |
| 146 | 146 | */ |
| 147 | - private function post_process( $jsonld ) { |
|
| 147 | + private function post_process($jsonld) { |
|
| 148 | 148 | |
| 149 | - foreach ( $jsonld as $key => $value ) { |
|
| 150 | - if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 149 | + foreach ($jsonld as $key => $value) { |
|
| 150 | + if ('streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key) { |
|
| 151 | 151 | $jsonld['address']['@type'] = 'PostalAddress'; |
| 152 | - $jsonld['address'][ $key ] = $value; |
|
| 153 | - unset( $jsonld[ $key ] ); |
|
| 152 | + $jsonld['address'][$key] = $value; |
|
| 153 | + unset($jsonld[$key]); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 156 | + if ('latitude' === $key || 'longitude' === $key) { |
|
| 157 | 157 | $jsonld['geo']['@type'] = 'GeoCoordinates'; |
| 158 | - $jsonld['geo'][ $key ] = $value; |
|
| 159 | - unset( $jsonld[ $key ] ); |
|
| 158 | + $jsonld['geo'][$key] = $value; |
|
| 159 | + unset($jsonld[$key]); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | - exit; |
|
| 14 | + exit; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -21,394 +21,394 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class Wordlift_Configuration_Service { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * The entity base path option name. |
|
| 26 | - * |
|
| 27 | - * @since 3.6.0 |
|
| 28 | - */ |
|
| 29 | - const ENTITY_BASE_PATH_KEY = 'wl_entity_base_path'; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * The skip wizard (admin installation wizard) option name. |
|
| 33 | - * |
|
| 34 | - * @since 3.9.0 |
|
| 35 | - */ |
|
| 36 | - const SKIP_WIZARD = 'wl_skip_wizard'; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * WordLift's key option name. |
|
| 40 | - * |
|
| 41 | - * @since 3.9.0 |
|
| 42 | - */ |
|
| 43 | - const KEY = 'key'; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * WordLift's configured language option name. |
|
| 47 | - * |
|
| 48 | - * @since 3.9.0 |
|
| 49 | - */ |
|
| 50 | - const LANGUAGE = 'site_language'; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * The publisher entity post ID option name. |
|
| 54 | - * |
|
| 55 | - * @since 3.9.0 |
|
| 56 | - */ |
|
| 57 | - const PUBLISHER_ID = 'publisher_id'; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * The dataset URI option name |
|
| 61 | - * |
|
| 62 | - * @since 3.10.0 |
|
| 63 | - */ |
|
| 64 | - const DATASET_URI = 'redlink_dataset_uri'; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * The link by default option name. |
|
| 68 | - * |
|
| 69 | - * @since 3.11.0 |
|
| 70 | - */ |
|
| 71 | - const LINK_BY_DEFAULT = 'link_by_default'; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * The Wordlift_Configuration_Service's singleton instance. |
|
| 75 | - * |
|
| 76 | - * @since 3.6.0 |
|
| 77 | - * |
|
| 78 | - * @access private |
|
| 79 | - * @var \Wordlift_Configuration_Service $instance Wordlift_Configuration_Service's singleton instance. |
|
| 80 | - */ |
|
| 81 | - private static $instance; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Create a Wordlift_Configuration_Service's instance. |
|
| 85 | - * |
|
| 86 | - * @since 3.6.0 |
|
| 87 | - */ |
|
| 88 | - public function __construct() { |
|
| 89 | - |
|
| 90 | - self::$instance = $this; |
|
| 91 | - |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Get the singleton instance. |
|
| 96 | - * |
|
| 97 | - * @since 3.6.0 |
|
| 98 | - * |
|
| 99 | - * @return \Wordlift_Configuration_Service |
|
| 100 | - */ |
|
| 101 | - public static function get_instance() { |
|
| 102 | - |
|
| 103 | - return self::$instance; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Get a configuration given the option name and a key. The option value is |
|
| 108 | - * expected to be an array. |
|
| 109 | - * |
|
| 110 | - * @since 3.6.0 |
|
| 111 | - * |
|
| 112 | - * @param string $option The option name. |
|
| 113 | - * @param string $key A key in the option value array. |
|
| 114 | - * @param string $default The default value in case the key is not found (by default an empty string). |
|
| 115 | - * |
|
| 116 | - * @return mixed The configuration value or the default value if not found. |
|
| 117 | - */ |
|
| 118 | - private function get( $option, $key, $default = '' ) { |
|
| 119 | - |
|
| 120 | - $options = get_option( $option, array() ); |
|
| 121 | - |
|
| 122 | - return isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Set a configuration parameter. |
|
| 127 | - * |
|
| 128 | - * @since 3.9.0 |
|
| 129 | - * |
|
| 130 | - * @param string $option Name of option to retrieve. Expected to not be SQL-escaped. |
|
| 131 | - * @param string $key The value key. |
|
| 132 | - * @param mixed $value The value. |
|
| 133 | - */ |
|
| 134 | - private function set( $option, $key, $value ) { |
|
| 135 | - |
|
| 136 | - $values = get_option( $option ); |
|
| 137 | - $values = isset( $values ) ? $values : array(); |
|
| 138 | - $values[ $key ] = $value; |
|
| 139 | - update_option( $option, $values ); |
|
| 140 | - |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Get the entity base path, by default 'entity'. |
|
| 145 | - * |
|
| 146 | - * @since 3.6.0 |
|
| 147 | - * |
|
| 148 | - * @return string The entity base path. |
|
| 149 | - */ |
|
| 150 | - public function get_entity_base_path() { |
|
| 151 | - |
|
| 152 | - return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' ); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Get the entity base path. |
|
| 157 | - * |
|
| 158 | - * @since 3.9.0 |
|
| 159 | - * |
|
| 160 | - * @param string $value The entity base path. |
|
| 161 | - */ |
|
| 162 | - public function set_entity_base_path( $value ) { |
|
| 163 | - |
|
| 164 | - $this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value ); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Whether the installation skip wizard should be skipped. |
|
| 169 | - * |
|
| 170 | - * @since 3.9.0 |
|
| 171 | - * |
|
| 172 | - * @return bool True if it should be skipped otherwise false. |
|
| 173 | - */ |
|
| 174 | - public function is_skip_wizard() { |
|
| 175 | - |
|
| 176 | - return $this->get( 'wl_general_settings', self::SKIP_WIZARD, false ); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * Set the skip wizard parameter. |
|
| 181 | - * |
|
| 182 | - * @since 3.9.0 |
|
| 183 | - * |
|
| 184 | - * @param bool $value True to skip the wizard. We expect a boolean value. |
|
| 185 | - */ |
|
| 186 | - public function set_skip_wizard( $value ) { |
|
| 187 | - |
|
| 188 | - $this->set( 'wl_general_settings', self::SKIP_WIZARD, true === $value ); |
|
| 189 | - |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Get WordLift's key. |
|
| 194 | - * |
|
| 195 | - * @since 3.9.0 |
|
| 196 | - * |
|
| 197 | - * @return WordLift's key or an empty string if not set. |
|
| 198 | - */ |
|
| 199 | - public function get_key() { |
|
| 200 | - |
|
| 201 | - return $this->get( 'wl_general_settings', self::KEY, '' ); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Set WordLift's key. |
|
| 206 | - * |
|
| 207 | - * @since 3.9.0 |
|
| 208 | - * |
|
| 209 | - * @param string $value WordLift's key. |
|
| 210 | - */ |
|
| 211 | - public function set_key( $value ) { |
|
| 212 | - |
|
| 213 | - $this->set( 'wl_general_settings', self::KEY, $value ); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * Get WordLift's configured language, by default 'en'. |
|
| 218 | - * |
|
| 219 | - * Note that WordLift's language is used when writing strings to the Linked Data dataset, not for the analysis. |
|
| 220 | - * |
|
| 221 | - * @since 3.9.0 |
|
| 222 | - * |
|
| 223 | - * @return string WordLift's configured language code ('en' by default). |
|
| 224 | - */ |
|
| 225 | - public function get_language_code() { |
|
| 226 | - |
|
| 227 | - return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' ); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * Set WordLift's language code, used when storing strings to the Linked Data dataset. |
|
| 232 | - * |
|
| 233 | - * @since 3.9.0 |
|
| 234 | - * |
|
| 235 | - * @param string $value WordLift's language code. |
|
| 236 | - */ |
|
| 237 | - public function set_language_code( $value ) { |
|
| 238 | - |
|
| 239 | - $this->set( 'wl_general_settings', self::LANGUAGE, $value ); |
|
| 240 | - |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Get the publisher entity post id. |
|
| 245 | - * |
|
| 246 | - * The publisher entity post id points to an entity post which contains the data for the publisher used in schema.org |
|
| 247 | - * Article markup. |
|
| 248 | - * |
|
| 249 | - * @since 3.9.0 |
|
| 250 | - * |
|
| 251 | - * @return int|NULL The publisher entity post id or NULL if not set. |
|
| 252 | - */ |
|
| 253 | - public function get_publisher_id() { |
|
| 254 | - |
|
| 255 | - return $this->get( 'wl_general_settings', self::PUBLISHER_ID, null ); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * Set the publisher entity post id. |
|
| 260 | - * |
|
| 261 | - * @since 3.9.0 |
|
| 262 | - * |
|
| 263 | - * @param int $value The publisher entity post id. |
|
| 264 | - */ |
|
| 265 | - public function set_publisher_id( $value ) { |
|
| 266 | - |
|
| 267 | - $this->set( 'wl_general_settings', self::PUBLISHER_ID, $value ); |
|
| 268 | - |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * Get the dataset URI. |
|
| 273 | - * |
|
| 274 | - * @since 3.10.0 |
|
| 275 | - * |
|
| 276 | - * @return string The dataset URI or an empty string if not set. |
|
| 277 | - */ |
|
| 278 | - public function get_dataset_uri() { |
|
| 279 | - |
|
| 280 | - return $this->get( 'wl_advanced_settings', self::DATASET_URI, null ); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * Set the dataset URI. |
|
| 285 | - * |
|
| 286 | - * @since 3.10.0 |
|
| 287 | - * |
|
| 288 | - * @param string $value The dataset URI. |
|
| 289 | - */ |
|
| 290 | - public function set_dataset_uri( $value ) { |
|
| 291 | - |
|
| 292 | - $this->set( 'wl_advanced_settings', self::DATASET_URI, $value ); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * Intercept the change of the WordLift key in order to set the dataset URI. |
|
| 297 | - * |
|
| 298 | - * @since 3.11.0 |
|
| 299 | - * |
|
| 300 | - * @param array $old_value The old settings. |
|
| 301 | - * @param array $new_value The new settings. |
|
| 302 | - */ |
|
| 303 | - public function update_key( $old_value, $new_value ) { |
|
| 304 | - |
|
| 305 | - // Check the old key value and the new one. We're going to ask for the dataset URI only if the key has changed. |
|
| 306 | - $old_key = isset( $old_value['key'] ) ? $old_value['key'] : ''; |
|
| 307 | - $new_key = isset( $new_value['key'] ) ? $new_value['key'] : ''; |
|
| 308 | - |
|
| 309 | - // If the key hasn't changed, don't do anything. |
|
| 310 | - // WARN The 'update_option' hook is fired only if the new and old value are not equal |
|
| 311 | - if ( $old_key === $new_key ) { |
|
| 312 | - return; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - // If the key is empty, empty the dataset URI. |
|
| 316 | - if ( '' === $new_key ) { |
|
| 317 | - $this->set_dataset_uri( '' ); |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - // make the request to the remote server |
|
| 321 | - $this->get_remote_dataset_uri( $new_key ); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * Handle retrieving the dataset uri from the remote server. |
|
| 326 | - * |
|
| 327 | - * If a valid dataset uri is returned it is stored in the appropriate option, |
|
| 328 | - * otherwise the option is set to empty string. |
|
| 329 | - * |
|
| 330 | - * @since 3.12.0 |
|
| 331 | - * |
|
| 332 | - * @param string $key The key to be used |
|
| 333 | - * |
|
| 334 | - */ |
|
| 335 | - private function get_remote_dataset_uri( $key ) { |
|
| 336 | - // Request the dataset URI. |
|
| 337 | - $response = wp_remote_get( $this->get_accounts_by_key_dataset_uri( $key ), unserialize( WL_REDLINK_API_HTTP_OPTIONS ) ); |
|
| 338 | - |
|
| 339 | - // If the response is valid, then set the value. |
|
| 340 | - if ( ! is_wp_error( $response ) && 200 === (int) $response['response']['code'] ) { |
|
| 341 | - $this->set_dataset_uri( $response['body'] ); |
|
| 342 | - } else { |
|
| 343 | - $this->set_dataset_uri( '' ); |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - /** |
|
| 348 | - * Handle the edge case where a user submits the same key again |
|
| 349 | - * when he does not have the dataset uri to regain it. |
|
| 350 | - * |
|
| 351 | - * This can not be handled in the normal option update hook because |
|
| 352 | - * it is not being triggered when the save value equals to the one already |
|
| 353 | - * in the DB. |
|
| 354 | - * |
|
| 355 | - * @since 3.12.0 |
|
| 356 | - * |
|
| 357 | - * @param mixed $value The new, unserialized option value. |
|
| 358 | - * @param mixed $old_value The old option value. |
|
| 359 | - * |
|
| 360 | - * @return mixed The same value in the $value parameter |
|
| 361 | - * |
|
| 362 | - */ |
|
| 363 | - function maybe_update_dataset_uri( $value, $old_value ) { |
|
| 364 | - |
|
| 365 | - $dataset_uri = $this->get_dataset_uri(); |
|
| 366 | - |
|
| 367 | - if ( ! empty( $value ) && $value == $old_value && empty( $dataset_uri ) ) { |
|
| 368 | - |
|
| 369 | - // make the request to the remote server to try to get the dataset uri |
|
| 370 | - $this->get_remote_dataset_uri( $value ); |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - return $value; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * Get the API URI to retrieve the dataset URI using the WordLift Key. |
|
| 378 | - * |
|
| 379 | - * @since 3.11.0 |
|
| 380 | - * |
|
| 381 | - * @param string $key The WordLift key to use. |
|
| 382 | - * |
|
| 383 | - * @return string The API URI. |
|
| 384 | - */ |
|
| 385 | - public function get_accounts_by_key_dataset_uri( $key ) { |
|
| 386 | - |
|
| 387 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . "accounts/key=$key/dataset_uri"; |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * Get the `link by default` option. |
|
| 392 | - * |
|
| 393 | - * @since 3.13.0 |
|
| 394 | - * |
|
| 395 | - * @return bool True if entities must be linked by default otherwise false. |
|
| 396 | - */ |
|
| 397 | - public function is_link_by_default() { |
|
| 398 | - |
|
| 399 | - return 'yes' === $this->get( 'wl_general_settings', self::LINK_BY_DEFAULT, 'yes' ); |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * Set the `link by default` option. |
|
| 404 | - * |
|
| 405 | - * @since 3.13.0 |
|
| 406 | - * |
|
| 407 | - * @param bool $value True to enabling linking by default, otherwise false. |
|
| 408 | - */ |
|
| 409 | - public function set_link_by_default( $value ) { |
|
| 410 | - |
|
| 411 | - $this->set( 'wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no' ); |
|
| 412 | - } |
|
| 24 | + /** |
|
| 25 | + * The entity base path option name. |
|
| 26 | + * |
|
| 27 | + * @since 3.6.0 |
|
| 28 | + */ |
|
| 29 | + const ENTITY_BASE_PATH_KEY = 'wl_entity_base_path'; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * The skip wizard (admin installation wizard) option name. |
|
| 33 | + * |
|
| 34 | + * @since 3.9.0 |
|
| 35 | + */ |
|
| 36 | + const SKIP_WIZARD = 'wl_skip_wizard'; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * WordLift's key option name. |
|
| 40 | + * |
|
| 41 | + * @since 3.9.0 |
|
| 42 | + */ |
|
| 43 | + const KEY = 'key'; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * WordLift's configured language option name. |
|
| 47 | + * |
|
| 48 | + * @since 3.9.0 |
|
| 49 | + */ |
|
| 50 | + const LANGUAGE = 'site_language'; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * The publisher entity post ID option name. |
|
| 54 | + * |
|
| 55 | + * @since 3.9.0 |
|
| 56 | + */ |
|
| 57 | + const PUBLISHER_ID = 'publisher_id'; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * The dataset URI option name |
|
| 61 | + * |
|
| 62 | + * @since 3.10.0 |
|
| 63 | + */ |
|
| 64 | + const DATASET_URI = 'redlink_dataset_uri'; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * The link by default option name. |
|
| 68 | + * |
|
| 69 | + * @since 3.11.0 |
|
| 70 | + */ |
|
| 71 | + const LINK_BY_DEFAULT = 'link_by_default'; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * The Wordlift_Configuration_Service's singleton instance. |
|
| 75 | + * |
|
| 76 | + * @since 3.6.0 |
|
| 77 | + * |
|
| 78 | + * @access private |
|
| 79 | + * @var \Wordlift_Configuration_Service $instance Wordlift_Configuration_Service's singleton instance. |
|
| 80 | + */ |
|
| 81 | + private static $instance; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Create a Wordlift_Configuration_Service's instance. |
|
| 85 | + * |
|
| 86 | + * @since 3.6.0 |
|
| 87 | + */ |
|
| 88 | + public function __construct() { |
|
| 89 | + |
|
| 90 | + self::$instance = $this; |
|
| 91 | + |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Get the singleton instance. |
|
| 96 | + * |
|
| 97 | + * @since 3.6.0 |
|
| 98 | + * |
|
| 99 | + * @return \Wordlift_Configuration_Service |
|
| 100 | + */ |
|
| 101 | + public static function get_instance() { |
|
| 102 | + |
|
| 103 | + return self::$instance; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Get a configuration given the option name and a key. The option value is |
|
| 108 | + * expected to be an array. |
|
| 109 | + * |
|
| 110 | + * @since 3.6.0 |
|
| 111 | + * |
|
| 112 | + * @param string $option The option name. |
|
| 113 | + * @param string $key A key in the option value array. |
|
| 114 | + * @param string $default The default value in case the key is not found (by default an empty string). |
|
| 115 | + * |
|
| 116 | + * @return mixed The configuration value or the default value if not found. |
|
| 117 | + */ |
|
| 118 | + private function get( $option, $key, $default = '' ) { |
|
| 119 | + |
|
| 120 | + $options = get_option( $option, array() ); |
|
| 121 | + |
|
| 122 | + return isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Set a configuration parameter. |
|
| 127 | + * |
|
| 128 | + * @since 3.9.0 |
|
| 129 | + * |
|
| 130 | + * @param string $option Name of option to retrieve. Expected to not be SQL-escaped. |
|
| 131 | + * @param string $key The value key. |
|
| 132 | + * @param mixed $value The value. |
|
| 133 | + */ |
|
| 134 | + private function set( $option, $key, $value ) { |
|
| 135 | + |
|
| 136 | + $values = get_option( $option ); |
|
| 137 | + $values = isset( $values ) ? $values : array(); |
|
| 138 | + $values[ $key ] = $value; |
|
| 139 | + update_option( $option, $values ); |
|
| 140 | + |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Get the entity base path, by default 'entity'. |
|
| 145 | + * |
|
| 146 | + * @since 3.6.0 |
|
| 147 | + * |
|
| 148 | + * @return string The entity base path. |
|
| 149 | + */ |
|
| 150 | + public function get_entity_base_path() { |
|
| 151 | + |
|
| 152 | + return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' ); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Get the entity base path. |
|
| 157 | + * |
|
| 158 | + * @since 3.9.0 |
|
| 159 | + * |
|
| 160 | + * @param string $value The entity base path. |
|
| 161 | + */ |
|
| 162 | + public function set_entity_base_path( $value ) { |
|
| 163 | + |
|
| 164 | + $this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value ); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Whether the installation skip wizard should be skipped. |
|
| 169 | + * |
|
| 170 | + * @since 3.9.0 |
|
| 171 | + * |
|
| 172 | + * @return bool True if it should be skipped otherwise false. |
|
| 173 | + */ |
|
| 174 | + public function is_skip_wizard() { |
|
| 175 | + |
|
| 176 | + return $this->get( 'wl_general_settings', self::SKIP_WIZARD, false ); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * Set the skip wizard parameter. |
|
| 181 | + * |
|
| 182 | + * @since 3.9.0 |
|
| 183 | + * |
|
| 184 | + * @param bool $value True to skip the wizard. We expect a boolean value. |
|
| 185 | + */ |
|
| 186 | + public function set_skip_wizard( $value ) { |
|
| 187 | + |
|
| 188 | + $this->set( 'wl_general_settings', self::SKIP_WIZARD, true === $value ); |
|
| 189 | + |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Get WordLift's key. |
|
| 194 | + * |
|
| 195 | + * @since 3.9.0 |
|
| 196 | + * |
|
| 197 | + * @return WordLift's key or an empty string if not set. |
|
| 198 | + */ |
|
| 199 | + public function get_key() { |
|
| 200 | + |
|
| 201 | + return $this->get( 'wl_general_settings', self::KEY, '' ); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Set WordLift's key. |
|
| 206 | + * |
|
| 207 | + * @since 3.9.0 |
|
| 208 | + * |
|
| 209 | + * @param string $value WordLift's key. |
|
| 210 | + */ |
|
| 211 | + public function set_key( $value ) { |
|
| 212 | + |
|
| 213 | + $this->set( 'wl_general_settings', self::KEY, $value ); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * Get WordLift's configured language, by default 'en'. |
|
| 218 | + * |
|
| 219 | + * Note that WordLift's language is used when writing strings to the Linked Data dataset, not for the analysis. |
|
| 220 | + * |
|
| 221 | + * @since 3.9.0 |
|
| 222 | + * |
|
| 223 | + * @return string WordLift's configured language code ('en' by default). |
|
| 224 | + */ |
|
| 225 | + public function get_language_code() { |
|
| 226 | + |
|
| 227 | + return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' ); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Set WordLift's language code, used when storing strings to the Linked Data dataset. |
|
| 232 | + * |
|
| 233 | + * @since 3.9.0 |
|
| 234 | + * |
|
| 235 | + * @param string $value WordLift's language code. |
|
| 236 | + */ |
|
| 237 | + public function set_language_code( $value ) { |
|
| 238 | + |
|
| 239 | + $this->set( 'wl_general_settings', self::LANGUAGE, $value ); |
|
| 240 | + |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Get the publisher entity post id. |
|
| 245 | + * |
|
| 246 | + * The publisher entity post id points to an entity post which contains the data for the publisher used in schema.org |
|
| 247 | + * Article markup. |
|
| 248 | + * |
|
| 249 | + * @since 3.9.0 |
|
| 250 | + * |
|
| 251 | + * @return int|NULL The publisher entity post id or NULL if not set. |
|
| 252 | + */ |
|
| 253 | + public function get_publisher_id() { |
|
| 254 | + |
|
| 255 | + return $this->get( 'wl_general_settings', self::PUBLISHER_ID, null ); |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * Set the publisher entity post id. |
|
| 260 | + * |
|
| 261 | + * @since 3.9.0 |
|
| 262 | + * |
|
| 263 | + * @param int $value The publisher entity post id. |
|
| 264 | + */ |
|
| 265 | + public function set_publisher_id( $value ) { |
|
| 266 | + |
|
| 267 | + $this->set( 'wl_general_settings', self::PUBLISHER_ID, $value ); |
|
| 268 | + |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * Get the dataset URI. |
|
| 273 | + * |
|
| 274 | + * @since 3.10.0 |
|
| 275 | + * |
|
| 276 | + * @return string The dataset URI or an empty string if not set. |
|
| 277 | + */ |
|
| 278 | + public function get_dataset_uri() { |
|
| 279 | + |
|
| 280 | + return $this->get( 'wl_advanced_settings', self::DATASET_URI, null ); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * Set the dataset URI. |
|
| 285 | + * |
|
| 286 | + * @since 3.10.0 |
|
| 287 | + * |
|
| 288 | + * @param string $value The dataset URI. |
|
| 289 | + */ |
|
| 290 | + public function set_dataset_uri( $value ) { |
|
| 291 | + |
|
| 292 | + $this->set( 'wl_advanced_settings', self::DATASET_URI, $value ); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * Intercept the change of the WordLift key in order to set the dataset URI. |
|
| 297 | + * |
|
| 298 | + * @since 3.11.0 |
|
| 299 | + * |
|
| 300 | + * @param array $old_value The old settings. |
|
| 301 | + * @param array $new_value The new settings. |
|
| 302 | + */ |
|
| 303 | + public function update_key( $old_value, $new_value ) { |
|
| 304 | + |
|
| 305 | + // Check the old key value and the new one. We're going to ask for the dataset URI only if the key has changed. |
|
| 306 | + $old_key = isset( $old_value['key'] ) ? $old_value['key'] : ''; |
|
| 307 | + $new_key = isset( $new_value['key'] ) ? $new_value['key'] : ''; |
|
| 308 | + |
|
| 309 | + // If the key hasn't changed, don't do anything. |
|
| 310 | + // WARN The 'update_option' hook is fired only if the new and old value are not equal |
|
| 311 | + if ( $old_key === $new_key ) { |
|
| 312 | + return; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + // If the key is empty, empty the dataset URI. |
|
| 316 | + if ( '' === $new_key ) { |
|
| 317 | + $this->set_dataset_uri( '' ); |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + // make the request to the remote server |
|
| 321 | + $this->get_remote_dataset_uri( $new_key ); |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * Handle retrieving the dataset uri from the remote server. |
|
| 326 | + * |
|
| 327 | + * If a valid dataset uri is returned it is stored in the appropriate option, |
|
| 328 | + * otherwise the option is set to empty string. |
|
| 329 | + * |
|
| 330 | + * @since 3.12.0 |
|
| 331 | + * |
|
| 332 | + * @param string $key The key to be used |
|
| 333 | + * |
|
| 334 | + */ |
|
| 335 | + private function get_remote_dataset_uri( $key ) { |
|
| 336 | + // Request the dataset URI. |
|
| 337 | + $response = wp_remote_get( $this->get_accounts_by_key_dataset_uri( $key ), unserialize( WL_REDLINK_API_HTTP_OPTIONS ) ); |
|
| 338 | + |
|
| 339 | + // If the response is valid, then set the value. |
|
| 340 | + if ( ! is_wp_error( $response ) && 200 === (int) $response['response']['code'] ) { |
|
| 341 | + $this->set_dataset_uri( $response['body'] ); |
|
| 342 | + } else { |
|
| 343 | + $this->set_dataset_uri( '' ); |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + /** |
|
| 348 | + * Handle the edge case where a user submits the same key again |
|
| 349 | + * when he does not have the dataset uri to regain it. |
|
| 350 | + * |
|
| 351 | + * This can not be handled in the normal option update hook because |
|
| 352 | + * it is not being triggered when the save value equals to the one already |
|
| 353 | + * in the DB. |
|
| 354 | + * |
|
| 355 | + * @since 3.12.0 |
|
| 356 | + * |
|
| 357 | + * @param mixed $value The new, unserialized option value. |
|
| 358 | + * @param mixed $old_value The old option value. |
|
| 359 | + * |
|
| 360 | + * @return mixed The same value in the $value parameter |
|
| 361 | + * |
|
| 362 | + */ |
|
| 363 | + function maybe_update_dataset_uri( $value, $old_value ) { |
|
| 364 | + |
|
| 365 | + $dataset_uri = $this->get_dataset_uri(); |
|
| 366 | + |
|
| 367 | + if ( ! empty( $value ) && $value == $old_value && empty( $dataset_uri ) ) { |
|
| 368 | + |
|
| 369 | + // make the request to the remote server to try to get the dataset uri |
|
| 370 | + $this->get_remote_dataset_uri( $value ); |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + return $value; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * Get the API URI to retrieve the dataset URI using the WordLift Key. |
|
| 378 | + * |
|
| 379 | + * @since 3.11.0 |
|
| 380 | + * |
|
| 381 | + * @param string $key The WordLift key to use. |
|
| 382 | + * |
|
| 383 | + * @return string The API URI. |
|
| 384 | + */ |
|
| 385 | + public function get_accounts_by_key_dataset_uri( $key ) { |
|
| 386 | + |
|
| 387 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . "accounts/key=$key/dataset_uri"; |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * Get the `link by default` option. |
|
| 392 | + * |
|
| 393 | + * @since 3.13.0 |
|
| 394 | + * |
|
| 395 | + * @return bool True if entities must be linked by default otherwise false. |
|
| 396 | + */ |
|
| 397 | + public function is_link_by_default() { |
|
| 398 | + |
|
| 399 | + return 'yes' === $this->get( 'wl_general_settings', self::LINK_BY_DEFAULT, 'yes' ); |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * Set the `link by default` option. |
|
| 404 | + * |
|
| 405 | + * @since 3.13.0 |
|
| 406 | + * |
|
| 407 | + * @param bool $value True to enabling linking by default, otherwise false. |
|
| 408 | + */ |
|
| 409 | + public function set_link_by_default( $value ) { |
|
| 410 | + |
|
| 411 | + $this->set( 'wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no' ); |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | 414 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @since 3.6.0 |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @return mixed The configuration value or the default value if not found. |
| 117 | 117 | */ |
| 118 | - private function get( $option, $key, $default = '' ) { |
|
| 118 | + private function get($option, $key, $default = '') { |
|
| 119 | 119 | |
| 120 | - $options = get_option( $option, array() ); |
|
| 120 | + $options = get_option($option, array()); |
|
| 121 | 121 | |
| 122 | - return isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
| 122 | + return isset($options[$key]) ? $options[$key] : $default; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | * @param string $key The value key. |
| 132 | 132 | * @param mixed $value The value. |
| 133 | 133 | */ |
| 134 | - private function set( $option, $key, $value ) { |
|
| 134 | + private function set($option, $key, $value) { |
|
| 135 | 135 | |
| 136 | - $values = get_option( $option ); |
|
| 137 | - $values = isset( $values ) ? $values : array(); |
|
| 138 | - $values[ $key ] = $value; |
|
| 139 | - update_option( $option, $values ); |
|
| 136 | + $values = get_option($option); |
|
| 137 | + $values = isset($values) ? $values : array(); |
|
| 138 | + $values[$key] = $value; |
|
| 139 | + update_option($option, $values); |
|
| 140 | 140 | |
| 141 | 141 | } |
| 142 | 142 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function get_entity_base_path() { |
| 151 | 151 | |
| 152 | - return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' ); |
|
| 152 | + return $this->get('wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity'); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @param string $value The entity base path. |
| 161 | 161 | */ |
| 162 | - public function set_entity_base_path( $value ) { |
|
| 162 | + public function set_entity_base_path($value) { |
|
| 163 | 163 | |
| 164 | - $this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value ); |
|
| 164 | + $this->set('wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function is_skip_wizard() { |
| 175 | 175 | |
| 176 | - return $this->get( 'wl_general_settings', self::SKIP_WIZARD, false ); |
|
| 176 | + return $this->get('wl_general_settings', self::SKIP_WIZARD, false); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @param bool $value True to skip the wizard. We expect a boolean value. |
| 185 | 185 | */ |
| 186 | - public function set_skip_wizard( $value ) { |
|
| 186 | + public function set_skip_wizard($value) { |
|
| 187 | 187 | |
| 188 | - $this->set( 'wl_general_settings', self::SKIP_WIZARD, true === $value ); |
|
| 188 | + $this->set('wl_general_settings', self::SKIP_WIZARD, true === $value); |
|
| 189 | 189 | |
| 190 | 190 | } |
| 191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function get_key() { |
| 200 | 200 | |
| 201 | - return $this->get( 'wl_general_settings', self::KEY, '' ); |
|
| 201 | + return $this->get('wl_general_settings', self::KEY, ''); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | * |
| 209 | 209 | * @param string $value WordLift's key. |
| 210 | 210 | */ |
| 211 | - public function set_key( $value ) { |
|
| 211 | + public function set_key($value) { |
|
| 212 | 212 | |
| 213 | - $this->set( 'wl_general_settings', self::KEY, $value ); |
|
| 213 | + $this->set('wl_general_settings', self::KEY, $value); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | public function get_language_code() { |
| 226 | 226 | |
| 227 | - return $this->get( 'wl_general_settings', self::LANGUAGE, 'en' ); |
|
| 227 | + return $this->get('wl_general_settings', self::LANGUAGE, 'en'); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @param string $value WordLift's language code. |
| 236 | 236 | */ |
| 237 | - public function set_language_code( $value ) { |
|
| 237 | + public function set_language_code($value) { |
|
| 238 | 238 | |
| 239 | - $this->set( 'wl_general_settings', self::LANGUAGE, $value ); |
|
| 239 | + $this->set('wl_general_settings', self::LANGUAGE, $value); |
|
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public function get_publisher_id() { |
| 254 | 254 | |
| 255 | - return $this->get( 'wl_general_settings', self::PUBLISHER_ID, null ); |
|
| 255 | + return $this->get('wl_general_settings', self::PUBLISHER_ID, null); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | * |
| 263 | 263 | * @param int $value The publisher entity post id. |
| 264 | 264 | */ |
| 265 | - public function set_publisher_id( $value ) { |
|
| 265 | + public function set_publisher_id($value) { |
|
| 266 | 266 | |
| 267 | - $this->set( 'wl_general_settings', self::PUBLISHER_ID, $value ); |
|
| 267 | + $this->set('wl_general_settings', self::PUBLISHER_ID, $value); |
|
| 268 | 268 | |
| 269 | 269 | } |
| 270 | 270 | |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | public function get_dataset_uri() { |
| 279 | 279 | |
| 280 | - return $this->get( 'wl_advanced_settings', self::DATASET_URI, null ); |
|
| 280 | + return $this->get('wl_advanced_settings', self::DATASET_URI, null); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | * @param string $value The dataset URI. |
| 289 | 289 | */ |
| 290 | - public function set_dataset_uri( $value ) { |
|
| 290 | + public function set_dataset_uri($value) { |
|
| 291 | 291 | |
| 292 | - $this->set( 'wl_advanced_settings', self::DATASET_URI, $value ); |
|
| 292 | + $this->set('wl_advanced_settings', self::DATASET_URI, $value); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -300,25 +300,25 @@ discard block |
||
| 300 | 300 | * @param array $old_value The old settings. |
| 301 | 301 | * @param array $new_value The new settings. |
| 302 | 302 | */ |
| 303 | - public function update_key( $old_value, $new_value ) { |
|
| 303 | + public function update_key($old_value, $new_value) { |
|
| 304 | 304 | |
| 305 | 305 | // Check the old key value and the new one. We're going to ask for the dataset URI only if the key has changed. |
| 306 | - $old_key = isset( $old_value['key'] ) ? $old_value['key'] : ''; |
|
| 307 | - $new_key = isset( $new_value['key'] ) ? $new_value['key'] : ''; |
|
| 306 | + $old_key = isset($old_value['key']) ? $old_value['key'] : ''; |
|
| 307 | + $new_key = isset($new_value['key']) ? $new_value['key'] : ''; |
|
| 308 | 308 | |
| 309 | 309 | // If the key hasn't changed, don't do anything. |
| 310 | 310 | // WARN The 'update_option' hook is fired only if the new and old value are not equal |
| 311 | - if ( $old_key === $new_key ) { |
|
| 311 | + if ($old_key === $new_key) { |
|
| 312 | 312 | return; |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // If the key is empty, empty the dataset URI. |
| 316 | - if ( '' === $new_key ) { |
|
| 317 | - $this->set_dataset_uri( '' ); |
|
| 316 | + if ('' === $new_key) { |
|
| 317 | + $this->set_dataset_uri(''); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // make the request to the remote server |
| 321 | - $this->get_remote_dataset_uri( $new_key ); |
|
| 321 | + $this->get_remote_dataset_uri($new_key); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -332,15 +332,15 @@ discard block |
||
| 332 | 332 | * @param string $key The key to be used |
| 333 | 333 | * |
| 334 | 334 | */ |
| 335 | - private function get_remote_dataset_uri( $key ) { |
|
| 335 | + private function get_remote_dataset_uri($key) { |
|
| 336 | 336 | // Request the dataset URI. |
| 337 | - $response = wp_remote_get( $this->get_accounts_by_key_dataset_uri( $key ), unserialize( WL_REDLINK_API_HTTP_OPTIONS ) ); |
|
| 337 | + $response = wp_remote_get($this->get_accounts_by_key_dataset_uri($key), unserialize(WL_REDLINK_API_HTTP_OPTIONS)); |
|
| 338 | 338 | |
| 339 | 339 | // If the response is valid, then set the value. |
| 340 | - if ( ! is_wp_error( $response ) && 200 === (int) $response['response']['code'] ) { |
|
| 341 | - $this->set_dataset_uri( $response['body'] ); |
|
| 340 | + if ( ! is_wp_error($response) && 200 === (int) $response['response']['code']) { |
|
| 341 | + $this->set_dataset_uri($response['body']); |
|
| 342 | 342 | } else { |
| 343 | - $this->set_dataset_uri( '' ); |
|
| 343 | + $this->set_dataset_uri(''); |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
@@ -360,14 +360,14 @@ discard block |
||
| 360 | 360 | * @return mixed The same value in the $value parameter |
| 361 | 361 | * |
| 362 | 362 | */ |
| 363 | - function maybe_update_dataset_uri( $value, $old_value ) { |
|
| 363 | + function maybe_update_dataset_uri($value, $old_value) { |
|
| 364 | 364 | |
| 365 | 365 | $dataset_uri = $this->get_dataset_uri(); |
| 366 | 366 | |
| 367 | - if ( ! empty( $value ) && $value == $old_value && empty( $dataset_uri ) ) { |
|
| 367 | + if ( ! empty($value) && $value == $old_value && empty($dataset_uri)) { |
|
| 368 | 368 | |
| 369 | 369 | // make the request to the remote server to try to get the dataset uri |
| 370 | - $this->get_remote_dataset_uri( $value ); |
|
| 370 | + $this->get_remote_dataset_uri($value); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | return $value; |
@@ -382,9 +382,9 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @return string The API URI. |
| 384 | 384 | */ |
| 385 | - public function get_accounts_by_key_dataset_uri( $key ) { |
|
| 385 | + public function get_accounts_by_key_dataset_uri($key) { |
|
| 386 | 386 | |
| 387 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . "accounts/key=$key/dataset_uri"; |
|
| 387 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE."accounts/key=$key/dataset_uri"; |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | */ |
| 397 | 397 | public function is_link_by_default() { |
| 398 | 398 | |
| 399 | - return 'yes' === $this->get( 'wl_general_settings', self::LINK_BY_DEFAULT, 'yes' ); |
|
| 399 | + return 'yes' === $this->get('wl_general_settings', self::LINK_BY_DEFAULT, 'yes'); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -406,9 +406,9 @@ discard block |
||
| 406 | 406 | * |
| 407 | 407 | * @param bool $value True to enabling linking by default, otherwise false. |
| 408 | 408 | */ |
| 409 | - public function set_link_by_default( $value ) { |
|
| 409 | + public function set_link_by_default($value) { |
|
| 410 | 410 | |
| 411 | - $this->set( 'wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no' ); |
|
| 411 | + $this->set('wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no'); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | } |
@@ -10,22 +10,22 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | function wl_ajax_analyze_action() { |
| 12 | 12 | |
| 13 | - try { |
|
| 14 | - if ( $analysis = wl_analyze_content( file_get_contents( "php://input" ) ) ) { |
|
| 15 | - header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); |
|
| 16 | - echo( $analysis ); |
|
| 17 | - wp_die(); |
|
| 18 | - } |
|
| 19 | - |
|
| 20 | - status_header( 500 ); |
|
| 21 | - wp_send_json( __( 'An error occurred while request an analysis to the remote service. Please try again later.', 'wordlift' ) ); |
|
| 22 | - |
|
| 23 | - } catch ( Exception $e ) { |
|
| 24 | - wp_send_json_error( array( |
|
| 25 | - 'code' => $e->getCode(), |
|
| 26 | - 'message' => $e->getMessage(), |
|
| 27 | - ) ); |
|
| 28 | - } |
|
| 13 | + try { |
|
| 14 | + if ( $analysis = wl_analyze_content( file_get_contents( "php://input" ) ) ) { |
|
| 15 | + header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); |
|
| 16 | + echo( $analysis ); |
|
| 17 | + wp_die(); |
|
| 18 | + } |
|
| 19 | + |
|
| 20 | + status_header( 500 ); |
|
| 21 | + wp_send_json( __( 'An error occurred while request an analysis to the remote service. Please try again later.', 'wordlift' ) ); |
|
| 22 | + |
|
| 23 | + } catch ( Exception $e ) { |
|
| 24 | + wp_send_json_error( array( |
|
| 25 | + 'code' => $e->getCode(), |
|
| 26 | + 'message' => $e->getMessage(), |
|
| 27 | + ) ); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
@@ -45,51 +45,51 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | function wl_analyze_content( $content ) { |
| 47 | 47 | |
| 48 | - // Get the analyzer URL. |
|
| 49 | - $url = wl_configuration_get_analyzer_url(); |
|
| 48 | + // Get the analyzer URL. |
|
| 49 | + $url = wl_configuration_get_analyzer_url(); |
|
| 50 | 50 | |
| 51 | - // Set the content type to the request content type or to text/plain by default. |
|
| 52 | - $content_type = isset( $_SERVER['CONTENT_TYPE'] ) ? $_SERVER['CONTENT_TYPE'] : 'text/plain'; |
|
| 51 | + // Set the content type to the request content type or to text/plain by default. |
|
| 52 | + $content_type = isset( $_SERVER['CONTENT_TYPE'] ) ? $_SERVER['CONTENT_TYPE'] : 'text/plain'; |
|
| 53 | 53 | |
| 54 | - // Prepare the request. |
|
| 55 | - $args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array( |
|
| 56 | - 'method' => 'POST', |
|
| 57 | - 'headers' => array( |
|
| 58 | - 'Accept' => 'application/json', |
|
| 59 | - 'Content-type' => $content_type, |
|
| 60 | - ), |
|
| 61 | - // we need to downgrade the HTTP version in this case since chunked encoding is dumping numbers in the response. |
|
| 62 | - 'httpversion' => '1.0', |
|
| 63 | - 'body' => $content, |
|
| 64 | - ) ); |
|
| 54 | + // Prepare the request. |
|
| 55 | + $args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array( |
|
| 56 | + 'method' => 'POST', |
|
| 57 | + 'headers' => array( |
|
| 58 | + 'Accept' => 'application/json', |
|
| 59 | + 'Content-type' => $content_type, |
|
| 60 | + ), |
|
| 61 | + // we need to downgrade the HTTP version in this case since chunked encoding is dumping numbers in the response. |
|
| 62 | + 'httpversion' => '1.0', |
|
| 63 | + 'body' => $content, |
|
| 64 | + ) ); |
|
| 65 | 65 | |
| 66 | - $response = wp_remote_post( $url, $args ); |
|
| 66 | + $response = wp_remote_post( $url, $args ); |
|
| 67 | 67 | |
| 68 | - // If it's an error log it. |
|
| 69 | - if ( is_wp_error( $response ) ) { |
|
| 68 | + // If it's an error log it. |
|
| 69 | + if ( is_wp_error( $response ) ) { |
|
| 70 | 70 | |
| 71 | - $message = "An error occurred while requesting an analysis to $url: {$response->get_error_message()}"; |
|
| 71 | + $message = "An error occurred while requesting an analysis to $url: {$response->get_error_message()}"; |
|
| 72 | 72 | |
| 73 | - Wordlift_Log_Service::get_logger( 'wl_analyze_content' )->error( $message ); |
|
| 73 | + Wordlift_Log_Service::get_logger( 'wl_analyze_content' )->error( $message ); |
|
| 74 | 74 | |
| 75 | - throw new Exception( $response->get_error_message(), $response->get_error_code() ); |
|
| 76 | - } |
|
| 75 | + throw new Exception( $response->get_error_message(), $response->get_error_code() ); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - // Get the status code. |
|
| 79 | - $status_code = (int) $response['response']['code']; |
|
| 78 | + // Get the status code. |
|
| 79 | + $status_code = (int) $response['response']['code']; |
|
| 80 | 80 | |
| 81 | - // If status code is OK, return the body. |
|
| 82 | - if ( 200 === $status_code ) { |
|
| 83 | - return $response['body']; |
|
| 84 | - } |
|
| 81 | + // If status code is OK, return the body. |
|
| 82 | + if ( 200 === $status_code ) { |
|
| 83 | + return $response['body']; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - // Invalid request, e.g. invalid key. |
|
| 87 | - if ( 400 === $status_code ) { |
|
| 88 | - $error = json_decode( $response['body'] ); |
|
| 86 | + // Invalid request, e.g. invalid key. |
|
| 87 | + if ( 400 === $status_code ) { |
|
| 88 | + $error = json_decode( $response['body'] ); |
|
| 89 | 89 | |
| 90 | - throw new Exception( $error->message, $error->code ); |
|
| 91 | - } |
|
| 90 | + throw new Exception( $error->message, $error->code ); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - // Another generic error. |
|
| 94 | - throw new Exception( "An error occurred.", $status_code );; |
|
| 93 | + // Another generic error. |
|
| 94 | + throw new Exception( "An error occurred.", $status_code );; |
|
| 95 | 95 | } |
@@ -11,25 +11,25 @@ discard block |
||
| 11 | 11 | function wl_ajax_analyze_action() { |
| 12 | 12 | |
| 13 | 13 | try { |
| 14 | - if ( $analysis = wl_analyze_content( file_get_contents( "php://input" ) ) ) { |
|
| 15 | - header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); |
|
| 16 | - echo( $analysis ); |
|
| 14 | + if ($analysis = wl_analyze_content(file_get_contents("php://input"))) { |
|
| 15 | + header('Content-Type: application/json; charset='.get_option('blog_charset')); |
|
| 16 | + echo($analysis); |
|
| 17 | 17 | wp_die(); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - status_header( 500 ); |
|
| 21 | - wp_send_json( __( 'An error occurred while request an analysis to the remote service. Please try again later.', 'wordlift' ) ); |
|
| 20 | + status_header(500); |
|
| 21 | + wp_send_json(__('An error occurred while request an analysis to the remote service. Please try again later.', 'wordlift')); |
|
| 22 | 22 | |
| 23 | - } catch ( Exception $e ) { |
|
| 24 | - wp_send_json_error( array( |
|
| 23 | + } catch (Exception $e) { |
|
| 24 | + wp_send_json_error(array( |
|
| 25 | 25 | 'code' => $e->getCode(), |
| 26 | 26 | 'message' => $e->getMessage(), |
| 27 | - ) ); |
|
| 27 | + )); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -add_action( 'wp_ajax_wordlift_analyze', 'wl_ajax_analyze_action' ); |
|
| 32 | +add_action('wp_ajax_wordlift_analyze', 'wl_ajax_analyze_action'); |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Analyze the provided content. The analysis will make use of the method *wl_ajax_analyze_action* |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return string Returns null on failure, or the WP_Error, or a WP_Response with the response. |
| 45 | 45 | */ |
| 46 | -function wl_analyze_content( $content ) { |
|
| 46 | +function wl_analyze_content($content) { |
|
| 47 | 47 | |
| 48 | 48 | // Get the analyzer URL. |
| 49 | 49 | $url = wl_configuration_get_analyzer_url(); |
| 50 | 50 | |
| 51 | 51 | // Set the content type to the request content type or to text/plain by default. |
| 52 | - $content_type = isset( $_SERVER['CONTENT_TYPE'] ) ? $_SERVER['CONTENT_TYPE'] : 'text/plain'; |
|
| 52 | + $content_type = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : 'text/plain'; |
|
| 53 | 53 | |
| 54 | 54 | // Prepare the request. |
| 55 | - $args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array( |
|
| 55 | + $args = array_merge_recursive(unserialize(WL_REDLINK_API_HTTP_OPTIONS), array( |
|
| 56 | 56 | 'method' => 'POST', |
| 57 | 57 | 'headers' => array( |
| 58 | 58 | 'Accept' => 'application/json', |
@@ -61,35 +61,35 @@ discard block |
||
| 61 | 61 | // we need to downgrade the HTTP version in this case since chunked encoding is dumping numbers in the response. |
| 62 | 62 | 'httpversion' => '1.0', |
| 63 | 63 | 'body' => $content, |
| 64 | - ) ); |
|
| 64 | + )); |
|
| 65 | 65 | |
| 66 | - $response = wp_remote_post( $url, $args ); |
|
| 66 | + $response = wp_remote_post($url, $args); |
|
| 67 | 67 | |
| 68 | 68 | // If it's an error log it. |
| 69 | - if ( is_wp_error( $response ) ) { |
|
| 69 | + if (is_wp_error($response)) { |
|
| 70 | 70 | |
| 71 | 71 | $message = "An error occurred while requesting an analysis to $url: {$response->get_error_message()}"; |
| 72 | 72 | |
| 73 | - Wordlift_Log_Service::get_logger( 'wl_analyze_content' )->error( $message ); |
|
| 73 | + Wordlift_Log_Service::get_logger('wl_analyze_content')->error($message); |
|
| 74 | 74 | |
| 75 | - throw new Exception( $response->get_error_message(), $response->get_error_code() ); |
|
| 75 | + throw new Exception($response->get_error_message(), $response->get_error_code()); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // Get the status code. |
| 79 | 79 | $status_code = (int) $response['response']['code']; |
| 80 | 80 | |
| 81 | 81 | // If status code is OK, return the body. |
| 82 | - if ( 200 === $status_code ) { |
|
| 82 | + if (200 === $status_code) { |
|
| 83 | 83 | return $response['body']; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // Invalid request, e.g. invalid key. |
| 87 | - if ( 400 === $status_code ) { |
|
| 88 | - $error = json_decode( $response['body'] ); |
|
| 87 | + if (400 === $status_code) { |
|
| 88 | + $error = json_decode($response['body']); |
|
| 89 | 89 | |
| 90 | - throw new Exception( $error->message, $error->code ); |
|
| 90 | + throw new Exception($error->message, $error->code); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Another generic error. |
| 94 | - throw new Exception( "An error occurred.", $status_code );; |
|
| 94 | + throw new Exception("An error occurred.", $status_code); ; |
|
| 95 | 95 | } |
@@ -14,19 +14,19 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function wl_linked_data_save_post( $post_id ) { |
| 16 | 16 | |
| 17 | - // If it's not numeric exit from here. |
|
| 18 | - if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) { |
|
| 19 | - return; |
|
| 20 | - } |
|
| 17 | + // If it's not numeric exit from here. |
|
| 18 | + if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) { |
|
| 19 | + return; |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - // unhook this function so it doesn't loop infinitely |
|
| 23 | - remove_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 22 | + // unhook this function so it doesn't loop infinitely |
|
| 23 | + remove_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 24 | 24 | |
| 25 | - // raise the *wl_linked_data_save_post* event. |
|
| 26 | - do_action( 'wl_linked_data_save_post', $post_id ); |
|
| 25 | + // raise the *wl_linked_data_save_post* event. |
|
| 26 | + do_action( 'wl_linked_data_save_post', $post_id ); |
|
| 27 | 27 | |
| 28 | - // re-hook this function |
|
| 29 | - add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 28 | + // re-hook this function |
|
| 29 | + add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | add_action( 'save_post', 'wl_linked_data_save_post' ); |
@@ -40,143 +40,143 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function wl_linked_data_save_post_and_related_entities( $post_id ) { |
| 42 | 42 | |
| 43 | - // Ignore auto-saves |
|
| 44 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 45 | - return; |
|
| 46 | - } |
|
| 43 | + // Ignore auto-saves |
|
| 44 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 45 | + return; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - // get the current post. |
|
| 49 | - $post = get_post( $post_id ); |
|
| 48 | + // get the current post. |
|
| 49 | + $post = get_post( $post_id ); |
|
| 50 | 50 | |
| 51 | - remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 51 | + remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 52 | 52 | |
| 53 | - // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" ); |
|
| 53 | + // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" ); |
|
| 54 | 54 | |
| 55 | - // Store mapping between tmp new entities uris and real new entities uri |
|
| 56 | - $entities_uri_mapping = array(); |
|
| 55 | + // Store mapping between tmp new entities uris and real new entities uri |
|
| 56 | + $entities_uri_mapping = array(); |
|
| 57 | 57 | |
| 58 | - // Save the entities coming with POST data. |
|
| 59 | - if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) { |
|
| 58 | + // Save the entities coming with POST data. |
|
| 59 | + if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) { |
|
| 60 | 60 | |
| 61 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " ); |
|
| 62 | - wl_write_log( json_encode( $_POST['wl_entities'] ) ); |
|
| 63 | - wl_write_log( "]" ); |
|
| 64 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " ); |
|
| 65 | - wl_write_log( json_encode( $_POST['wl_boxes'], true ) ); |
|
| 66 | - wl_write_log( "]" ); |
|
| 61 | + wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " ); |
|
| 62 | + wl_write_log( json_encode( $_POST['wl_entities'] ) ); |
|
| 63 | + wl_write_log( "]" ); |
|
| 64 | + wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " ); |
|
| 65 | + wl_write_log( json_encode( $_POST['wl_boxes'], true ) ); |
|
| 66 | + wl_write_log( "]" ); |
|
| 67 | 67 | |
| 68 | - $entities_via_post = $_POST['wl_entities']; |
|
| 69 | - $boxes_via_post = $_POST['wl_boxes']; |
|
| 68 | + $entities_via_post = $_POST['wl_entities']; |
|
| 69 | + $boxes_via_post = $_POST['wl_boxes']; |
|
| 70 | 70 | |
| 71 | - foreach ( $entities_via_post as $entity_uri => $entity ) { |
|
| 71 | + foreach ( $entities_via_post as $entity_uri => $entity ) { |
|
| 72 | 72 | |
| 73 | - // Only if the current entity is created from scratch let's avoid to |
|
| 74 | - // create more than one entity with same label & entity type. |
|
| 75 | - $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ? |
|
| 76 | - $entity['main_type'] : null; |
|
| 77 | - |
|
| 78 | - // Look if current entity uri matches an internal existing entity, meaning: |
|
| 79 | - // 1. when $entity_uri is an internal uri |
|
| 80 | - // 2. when $entity_uri is an external uri used as sameAs of an internal entity |
|
| 81 | - $ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $entity_uri ); |
|
| 73 | + // Only if the current entity is created from scratch let's avoid to |
|
| 74 | + // create more than one entity with same label & entity type. |
|
| 75 | + $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ? |
|
| 76 | + $entity['main_type'] : null; |
|
| 77 | + |
|
| 78 | + // Look if current entity uri matches an internal existing entity, meaning: |
|
| 79 | + // 1. when $entity_uri is an internal uri |
|
| 80 | + // 2. when $entity_uri is an external uri used as sameAs of an internal entity |
|
| 81 | + $ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $entity_uri ); |
|
| 82 | 82 | |
| 83 | - // Detect the uri depending if is an existing or a new entity |
|
| 84 | - $uri = ( null === $ie ) ? |
|
| 85 | - Wordlift_Uri_Service::get_instance()->build_uri( |
|
| 86 | - $entity['label'], |
|
| 87 | - Wordlift_Entity_Service::TYPE_NAME, |
|
| 88 | - $entity_type |
|
| 89 | - ) : wl_get_entity_uri( $ie->ID ); |
|
| 83 | + // Detect the uri depending if is an existing or a new entity |
|
| 84 | + $uri = ( null === $ie ) ? |
|
| 85 | + Wordlift_Uri_Service::get_instance()->build_uri( |
|
| 86 | + $entity['label'], |
|
| 87 | + Wordlift_Entity_Service::TYPE_NAME, |
|
| 88 | + $entity_type |
|
| 89 | + ) : wl_get_entity_uri( $ie->ID ); |
|
| 90 | 90 | |
| 91 | - wl_write_log( "Map $entity_uri on $uri" ); |
|
| 92 | - $entities_uri_mapping[ $entity_uri ] = $uri; |
|
| 91 | + wl_write_log( "Map $entity_uri on $uri" ); |
|
| 92 | + $entities_uri_mapping[ $entity_uri ] = $uri; |
|
| 93 | 93 | |
| 94 | - // Local entities have a tmp uri with 'local-entity-' prefix |
|
| 95 | - // These uris need to be rewritten here and replaced in the content |
|
| 96 | - if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) { |
|
| 97 | - // Override the entity obj |
|
| 98 | - $entity['uri'] = $uri; |
|
| 99 | - } |
|
| 94 | + // Local entities have a tmp uri with 'local-entity-' prefix |
|
| 95 | + // These uris need to be rewritten here and replaced in the content |
|
| 96 | + if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) { |
|
| 97 | + // Override the entity obj |
|
| 98 | + $entity['uri'] = $uri; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - // Update entity data with related post |
|
| 102 | - $entity['related_post_id'] = $post_id; |
|
| 101 | + // Update entity data with related post |
|
| 102 | + $entity['related_post_id'] = $post_id; |
|
| 103 | 103 | |
| 104 | - // Save the entity if is a new entity |
|
| 105 | - if ( null === $ie ) { |
|
| 106 | - wl_save_entity( $entity ); |
|
| 107 | - } |
|
| 104 | + // Save the entity if is a new entity |
|
| 105 | + if ( null === $ie ) { |
|
| 106 | + wl_save_entity( $entity ); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - // Replace tmp uris in content post if needed |
|
| 114 | - $updated_post_content = $post->post_content; |
|
| 115 | - // Save each entity and store the post id. |
|
| 116 | - foreach ( $entities_uri_mapping as $tmp_uri => $uri ) { |
|
| 117 | - $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content ); |
|
| 118 | - } |
|
| 113 | + // Replace tmp uris in content post if needed |
|
| 114 | + $updated_post_content = $post->post_content; |
|
| 115 | + // Save each entity and store the post id. |
|
| 116 | + foreach ( $entities_uri_mapping as $tmp_uri => $uri ) { |
|
| 117 | + $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content ); |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - // Update the post content |
|
| 121 | - wp_update_post( array( |
|
| 122 | - 'ID' => $post->ID, |
|
| 123 | - 'post_content' => $updated_post_content, |
|
| 124 | - ) ); |
|
| 120 | + // Update the post content |
|
| 121 | + wp_update_post( array( |
|
| 122 | + 'ID' => $post->ID, |
|
| 123 | + 'post_content' => $updated_post_content, |
|
| 124 | + ) ); |
|
| 125 | 125 | |
| 126 | - // Extract related/referenced entities from text. |
|
| 127 | - $disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content ); |
|
| 126 | + // Extract related/referenced entities from text. |
|
| 127 | + $disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content ); |
|
| 128 | 128 | |
| 129 | - // Reset previously saved instances |
|
| 130 | - wl_core_delete_relation_instances( $post_id ); |
|
| 129 | + // Reset previously saved instances |
|
| 130 | + wl_core_delete_relation_instances( $post_id ); |
|
| 131 | 131 | |
| 132 | - // Save relation instances |
|
| 133 | - foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) { |
|
| 132 | + // Save relation instances |
|
| 133 | + foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) { |
|
| 134 | 134 | |
| 135 | - wl_core_add_relation_instance( |
|
| 136 | - $post_id, |
|
| 137 | - Wordlift_Entity_Service::get_instance()->get_classification_scope_for( $referenced_entity_id ), |
|
| 138 | - $referenced_entity_id |
|
| 139 | - ); |
|
| 135 | + wl_core_add_relation_instance( |
|
| 136 | + $post_id, |
|
| 137 | + Wordlift_Entity_Service::get_instance()->get_classification_scope_for( $referenced_entity_id ), |
|
| 138 | + $referenced_entity_id |
|
| 139 | + ); |
|
| 140 | 140 | |
| 141 | - } |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - if ( isset( $_POST['wl_entities'] ) ) { |
|
| 144 | - // Save post metadata if available |
|
| 145 | - $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ? |
|
| 146 | - $_POST['wl_metadata'] : array(); |
|
| 143 | + if ( isset( $_POST['wl_entities'] ) ) { |
|
| 144 | + // Save post metadata if available |
|
| 145 | + $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ? |
|
| 146 | + $_POST['wl_metadata'] : array(); |
|
| 147 | 147 | |
| 148 | - $fields = array( |
|
| 149 | - Wordlift_Schema_Service::FIELD_LOCATION_CREATED, |
|
| 150 | - Wordlift_Schema_Service::FIELD_TOPIC, |
|
| 151 | - ); |
|
| 152 | - |
|
| 153 | - // Unlink topic taxonomy terms |
|
| 154 | - Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID ); |
|
| 155 | - |
|
| 156 | - foreach ( $fields as $field ) { |
|
| 157 | - |
|
| 158 | - // Delete current values |
|
| 159 | - delete_post_meta( $post->ID, $field ); |
|
| 160 | - // Retrieve the entity uri |
|
| 161 | - $uri = ( isset( $metadata_via_post[ $field ] ) ) ? |
|
| 162 | - stripslashes( $metadata_via_post[ $field ] ) : ''; |
|
| 163 | - |
|
| 164 | - $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ); |
|
| 165 | - |
|
| 166 | - if ( $entity ) { |
|
| 167 | - add_post_meta( $post->ID, $field, $entity->ID, true ); |
|
| 168 | - // Set also the topic taxonomy |
|
| 169 | - if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) { |
|
| 170 | - Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity ); |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - // Push the post to Redlink. |
|
| 177 | - wl_linked_data_push_to_redlink( $post->ID ); |
|
| 178 | - |
|
| 179 | - add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 148 | + $fields = array( |
|
| 149 | + Wordlift_Schema_Service::FIELD_LOCATION_CREATED, |
|
| 150 | + Wordlift_Schema_Service::FIELD_TOPIC, |
|
| 151 | + ); |
|
| 152 | + |
|
| 153 | + // Unlink topic taxonomy terms |
|
| 154 | + Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID ); |
|
| 155 | + |
|
| 156 | + foreach ( $fields as $field ) { |
|
| 157 | + |
|
| 158 | + // Delete current values |
|
| 159 | + delete_post_meta( $post->ID, $field ); |
|
| 160 | + // Retrieve the entity uri |
|
| 161 | + $uri = ( isset( $metadata_via_post[ $field ] ) ) ? |
|
| 162 | + stripslashes( $metadata_via_post[ $field ] ) : ''; |
|
| 163 | + |
|
| 164 | + $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ); |
|
| 165 | + |
|
| 166 | + if ( $entity ) { |
|
| 167 | + add_post_meta( $post->ID, $field, $entity->ID, true ); |
|
| 168 | + // Set also the topic taxonomy |
|
| 169 | + if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) { |
|
| 170 | + Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity ); |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + // Push the post to Redlink. |
|
| 177 | + wl_linked_data_push_to_redlink( $post->ID ); |
|
| 178 | + |
|
| 179 | + add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
@@ -186,20 +186,20 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | function wordlift_save_post_add_default_schema_type( $entity_id ) { |
| 188 | 188 | |
| 189 | - $entity = get_post( $entity_id ); |
|
| 189 | + $entity = get_post( $entity_id ); |
|
| 190 | 190 | |
| 191 | - // Avoid doing anything if post is autosave or a revision. |
|
| 191 | + // Avoid doing anything if post is autosave or a revision. |
|
| 192 | 192 | |
| 193 | - if ( wp_is_post_autosave( $entity ) || wp_is_post_revision( $entity ) ) { |
|
| 194 | - return; |
|
| 195 | - } |
|
| 193 | + if ( wp_is_post_autosave( $entity ) || wp_is_post_revision( $entity ) ) { |
|
| 194 | + return; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - $entity_type = wl_schema_get_types( $entity_id ); |
|
| 197 | + $entity_type = wl_schema_get_types( $entity_id ); |
|
| 198 | 198 | |
| 199 | - // Assign type 'Thing' if we are dealing with an entity without type |
|
| 200 | - if ( $entity->post_type == Wordlift_Entity_Service::TYPE_NAME && is_null( $entity_type ) ) { |
|
| 201 | - wl_schema_set_types( $entity_id, 'Thing' ); |
|
| 202 | - } |
|
| 199 | + // Assign type 'Thing' if we are dealing with an entity without type |
|
| 200 | + if ( $entity->post_type == Wordlift_Entity_Service::TYPE_NAME && is_null( $entity_type ) ) { |
|
| 201 | + wl_schema_set_types( $entity_id, 'Thing' ); |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | |
@@ -225,185 +225,185 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | function wl_save_entity( $entity_data ) { |
| 227 | 227 | |
| 228 | - $uri = $entity_data['uri']; |
|
| 229 | - $label = $entity_data['label']; |
|
| 230 | - $type_uri = $entity_data['main_type']; |
|
| 231 | - $entity_types = isset( $entity_data['type'] ) ? $entity_data['type'] : array(); |
|
| 232 | - $description = $entity_data['description']; |
|
| 233 | - $images = isset( $entity_data['image'] ) ? wl_force_to_array( $entity_data['image'] ) : array(); |
|
| 234 | - $same_as = isset( $entity_data['sameas'] ) ? wl_force_to_array( $entity_data['sameas'] ) : array(); |
|
| 235 | - $related_post_id = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null; |
|
| 236 | - $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array(); |
|
| 237 | - |
|
| 238 | - // Get the synonyms. |
|
| 239 | - $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array(); |
|
| 240 | - |
|
| 241 | - // Check whether an entity already exists with the provided URI. |
|
| 242 | - if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) { |
|
| 243 | - return $post; |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - // Prepare properties of the new entity. |
|
| 247 | - $params = array( |
|
| 248 | - 'post_status' => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ), |
|
| 249 | - 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 250 | - 'post_title' => $label, |
|
| 251 | - 'post_content' => $description, |
|
| 252 | - 'post_excerpt' => '', |
|
| 253 | - // Ensure we're using a valid slug. We're not overwriting an existing |
|
| 254 | - // entity with a post_name already set, since this call is made only for |
|
| 255 | - // new entities. |
|
| 256 | - // |
|
| 257 | - // See https://github.com/insideout10/wordlift-plugin/issues/282 |
|
| 258 | - 'post_name' => sanitize_title( $label ), |
|
| 259 | - ); |
|
| 260 | - |
|
| 261 | - // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over" |
|
| 262 | - // the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 263 | - // Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148) |
|
| 264 | - // This does NOT affect saving an entity from the entity admin page since this function is called when an entity |
|
| 265 | - // is created when saving a post. |
|
| 266 | - global $wpseo_metabox, $seo_ultimate; |
|
| 267 | - if ( isset( $wpseo_metabox ) ) { |
|
| 268 | - remove_action( 'wp_insert_post', array( |
|
| 269 | - $wpseo_metabox, |
|
| 270 | - 'save_postdata', |
|
| 271 | - ) ); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - if ( isset( $seo_ultimate ) ) { |
|
| 275 | - remove_action( 'save_post', array( |
|
| 276 | - $seo_ultimate, |
|
| 277 | - 'save_postmeta_box', |
|
| 278 | - ) ); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to |
|
| 282 | - // save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks |
|
| 283 | - // to the save_post and restore them after we saved the entity. |
|
| 284 | - // see https://github.com/insideout10/wordlift-plugin/issues/203 |
|
| 285 | - // see https://github.com/insideout10/wordlift-plugin/issues/156 |
|
| 286 | - // see https://github.com/insideout10/wordlift-plugin/issues/148 |
|
| 287 | - global $wp_filter; |
|
| 288 | - $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 289 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 290 | - |
|
| 291 | - // create or update the post. |
|
| 292 | - $post_id = wp_insert_post( $params, true ); |
|
| 293 | - |
|
| 294 | - // Setting the alternative labels for this entity. |
|
| 295 | - Wordlift_Entity_Service::get_instance() |
|
| 296 | - ->set_alternative_labels( $post_id, $synonyms ); |
|
| 297 | - |
|
| 298 | - // Restore all the existing filters. |
|
| 299 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 300 | - |
|
| 301 | - // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 302 | - if ( isset( $wpseo_metabox ) ) { |
|
| 303 | - add_action( 'wp_insert_post', array( |
|
| 304 | - $wpseo_metabox, |
|
| 305 | - 'save_postdata', |
|
| 306 | - ) ); |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - // If SEO Ultimate is installed, add back the hook we removed a few lines above. |
|
| 310 | - if ( isset( $seo_ultimate ) ) { |
|
| 311 | - add_action( 'save_post', array( |
|
| 312 | - $seo_ultimate, |
|
| 313 | - 'save_postmeta_box', |
|
| 314 | - ), 10, 2 ); |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - // TODO: handle errors. |
|
| 318 | - if ( is_wp_error( $post_id ) ) { |
|
| 319 | - wl_write_log( ': error occurred' ); |
|
| 320 | - |
|
| 321 | - // inform an error occurred. |
|
| 322 | - return null; |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - wl_set_entity_main_type( $post_id, $type_uri ); |
|
| 326 | - |
|
| 327 | - // Save the entity types. |
|
| 328 | - wl_set_entity_rdf_types( $post_id, $entity_types ); |
|
| 329 | - |
|
| 330 | - // Get a dataset URI for the entity. |
|
| 331 | - $wl_uri = wl_build_entity_uri( $post_id ); |
|
| 332 | - |
|
| 333 | - // Save the entity URI. |
|
| 334 | - wl_set_entity_uri( $post_id, $wl_uri ); |
|
| 335 | - |
|
| 336 | - // Add the uri to the sameAs data if it's not a local URI. |
|
| 337 | - if ( $wl_uri !== $uri ) { |
|
| 338 | - array_push( $same_as, $uri ); |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - $new_uri = wl_get_entity_uri( $post_id ); |
|
| 342 | - |
|
| 343 | - // Save the sameAs data for the entity. |
|
| 344 | - wl_schema_set_value( $post_id, 'sameAs', $same_as ); |
|
| 345 | - |
|
| 346 | - // Save the other properties (latitude, langitude, startDate, endDate, etc.) |
|
| 347 | - foreach ( $other_properties as $property_name => $property_value ) { |
|
| 348 | - wl_schema_set_value( $post_id, $property_name, $property_value ); |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - // Call hooks. |
|
| 352 | - do_action( 'wl_save_entity', $post_id ); |
|
| 353 | - |
|
| 354 | - foreach ( $images as $image_remote_url ) { |
|
| 355 | - |
|
| 356 | - // Check if image is already present in local DB |
|
| 357 | - if ( strpos( $image_remote_url, site_url() ) !== false ) { |
|
| 358 | - // Do nothing. |
|
| 359 | - continue; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - // Check if there is an existing attachment for this post ID and source URL. |
|
| 363 | - $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url ); |
|
| 364 | - |
|
| 365 | - // Skip if an existing image is found. |
|
| 366 | - if ( null !== $existing_image ) { |
|
| 367 | - continue; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - // Save the image and get the local path. |
|
| 371 | - $image = wl_save_image( $image_remote_url ); |
|
| 372 | - |
|
| 373 | - // Get the local URL. |
|
| 374 | - $filename = $image['path']; |
|
| 375 | - $url = $image['url']; |
|
| 376 | - $content_type = $image['content_type']; |
|
| 377 | - |
|
| 378 | - $attachment = array( |
|
| 379 | - 'guid' => $url, |
|
| 380 | - // post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type |
|
| 381 | - 'post_title' => $label, |
|
| 382 | - // Set the title to the post title. |
|
| 383 | - 'post_content' => '', |
|
| 384 | - 'post_status' => 'inherit', |
|
| 385 | - 'post_mime_type' => $content_type, |
|
| 386 | - ); |
|
| 387 | - |
|
| 388 | - // Create the attachment in WordPress and generate the related metadata. |
|
| 389 | - $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id ); |
|
| 228 | + $uri = $entity_data['uri']; |
|
| 229 | + $label = $entity_data['label']; |
|
| 230 | + $type_uri = $entity_data['main_type']; |
|
| 231 | + $entity_types = isset( $entity_data['type'] ) ? $entity_data['type'] : array(); |
|
| 232 | + $description = $entity_data['description']; |
|
| 233 | + $images = isset( $entity_data['image'] ) ? wl_force_to_array( $entity_data['image'] ) : array(); |
|
| 234 | + $same_as = isset( $entity_data['sameas'] ) ? wl_force_to_array( $entity_data['sameas'] ) : array(); |
|
| 235 | + $related_post_id = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null; |
|
| 236 | + $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array(); |
|
| 237 | + |
|
| 238 | + // Get the synonyms. |
|
| 239 | + $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array(); |
|
| 240 | + |
|
| 241 | + // Check whether an entity already exists with the provided URI. |
|
| 242 | + if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) { |
|
| 243 | + return $post; |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + // Prepare properties of the new entity. |
|
| 247 | + $params = array( |
|
| 248 | + 'post_status' => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ), |
|
| 249 | + 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 250 | + 'post_title' => $label, |
|
| 251 | + 'post_content' => $description, |
|
| 252 | + 'post_excerpt' => '', |
|
| 253 | + // Ensure we're using a valid slug. We're not overwriting an existing |
|
| 254 | + // entity with a post_name already set, since this call is made only for |
|
| 255 | + // new entities. |
|
| 256 | + // |
|
| 257 | + // See https://github.com/insideout10/wordlift-plugin/issues/282 |
|
| 258 | + 'post_name' => sanitize_title( $label ), |
|
| 259 | + ); |
|
| 260 | + |
|
| 261 | + // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over" |
|
| 262 | + // the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 263 | + // Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148) |
|
| 264 | + // This does NOT affect saving an entity from the entity admin page since this function is called when an entity |
|
| 265 | + // is created when saving a post. |
|
| 266 | + global $wpseo_metabox, $seo_ultimate; |
|
| 267 | + if ( isset( $wpseo_metabox ) ) { |
|
| 268 | + remove_action( 'wp_insert_post', array( |
|
| 269 | + $wpseo_metabox, |
|
| 270 | + 'save_postdata', |
|
| 271 | + ) ); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + if ( isset( $seo_ultimate ) ) { |
|
| 275 | + remove_action( 'save_post', array( |
|
| 276 | + $seo_ultimate, |
|
| 277 | + 'save_postmeta_box', |
|
| 278 | + ) ); |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to |
|
| 282 | + // save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks |
|
| 283 | + // to the save_post and restore them after we saved the entity. |
|
| 284 | + // see https://github.com/insideout10/wordlift-plugin/issues/203 |
|
| 285 | + // see https://github.com/insideout10/wordlift-plugin/issues/156 |
|
| 286 | + // see https://github.com/insideout10/wordlift-plugin/issues/148 |
|
| 287 | + global $wp_filter; |
|
| 288 | + $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 289 | + is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 290 | + |
|
| 291 | + // create or update the post. |
|
| 292 | + $post_id = wp_insert_post( $params, true ); |
|
| 293 | + |
|
| 294 | + // Setting the alternative labels for this entity. |
|
| 295 | + Wordlift_Entity_Service::get_instance() |
|
| 296 | + ->set_alternative_labels( $post_id, $synonyms ); |
|
| 297 | + |
|
| 298 | + // Restore all the existing filters. |
|
| 299 | + is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 300 | + |
|
| 301 | + // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156) |
|
| 302 | + if ( isset( $wpseo_metabox ) ) { |
|
| 303 | + add_action( 'wp_insert_post', array( |
|
| 304 | + $wpseo_metabox, |
|
| 305 | + 'save_postdata', |
|
| 306 | + ) ); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + // If SEO Ultimate is installed, add back the hook we removed a few lines above. |
|
| 310 | + if ( isset( $seo_ultimate ) ) { |
|
| 311 | + add_action( 'save_post', array( |
|
| 312 | + $seo_ultimate, |
|
| 313 | + 'save_postmeta_box', |
|
| 314 | + ), 10, 2 ); |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + // TODO: handle errors. |
|
| 318 | + if ( is_wp_error( $post_id ) ) { |
|
| 319 | + wl_write_log( ': error occurred' ); |
|
| 320 | + |
|
| 321 | + // inform an error occurred. |
|
| 322 | + return null; |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + wl_set_entity_main_type( $post_id, $type_uri ); |
|
| 326 | + |
|
| 327 | + // Save the entity types. |
|
| 328 | + wl_set_entity_rdf_types( $post_id, $entity_types ); |
|
| 329 | + |
|
| 330 | + // Get a dataset URI for the entity. |
|
| 331 | + $wl_uri = wl_build_entity_uri( $post_id ); |
|
| 332 | + |
|
| 333 | + // Save the entity URI. |
|
| 334 | + wl_set_entity_uri( $post_id, $wl_uri ); |
|
| 335 | + |
|
| 336 | + // Add the uri to the sameAs data if it's not a local URI. |
|
| 337 | + if ( $wl_uri !== $uri ) { |
|
| 338 | + array_push( $same_as, $uri ); |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + $new_uri = wl_get_entity_uri( $post_id ); |
|
| 342 | + |
|
| 343 | + // Save the sameAs data for the entity. |
|
| 344 | + wl_schema_set_value( $post_id, 'sameAs', $same_as ); |
|
| 345 | + |
|
| 346 | + // Save the other properties (latitude, langitude, startDate, endDate, etc.) |
|
| 347 | + foreach ( $other_properties as $property_name => $property_value ) { |
|
| 348 | + wl_schema_set_value( $post_id, $property_name, $property_value ); |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + // Call hooks. |
|
| 352 | + do_action( 'wl_save_entity', $post_id ); |
|
| 353 | + |
|
| 354 | + foreach ( $images as $image_remote_url ) { |
|
| 355 | + |
|
| 356 | + // Check if image is already present in local DB |
|
| 357 | + if ( strpos( $image_remote_url, site_url() ) !== false ) { |
|
| 358 | + // Do nothing. |
|
| 359 | + continue; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + // Check if there is an existing attachment for this post ID and source URL. |
|
| 363 | + $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url ); |
|
| 364 | + |
|
| 365 | + // Skip if an existing image is found. |
|
| 366 | + if ( null !== $existing_image ) { |
|
| 367 | + continue; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + // Save the image and get the local path. |
|
| 371 | + $image = wl_save_image( $image_remote_url ); |
|
| 372 | + |
|
| 373 | + // Get the local URL. |
|
| 374 | + $filename = $image['path']; |
|
| 375 | + $url = $image['url']; |
|
| 376 | + $content_type = $image['content_type']; |
|
| 377 | + |
|
| 378 | + $attachment = array( |
|
| 379 | + 'guid' => $url, |
|
| 380 | + // post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type |
|
| 381 | + 'post_title' => $label, |
|
| 382 | + // Set the title to the post title. |
|
| 383 | + 'post_content' => '', |
|
| 384 | + 'post_status' => 'inherit', |
|
| 385 | + 'post_mime_type' => $content_type, |
|
| 386 | + ); |
|
| 387 | + |
|
| 388 | + // Create the attachment in WordPress and generate the related metadata. |
|
| 389 | + $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id ); |
|
| 390 | 390 | |
| 391 | - // Set the source URL for the image. |
|
| 392 | - wl_set_source_url( $attachment_id, $image_remote_url ); |
|
| 391 | + // Set the source URL for the image. |
|
| 392 | + wl_set_source_url( $attachment_id, $image_remote_url ); |
|
| 393 | 393 | |
| 394 | - $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
| 395 | - wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
| 394 | + $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
| 395 | + wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
| 396 | 396 | |
| 397 | - // Set it as the featured image. |
|
| 398 | - set_post_thumbnail( $post_id, $attachment_id ); |
|
| 399 | - } |
|
| 397 | + // Set it as the featured image. |
|
| 398 | + set_post_thumbnail( $post_id, $attachment_id ); |
|
| 399 | + } |
|
| 400 | 400 | |
| 401 | - // The entity is pushed to Redlink on save by the function hooked to save_post. |
|
| 402 | - // save the entity in the triple store. |
|
| 403 | - wl_linked_data_push_to_redlink( $post_id ); |
|
| 401 | + // The entity is pushed to Redlink on save by the function hooked to save_post. |
|
| 402 | + // save the entity in the triple store. |
|
| 403 | + wl_linked_data_push_to_redlink( $post_id ); |
|
| 404 | 404 | |
| 405 | - // finally return the entity post. |
|
| 406 | - return get_post( $post_id ); |
|
| 405 | + // finally return the entity post. |
|
| 406 | + return get_post( $post_id ); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -417,42 +417,42 @@ discard block |
||
| 417 | 417 | */ |
| 418 | 418 | function wl_linked_data_content_get_embedded_entities( $content ) { |
| 419 | 419 | |
| 420 | - // Remove quote escapes. |
|
| 421 | - $content = str_replace( '\\"', '"', $content ); |
|
| 420 | + // Remove quote escapes. |
|
| 421 | + $content = str_replace( '\\"', '"', $content ); |
|
| 422 | 422 | |
| 423 | - // Match all itemid attributes. |
|
| 424 | - $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
|
| 423 | + // Match all itemid attributes. |
|
| 424 | + $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
|
| 425 | 425 | |
| 426 | - // wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" ); |
|
| 426 | + // wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" ); |
|
| 427 | 427 | |
| 428 | - // Remove the pattern while it is found (match nested annotations). |
|
| 429 | - $matches = array(); |
|
| 428 | + // Remove the pattern while it is found (match nested annotations). |
|
| 429 | + $matches = array(); |
|
| 430 | 430 | |
| 431 | - // In case of errors, return an empty array. |
|
| 432 | - if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 433 | - wl_write_log( "Found no entities embedded in content" ); |
|
| 431 | + // In case of errors, return an empty array. |
|
| 432 | + if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 433 | + wl_write_log( "Found no entities embedded in content" ); |
|
| 434 | 434 | |
| 435 | - return array(); |
|
| 436 | - } |
|
| 435 | + return array(); |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | 438 | // wl_write_log("wl_update_related_entities [ content :: $content ][ data :: " . var_export($data, true). " ][ matches :: " . var_export($matches, true) . " ]"); |
| 439 | 439 | |
| 440 | - // Collect the entities. |
|
| 441 | - $entities = array(); |
|
| 442 | - foreach ( $matches[1] as $uri ) { |
|
| 443 | - $uri_d = html_entity_decode( $uri ); |
|
| 440 | + // Collect the entities. |
|
| 441 | + $entities = array(); |
|
| 442 | + foreach ( $matches[1] as $uri ) { |
|
| 443 | + $uri_d = html_entity_decode( $uri ); |
|
| 444 | 444 | |
| 445 | - $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d ); |
|
| 445 | + $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d ); |
|
| 446 | 446 | |
| 447 | - if ( null !== $entity ) { |
|
| 448 | - array_push( $entities, $entity->ID ); |
|
| 449 | - } |
|
| 450 | - } |
|
| 447 | + if ( null !== $entity ) { |
|
| 448 | + array_push( $entities, $entity->ID ); |
|
| 449 | + } |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | - // $count = sizeof( $entities ); |
|
| 453 | - // wl_write_log( "Found $count entities embedded in content" ); |
|
| 452 | + // $count = sizeof( $entities ); |
|
| 453 | + // wl_write_log( "Found $count entities embedded in content" ); |
|
| 454 | 454 | |
| 455 | - return $entities; |
|
| 455 | + return $entities; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -464,22 +464,22 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | function wl_linked_data_push_to_redlink( $post_id ) { |
| 466 | 466 | |
| 467 | - // Get the post. |
|
| 468 | - $post = get_post( $post_id ); |
|
| 467 | + // Get the post. |
|
| 468 | + $post = get_post( $post_id ); |
|
| 469 | 469 | |
| 470 | - // wl_write_log( "wl_linked_data_push_to_redlink [ post id :: $post_id ][ post type :: $post->post_type ]" ); |
|
| 470 | + // wl_write_log( "wl_linked_data_push_to_redlink [ post id :: $post_id ][ post type :: $post->post_type ]" ); |
|
| 471 | 471 | |
| 472 | - // Call the method on behalf of the post type. |
|
| 473 | - switch ( $post->post_type ) { |
|
| 474 | - case 'entity': |
|
| 475 | - wl_push_entity_post_to_redlink( $post ); |
|
| 476 | - break; |
|
| 477 | - default: |
|
| 478 | - wl_push_post_to_redlink( $post ); |
|
| 479 | - } |
|
| 472 | + // Call the method on behalf of the post type. |
|
| 473 | + switch ( $post->post_type ) { |
|
| 474 | + case 'entity': |
|
| 475 | + wl_push_entity_post_to_redlink( $post ); |
|
| 476 | + break; |
|
| 477 | + default: |
|
| 478 | + wl_push_post_to_redlink( $post ); |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | - // Reindex the triple store if buffering is turned off. |
|
| 482 | - if ( false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) { |
|
| 483 | - wordlift_reindex_triple_store(); |
|
| 484 | - } |
|
| 481 | + // Reindex the triple store if buffering is turned off. |
|
| 482 | + if ( false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) { |
|
| 483 | + wordlift_reindex_triple_store(); |
|
| 484 | + } |
|
| 485 | 485 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * The Linked Data module provides synchronization of local WordPress data with the remote Linked Data store. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -require_once( 'wordlift_linked_data_images.php' ); |
|
| 6 | +require_once('wordlift_linked_data_images.php'); |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Receive events from post saves, and split them according to the post type. |
@@ -12,24 +12,24 @@ discard block |
||
| 12 | 12 | * |
| 13 | 13 | * @param int $post_id The post id. |
| 14 | 14 | */ |
| 15 | -function wl_linked_data_save_post( $post_id ) { |
|
| 15 | +function wl_linked_data_save_post($post_id) { |
|
| 16 | 16 | |
| 17 | 17 | // If it's not numeric exit from here. |
| 18 | - if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) { |
|
| 18 | + if ( ! is_numeric($post_id) || is_numeric(wp_is_post_revision($post_id))) { |
|
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // unhook this function so it doesn't loop infinitely |
| 23 | - remove_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 23 | + remove_action('save_post', 'wl_linked_data_save_post'); |
|
| 24 | 24 | |
| 25 | 25 | // raise the *wl_linked_data_save_post* event. |
| 26 | - do_action( 'wl_linked_data_save_post', $post_id ); |
|
| 26 | + do_action('wl_linked_data_save_post', $post_id); |
|
| 27 | 27 | |
| 28 | 28 | // re-hook this function |
| 29 | - add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 29 | + add_action('save_post', 'wl_linked_data_save_post'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -add_action( 'save_post', 'wl_linked_data_save_post' ); |
|
| 32 | +add_action('save_post', 'wl_linked_data_save_post'); |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Save the post to the triple store. Also saves the entities locally and on the triple store. |
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param int $post_id The post id being saved. |
| 40 | 40 | */ |
| 41 | -function wl_linked_data_save_post_and_related_entities( $post_id ) { |
|
| 41 | +function wl_linked_data_save_post_and_related_entities($post_id) { |
|
| 42 | 42 | |
| 43 | 43 | // Ignore auto-saves |
| 44 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 44 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 45 | 45 | return; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // get the current post. |
| 49 | - $post = get_post( $post_id ); |
|
| 49 | + $post = get_post($post_id); |
|
| 50 | 50 | |
| 51 | - remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 51 | + remove_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities'); |
|
| 52 | 52 | |
| 53 | 53 | // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" ); |
| 54 | 54 | |
@@ -56,44 +56,44 @@ discard block |
||
| 56 | 56 | $entities_uri_mapping = array(); |
| 57 | 57 | |
| 58 | 58 | // Save the entities coming with POST data. |
| 59 | - if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) { |
|
| 59 | + if (isset($_POST['wl_entities']) && isset($_POST['wl_boxes'])) { |
|
| 60 | 60 | |
| 61 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " ); |
|
| 62 | - wl_write_log( json_encode( $_POST['wl_entities'] ) ); |
|
| 63 | - wl_write_log( "]" ); |
|
| 64 | - wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " ); |
|
| 65 | - wl_write_log( json_encode( $_POST['wl_boxes'], true ) ); |
|
| 66 | - wl_write_log( "]" ); |
|
| 61 | + wl_write_log("[ post id :: $post_id ][ POST(wl_entities) :: "); |
|
| 62 | + wl_write_log(json_encode($_POST['wl_entities'])); |
|
| 63 | + wl_write_log("]"); |
|
| 64 | + wl_write_log("[ post id :: $post_id ][ POST(wl_boxes) :: "); |
|
| 65 | + wl_write_log(json_encode($_POST['wl_boxes'], true)); |
|
| 66 | + wl_write_log("]"); |
|
| 67 | 67 | |
| 68 | 68 | $entities_via_post = $_POST['wl_entities']; |
| 69 | 69 | $boxes_via_post = $_POST['wl_boxes']; |
| 70 | 70 | |
| 71 | - foreach ( $entities_via_post as $entity_uri => $entity ) { |
|
| 71 | + foreach ($entities_via_post as $entity_uri => $entity) { |
|
| 72 | 72 | |
| 73 | 73 | // Only if the current entity is created from scratch let's avoid to |
| 74 | 74 | // create more than one entity with same label & entity type. |
| 75 | - $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ? |
|
| 75 | + $entity_type = (preg_match('/^local-entity-.+/', $entity_uri) > 0) ? |
|
| 76 | 76 | $entity['main_type'] : null; |
| 77 | 77 | |
| 78 | 78 | // Look if current entity uri matches an internal existing entity, meaning: |
| 79 | 79 | // 1. when $entity_uri is an internal uri |
| 80 | 80 | // 2. when $entity_uri is an external uri used as sameAs of an internal entity |
| 81 | - $ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $entity_uri ); |
|
| 81 | + $ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($entity_uri); |
|
| 82 | 82 | |
| 83 | 83 | // Detect the uri depending if is an existing or a new entity |
| 84 | - $uri = ( null === $ie ) ? |
|
| 84 | + $uri = (null === $ie) ? |
|
| 85 | 85 | Wordlift_Uri_Service::get_instance()->build_uri( |
| 86 | 86 | $entity['label'], |
| 87 | 87 | Wordlift_Entity_Service::TYPE_NAME, |
| 88 | 88 | $entity_type |
| 89 | - ) : wl_get_entity_uri( $ie->ID ); |
|
| 89 | + ) : wl_get_entity_uri($ie->ID); |
|
| 90 | 90 | |
| 91 | - wl_write_log( "Map $entity_uri on $uri" ); |
|
| 92 | - $entities_uri_mapping[ $entity_uri ] = $uri; |
|
| 91 | + wl_write_log("Map $entity_uri on $uri"); |
|
| 92 | + $entities_uri_mapping[$entity_uri] = $uri; |
|
| 93 | 93 | |
| 94 | 94 | // Local entities have a tmp uri with 'local-entity-' prefix |
| 95 | 95 | // These uris need to be rewritten here and replaced in the content |
| 96 | - if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) { |
|
| 96 | + if (preg_match('/^local-entity-.+/', $entity_uri) > 0) { |
|
| 97 | 97 | // Override the entity obj |
| 98 | 98 | $entity['uri'] = $uri; |
| 99 | 99 | } |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | $entity['related_post_id'] = $post_id; |
| 103 | 103 | |
| 104 | 104 | // Save the entity if is a new entity |
| 105 | - if ( null === $ie ) { |
|
| 106 | - wl_save_entity( $entity ); |
|
| 105 | + if (null === $ie) { |
|
| 106 | + wl_save_entity($entity); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | } |
@@ -113,36 +113,36 @@ discard block |
||
| 113 | 113 | // Replace tmp uris in content post if needed |
| 114 | 114 | $updated_post_content = $post->post_content; |
| 115 | 115 | // Save each entity and store the post id. |
| 116 | - foreach ( $entities_uri_mapping as $tmp_uri => $uri ) { |
|
| 117 | - $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content ); |
|
| 116 | + foreach ($entities_uri_mapping as $tmp_uri => $uri) { |
|
| 117 | + $updated_post_content = str_replace($tmp_uri, $uri, $updated_post_content); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Update the post content |
| 121 | - wp_update_post( array( |
|
| 121 | + wp_update_post(array( |
|
| 122 | 122 | 'ID' => $post->ID, |
| 123 | 123 | 'post_content' => $updated_post_content, |
| 124 | - ) ); |
|
| 124 | + )); |
|
| 125 | 125 | |
| 126 | 126 | // Extract related/referenced entities from text. |
| 127 | - $disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content ); |
|
| 127 | + $disambiguated_entities = wl_linked_data_content_get_embedded_entities($updated_post_content); |
|
| 128 | 128 | |
| 129 | 129 | // Reset previously saved instances |
| 130 | - wl_core_delete_relation_instances( $post_id ); |
|
| 130 | + wl_core_delete_relation_instances($post_id); |
|
| 131 | 131 | |
| 132 | 132 | // Save relation instances |
| 133 | - foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) { |
|
| 133 | + foreach (array_unique($disambiguated_entities) as $referenced_entity_id) { |
|
| 134 | 134 | |
| 135 | 135 | wl_core_add_relation_instance( |
| 136 | 136 | $post_id, |
| 137 | - Wordlift_Entity_Service::get_instance()->get_classification_scope_for( $referenced_entity_id ), |
|
| 137 | + Wordlift_Entity_Service::get_instance()->get_classification_scope_for($referenced_entity_id), |
|
| 138 | 138 | $referenced_entity_id |
| 139 | 139 | ); |
| 140 | 140 | |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if ( isset( $_POST['wl_entities'] ) ) { |
|
| 143 | + if (isset($_POST['wl_entities'])) { |
|
| 144 | 144 | // Save post metadata if available |
| 145 | - $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ? |
|
| 145 | + $metadata_via_post = (isset($_POST['wl_metadata'])) ? |
|
| 146 | 146 | $_POST['wl_metadata'] : array(); |
| 147 | 147 | |
| 148 | 148 | $fields = array( |
@@ -151,61 +151,61 @@ discard block |
||
| 151 | 151 | ); |
| 152 | 152 | |
| 153 | 153 | // Unlink topic taxonomy terms |
| 154 | - Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID ); |
|
| 154 | + Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for($post->ID); |
|
| 155 | 155 | |
| 156 | - foreach ( $fields as $field ) { |
|
| 156 | + foreach ($fields as $field) { |
|
| 157 | 157 | |
| 158 | 158 | // Delete current values |
| 159 | - delete_post_meta( $post->ID, $field ); |
|
| 159 | + delete_post_meta($post->ID, $field); |
|
| 160 | 160 | // Retrieve the entity uri |
| 161 | - $uri = ( isset( $metadata_via_post[ $field ] ) ) ? |
|
| 162 | - stripslashes( $metadata_via_post[ $field ] ) : ''; |
|
| 161 | + $uri = (isset($metadata_via_post[$field])) ? |
|
| 162 | + stripslashes($metadata_via_post[$field]) : ''; |
|
| 163 | 163 | |
| 164 | - $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ); |
|
| 164 | + $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri); |
|
| 165 | 165 | |
| 166 | - if ( $entity ) { |
|
| 167 | - add_post_meta( $post->ID, $field, $entity->ID, true ); |
|
| 166 | + if ($entity) { |
|
| 167 | + add_post_meta($post->ID, $field, $entity->ID, true); |
|
| 168 | 168 | // Set also the topic taxonomy |
| 169 | - if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) { |
|
| 170 | - Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity ); |
|
| 169 | + if ($field === Wordlift_Schema_Service::FIELD_TOPIC) { |
|
| 170 | + Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for($post->ID, $entity); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // Push the post to Redlink. |
| 177 | - wl_linked_data_push_to_redlink( $post->ID ); |
|
| 177 | + wl_linked_data_push_to_redlink($post->ID); |
|
| 178 | 178 | |
| 179 | - add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 179 | + add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities'); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | -add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' ); |
|
| 182 | +add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities'); |
|
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | 185 | * Adds default schema type "Thing" as soon as an entity is created. |
| 186 | 186 | */ |
| 187 | -function wordlift_save_post_add_default_schema_type( $entity_id ) { |
|
| 187 | +function wordlift_save_post_add_default_schema_type($entity_id) { |
|
| 188 | 188 | |
| 189 | - $entity = get_post( $entity_id ); |
|
| 189 | + $entity = get_post($entity_id); |
|
| 190 | 190 | |
| 191 | 191 | // Avoid doing anything if post is autosave or a revision. |
| 192 | 192 | |
| 193 | - if ( wp_is_post_autosave( $entity ) || wp_is_post_revision( $entity ) ) { |
|
| 193 | + if (wp_is_post_autosave($entity) || wp_is_post_revision($entity)) { |
|
| 194 | 194 | return; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - $entity_type = wl_schema_get_types( $entity_id ); |
|
| 197 | + $entity_type = wl_schema_get_types($entity_id); |
|
| 198 | 198 | |
| 199 | 199 | // Assign type 'Thing' if we are dealing with an entity without type |
| 200 | - if ( $entity->post_type == Wordlift_Entity_Service::TYPE_NAME && is_null( $entity_type ) ) { |
|
| 201 | - wl_schema_set_types( $entity_id, 'Thing' ); |
|
| 200 | + if ($entity->post_type == Wordlift_Entity_Service::TYPE_NAME && is_null($entity_type)) { |
|
| 201 | + wl_schema_set_types($entity_id, 'Thing'); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // Priority 1 (default is 10) because we want the default type to be set as soon as possible |
| 207 | 207 | // Attatched to save_post because *wl_linked_data_save_post* does not always fire |
| 208 | -add_action( 'save_post', 'wordlift_save_post_add_default_schema_type', 1 ); |
|
| 208 | +add_action('save_post', 'wordlift_save_post_add_default_schema_type', 1); |
|
| 209 | 209 | |
| 210 | 210 | /** |
| 211 | 211 | * Save the specified data as an entity in WordPress. This method only create new entities. When an existing entity is |
@@ -223,29 +223,29 @@ discard block |
||
| 223 | 223 | * |
| 224 | 224 | * @return null|WP_Post A post instance or null in case of failure. |
| 225 | 225 | */ |
| 226 | -function wl_save_entity( $entity_data ) { |
|
| 226 | +function wl_save_entity($entity_data) { |
|
| 227 | 227 | |
| 228 | 228 | $uri = $entity_data['uri']; |
| 229 | 229 | $label = $entity_data['label']; |
| 230 | 230 | $type_uri = $entity_data['main_type']; |
| 231 | - $entity_types = isset( $entity_data['type'] ) ? $entity_data['type'] : array(); |
|
| 231 | + $entity_types = isset($entity_data['type']) ? $entity_data['type'] : array(); |
|
| 232 | 232 | $description = $entity_data['description']; |
| 233 | - $images = isset( $entity_data['image'] ) ? wl_force_to_array( $entity_data['image'] ) : array(); |
|
| 234 | - $same_as = isset( $entity_data['sameas'] ) ? wl_force_to_array( $entity_data['sameas'] ) : array(); |
|
| 235 | - $related_post_id = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null; |
|
| 236 | - $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array(); |
|
| 233 | + $images = isset($entity_data['image']) ? wl_force_to_array($entity_data['image']) : array(); |
|
| 234 | + $same_as = isset($entity_data['sameas']) ? wl_force_to_array($entity_data['sameas']) : array(); |
|
| 235 | + $related_post_id = isset($entity_data['related_post_id']) ? $entity_data['related_post_id'] : null; |
|
| 236 | + $other_properties = isset($entity_data['properties']) ? $entity_data['properties'] : array(); |
|
| 237 | 237 | |
| 238 | 238 | // Get the synonyms. |
| 239 | - $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array(); |
|
| 239 | + $synonyms = isset($entity_data['synonym']) ? $entity_data['synonym'] : array(); |
|
| 240 | 240 | |
| 241 | 241 | // Check whether an entity already exists with the provided URI. |
| 242 | - if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) { |
|
| 242 | + if (null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri)) { |
|
| 243 | 243 | return $post; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | // Prepare properties of the new entity. |
| 247 | 247 | $params = array( |
| 248 | - 'post_status' => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ), |
|
| 248 | + 'post_status' => (is_numeric($related_post_id) ? get_post_status($related_post_id) : 'draft'), |
|
| 249 | 249 | 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
| 250 | 250 | 'post_title' => $label, |
| 251 | 251 | 'post_content' => $description, |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | // new entities. |
| 256 | 256 | // |
| 257 | 257 | // See https://github.com/insideout10/wordlift-plugin/issues/282 |
| 258 | - 'post_name' => sanitize_title( $label ), |
|
| 258 | + 'post_name' => sanitize_title($label), |
|
| 259 | 259 | ); |
| 260 | 260 | |
| 261 | 261 | // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over" |
@@ -264,18 +264,18 @@ discard block |
||
| 264 | 264 | // This does NOT affect saving an entity from the entity admin page since this function is called when an entity |
| 265 | 265 | // is created when saving a post. |
| 266 | 266 | global $wpseo_metabox, $seo_ultimate; |
| 267 | - if ( isset( $wpseo_metabox ) ) { |
|
| 268 | - remove_action( 'wp_insert_post', array( |
|
| 267 | + if (isset($wpseo_metabox)) { |
|
| 268 | + remove_action('wp_insert_post', array( |
|
| 269 | 269 | $wpseo_metabox, |
| 270 | 270 | 'save_postdata', |
| 271 | - ) ); |
|
| 271 | + )); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if ( isset( $seo_ultimate ) ) { |
|
| 275 | - remove_action( 'save_post', array( |
|
| 274 | + if (isset($seo_ultimate)) { |
|
| 275 | + remove_action('save_post', array( |
|
| 276 | 276 | $seo_ultimate, |
| 277 | 277 | 'save_postmeta_box', |
| 278 | - ) ); |
|
| 278 | + )); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to |
@@ -285,90 +285,90 @@ discard block |
||
| 285 | 285 | // see https://github.com/insideout10/wordlift-plugin/issues/156 |
| 286 | 286 | // see https://github.com/insideout10/wordlift-plugin/issues/148 |
| 287 | 287 | global $wp_filter; |
| 288 | - $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 289 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 288 | + $save_post_filters = is_array($wp_filter['save_post']) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks; |
|
| 289 | + is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters(); |
|
| 290 | 290 | |
| 291 | 291 | // create or update the post. |
| 292 | - $post_id = wp_insert_post( $params, true ); |
|
| 292 | + $post_id = wp_insert_post($params, true); |
|
| 293 | 293 | |
| 294 | 294 | // Setting the alternative labels for this entity. |
| 295 | 295 | Wordlift_Entity_Service::get_instance() |
| 296 | - ->set_alternative_labels( $post_id, $synonyms ); |
|
| 296 | + ->set_alternative_labels($post_id, $synonyms); |
|
| 297 | 297 | |
| 298 | 298 | // Restore all the existing filters. |
| 299 | - is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 299 | + is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters; |
|
| 300 | 300 | |
| 301 | 301 | // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156) |
| 302 | - if ( isset( $wpseo_metabox ) ) { |
|
| 303 | - add_action( 'wp_insert_post', array( |
|
| 302 | + if (isset($wpseo_metabox)) { |
|
| 303 | + add_action('wp_insert_post', array( |
|
| 304 | 304 | $wpseo_metabox, |
| 305 | 305 | 'save_postdata', |
| 306 | - ) ); |
|
| 306 | + )); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | // If SEO Ultimate is installed, add back the hook we removed a few lines above. |
| 310 | - if ( isset( $seo_ultimate ) ) { |
|
| 311 | - add_action( 'save_post', array( |
|
| 310 | + if (isset($seo_ultimate)) { |
|
| 311 | + add_action('save_post', array( |
|
| 312 | 312 | $seo_ultimate, |
| 313 | 313 | 'save_postmeta_box', |
| 314 | - ), 10, 2 ); |
|
| 314 | + ), 10, 2); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | // TODO: handle errors. |
| 318 | - if ( is_wp_error( $post_id ) ) { |
|
| 319 | - wl_write_log( ': error occurred' ); |
|
| 318 | + if (is_wp_error($post_id)) { |
|
| 319 | + wl_write_log(': error occurred'); |
|
| 320 | 320 | |
| 321 | 321 | // inform an error occurred. |
| 322 | 322 | return null; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - wl_set_entity_main_type( $post_id, $type_uri ); |
|
| 325 | + wl_set_entity_main_type($post_id, $type_uri); |
|
| 326 | 326 | |
| 327 | 327 | // Save the entity types. |
| 328 | - wl_set_entity_rdf_types( $post_id, $entity_types ); |
|
| 328 | + wl_set_entity_rdf_types($post_id, $entity_types); |
|
| 329 | 329 | |
| 330 | 330 | // Get a dataset URI for the entity. |
| 331 | - $wl_uri = wl_build_entity_uri( $post_id ); |
|
| 331 | + $wl_uri = wl_build_entity_uri($post_id); |
|
| 332 | 332 | |
| 333 | 333 | // Save the entity URI. |
| 334 | - wl_set_entity_uri( $post_id, $wl_uri ); |
|
| 334 | + wl_set_entity_uri($post_id, $wl_uri); |
|
| 335 | 335 | |
| 336 | 336 | // Add the uri to the sameAs data if it's not a local URI. |
| 337 | - if ( $wl_uri !== $uri ) { |
|
| 338 | - array_push( $same_as, $uri ); |
|
| 337 | + if ($wl_uri !== $uri) { |
|
| 338 | + array_push($same_as, $uri); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - $new_uri = wl_get_entity_uri( $post_id ); |
|
| 341 | + $new_uri = wl_get_entity_uri($post_id); |
|
| 342 | 342 | |
| 343 | 343 | // Save the sameAs data for the entity. |
| 344 | - wl_schema_set_value( $post_id, 'sameAs', $same_as ); |
|
| 344 | + wl_schema_set_value($post_id, 'sameAs', $same_as); |
|
| 345 | 345 | |
| 346 | 346 | // Save the other properties (latitude, langitude, startDate, endDate, etc.) |
| 347 | - foreach ( $other_properties as $property_name => $property_value ) { |
|
| 348 | - wl_schema_set_value( $post_id, $property_name, $property_value ); |
|
| 347 | + foreach ($other_properties as $property_name => $property_value) { |
|
| 348 | + wl_schema_set_value($post_id, $property_name, $property_value); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // Call hooks. |
| 352 | - do_action( 'wl_save_entity', $post_id ); |
|
| 352 | + do_action('wl_save_entity', $post_id); |
|
| 353 | 353 | |
| 354 | - foreach ( $images as $image_remote_url ) { |
|
| 354 | + foreach ($images as $image_remote_url) { |
|
| 355 | 355 | |
| 356 | 356 | // Check if image is already present in local DB |
| 357 | - if ( strpos( $image_remote_url, site_url() ) !== false ) { |
|
| 357 | + if (strpos($image_remote_url, site_url()) !== false) { |
|
| 358 | 358 | // Do nothing. |
| 359 | 359 | continue; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | // Check if there is an existing attachment for this post ID and source URL. |
| 363 | - $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url ); |
|
| 363 | + $existing_image = wl_get_attachment_for_source_url($post_id, $image_remote_url); |
|
| 364 | 364 | |
| 365 | 365 | // Skip if an existing image is found. |
| 366 | - if ( null !== $existing_image ) { |
|
| 366 | + if (null !== $existing_image) { |
|
| 367 | 367 | continue; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | // Save the image and get the local path. |
| 371 | - $image = wl_save_image( $image_remote_url ); |
|
| 371 | + $image = wl_save_image($image_remote_url); |
|
| 372 | 372 | |
| 373 | 373 | // Get the local URL. |
| 374 | 374 | $filename = $image['path']; |
@@ -386,24 +386,24 @@ discard block |
||
| 386 | 386 | ); |
| 387 | 387 | |
| 388 | 388 | // Create the attachment in WordPress and generate the related metadata. |
| 389 | - $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id ); |
|
| 389 | + $attachment_id = wp_insert_attachment($attachment, $filename, $post_id); |
|
| 390 | 390 | |
| 391 | 391 | // Set the source URL for the image. |
| 392 | - wl_set_source_url( $attachment_id, $image_remote_url ); |
|
| 392 | + wl_set_source_url($attachment_id, $image_remote_url); |
|
| 393 | 393 | |
| 394 | - $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
| 395 | - wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
| 394 | + $attachment_data = wp_generate_attachment_metadata($attachment_id, $filename); |
|
| 395 | + wp_update_attachment_metadata($attachment_id, $attachment_data); |
|
| 396 | 396 | |
| 397 | 397 | // Set it as the featured image. |
| 398 | - set_post_thumbnail( $post_id, $attachment_id ); |
|
| 398 | + set_post_thumbnail($post_id, $attachment_id); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | // The entity is pushed to Redlink on save by the function hooked to save_post. |
| 402 | 402 | // save the entity in the triple store. |
| 403 | - wl_linked_data_push_to_redlink( $post_id ); |
|
| 403 | + wl_linked_data_push_to_redlink($post_id); |
|
| 404 | 404 | |
| 405 | 405 | // finally return the entity post. |
| 406 | - return get_post( $post_id ); |
|
| 406 | + return get_post($post_id); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -415,10 +415,10 @@ discard block |
||
| 415 | 415 | * |
| 416 | 416 | * @return array An array of entity posts. |
| 417 | 417 | */ |
| 418 | -function wl_linked_data_content_get_embedded_entities( $content ) { |
|
| 418 | +function wl_linked_data_content_get_embedded_entities($content) { |
|
| 419 | 419 | |
| 420 | 420 | // Remove quote escapes. |
| 421 | - $content = str_replace( '\\"', '"', $content ); |
|
| 421 | + $content = str_replace('\\"', '"', $content); |
|
| 422 | 422 | |
| 423 | 423 | // Match all itemid attributes. |
| 424 | 424 | $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im'; |
@@ -429,8 +429,8 @@ discard block |
||
| 429 | 429 | $matches = array(); |
| 430 | 430 | |
| 431 | 431 | // In case of errors, return an empty array. |
| 432 | - if ( false === preg_match_all( $pattern, $content, $matches ) ) { |
|
| 433 | - wl_write_log( "Found no entities embedded in content" ); |
|
| 432 | + if (false === preg_match_all($pattern, $content, $matches)) { |
|
| 433 | + wl_write_log("Found no entities embedded in content"); |
|
| 434 | 434 | |
| 435 | 435 | return array(); |
| 436 | 436 | } |
@@ -439,13 +439,13 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | // Collect the entities. |
| 441 | 441 | $entities = array(); |
| 442 | - foreach ( $matches[1] as $uri ) { |
|
| 443 | - $uri_d = html_entity_decode( $uri ); |
|
| 442 | + foreach ($matches[1] as $uri) { |
|
| 443 | + $uri_d = html_entity_decode($uri); |
|
| 444 | 444 | |
| 445 | - $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d ); |
|
| 445 | + $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri_d); |
|
| 446 | 446 | |
| 447 | - if ( null !== $entity ) { |
|
| 448 | - array_push( $entities, $entity->ID ); |
|
| 447 | + if (null !== $entity) { |
|
| 448 | + array_push($entities, $entity->ID); |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | |
@@ -462,24 +462,24 @@ discard block |
||
| 462 | 462 | * |
| 463 | 463 | * @param int $post_id The post ID. |
| 464 | 464 | */ |
| 465 | -function wl_linked_data_push_to_redlink( $post_id ) { |
|
| 465 | +function wl_linked_data_push_to_redlink($post_id) { |
|
| 466 | 466 | |
| 467 | 467 | // Get the post. |
| 468 | - $post = get_post( $post_id ); |
|
| 468 | + $post = get_post($post_id); |
|
| 469 | 469 | |
| 470 | 470 | // wl_write_log( "wl_linked_data_push_to_redlink [ post id :: $post_id ][ post type :: $post->post_type ]" ); |
| 471 | 471 | |
| 472 | 472 | // Call the method on behalf of the post type. |
| 473 | - switch ( $post->post_type ) { |
|
| 473 | + switch ($post->post_type) { |
|
| 474 | 474 | case 'entity': |
| 475 | - wl_push_entity_post_to_redlink( $post ); |
|
| 475 | + wl_push_entity_post_to_redlink($post); |
|
| 476 | 476 | break; |
| 477 | 477 | default: |
| 478 | - wl_push_post_to_redlink( $post ); |
|
| 478 | + wl_push_post_to_redlink($post); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | // Reindex the triple store if buffering is turned off. |
| 482 | - if ( false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) { |
|
| 482 | + if (false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING) { |
|
| 483 | 483 | wordlift_reindex_triple_store(); |
| 484 | 484 | } |
| 485 | 485 | } |