@@ -58,137 +58,137 @@ |
||
| 58 | 58 | // return sizeof( $results ); |
| 59 | 59 | // } |
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * The {@link Wordlift_Entity_Service} instance. |
|
| 63 | - * |
|
| 64 | - * @since 3.12.2 |
|
| 65 | - * @access private |
|
| 66 | - * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 67 | - */ |
|
| 68 | - private $entity_service; |
|
| 69 | - /** |
|
| 70 | - * @var |
|
| 71 | - */ |
|
| 72 | - private $sparql_service; |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Create a {@link Wordlift_Admin_Status_Page} instance. |
|
| 76 | - * |
|
| 77 | - * @since 3.12.2 |
|
| 78 | - * |
|
| 79 | - * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 80 | - * @param \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance. |
|
| 81 | - */ |
|
| 82 | - public function __construct( $entity_service, $sparql_service ) { |
|
| 83 | - |
|
| 84 | - $this->entity_service = $entity_service; |
|
| 85 | - $this->sparql_service = $sparql_service; |
|
| 86 | - |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Get the list of entity URIs. |
|
| 91 | - * |
|
| 92 | - * @since 3.12.2 |
|
| 93 | - * @return array An array of entity URIs. |
|
| 94 | - */ |
|
| 95 | - protected function get_entity_uris() { |
|
| 96 | - |
|
| 97 | - // Get the entity IDs. |
|
| 98 | - $ids = $this->entity_service->get( array( |
|
| 99 | - 'numberposts' => - 1, |
|
| 100 | - 'fields' => 'ids', |
|
| 101 | - 'post_status' => 'publish', |
|
| 102 | - ) ); |
|
| 103 | - |
|
| 104 | - // Create a reference to the entity service for the closure. |
|
| 105 | - $entity_service = $this->entity_service; |
|
| 106 | - |
|
| 107 | - // Combine IDs with URIs. |
|
| 108 | - return array_combine( $ids, array_map( function ( $item ) use ( $entity_service ) { |
|
| 109 | - return $entity_service->get_uri( $item ); |
|
| 110 | - }, $ids ) ); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Get the list of URIs in the Linked Data Cloud. |
|
| 115 | - * |
|
| 116 | - * @since 3.12.2 |
|
| 117 | - * @return array|null An array of URIs. |
|
| 118 | - */ |
|
| 119 | - protected function get_linked_data_uris() { |
|
| 120 | - |
|
| 121 | - // Prepare the query to get the URIs from the Linked Data Cloud. |
|
| 122 | - $query = Wordlift_Query_Builder::new_instance() |
|
| 123 | - ->select( 'DISTINCT ?s' ) |
|
| 124 | - ->statement( '?s', Wordlift_Query_Builder::RDFS_TYPE_URI, '?o' ) |
|
| 125 | - ->build(); |
|
| 126 | - |
|
| 127 | - // Execute the query. |
|
| 128 | - $response = $this->sparql_service->select( $query ); |
|
| 129 | - |
|
| 130 | - // If the response is an error, return null. |
|
| 131 | - if ( is_a( $response, 'WP_Error' ) ) { |
|
| 132 | - return null; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // Split the response into single URIs. |
|
| 136 | - $uris = preg_split( "/(\r\n|\n|\r)/", $response['body'] ); |
|
| 137 | - |
|
| 138 | - // Remove the header. |
|
| 139 | - unset( $uris[0] ); |
|
| 140 | - |
|
| 141 | - // Finally return the URIs. |
|
| 142 | - return $uris; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Get the page title. Will be translated. |
|
| 147 | - * |
|
| 148 | - * @since 3.11.0 |
|
| 149 | - * |
|
| 150 | - * @return string The page title. |
|
| 151 | - */ |
|
| 152 | - function get_page_title() { |
|
| 153 | - |
|
| 154 | - return _x( 'Status Report', 'Page title', 'wordlift' ); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Get the menu title. Will be translated. |
|
| 159 | - * |
|
| 160 | - * @since 3.11.0 |
|
| 161 | - * |
|
| 162 | - * @return string The menu title. |
|
| 163 | - */ |
|
| 164 | - function get_menu_title() { |
|
| 165 | - |
|
| 166 | - return _x( 'Status Report', 'Menu title', 'wordlift' ); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * Get the menu slug. |
|
| 171 | - * |
|
| 172 | - * @since 3.11.0 |
|
| 173 | - * |
|
| 174 | - * @return string The menu slug. |
|
| 175 | - */ |
|
| 176 | - function get_menu_slug() { |
|
| 177 | - |
|
| 178 | - return 'wl_status_report'; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * Get the partial file name, used in the {@link render} function. |
|
| 183 | - * |
|
| 184 | - * @since 3.11.0 |
|
| 185 | - * |
|
| 186 | - * @return string The partial file name. |
|
| 187 | - */ |
|
| 188 | - function get_partial_name() { |
|
| 189 | - |
|
| 190 | - |
|
| 191 | - return 'wordlift-admin-status-page.php'; |
|
| 192 | - } |
|
| 61 | + /** |
|
| 62 | + * The {@link Wordlift_Entity_Service} instance. |
|
| 63 | + * |
|
| 64 | + * @since 3.12.2 |
|
| 65 | + * @access private |
|
| 66 | + * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 67 | + */ |
|
| 68 | + private $entity_service; |
|
| 69 | + /** |
|
| 70 | + * @var |
|
| 71 | + */ |
|
| 72 | + private $sparql_service; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Create a {@link Wordlift_Admin_Status_Page} instance. |
|
| 76 | + * |
|
| 77 | + * @since 3.12.2 |
|
| 78 | + * |
|
| 79 | + * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 80 | + * @param \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance. |
|
| 81 | + */ |
|
| 82 | + public function __construct( $entity_service, $sparql_service ) { |
|
| 83 | + |
|
| 84 | + $this->entity_service = $entity_service; |
|
| 85 | + $this->sparql_service = $sparql_service; |
|
| 86 | + |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Get the list of entity URIs. |
|
| 91 | + * |
|
| 92 | + * @since 3.12.2 |
|
| 93 | + * @return array An array of entity URIs. |
|
| 94 | + */ |
|
| 95 | + protected function get_entity_uris() { |
|
| 96 | + |
|
| 97 | + // Get the entity IDs. |
|
| 98 | + $ids = $this->entity_service->get( array( |
|
| 99 | + 'numberposts' => - 1, |
|
| 100 | + 'fields' => 'ids', |
|
| 101 | + 'post_status' => 'publish', |
|
| 102 | + ) ); |
|
| 103 | + |
|
| 104 | + // Create a reference to the entity service for the closure. |
|
| 105 | + $entity_service = $this->entity_service; |
|
| 106 | + |
|
| 107 | + // Combine IDs with URIs. |
|
| 108 | + return array_combine( $ids, array_map( function ( $item ) use ( $entity_service ) { |
|
| 109 | + return $entity_service->get_uri( $item ); |
|
| 110 | + }, $ids ) ); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Get the list of URIs in the Linked Data Cloud. |
|
| 115 | + * |
|
| 116 | + * @since 3.12.2 |
|
| 117 | + * @return array|null An array of URIs. |
|
| 118 | + */ |
|
| 119 | + protected function get_linked_data_uris() { |
|
| 120 | + |
|
| 121 | + // Prepare the query to get the URIs from the Linked Data Cloud. |
|
| 122 | + $query = Wordlift_Query_Builder::new_instance() |
|
| 123 | + ->select( 'DISTINCT ?s' ) |
|
| 124 | + ->statement( '?s', Wordlift_Query_Builder::RDFS_TYPE_URI, '?o' ) |
|
| 125 | + ->build(); |
|
| 126 | + |
|
| 127 | + // Execute the query. |
|
| 128 | + $response = $this->sparql_service->select( $query ); |
|
| 129 | + |
|
| 130 | + // If the response is an error, return null. |
|
| 131 | + if ( is_a( $response, 'WP_Error' ) ) { |
|
| 132 | + return null; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // Split the response into single URIs. |
|
| 136 | + $uris = preg_split( "/(\r\n|\n|\r)/", $response['body'] ); |
|
| 137 | + |
|
| 138 | + // Remove the header. |
|
| 139 | + unset( $uris[0] ); |
|
| 140 | + |
|
| 141 | + // Finally return the URIs. |
|
| 142 | + return $uris; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Get the page title. Will be translated. |
|
| 147 | + * |
|
| 148 | + * @since 3.11.0 |
|
| 149 | + * |
|
| 150 | + * @return string The page title. |
|
| 151 | + */ |
|
| 152 | + function get_page_title() { |
|
| 153 | + |
|
| 154 | + return _x( 'Status Report', 'Page title', 'wordlift' ); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Get the menu title. Will be translated. |
|
| 159 | + * |
|
| 160 | + * @since 3.11.0 |
|
| 161 | + * |
|
| 162 | + * @return string The menu title. |
|
| 163 | + */ |
|
| 164 | + function get_menu_title() { |
|
| 165 | + |
|
| 166 | + return _x( 'Status Report', 'Menu title', 'wordlift' ); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * Get the menu slug. |
|
| 171 | + * |
|
| 172 | + * @since 3.11.0 |
|
| 173 | + * |
|
| 174 | + * @return string The menu slug. |
|
| 175 | + */ |
|
| 176 | + function get_menu_slug() { |
|
| 177 | + |
|
| 178 | + return 'wl_status_report'; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * Get the partial file name, used in the {@link render} function. |
|
| 183 | + * |
|
| 184 | + * @since 3.11.0 |
|
| 185 | + * |
|
| 186 | + * @return string The partial file name. |
|
| 187 | + */ |
|
| 188 | + function get_partial_name() { |
|
| 189 | + |
|
| 190 | + |
|
| 191 | + return 'wordlift-admin-status-page.php'; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
| 80 | 80 | * @param \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance. |
| 81 | 81 | */ |
| 82 | - public function __construct( $entity_service, $sparql_service ) { |
|
| 82 | + public function __construct($entity_service, $sparql_service) { |
|
| 83 | 83 | |
| 84 | 84 | $this->entity_service = $entity_service; |
| 85 | 85 | $this->sparql_service = $sparql_service; |
@@ -95,19 +95,19 @@ discard block |
||
| 95 | 95 | protected function get_entity_uris() { |
| 96 | 96 | |
| 97 | 97 | // Get the entity IDs. |
| 98 | - $ids = $this->entity_service->get( array( |
|
| 99 | - 'numberposts' => - 1, |
|
| 98 | + $ids = $this->entity_service->get(array( |
|
| 99 | + 'numberposts' => -1, |
|
| 100 | 100 | 'fields' => 'ids', |
| 101 | 101 | 'post_status' => 'publish', |
| 102 | - ) ); |
|
| 102 | + )); |
|
| 103 | 103 | |
| 104 | 104 | // Create a reference to the entity service for the closure. |
| 105 | 105 | $entity_service = $this->entity_service; |
| 106 | 106 | |
| 107 | 107 | // Combine IDs with URIs. |
| 108 | - return array_combine( $ids, array_map( function ( $item ) use ( $entity_service ) { |
|
| 109 | - return $entity_service->get_uri( $item ); |
|
| 110 | - }, $ids ) ); |
|
| 108 | + return array_combine($ids, array_map(function($item) use ($entity_service) { |
|
| 109 | + return $entity_service->get_uri($item); |
|
| 110 | + }, $ids)); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -120,23 +120,23 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | // Prepare the query to get the URIs from the Linked Data Cloud. |
| 122 | 122 | $query = Wordlift_Query_Builder::new_instance() |
| 123 | - ->select( 'DISTINCT ?s' ) |
|
| 124 | - ->statement( '?s', Wordlift_Query_Builder::RDFS_TYPE_URI, '?o' ) |
|
| 123 | + ->select('DISTINCT ?s') |
|
| 124 | + ->statement('?s', Wordlift_Query_Builder::RDFS_TYPE_URI, '?o') |
|
| 125 | 125 | ->build(); |
| 126 | 126 | |
| 127 | 127 | // Execute the query. |
| 128 | - $response = $this->sparql_service->select( $query ); |
|
| 128 | + $response = $this->sparql_service->select($query); |
|
| 129 | 129 | |
| 130 | 130 | // If the response is an error, return null. |
| 131 | - if ( is_a( $response, 'WP_Error' ) ) { |
|
| 131 | + if (is_a($response, 'WP_Error')) { |
|
| 132 | 132 | return null; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Split the response into single URIs. |
| 136 | - $uris = preg_split( "/(\r\n|\n|\r)/", $response['body'] ); |
|
| 136 | + $uris = preg_split("/(\r\n|\n|\r)/", $response['body']); |
|
| 137 | 137 | |
| 138 | 138 | // Remove the header. |
| 139 | - unset( $uris[0] ); |
|
| 139 | + unset($uris[0]); |
|
| 140 | 140 | |
| 141 | 141 | // Finally return the URIs. |
| 142 | 142 | return $uris; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | function get_page_title() { |
| 153 | 153 | |
| 154 | - return _x( 'Status Report', 'Page title', 'wordlift' ); |
|
| 154 | + return _x('Status Report', 'Page title', 'wordlift'); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | function get_menu_title() { |
| 165 | 165 | |
| 166 | - return _x( 'Status Report', 'Menu title', 'wordlift' ); |
|
| 166 | + return _x('Status Report', 'Menu title', 'wordlift'); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -14,9 +14,9 @@ |
||
| 14 | 14 | |
| 15 | 15 | if ( 0 < count( $not_found_uris ) ) { |
| 16 | 16 | |
| 17 | - $first_id = key( $not_found_uris ); |
|
| 18 | - // Re-push the entity to the Linked Data Cloud. |
|
| 19 | - wl_linked_data_push_to_redlink( $first_id ); |
|
| 17 | + $first_id = key( $not_found_uris ); |
|
| 18 | + // Re-push the entity to the Linked Data Cloud. |
|
| 19 | + wl_linked_data_push_to_redlink( $first_id ); |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | ?> |
@@ -10,30 +10,30 @@ |
||
| 10 | 10 | |
| 11 | 11 | $remote_uris = $this->get_linked_data_uris(); |
| 12 | 12 | |
| 13 | -$not_found_uris = array_diff( $local_uris, $remote_uris ); |
|
| 13 | +$not_found_uris = array_diff($local_uris, $remote_uris); |
|
| 14 | 14 | |
| 15 | -if ( 0 < count( $not_found_uris ) ) { |
|
| 15 | +if (0 < count($not_found_uris)) { |
|
| 16 | 16 | |
| 17 | - $first_id = key( $not_found_uris ); |
|
| 17 | + $first_id = key($not_found_uris); |
|
| 18 | 18 | // Re-push the entity to the Linked Data Cloud. |
| 19 | - wl_linked_data_push_to_redlink( $first_id ); |
|
| 19 | + wl_linked_data_push_to_redlink($first_id); |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | ?> |
| 23 | 23 | |
| 24 | 24 | <div class="wrap"> |
| 25 | - <h1><?php esc_html_e( 'Status Report', 'wordlift' ); ?></h1> |
|
| 25 | + <h1><?php esc_html_e('Status Report', 'wordlift'); ?></h1> |
|
| 26 | 26 | |
| 27 | - <p><?php echo esc_html( sprintf( __( '%d not found URIs; %d local entity URIs; %d remote URIs (including posts and authors).', 'wordlift' ), count( $not_found_uris ), count( $local_uris ), count( $remote_uris ) ) ); ?></p> |
|
| 27 | + <p><?php echo esc_html(sprintf(__('%d not found URIs; %d local entity URIs; %d remote URIs (including posts and authors).', 'wordlift'), count($not_found_uris), count($local_uris), count($remote_uris))); ?></p> |
|
| 28 | 28 | |
| 29 | 29 | <table class="wp-list-table widefat fixed striped posts"> |
| 30 | 30 | <thead> |
| 31 | - <th scope="col"><?php esc_html_e( 'URL', 'wordlift' ); ?></th> |
|
| 31 | + <th scope="col"><?php esc_html_e('URL', 'wordlift'); ?></th> |
|
| 32 | 32 | </thead> |
| 33 | 33 | <tbody> |
| 34 | - <?php foreach ( $not_found_uris as $id => $uri ) { ?> |
|
| 34 | + <?php foreach ($not_found_uris as $id => $uri) { ?> |
|
| 35 | 35 | <tr> |
| 36 | - <td><?php echo esc_html( $uri ); ?></td> |
|
| 36 | + <td><?php echo esc_html($uri); ?></td> |
|
| 37 | 37 | </tr> |
| 38 | 38 | <?php } ?> |
| 39 | 39 | </tbody> |
@@ -18,115 +18,115 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | abstract class Wordlift_Admin_Page { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Get the parent slug. |
|
| 23 | - * |
|
| 24 | - * @since 3.11.0 |
|
| 25 | - * |
|
| 26 | - * @return string The parent slug (default 'wl_admin_menu'). |
|
| 27 | - */ |
|
| 28 | - protected function get_parent_slug() { |
|
| 29 | - |
|
| 30 | - return 'wl_admin_menu'; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Get the required capability. |
|
| 35 | - * |
|
| 36 | - * @since 3.11.0 |
|
| 37 | - * |
|
| 38 | - * @return string The capability (default 'manage_options'). |
|
| 39 | - */ |
|
| 40 | - protected function get_capability() { |
|
| 41 | - |
|
| 42 | - return 'manage_options'; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Get the page title. Will be translated. |
|
| 47 | - * |
|
| 48 | - * @since 3.11.0 |
|
| 49 | - * |
|
| 50 | - * @return string The page title. |
|
| 51 | - */ |
|
| 52 | - abstract function get_page_title(); |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Get the menu title. Will be translated. |
|
| 56 | - * |
|
| 57 | - * @since 3.11.0 |
|
| 58 | - * |
|
| 59 | - * @return string The menu title. |
|
| 60 | - */ |
|
| 61 | - abstract function get_menu_title(); |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Get the menu slug. |
|
| 65 | - * |
|
| 66 | - * @since 3.11.0 |
|
| 67 | - * |
|
| 68 | - * @return string The menu slug. |
|
| 69 | - */ |
|
| 70 | - abstract function get_menu_slug(); |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Get the partial file name, used in the {@link render} function. |
|
| 74 | - * |
|
| 75 | - * @since 3.11.0 |
|
| 76 | - * |
|
| 77 | - * @return string The partial file name. |
|
| 78 | - */ |
|
| 79 | - abstract function get_partial_name(); |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * The `admin_menu` callback. Will call {@link add_submenu_page} to add the |
|
| 83 | - * page to the admin menu. |
|
| 84 | - * |
|
| 85 | - * @since 3.11.0 |
|
| 86 | - * |
|
| 87 | - * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
|
| 88 | - */ |
|
| 89 | - public function admin_menu() { |
|
| 90 | - |
|
| 91 | - // Add the sub-menu page. |
|
| 92 | - // |
|
| 93 | - // See http://codex.wordpress.org/Function_Reference/add_submenu_page |
|
| 94 | - $page = add_submenu_page( |
|
| 95 | - $this->get_parent_slug(), |
|
| 96 | - $this->get_page_title(), |
|
| 97 | - $this->get_menu_title(), |
|
| 98 | - $this->get_capability(), // The required capability, provided by the calling hook. |
|
| 99 | - $this->get_menu_slug(), |
|
| 100 | - array( $this, 'render' ) |
|
| 101 | - ); |
|
| 102 | - |
|
| 103 | - // Set a hook to enqueue scripts only when the settings page is displayed. |
|
| 104 | - add_action( 'admin_print_scripts-' . $page, array( |
|
| 105 | - $this, |
|
| 106 | - 'enqueue_scripts', |
|
| 107 | - ) ); |
|
| 108 | - |
|
| 109 | - // Finally return the page hook_suffix. |
|
| 110 | - return $page; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Enqueue scripts for the specific page. Subclasses can override this function |
|
| 115 | - * to provide their own styles/scripts. |
|
| 116 | - * |
|
| 117 | - * @since 3.11.0 |
|
| 118 | - */ |
|
| 119 | - public function enqueue_scripts() { |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Render the page. |
|
| 124 | - */ |
|
| 125 | - public function render() { |
|
| 126 | - |
|
| 127 | - // Include the partial. |
|
| 128 | - include( plugin_dir_path( __FILE__ ) . 'partials/' . $this->get_partial_name() ); |
|
| 129 | - |
|
| 130 | - } |
|
| 21 | + /** |
|
| 22 | + * Get the parent slug. |
|
| 23 | + * |
|
| 24 | + * @since 3.11.0 |
|
| 25 | + * |
|
| 26 | + * @return string The parent slug (default 'wl_admin_menu'). |
|
| 27 | + */ |
|
| 28 | + protected function get_parent_slug() { |
|
| 29 | + |
|
| 30 | + return 'wl_admin_menu'; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Get the required capability. |
|
| 35 | + * |
|
| 36 | + * @since 3.11.0 |
|
| 37 | + * |
|
| 38 | + * @return string The capability (default 'manage_options'). |
|
| 39 | + */ |
|
| 40 | + protected function get_capability() { |
|
| 41 | + |
|
| 42 | + return 'manage_options'; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Get the page title. Will be translated. |
|
| 47 | + * |
|
| 48 | + * @since 3.11.0 |
|
| 49 | + * |
|
| 50 | + * @return string The page title. |
|
| 51 | + */ |
|
| 52 | + abstract function get_page_title(); |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Get the menu title. Will be translated. |
|
| 56 | + * |
|
| 57 | + * @since 3.11.0 |
|
| 58 | + * |
|
| 59 | + * @return string The menu title. |
|
| 60 | + */ |
|
| 61 | + abstract function get_menu_title(); |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Get the menu slug. |
|
| 65 | + * |
|
| 66 | + * @since 3.11.0 |
|
| 67 | + * |
|
| 68 | + * @return string The menu slug. |
|
| 69 | + */ |
|
| 70 | + abstract function get_menu_slug(); |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Get the partial file name, used in the {@link render} function. |
|
| 74 | + * |
|
| 75 | + * @since 3.11.0 |
|
| 76 | + * |
|
| 77 | + * @return string The partial file name. |
|
| 78 | + */ |
|
| 79 | + abstract function get_partial_name(); |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * The `admin_menu` callback. Will call {@link add_submenu_page} to add the |
|
| 83 | + * page to the admin menu. |
|
| 84 | + * |
|
| 85 | + * @since 3.11.0 |
|
| 86 | + * |
|
| 87 | + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
|
| 88 | + */ |
|
| 89 | + public function admin_menu() { |
|
| 90 | + |
|
| 91 | + // Add the sub-menu page. |
|
| 92 | + // |
|
| 93 | + // See http://codex.wordpress.org/Function_Reference/add_submenu_page |
|
| 94 | + $page = add_submenu_page( |
|
| 95 | + $this->get_parent_slug(), |
|
| 96 | + $this->get_page_title(), |
|
| 97 | + $this->get_menu_title(), |
|
| 98 | + $this->get_capability(), // The required capability, provided by the calling hook. |
|
| 99 | + $this->get_menu_slug(), |
|
| 100 | + array( $this, 'render' ) |
|
| 101 | + ); |
|
| 102 | + |
|
| 103 | + // Set a hook to enqueue scripts only when the settings page is displayed. |
|
| 104 | + add_action( 'admin_print_scripts-' . $page, array( |
|
| 105 | + $this, |
|
| 106 | + 'enqueue_scripts', |
|
| 107 | + ) ); |
|
| 108 | + |
|
| 109 | + // Finally return the page hook_suffix. |
|
| 110 | + return $page; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Enqueue scripts for the specific page. Subclasses can override this function |
|
| 115 | + * to provide their own styles/scripts. |
|
| 116 | + * |
|
| 117 | + * @since 3.11.0 |
|
| 118 | + */ |
|
| 119 | + public function enqueue_scripts() { |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Render the page. |
|
| 124 | + */ |
|
| 125 | + public function render() { |
|
| 126 | + |
|
| 127 | + // Include the partial. |
|
| 128 | + include( plugin_dir_path( __FILE__ ) . 'partials/' . $this->get_partial_name() ); |
|
| 129 | + |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | 132 | } |
@@ -529,322 +529,322 @@ discard block |
||
| 529 | 529 | * The class responsible for orchestrating the actions and filters of the |
| 530 | 530 | * core plugin. |
| 531 | 531 | */ |
| 532 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 532 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php'; |
|
| 533 | 533 | |
| 534 | 534 | /** |
| 535 | 535 | * The class responsible for defining internationalization functionality |
| 536 | 536 | * of the plugin. |
| 537 | 537 | */ |
| 538 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 538 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php'; |
|
| 539 | 539 | |
| 540 | 540 | /** |
| 541 | 541 | * WordLift's supported languages. |
| 542 | 542 | */ |
| 543 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 543 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-languages.php'; |
|
| 544 | 544 | |
| 545 | 545 | /** |
| 546 | 546 | * Provide support functions to sanitize data. |
| 547 | 547 | */ |
| 548 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 548 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php'; |
|
| 549 | 549 | |
| 550 | 550 | /** |
| 551 | 551 | * The Redirect service. |
| 552 | 552 | */ |
| 553 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 553 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php'; |
|
| 554 | 554 | |
| 555 | 555 | /** |
| 556 | 556 | * The Log service. |
| 557 | 557 | */ |
| 558 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 558 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php'; |
|
| 559 | 559 | |
| 560 | 560 | /** |
| 561 | 561 | * The configuration service. |
| 562 | 562 | */ |
| 563 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 563 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php'; |
|
| 564 | 564 | |
| 565 | 565 | /** |
| 566 | 566 | * The entity post type service (this is the WordPress post type, not the entity schema type). |
| 567 | 567 | */ |
| 568 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 568 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-type-service.php'; |
|
| 569 | 569 | |
| 570 | 570 | /** |
| 571 | 571 | * The entity type service (i.e. the schema type). |
| 572 | 572 | */ |
| 573 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 573 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php'; |
|
| 574 | 574 | |
| 575 | 575 | /** |
| 576 | 576 | * The entity link service. |
| 577 | 577 | */ |
| 578 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 578 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php'; |
|
| 579 | 579 | |
| 580 | 580 | /** |
| 581 | 581 | * The Query builder. |
| 582 | 582 | */ |
| 583 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 583 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php'; |
|
| 584 | 584 | |
| 585 | 585 | /** |
| 586 | 586 | * The Schema service. |
| 587 | 587 | */ |
| 588 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 588 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php'; |
|
| 589 | 589 | |
| 590 | 590 | /** |
| 591 | 591 | * The schema:url property service. |
| 592 | 592 | */ |
| 593 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 594 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 593 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-service.php'; |
|
| 594 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-url-property-service.php'; |
|
| 595 | 595 | |
| 596 | 596 | /** |
| 597 | 597 | * The UI service. |
| 598 | 598 | */ |
| 599 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 599 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php'; |
|
| 600 | 600 | |
| 601 | 601 | /** |
| 602 | 602 | * The Thumbnail service. |
| 603 | 603 | */ |
| 604 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 604 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php'; |
|
| 605 | 605 | |
| 606 | 606 | /** |
| 607 | 607 | * The Entity Types Taxonomy service. |
| 608 | 608 | */ |
| 609 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 609 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 610 | 610 | |
| 611 | 611 | /** |
| 612 | 612 | * The Entity service. |
| 613 | 613 | */ |
| 614 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 614 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php'; |
|
| 615 | 615 | |
| 616 | 616 | // Add the entity rating service. |
| 617 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 617 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rating-service.php'; |
|
| 618 | 618 | |
| 619 | 619 | /** |
| 620 | 620 | * The User service. |
| 621 | 621 | */ |
| 622 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 622 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php'; |
|
| 623 | 623 | |
| 624 | 624 | /** |
| 625 | 625 | * The Timeline service. |
| 626 | 626 | */ |
| 627 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 627 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php'; |
|
| 628 | 628 | |
| 629 | 629 | /** |
| 630 | 630 | * The Topic Taxonomy service. |
| 631 | 631 | */ |
| 632 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 632 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 633 | 633 | |
| 634 | 634 | /** |
| 635 | 635 | * The SPARQL service. |
| 636 | 636 | */ |
| 637 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 637 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php'; |
|
| 638 | 638 | |
| 639 | 639 | /** |
| 640 | 640 | * The WordLift import service. |
| 641 | 641 | */ |
| 642 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 642 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php'; |
|
| 643 | 643 | |
| 644 | 644 | /** |
| 645 | 645 | * The WordLift URI service. |
| 646 | 646 | */ |
| 647 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 647 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php'; |
|
| 648 | 648 | |
| 649 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 649 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-listable.php'; |
|
| 650 | 650 | |
| 651 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 651 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-factory.php'; |
|
| 652 | 652 | |
| 653 | 653 | /** |
| 654 | 654 | * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
| 655 | 655 | */ |
| 656 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 656 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rebuild-service.php'; |
|
| 657 | 657 | |
| 658 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 658 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 659 | 659 | |
| 660 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 660 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-attachment-service.php'; |
|
| 661 | 661 | |
| 662 | 662 | /** |
| 663 | 663 | * Load the converters. |
| 664 | 664 | */ |
| 665 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 666 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 667 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 668 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 669 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 665 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/intf-wordlift-post-converter.php'; |
|
| 666 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 667 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 668 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 669 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 670 | 670 | |
| 671 | 671 | /** |
| 672 | 672 | * Load the content filter. |
| 673 | 673 | */ |
| 674 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 674 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-content-filter-service.php'; |
|
| 675 | 675 | |
| 676 | 676 | /* |
| 677 | 677 | * Load the excerpt helper. |
| 678 | 678 | */ |
| 679 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 679 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 680 | 680 | |
| 681 | 681 | /** |
| 682 | 682 | * Load the JSON-LD service to publish entities using JSON-LD.s |
| 683 | 683 | * |
| 684 | 684 | * @since 3.8.0 |
| 685 | 685 | */ |
| 686 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 686 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-service.php'; |
|
| 687 | 687 | |
| 688 | 688 | // The Publisher Service and the AJAX adapter. |
| 689 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 690 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 689 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-service.php'; |
|
| 690 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 691 | 691 | |
| 692 | 692 | /** |
| 693 | 693 | * Load the WordLift key validation service. |
| 694 | 694 | */ |
| 695 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 695 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-key-validation-service.php'; |
|
| 696 | 696 | |
| 697 | 697 | // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
| 698 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 698 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 699 | 699 | |
| 700 | 700 | // Load the `Wordlift_Event_Entity_Page_Service` class definition. |
| 701 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-event-entity-page-service.php'; |
|
| 701 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-event-entity-page-service.php'; |
|
| 702 | 702 | |
| 703 | 703 | /** Adapters. */ |
| 704 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 705 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 704 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-tinymce-adapter.php'; |
|
| 705 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-newrelic-adapter.php'; |
|
| 706 | 706 | |
| 707 | 707 | /** |
| 708 | 708 | * The class responsible for defining all actions that occur in the admin area. |
| 709 | 709 | */ |
| 710 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 710 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php'; |
|
| 711 | 711 | |
| 712 | 712 | /** |
| 713 | 713 | * The class to customize the entity list admin page. |
| 714 | 714 | */ |
| 715 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 715 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php'; |
|
| 716 | 716 | |
| 717 | 717 | /** |
| 718 | 718 | * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
| 719 | 719 | */ |
| 720 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 720 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 721 | 721 | |
| 722 | 722 | /** |
| 723 | 723 | * The Notice service. |
| 724 | 724 | */ |
| 725 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 725 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php'; |
|
| 726 | 726 | |
| 727 | 727 | /** |
| 728 | 728 | * The PrimaShop adapter. |
| 729 | 729 | */ |
| 730 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 730 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php'; |
|
| 731 | 731 | |
| 732 | 732 | /** |
| 733 | 733 | * The WordLift Dashboard service. |
| 734 | 734 | */ |
| 735 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 735 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php'; |
|
| 736 | 736 | |
| 737 | 737 | /** |
| 738 | 738 | * The admin 'Install wizard' page. |
| 739 | 739 | */ |
| 740 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 740 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-setup.php'; |
|
| 741 | 741 | |
| 742 | 742 | /** |
| 743 | 743 | * The WordLift entity type list admin page controller. |
| 744 | 744 | */ |
| 745 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 745 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 746 | 746 | |
| 747 | 747 | /** |
| 748 | 748 | * The WordLift entity type settings admin page controller. |
| 749 | 749 | */ |
| 750 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 750 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-settings.php'; |
|
| 751 | 751 | |
| 752 | 752 | /** |
| 753 | 753 | * The admin 'Download Your Data' page. |
| 754 | 754 | */ |
| 755 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 755 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php'; |
|
| 756 | 756 | |
| 757 | 757 | /** |
| 758 | 758 | * The admin 'Download Your Data' page. |
| 759 | 759 | */ |
| 760 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 760 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php'; |
|
| 761 | 761 | |
| 762 | 762 | /** |
| 763 | 763 | * The admin 'WordLift Settings' page. |
| 764 | 764 | */ |
| 765 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 766 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 767 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 768 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 769 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 770 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 771 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 772 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 773 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 765 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/intf-wordlift-admin-element.php'; |
|
| 766 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-input-element.php'; |
|
| 767 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-select2-element.php'; |
|
| 768 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-language-select-element.php'; |
|
| 769 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-tabs-element.php'; |
|
| 770 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-publisher-element.php'; |
|
| 771 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-page.php'; |
|
| 772 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page.php'; |
|
| 773 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 774 | 774 | |
| 775 | 775 | /** Admin Pages */ |
| 776 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 777 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 776 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 777 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-status-page.php'; |
|
| 778 | 778 | |
| 779 | 779 | /** |
| 780 | 780 | * The class responsible for defining all actions that occur in the public-facing |
| 781 | 781 | * side of the site. |
| 782 | 782 | */ |
| 783 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 783 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php'; |
|
| 784 | 784 | |
| 785 | 785 | /** |
| 786 | 786 | * The shortcode abstract class. |
| 787 | 787 | */ |
| 788 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 788 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php'; |
|
| 789 | 789 | |
| 790 | 790 | /** |
| 791 | 791 | * The Timeline shortcode. |
| 792 | 792 | */ |
| 793 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 793 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php'; |
|
| 794 | 794 | |
| 795 | 795 | /** |
| 796 | 796 | * The Navigator shortcode. |
| 797 | 797 | */ |
| 798 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 798 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php'; |
|
| 799 | 799 | |
| 800 | 800 | /** |
| 801 | 801 | * The chord shortcode. |
| 802 | 802 | */ |
| 803 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 803 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php'; |
|
| 804 | 804 | |
| 805 | 805 | /** |
| 806 | 806 | * The geomap shortcode. |
| 807 | 807 | */ |
| 808 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 808 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php'; |
|
| 809 | 809 | |
| 810 | 810 | /** |
| 811 | 811 | * The entity cloud shortcode. |
| 812 | 812 | */ |
| 813 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 813 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | 816 | * The ShareThis service. |
| 817 | 817 | */ |
| 818 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 818 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php'; |
|
| 819 | 819 | |
| 820 | 820 | /** |
| 821 | 821 | * The SEO service. |
| 822 | 822 | */ |
| 823 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 823 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-seo-service.php'; |
|
| 824 | 824 | |
| 825 | 825 | /** |
| 826 | 826 | * The AMP service. |
| 827 | 827 | */ |
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 828 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-amp-service.php'; |
|
| 829 | 829 | |
| 830 | 830 | /** Widgets */ |
| 831 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 831 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-widget.php'; |
|
| 832 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 833 | 833 | |
| 834 | 834 | $this->loader = new Wordlift_Loader(); |
| 835 | 835 | |
| 836 | 836 | // Instantiate a global logger. |
| 837 | 837 | global $wl_logger; |
| 838 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 838 | + $wl_logger = Wordlift_Log_Service::get_logger('WordLift'); |
|
| 839 | 839 | |
| 840 | 840 | // Create the configuration service. |
| 841 | 841 | $this->configuration_service = new Wordlift_Configuration_Service(); |
| 842 | 842 | |
| 843 | 843 | // Create an entity type service instance. It'll be later bound to the init action. |
| 844 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 844 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path()); |
|
| 845 | 845 | |
| 846 | 846 | // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
| 847 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 847 | + $this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_post_type_service, $this->configuration_service->get_entity_base_path()); |
|
| 848 | 848 | |
| 849 | 849 | // Create an instance of the UI service. |
| 850 | 850 | $this->ui_service = new Wordlift_UI_Service(); |
@@ -855,23 +855,23 @@ discard block |
||
| 855 | 855 | $this->sparql_service = new Wordlift_Sparql_Service(); |
| 856 | 856 | |
| 857 | 857 | // Create an instance of the Schema service. |
| 858 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 858 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service($this->sparql_service); |
|
| 859 | 859 | $this->schema_service = new Wordlift_Schema_Service(); |
| 860 | 860 | |
| 861 | 861 | // Create an instance of the Notice service. |
| 862 | 862 | $this->notice_service = new Wordlift_Notice_Service(); |
| 863 | 863 | |
| 864 | 864 | // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
| 865 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service ); |
|
| 865 | + $this->entity_service = new Wordlift_Entity_Service($this->ui_service); |
|
| 866 | 866 | |
| 867 | 867 | // Create an instance of the User service. |
| 868 | 868 | $this->user_service = new Wordlift_User_Service(); |
| 869 | 869 | |
| 870 | 870 | // Create a new instance of the Timeline service and Timeline shortcode. |
| 871 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 871 | + $this->timeline_service = new Wordlift_Timeline_Service($this->entity_service); |
|
| 872 | 872 | |
| 873 | 873 | // Create a new instance of the Redirect service. |
| 874 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 874 | + $this->redirect_service = new Wordlift_Redirect_Service($this->entity_service); |
|
| 875 | 875 | |
| 876 | 876 | // Initialize the shortcodes. |
| 877 | 877 | new Wordlift_Navigator_Shortcode(); |
@@ -897,45 +897,45 @@ discard block |
||
| 897 | 897 | $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
| 898 | 898 | |
| 899 | 899 | // Create an import service instance to hook later to WP's import function. |
| 900 | - $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() ); |
|
| 900 | + $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()); |
|
| 901 | 901 | |
| 902 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 902 | + $uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']); |
|
| 903 | 903 | |
| 904 | 904 | // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
| 905 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 905 | + $this->rebuild_service = new Wordlift_Rebuild_Service($this->sparql_service, $uri_service); |
|
| 906 | 906 | |
| 907 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 907 | + $this->entity_type_service = new Wordlift_Entity_Type_Service($this->schema_service); |
|
| 908 | 908 | |
| 909 | 909 | // Create the entity rating service. |
| 910 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 910 | + $this->rating_service = new Wordlift_Rating_Service($this->entity_service, $this->entity_type_service, $this->notice_service); |
|
| 911 | 911 | |
| 912 | 912 | // Create entity list customization (wp-admin/edit.php) |
| 913 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 913 | + $this->entity_list_service = new Wordlift_Entity_List_Service($this->rating_service); |
|
| 914 | 914 | |
| 915 | 915 | // Create a new instance of the Redirect service. |
| 916 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service ); |
|
| 916 | + $this->dashboard_service = new Wordlift_Dashboard_Service($this->rating_service); |
|
| 917 | 917 | |
| 918 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 919 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 918 | + $this->property_factory = new Wordlift_Property_Factory($schema_url_property_service); |
|
| 919 | + $this->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service); |
|
| 920 | 920 | |
| 921 | 921 | $attachment_service = new Wordlift_Attachment_Service(); |
| 922 | 922 | |
| 923 | 923 | // Instantiate the JSON-LD service. |
| 924 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 925 | - $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 ); |
|
| 926 | - $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 ); |
|
| 927 | - $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 ); |
|
| 928 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter ); |
|
| 924 | + $property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service); |
|
| 925 | + $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); |
|
| 926 | + $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); |
|
| 927 | + $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); |
|
| 928 | + $this->jsonld_service = new Wordlift_Jsonld_Service($this->entity_service, $this->postid_to_jsonld_converter); |
|
| 929 | 929 | |
| 930 | 930 | // Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins). |
| 931 | 931 | $this->key_validation_service = new Wordlift_Key_Validation_Service(); |
| 932 | 932 | |
| 933 | 933 | // Create an instance of the Publisher Service and the AJAX Adapter. |
| 934 | 934 | $publisher_service = new Wordlift_Publisher_Service(); |
| 935 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 935 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter($publisher_service); |
|
| 936 | 936 | |
| 937 | 937 | /** Adapters. */ |
| 938 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 938 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter($this); |
|
| 939 | 939 | |
| 940 | 940 | /** WordPress Admin UI. */ |
| 941 | 941 | |
@@ -944,14 +944,14 @@ discard block |
||
| 944 | 944 | $this->select2_element = new Wordlift_Admin_Select2_Element(); |
| 945 | 945 | $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
| 946 | 946 | $tabs_element = new Wordlift_Admin_Tabs_Element(); |
| 947 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 947 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element($this->configuration_service, $publisher_service, $tabs_element, $this->select2_element); |
|
| 948 | 948 | |
| 949 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 950 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element ); |
|
| 951 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 949 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service); |
|
| 950 | + $this->settings_page = new Wordlift_Admin_Settings_Page($this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element); |
|
| 951 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link($this->settings_page); |
|
| 952 | 952 | |
| 953 | 953 | // Pages. |
| 954 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 954 | + new Wordlift_Admin_Post_Edit_Page($this); |
|
| 955 | 955 | |
| 956 | 956 | // create an instance of the entity type list admin page controller. |
| 957 | 957 | $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
@@ -963,23 +963,23 @@ discard block |
||
| 963 | 963 | $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
| 964 | 964 | |
| 965 | 965 | //** WordPress Admin */ |
| 966 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 967 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 966 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service); |
|
| 967 | + $this->status_page = new Wordlift_Admin_Status_Page($this->entity_service, $this->sparql_service); |
|
| 968 | 968 | |
| 969 | 969 | // Create an instance of the install wizard. |
| 970 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 970 | + $this->admin_setup = new Wordlift_Admin_Setup($this->configuration_service, $this->key_validation_service, $this->entity_service); |
|
| 971 | 971 | |
| 972 | 972 | // Create an instance of the content filter service. |
| 973 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service ); |
|
| 973 | + $this->content_filter_service = new Wordlift_Content_Filter_Service($this->entity_service); |
|
| 974 | 974 | |
| 975 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 975 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service($this->entity_post_type_service); |
|
| 976 | 976 | |
| 977 | 977 | $this->event_entity_page_service = new Wordlift_Event_Entity_Page_Service(); |
| 978 | 978 | |
| 979 | 979 | // Load the debug service if WP is in debug mode. |
| 980 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 981 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 982 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 980 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
| 981 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-debug-service.php'; |
|
| 982 | + new Wordlift_Debug_Service($this->entity_service, $uri_service); |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | } |
@@ -996,9 +996,9 @@ discard block |
||
| 996 | 996 | private function set_locale() { |
| 997 | 997 | |
| 998 | 998 | $plugin_i18n = new Wordlift_i18n(); |
| 999 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 999 | + $plugin_i18n->set_domain($this->get_plugin_name()); |
|
| 1000 | 1000 | |
| 1001 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1001 | + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
| 1002 | 1002 | |
| 1003 | 1003 | } |
| 1004 | 1004 | |
@@ -1018,117 +1018,117 @@ discard block |
||
| 1018 | 1018 | $this->notice_service |
| 1019 | 1019 | ); |
| 1020 | 1020 | |
| 1021 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1022 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1021 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
| 1022 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); |
|
| 1023 | 1023 | |
| 1024 | 1024 | // Hook the init action to the Topic Taxonomy service. |
| 1025 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1025 | + $this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0); |
|
| 1026 | 1026 | |
| 1027 | 1027 | // Hook the deleted_post_meta action to the Thumbnail service. |
| 1028 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1028 | + $this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4); |
|
| 1029 | 1029 | |
| 1030 | 1030 | // Hook the added_post_meta action to the Thumbnail service. |
| 1031 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1031 | + $this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1032 | 1032 | |
| 1033 | 1033 | // Hook the updated_post_meta action to the Thumbnail service. |
| 1034 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1034 | + $this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1035 | 1035 | |
| 1036 | 1036 | // Hook posts inserts (or updates) to the user service. |
| 1037 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 1037 | + $this->loader->add_action('wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3); |
|
| 1038 | 1038 | |
| 1039 | 1039 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1040 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1040 | + $this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1041 | 1041 | |
| 1042 | 1042 | // Register custom allowed redirect hosts. |
| 1043 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1043 | + $this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts'); |
|
| 1044 | 1044 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1045 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1045 | + $this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect'); |
|
| 1046 | 1046 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1047 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1047 | + $this->loader->add_action('wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats'); |
|
| 1048 | 1048 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1049 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1049 | + $this->loader->add_action('wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets'); |
|
| 1050 | 1050 | |
| 1051 | 1051 | // Hook save_post to the entity service to update custom fields (such as alternate labels). |
| 1052 | 1052 | // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
| 1053 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1054 | - $this->loader->add_action( 'save_post_entity', $this->rating_service, 'set_rating_for', 10, 1 ); |
|
| 1053 | + $this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3); |
|
| 1054 | + $this->loader->add_action('save_post_entity', $this->rating_service, 'set_rating_for', 10, 1); |
|
| 1055 | 1055 | |
| 1056 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1057 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1056 | + $this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1); |
|
| 1057 | + $this->loader->add_action('in_admin_header', $this->rating_service, 'in_admin_header'); |
|
| 1058 | 1058 | |
| 1059 | 1059 | // Entity listing customization (wp-admin/edit.php) |
| 1060 | 1060 | // Add custom columns |
| 1061 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1062 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1061 | + $this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns'); |
|
| 1062 | + $this->loader->add_filter('manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2); |
|
| 1063 | 1063 | // Add 4W selection |
| 1064 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1065 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1064 | + $this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope'); |
|
| 1065 | + $this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope'); |
|
| 1066 | 1066 | |
| 1067 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1067 | + $this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args'); |
|
| 1068 | 1068 | |
| 1069 | 1069 | // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
| 1070 | 1070 | // entities. |
| 1071 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1071 | + $this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2); |
|
| 1072 | 1072 | |
| 1073 | 1073 | // Filter imported post meta. |
| 1074 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1074 | + $this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3); |
|
| 1075 | 1075 | |
| 1076 | 1076 | // Notify the import service when an import starts and ends. |
| 1077 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1078 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1077 | + $this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0); |
|
| 1078 | + $this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0); |
|
| 1079 | 1079 | |
| 1080 | 1080 | // Hook the AJAX wl_rebuild action to the Rebuild Service. |
| 1081 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1081 | + $this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild'); |
|
| 1082 | 1082 | |
| 1083 | 1083 | // Hook the menu to the Download Your Data page. |
| 1084 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1085 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1086 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1084 | + $this->loader->add_action('admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0); |
|
| 1085 | + $this->loader->add_action('admin_menu', $this->status_page, 'admin_menu', 100, 0); |
|
| 1086 | + $this->loader->add_action('admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0); |
|
| 1087 | 1087 | |
| 1088 | 1088 | // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
| 1089 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1089 | + $this->loader->add_action('wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10); |
|
| 1090 | 1090 | |
| 1091 | 1091 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1092 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1092 | + $this->loader->add_action('wp_ajax_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1093 | 1093 | |
| 1094 | 1094 | // Hook the AJAX wl_validate_key action to the Key Validation service. |
| 1095 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1095 | + $this->loader->add_action('wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key'); |
|
| 1096 | 1096 | |
| 1097 | 1097 | // Hook the `admin_init` function to the Admin Setup. |
| 1098 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1098 | + $this->loader->add_action('admin_init', $this->admin_setup, 'admin_init'); |
|
| 1099 | 1099 | |
| 1100 | 1100 | // Hook the admin_init to the settings page. |
| 1101 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1101 | + $this->loader->add_action('admin_init', $this->settings_page, 'admin_init'); |
|
| 1102 | 1102 | |
| 1103 | 1103 | // Hook the menu creation on the general wordlift menu creation |
| 1104 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1104 | + $this->loader->add_action('wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2); |
|
| 1105 | 1105 | |
| 1106 | 1106 | // Hook key update. |
| 1107 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1108 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1107 | + $this->loader->add_action('pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2); |
|
| 1108 | + $this->loader->add_action('update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2); |
|
| 1109 | 1109 | |
| 1110 | 1110 | // Add additional action links to the WordLift plugin in the plugins page. |
| 1111 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1111 | + $this->loader->add_filter('plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1); |
|
| 1112 | 1112 | |
| 1113 | 1113 | // Hook the AJAX `wl_publisher` action name. |
| 1114 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1114 | + $this->loader->add_action('wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher'); |
|
| 1115 | 1115 | |
| 1116 | 1116 | // Hook row actions for the entity type list admin. |
| 1117 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1117 | + $this->loader->add_filter('wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2); |
|
| 1118 | 1118 | |
| 1119 | 1119 | // Hook capabilities manipulation to allow access to entity type admin |
| 1120 | 1120 | // page on wordpress versions before 4.7. |
| 1121 | 1121 | global $wp_version; |
| 1122 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1123 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1122 | + if (version_compare($wp_version, '4.7', '<')) { |
|
| 1123 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4); |
|
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | 1126 | /** Adapters. */ |
| 1127 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1127 | + $this->loader->add_filter('mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1); |
|
| 1128 | 1128 | |
| 1129 | 1129 | // Hooks to restrict multisite super admin from manipulating entity types. |
| 1130 | - if ( is_multisite() ) { |
|
| 1131 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1130 | + if (is_multisite()) { |
|
| 1131 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4); |
|
| 1132 | 1132 | } |
| 1133 | 1133 | } |
| 1134 | 1134 | |
@@ -1141,44 +1141,44 @@ discard block |
||
| 1141 | 1141 | */ |
| 1142 | 1142 | private function define_public_hooks() { |
| 1143 | 1143 | |
| 1144 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1144 | + $plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version()); |
|
| 1145 | 1145 | |
| 1146 | 1146 | // Register the entity post type. |
| 1147 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1147 | + $this->loader->add_action('init', $this->entity_post_type_service, 'register'); |
|
| 1148 | 1148 | |
| 1149 | 1149 | // Bind the link generation and handling hooks to the entity link service. |
| 1150 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1151 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 1152 | - $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 ); |
|
| 1153 | - $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 ); |
|
| 1150 | + $this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4); |
|
| 1151 | + $this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1); |
|
| 1152 | + $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); |
|
| 1153 | + $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); |
|
| 1154 | 1154 | |
| 1155 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1156 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1155 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
| 1156 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
| 1157 | 1157 | |
| 1158 | 1158 | // Hook the content filter service to add entity links. |
| 1159 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1159 | + $this->loader->add_filter('the_content', $this->content_filter_service, 'the_content'); |
|
| 1160 | 1160 | |
| 1161 | 1161 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1162 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1162 | + $this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1163 | 1163 | |
| 1164 | 1164 | // Hook the ShareThis service. |
| 1165 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1166 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1165 | + $this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99); |
|
| 1166 | + $this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99); |
|
| 1167 | 1167 | |
| 1168 | 1168 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1169 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1169 | + $this->loader->add_action('wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1170 | 1170 | |
| 1171 | 1171 | // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
| 1172 | 1172 | // in order to tweak WP's `WP_Query` to include entities in queries related |
| 1173 | 1173 | // to categories. |
| 1174 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1174 | + $this->loader->add_action('pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1); |
|
| 1175 | 1175 | |
| 1176 | 1176 | /* |
| 1177 | 1177 | * Hook the `pre_get_posts` action to the `Wordlift_Event_Entity_Page_Service` |
| 1178 | 1178 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1179 | 1179 | * order of start time. |
| 1180 | 1180 | */ |
| 1181 | - $this->loader->add_action( 'pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1181 | + $this->loader->add_action('pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1); |
|
| 1182 | 1182 | |
| 1183 | 1183 | } |
| 1184 | 1184 | |
@@ -29,1197 +29,1197 @@ |
||
| 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_Language_Select_Element} element renderer. |
|
| 413 | - * |
|
| 414 | - * @since 3.11.0 |
|
| 415 | - * @access protected |
|
| 416 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 417 | - */ |
|
| 418 | - protected $language_select_element; |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 422 | - * |
|
| 423 | - * @since 3.11.0 |
|
| 424 | - * @access protected |
|
| 425 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 426 | - */ |
|
| 427 | - protected $publisher_element; |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 431 | - * |
|
| 432 | - * @since 3.11.0 |
|
| 433 | - * @access protected |
|
| 434 | - * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 435 | - */ |
|
| 436 | - protected $select2_element; |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * The controller for the entity type list admin page |
|
| 440 | - * |
|
| 441 | - * @since 3.11.0 |
|
| 442 | - * @access private |
|
| 443 | - * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 444 | - */ |
|
| 445 | - private $entity_type_admin_page; |
|
| 446 | - |
|
| 447 | - /** |
|
| 448 | - * The controller for the entity type settings admin page |
|
| 449 | - * |
|
| 450 | - * @since 3.11.0 |
|
| 451 | - * @access private |
|
| 452 | - * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 453 | - */ |
|
| 454 | - private $entity_type_settings_admin_page; |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 458 | - * |
|
| 459 | - * @since 3.11.0 |
|
| 460 | - * @access protected |
|
| 461 | - * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 462 | - */ |
|
| 463 | - protected $related_entities_cloud_widget; |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * {@link Wordlift}'s singleton instance. |
|
| 467 | - * |
|
| 468 | - * @since 3.11.2 |
|
| 469 | - * |
|
| 470 | - * @since 3.11.2 |
|
| 471 | - * @access private |
|
| 472 | - * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 473 | - */ |
|
| 474 | - private static $instance; |
|
| 475 | - |
|
| 476 | - /** |
|
| 477 | - * Define the core functionality of the plugin. |
|
| 478 | - * |
|
| 479 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 480 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 481 | - * the public-facing side of the site. |
|
| 482 | - * |
|
| 483 | - * @since 1.0.0 |
|
| 484 | - */ |
|
| 485 | - public function __construct() { |
|
| 486 | - |
|
| 487 | - $this->plugin_name = 'wordlift'; |
|
| 488 | - $this->version = '3.13.0-dev'; |
|
| 489 | - $this->load_dependencies(); |
|
| 490 | - $this->set_locale(); |
|
| 491 | - $this->define_admin_hooks(); |
|
| 492 | - $this->define_public_hooks(); |
|
| 493 | - |
|
| 494 | - self::$instance = $this; |
|
| 495 | - |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - /** |
|
| 499 | - * Get the singleton instance. |
|
| 500 | - * |
|
| 501 | - * @since 3.11.2 |
|
| 502 | - * |
|
| 503 | - * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 504 | - */ |
|
| 505 | - public static function get_instance() { |
|
| 506 | - |
|
| 507 | - return self::$instance; |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - /** |
|
| 511 | - * Load the required dependencies for this plugin. |
|
| 512 | - * |
|
| 513 | - * Include the following files that make up the plugin: |
|
| 514 | - * |
|
| 515 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 516 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 517 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 518 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 519 | - * |
|
| 520 | - * Create an instance of the loader which will be used to register the hooks |
|
| 521 | - * with WordPress. |
|
| 522 | - * |
|
| 523 | - * @since 1.0.0 |
|
| 524 | - * @access private |
|
| 525 | - */ |
|
| 526 | - private function load_dependencies() { |
|
| 527 | - |
|
| 528 | - /** |
|
| 529 | - * The class responsible for orchestrating the actions and filters of the |
|
| 530 | - * core plugin. |
|
| 531 | - */ |
|
| 532 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 533 | - |
|
| 534 | - /** |
|
| 535 | - * The class responsible for defining internationalization functionality |
|
| 536 | - * of the plugin. |
|
| 537 | - */ |
|
| 538 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 539 | - |
|
| 540 | - /** |
|
| 541 | - * WordLift's supported languages. |
|
| 542 | - */ |
|
| 543 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 544 | - |
|
| 545 | - /** |
|
| 546 | - * Provide support functions to sanitize data. |
|
| 547 | - */ |
|
| 548 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 549 | - |
|
| 550 | - /** |
|
| 551 | - * The Redirect service. |
|
| 552 | - */ |
|
| 553 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 554 | - |
|
| 555 | - /** |
|
| 556 | - * The Log service. |
|
| 557 | - */ |
|
| 558 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 559 | - |
|
| 560 | - /** |
|
| 561 | - * The configuration service. |
|
| 562 | - */ |
|
| 563 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 564 | - |
|
| 565 | - /** |
|
| 566 | - * The entity post type service (this is the WordPress post type, not the entity schema type). |
|
| 567 | - */ |
|
| 568 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 569 | - |
|
| 570 | - /** |
|
| 571 | - * The entity type service (i.e. the schema type). |
|
| 572 | - */ |
|
| 573 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 574 | - |
|
| 575 | - /** |
|
| 576 | - * The entity link service. |
|
| 577 | - */ |
|
| 578 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 579 | - |
|
| 580 | - /** |
|
| 581 | - * The Query builder. |
|
| 582 | - */ |
|
| 583 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 584 | - |
|
| 585 | - /** |
|
| 586 | - * The Schema service. |
|
| 587 | - */ |
|
| 588 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 589 | - |
|
| 590 | - /** |
|
| 591 | - * The schema:url property service. |
|
| 592 | - */ |
|
| 593 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 594 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 595 | - |
|
| 596 | - /** |
|
| 597 | - * The UI service. |
|
| 598 | - */ |
|
| 599 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 600 | - |
|
| 601 | - /** |
|
| 602 | - * The Thumbnail service. |
|
| 603 | - */ |
|
| 604 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 605 | - |
|
| 606 | - /** |
|
| 607 | - * The Entity Types Taxonomy service. |
|
| 608 | - */ |
|
| 609 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 610 | - |
|
| 611 | - /** |
|
| 612 | - * The Entity service. |
|
| 613 | - */ |
|
| 614 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 615 | - |
|
| 616 | - // Add the entity rating service. |
|
| 617 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 618 | - |
|
| 619 | - /** |
|
| 620 | - * The User service. |
|
| 621 | - */ |
|
| 622 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 623 | - |
|
| 624 | - /** |
|
| 625 | - * The Timeline service. |
|
| 626 | - */ |
|
| 627 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 628 | - |
|
| 629 | - /** |
|
| 630 | - * The Topic Taxonomy service. |
|
| 631 | - */ |
|
| 632 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 633 | - |
|
| 634 | - /** |
|
| 635 | - * The SPARQL service. |
|
| 636 | - */ |
|
| 637 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 638 | - |
|
| 639 | - /** |
|
| 640 | - * The WordLift import service. |
|
| 641 | - */ |
|
| 642 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 643 | - |
|
| 644 | - /** |
|
| 645 | - * The WordLift URI service. |
|
| 646 | - */ |
|
| 647 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 648 | - |
|
| 649 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 650 | - |
|
| 651 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 652 | - |
|
| 653 | - /** |
|
| 654 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 655 | - */ |
|
| 656 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 657 | - |
|
| 658 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 659 | - |
|
| 660 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 661 | - |
|
| 662 | - /** |
|
| 663 | - * Load the converters. |
|
| 664 | - */ |
|
| 665 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 666 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 667 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 668 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 669 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 670 | - |
|
| 671 | - /** |
|
| 672 | - * Load the content filter. |
|
| 673 | - */ |
|
| 674 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 675 | - |
|
| 676 | - /* |
|
| 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_Language_Select_Element} element renderer. |
|
| 413 | + * |
|
| 414 | + * @since 3.11.0 |
|
| 415 | + * @access protected |
|
| 416 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 417 | + */ |
|
| 418 | + protected $language_select_element; |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 422 | + * |
|
| 423 | + * @since 3.11.0 |
|
| 424 | + * @access protected |
|
| 425 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 426 | + */ |
|
| 427 | + protected $publisher_element; |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 431 | + * |
|
| 432 | + * @since 3.11.0 |
|
| 433 | + * @access protected |
|
| 434 | + * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 435 | + */ |
|
| 436 | + protected $select2_element; |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * The controller for the entity type list admin page |
|
| 440 | + * |
|
| 441 | + * @since 3.11.0 |
|
| 442 | + * @access private |
|
| 443 | + * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 444 | + */ |
|
| 445 | + private $entity_type_admin_page; |
|
| 446 | + |
|
| 447 | + /** |
|
| 448 | + * The controller for the entity type settings admin page |
|
| 449 | + * |
|
| 450 | + * @since 3.11.0 |
|
| 451 | + * @access private |
|
| 452 | + * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 453 | + */ |
|
| 454 | + private $entity_type_settings_admin_page; |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 458 | + * |
|
| 459 | + * @since 3.11.0 |
|
| 460 | + * @access protected |
|
| 461 | + * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 462 | + */ |
|
| 463 | + protected $related_entities_cloud_widget; |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * {@link Wordlift}'s singleton instance. |
|
| 467 | + * |
|
| 468 | + * @since 3.11.2 |
|
| 469 | + * |
|
| 470 | + * @since 3.11.2 |
|
| 471 | + * @access private |
|
| 472 | + * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 473 | + */ |
|
| 474 | + private static $instance; |
|
| 475 | + |
|
| 476 | + /** |
|
| 477 | + * Define the core functionality of the plugin. |
|
| 478 | + * |
|
| 479 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 480 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 481 | + * the public-facing side of the site. |
|
| 482 | + * |
|
| 483 | + * @since 1.0.0 |
|
| 484 | + */ |
|
| 485 | + public function __construct() { |
|
| 486 | + |
|
| 487 | + $this->plugin_name = 'wordlift'; |
|
| 488 | + $this->version = '3.13.0-dev'; |
|
| 489 | + $this->load_dependencies(); |
|
| 490 | + $this->set_locale(); |
|
| 491 | + $this->define_admin_hooks(); |
|
| 492 | + $this->define_public_hooks(); |
|
| 493 | + |
|
| 494 | + self::$instance = $this; |
|
| 495 | + |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + /** |
|
| 499 | + * Get the singleton instance. |
|
| 500 | + * |
|
| 501 | + * @since 3.11.2 |
|
| 502 | + * |
|
| 503 | + * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 504 | + */ |
|
| 505 | + public static function get_instance() { |
|
| 506 | + |
|
| 507 | + return self::$instance; |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + /** |
|
| 511 | + * Load the required dependencies for this plugin. |
|
| 512 | + * |
|
| 513 | + * Include the following files that make up the plugin: |
|
| 514 | + * |
|
| 515 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 516 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 517 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 518 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 519 | + * |
|
| 520 | + * Create an instance of the loader which will be used to register the hooks |
|
| 521 | + * with WordPress. |
|
| 522 | + * |
|
| 523 | + * @since 1.0.0 |
|
| 524 | + * @access private |
|
| 525 | + */ |
|
| 526 | + private function load_dependencies() { |
|
| 527 | + |
|
| 528 | + /** |
|
| 529 | + * The class responsible for orchestrating the actions and filters of the |
|
| 530 | + * core plugin. |
|
| 531 | + */ |
|
| 532 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 533 | + |
|
| 534 | + /** |
|
| 535 | + * The class responsible for defining internationalization functionality |
|
| 536 | + * of the plugin. |
|
| 537 | + */ |
|
| 538 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 539 | + |
|
| 540 | + /** |
|
| 541 | + * WordLift's supported languages. |
|
| 542 | + */ |
|
| 543 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 544 | + |
|
| 545 | + /** |
|
| 546 | + * Provide support functions to sanitize data. |
|
| 547 | + */ |
|
| 548 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 549 | + |
|
| 550 | + /** |
|
| 551 | + * The Redirect service. |
|
| 552 | + */ |
|
| 553 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 554 | + |
|
| 555 | + /** |
|
| 556 | + * The Log service. |
|
| 557 | + */ |
|
| 558 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 559 | + |
|
| 560 | + /** |
|
| 561 | + * The configuration service. |
|
| 562 | + */ |
|
| 563 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 564 | + |
|
| 565 | + /** |
|
| 566 | + * The entity post type service (this is the WordPress post type, not the entity schema type). |
|
| 567 | + */ |
|
| 568 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 569 | + |
|
| 570 | + /** |
|
| 571 | + * The entity type service (i.e. the schema type). |
|
| 572 | + */ |
|
| 573 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 574 | + |
|
| 575 | + /** |
|
| 576 | + * The entity link service. |
|
| 577 | + */ |
|
| 578 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 579 | + |
|
| 580 | + /** |
|
| 581 | + * The Query builder. |
|
| 582 | + */ |
|
| 583 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 584 | + |
|
| 585 | + /** |
|
| 586 | + * The Schema service. |
|
| 587 | + */ |
|
| 588 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 589 | + |
|
| 590 | + /** |
|
| 591 | + * The schema:url property service. |
|
| 592 | + */ |
|
| 593 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 594 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 595 | + |
|
| 596 | + /** |
|
| 597 | + * The UI service. |
|
| 598 | + */ |
|
| 599 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 600 | + |
|
| 601 | + /** |
|
| 602 | + * The Thumbnail service. |
|
| 603 | + */ |
|
| 604 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 605 | + |
|
| 606 | + /** |
|
| 607 | + * The Entity Types Taxonomy service. |
|
| 608 | + */ |
|
| 609 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 610 | + |
|
| 611 | + /** |
|
| 612 | + * The Entity service. |
|
| 613 | + */ |
|
| 614 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 615 | + |
|
| 616 | + // Add the entity rating service. |
|
| 617 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 618 | + |
|
| 619 | + /** |
|
| 620 | + * The User service. |
|
| 621 | + */ |
|
| 622 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 623 | + |
|
| 624 | + /** |
|
| 625 | + * The Timeline service. |
|
| 626 | + */ |
|
| 627 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 628 | + |
|
| 629 | + /** |
|
| 630 | + * The Topic Taxonomy service. |
|
| 631 | + */ |
|
| 632 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 633 | + |
|
| 634 | + /** |
|
| 635 | + * The SPARQL service. |
|
| 636 | + */ |
|
| 637 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 638 | + |
|
| 639 | + /** |
|
| 640 | + * The WordLift import service. |
|
| 641 | + */ |
|
| 642 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 643 | + |
|
| 644 | + /** |
|
| 645 | + * The WordLift URI service. |
|
| 646 | + */ |
|
| 647 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 648 | + |
|
| 649 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 650 | + |
|
| 651 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 652 | + |
|
| 653 | + /** |
|
| 654 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 655 | + */ |
|
| 656 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 657 | + |
|
| 658 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 659 | + |
|
| 660 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 661 | + |
|
| 662 | + /** |
|
| 663 | + * Load the converters. |
|
| 664 | + */ |
|
| 665 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 666 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 667 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 668 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 669 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 670 | + |
|
| 671 | + /** |
|
| 672 | + * Load the content filter. |
|
| 673 | + */ |
|
| 674 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 675 | + |
|
| 676 | + /* |
|
| 677 | 677 | * Load the excerpt helper. |
| 678 | 678 | */ |
| 679 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 680 | - |
|
| 681 | - /** |
|
| 682 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 683 | - * |
|
| 684 | - * @since 3.8.0 |
|
| 685 | - */ |
|
| 686 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 687 | - |
|
| 688 | - // The Publisher Service and the AJAX adapter. |
|
| 689 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 690 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 691 | - |
|
| 692 | - /** |
|
| 693 | - * Load the WordLift key validation service. |
|
| 694 | - */ |
|
| 695 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 696 | - |
|
| 697 | - // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 698 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 699 | - |
|
| 700 | - // Load the `Wordlift_Event_Entity_Page_Service` class definition. |
|
| 701 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-event-entity-page-service.php'; |
|
| 702 | - |
|
| 703 | - /** Adapters. */ |
|
| 704 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 705 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 706 | - |
|
| 707 | - /** |
|
| 708 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 709 | - */ |
|
| 710 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 711 | - |
|
| 712 | - /** |
|
| 713 | - * The class to customize the entity list admin page. |
|
| 714 | - */ |
|
| 715 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 716 | - |
|
| 717 | - /** |
|
| 718 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 719 | - */ |
|
| 720 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 721 | - |
|
| 722 | - /** |
|
| 723 | - * The Notice service. |
|
| 724 | - */ |
|
| 725 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 726 | - |
|
| 727 | - /** |
|
| 728 | - * The PrimaShop adapter. |
|
| 729 | - */ |
|
| 730 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 731 | - |
|
| 732 | - /** |
|
| 733 | - * The WordLift Dashboard service. |
|
| 734 | - */ |
|
| 735 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 736 | - |
|
| 737 | - /** |
|
| 738 | - * The admin 'Install wizard' page. |
|
| 739 | - */ |
|
| 740 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 679 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 680 | + |
|
| 681 | + /** |
|
| 682 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 683 | + * |
|
| 684 | + * @since 3.8.0 |
|
| 685 | + */ |
|
| 686 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 687 | + |
|
| 688 | + // The Publisher Service and the AJAX adapter. |
|
| 689 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 690 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 691 | + |
|
| 692 | + /** |
|
| 693 | + * Load the WordLift key validation service. |
|
| 694 | + */ |
|
| 695 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 696 | + |
|
| 697 | + // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 698 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 699 | + |
|
| 700 | + // Load the `Wordlift_Event_Entity_Page_Service` class definition. |
|
| 701 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-event-entity-page-service.php'; |
|
| 702 | + |
|
| 703 | + /** Adapters. */ |
|
| 704 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 705 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 706 | + |
|
| 707 | + /** |
|
| 708 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 709 | + */ |
|
| 710 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 711 | + |
|
| 712 | + /** |
|
| 713 | + * The class to customize the entity list admin page. |
|
| 714 | + */ |
|
| 715 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 716 | + |
|
| 717 | + /** |
|
| 718 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 719 | + */ |
|
| 720 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 721 | + |
|
| 722 | + /** |
|
| 723 | + * The Notice service. |
|
| 724 | + */ |
|
| 725 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 726 | + |
|
| 727 | + /** |
|
| 728 | + * The PrimaShop adapter. |
|
| 729 | + */ |
|
| 730 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 731 | + |
|
| 732 | + /** |
|
| 733 | + * The WordLift Dashboard service. |
|
| 734 | + */ |
|
| 735 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 736 | + |
|
| 737 | + /** |
|
| 738 | + * The admin 'Install wizard' page. |
|
| 739 | + */ |
|
| 740 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 741 | + |
|
| 742 | + /** |
|
| 743 | + * The WordLift entity type list admin page controller. |
|
| 744 | + */ |
|
| 745 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 746 | + |
|
| 747 | + /** |
|
| 748 | + * The WordLift entity type settings admin page controller. |
|
| 749 | + */ |
|
| 750 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 751 | + |
|
| 752 | + /** |
|
| 753 | + * The admin 'Download Your Data' page. |
|
| 754 | + */ |
|
| 755 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 756 | + |
|
| 757 | + /** |
|
| 758 | + * The admin 'Download Your Data' page. |
|
| 759 | + */ |
|
| 760 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 761 | + |
|
| 762 | + /** |
|
| 763 | + * The admin 'WordLift Settings' page. |
|
| 764 | + */ |
|
| 765 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 766 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 767 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 768 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 769 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 770 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 771 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 772 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 773 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 774 | + |
|
| 775 | + /** Admin Pages */ |
|
| 776 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 777 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 778 | + |
|
| 779 | + /** |
|
| 780 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 781 | + * side of the site. |
|
| 782 | + */ |
|
| 783 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 784 | + |
|
| 785 | + /** |
|
| 786 | + * The shortcode abstract class. |
|
| 787 | + */ |
|
| 788 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 789 | + |
|
| 790 | + /** |
|
| 791 | + * The Timeline shortcode. |
|
| 792 | + */ |
|
| 793 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 794 | + |
|
| 795 | + /** |
|
| 796 | + * The Navigator shortcode. |
|
| 797 | + */ |
|
| 798 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 799 | + |
|
| 800 | + /** |
|
| 801 | + * The chord shortcode. |
|
| 802 | + */ |
|
| 803 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 804 | + |
|
| 805 | + /** |
|
| 806 | + * The geomap shortcode. |
|
| 807 | + */ |
|
| 808 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 809 | + |
|
| 810 | + /** |
|
| 811 | + * The entity cloud shortcode. |
|
| 812 | + */ |
|
| 813 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 741 | 814 | |
| 742 | - /** |
|
| 743 | - * The WordLift entity type list admin page controller. |
|
| 744 | - */ |
|
| 745 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 746 | - |
|
| 747 | - /** |
|
| 748 | - * The WordLift entity type settings admin page controller. |
|
| 749 | - */ |
|
| 750 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 751 | - |
|
| 752 | - /** |
|
| 753 | - * The admin 'Download Your Data' page. |
|
| 754 | - */ |
|
| 755 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 756 | - |
|
| 757 | - /** |
|
| 758 | - * The admin 'Download Your Data' page. |
|
| 759 | - */ |
|
| 760 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 761 | - |
|
| 762 | - /** |
|
| 763 | - * The admin 'WordLift Settings' page. |
|
| 764 | - */ |
|
| 765 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 766 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 767 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 768 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 769 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 770 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 771 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 772 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 773 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 774 | - |
|
| 775 | - /** Admin Pages */ |
|
| 776 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 777 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 778 | - |
|
| 779 | - /** |
|
| 780 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 781 | - * side of the site. |
|
| 782 | - */ |
|
| 783 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 784 | - |
|
| 785 | - /** |
|
| 786 | - * The shortcode abstract class. |
|
| 787 | - */ |
|
| 788 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 789 | - |
|
| 790 | - /** |
|
| 791 | - * The Timeline shortcode. |
|
| 792 | - */ |
|
| 793 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 794 | - |
|
| 795 | - /** |
|
| 796 | - * The Navigator shortcode. |
|
| 797 | - */ |
|
| 798 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 815 | + /** |
|
| 816 | + * The ShareThis service. |
|
| 817 | + */ |
|
| 818 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 799 | 819 | |
| 800 | - /** |
|
| 801 | - * The chord shortcode. |
|
| 802 | - */ |
|
| 803 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 820 | + /** |
|
| 821 | + * The SEO service. |
|
| 822 | + */ |
|
| 823 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 804 | 824 | |
| 805 | - /** |
|
| 806 | - * The geomap shortcode. |
|
| 807 | - */ |
|
| 808 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 809 | - |
|
| 810 | - /** |
|
| 811 | - * The entity cloud shortcode. |
|
| 812 | - */ |
|
| 813 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 814 | - |
|
| 815 | - /** |
|
| 816 | - * The ShareThis service. |
|
| 817 | - */ |
|
| 818 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 819 | - |
|
| 820 | - /** |
|
| 821 | - * The SEO service. |
|
| 822 | - */ |
|
| 823 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 824 | - |
|
| 825 | - /** |
|
| 826 | - * The AMP service. |
|
| 827 | - */ |
|
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 825 | + /** |
|
| 826 | + * The AMP service. |
|
| 827 | + */ |
|
| 828 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 829 | 829 | |
| 830 | - /** Widgets */ |
|
| 831 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 830 | + /** Widgets */ |
|
| 831 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 832 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 833 | 833 | |
| 834 | - $this->loader = new Wordlift_Loader(); |
|
| 834 | + $this->loader = new Wordlift_Loader(); |
|
| 835 | 835 | |
| 836 | - // Instantiate a global logger. |
|
| 837 | - global $wl_logger; |
|
| 838 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 836 | + // Instantiate a global logger. |
|
| 837 | + global $wl_logger; |
|
| 838 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 839 | 839 | |
| 840 | - // Create the configuration service. |
|
| 841 | - $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 840 | + // Create the configuration service. |
|
| 841 | + $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 842 | 842 | |
| 843 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 844 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 843 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 844 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 845 | 845 | |
| 846 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 847 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 846 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 847 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 848 | 848 | |
| 849 | - // Create an instance of the UI service. |
|
| 850 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 849 | + // Create an instance of the UI service. |
|
| 850 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 851 | 851 | |
| 852 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 853 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 852 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 853 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 854 | 854 | |
| 855 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 855 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 856 | 856 | |
| 857 | - // Create an instance of the Schema service. |
|
| 858 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 859 | - $this->schema_service = new Wordlift_Schema_Service(); |
|
| 857 | + // Create an instance of the Schema service. |
|
| 858 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 859 | + $this->schema_service = new Wordlift_Schema_Service(); |
|
| 860 | 860 | |
| 861 | - // Create an instance of the Notice service. |
|
| 862 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 861 | + // Create an instance of the Notice service. |
|
| 862 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 863 | 863 | |
| 864 | - // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 865 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service ); |
|
| 864 | + // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 865 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service ); |
|
| 866 | 866 | |
| 867 | - // Create an instance of the User service. |
|
| 868 | - $this->user_service = new Wordlift_User_Service(); |
|
| 867 | + // Create an instance of the User service. |
|
| 868 | + $this->user_service = new Wordlift_User_Service(); |
|
| 869 | 869 | |
| 870 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 871 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 870 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 871 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 872 | 872 | |
| 873 | - // Create a new instance of the Redirect service. |
|
| 874 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 873 | + // Create a new instance of the Redirect service. |
|
| 874 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 875 | 875 | |
| 876 | - // Initialize the shortcodes. |
|
| 877 | - new Wordlift_Navigator_Shortcode(); |
|
| 878 | - new Wordlift_Chord_Shortcode(); |
|
| 879 | - new Wordlift_Geomap_Shortcode(); |
|
| 880 | - new Wordlift_Timeline_Shortcode(); |
|
| 881 | - new Wordlift_Related_Entities_Cloud_Shortcode(); |
|
| 876 | + // Initialize the shortcodes. |
|
| 877 | + new Wordlift_Navigator_Shortcode(); |
|
| 878 | + new Wordlift_Chord_Shortcode(); |
|
| 879 | + new Wordlift_Geomap_Shortcode(); |
|
| 880 | + new Wordlift_Timeline_Shortcode(); |
|
| 881 | + new Wordlift_Related_Entities_Cloud_Shortcode(); |
|
| 882 | 882 | |
| 883 | - // Initialize the SEO service. |
|
| 884 | - new Wordlift_Seo_Service(); |
|
| 883 | + // Initialize the SEO service. |
|
| 884 | + new Wordlift_Seo_Service(); |
|
| 885 | 885 | |
| 886 | - // Initialize the AMP service. |
|
| 887 | - new Wordlift_AMP_Service(); |
|
| 886 | + // Initialize the AMP service. |
|
| 887 | + new Wordlift_AMP_Service(); |
|
| 888 | 888 | |
| 889 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 889 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 890 | 890 | |
| 891 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 891 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 892 | 892 | |
| 893 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 894 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 893 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 894 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 895 | 895 | |
| 896 | - // Create an instance of the PrimaShop adapter. |
|
| 897 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 896 | + // Create an instance of the PrimaShop adapter. |
|
| 897 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 898 | 898 | |
| 899 | - // Create an import service instance to hook later to WP's import function. |
|
| 900 | - $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() ); |
|
| 899 | + // Create an import service instance to hook later to WP's import function. |
|
| 900 | + $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() ); |
|
| 901 | 901 | |
| 902 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 902 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 903 | 903 | |
| 904 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 905 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 904 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 905 | + $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 906 | 906 | |
| 907 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 907 | + $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 908 | 908 | |
| 909 | - // Create the entity rating service. |
|
| 910 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 909 | + // Create the entity rating service. |
|
| 910 | + $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 911 | 911 | |
| 912 | - // Create entity list customization (wp-admin/edit.php) |
|
| 913 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 912 | + // Create entity list customization (wp-admin/edit.php) |
|
| 913 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 914 | 914 | |
| 915 | - // Create a new instance of the Redirect service. |
|
| 916 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service ); |
|
| 915 | + // Create a new instance of the Redirect service. |
|
| 916 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service ); |
|
| 917 | 917 | |
| 918 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 919 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 918 | + $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 919 | + $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 920 | 920 | |
| 921 | - $attachment_service = new Wordlift_Attachment_Service(); |
|
| 921 | + $attachment_service = new Wordlift_Attachment_Service(); |
|
| 922 | 922 | |
| 923 | - // Instantiate the JSON-LD service. |
|
| 924 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 925 | - $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 ); |
|
| 926 | - $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 ); |
|
| 927 | - $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 ); |
|
| 928 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter ); |
|
| 923 | + // Instantiate the JSON-LD service. |
|
| 924 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 925 | + $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 ); |
|
| 926 | + $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 ); |
|
| 927 | + $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 ); |
|
| 928 | + $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter ); |
|
| 929 | 929 | |
| 930 | - // Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins). |
|
| 931 | - $this->key_validation_service = new Wordlift_Key_Validation_Service(); |
|
| 930 | + // Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins). |
|
| 931 | + $this->key_validation_service = new Wordlift_Key_Validation_Service(); |
|
| 932 | 932 | |
| 933 | - // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 934 | - $publisher_service = new Wordlift_Publisher_Service(); |
|
| 935 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 933 | + // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 934 | + $publisher_service = new Wordlift_Publisher_Service(); |
|
| 935 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 936 | 936 | |
| 937 | - /** Adapters. */ |
|
| 938 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 937 | + /** Adapters. */ |
|
| 938 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 939 | 939 | |
| 940 | - /** WordPress Admin UI. */ |
|
| 940 | + /** WordPress Admin UI. */ |
|
| 941 | 941 | |
| 942 | - // UI elements. |
|
| 943 | - $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 944 | - $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 945 | - $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 946 | - $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 947 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 942 | + // UI elements. |
|
| 943 | + $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 944 | + $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 945 | + $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 946 | + $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 947 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 948 | 948 | |
| 949 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 950 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element ); |
|
| 951 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 949 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 950 | + $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element ); |
|
| 951 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 952 | 952 | |
| 953 | - // Pages. |
|
| 954 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 953 | + // Pages. |
|
| 954 | + new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 955 | 955 | |
| 956 | - // create an instance of the entity type list admin page controller. |
|
| 957 | - $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 956 | + // create an instance of the entity type list admin page controller. |
|
| 957 | + $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 958 | 958 | |
| 959 | - // create an instance of the entity type etting admin page controller. |
|
| 960 | - $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 959 | + // create an instance of the entity type etting admin page controller. |
|
| 960 | + $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 961 | 961 | |
| 962 | - /** Widgets */ |
|
| 963 | - $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 962 | + /** Widgets */ |
|
| 963 | + $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 964 | 964 | |
| 965 | - //** WordPress Admin */ |
|
| 966 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 967 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 965 | + //** WordPress Admin */ |
|
| 966 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 967 | + $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 968 | 968 | |
| 969 | - // Create an instance of the install wizard. |
|
| 970 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 969 | + // Create an instance of the install wizard. |
|
| 970 | + $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 971 | 971 | |
| 972 | - // Create an instance of the content filter service. |
|
| 973 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service ); |
|
| 972 | + // Create an instance of the content filter service. |
|
| 973 | + $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service ); |
|
| 974 | 974 | |
| 975 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 975 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 976 | 976 | |
| 977 | - $this->event_entity_page_service = new Wordlift_Event_Entity_Page_Service(); |
|
| 977 | + $this->event_entity_page_service = new Wordlift_Event_Entity_Page_Service(); |
|
| 978 | 978 | |
| 979 | - // Load the debug service if WP is in debug mode. |
|
| 980 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 981 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 982 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 983 | - } |
|
| 979 | + // Load the debug service if WP is in debug mode. |
|
| 980 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 981 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 982 | + new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 983 | + } |
|
| 984 | 984 | |
| 985 | - } |
|
| 985 | + } |
|
| 986 | 986 | |
| 987 | - /** |
|
| 988 | - * Define the locale for this plugin for internationalization. |
|
| 989 | - * |
|
| 990 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 991 | - * with WordPress. |
|
| 992 | - * |
|
| 993 | - * @since 1.0.0 |
|
| 994 | - * @access private |
|
| 995 | - */ |
|
| 996 | - private function set_locale() { |
|
| 987 | + /** |
|
| 988 | + * Define the locale for this plugin for internationalization. |
|
| 989 | + * |
|
| 990 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 991 | + * with WordPress. |
|
| 992 | + * |
|
| 993 | + * @since 1.0.0 |
|
| 994 | + * @access private |
|
| 995 | + */ |
|
| 996 | + private function set_locale() { |
|
| 997 | 997 | |
| 998 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 999 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 998 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 999 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1000 | 1000 | |
| 1001 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1001 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1002 | 1002 | |
| 1003 | - } |
|
| 1003 | + } |
|
| 1004 | 1004 | |
| 1005 | - /** |
|
| 1006 | - * Register all of the hooks related to the admin area functionality |
|
| 1007 | - * of the plugin. |
|
| 1008 | - * |
|
| 1009 | - * @since 1.0.0 |
|
| 1010 | - * @access private |
|
| 1011 | - */ |
|
| 1012 | - private function define_admin_hooks() { |
|
| 1005 | + /** |
|
| 1006 | + * Register all of the hooks related to the admin area functionality |
|
| 1007 | + * of the plugin. |
|
| 1008 | + * |
|
| 1009 | + * @since 1.0.0 |
|
| 1010 | + * @access private |
|
| 1011 | + */ |
|
| 1012 | + private function define_admin_hooks() { |
|
| 1013 | 1013 | |
| 1014 | - $plugin_admin = new Wordlift_Admin( |
|
| 1015 | - $this->get_plugin_name(), |
|
| 1016 | - $this->get_version(), |
|
| 1017 | - $this->configuration_service, |
|
| 1018 | - $this->notice_service |
|
| 1019 | - ); |
|
| 1014 | + $plugin_admin = new Wordlift_Admin( |
|
| 1015 | + $this->get_plugin_name(), |
|
| 1016 | + $this->get_version(), |
|
| 1017 | + $this->configuration_service, |
|
| 1018 | + $this->notice_service |
|
| 1019 | + ); |
|
| 1020 | 1020 | |
| 1021 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1022 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1021 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1022 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1023 | 1023 | |
| 1024 | - // Hook the init action to the Topic Taxonomy service. |
|
| 1025 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1024 | + // Hook the init action to the Topic Taxonomy service. |
|
| 1025 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1026 | 1026 | |
| 1027 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1028 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1027 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1028 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1029 | 1029 | |
| 1030 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 1031 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1030 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 1031 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1032 | 1032 | |
| 1033 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1034 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1033 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1034 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1035 | 1035 | |
| 1036 | - // Hook posts inserts (or updates) to the user service. |
|
| 1037 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 1036 | + // Hook posts inserts (or updates) to the user service. |
|
| 1037 | + $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 1038 | 1038 | |
| 1039 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1040 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1039 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1040 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1041 | 1041 | |
| 1042 | - // Register custom allowed redirect hosts. |
|
| 1043 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1044 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1045 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1046 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1047 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1048 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1049 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1042 | + // Register custom allowed redirect hosts. |
|
| 1043 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1044 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1045 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1046 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1047 | + $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1048 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1049 | + $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1050 | 1050 | |
| 1051 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1052 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1053 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1054 | - $this->loader->add_action( 'save_post_entity', $this->rating_service, 'set_rating_for', 10, 1 ); |
|
| 1051 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1052 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1053 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1054 | + $this->loader->add_action( 'save_post_entity', $this->rating_service, 'set_rating_for', 10, 1 ); |
|
| 1055 | 1055 | |
| 1056 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1057 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1056 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1057 | + $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1058 | 1058 | |
| 1059 | - // Entity listing customization (wp-admin/edit.php) |
|
| 1060 | - // Add custom columns |
|
| 1061 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1062 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1063 | - // Add 4W selection |
|
| 1064 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1065 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1059 | + // Entity listing customization (wp-admin/edit.php) |
|
| 1060 | + // Add custom columns |
|
| 1061 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1062 | + $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1063 | + // Add 4W selection |
|
| 1064 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1065 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1066 | 1066 | |
| 1067 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1067 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1068 | 1068 | |
| 1069 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1070 | - // entities. |
|
| 1071 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1069 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1070 | + // entities. |
|
| 1071 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1072 | 1072 | |
| 1073 | - // Filter imported post meta. |
|
| 1074 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1073 | + // Filter imported post meta. |
|
| 1074 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1075 | 1075 | |
| 1076 | - // Notify the import service when an import starts and ends. |
|
| 1077 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1078 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1079 | - |
|
| 1080 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1081 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1076 | + // Notify the import service when an import starts and ends. |
|
| 1077 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1078 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1079 | + |
|
| 1080 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1081 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1082 | 1082 | |
| 1083 | - // Hook the menu to the Download Your Data page. |
|
| 1084 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1085 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1086 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1087 | - |
|
| 1088 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1089 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1083 | + // Hook the menu to the Download Your Data page. |
|
| 1084 | + $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1085 | + $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1086 | + $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1087 | + |
|
| 1088 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1089 | + $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1090 | 1090 | |
| 1091 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1092 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1091 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1092 | + $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1093 | 1093 | |
| 1094 | - // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1095 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1094 | + // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1095 | + $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1096 | 1096 | |
| 1097 | - // Hook the `admin_init` function to the Admin Setup. |
|
| 1098 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1097 | + // Hook the `admin_init` function to the Admin Setup. |
|
| 1098 | + $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1099 | 1099 | |
| 1100 | - // Hook the admin_init to the settings page. |
|
| 1101 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1100 | + // Hook the admin_init to the settings page. |
|
| 1101 | + $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1102 | 1102 | |
| 1103 | - // Hook the menu creation on the general wordlift menu creation |
|
| 1104 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1105 | - |
|
| 1106 | - // Hook key update. |
|
| 1107 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1108 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1103 | + // Hook the menu creation on the general wordlift menu creation |
|
| 1104 | + $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1105 | + |
|
| 1106 | + // Hook key update. |
|
| 1107 | + $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1108 | + $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1109 | 1109 | |
| 1110 | - // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1111 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1110 | + // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1111 | + $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1112 | 1112 | |
| 1113 | - // Hook the AJAX `wl_publisher` action name. |
|
| 1114 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1113 | + // Hook the AJAX `wl_publisher` action name. |
|
| 1114 | + $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1115 | 1115 | |
| 1116 | - // Hook row actions for the entity type list admin. |
|
| 1117 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1116 | + // Hook row actions for the entity type list admin. |
|
| 1117 | + $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1118 | 1118 | |
| 1119 | - // Hook capabilities manipulation to allow access to entity type admin |
|
| 1120 | - // page on wordpress versions before 4.7. |
|
| 1121 | - global $wp_version; |
|
| 1122 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1123 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1124 | - } |
|
| 1119 | + // Hook capabilities manipulation to allow access to entity type admin |
|
| 1120 | + // page on wordpress versions before 4.7. |
|
| 1121 | + global $wp_version; |
|
| 1122 | + if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1123 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1124 | + } |
|
| 1125 | 1125 | |
| 1126 | - /** Adapters. */ |
|
| 1127 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1126 | + /** Adapters. */ |
|
| 1127 | + $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1128 | 1128 | |
| 1129 | - // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1130 | - if ( is_multisite() ) { |
|
| 1131 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1132 | - } |
|
| 1133 | - } |
|
| 1129 | + // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1130 | + if ( is_multisite() ) { |
|
| 1131 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1132 | + } |
|
| 1133 | + } |
|
| 1134 | 1134 | |
| 1135 | - /** |
|
| 1136 | - * Register all of the hooks related to the public-facing functionality |
|
| 1137 | - * of the plugin. |
|
| 1138 | - * |
|
| 1139 | - * @since 1.0.0 |
|
| 1140 | - * @access private |
|
| 1141 | - */ |
|
| 1142 | - private function define_public_hooks() { |
|
| 1135 | + /** |
|
| 1136 | + * Register all of the hooks related to the public-facing functionality |
|
| 1137 | + * of the plugin. |
|
| 1138 | + * |
|
| 1139 | + * @since 1.0.0 |
|
| 1140 | + * @access private |
|
| 1141 | + */ |
|
| 1142 | + private function define_public_hooks() { |
|
| 1143 | 1143 | |
| 1144 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1144 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1145 | 1145 | |
| 1146 | - // Register the entity post type. |
|
| 1147 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1146 | + // Register the entity post type. |
|
| 1147 | + $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1148 | 1148 | |
| 1149 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 1150 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1151 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 1152 | - $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 ); |
|
| 1153 | - $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 ); |
|
| 1149 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 1150 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1151 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 1152 | + $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 ); |
|
| 1153 | + $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 ); |
|
| 1154 | 1154 | |
| 1155 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1156 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1155 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1156 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1157 | 1157 | |
| 1158 | - // Hook the content filter service to add entity links. |
|
| 1159 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1158 | + // Hook the content filter service to add entity links. |
|
| 1159 | + $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1160 | 1160 | |
| 1161 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1162 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1161 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1162 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1163 | 1163 | |
| 1164 | - // Hook the ShareThis service. |
|
| 1165 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1166 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1164 | + // Hook the ShareThis service. |
|
| 1165 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1166 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1167 | 1167 | |
| 1168 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1169 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1168 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1169 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1170 | 1170 | |
| 1171 | - // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1172 | - // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1173 | - // to categories. |
|
| 1174 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1171 | + // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1172 | + // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1173 | + // to categories. |
|
| 1174 | + $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1175 | 1175 | |
| 1176 | - /* |
|
| 1176 | + /* |
|
| 1177 | 1177 | * Hook the `pre_get_posts` action to the `Wordlift_Event_Entity_Page_Service` |
| 1178 | 1178 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1179 | 1179 | * order of start time. |
| 1180 | 1180 | */ |
| 1181 | - $this->loader->add_action( 'pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1182 | - |
|
| 1183 | - } |
|
| 1184 | - |
|
| 1185 | - /** |
|
| 1186 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 1187 | - * |
|
| 1188 | - * @since 1.0.0 |
|
| 1189 | - */ |
|
| 1190 | - public function run() { |
|
| 1191 | - $this->loader->run(); |
|
| 1192 | - } |
|
| 1193 | - |
|
| 1194 | - /** |
|
| 1195 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 1196 | - * WordPress and to define internationalization functionality. |
|
| 1197 | - * |
|
| 1198 | - * @since 1.0.0 |
|
| 1199 | - * @return string The name of the plugin. |
|
| 1200 | - */ |
|
| 1201 | - public function get_plugin_name() { |
|
| 1202 | - return $this->plugin_name; |
|
| 1203 | - } |
|
| 1204 | - |
|
| 1205 | - /** |
|
| 1206 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1207 | - * |
|
| 1208 | - * @since 1.0.0 |
|
| 1209 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1210 | - */ |
|
| 1211 | - public function get_loader() { |
|
| 1212 | - return $this->loader; |
|
| 1213 | - } |
|
| 1214 | - |
|
| 1215 | - /** |
|
| 1216 | - * Retrieve the version number of the plugin. |
|
| 1217 | - * |
|
| 1218 | - * @since 1.0.0 |
|
| 1219 | - * @return string The version number of the plugin. |
|
| 1220 | - */ |
|
| 1221 | - public function get_version() { |
|
| 1222 | - return $this->version; |
|
| 1223 | - } |
|
| 1181 | + $this->loader->add_action( 'pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1182 | + |
|
| 1183 | + } |
|
| 1184 | + |
|
| 1185 | + /** |
|
| 1186 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 1187 | + * |
|
| 1188 | + * @since 1.0.0 |
|
| 1189 | + */ |
|
| 1190 | + public function run() { |
|
| 1191 | + $this->loader->run(); |
|
| 1192 | + } |
|
| 1193 | + |
|
| 1194 | + /** |
|
| 1195 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 1196 | + * WordPress and to define internationalization functionality. |
|
| 1197 | + * |
|
| 1198 | + * @since 1.0.0 |
|
| 1199 | + * @return string The name of the plugin. |
|
| 1200 | + */ |
|
| 1201 | + public function get_plugin_name() { |
|
| 1202 | + return $this->plugin_name; |
|
| 1203 | + } |
|
| 1204 | + |
|
| 1205 | + /** |
|
| 1206 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1207 | + * |
|
| 1208 | + * @since 1.0.0 |
|
| 1209 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1210 | + */ |
|
| 1211 | + public function get_loader() { |
|
| 1212 | + return $this->loader; |
|
| 1213 | + } |
|
| 1214 | + |
|
| 1215 | + /** |
|
| 1216 | + * Retrieve the version number of the plugin. |
|
| 1217 | + * |
|
| 1218 | + * @since 1.0.0 |
|
| 1219 | + * @return string The version number of the plugin. |
|
| 1220 | + */ |
|
| 1221 | + public function get_version() { |
|
| 1222 | + return $this->version; |
|
| 1223 | + } |
|
| 1224 | 1224 | |
| 1225 | 1225 | } |
@@ -11,189 +11,189 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Wordlift_Sparql_Service { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * A {@link Wordlift_Log_Service} instance. |
|
| 16 | - * |
|
| 17 | - * @since 3.6.0 |
|
| 18 | - * @access private |
|
| 19 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 20 | - */ |
|
| 21 | - private $log; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * The {@link Wordlift_Sparql_Service} singleton instance. |
|
| 25 | - * |
|
| 26 | - * @since 3.6.0 |
|
| 27 | - * @access private |
|
| 28 | - * @var \Wordlift_Sparql_Service $instance The {@link Wordlift_Sparql_Service} singleton instance. |
|
| 29 | - */ |
|
| 30 | - private static $instance; |
|
| 14 | + /** |
|
| 15 | + * A {@link Wordlift_Log_Service} instance. |
|
| 16 | + * |
|
| 17 | + * @since 3.6.0 |
|
| 18 | + * @access private |
|
| 19 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 20 | + */ |
|
| 21 | + private $log; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * The {@link Wordlift_Sparql_Service} singleton instance. |
|
| 25 | + * |
|
| 26 | + * @since 3.6.0 |
|
| 27 | + * @access private |
|
| 28 | + * @var \Wordlift_Sparql_Service $instance The {@link Wordlift_Sparql_Service} singleton instance. |
|
| 29 | + */ |
|
| 30 | + private static $instance; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Create a {@link Wordlift_Sparql_Service} instance. |
|
| 34 | - * |
|
| 35 | - * @since 3.6.0 |
|
| 36 | - */ |
|
| 37 | - public function __construct() { |
|
| 32 | + /** |
|
| 33 | + * Create a {@link Wordlift_Sparql_Service} instance. |
|
| 34 | + * |
|
| 35 | + * @since 3.6.0 |
|
| 36 | + */ |
|
| 37 | + public function __construct() { |
|
| 38 | 38 | |
| 39 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Sparql_Service' ); |
|
| 39 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Sparql_Service' ); |
|
| 40 | 40 | |
| 41 | - self::$instance = $this; |
|
| 41 | + self::$instance = $this; |
|
| 42 | 42 | |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Get the singleton instance of the {@link Wordlift_Sparql_Service}. |
|
| 47 | - * |
|
| 48 | - * @since 3.6.0 |
|
| 49 | - * @return \Wordlift_Sparql_Service |
|
| 50 | - */ |
|
| 51 | - public static function get_instance() { |
|
| 45 | + /** |
|
| 46 | + * Get the singleton instance of the {@link Wordlift_Sparql_Service}. |
|
| 47 | + * |
|
| 48 | + * @since 3.6.0 |
|
| 49 | + * @return \Wordlift_Sparql_Service |
|
| 50 | + */ |
|
| 51 | + public static function get_instance() { |
|
| 52 | 52 | |
| 53 | - return self::$instance; |
|
| 54 | - } |
|
| 53 | + return self::$instance; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Queue a SPARQL statement for execution. |
|
| 58 | - * |
|
| 59 | - * @since 3.6.0 |
|
| 60 | - * |
|
| 61 | - * @param string $stmt The SPARQL statement. |
|
| 62 | - */ |
|
| 63 | - public function queue( $stmt ) { |
|
| 56 | + /** |
|
| 57 | + * Queue a SPARQL statement for execution. |
|
| 58 | + * |
|
| 59 | + * @since 3.6.0 |
|
| 60 | + * |
|
| 61 | + * @param string $stmt The SPARQL statement. |
|
| 62 | + */ |
|
| 63 | + public function queue( $stmt ) { |
|
| 64 | 64 | |
| 65 | - rl_execute_sparql_update_query( $stmt ); |
|
| 65 | + rl_execute_sparql_update_query( $stmt ); |
|
| 66 | 66 | |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Execute the SELECT query. |
|
| 71 | - * |
|
| 72 | - * @since 3.12.2 |
|
| 73 | - * |
|
| 74 | - * @param string $query The SELECT query to execute. |
|
| 75 | - * |
|
| 76 | - * @return WP_Error|array The response or WP_Error on failure. |
|
| 77 | - */ |
|
| 78 | - public function select( $query ) { |
|
| 69 | + /** |
|
| 70 | + * Execute the SELECT query. |
|
| 71 | + * |
|
| 72 | + * @since 3.12.2 |
|
| 73 | + * |
|
| 74 | + * @param string $query The SELECT query to execute. |
|
| 75 | + * |
|
| 76 | + * @return WP_Error|array The response or WP_Error on failure. |
|
| 77 | + */ |
|
| 78 | + public function select( $query ) { |
|
| 79 | 79 | |
| 80 | - // Prepare the SPARQL statement by prepending the default namespaces. |
|
| 81 | - $sparql = rl_sparql_prefixes() . "\n" . $query; |
|
| 82 | - |
|
| 83 | - // Get the SPARQL SELECT URL. |
|
| 84 | - $url = wl_configuration_get_query_select_url( 'csv' ) . urlencode( $sparql ); |
|
| 85 | - |
|
| 86 | - // Prepare the request. |
|
| 87 | - $args = unserialize( WL_REDLINK_API_HTTP_OPTIONS ); |
|
| 88 | - |
|
| 89 | - return wp_remote_get( $url, $args ); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Formats the provided value according to the specified type in order to |
|
| 94 | - * insert the value using SPARQL. The value is also escaped. |
|
| 95 | - * |
|
| 96 | - * @since 3.6.0 |
|
| 97 | - * |
|
| 98 | - * @param string $value The value. |
|
| 99 | - * @param string $type The value type. |
|
| 100 | - * |
|
| 101 | - * @return string The formatted value for SPARQL statements. |
|
| 102 | - */ |
|
| 103 | - public function format( $value, $type ) { |
|
| 104 | - |
|
| 105 | - // see https://www.w3.org/TR/sparql11-query/. |
|
| 106 | - |
|
| 107 | - switch ( $type ) { |
|
| 108 | - |
|
| 109 | - case Wordlift_Schema_Service::DATA_TYPE_BOOLEAN: |
|
| 110 | - |
|
| 111 | - // SPARQL supports 'true' and 'false', so we evaluate the $value |
|
| 112 | - // and return true/false accordingly. |
|
| 113 | - return $value ? 'true' : 'false'; |
|
| 114 | - |
|
| 115 | - case Wordlift_Schema_Service::DATA_TYPE_DATE: |
|
| 116 | - |
|
| 117 | - return sprintf( '"%s"^^xsd:date', self::escape( $value ) ); |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - case Wordlift_Schema_Service::DATA_TYPE_DOUBLE: |
|
| 121 | - |
|
| 122 | - return sprintf( '"%s"^^xsd:double', self::escape( $value ) ); |
|
| 123 | - |
|
| 124 | - case Wordlift_Schema_Service::DATA_TYPE_INTEGER: |
|
| 125 | - |
|
| 126 | - return sprintf( '"%s"^^xsd:integer', self::escape( $value ) ); |
|
| 80 | + // Prepare the SPARQL statement by prepending the default namespaces. |
|
| 81 | + $sparql = rl_sparql_prefixes() . "\n" . $query; |
|
| 82 | + |
|
| 83 | + // Get the SPARQL SELECT URL. |
|
| 84 | + $url = wl_configuration_get_query_select_url( 'csv' ) . urlencode( $sparql ); |
|
| 85 | + |
|
| 86 | + // Prepare the request. |
|
| 87 | + $args = unserialize( WL_REDLINK_API_HTTP_OPTIONS ); |
|
| 88 | + |
|
| 89 | + return wp_remote_get( $url, $args ); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Formats the provided value according to the specified type in order to |
|
| 94 | + * insert the value using SPARQL. The value is also escaped. |
|
| 95 | + * |
|
| 96 | + * @since 3.6.0 |
|
| 97 | + * |
|
| 98 | + * @param string $value The value. |
|
| 99 | + * @param string $type The value type. |
|
| 100 | + * |
|
| 101 | + * @return string The formatted value for SPARQL statements. |
|
| 102 | + */ |
|
| 103 | + public function format( $value, $type ) { |
|
| 104 | + |
|
| 105 | + // see https://www.w3.org/TR/sparql11-query/. |
|
| 106 | + |
|
| 107 | + switch ( $type ) { |
|
| 108 | + |
|
| 109 | + case Wordlift_Schema_Service::DATA_TYPE_BOOLEAN: |
|
| 110 | + |
|
| 111 | + // SPARQL supports 'true' and 'false', so we evaluate the $value |
|
| 112 | + // and return true/false accordingly. |
|
| 113 | + return $value ? 'true' : 'false'; |
|
| 114 | + |
|
| 115 | + case Wordlift_Schema_Service::DATA_TYPE_DATE: |
|
| 116 | + |
|
| 117 | + return sprintf( '"%s"^^xsd:date', self::escape( $value ) ); |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + case Wordlift_Schema_Service::DATA_TYPE_DOUBLE: |
|
| 121 | + |
|
| 122 | + return sprintf( '"%s"^^xsd:double', self::escape( $value ) ); |
|
| 123 | + |
|
| 124 | + case Wordlift_Schema_Service::DATA_TYPE_INTEGER: |
|
| 125 | + |
|
| 126 | + return sprintf( '"%s"^^xsd:integer', self::escape( $value ) ); |
|
| 127 | 127 | |
| 128 | - case Wordlift_Schema_Service::DATA_TYPE_STRING: |
|
| 128 | + case Wordlift_Schema_Service::DATA_TYPE_STRING: |
|
| 129 | 129 | |
| 130 | - return sprintf( '"%s"^^xsd:string', self::escape( $value ) ); |
|
| 130 | + return sprintf( '"%s"^^xsd:string', self::escape( $value ) ); |
|
| 131 | 131 | |
| 132 | - case Wordlift_Schema_Service::DATA_TYPE_URI: |
|
| 132 | + case Wordlift_Schema_Service::DATA_TYPE_URI: |
|
| 133 | 133 | |
| 134 | - return sprintf( '<%s>', self::escape_uri( $value ) ); |
|
| 134 | + return sprintf( '<%s>', self::escape_uri( $value ) ); |
|
| 135 | 135 | |
| 136 | - default: |
|
| 136 | + default: |
|
| 137 | 137 | |
| 138 | - $this->log->warn( "Unknown data type [ type :: $type ]" ); |
|
| 138 | + $this->log->warn( "Unknown data type [ type :: $type ]" ); |
|
| 139 | 139 | |
| 140 | - // Try to insert the value anyway. |
|
| 141 | - return sprintf( '"%s"', self::escape( $value ) ); |
|
| 142 | - } |
|
| 140 | + // Try to insert the value anyway. |
|
| 141 | + return sprintf( '"%s"', self::escape( $value ) ); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Escapes an URI for a SPARQL statement. |
|
| 148 | - * |
|
| 149 | - * @since 3.6.0 |
|
| 150 | - * |
|
| 151 | - * @param string $uri The URI to escape. |
|
| 152 | - * |
|
| 153 | - * @return string The escaped URI. |
|
| 154 | - */ |
|
| 155 | - public static function escape_uri( $uri ) { |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Escapes an URI for a SPARQL statement. |
|
| 148 | + * |
|
| 149 | + * @since 3.6.0 |
|
| 150 | + * |
|
| 151 | + * @param string $uri The URI to escape. |
|
| 152 | + * |
|
| 153 | + * @return string The escaped URI. |
|
| 154 | + */ |
|
| 155 | + public static function escape_uri( $uri ) { |
|
| 156 | 156 | |
| 157 | - // Should we validate the IRI? |
|
| 158 | - // http://www.w3.org/TR/sparql11-query/#QSynIRI |
|
| 157 | + // Should we validate the IRI? |
|
| 158 | + // http://www.w3.org/TR/sparql11-query/#QSynIRI |
|
| 159 | 159 | |
| 160 | - $uri = str_replace( '<', '\<', $uri ); |
|
| 161 | - $uri = str_replace( '>', '\>', $uri ); |
|
| 160 | + $uri = str_replace( '<', '\<', $uri ); |
|
| 161 | + $uri = str_replace( '>', '\>', $uri ); |
|
| 162 | 162 | |
| 163 | - return $uri; |
|
| 164 | - } |
|
| 163 | + return $uri; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * Escapes a string for a SPARQL statement. |
|
| 168 | - * |
|
| 169 | - * @since 3.6.0 |
|
| 170 | - * |
|
| 171 | - * @param string $string The string to escape. |
|
| 172 | - * |
|
| 173 | - * @return string The escaped string. |
|
| 174 | - */ |
|
| 175 | - public static function escape( $string ) { |
|
| 166 | + /** |
|
| 167 | + * Escapes a string for a SPARQL statement. |
|
| 168 | + * |
|
| 169 | + * @since 3.6.0 |
|
| 170 | + * |
|
| 171 | + * @param string $string The string to escape. |
|
| 172 | + * |
|
| 173 | + * @return string The escaped string. |
|
| 174 | + */ |
|
| 175 | + public static function escape( $string ) { |
|
| 176 | 176 | |
| 177 | - // see http://www.w3.org/TR/rdf-sparql-query/ |
|
| 178 | - // '\t' U+0009 (tab) |
|
| 179 | - // '\n' U+000A (line feed) |
|
| 180 | - // '\r' U+000D (carriage return) |
|
| 181 | - // '\b' U+0008 (backspace) |
|
| 182 | - // '\f' U+000C (form feed) |
|
| 183 | - // '\"' U+0022 (quotation mark, double quote mark) |
|
| 184 | - // "\'" U+0027 (apostrophe-quote, single quote mark) |
|
| 185 | - // '\\' U+005C (backslash) |
|
| 177 | + // see http://www.w3.org/TR/rdf-sparql-query/ |
|
| 178 | + // '\t' U+0009 (tab) |
|
| 179 | + // '\n' U+000A (line feed) |
|
| 180 | + // '\r' U+000D (carriage return) |
|
| 181 | + // '\b' U+0008 (backspace) |
|
| 182 | + // '\f' U+000C (form feed) |
|
| 183 | + // '\"' U+0022 (quotation mark, double quote mark) |
|
| 184 | + // "\'" U+0027 (apostrophe-quote, single quote mark) |
|
| 185 | + // '\\' U+005C (backslash) |
|
| 186 | 186 | |
| 187 | - $string = str_replace( '\\', '\\\\', $string ); |
|
| 188 | - $string = str_replace( '\'', '\\\'', $string ); |
|
| 189 | - $string = str_replace( '"', '\\"', $string ); |
|
| 190 | - $string = str_replace( "\f", '\\f', $string ); |
|
| 191 | - $string = str_replace( "\b", '\\b', $string ); |
|
| 192 | - $string = str_replace( "\r", '\\r', $string ); |
|
| 193 | - $string = str_replace( "\n", '\\n', $string ); |
|
| 194 | - $string = str_replace( "\t", '\\t', $string ); |
|
| 187 | + $string = str_replace( '\\', '\\\\', $string ); |
|
| 188 | + $string = str_replace( '\'', '\\\'', $string ); |
|
| 189 | + $string = str_replace( '"', '\\"', $string ); |
|
| 190 | + $string = str_replace( "\f", '\\f', $string ); |
|
| 191 | + $string = str_replace( "\b", '\\b', $string ); |
|
| 192 | + $string = str_replace( "\r", '\\r', $string ); |
|
| 193 | + $string = str_replace( "\n", '\\n', $string ); |
|
| 194 | + $string = str_replace( "\t", '\\t', $string ); |
|
| 195 | 195 | |
| 196 | - return $string; |
|
| 197 | - } |
|
| 196 | + return $string; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | 199 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function __construct() { |
| 38 | 38 | |
| 39 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Sparql_Service' ); |
|
| 39 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Sparql_Service'); |
|
| 40 | 40 | |
| 41 | 41 | self::$instance = $this; |
| 42 | 42 | |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param string $stmt The SPARQL statement. |
| 62 | 62 | */ |
| 63 | - public function queue( $stmt ) { |
|
| 63 | + public function queue($stmt) { |
|
| 64 | 64 | |
| 65 | - rl_execute_sparql_update_query( $stmt ); |
|
| 65 | + rl_execute_sparql_update_query($stmt); |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
@@ -75,18 +75,18 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return WP_Error|array The response or WP_Error on failure. |
| 77 | 77 | */ |
| 78 | - public function select( $query ) { |
|
| 78 | + public function select($query) { |
|
| 79 | 79 | |
| 80 | 80 | // Prepare the SPARQL statement by prepending the default namespaces. |
| 81 | - $sparql = rl_sparql_prefixes() . "\n" . $query; |
|
| 81 | + $sparql = rl_sparql_prefixes()."\n".$query; |
|
| 82 | 82 | |
| 83 | 83 | // Get the SPARQL SELECT URL. |
| 84 | - $url = wl_configuration_get_query_select_url( 'csv' ) . urlencode( $sparql ); |
|
| 84 | + $url = wl_configuration_get_query_select_url('csv').urlencode($sparql); |
|
| 85 | 85 | |
| 86 | 86 | // Prepare the request. |
| 87 | - $args = unserialize( WL_REDLINK_API_HTTP_OPTIONS ); |
|
| 87 | + $args = unserialize(WL_REDLINK_API_HTTP_OPTIONS); |
|
| 88 | 88 | |
| 89 | - return wp_remote_get( $url, $args ); |
|
| 89 | + return wp_remote_get($url, $args); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @return string The formatted value for SPARQL statements. |
| 102 | 102 | */ |
| 103 | - public function format( $value, $type ) { |
|
| 103 | + public function format($value, $type) { |
|
| 104 | 104 | |
| 105 | 105 | // see https://www.w3.org/TR/sparql11-query/. |
| 106 | 106 | |
| 107 | - switch ( $type ) { |
|
| 107 | + switch ($type) { |
|
| 108 | 108 | |
| 109 | 109 | case Wordlift_Schema_Service::DATA_TYPE_BOOLEAN: |
| 110 | 110 | |
@@ -114,31 +114,31 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | case Wordlift_Schema_Service::DATA_TYPE_DATE: |
| 116 | 116 | |
| 117 | - return sprintf( '"%s"^^xsd:date', self::escape( $value ) ); |
|
| 117 | + return sprintf('"%s"^^xsd:date', self::escape($value)); |
|
| 118 | 118 | |
| 119 | 119 | |
| 120 | 120 | case Wordlift_Schema_Service::DATA_TYPE_DOUBLE: |
| 121 | 121 | |
| 122 | - return sprintf( '"%s"^^xsd:double', self::escape( $value ) ); |
|
| 122 | + return sprintf('"%s"^^xsd:double', self::escape($value)); |
|
| 123 | 123 | |
| 124 | 124 | case Wordlift_Schema_Service::DATA_TYPE_INTEGER: |
| 125 | 125 | |
| 126 | - return sprintf( '"%s"^^xsd:integer', self::escape( $value ) ); |
|
| 126 | + return sprintf('"%s"^^xsd:integer', self::escape($value)); |
|
| 127 | 127 | |
| 128 | 128 | case Wordlift_Schema_Service::DATA_TYPE_STRING: |
| 129 | 129 | |
| 130 | - return sprintf( '"%s"^^xsd:string', self::escape( $value ) ); |
|
| 130 | + return sprintf('"%s"^^xsd:string', self::escape($value)); |
|
| 131 | 131 | |
| 132 | 132 | case Wordlift_Schema_Service::DATA_TYPE_URI: |
| 133 | 133 | |
| 134 | - return sprintf( '<%s>', self::escape_uri( $value ) ); |
|
| 134 | + return sprintf('<%s>', self::escape_uri($value)); |
|
| 135 | 135 | |
| 136 | 136 | default: |
| 137 | 137 | |
| 138 | - $this->log->warn( "Unknown data type [ type :: $type ]" ); |
|
| 138 | + $this->log->warn("Unknown data type [ type :: $type ]"); |
|
| 139 | 139 | |
| 140 | 140 | // Try to insert the value anyway. |
| 141 | - return sprintf( '"%s"', self::escape( $value ) ); |
|
| 141 | + return sprintf('"%s"', self::escape($value)); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | } |
@@ -152,13 +152,13 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return string The escaped URI. |
| 154 | 154 | */ |
| 155 | - public static function escape_uri( $uri ) { |
|
| 155 | + public static function escape_uri($uri) { |
|
| 156 | 156 | |
| 157 | 157 | // Should we validate the IRI? |
| 158 | 158 | // http://www.w3.org/TR/sparql11-query/#QSynIRI |
| 159 | 159 | |
| 160 | - $uri = str_replace( '<', '\<', $uri ); |
|
| 161 | - $uri = str_replace( '>', '\>', $uri ); |
|
| 160 | + $uri = str_replace('<', '\<', $uri); |
|
| 161 | + $uri = str_replace('>', '\>', $uri); |
|
| 162 | 162 | |
| 163 | 163 | return $uri; |
| 164 | 164 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return string The escaped string. |
| 174 | 174 | */ |
| 175 | - public static function escape( $string ) { |
|
| 175 | + public static function escape($string) { |
|
| 176 | 176 | |
| 177 | 177 | // see http://www.w3.org/TR/rdf-sparql-query/ |
| 178 | 178 | // '\t' U+0009 (tab) |
@@ -184,14 +184,14 @@ discard block |
||
| 184 | 184 | // "\'" U+0027 (apostrophe-quote, single quote mark) |
| 185 | 185 | // '\\' U+005C (backslash) |
| 186 | 186 | |
| 187 | - $string = str_replace( '\\', '\\\\', $string ); |
|
| 188 | - $string = str_replace( '\'', '\\\'', $string ); |
|
| 189 | - $string = str_replace( '"', '\\"', $string ); |
|
| 190 | - $string = str_replace( "\f", '\\f', $string ); |
|
| 191 | - $string = str_replace( "\b", '\\b', $string ); |
|
| 192 | - $string = str_replace( "\r", '\\r', $string ); |
|
| 193 | - $string = str_replace( "\n", '\\n', $string ); |
|
| 194 | - $string = str_replace( "\t", '\\t', $string ); |
|
| 187 | + $string = str_replace('\\', '\\\\', $string); |
|
| 188 | + $string = str_replace('\'', '\\\'', $string); |
|
| 189 | + $string = str_replace('"', '\\"', $string); |
|
| 190 | + $string = str_replace("\f", '\\f', $string); |
|
| 191 | + $string = str_replace("\b", '\\b', $string); |
|
| 192 | + $string = str_replace("\r", '\\r', $string); |
|
| 193 | + $string = str_replace("\n", '\\n', $string); |
|
| 194 | + $string = str_replace("\t", '\\t', $string); |
|
| 195 | 195 | |
| 196 | 196 | return $string; |
| 197 | 197 | } |
@@ -7,291 +7,291 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_Query_Builder { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * The INSERT statement template. |
|
| 12 | - * |
|
| 13 | - * @since 3.1.7 |
|
| 14 | - */ |
|
| 15 | - const INSERT = 'INSERT DATA { %s };'; |
|
| 16 | - |
|
| 17 | - /** |
|
| 18 | - * The DELETE statement template (it repeats the statements in the WHERE clause. |
|
| 19 | - * |
|
| 20 | - * @since 3.1.7 |
|
| 21 | - */ |
|
| 22 | - const DELETE = 'DELETE { %s } WHERE { %1$s };'; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Tell the statement function to guess the object type (URI, value or parameter). |
|
| 26 | - * |
|
| 27 | - * @since 3.1.7 |
|
| 28 | - */ |
|
| 29 | - const OBJECT_AUTO = - 1; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Tell the statement function that the object is a URI. |
|
| 33 | - * |
|
| 34 | - * @since 3.1.7 |
|
| 35 | - */ |
|
| 36 | - const OBJECT_URI = 0; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Tell the statement function that the object is a value. |
|
| 40 | - * |
|
| 41 | - * @since 3.1.7 |
|
| 42 | - */ |
|
| 43 | - const OBJECT_VALUE = 1; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Tell the statement function that the object is a parameter. |
|
| 47 | - * |
|
| 48 | - * @since 3.1.7 |
|
| 49 | - */ |
|
| 50 | - const OBJECT_PARAMETER = 2; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * The RDFS type. |
|
| 54 | - * |
|
| 55 | - * @since 3.1.7 |
|
| 56 | - */ |
|
| 57 | - const RDFS_TYPE_URI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * The schema.org/Person type. |
|
| 61 | - * |
|
| 62 | - * @since 3.1.7 |
|
| 63 | - */ |
|
| 64 | - const SCHEMA_PERSON_URI = 'http://schema.org/Person'; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * The schema.org given name predicate. |
|
| 68 | - * |
|
| 69 | - * @since 3.1.7 |
|
| 70 | - */ |
|
| 71 | - const SCHEMA_GIVEN_NAME_URI = 'http://schema.org/givenName'; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * The schema.org family name predicate. |
|
| 75 | - * |
|
| 76 | - * @since 3.1.7 |
|
| 77 | - */ |
|
| 78 | - const SCHEMA_FAMILY_NAME_URI = 'http://schema.org/familyName'; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * The schema.org url predicate. |
|
| 82 | - * |
|
| 83 | - * @since 3.1.7 |
|
| 84 | - */ |
|
| 85 | - const SCHEMA_URL_URI = 'http://schema.org/url'; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @since 3.14.0 |
|
| 89 | - */ |
|
| 90 | - const SCHEMA_IMAGE_URI = 'http://schema.org/image'; |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * The location created predicate. |
|
| 94 | - * |
|
| 95 | - * @since 3.14.0 |
|
| 96 | - */ |
|
| 97 | - const SCHEMA_LOCATION_CREATED_URI = 'http://schema.org/locationCreated'; |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @since 3.14.0 |
|
| 101 | - */ |
|
| 102 | - const SCHEMA_AUTHOR_URI = 'http://schema.org/author'; |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @since 3.14.0 |
|
| 106 | - */ |
|
| 107 | - const SCHEMA_INTERACTION_COUNT_URI = 'http://schema.org/interactionCount'; |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @since 3.14.0 |
|
| 111 | - */ |
|
| 112 | - const DCTERMS_SUBJECT_URI = 'http://purl.org/dc/terms/subject'; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @since 3.14.0 |
|
| 116 | - */ |
|
| 117 | - const DCTERMS_REFERENCES_URI = 'http://purl.org/dc/terms/references'; |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * The RDF label. |
|
| 121 | - * |
|
| 122 | - * @since 3.1.7 |
|
| 123 | - */ |
|
| 124 | - const RDFS_LABEL_URI = 'http://www.w3.org/2000/01/rdf-schema#label'; |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Hold the template (INSERT or DELETE). |
|
| 128 | - * |
|
| 129 | - * @since 3.1.7 |
|
| 130 | - * @access private |
|
| 131 | - * @var string $template The query template. |
|
| 132 | - */ |
|
| 133 | - private $template; |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * An array of statements (in the form of subject, predicate, object). |
|
| 137 | - * |
|
| 138 | - * @since 3.1.7 |
|
| 139 | - * @access private |
|
| 140 | - * @var array $statements An array of statements. |
|
| 141 | - */ |
|
| 142 | - private $statements = array(); |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * Create a new instance of the Query builder (compatible with PHP 5.3). |
|
| 146 | - * |
|
| 147 | - * @since 3.1.7 |
|
| 148 | - * @return Wordlift_Query_Builder A new instance of the Query builder. |
|
| 149 | - */ |
|
| 150 | - public static function new_instance() { |
|
| 151 | - |
|
| 152 | - return new Wordlift_Query_Builder(); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Set the query to INSERT. |
|
| 157 | - * |
|
| 158 | - * @since 3.1.7 |
|
| 159 | - * @return Wordlift_Query_Builder The Query builder. |
|
| 160 | - */ |
|
| 161 | - public function insert() { |
|
| 162 | - |
|
| 163 | - $this->template = self::INSERT; |
|
| 164 | - |
|
| 165 | - return $this; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Set the query to DELETE. |
|
| 170 | - * |
|
| 171 | - * @since 3.1.7 |
|
| 172 | - * @return $this \Wordlift_Query_Builder The Query builder. |
|
| 173 | - */ |
|
| 174 | - public function delete() { |
|
| 175 | - |
|
| 176 | - $this->template = self::DELETE; |
|
| 177 | - |
|
| 178 | - return $this; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * Set the query to SELECT. |
|
| 183 | - * |
|
| 184 | - * @since 3.12.2 |
|
| 185 | - * |
|
| 186 | - * @param string $props The list of properties to read. |
|
| 187 | - * |
|
| 188 | - * @return $this \Wordlift_Query_Builder The Query builder. |
|
| 189 | - */ |
|
| 190 | - public function select( $props = '*' ) { |
|
| 191 | - |
|
| 192 | - $this->template = "SELECT $props WHERE { %s }"; |
|
| 193 | - |
|
| 194 | - return $this; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * Add a statement. |
|
| 199 | - * |
|
| 200 | - * @since 3.1.7 |
|
| 201 | - * |
|
| 202 | - * @param string $subject The subject of the statement (must be a URI). |
|
| 203 | - * @param string $predicate The predicate (must be a URI). |
|
| 204 | - * @param string $object The object, can be a URI or a value. |
|
| 205 | - * @param int $object_type The object type, either a {@link OBJECT_URI} or a value {@link OBJECT_VALUE}. If set to {@link OBJECT_AUTO}, the Query builder will try to guess. |
|
| 206 | - * @param string|null $data_type The data type (or null). |
|
| 207 | - * @param string|null $language The language code (or null). |
|
| 208 | - * |
|
| 209 | - * @return $this \Wordlift_Query_Builder The Query builder. |
|
| 210 | - */ |
|
| 211 | - public function statement( $subject, $predicate, $object, $object_type = self::OBJECT_AUTO, $data_type = null, $language = null ) { |
|
| 212 | - |
|
| 213 | - // If no value has been provided, we don't set any statement. |
|
| 214 | - if ( empty( $object ) ) { |
|
| 215 | - return $this; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - // Guess the subject type. |
|
| 219 | - $subject_value_type = $this->guess_object_type( $predicate, $object ); |
|
| 220 | - |
|
| 221 | - // Get the object type if set, otherwise try to guess it. |
|
| 222 | - $object_value_type = ( self::OBJECT_AUTO === $object_type ? $this->guess_object_type( $predicate, $object ) : $object_type ); |
|
| 223 | - |
|
| 224 | - // Prepare the statement template. |
|
| 225 | - $template = |
|
| 226 | - // Subject as a parameter, no `<`, `>`. |
|
| 227 | - ( self::OBJECT_PARAMETER === $subject_value_type ? '%1$s' : '<%1$s>' ) . |
|
| 228 | - // Predicate. |
|
| 229 | - ' <%2$s> ' . |
|
| 230 | - // Object. |
|
| 231 | - ( self::OBJECT_URI === $object_value_type ? '<%3$s>' : |
|
| 232 | - ( self::OBJECT_PARAMETER === $object_value_type ? '%3$s' : |
|
| 233 | - // self::OBJECT_VALUE === $object_value_type |
|
| 234 | - '"%3$s"' . ( isset( $data_type ) ? '^^%4$s' : '' ) . ( isset( $language ) ? '@%5$s' : '' ) ) ); |
|
| 235 | - |
|
| 236 | - // Escape the subject, predicate and object. |
|
| 237 | - $escaped_subject = Wordlift_Sparql_Service::escape_uri( $subject ); |
|
| 238 | - $escaped_predicate = Wordlift_Sparql_Service::escape_uri( $predicate ); |
|
| 239 | - $escaped_object = ( self::OBJECT_URI === $object_value_type ? Wordlift_Sparql_Service::escape_uri( $object ) : Wordlift_Sparql_Service::escape( $object ) ); |
|
| 240 | - |
|
| 241 | - // Prepare the statement and add it to the list of statements. |
|
| 242 | - $this->statements[] = sprintf( $template, $escaped_subject, $escaped_predicate, $escaped_object, $data_type, $language ); |
|
| 243 | - |
|
| 244 | - return $this; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * Build the query. |
|
| 249 | - * |
|
| 250 | - * @since 3.1.7 |
|
| 251 | - * @return string The query string. |
|
| 252 | - */ |
|
| 253 | - public function build() { |
|
| 254 | - |
|
| 255 | - // If there are no statements return an empty string. |
|
| 256 | - if ( 0 === count( $this->statements ) ) { |
|
| 257 | - return ''; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - return sprintf( $this->template, implode( ' . ', $this->statements ) ) . "\n"; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * Guess the statement object type. |
|
| 265 | - * |
|
| 266 | - * @since 3.1.7 |
|
| 267 | - * |
|
| 268 | - * @param string $predicate The predicate. |
|
| 269 | - * @param string $object The object. |
|
| 270 | - * |
|
| 271 | - * @return int {@link Wordlift_Query_Builder::OBJECT_URI} if the Query builder thinks the object must be an URI, {@link Wordlift_Query_Builder::OBJECT_VALUE} otherwise. |
|
| 272 | - */ |
|
| 273 | - private function guess_object_type( $predicate, $object ) { |
|
| 274 | - |
|
| 275 | - // If the object starts with a question mark, it's a parameter. |
|
| 276 | - if ( 0 === strpos( $object, '?' ) ) { |
|
| 277 | - return self::OBJECT_PARAMETER; |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - // Guess based on the predicate. |
|
| 281 | - switch ( $predicate ) { |
|
| 282 | - |
|
| 283 | - case self::DCTERMS_REFERENCES_URI: |
|
| 284 | - case self::DCTERMS_SUBJECT_URI: |
|
| 285 | - case self::RDFS_TYPE_URI: |
|
| 286 | - case self::SCHEMA_AUTHOR_URI: |
|
| 287 | - case self::SCHEMA_LOCATION_CREATED_URI: |
|
| 288 | - case self::SCHEMA_URL_URI: |
|
| 289 | - case self::SCHEMA_IMAGE_URI: |
|
| 290 | - return self::OBJECT_URI; |
|
| 291 | - |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - return self::OBJECT_VALUE; |
|
| 295 | - } |
|
| 10 | + /** |
|
| 11 | + * The INSERT statement template. |
|
| 12 | + * |
|
| 13 | + * @since 3.1.7 |
|
| 14 | + */ |
|
| 15 | + const INSERT = 'INSERT DATA { %s };'; |
|
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * The DELETE statement template (it repeats the statements in the WHERE clause. |
|
| 19 | + * |
|
| 20 | + * @since 3.1.7 |
|
| 21 | + */ |
|
| 22 | + const DELETE = 'DELETE { %s } WHERE { %1$s };'; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Tell the statement function to guess the object type (URI, value or parameter). |
|
| 26 | + * |
|
| 27 | + * @since 3.1.7 |
|
| 28 | + */ |
|
| 29 | + const OBJECT_AUTO = - 1; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Tell the statement function that the object is a URI. |
|
| 33 | + * |
|
| 34 | + * @since 3.1.7 |
|
| 35 | + */ |
|
| 36 | + const OBJECT_URI = 0; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Tell the statement function that the object is a value. |
|
| 40 | + * |
|
| 41 | + * @since 3.1.7 |
|
| 42 | + */ |
|
| 43 | + const OBJECT_VALUE = 1; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Tell the statement function that the object is a parameter. |
|
| 47 | + * |
|
| 48 | + * @since 3.1.7 |
|
| 49 | + */ |
|
| 50 | + const OBJECT_PARAMETER = 2; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * The RDFS type. |
|
| 54 | + * |
|
| 55 | + * @since 3.1.7 |
|
| 56 | + */ |
|
| 57 | + const RDFS_TYPE_URI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * The schema.org/Person type. |
|
| 61 | + * |
|
| 62 | + * @since 3.1.7 |
|
| 63 | + */ |
|
| 64 | + const SCHEMA_PERSON_URI = 'http://schema.org/Person'; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * The schema.org given name predicate. |
|
| 68 | + * |
|
| 69 | + * @since 3.1.7 |
|
| 70 | + */ |
|
| 71 | + const SCHEMA_GIVEN_NAME_URI = 'http://schema.org/givenName'; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * The schema.org family name predicate. |
|
| 75 | + * |
|
| 76 | + * @since 3.1.7 |
|
| 77 | + */ |
|
| 78 | + const SCHEMA_FAMILY_NAME_URI = 'http://schema.org/familyName'; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * The schema.org url predicate. |
|
| 82 | + * |
|
| 83 | + * @since 3.1.7 |
|
| 84 | + */ |
|
| 85 | + const SCHEMA_URL_URI = 'http://schema.org/url'; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @since 3.14.0 |
|
| 89 | + */ |
|
| 90 | + const SCHEMA_IMAGE_URI = 'http://schema.org/image'; |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * The location created predicate. |
|
| 94 | + * |
|
| 95 | + * @since 3.14.0 |
|
| 96 | + */ |
|
| 97 | + const SCHEMA_LOCATION_CREATED_URI = 'http://schema.org/locationCreated'; |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @since 3.14.0 |
|
| 101 | + */ |
|
| 102 | + const SCHEMA_AUTHOR_URI = 'http://schema.org/author'; |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @since 3.14.0 |
|
| 106 | + */ |
|
| 107 | + const SCHEMA_INTERACTION_COUNT_URI = 'http://schema.org/interactionCount'; |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @since 3.14.0 |
|
| 111 | + */ |
|
| 112 | + const DCTERMS_SUBJECT_URI = 'http://purl.org/dc/terms/subject'; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * @since 3.14.0 |
|
| 116 | + */ |
|
| 117 | + const DCTERMS_REFERENCES_URI = 'http://purl.org/dc/terms/references'; |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * The RDF label. |
|
| 121 | + * |
|
| 122 | + * @since 3.1.7 |
|
| 123 | + */ |
|
| 124 | + const RDFS_LABEL_URI = 'http://www.w3.org/2000/01/rdf-schema#label'; |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Hold the template (INSERT or DELETE). |
|
| 128 | + * |
|
| 129 | + * @since 3.1.7 |
|
| 130 | + * @access private |
|
| 131 | + * @var string $template The query template. |
|
| 132 | + */ |
|
| 133 | + private $template; |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * An array of statements (in the form of subject, predicate, object). |
|
| 137 | + * |
|
| 138 | + * @since 3.1.7 |
|
| 139 | + * @access private |
|
| 140 | + * @var array $statements An array of statements. |
|
| 141 | + */ |
|
| 142 | + private $statements = array(); |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * Create a new instance of the Query builder (compatible with PHP 5.3). |
|
| 146 | + * |
|
| 147 | + * @since 3.1.7 |
|
| 148 | + * @return Wordlift_Query_Builder A new instance of the Query builder. |
|
| 149 | + */ |
|
| 150 | + public static function new_instance() { |
|
| 151 | + |
|
| 152 | + return new Wordlift_Query_Builder(); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Set the query to INSERT. |
|
| 157 | + * |
|
| 158 | + * @since 3.1.7 |
|
| 159 | + * @return Wordlift_Query_Builder The Query builder. |
|
| 160 | + */ |
|
| 161 | + public function insert() { |
|
| 162 | + |
|
| 163 | + $this->template = self::INSERT; |
|
| 164 | + |
|
| 165 | + return $this; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Set the query to DELETE. |
|
| 170 | + * |
|
| 171 | + * @since 3.1.7 |
|
| 172 | + * @return $this \Wordlift_Query_Builder The Query builder. |
|
| 173 | + */ |
|
| 174 | + public function delete() { |
|
| 175 | + |
|
| 176 | + $this->template = self::DELETE; |
|
| 177 | + |
|
| 178 | + return $this; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * Set the query to SELECT. |
|
| 183 | + * |
|
| 184 | + * @since 3.12.2 |
|
| 185 | + * |
|
| 186 | + * @param string $props The list of properties to read. |
|
| 187 | + * |
|
| 188 | + * @return $this \Wordlift_Query_Builder The Query builder. |
|
| 189 | + */ |
|
| 190 | + public function select( $props = '*' ) { |
|
| 191 | + |
|
| 192 | + $this->template = "SELECT $props WHERE { %s }"; |
|
| 193 | + |
|
| 194 | + return $this; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * Add a statement. |
|
| 199 | + * |
|
| 200 | + * @since 3.1.7 |
|
| 201 | + * |
|
| 202 | + * @param string $subject The subject of the statement (must be a URI). |
|
| 203 | + * @param string $predicate The predicate (must be a URI). |
|
| 204 | + * @param string $object The object, can be a URI or a value. |
|
| 205 | + * @param int $object_type The object type, either a {@link OBJECT_URI} or a value {@link OBJECT_VALUE}. If set to {@link OBJECT_AUTO}, the Query builder will try to guess. |
|
| 206 | + * @param string|null $data_type The data type (or null). |
|
| 207 | + * @param string|null $language The language code (or null). |
|
| 208 | + * |
|
| 209 | + * @return $this \Wordlift_Query_Builder The Query builder. |
|
| 210 | + */ |
|
| 211 | + public function statement( $subject, $predicate, $object, $object_type = self::OBJECT_AUTO, $data_type = null, $language = null ) { |
|
| 212 | + |
|
| 213 | + // If no value has been provided, we don't set any statement. |
|
| 214 | + if ( empty( $object ) ) { |
|
| 215 | + return $this; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + // Guess the subject type. |
|
| 219 | + $subject_value_type = $this->guess_object_type( $predicate, $object ); |
|
| 220 | + |
|
| 221 | + // Get the object type if set, otherwise try to guess it. |
|
| 222 | + $object_value_type = ( self::OBJECT_AUTO === $object_type ? $this->guess_object_type( $predicate, $object ) : $object_type ); |
|
| 223 | + |
|
| 224 | + // Prepare the statement template. |
|
| 225 | + $template = |
|
| 226 | + // Subject as a parameter, no `<`, `>`. |
|
| 227 | + ( self::OBJECT_PARAMETER === $subject_value_type ? '%1$s' : '<%1$s>' ) . |
|
| 228 | + // Predicate. |
|
| 229 | + ' <%2$s> ' . |
|
| 230 | + // Object. |
|
| 231 | + ( self::OBJECT_URI === $object_value_type ? '<%3$s>' : |
|
| 232 | + ( self::OBJECT_PARAMETER === $object_value_type ? '%3$s' : |
|
| 233 | + // self::OBJECT_VALUE === $object_value_type |
|
| 234 | + '"%3$s"' . ( isset( $data_type ) ? '^^%4$s' : '' ) . ( isset( $language ) ? '@%5$s' : '' ) ) ); |
|
| 235 | + |
|
| 236 | + // Escape the subject, predicate and object. |
|
| 237 | + $escaped_subject = Wordlift_Sparql_Service::escape_uri( $subject ); |
|
| 238 | + $escaped_predicate = Wordlift_Sparql_Service::escape_uri( $predicate ); |
|
| 239 | + $escaped_object = ( self::OBJECT_URI === $object_value_type ? Wordlift_Sparql_Service::escape_uri( $object ) : Wordlift_Sparql_Service::escape( $object ) ); |
|
| 240 | + |
|
| 241 | + // Prepare the statement and add it to the list of statements. |
|
| 242 | + $this->statements[] = sprintf( $template, $escaped_subject, $escaped_predicate, $escaped_object, $data_type, $language ); |
|
| 243 | + |
|
| 244 | + return $this; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * Build the query. |
|
| 249 | + * |
|
| 250 | + * @since 3.1.7 |
|
| 251 | + * @return string The query string. |
|
| 252 | + */ |
|
| 253 | + public function build() { |
|
| 254 | + |
|
| 255 | + // If there are no statements return an empty string. |
|
| 256 | + if ( 0 === count( $this->statements ) ) { |
|
| 257 | + return ''; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + return sprintf( $this->template, implode( ' . ', $this->statements ) ) . "\n"; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * Guess the statement object type. |
|
| 265 | + * |
|
| 266 | + * @since 3.1.7 |
|
| 267 | + * |
|
| 268 | + * @param string $predicate The predicate. |
|
| 269 | + * @param string $object The object. |
|
| 270 | + * |
|
| 271 | + * @return int {@link Wordlift_Query_Builder::OBJECT_URI} if the Query builder thinks the object must be an URI, {@link Wordlift_Query_Builder::OBJECT_VALUE} otherwise. |
|
| 272 | + */ |
|
| 273 | + private function guess_object_type( $predicate, $object ) { |
|
| 274 | + |
|
| 275 | + // If the object starts with a question mark, it's a parameter. |
|
| 276 | + if ( 0 === strpos( $object, '?' ) ) { |
|
| 277 | + return self::OBJECT_PARAMETER; |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + // Guess based on the predicate. |
|
| 281 | + switch ( $predicate ) { |
|
| 282 | + |
|
| 283 | + case self::DCTERMS_REFERENCES_URI: |
|
| 284 | + case self::DCTERMS_SUBJECT_URI: |
|
| 285 | + case self::RDFS_TYPE_URI: |
|
| 286 | + case self::SCHEMA_AUTHOR_URI: |
|
| 287 | + case self::SCHEMA_LOCATION_CREATED_URI: |
|
| 288 | + case self::SCHEMA_URL_URI: |
|
| 289 | + case self::SCHEMA_IMAGE_URI: |
|
| 290 | + return self::OBJECT_URI; |
|
| 291 | + |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + return self::OBJECT_VALUE; |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | 297 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @return $this \Wordlift_Query_Builder The Query builder. |
| 189 | 189 | */ |
| 190 | - public function select( $props = '*' ) { |
|
| 190 | + public function select($props = '*') { |
|
| 191 | 191 | |
| 192 | 192 | $this->template = "SELECT $props WHERE { %s }"; |
| 193 | 193 | |
@@ -208,38 +208,36 @@ discard block |
||
| 208 | 208 | * |
| 209 | 209 | * @return $this \Wordlift_Query_Builder The Query builder. |
| 210 | 210 | */ |
| 211 | - public function statement( $subject, $predicate, $object, $object_type = self::OBJECT_AUTO, $data_type = null, $language = null ) { |
|
| 211 | + public function statement($subject, $predicate, $object, $object_type = self::OBJECT_AUTO, $data_type = null, $language = null) { |
|
| 212 | 212 | |
| 213 | 213 | // If no value has been provided, we don't set any statement. |
| 214 | - if ( empty( $object ) ) { |
|
| 214 | + if (empty($object)) { |
|
| 215 | 215 | return $this; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Guess the subject type. |
| 219 | - $subject_value_type = $this->guess_object_type( $predicate, $object ); |
|
| 219 | + $subject_value_type = $this->guess_object_type($predicate, $object); |
|
| 220 | 220 | |
| 221 | 221 | // Get the object type if set, otherwise try to guess it. |
| 222 | - $object_value_type = ( self::OBJECT_AUTO === $object_type ? $this->guess_object_type( $predicate, $object ) : $object_type ); |
|
| 222 | + $object_value_type = (self::OBJECT_AUTO === $object_type ? $this->guess_object_type($predicate, $object) : $object_type); |
|
| 223 | 223 | |
| 224 | 224 | // Prepare the statement template. |
| 225 | 225 | $template = |
| 226 | 226 | // Subject as a parameter, no `<`, `>`. |
| 227 | - ( self::OBJECT_PARAMETER === $subject_value_type ? '%1$s' : '<%1$s>' ) . |
|
| 227 | + (self::OBJECT_PARAMETER === $subject_value_type ? '%1$s' : '<%1$s>'). |
|
| 228 | 228 | // Predicate. |
| 229 | - ' <%2$s> ' . |
|
| 229 | + ' <%2$s> '. |
|
| 230 | 230 | // Object. |
| 231 | - ( self::OBJECT_URI === $object_value_type ? '<%3$s>' : |
|
| 232 | - ( self::OBJECT_PARAMETER === $object_value_type ? '%3$s' : |
|
| 233 | - // self::OBJECT_VALUE === $object_value_type |
|
| 234 | - '"%3$s"' . ( isset( $data_type ) ? '^^%4$s' : '' ) . ( isset( $language ) ? '@%5$s' : '' ) ) ); |
|
| 231 | + (self::OBJECT_URI === $object_value_type ? '<%3$s>' : (self::OBJECT_PARAMETER === $object_value_type ? '%3$s' : // self::OBJECT_VALUE === $object_value_type |
|
| 232 | + '"%3$s"'.(isset($data_type) ? '^^%4$s' : '').(isset($language) ? '@%5$s' : ''))); |
|
| 235 | 233 | |
| 236 | 234 | // Escape the subject, predicate and object. |
| 237 | - $escaped_subject = Wordlift_Sparql_Service::escape_uri( $subject ); |
|
| 238 | - $escaped_predicate = Wordlift_Sparql_Service::escape_uri( $predicate ); |
|
| 239 | - $escaped_object = ( self::OBJECT_URI === $object_value_type ? Wordlift_Sparql_Service::escape_uri( $object ) : Wordlift_Sparql_Service::escape( $object ) ); |
|
| 235 | + $escaped_subject = Wordlift_Sparql_Service::escape_uri($subject); |
|
| 236 | + $escaped_predicate = Wordlift_Sparql_Service::escape_uri($predicate); |
|
| 237 | + $escaped_object = (self::OBJECT_URI === $object_value_type ? Wordlift_Sparql_Service::escape_uri($object) : Wordlift_Sparql_Service::escape($object)); |
|
| 240 | 238 | |
| 241 | 239 | // Prepare the statement and add it to the list of statements. |
| 242 | - $this->statements[] = sprintf( $template, $escaped_subject, $escaped_predicate, $escaped_object, $data_type, $language ); |
|
| 240 | + $this->statements[] = sprintf($template, $escaped_subject, $escaped_predicate, $escaped_object, $data_type, $language); |
|
| 243 | 241 | |
| 244 | 242 | return $this; |
| 245 | 243 | } |
@@ -253,11 +251,11 @@ discard block |
||
| 253 | 251 | public function build() { |
| 254 | 252 | |
| 255 | 253 | // If there are no statements return an empty string. |
| 256 | - if ( 0 === count( $this->statements ) ) { |
|
| 254 | + if (0 === count($this->statements)) { |
|
| 257 | 255 | return ''; |
| 258 | 256 | } |
| 259 | 257 | |
| 260 | - return sprintf( $this->template, implode( ' . ', $this->statements ) ) . "\n"; |
|
| 258 | + return sprintf($this->template, implode(' . ', $this->statements))."\n"; |
|
| 261 | 259 | } |
| 262 | 260 | |
| 263 | 261 | /** |
@@ -270,15 +268,15 @@ discard block |
||
| 270 | 268 | * |
| 271 | 269 | * @return int {@link Wordlift_Query_Builder::OBJECT_URI} if the Query builder thinks the object must be an URI, {@link Wordlift_Query_Builder::OBJECT_VALUE} otherwise. |
| 272 | 270 | */ |
| 273 | - private function guess_object_type( $predicate, $object ) { |
|
| 271 | + private function guess_object_type($predicate, $object) { |
|
| 274 | 272 | |
| 275 | 273 | // If the object starts with a question mark, it's a parameter. |
| 276 | - if ( 0 === strpos( $object, '?' ) ) { |
|
| 274 | + if (0 === strpos($object, '?')) { |
|
| 277 | 275 | return self::OBJECT_PARAMETER; |
| 278 | 276 | } |
| 279 | 277 | |
| 280 | 278 | // Guess based on the predicate. |
| 281 | - switch ( $predicate ) { |
|
| 279 | + switch ($predicate) { |
|
| 282 | 280 | |
| 283 | 281 | case self::DCTERMS_REFERENCES_URI: |
| 284 | 282 | case self::DCTERMS_SUBJECT_URI: |
@@ -7,507 +7,507 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_Entity_Service { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * The Log service. |
|
| 12 | - * |
|
| 13 | - * @since 3.2.0 |
|
| 14 | - * @access private |
|
| 15 | - * @var \Wordlift_Log_Service $log The Log service. |
|
| 16 | - */ |
|
| 17 | - private $log; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * The UI service. |
|
| 21 | - * |
|
| 22 | - * @since 3.2.0 |
|
| 23 | - * @access private |
|
| 24 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 25 | - */ |
|
| 26 | - private $ui_service; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * The entity post type name. |
|
| 30 | - * |
|
| 31 | - * @since 3.1.0 |
|
| 32 | - */ |
|
| 33 | - const TYPE_NAME = 'entity'; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The alternative label meta key. |
|
| 37 | - * |
|
| 38 | - * @since 3.2.0 |
|
| 39 | - */ |
|
| 40 | - const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label'; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The alternative label input template. |
|
| 44 | - * |
|
| 45 | - * @since 3.2.0 |
|
| 46 | - */ |
|
| 47 | - // TODO: this should be moved to a class that deals with HTML code. |
|
| 48 | - const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label"> |
|
| 10 | + /** |
|
| 11 | + * The Log service. |
|
| 12 | + * |
|
| 13 | + * @since 3.2.0 |
|
| 14 | + * @access private |
|
| 15 | + * @var \Wordlift_Log_Service $log The Log service. |
|
| 16 | + */ |
|
| 17 | + private $log; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * The UI service. |
|
| 21 | + * |
|
| 22 | + * @since 3.2.0 |
|
| 23 | + * @access private |
|
| 24 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 25 | + */ |
|
| 26 | + private $ui_service; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * The entity post type name. |
|
| 30 | + * |
|
| 31 | + * @since 3.1.0 |
|
| 32 | + */ |
|
| 33 | + const TYPE_NAME = 'entity'; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The alternative label meta key. |
|
| 37 | + * |
|
| 38 | + * @since 3.2.0 |
|
| 39 | + */ |
|
| 40 | + const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label'; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The alternative label input template. |
|
| 44 | + * |
|
| 45 | + * @since 3.2.0 |
|
| 46 | + */ |
|
| 47 | + // TODO: this should be moved to a class that deals with HTML code. |
|
| 48 | + const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label"> |
|
| 49 | 49 | <label class="screen-reader-text" id="wl-alternative-label-prompt-text" for="wl-alternative-label">Enter alternative label here</label> |
| 50 | 50 | <input name="wl_alternative_label[]" size="30" value="%s" id="wl-alternative-label" type="text"> |
| 51 | 51 | <button class="button wl-delete-button">%s</button> |
| 52 | 52 | </div>'; |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * A singleton instance of the Entity service. |
|
| 56 | - * |
|
| 57 | - * @since 3.2.0 |
|
| 58 | - * @access private |
|
| 59 | - * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service. |
|
| 60 | - */ |
|
| 61 | - private static $instance; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Create a Wordlift_Entity_Service instance. |
|
| 65 | - * |
|
| 66 | - * @since 3.2.0 |
|
| 67 | - * |
|
| 68 | - * @param \Wordlift_UI_Service $ui_service The UI service. |
|
| 69 | - */ |
|
| 70 | - public function __construct( $ui_service ) { |
|
| 71 | - |
|
| 72 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' ); |
|
| 73 | - |
|
| 74 | - // Set the UI service. |
|
| 75 | - $this->ui_service = $ui_service; |
|
| 76 | - |
|
| 77 | - // Set the singleton instance. |
|
| 78 | - self::$instance = $this; |
|
| 79 | - |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Get the singleton instance of the Entity service. |
|
| 84 | - * |
|
| 85 | - * @since 3.2.0 |
|
| 86 | - * @return \Wordlift_Entity_Service The singleton instance of the Entity service. |
|
| 87 | - */ |
|
| 88 | - public static function get_instance() { |
|
| 89 | - |
|
| 90 | - return self::$instance; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Determines whether a post is an entity or not. |
|
| 95 | - * |
|
| 96 | - * @since 3.1.0 |
|
| 97 | - * |
|
| 98 | - * @param int $post_id A post id. |
|
| 99 | - * |
|
| 100 | - * @return bool Return true if the post is an entity otherwise false. |
|
| 101 | - */ |
|
| 102 | - public function is_entity( $post_id ) { |
|
| 103 | - |
|
| 104 | - return ( self::TYPE_NAME === get_post_type( $post_id ) ); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Get the proper classification scope for a given entity post |
|
| 109 | - * |
|
| 110 | - * @since 3.5.0 |
|
| 111 | - * |
|
| 112 | - * @param integer $post_id An entity post id. |
|
| 113 | - * |
|
| 114 | - * @return string Returns an uri. |
|
| 115 | - */ |
|
| 116 | - public function get_classification_scope_for( $post_id ) { |
|
| 117 | - |
|
| 118 | - if ( false === $this->is_entity( $post_id ) ) { |
|
| 119 | - return null; |
|
| 120 | - } |
|
| 121 | - // Retrieve the entity type |
|
| 122 | - $entity_type_arr = wl_entity_type_taxonomy_get_type( $post_id ); |
|
| 123 | - $entity_type = str_replace( 'wl-', '', $entity_type_arr['css_class'] ); |
|
| 124 | - // Retrieve classification boxes configuration |
|
| 125 | - $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES ); |
|
| 126 | - foreach ( $classification_boxes as $cb ) { |
|
| 127 | - if ( in_array( $entity_type, $cb['registeredTypes'] ) ) { |
|
| 128 | - return $cb['id']; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - // or null |
|
| 133 | - return null; |
|
| 134 | - |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - public function is_used( $post_id ) { |
|
| 139 | - |
|
| 140 | - if ( false === $this->is_entity( $post_id ) ) { |
|
| 141 | - return null; |
|
| 142 | - } |
|
| 143 | - // Retrieve the post |
|
| 144 | - $entity = get_post( $post_id ); |
|
| 145 | - |
|
| 146 | - global $wpdb; |
|
| 147 | - // Retrieve Wordlift relation instances table name |
|
| 148 | - $table_name = wl_core_get_relation_instances_table_name(); |
|
| 149 | - |
|
| 150 | - // Check is it's referenced / related to another post / entity |
|
| 151 | - $stmt = $wpdb->prepare( |
|
| 152 | - "SELECT COUNT(*) FROM $table_name WHERE object_id = %d", |
|
| 153 | - $entity->ID |
|
| 154 | - ); |
|
| 155 | - |
|
| 156 | - // Perform the query |
|
| 157 | - $relation_instances = (int) $wpdb->get_var( $stmt ); |
|
| 158 | - // If there is at least one relation instance for the current entity, then it's used |
|
| 159 | - if ( 0 < $relation_instances ) { |
|
| 160 | - return true; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - // Check if the entity uri is used as meta_value |
|
| 164 | - $stmt = $wpdb->prepare( |
|
| 165 | - "SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s", |
|
| 166 | - $entity->ID, |
|
| 167 | - wl_get_entity_uri( $entity->ID ) |
|
| 168 | - ); |
|
| 169 | - // Perform the query |
|
| 170 | - $meta_instances = (int) $wpdb->get_var( $stmt ); |
|
| 171 | - |
|
| 172 | - // If there is at least one meta that refers the current entity uri, then current entity is used |
|
| 173 | - if ( 0 < $meta_instances ) { |
|
| 174 | - return true; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - // If we are here, it means the current entity is not used at the moment |
|
| 178 | - return false; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * Determines whether a given uri is an internal uri or not. |
|
| 183 | - * |
|
| 184 | - * @since 3.3.2 |
|
| 185 | - * |
|
| 186 | - * @param int $uri An uri. |
|
| 187 | - * |
|
| 188 | - * @return true if the uri internal to the current dataset otherwise false. |
|
| 189 | - */ |
|
| 190 | - public function is_internal_uri( $uri ) { |
|
| 191 | - |
|
| 192 | - return ( 0 === strrpos( $uri, wl_configuration_get_redlink_dataset_uri() ) ); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Find entity posts by the entity URI. Entity as searched by their entity URI or same as. |
|
| 197 | - * |
|
| 198 | - * @since 3.2.0 |
|
| 199 | - * |
|
| 200 | - * @param string $uri The entity URI. |
|
| 201 | - * |
|
| 202 | - * @return WP_Post|null A WP_Post instance or null if not found. |
|
| 203 | - */ |
|
| 204 | - public function get_entity_post_by_uri( $uri ) { |
|
| 205 | - |
|
| 206 | - // Check if we've been provided with a value otherwise return null. |
|
| 207 | - if ( empty( $uri ) ) { |
|
| 208 | - return null; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - $query_args = array( |
|
| 212 | - 'posts_per_page' => 1, |
|
| 213 | - 'post_status' => 'any', |
|
| 214 | - 'post_type' => self::TYPE_NAME, |
|
| 215 | - 'meta_query' => array( |
|
| 216 | - array( |
|
| 217 | - 'key' => WL_ENTITY_URL_META_NAME, |
|
| 218 | - 'value' => $uri, |
|
| 219 | - 'compare' => '=', |
|
| 220 | - ), |
|
| 221 | - ), |
|
| 222 | - ); |
|
| 223 | - |
|
| 224 | - // Only if the current uri is not an internal uri, entity search is |
|
| 225 | - // performed also looking at sameAs values. |
|
| 226 | - // |
|
| 227 | - // This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237 |
|
| 228 | - if ( ! $this->is_internal_uri( $uri ) ) { |
|
| 229 | - |
|
| 230 | - $query_args['meta_query']['relation'] = 'OR'; |
|
| 231 | - $query_args['meta_query'][] = array( |
|
| 232 | - 'key' => Wordlift_Schema_Service::FIELD_SAME_AS, |
|
| 233 | - 'value' => $uri, |
|
| 234 | - 'compare' => '=', |
|
| 235 | - ); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - $query = new WP_Query( $query_args ); |
|
| 239 | - |
|
| 240 | - // Get the matching entity posts. |
|
| 241 | - $posts = $query->get_posts(); |
|
| 242 | - |
|
| 243 | - // Return null if no post is found. |
|
| 244 | - if ( 0 === count( $posts ) ) { |
|
| 245 | - return null; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - // Return the found post. |
|
| 249 | - return $posts[0]; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Fires once a post has been saved. This function uses the $_REQUEST, therefore |
|
| 254 | - * we check that the post we're saving is the current post. |
|
| 255 | - * |
|
| 256 | - * @see https://github.com/insideout10/wordlift-plugin/issues/363 |
|
| 257 | - * |
|
| 258 | - * @since 3.2.0 |
|
| 259 | - * |
|
| 260 | - * @param int $post_id Post ID. |
|
| 261 | - * @param WP_Post $post Post object. |
|
| 262 | - * @param bool $update Whether this is an existing post being updated or not. |
|
| 263 | - */ |
|
| 264 | - public function save_post( $post_id, $post, $update ) { |
|
| 265 | - |
|
| 266 | - // Avoid doing anything if post is autosave or a revision. |
|
| 267 | - |
|
| 268 | - if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) { |
|
| 269 | - return; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - // We're setting the alternative label that have been provided via the UI |
|
| 273 | - // (in fact we're using $_REQUEST), while save_post may be also called |
|
| 274 | - // programmatically by some other function: we need to check therefore if |
|
| 275 | - // the $post_id in the save_post call matches the post id set in the request. |
|
| 276 | - // |
|
| 277 | - // If this is not the current post being saved or if it's not an entity, return. |
|
| 278 | - if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) { |
|
| 279 | - return; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - // Get the alt labels from the request (or empty array). |
|
| 283 | - $alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array(); |
|
| 284 | - |
|
| 285 | - // Set the alternative labels. |
|
| 286 | - $this->set_alternative_labels( $post_id, $alt_labels ); |
|
| 287 | - |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * Set the alternative labels. |
|
| 292 | - * |
|
| 293 | - * @since 3.2.0 |
|
| 294 | - * |
|
| 295 | - * @param int $post_id The post id. |
|
| 296 | - * @param array $alt_labels An array of labels. |
|
| 297 | - */ |
|
| 298 | - public function set_alternative_labels( $post_id, $alt_labels ) { |
|
| 299 | - |
|
| 300 | - // Force $alt_labels to be an array |
|
| 301 | - if ( ! is_array( $alt_labels ) ) { |
|
| 302 | - $alt_labels = array( $alt_labels ); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - $this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" ); |
|
| 306 | - |
|
| 307 | - // Delete all the existing alternate labels. |
|
| 308 | - delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY ); |
|
| 309 | - |
|
| 310 | - // Set the alternative labels. |
|
| 311 | - foreach ( $alt_labels as $alt_label ) { |
|
| 312 | - if ( ! empty( $alt_label ) ) { |
|
| 313 | - add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label ); |
|
| 314 | - } |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * Retrieve the alternate labels. |
|
| 321 | - * |
|
| 322 | - * @since 3.2.0 |
|
| 323 | - * |
|
| 324 | - * @param int $post_id Post id. |
|
| 325 | - * |
|
| 326 | - * @return mixed An array of alternative labels. |
|
| 327 | - */ |
|
| 328 | - public function get_alternative_labels( $post_id ) { |
|
| 329 | - |
|
| 330 | - return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY ); |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * Retrieve the labels for an entity, i.e. the title + the synonyms. |
|
| 335 | - * |
|
| 336 | - * @since 3.12.0 |
|
| 337 | - * |
|
| 338 | - * @param int $post_id The entity {@link WP_Post} id. |
|
| 339 | - * |
|
| 340 | - * @return array An array with the entity title and labels. |
|
| 341 | - */ |
|
| 342 | - public function get_labels( $post_id ) { |
|
| 343 | - |
|
| 344 | - return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) ); |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - /** |
|
| 348 | - * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0). |
|
| 349 | - * |
|
| 350 | - * @since 3.2.0 |
|
| 351 | - * |
|
| 352 | - * @param WP_Post $post Post object. |
|
| 353 | - */ |
|
| 354 | - public function edit_form_before_permalink( $post ) { |
|
| 355 | - |
|
| 356 | - // If it's not an entity, return. |
|
| 357 | - if ( ! $this->is_entity( $post->ID ) ) { |
|
| 358 | - return; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - // Print the input template. |
|
| 362 | - $this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() ); |
|
| 363 | - |
|
| 364 | - // Print all the currently set alternative labels. |
|
| 365 | - foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) { |
|
| 366 | - |
|
| 367 | - echo $this->get_alternative_label_input( $alt_label ); |
|
| 368 | - |
|
| 369 | - }; |
|
| 370 | - |
|
| 371 | - // Print the button. |
|
| 372 | - $this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) ); |
|
| 373 | - |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * Get the URI for the entity with the specified post id. |
|
| 378 | - * |
|
| 379 | - * @since 3.6.0 |
|
| 380 | - * |
|
| 381 | - * @param int $post_id The entity post id. |
|
| 382 | - * |
|
| 383 | - * @return null|string The entity URI or NULL if not found or the dataset URI is not configured. |
|
| 384 | - */ |
|
| 385 | - public function get_uri( $post_id ) { |
|
| 386 | - |
|
| 387 | - // If a null is given, nothing to do |
|
| 388 | - if ( null == $post_id ) { |
|
| 389 | - return null; |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - $uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true ); |
|
| 393 | - |
|
| 394 | - // If the dataset uri is not properly configured, null is returned |
|
| 395 | - if ( '' === wl_configuration_get_redlink_dataset_uri() ) { |
|
| 396 | - return null; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - // Set the URI if it isn't set yet. |
|
| 400 | - $post_status = get_post_status( $post_id ); |
|
| 401 | - if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) { |
|
| 402 | - $uri = wl_build_entity_uri( $post_id ); |
|
| 403 | - wl_set_entity_uri( $post_id, $uri ); |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - return $uri; |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * Get the alternative label input HTML code. |
|
| 412 | - * |
|
| 413 | - * @since 3.2.0 |
|
| 414 | - * |
|
| 415 | - * @param string $value The input value. |
|
| 416 | - * |
|
| 417 | - * @return string The input HTML code. |
|
| 418 | - */ |
|
| 419 | - private function get_alternative_label_input( $value = '' ) { |
|
| 420 | - |
|
| 421 | - return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) ); |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * Get the number of entity posts published in this blog. |
|
| 426 | - * |
|
| 427 | - * @since 3.6.0 |
|
| 428 | - * |
|
| 429 | - * @return int The number of published entity posts. |
|
| 430 | - */ |
|
| 431 | - public function count() { |
|
| 432 | - |
|
| 433 | - $count = wp_count_posts( self::TYPE_NAME ); |
|
| 434 | - |
|
| 435 | - return $count->publish; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * Create a new entity. |
|
| 440 | - * |
|
| 441 | - * @since 3.9.0 |
|
| 442 | - * |
|
| 443 | - * @param string $name The entity name. |
|
| 444 | - * @param string $type_uri The entity's type URI. |
|
| 445 | - * @param null $logo The entity logo id (or NULL if none). |
|
| 446 | - * @param string $status The post status, by default 'publish'. |
|
| 447 | - * |
|
| 448 | - * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails. |
|
| 449 | - */ |
|
| 450 | - public function create( $name, $type_uri, $logo = null, $status = 'publish' ) { |
|
| 451 | - |
|
| 452 | - // Create an entity for the publisher. |
|
| 453 | - $post_id = wp_insert_post( array( |
|
| 454 | - 'post_type' => self::TYPE_NAME, |
|
| 455 | - 'post_title' => $name, |
|
| 456 | - 'post_status' => $status, |
|
| 457 | - 'post_content' => '', |
|
| 458 | - ) ); |
|
| 459 | - |
|
| 460 | - // Return the error if any. |
|
| 461 | - if ( is_wp_error( $post_id ) ) { |
|
| 462 | - return $post_id; |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - // Set the entity logo. |
|
| 466 | - if ( $logo && is_numeric( $logo ) ) { |
|
| 467 | - set_post_thumbnail( $post_id, $logo ); |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - // Set the entity type. |
|
| 471 | - Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri ); |
|
| 472 | - |
|
| 473 | - return $post_id; |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - /** |
|
| 477 | - * Get the entities related to the one with the specified id. By default only |
|
| 478 | - * published entities will be returned. |
|
| 479 | - * |
|
| 480 | - * @since 3.10.0 |
|
| 481 | - * |
|
| 482 | - * @param int $id The post id. |
|
| 483 | - * @param string $post_status The target post status (default = publish). |
|
| 484 | - * |
|
| 485 | - * @return array An array of post ids. |
|
| 486 | - */ |
|
| 487 | - public function get_related_entities( $id, $post_status = 'publish' ) { |
|
| 488 | - |
|
| 489 | - return wl_core_inner_get_related_entities( 'post_ids', $id, null, $post_status ); |
|
| 490 | - } |
|
| 491 | - |
|
| 492 | - /** |
|
| 493 | - * Get the list of entities. |
|
| 494 | - * |
|
| 495 | - * @since 3.12.2 |
|
| 496 | - * |
|
| 497 | - * @param array $params Custom parameters for WordPress' own {@link get_posts} function. |
|
| 498 | - * |
|
| 499 | - * @return array An array of entity posts. |
|
| 500 | - */ |
|
| 501 | - public function get( $params = array() ) { |
|
| 502 | - |
|
| 503 | - // Set the defaults. |
|
| 504 | - $defaults = array( 'post_type' => 'entity' ); |
|
| 505 | - |
|
| 506 | - // Merge the defaults with the provided parameters. |
|
| 507 | - $args = wp_parse_args( $params, $defaults ); |
|
| 508 | - |
|
| 509 | - // Call the `get_posts` function. |
|
| 510 | - return get_posts( $args ); |
|
| 511 | - } |
|
| 54 | + /** |
|
| 55 | + * A singleton instance of the Entity service. |
|
| 56 | + * |
|
| 57 | + * @since 3.2.0 |
|
| 58 | + * @access private |
|
| 59 | + * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service. |
|
| 60 | + */ |
|
| 61 | + private static $instance; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Create a Wordlift_Entity_Service instance. |
|
| 65 | + * |
|
| 66 | + * @since 3.2.0 |
|
| 67 | + * |
|
| 68 | + * @param \Wordlift_UI_Service $ui_service The UI service. |
|
| 69 | + */ |
|
| 70 | + public function __construct( $ui_service ) { |
|
| 71 | + |
|
| 72 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' ); |
|
| 73 | + |
|
| 74 | + // Set the UI service. |
|
| 75 | + $this->ui_service = $ui_service; |
|
| 76 | + |
|
| 77 | + // Set the singleton instance. |
|
| 78 | + self::$instance = $this; |
|
| 79 | + |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Get the singleton instance of the Entity service. |
|
| 84 | + * |
|
| 85 | + * @since 3.2.0 |
|
| 86 | + * @return \Wordlift_Entity_Service The singleton instance of the Entity service. |
|
| 87 | + */ |
|
| 88 | + public static function get_instance() { |
|
| 89 | + |
|
| 90 | + return self::$instance; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Determines whether a post is an entity or not. |
|
| 95 | + * |
|
| 96 | + * @since 3.1.0 |
|
| 97 | + * |
|
| 98 | + * @param int $post_id A post id. |
|
| 99 | + * |
|
| 100 | + * @return bool Return true if the post is an entity otherwise false. |
|
| 101 | + */ |
|
| 102 | + public function is_entity( $post_id ) { |
|
| 103 | + |
|
| 104 | + return ( self::TYPE_NAME === get_post_type( $post_id ) ); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Get the proper classification scope for a given entity post |
|
| 109 | + * |
|
| 110 | + * @since 3.5.0 |
|
| 111 | + * |
|
| 112 | + * @param integer $post_id An entity post id. |
|
| 113 | + * |
|
| 114 | + * @return string Returns an uri. |
|
| 115 | + */ |
|
| 116 | + public function get_classification_scope_for( $post_id ) { |
|
| 117 | + |
|
| 118 | + if ( false === $this->is_entity( $post_id ) ) { |
|
| 119 | + return null; |
|
| 120 | + } |
|
| 121 | + // Retrieve the entity type |
|
| 122 | + $entity_type_arr = wl_entity_type_taxonomy_get_type( $post_id ); |
|
| 123 | + $entity_type = str_replace( 'wl-', '', $entity_type_arr['css_class'] ); |
|
| 124 | + // Retrieve classification boxes configuration |
|
| 125 | + $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES ); |
|
| 126 | + foreach ( $classification_boxes as $cb ) { |
|
| 127 | + if ( in_array( $entity_type, $cb['registeredTypes'] ) ) { |
|
| 128 | + return $cb['id']; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + // or null |
|
| 133 | + return null; |
|
| 134 | + |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + public function is_used( $post_id ) { |
|
| 139 | + |
|
| 140 | + if ( false === $this->is_entity( $post_id ) ) { |
|
| 141 | + return null; |
|
| 142 | + } |
|
| 143 | + // Retrieve the post |
|
| 144 | + $entity = get_post( $post_id ); |
|
| 145 | + |
|
| 146 | + global $wpdb; |
|
| 147 | + // Retrieve Wordlift relation instances table name |
|
| 148 | + $table_name = wl_core_get_relation_instances_table_name(); |
|
| 149 | + |
|
| 150 | + // Check is it's referenced / related to another post / entity |
|
| 151 | + $stmt = $wpdb->prepare( |
|
| 152 | + "SELECT COUNT(*) FROM $table_name WHERE object_id = %d", |
|
| 153 | + $entity->ID |
|
| 154 | + ); |
|
| 155 | + |
|
| 156 | + // Perform the query |
|
| 157 | + $relation_instances = (int) $wpdb->get_var( $stmt ); |
|
| 158 | + // If there is at least one relation instance for the current entity, then it's used |
|
| 159 | + if ( 0 < $relation_instances ) { |
|
| 160 | + return true; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + // Check if the entity uri is used as meta_value |
|
| 164 | + $stmt = $wpdb->prepare( |
|
| 165 | + "SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s", |
|
| 166 | + $entity->ID, |
|
| 167 | + wl_get_entity_uri( $entity->ID ) |
|
| 168 | + ); |
|
| 169 | + // Perform the query |
|
| 170 | + $meta_instances = (int) $wpdb->get_var( $stmt ); |
|
| 171 | + |
|
| 172 | + // If there is at least one meta that refers the current entity uri, then current entity is used |
|
| 173 | + if ( 0 < $meta_instances ) { |
|
| 174 | + return true; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + // If we are here, it means the current entity is not used at the moment |
|
| 178 | + return false; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * Determines whether a given uri is an internal uri or not. |
|
| 183 | + * |
|
| 184 | + * @since 3.3.2 |
|
| 185 | + * |
|
| 186 | + * @param int $uri An uri. |
|
| 187 | + * |
|
| 188 | + * @return true if the uri internal to the current dataset otherwise false. |
|
| 189 | + */ |
|
| 190 | + public function is_internal_uri( $uri ) { |
|
| 191 | + |
|
| 192 | + return ( 0 === strrpos( $uri, wl_configuration_get_redlink_dataset_uri() ) ); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Find entity posts by the entity URI. Entity as searched by their entity URI or same as. |
|
| 197 | + * |
|
| 198 | + * @since 3.2.0 |
|
| 199 | + * |
|
| 200 | + * @param string $uri The entity URI. |
|
| 201 | + * |
|
| 202 | + * @return WP_Post|null A WP_Post instance or null if not found. |
|
| 203 | + */ |
|
| 204 | + public function get_entity_post_by_uri( $uri ) { |
|
| 205 | + |
|
| 206 | + // Check if we've been provided with a value otherwise return null. |
|
| 207 | + if ( empty( $uri ) ) { |
|
| 208 | + return null; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + $query_args = array( |
|
| 212 | + 'posts_per_page' => 1, |
|
| 213 | + 'post_status' => 'any', |
|
| 214 | + 'post_type' => self::TYPE_NAME, |
|
| 215 | + 'meta_query' => array( |
|
| 216 | + array( |
|
| 217 | + 'key' => WL_ENTITY_URL_META_NAME, |
|
| 218 | + 'value' => $uri, |
|
| 219 | + 'compare' => '=', |
|
| 220 | + ), |
|
| 221 | + ), |
|
| 222 | + ); |
|
| 223 | + |
|
| 224 | + // Only if the current uri is not an internal uri, entity search is |
|
| 225 | + // performed also looking at sameAs values. |
|
| 226 | + // |
|
| 227 | + // This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237 |
|
| 228 | + if ( ! $this->is_internal_uri( $uri ) ) { |
|
| 229 | + |
|
| 230 | + $query_args['meta_query']['relation'] = 'OR'; |
|
| 231 | + $query_args['meta_query'][] = array( |
|
| 232 | + 'key' => Wordlift_Schema_Service::FIELD_SAME_AS, |
|
| 233 | + 'value' => $uri, |
|
| 234 | + 'compare' => '=', |
|
| 235 | + ); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + $query = new WP_Query( $query_args ); |
|
| 239 | + |
|
| 240 | + // Get the matching entity posts. |
|
| 241 | + $posts = $query->get_posts(); |
|
| 242 | + |
|
| 243 | + // Return null if no post is found. |
|
| 244 | + if ( 0 === count( $posts ) ) { |
|
| 245 | + return null; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + // Return the found post. |
|
| 249 | + return $posts[0]; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Fires once a post has been saved. This function uses the $_REQUEST, therefore |
|
| 254 | + * we check that the post we're saving is the current post. |
|
| 255 | + * |
|
| 256 | + * @see https://github.com/insideout10/wordlift-plugin/issues/363 |
|
| 257 | + * |
|
| 258 | + * @since 3.2.0 |
|
| 259 | + * |
|
| 260 | + * @param int $post_id Post ID. |
|
| 261 | + * @param WP_Post $post Post object. |
|
| 262 | + * @param bool $update Whether this is an existing post being updated or not. |
|
| 263 | + */ |
|
| 264 | + public function save_post( $post_id, $post, $update ) { |
|
| 265 | + |
|
| 266 | + // Avoid doing anything if post is autosave or a revision. |
|
| 267 | + |
|
| 268 | + if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) { |
|
| 269 | + return; |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + // We're setting the alternative label that have been provided via the UI |
|
| 273 | + // (in fact we're using $_REQUEST), while save_post may be also called |
|
| 274 | + // programmatically by some other function: we need to check therefore if |
|
| 275 | + // the $post_id in the save_post call matches the post id set in the request. |
|
| 276 | + // |
|
| 277 | + // If this is not the current post being saved or if it's not an entity, return. |
|
| 278 | + if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) { |
|
| 279 | + return; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + // Get the alt labels from the request (or empty array). |
|
| 283 | + $alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array(); |
|
| 284 | + |
|
| 285 | + // Set the alternative labels. |
|
| 286 | + $this->set_alternative_labels( $post_id, $alt_labels ); |
|
| 287 | + |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * Set the alternative labels. |
|
| 292 | + * |
|
| 293 | + * @since 3.2.0 |
|
| 294 | + * |
|
| 295 | + * @param int $post_id The post id. |
|
| 296 | + * @param array $alt_labels An array of labels. |
|
| 297 | + */ |
|
| 298 | + public function set_alternative_labels( $post_id, $alt_labels ) { |
|
| 299 | + |
|
| 300 | + // Force $alt_labels to be an array |
|
| 301 | + if ( ! is_array( $alt_labels ) ) { |
|
| 302 | + $alt_labels = array( $alt_labels ); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + $this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" ); |
|
| 306 | + |
|
| 307 | + // Delete all the existing alternate labels. |
|
| 308 | + delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY ); |
|
| 309 | + |
|
| 310 | + // Set the alternative labels. |
|
| 311 | + foreach ( $alt_labels as $alt_label ) { |
|
| 312 | + if ( ! empty( $alt_label ) ) { |
|
| 313 | + add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label ); |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * Retrieve the alternate labels. |
|
| 321 | + * |
|
| 322 | + * @since 3.2.0 |
|
| 323 | + * |
|
| 324 | + * @param int $post_id Post id. |
|
| 325 | + * |
|
| 326 | + * @return mixed An array of alternative labels. |
|
| 327 | + */ |
|
| 328 | + public function get_alternative_labels( $post_id ) { |
|
| 329 | + |
|
| 330 | + return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY ); |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * Retrieve the labels for an entity, i.e. the title + the synonyms. |
|
| 335 | + * |
|
| 336 | + * @since 3.12.0 |
|
| 337 | + * |
|
| 338 | + * @param int $post_id The entity {@link WP_Post} id. |
|
| 339 | + * |
|
| 340 | + * @return array An array with the entity title and labels. |
|
| 341 | + */ |
|
| 342 | + public function get_labels( $post_id ) { |
|
| 343 | + |
|
| 344 | + return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) ); |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + /** |
|
| 348 | + * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0). |
|
| 349 | + * |
|
| 350 | + * @since 3.2.0 |
|
| 351 | + * |
|
| 352 | + * @param WP_Post $post Post object. |
|
| 353 | + */ |
|
| 354 | + public function edit_form_before_permalink( $post ) { |
|
| 355 | + |
|
| 356 | + // If it's not an entity, return. |
|
| 357 | + if ( ! $this->is_entity( $post->ID ) ) { |
|
| 358 | + return; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + // Print the input template. |
|
| 362 | + $this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() ); |
|
| 363 | + |
|
| 364 | + // Print all the currently set alternative labels. |
|
| 365 | + foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) { |
|
| 366 | + |
|
| 367 | + echo $this->get_alternative_label_input( $alt_label ); |
|
| 368 | + |
|
| 369 | + }; |
|
| 370 | + |
|
| 371 | + // Print the button. |
|
| 372 | + $this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) ); |
|
| 373 | + |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * Get the URI for the entity with the specified post id. |
|
| 378 | + * |
|
| 379 | + * @since 3.6.0 |
|
| 380 | + * |
|
| 381 | + * @param int $post_id The entity post id. |
|
| 382 | + * |
|
| 383 | + * @return null|string The entity URI or NULL if not found or the dataset URI is not configured. |
|
| 384 | + */ |
|
| 385 | + public function get_uri( $post_id ) { |
|
| 386 | + |
|
| 387 | + // If a null is given, nothing to do |
|
| 388 | + if ( null == $post_id ) { |
|
| 389 | + return null; |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + $uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true ); |
|
| 393 | + |
|
| 394 | + // If the dataset uri is not properly configured, null is returned |
|
| 395 | + if ( '' === wl_configuration_get_redlink_dataset_uri() ) { |
|
| 396 | + return null; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + // Set the URI if it isn't set yet. |
|
| 400 | + $post_status = get_post_status( $post_id ); |
|
| 401 | + if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) { |
|
| 402 | + $uri = wl_build_entity_uri( $post_id ); |
|
| 403 | + wl_set_entity_uri( $post_id, $uri ); |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + return $uri; |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * Get the alternative label input HTML code. |
|
| 412 | + * |
|
| 413 | + * @since 3.2.0 |
|
| 414 | + * |
|
| 415 | + * @param string $value The input value. |
|
| 416 | + * |
|
| 417 | + * @return string The input HTML code. |
|
| 418 | + */ |
|
| 419 | + private function get_alternative_label_input( $value = '' ) { |
|
| 420 | + |
|
| 421 | + return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) ); |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * Get the number of entity posts published in this blog. |
|
| 426 | + * |
|
| 427 | + * @since 3.6.0 |
|
| 428 | + * |
|
| 429 | + * @return int The number of published entity posts. |
|
| 430 | + */ |
|
| 431 | + public function count() { |
|
| 432 | + |
|
| 433 | + $count = wp_count_posts( self::TYPE_NAME ); |
|
| 434 | + |
|
| 435 | + return $count->publish; |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * Create a new entity. |
|
| 440 | + * |
|
| 441 | + * @since 3.9.0 |
|
| 442 | + * |
|
| 443 | + * @param string $name The entity name. |
|
| 444 | + * @param string $type_uri The entity's type URI. |
|
| 445 | + * @param null $logo The entity logo id (or NULL if none). |
|
| 446 | + * @param string $status The post status, by default 'publish'. |
|
| 447 | + * |
|
| 448 | + * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails. |
|
| 449 | + */ |
|
| 450 | + public function create( $name, $type_uri, $logo = null, $status = 'publish' ) { |
|
| 451 | + |
|
| 452 | + // Create an entity for the publisher. |
|
| 453 | + $post_id = wp_insert_post( array( |
|
| 454 | + 'post_type' => self::TYPE_NAME, |
|
| 455 | + 'post_title' => $name, |
|
| 456 | + 'post_status' => $status, |
|
| 457 | + 'post_content' => '', |
|
| 458 | + ) ); |
|
| 459 | + |
|
| 460 | + // Return the error if any. |
|
| 461 | + if ( is_wp_error( $post_id ) ) { |
|
| 462 | + return $post_id; |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + // Set the entity logo. |
|
| 466 | + if ( $logo && is_numeric( $logo ) ) { |
|
| 467 | + set_post_thumbnail( $post_id, $logo ); |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + // Set the entity type. |
|
| 471 | + Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri ); |
|
| 472 | + |
|
| 473 | + return $post_id; |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + /** |
|
| 477 | + * Get the entities related to the one with the specified id. By default only |
|
| 478 | + * published entities will be returned. |
|
| 479 | + * |
|
| 480 | + * @since 3.10.0 |
|
| 481 | + * |
|
| 482 | + * @param int $id The post id. |
|
| 483 | + * @param string $post_status The target post status (default = publish). |
|
| 484 | + * |
|
| 485 | + * @return array An array of post ids. |
|
| 486 | + */ |
|
| 487 | + public function get_related_entities( $id, $post_status = 'publish' ) { |
|
| 488 | + |
|
| 489 | + return wl_core_inner_get_related_entities( 'post_ids', $id, null, $post_status ); |
|
| 490 | + } |
|
| 491 | + |
|
| 492 | + /** |
|
| 493 | + * Get the list of entities. |
|
| 494 | + * |
|
| 495 | + * @since 3.12.2 |
|
| 496 | + * |
|
| 497 | + * @param array $params Custom parameters for WordPress' own {@link get_posts} function. |
|
| 498 | + * |
|
| 499 | + * @return array An array of entity posts. |
|
| 500 | + */ |
|
| 501 | + public function get( $params = array() ) { |
|
| 502 | + |
|
| 503 | + // Set the defaults. |
|
| 504 | + $defaults = array( 'post_type' => 'entity' ); |
|
| 505 | + |
|
| 506 | + // Merge the defaults with the provided parameters. |
|
| 507 | + $args = wp_parse_args( $params, $defaults ); |
|
| 508 | + |
|
| 509 | + // Call the `get_posts` function. |
|
| 510 | + return get_posts( $args ); |
|
| 511 | + } |
|
| 512 | 512 | |
| 513 | 513 | } |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @param \Wordlift_UI_Service $ui_service The UI service. |
| 69 | 69 | */ |
| 70 | - public function __construct( $ui_service ) { |
|
| 70 | + public function __construct($ui_service) { |
|
| 71 | 71 | |
| 72 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' ); |
|
| 72 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Entity_Service'); |
|
| 73 | 73 | |
| 74 | 74 | // Set the UI service. |
| 75 | 75 | $this->ui_service = $ui_service; |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return bool Return true if the post is an entity otherwise false. |
| 101 | 101 | */ |
| 102 | - public function is_entity( $post_id ) { |
|
| 102 | + public function is_entity($post_id) { |
|
| 103 | 103 | |
| 104 | - return ( self::TYPE_NAME === get_post_type( $post_id ) ); |
|
| 104 | + return (self::TYPE_NAME === get_post_type($post_id)); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -113,18 +113,18 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return string Returns an uri. |
| 115 | 115 | */ |
| 116 | - public function get_classification_scope_for( $post_id ) { |
|
| 116 | + public function get_classification_scope_for($post_id) { |
|
| 117 | 117 | |
| 118 | - if ( false === $this->is_entity( $post_id ) ) { |
|
| 118 | + if (false === $this->is_entity($post_id)) { |
|
| 119 | 119 | return null; |
| 120 | 120 | } |
| 121 | 121 | // Retrieve the entity type |
| 122 | - $entity_type_arr = wl_entity_type_taxonomy_get_type( $post_id ); |
|
| 123 | - $entity_type = str_replace( 'wl-', '', $entity_type_arr['css_class'] ); |
|
| 122 | + $entity_type_arr = wl_entity_type_taxonomy_get_type($post_id); |
|
| 123 | + $entity_type = str_replace('wl-', '', $entity_type_arr['css_class']); |
|
| 124 | 124 | // Retrieve classification boxes configuration |
| 125 | - $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES ); |
|
| 126 | - foreach ( $classification_boxes as $cb ) { |
|
| 127 | - if ( in_array( $entity_type, $cb['registeredTypes'] ) ) { |
|
| 125 | + $classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES); |
|
| 126 | + foreach ($classification_boxes as $cb) { |
|
| 127 | + if (in_array($entity_type, $cb['registeredTypes'])) { |
|
| 128 | 128 | return $cb['id']; |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
| 138 | - public function is_used( $post_id ) { |
|
| 138 | + public function is_used($post_id) { |
|
| 139 | 139 | |
| 140 | - if ( false === $this->is_entity( $post_id ) ) { |
|
| 140 | + if (false === $this->is_entity($post_id)) { |
|
| 141 | 141 | return null; |
| 142 | 142 | } |
| 143 | 143 | // Retrieve the post |
| 144 | - $entity = get_post( $post_id ); |
|
| 144 | + $entity = get_post($post_id); |
|
| 145 | 145 | |
| 146 | 146 | global $wpdb; |
| 147 | 147 | // Retrieve Wordlift relation instances table name |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | ); |
| 155 | 155 | |
| 156 | 156 | // Perform the query |
| 157 | - $relation_instances = (int) $wpdb->get_var( $stmt ); |
|
| 157 | + $relation_instances = (int) $wpdb->get_var($stmt); |
|
| 158 | 158 | // If there is at least one relation instance for the current entity, then it's used |
| 159 | - if ( 0 < $relation_instances ) { |
|
| 159 | + if (0 < $relation_instances) { |
|
| 160 | 160 | return true; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | $stmt = $wpdb->prepare( |
| 165 | 165 | "SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s", |
| 166 | 166 | $entity->ID, |
| 167 | - wl_get_entity_uri( $entity->ID ) |
|
| 167 | + wl_get_entity_uri($entity->ID) |
|
| 168 | 168 | ); |
| 169 | 169 | // Perform the query |
| 170 | - $meta_instances = (int) $wpdb->get_var( $stmt ); |
|
| 170 | + $meta_instances = (int) $wpdb->get_var($stmt); |
|
| 171 | 171 | |
| 172 | 172 | // If there is at least one meta that refers the current entity uri, then current entity is used |
| 173 | - if ( 0 < $meta_instances ) { |
|
| 173 | + if (0 < $meta_instances) { |
|
| 174 | 174 | return true; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @return true if the uri internal to the current dataset otherwise false. |
| 189 | 189 | */ |
| 190 | - public function is_internal_uri( $uri ) { |
|
| 190 | + public function is_internal_uri($uri) { |
|
| 191 | 191 | |
| 192 | - return ( 0 === strrpos( $uri, wl_configuration_get_redlink_dataset_uri() ) ); |
|
| 192 | + return (0 === strrpos($uri, wl_configuration_get_redlink_dataset_uri())); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -201,10 +201,10 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @return WP_Post|null A WP_Post instance or null if not found. |
| 203 | 203 | */ |
| 204 | - public function get_entity_post_by_uri( $uri ) { |
|
| 204 | + public function get_entity_post_by_uri($uri) { |
|
| 205 | 205 | |
| 206 | 206 | // Check if we've been provided with a value otherwise return null. |
| 207 | - if ( empty( $uri ) ) { |
|
| 207 | + if (empty($uri)) { |
|
| 208 | 208 | return null; |
| 209 | 209 | } |
| 210 | 210 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | // performed also looking at sameAs values. |
| 226 | 226 | // |
| 227 | 227 | // This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237 |
| 228 | - if ( ! $this->is_internal_uri( $uri ) ) { |
|
| 228 | + if ( ! $this->is_internal_uri($uri)) { |
|
| 229 | 229 | |
| 230 | 230 | $query_args['meta_query']['relation'] = 'OR'; |
| 231 | 231 | $query_args['meta_query'][] = array( |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | ); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - $query = new WP_Query( $query_args ); |
|
| 238 | + $query = new WP_Query($query_args); |
|
| 239 | 239 | |
| 240 | 240 | // Get the matching entity posts. |
| 241 | 241 | $posts = $query->get_posts(); |
| 242 | 242 | |
| 243 | 243 | // Return null if no post is found. |
| 244 | - if ( 0 === count( $posts ) ) { |
|
| 244 | + if (0 === count($posts)) { |
|
| 245 | 245 | return null; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | * @param WP_Post $post Post object. |
| 262 | 262 | * @param bool $update Whether this is an existing post being updated or not. |
| 263 | 263 | */ |
| 264 | - public function save_post( $post_id, $post, $update ) { |
|
| 264 | + public function save_post($post_id, $post, $update) { |
|
| 265 | 265 | |
| 266 | 266 | // Avoid doing anything if post is autosave or a revision. |
| 267 | 267 | |
| 268 | - if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) { |
|
| 268 | + if (wp_is_post_autosave($post) || wp_is_post_revision($post)) { |
|
| 269 | 269 | return; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -275,15 +275,15 @@ discard block |
||
| 275 | 275 | // the $post_id in the save_post call matches the post id set in the request. |
| 276 | 276 | // |
| 277 | 277 | // If this is not the current post being saved or if it's not an entity, return. |
| 278 | - if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) { |
|
| 278 | + if ( ! isset($_REQUEST['post_ID']) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity($post_id)) { |
|
| 279 | 279 | return; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // Get the alt labels from the request (or empty array). |
| 283 | - $alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array(); |
|
| 283 | + $alt_labels = isset($_REQUEST['wl_alternative_label']) ? $_REQUEST['wl_alternative_label'] : array(); |
|
| 284 | 284 | |
| 285 | 285 | // Set the alternative labels. |
| 286 | - $this->set_alternative_labels( $post_id, $alt_labels ); |
|
| 286 | + $this->set_alternative_labels($post_id, $alt_labels); |
|
| 287 | 287 | |
| 288 | 288 | } |
| 289 | 289 | |
@@ -295,22 +295,22 @@ discard block |
||
| 295 | 295 | * @param int $post_id The post id. |
| 296 | 296 | * @param array $alt_labels An array of labels. |
| 297 | 297 | */ |
| 298 | - public function set_alternative_labels( $post_id, $alt_labels ) { |
|
| 298 | + public function set_alternative_labels($post_id, $alt_labels) { |
|
| 299 | 299 | |
| 300 | 300 | // Force $alt_labels to be an array |
| 301 | - if ( ! is_array( $alt_labels ) ) { |
|
| 302 | - $alt_labels = array( $alt_labels ); |
|
| 301 | + if ( ! is_array($alt_labels)) { |
|
| 302 | + $alt_labels = array($alt_labels); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - $this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" ); |
|
| 305 | + $this->log->debug("Setting alternative labels [ post id :: $post_id ][ alt labels :: ".implode(',', $alt_labels)." ]"); |
|
| 306 | 306 | |
| 307 | 307 | // Delete all the existing alternate labels. |
| 308 | - delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY ); |
|
| 308 | + delete_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY); |
|
| 309 | 309 | |
| 310 | 310 | // Set the alternative labels. |
| 311 | - foreach ( $alt_labels as $alt_label ) { |
|
| 312 | - if ( ! empty( $alt_label ) ) { |
|
| 313 | - add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label ); |
|
| 311 | + foreach ($alt_labels as $alt_label) { |
|
| 312 | + if ( ! empty($alt_label)) { |
|
| 313 | + add_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label); |
|
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
@@ -325,9 +325,9 @@ discard block |
||
| 325 | 325 | * |
| 326 | 326 | * @return mixed An array of alternative labels. |
| 327 | 327 | */ |
| 328 | - public function get_alternative_labels( $post_id ) { |
|
| 328 | + public function get_alternative_labels($post_id) { |
|
| 329 | 329 | |
| 330 | - return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY ); |
|
| 330 | + return get_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -339,9 +339,9 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | * @return array An array with the entity title and labels. |
| 341 | 341 | */ |
| 342 | - public function get_labels( $post_id ) { |
|
| 342 | + public function get_labels($post_id) { |
|
| 343 | 343 | |
| 344 | - return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) ); |
|
| 344 | + return array_merge((array) get_the_title($post_id), $this->get_alternative_labels($post_id)); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -351,25 +351,25 @@ discard block |
||
| 351 | 351 | * |
| 352 | 352 | * @param WP_Post $post Post object. |
| 353 | 353 | */ |
| 354 | - public function edit_form_before_permalink( $post ) { |
|
| 354 | + public function edit_form_before_permalink($post) { |
|
| 355 | 355 | |
| 356 | 356 | // If it's not an entity, return. |
| 357 | - if ( ! $this->is_entity( $post->ID ) ) { |
|
| 357 | + if ( ! $this->is_entity($post->ID)) { |
|
| 358 | 358 | return; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | // Print the input template. |
| 362 | - $this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() ); |
|
| 362 | + $this->ui_service->print_template('wl-tmpl-alternative-label-input', $this->get_alternative_label_input()); |
|
| 363 | 363 | |
| 364 | 364 | // Print all the currently set alternative labels. |
| 365 | - foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) { |
|
| 365 | + foreach ($this->get_alternative_labels($post->ID) as $alt_label) { |
|
| 366 | 366 | |
| 367 | - echo $this->get_alternative_label_input( $alt_label ); |
|
| 367 | + echo $this->get_alternative_label_input($alt_label); |
|
| 368 | 368 | |
| 369 | 369 | }; |
| 370 | 370 | |
| 371 | 371 | // Print the button. |
| 372 | - $this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) ); |
|
| 372 | + $this->ui_service->print_button('wl-add-alternative-labels-button', __('Add more titles', 'wordlift')); |
|
| 373 | 373 | |
| 374 | 374 | } |
| 375 | 375 | |
@@ -382,25 +382,25 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @return null|string The entity URI or NULL if not found or the dataset URI is not configured. |
| 384 | 384 | */ |
| 385 | - public function get_uri( $post_id ) { |
|
| 385 | + public function get_uri($post_id) { |
|
| 386 | 386 | |
| 387 | 387 | // If a null is given, nothing to do |
| 388 | - if ( null == $post_id ) { |
|
| 388 | + if (null == $post_id) { |
|
| 389 | 389 | return null; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - $uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true ); |
|
| 392 | + $uri = get_post_meta($post_id, WL_ENTITY_URL_META_NAME, true); |
|
| 393 | 393 | |
| 394 | 394 | // If the dataset uri is not properly configured, null is returned |
| 395 | - if ( '' === wl_configuration_get_redlink_dataset_uri() ) { |
|
| 395 | + if ('' === wl_configuration_get_redlink_dataset_uri()) { |
|
| 396 | 396 | return null; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | // Set the URI if it isn't set yet. |
| 400 | - $post_status = get_post_status( $post_id ); |
|
| 401 | - if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) { |
|
| 402 | - $uri = wl_build_entity_uri( $post_id ); |
|
| 403 | - wl_set_entity_uri( $post_id, $uri ); |
|
| 400 | + $post_status = get_post_status($post_id); |
|
| 401 | + if (empty($uri) && 'auto-draft' !== $post_status && 'revision' !== $post_status) { |
|
| 402 | + $uri = wl_build_entity_uri($post_id); |
|
| 403 | + wl_set_entity_uri($post_id, $uri); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | return $uri; |
@@ -416,9 +416,9 @@ discard block |
||
| 416 | 416 | * |
| 417 | 417 | * @return string The input HTML code. |
| 418 | 418 | */ |
| 419 | - private function get_alternative_label_input( $value = '' ) { |
|
| 419 | + private function get_alternative_label_input($value = '') { |
|
| 420 | 420 | |
| 421 | - return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) ); |
|
| 421 | + return sprintf(self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr($value), __('Delete', 'wordlift')); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | */ |
| 431 | 431 | public function count() { |
| 432 | 432 | |
| 433 | - $count = wp_count_posts( self::TYPE_NAME ); |
|
| 433 | + $count = wp_count_posts(self::TYPE_NAME); |
|
| 434 | 434 | |
| 435 | 435 | return $count->publish; |
| 436 | 436 | } |
@@ -447,28 +447,28 @@ discard block |
||
| 447 | 447 | * |
| 448 | 448 | * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails. |
| 449 | 449 | */ |
| 450 | - public function create( $name, $type_uri, $logo = null, $status = 'publish' ) { |
|
| 450 | + public function create($name, $type_uri, $logo = null, $status = 'publish') { |
|
| 451 | 451 | |
| 452 | 452 | // Create an entity for the publisher. |
| 453 | - $post_id = wp_insert_post( array( |
|
| 453 | + $post_id = wp_insert_post(array( |
|
| 454 | 454 | 'post_type' => self::TYPE_NAME, |
| 455 | 455 | 'post_title' => $name, |
| 456 | 456 | 'post_status' => $status, |
| 457 | 457 | 'post_content' => '', |
| 458 | - ) ); |
|
| 458 | + )); |
|
| 459 | 459 | |
| 460 | 460 | // Return the error if any. |
| 461 | - if ( is_wp_error( $post_id ) ) { |
|
| 461 | + if (is_wp_error($post_id)) { |
|
| 462 | 462 | return $post_id; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // Set the entity logo. |
| 466 | - if ( $logo && is_numeric( $logo ) ) { |
|
| 467 | - set_post_thumbnail( $post_id, $logo ); |
|
| 466 | + if ($logo && is_numeric($logo)) { |
|
| 467 | + set_post_thumbnail($post_id, $logo); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | // Set the entity type. |
| 471 | - Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri ); |
|
| 471 | + Wordlift_Entity_Type_Service::get_instance()->set($post_id, $type_uri); |
|
| 472 | 472 | |
| 473 | 473 | return $post_id; |
| 474 | 474 | } |
@@ -484,9 +484,9 @@ discard block |
||
| 484 | 484 | * |
| 485 | 485 | * @return array An array of post ids. |
| 486 | 486 | */ |
| 487 | - public function get_related_entities( $id, $post_status = 'publish' ) { |
|
| 487 | + public function get_related_entities($id, $post_status = 'publish') { |
|
| 488 | 488 | |
| 489 | - return wl_core_inner_get_related_entities( 'post_ids', $id, null, $post_status ); |
|
| 489 | + return wl_core_inner_get_related_entities('post_ids', $id, null, $post_status); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | /** |
@@ -498,16 +498,16 @@ discard block |
||
| 498 | 498 | * |
| 499 | 499 | * @return array An array of entity posts. |
| 500 | 500 | */ |
| 501 | - public function get( $params = array() ) { |
|
| 501 | + public function get($params = array()) { |
|
| 502 | 502 | |
| 503 | 503 | // Set the defaults. |
| 504 | - $defaults = array( 'post_type' => 'entity' ); |
|
| 504 | + $defaults = array('post_type' => 'entity'); |
|
| 505 | 505 | |
| 506 | 506 | // Merge the defaults with the provided parameters. |
| 507 | - $args = wp_parse_args( $params, $defaults ); |
|
| 507 | + $args = wp_parse_args($params, $defaults); |
|
| 508 | 508 | |
| 509 | 509 | // Call the `get_posts` function. |
| 510 | - return get_posts( $args ); |
|
| 510 | + return get_posts($args); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | } |