@@ -79,7 +79,7 @@ |
||
| 79 | 79 | /** |
| 80 | 80 | * Push to queue |
| 81 | 81 | * |
| 82 | - * @param mixed $data Data. |
|
| 82 | + * @param string|null $data Data. |
|
| 83 | 83 | * |
| 84 | 84 | * @return $this |
| 85 | 85 | */ |
@@ -13,264 +13,264 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | abstract class Wordlift_Plugin_WP_Background_Process extends Wordlift_Plugin_WP_Async_Request { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Action |
|
| 18 | - * |
|
| 19 | - * (default value: 'background_process') |
|
| 20 | - * |
|
| 21 | - * @var string |
|
| 22 | - * @access protected |
|
| 23 | - */ |
|
| 24 | - protected $action = 'background_process'; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Start time of current process. |
|
| 28 | - * |
|
| 29 | - * (default value: 0) |
|
| 30 | - * |
|
| 31 | - * @var int |
|
| 32 | - * @access protected |
|
| 33 | - */ |
|
| 34 | - protected $start_time = 0; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Cron_hook_identifier |
|
| 38 | - * |
|
| 39 | - * @var mixed |
|
| 40 | - * @access protected |
|
| 41 | - */ |
|
| 42 | - protected $cron_hook_identifier; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Cron_interval_identifier |
|
| 46 | - * |
|
| 47 | - * @var mixed |
|
| 48 | - * @access protected |
|
| 49 | - */ |
|
| 50 | - protected $cron_interval_identifier; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Initiate new background process |
|
| 54 | - */ |
|
| 55 | - public function __construct() { |
|
| 56 | - parent::__construct(); |
|
| 57 | - |
|
| 58 | - $this->cron_hook_identifier = $this->identifier . '_cron'; |
|
| 59 | - $this->cron_interval_identifier = $this->identifier . '_cron_interval'; |
|
| 60 | - |
|
| 61 | - add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) ); |
|
| 62 | - add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) ); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Dispatch |
|
| 67 | - * |
|
| 68 | - * @access public |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - public function dispatch() { |
|
| 72 | - // Schedule the cron healthcheck. |
|
| 73 | - $this->schedule_event(); |
|
| 74 | - |
|
| 75 | - // Perform remote post. |
|
| 76 | - return parent::dispatch(); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Push to queue |
|
| 81 | - * |
|
| 82 | - * @param mixed $data Data. |
|
| 83 | - * |
|
| 84 | - * @return $this |
|
| 85 | - */ |
|
| 86 | - public function push_to_queue( $data ) { |
|
| 87 | - $this->data[] = $data; |
|
| 88 | - |
|
| 89 | - return $this; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Save queue |
|
| 94 | - * |
|
| 95 | - * @return $this |
|
| 96 | - */ |
|
| 97 | - public function save() { |
|
| 98 | - $key = $this->generate_key(); |
|
| 99 | - |
|
| 100 | - if ( ! empty( $this->data ) ) { |
|
| 101 | - update_site_option( $key, $this->data ); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - return $this; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Update queue |
|
| 109 | - * |
|
| 110 | - * @param string $key Key. |
|
| 111 | - * @param array $data Data. |
|
| 112 | - * |
|
| 113 | - * @return $this |
|
| 114 | - */ |
|
| 115 | - public function update( $key, $data ) { |
|
| 116 | - if ( ! empty( $data ) ) { |
|
| 117 | - update_site_option( $key, $data ); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - return $this; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Delete queue |
|
| 125 | - * |
|
| 126 | - * @param string $key Key. |
|
| 127 | - * |
|
| 128 | - * @return $this |
|
| 129 | - */ |
|
| 130 | - public function delete( $key ) { |
|
| 131 | - delete_site_option( $key ); |
|
| 132 | - |
|
| 133 | - return $this; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Generate key |
|
| 138 | - * |
|
| 139 | - * Generates a unique key based on microtime. Queue items are |
|
| 140 | - * given a unique key so that they can be merged upon save. |
|
| 141 | - * |
|
| 142 | - * @param int $length Length. |
|
| 143 | - * |
|
| 144 | - * @return string |
|
| 145 | - */ |
|
| 146 | - protected function generate_key( $length = 64 ) { |
|
| 147 | - $unique = md5( microtime() . rand() ); |
|
| 148 | - $prepend = $this->identifier . '_batch_'; |
|
| 149 | - |
|
| 150 | - return substr( $prepend . $unique, 0, $length ); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Maybe process queue |
|
| 155 | - * |
|
| 156 | - * Checks whether data exists within the queue and that |
|
| 157 | - * the process is not already running. |
|
| 158 | - */ |
|
| 159 | - public function maybe_handle() { |
|
| 160 | - // Don't lock up other requests while processing |
|
| 161 | - session_write_close(); |
|
| 162 | - |
|
| 163 | - if ( $this->is_process_running() ) { |
|
| 164 | - // Background process already running. |
|
| 165 | - wp_die(); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - if ( $this->is_queue_empty() ) { |
|
| 169 | - // No data to process. |
|
| 170 | - wp_die(); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
| 174 | - |
|
| 175 | - $this->handle(); |
|
| 176 | - |
|
| 177 | - wp_die(); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * Is queue empty |
|
| 182 | - * |
|
| 183 | - * @return bool |
|
| 184 | - */ |
|
| 185 | - protected function is_queue_empty() { |
|
| 186 | - global $wpdb; |
|
| 187 | - |
|
| 188 | - $table = $wpdb->options; |
|
| 189 | - $column = 'option_name'; |
|
| 190 | - |
|
| 191 | - if ( is_multisite() ) { |
|
| 192 | - $table = $wpdb->sitemeta; |
|
| 193 | - $column = 'meta_key'; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; |
|
| 197 | - |
|
| 198 | - $count = $wpdb->get_var( $wpdb->prepare( " |
|
| 16 | + /** |
|
| 17 | + * Action |
|
| 18 | + * |
|
| 19 | + * (default value: 'background_process') |
|
| 20 | + * |
|
| 21 | + * @var string |
|
| 22 | + * @access protected |
|
| 23 | + */ |
|
| 24 | + protected $action = 'background_process'; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Start time of current process. |
|
| 28 | + * |
|
| 29 | + * (default value: 0) |
|
| 30 | + * |
|
| 31 | + * @var int |
|
| 32 | + * @access protected |
|
| 33 | + */ |
|
| 34 | + protected $start_time = 0; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Cron_hook_identifier |
|
| 38 | + * |
|
| 39 | + * @var mixed |
|
| 40 | + * @access protected |
|
| 41 | + */ |
|
| 42 | + protected $cron_hook_identifier; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Cron_interval_identifier |
|
| 46 | + * |
|
| 47 | + * @var mixed |
|
| 48 | + * @access protected |
|
| 49 | + */ |
|
| 50 | + protected $cron_interval_identifier; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Initiate new background process |
|
| 54 | + */ |
|
| 55 | + public function __construct() { |
|
| 56 | + parent::__construct(); |
|
| 57 | + |
|
| 58 | + $this->cron_hook_identifier = $this->identifier . '_cron'; |
|
| 59 | + $this->cron_interval_identifier = $this->identifier . '_cron_interval'; |
|
| 60 | + |
|
| 61 | + add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) ); |
|
| 62 | + add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) ); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Dispatch |
|
| 67 | + * |
|
| 68 | + * @access public |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + public function dispatch() { |
|
| 72 | + // Schedule the cron healthcheck. |
|
| 73 | + $this->schedule_event(); |
|
| 74 | + |
|
| 75 | + // Perform remote post. |
|
| 76 | + return parent::dispatch(); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Push to queue |
|
| 81 | + * |
|
| 82 | + * @param mixed $data Data. |
|
| 83 | + * |
|
| 84 | + * @return $this |
|
| 85 | + */ |
|
| 86 | + public function push_to_queue( $data ) { |
|
| 87 | + $this->data[] = $data; |
|
| 88 | + |
|
| 89 | + return $this; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Save queue |
|
| 94 | + * |
|
| 95 | + * @return $this |
|
| 96 | + */ |
|
| 97 | + public function save() { |
|
| 98 | + $key = $this->generate_key(); |
|
| 99 | + |
|
| 100 | + if ( ! empty( $this->data ) ) { |
|
| 101 | + update_site_option( $key, $this->data ); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + return $this; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Update queue |
|
| 109 | + * |
|
| 110 | + * @param string $key Key. |
|
| 111 | + * @param array $data Data. |
|
| 112 | + * |
|
| 113 | + * @return $this |
|
| 114 | + */ |
|
| 115 | + public function update( $key, $data ) { |
|
| 116 | + if ( ! empty( $data ) ) { |
|
| 117 | + update_site_option( $key, $data ); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + return $this; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Delete queue |
|
| 125 | + * |
|
| 126 | + * @param string $key Key. |
|
| 127 | + * |
|
| 128 | + * @return $this |
|
| 129 | + */ |
|
| 130 | + public function delete( $key ) { |
|
| 131 | + delete_site_option( $key ); |
|
| 132 | + |
|
| 133 | + return $this; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Generate key |
|
| 138 | + * |
|
| 139 | + * Generates a unique key based on microtime. Queue items are |
|
| 140 | + * given a unique key so that they can be merged upon save. |
|
| 141 | + * |
|
| 142 | + * @param int $length Length. |
|
| 143 | + * |
|
| 144 | + * @return string |
|
| 145 | + */ |
|
| 146 | + protected function generate_key( $length = 64 ) { |
|
| 147 | + $unique = md5( microtime() . rand() ); |
|
| 148 | + $prepend = $this->identifier . '_batch_'; |
|
| 149 | + |
|
| 150 | + return substr( $prepend . $unique, 0, $length ); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Maybe process queue |
|
| 155 | + * |
|
| 156 | + * Checks whether data exists within the queue and that |
|
| 157 | + * the process is not already running. |
|
| 158 | + */ |
|
| 159 | + public function maybe_handle() { |
|
| 160 | + // Don't lock up other requests while processing |
|
| 161 | + session_write_close(); |
|
| 162 | + |
|
| 163 | + if ( $this->is_process_running() ) { |
|
| 164 | + // Background process already running. |
|
| 165 | + wp_die(); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + if ( $this->is_queue_empty() ) { |
|
| 169 | + // No data to process. |
|
| 170 | + wp_die(); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + check_ajax_referer( $this->identifier, 'nonce' ); |
|
| 174 | + |
|
| 175 | + $this->handle(); |
|
| 176 | + |
|
| 177 | + wp_die(); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * Is queue empty |
|
| 182 | + * |
|
| 183 | + * @return bool |
|
| 184 | + */ |
|
| 185 | + protected function is_queue_empty() { |
|
| 186 | + global $wpdb; |
|
| 187 | + |
|
| 188 | + $table = $wpdb->options; |
|
| 189 | + $column = 'option_name'; |
|
| 190 | + |
|
| 191 | + if ( is_multisite() ) { |
|
| 192 | + $table = $wpdb->sitemeta; |
|
| 193 | + $column = 'meta_key'; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; |
|
| 197 | + |
|
| 198 | + $count = $wpdb->get_var( $wpdb->prepare( " |
|
| 199 | 199 | SELECT COUNT(*) |
| 200 | 200 | FROM {$table} |
| 201 | 201 | WHERE {$column} LIKE %s |
| 202 | 202 | ", $key ) ); |
| 203 | 203 | |
| 204 | - return ( $count > 0 ) ? false : true; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Is process running |
|
| 209 | - * |
|
| 210 | - * Check whether the current process is already running |
|
| 211 | - * in a background process. |
|
| 212 | - */ |
|
| 213 | - protected function is_process_running() { |
|
| 214 | - if ( get_site_transient( $this->identifier . '_process_lock' ) ) { |
|
| 215 | - // Process already running. |
|
| 216 | - return true; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - return false; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * Lock process |
|
| 224 | - * |
|
| 225 | - * Lock the process so that multiple instances can't run simultaneously. |
|
| 226 | - * Override if applicable, but the duration should be greater than that |
|
| 227 | - * defined in the time_exceeded() method. |
|
| 228 | - */ |
|
| 229 | - protected function lock_process() { |
|
| 230 | - $this->start_time = time(); // Set start time of current process. |
|
| 231 | - |
|
| 232 | - $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute |
|
| 233 | - $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration ); |
|
| 234 | - |
|
| 235 | - set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration ); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * Unlock process |
|
| 240 | - * |
|
| 241 | - * Unlock the process so that other instances can spawn. |
|
| 242 | - * |
|
| 243 | - * @return $this |
|
| 244 | - */ |
|
| 245 | - protected function unlock_process() { |
|
| 246 | - delete_site_transient( $this->identifier . '_process_lock' ); |
|
| 247 | - |
|
| 248 | - return $this; |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * Get batch |
|
| 253 | - * |
|
| 254 | - * @return stdClass Return the first batch from the queue |
|
| 255 | - */ |
|
| 256 | - protected function get_batch() { |
|
| 257 | - global $wpdb; |
|
| 258 | - |
|
| 259 | - $table = $wpdb->options; |
|
| 260 | - $column = 'option_name'; |
|
| 261 | - $key_column = 'option_id'; |
|
| 262 | - $value_column = 'option_value'; |
|
| 263 | - |
|
| 264 | - if ( is_multisite() ) { |
|
| 265 | - $table = $wpdb->sitemeta; |
|
| 266 | - $column = 'meta_key'; |
|
| 267 | - $key_column = 'meta_id'; |
|
| 268 | - $value_column = 'meta_value'; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; |
|
| 272 | - |
|
| 273 | - $query = $wpdb->get_row( $wpdb->prepare( " |
|
| 204 | + return ( $count > 0 ) ? false : true; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Is process running |
|
| 209 | + * |
|
| 210 | + * Check whether the current process is already running |
|
| 211 | + * in a background process. |
|
| 212 | + */ |
|
| 213 | + protected function is_process_running() { |
|
| 214 | + if ( get_site_transient( $this->identifier . '_process_lock' ) ) { |
|
| 215 | + // Process already running. |
|
| 216 | + return true; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + return false; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * Lock process |
|
| 224 | + * |
|
| 225 | + * Lock the process so that multiple instances can't run simultaneously. |
|
| 226 | + * Override if applicable, but the duration should be greater than that |
|
| 227 | + * defined in the time_exceeded() method. |
|
| 228 | + */ |
|
| 229 | + protected function lock_process() { |
|
| 230 | + $this->start_time = time(); // Set start time of current process. |
|
| 231 | + |
|
| 232 | + $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute |
|
| 233 | + $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration ); |
|
| 234 | + |
|
| 235 | + set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration ); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * Unlock process |
|
| 240 | + * |
|
| 241 | + * Unlock the process so that other instances can spawn. |
|
| 242 | + * |
|
| 243 | + * @return $this |
|
| 244 | + */ |
|
| 245 | + protected function unlock_process() { |
|
| 246 | + delete_site_transient( $this->identifier . '_process_lock' ); |
|
| 247 | + |
|
| 248 | + return $this; |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * Get batch |
|
| 253 | + * |
|
| 254 | + * @return stdClass Return the first batch from the queue |
|
| 255 | + */ |
|
| 256 | + protected function get_batch() { |
|
| 257 | + global $wpdb; |
|
| 258 | + |
|
| 259 | + $table = $wpdb->options; |
|
| 260 | + $column = 'option_name'; |
|
| 261 | + $key_column = 'option_id'; |
|
| 262 | + $value_column = 'option_value'; |
|
| 263 | + |
|
| 264 | + if ( is_multisite() ) { |
|
| 265 | + $table = $wpdb->sitemeta; |
|
| 266 | + $column = 'meta_key'; |
|
| 267 | + $key_column = 'meta_id'; |
|
| 268 | + $value_column = 'meta_value'; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; |
|
| 272 | + |
|
| 273 | + $query = $wpdb->get_row( $wpdb->prepare( " |
|
| 274 | 274 | SELECT * |
| 275 | 275 | FROM {$table} |
| 276 | 276 | WHERE {$column} LIKE %s |
@@ -278,228 +278,228 @@ discard block |
||
| 278 | 278 | LIMIT 1 |
| 279 | 279 | ", $key ) ); |
| 280 | 280 | |
| 281 | - $batch = new stdClass(); |
|
| 282 | - $batch->key = $query->$column; |
|
| 283 | - $batch->data = maybe_unserialize( $query->$value_column ); |
|
| 284 | - |
|
| 285 | - return $batch; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * Handle |
|
| 290 | - * |
|
| 291 | - * Pass each queue item to the task handler, while remaining |
|
| 292 | - * within server memory and time limit constraints. |
|
| 293 | - */ |
|
| 294 | - protected function handle() { |
|
| 295 | - $this->lock_process(); |
|
| 296 | - |
|
| 297 | - do { |
|
| 298 | - $batch = $this->get_batch(); |
|
| 299 | - |
|
| 300 | - foreach ( $batch->data as $key => $value ) { |
|
| 301 | - $task = $this->task( $value ); |
|
| 302 | - |
|
| 303 | - if ( false !== $task ) { |
|
| 304 | - $batch->data[ $key ] = $task; |
|
| 305 | - } else { |
|
| 306 | - unset( $batch->data[ $key ] ); |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - if ( $this->time_exceeded() || $this->memory_exceeded() ) { |
|
| 310 | - // Batch limits reached. |
|
| 311 | - break; |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - // Update or delete current batch. |
|
| 316 | - if ( ! empty( $batch->data ) ) { |
|
| 317 | - $this->update( $batch->key, $batch->data ); |
|
| 318 | - } else { |
|
| 319 | - $this->delete( $batch->key ); |
|
| 320 | - } |
|
| 321 | - } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() ); |
|
| 322 | - |
|
| 323 | - $this->unlock_process(); |
|
| 324 | - |
|
| 325 | - // Start next batch or complete process. |
|
| 326 | - if ( ! $this->is_queue_empty() ) { |
|
| 327 | - $this->dispatch(); |
|
| 328 | - } else { |
|
| 329 | - $this->complete(); |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - wp_die(); |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * Memory exceeded |
|
| 337 | - * |
|
| 338 | - * Ensures the batch process never exceeds 90% |
|
| 339 | - * of the maximum WordPress memory. |
|
| 340 | - * |
|
| 341 | - * @return bool |
|
| 342 | - */ |
|
| 343 | - protected function memory_exceeded() { |
|
| 344 | - $memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory |
|
| 345 | - $current_memory = memory_get_usage( true ); |
|
| 346 | - $return = false; |
|
| 347 | - |
|
| 348 | - if ( $current_memory >= $memory_limit ) { |
|
| 349 | - $return = true; |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - return apply_filters( $this->identifier . '_memory_exceeded', $return ); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - /** |
|
| 356 | - * Get memory limit |
|
| 357 | - * |
|
| 358 | - * @return int |
|
| 359 | - */ |
|
| 360 | - protected function get_memory_limit() { |
|
| 361 | - if ( function_exists( 'ini_get' ) ) { |
|
| 362 | - $memory_limit = ini_get( 'memory_limit' ); |
|
| 363 | - } else { |
|
| 364 | - // Sensible default. |
|
| 365 | - $memory_limit = '128M'; |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - if ( ! $memory_limit || - 1 === intval( $memory_limit ) ) { |
|
| 369 | - // Unlimited, set to 32GB. |
|
| 370 | - $memory_limit = '32000M'; |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - return wp_convert_hr_to_bytes( $memory_limit ); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * Time exceeded. |
|
| 378 | - * |
|
| 379 | - * Ensures the batch never exceeds a sensible time limit. |
|
| 380 | - * A timeout limit of 30s is common on shared hosting. |
|
| 381 | - * |
|
| 382 | - * @return bool |
|
| 383 | - */ |
|
| 384 | - protected function time_exceeded() { |
|
| 385 | - $finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds |
|
| 386 | - $return = false; |
|
| 387 | - |
|
| 388 | - if ( time() >= $finish ) { |
|
| 389 | - $return = true; |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - return apply_filters( $this->identifier . '_time_exceeded', $return ); |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * Complete. |
|
| 397 | - * |
|
| 398 | - * Override if applicable, but ensure that the below actions are |
|
| 399 | - * performed, or, call parent::complete(). |
|
| 400 | - */ |
|
| 401 | - protected function complete() { |
|
| 402 | - // Unschedule the cron healthcheck. |
|
| 403 | - $this->clear_scheduled_event(); |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - /** |
|
| 407 | - * Schedule cron healthcheck |
|
| 408 | - * |
|
| 409 | - * @access public |
|
| 410 | - * |
|
| 411 | - * @param mixed $schedules Schedules. |
|
| 412 | - * |
|
| 413 | - * @return mixed |
|
| 414 | - */ |
|
| 415 | - public function schedule_cron_healthcheck( $schedules ) { |
|
| 416 | - $interval = apply_filters( $this->identifier . '_cron_interval', 5 ); |
|
| 417 | - |
|
| 418 | - if ( property_exists( $this, 'cron_interval' ) ) { |
|
| 419 | - $interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval ); |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - // Adds every 5 minutes to the existing schedules. |
|
| 423 | - $schedules[ $this->identifier . '_cron_interval' ] = array( |
|
| 424 | - 'interval' => MINUTE_IN_SECONDS * $interval, |
|
| 425 | - 'display' => sprintf( __( 'Every %d Minutes' ), $interval ), |
|
| 426 | - ); |
|
| 427 | - |
|
| 428 | - return $schedules; |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * Handle cron healthcheck |
|
| 433 | - * |
|
| 434 | - * Restart the background process if not already running |
|
| 435 | - * and data exists in the queue. |
|
| 436 | - */ |
|
| 437 | - public function handle_cron_healthcheck() { |
|
| 438 | - if ( $this->is_process_running() ) { |
|
| 439 | - // Background process already running. |
|
| 440 | - exit; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - if ( $this->is_queue_empty() ) { |
|
| 444 | - // No data to process. |
|
| 445 | - $this->clear_scheduled_event(); |
|
| 446 | - exit; |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - $this->handle(); |
|
| 450 | - |
|
| 451 | - exit; |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - /** |
|
| 455 | - * Schedule event |
|
| 456 | - */ |
|
| 457 | - protected function schedule_event() { |
|
| 458 | - if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { |
|
| 459 | - wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier ); |
|
| 460 | - } |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - /** |
|
| 464 | - * Clear scheduled event |
|
| 465 | - */ |
|
| 466 | - protected function clear_scheduled_event() { |
|
| 467 | - $timestamp = wp_next_scheduled( $this->cron_hook_identifier ); |
|
| 468 | - |
|
| 469 | - if ( $timestamp ) { |
|
| 470 | - wp_unschedule_event( $timestamp, $this->cron_hook_identifier ); |
|
| 471 | - } |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * Cancel Process |
|
| 476 | - * |
|
| 477 | - * Stop processing queue items, clear cronjob and delete batch. |
|
| 478 | - * |
|
| 479 | - */ |
|
| 480 | - public function cancel_process() { |
|
| 481 | - if ( ! $this->is_queue_empty() ) { |
|
| 482 | - $batch = $this->get_batch(); |
|
| 483 | - |
|
| 484 | - $this->delete( $batch->key ); |
|
| 485 | - |
|
| 486 | - wp_clear_scheduled_hook( $this->cron_hook_identifier ); |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - /** |
|
| 492 | - * Task |
|
| 493 | - * |
|
| 494 | - * Override this method to perform any actions required on each |
|
| 495 | - * queue item. Return the modified item for further processing |
|
| 496 | - * in the next pass through. Or, return false to remove the |
|
| 497 | - * item from the queue. |
|
| 498 | - * |
|
| 499 | - * @param mixed $item Queue item to iterate over. |
|
| 500 | - * |
|
| 501 | - * @return mixed |
|
| 502 | - */ |
|
| 503 | - abstract protected function task( $item ); |
|
| 281 | + $batch = new stdClass(); |
|
| 282 | + $batch->key = $query->$column; |
|
| 283 | + $batch->data = maybe_unserialize( $query->$value_column ); |
|
| 284 | + |
|
| 285 | + return $batch; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * Handle |
|
| 290 | + * |
|
| 291 | + * Pass each queue item to the task handler, while remaining |
|
| 292 | + * within server memory and time limit constraints. |
|
| 293 | + */ |
|
| 294 | + protected function handle() { |
|
| 295 | + $this->lock_process(); |
|
| 296 | + |
|
| 297 | + do { |
|
| 298 | + $batch = $this->get_batch(); |
|
| 299 | + |
|
| 300 | + foreach ( $batch->data as $key => $value ) { |
|
| 301 | + $task = $this->task( $value ); |
|
| 302 | + |
|
| 303 | + if ( false !== $task ) { |
|
| 304 | + $batch->data[ $key ] = $task; |
|
| 305 | + } else { |
|
| 306 | + unset( $batch->data[ $key ] ); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + if ( $this->time_exceeded() || $this->memory_exceeded() ) { |
|
| 310 | + // Batch limits reached. |
|
| 311 | + break; |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + // Update or delete current batch. |
|
| 316 | + if ( ! empty( $batch->data ) ) { |
|
| 317 | + $this->update( $batch->key, $batch->data ); |
|
| 318 | + } else { |
|
| 319 | + $this->delete( $batch->key ); |
|
| 320 | + } |
|
| 321 | + } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() ); |
|
| 322 | + |
|
| 323 | + $this->unlock_process(); |
|
| 324 | + |
|
| 325 | + // Start next batch or complete process. |
|
| 326 | + if ( ! $this->is_queue_empty() ) { |
|
| 327 | + $this->dispatch(); |
|
| 328 | + } else { |
|
| 329 | + $this->complete(); |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + wp_die(); |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * Memory exceeded |
|
| 337 | + * |
|
| 338 | + * Ensures the batch process never exceeds 90% |
|
| 339 | + * of the maximum WordPress memory. |
|
| 340 | + * |
|
| 341 | + * @return bool |
|
| 342 | + */ |
|
| 343 | + protected function memory_exceeded() { |
|
| 344 | + $memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory |
|
| 345 | + $current_memory = memory_get_usage( true ); |
|
| 346 | + $return = false; |
|
| 347 | + |
|
| 348 | + if ( $current_memory >= $memory_limit ) { |
|
| 349 | + $return = true; |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + return apply_filters( $this->identifier . '_memory_exceeded', $return ); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + /** |
|
| 356 | + * Get memory limit |
|
| 357 | + * |
|
| 358 | + * @return int |
|
| 359 | + */ |
|
| 360 | + protected function get_memory_limit() { |
|
| 361 | + if ( function_exists( 'ini_get' ) ) { |
|
| 362 | + $memory_limit = ini_get( 'memory_limit' ); |
|
| 363 | + } else { |
|
| 364 | + // Sensible default. |
|
| 365 | + $memory_limit = '128M'; |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + if ( ! $memory_limit || - 1 === intval( $memory_limit ) ) { |
|
| 369 | + // Unlimited, set to 32GB. |
|
| 370 | + $memory_limit = '32000M'; |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + return wp_convert_hr_to_bytes( $memory_limit ); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * Time exceeded. |
|
| 378 | + * |
|
| 379 | + * Ensures the batch never exceeds a sensible time limit. |
|
| 380 | + * A timeout limit of 30s is common on shared hosting. |
|
| 381 | + * |
|
| 382 | + * @return bool |
|
| 383 | + */ |
|
| 384 | + protected function time_exceeded() { |
|
| 385 | + $finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds |
|
| 386 | + $return = false; |
|
| 387 | + |
|
| 388 | + if ( time() >= $finish ) { |
|
| 389 | + $return = true; |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + return apply_filters( $this->identifier . '_time_exceeded', $return ); |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * Complete. |
|
| 397 | + * |
|
| 398 | + * Override if applicable, but ensure that the below actions are |
|
| 399 | + * performed, or, call parent::complete(). |
|
| 400 | + */ |
|
| 401 | + protected function complete() { |
|
| 402 | + // Unschedule the cron healthcheck. |
|
| 403 | + $this->clear_scheduled_event(); |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * Schedule cron healthcheck |
|
| 408 | + * |
|
| 409 | + * @access public |
|
| 410 | + * |
|
| 411 | + * @param mixed $schedules Schedules. |
|
| 412 | + * |
|
| 413 | + * @return mixed |
|
| 414 | + */ |
|
| 415 | + public function schedule_cron_healthcheck( $schedules ) { |
|
| 416 | + $interval = apply_filters( $this->identifier . '_cron_interval', 5 ); |
|
| 417 | + |
|
| 418 | + if ( property_exists( $this, 'cron_interval' ) ) { |
|
| 419 | + $interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval ); |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + // Adds every 5 minutes to the existing schedules. |
|
| 423 | + $schedules[ $this->identifier . '_cron_interval' ] = array( |
|
| 424 | + 'interval' => MINUTE_IN_SECONDS * $interval, |
|
| 425 | + 'display' => sprintf( __( 'Every %d Minutes' ), $interval ), |
|
| 426 | + ); |
|
| 427 | + |
|
| 428 | + return $schedules; |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * Handle cron healthcheck |
|
| 433 | + * |
|
| 434 | + * Restart the background process if not already running |
|
| 435 | + * and data exists in the queue. |
|
| 436 | + */ |
|
| 437 | + public function handle_cron_healthcheck() { |
|
| 438 | + if ( $this->is_process_running() ) { |
|
| 439 | + // Background process already running. |
|
| 440 | + exit; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + if ( $this->is_queue_empty() ) { |
|
| 444 | + // No data to process. |
|
| 445 | + $this->clear_scheduled_event(); |
|
| 446 | + exit; |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + $this->handle(); |
|
| 450 | + |
|
| 451 | + exit; |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + /** |
|
| 455 | + * Schedule event |
|
| 456 | + */ |
|
| 457 | + protected function schedule_event() { |
|
| 458 | + if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { |
|
| 459 | + wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier ); |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + /** |
|
| 464 | + * Clear scheduled event |
|
| 465 | + */ |
|
| 466 | + protected function clear_scheduled_event() { |
|
| 467 | + $timestamp = wp_next_scheduled( $this->cron_hook_identifier ); |
|
| 468 | + |
|
| 469 | + if ( $timestamp ) { |
|
| 470 | + wp_unschedule_event( $timestamp, $this->cron_hook_identifier ); |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * Cancel Process |
|
| 476 | + * |
|
| 477 | + * Stop processing queue items, clear cronjob and delete batch. |
|
| 478 | + * |
|
| 479 | + */ |
|
| 480 | + public function cancel_process() { |
|
| 481 | + if ( ! $this->is_queue_empty() ) { |
|
| 482 | + $batch = $this->get_batch(); |
|
| 483 | + |
|
| 484 | + $this->delete( $batch->key ); |
|
| 485 | + |
|
| 486 | + wp_clear_scheduled_hook( $this->cron_hook_identifier ); |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + /** |
|
| 492 | + * Task |
|
| 493 | + * |
|
| 494 | + * Override this method to perform any actions required on each |
|
| 495 | + * queue item. Return the modified item for further processing |
|
| 496 | + * in the next pass through. Or, return false to remove the |
|
| 497 | + * item from the queue. |
|
| 498 | + * |
|
| 499 | + * @param mixed $item Queue item to iterate over. |
|
| 500 | + * |
|
| 501 | + * @return mixed |
|
| 502 | + */ |
|
| 503 | + abstract protected function task( $item ); |
|
| 504 | 504 | |
| 505 | 505 | } |
| 506 | 506 | \ No newline at end of file |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | public function __construct() { |
| 56 | 56 | parent::__construct(); |
| 57 | 57 | |
| 58 | - $this->cron_hook_identifier = $this->identifier . '_cron'; |
|
| 59 | - $this->cron_interval_identifier = $this->identifier . '_cron_interval'; |
|
| 58 | + $this->cron_hook_identifier = $this->identifier.'_cron'; |
|
| 59 | + $this->cron_interval_identifier = $this->identifier.'_cron_interval'; |
|
| 60 | 60 | |
| 61 | - add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) ); |
|
| 62 | - add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) ); |
|
| 61 | + add_action($this->cron_hook_identifier, array($this, 'handle_cron_healthcheck')); |
|
| 62 | + add_filter('cron_schedules', array($this, 'schedule_cron_healthcheck')); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return $this |
| 85 | 85 | */ |
| 86 | - public function push_to_queue( $data ) { |
|
| 86 | + public function push_to_queue($data) { |
|
| 87 | 87 | $this->data[] = $data; |
| 88 | 88 | |
| 89 | 89 | return $this; |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | public function save() { |
| 98 | 98 | $key = $this->generate_key(); |
| 99 | 99 | |
| 100 | - if ( ! empty( $this->data ) ) { |
|
| 101 | - update_site_option( $key, $this->data ); |
|
| 100 | + if ( ! empty($this->data)) { |
|
| 101 | + update_site_option($key, $this->data); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | return $this; |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return $this |
| 114 | 114 | */ |
| 115 | - public function update( $key, $data ) { |
|
| 116 | - if ( ! empty( $data ) ) { |
|
| 117 | - update_site_option( $key, $data ); |
|
| 115 | + public function update($key, $data) { |
|
| 116 | + if ( ! empty($data)) { |
|
| 117 | + update_site_option($key, $data); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return $this; |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @return $this |
| 129 | 129 | */ |
| 130 | - public function delete( $key ) { |
|
| 131 | - delete_site_option( $key ); |
|
| 130 | + public function delete($key) { |
|
| 131 | + delete_site_option($key); |
|
| 132 | 132 | |
| 133 | 133 | return $this; |
| 134 | 134 | } |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @return string |
| 145 | 145 | */ |
| 146 | - protected function generate_key( $length = 64 ) { |
|
| 147 | - $unique = md5( microtime() . rand() ); |
|
| 148 | - $prepend = $this->identifier . '_batch_'; |
|
| 146 | + protected function generate_key($length = 64) { |
|
| 147 | + $unique = md5(microtime().rand()); |
|
| 148 | + $prepend = $this->identifier.'_batch_'; |
|
| 149 | 149 | |
| 150 | - return substr( $prepend . $unique, 0, $length ); |
|
| 150 | + return substr($prepend.$unique, 0, $length); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -160,17 +160,17 @@ discard block |
||
| 160 | 160 | // Don't lock up other requests while processing |
| 161 | 161 | session_write_close(); |
| 162 | 162 | |
| 163 | - if ( $this->is_process_running() ) { |
|
| 163 | + if ($this->is_process_running()) { |
|
| 164 | 164 | // Background process already running. |
| 165 | 165 | wp_die(); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if ( $this->is_queue_empty() ) { |
|
| 168 | + if ($this->is_queue_empty()) { |
|
| 169 | 169 | // No data to process. |
| 170 | 170 | wp_die(); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
| 173 | + check_ajax_referer($this->identifier, 'nonce'); |
|
| 174 | 174 | |
| 175 | 175 | $this->handle(); |
| 176 | 176 | |
@@ -188,20 +188,20 @@ discard block |
||
| 188 | 188 | $table = $wpdb->options; |
| 189 | 189 | $column = 'option_name'; |
| 190 | 190 | |
| 191 | - if ( is_multisite() ) { |
|
| 191 | + if (is_multisite()) { |
|
| 192 | 192 | $table = $wpdb->sitemeta; |
| 193 | 193 | $column = 'meta_key'; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; |
|
| 196 | + $key = $wpdb->esc_like($this->identifier.'_batch_').'%'; |
|
| 197 | 197 | |
| 198 | - $count = $wpdb->get_var( $wpdb->prepare( " |
|
| 198 | + $count = $wpdb->get_var($wpdb->prepare(" |
|
| 199 | 199 | SELECT COUNT(*) |
| 200 | 200 | FROM {$table} |
| 201 | 201 | WHERE {$column} LIKE %s |
| 202 | - ", $key ) ); |
|
| 202 | + ", $key)); |
|
| 203 | 203 | |
| 204 | - return ( $count > 0 ) ? false : true; |
|
| 204 | + return ($count > 0) ? false : true; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * in a background process. |
| 212 | 212 | */ |
| 213 | 213 | protected function is_process_running() { |
| 214 | - if ( get_site_transient( $this->identifier . '_process_lock' ) ) { |
|
| 214 | + if (get_site_transient($this->identifier.'_process_lock')) { |
|
| 215 | 215 | // Process already running. |
| 216 | 216 | return true; |
| 217 | 217 | } |
@@ -229,10 +229,10 @@ discard block |
||
| 229 | 229 | protected function lock_process() { |
| 230 | 230 | $this->start_time = time(); // Set start time of current process. |
| 231 | 231 | |
| 232 | - $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute |
|
| 233 | - $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration ); |
|
| 232 | + $lock_duration = (property_exists($this, 'queue_lock_time')) ? $this->queue_lock_time : 60; // 1 minute |
|
| 233 | + $lock_duration = apply_filters($this->identifier.'_queue_lock_time', $lock_duration); |
|
| 234 | 234 | |
| 235 | - set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration ); |
|
| 235 | + set_site_transient($this->identifier.'_process_lock', microtime(), $lock_duration); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @return $this |
| 244 | 244 | */ |
| 245 | 245 | protected function unlock_process() { |
| 246 | - delete_site_transient( $this->identifier . '_process_lock' ); |
|
| 246 | + delete_site_transient($this->identifier.'_process_lock'); |
|
| 247 | 247 | |
| 248 | 248 | return $this; |
| 249 | 249 | } |
@@ -261,26 +261,26 @@ discard block |
||
| 261 | 261 | $key_column = 'option_id'; |
| 262 | 262 | $value_column = 'option_value'; |
| 263 | 263 | |
| 264 | - if ( is_multisite() ) { |
|
| 264 | + if (is_multisite()) { |
|
| 265 | 265 | $table = $wpdb->sitemeta; |
| 266 | 266 | $column = 'meta_key'; |
| 267 | 267 | $key_column = 'meta_id'; |
| 268 | 268 | $value_column = 'meta_value'; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; |
|
| 271 | + $key = $wpdb->esc_like($this->identifier.'_batch_').'%'; |
|
| 272 | 272 | |
| 273 | - $query = $wpdb->get_row( $wpdb->prepare( " |
|
| 273 | + $query = $wpdb->get_row($wpdb->prepare(" |
|
| 274 | 274 | SELECT * |
| 275 | 275 | FROM {$table} |
| 276 | 276 | WHERE {$column} LIKE %s |
| 277 | 277 | ORDER BY {$key_column} ASC |
| 278 | 278 | LIMIT 1 |
| 279 | - ", $key ) ); |
|
| 279 | + ", $key)); |
|
| 280 | 280 | |
| 281 | 281 | $batch = new stdClass(); |
| 282 | 282 | $batch->key = $query->$column; |
| 283 | - $batch->data = maybe_unserialize( $query->$value_column ); |
|
| 283 | + $batch->data = maybe_unserialize($query->$value_column); |
|
| 284 | 284 | |
| 285 | 285 | return $batch; |
| 286 | 286 | } |
@@ -297,33 +297,33 @@ discard block |
||
| 297 | 297 | do { |
| 298 | 298 | $batch = $this->get_batch(); |
| 299 | 299 | |
| 300 | - foreach ( $batch->data as $key => $value ) { |
|
| 301 | - $task = $this->task( $value ); |
|
| 300 | + foreach ($batch->data as $key => $value) { |
|
| 301 | + $task = $this->task($value); |
|
| 302 | 302 | |
| 303 | - if ( false !== $task ) { |
|
| 304 | - $batch->data[ $key ] = $task; |
|
| 303 | + if (false !== $task) { |
|
| 304 | + $batch->data[$key] = $task; |
|
| 305 | 305 | } else { |
| 306 | - unset( $batch->data[ $key ] ); |
|
| 306 | + unset($batch->data[$key]); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - if ( $this->time_exceeded() || $this->memory_exceeded() ) { |
|
| 309 | + if ($this->time_exceeded() || $this->memory_exceeded()) { |
|
| 310 | 310 | // Batch limits reached. |
| 311 | 311 | break; |
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // Update or delete current batch. |
| 316 | - if ( ! empty( $batch->data ) ) { |
|
| 317 | - $this->update( $batch->key, $batch->data ); |
|
| 316 | + if ( ! empty($batch->data)) { |
|
| 317 | + $this->update($batch->key, $batch->data); |
|
| 318 | 318 | } else { |
| 319 | - $this->delete( $batch->key ); |
|
| 319 | + $this->delete($batch->key); |
|
| 320 | 320 | } |
| 321 | - } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() ); |
|
| 321 | + } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty()); |
|
| 322 | 322 | |
| 323 | 323 | $this->unlock_process(); |
| 324 | 324 | |
| 325 | 325 | // Start next batch or complete process. |
| 326 | - if ( ! $this->is_queue_empty() ) { |
|
| 326 | + if ( ! $this->is_queue_empty()) { |
|
| 327 | 327 | $this->dispatch(); |
| 328 | 328 | } else { |
| 329 | 329 | $this->complete(); |
@@ -342,14 +342,14 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | protected function memory_exceeded() { |
| 344 | 344 | $memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory |
| 345 | - $current_memory = memory_get_usage( true ); |
|
| 345 | + $current_memory = memory_get_usage(true); |
|
| 346 | 346 | $return = false; |
| 347 | 347 | |
| 348 | - if ( $current_memory >= $memory_limit ) { |
|
| 348 | + if ($current_memory >= $memory_limit) { |
|
| 349 | 349 | $return = true; |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - return apply_filters( $this->identifier . '_memory_exceeded', $return ); |
|
| 352 | + return apply_filters($this->identifier.'_memory_exceeded', $return); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | /** |
@@ -358,19 +358,19 @@ discard block |
||
| 358 | 358 | * @return int |
| 359 | 359 | */ |
| 360 | 360 | protected function get_memory_limit() { |
| 361 | - if ( function_exists( 'ini_get' ) ) { |
|
| 362 | - $memory_limit = ini_get( 'memory_limit' ); |
|
| 361 | + if (function_exists('ini_get')) { |
|
| 362 | + $memory_limit = ini_get('memory_limit'); |
|
| 363 | 363 | } else { |
| 364 | 364 | // Sensible default. |
| 365 | 365 | $memory_limit = '128M'; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - if ( ! $memory_limit || - 1 === intval( $memory_limit ) ) { |
|
| 368 | + if ( ! $memory_limit || - 1 === intval($memory_limit)) { |
|
| 369 | 369 | // Unlimited, set to 32GB. |
| 370 | 370 | $memory_limit = '32000M'; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - return wp_convert_hr_to_bytes( $memory_limit ); |
|
| 373 | + return wp_convert_hr_to_bytes($memory_limit); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /** |
@@ -382,14 +382,14 @@ discard block |
||
| 382 | 382 | * @return bool |
| 383 | 383 | */ |
| 384 | 384 | protected function time_exceeded() { |
| 385 | - $finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds |
|
| 385 | + $finish = $this->start_time + apply_filters($this->identifier.'_default_time_limit', 20); // 20 seconds |
|
| 386 | 386 | $return = false; |
| 387 | 387 | |
| 388 | - if ( time() >= $finish ) { |
|
| 388 | + if (time() >= $finish) { |
|
| 389 | 389 | $return = true; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - return apply_filters( $this->identifier . '_time_exceeded', $return ); |
|
| 392 | + return apply_filters($this->identifier.'_time_exceeded', $return); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -412,17 +412,17 @@ discard block |
||
| 412 | 412 | * |
| 413 | 413 | * @return mixed |
| 414 | 414 | */ |
| 415 | - public function schedule_cron_healthcheck( $schedules ) { |
|
| 416 | - $interval = apply_filters( $this->identifier . '_cron_interval', 5 ); |
|
| 415 | + public function schedule_cron_healthcheck($schedules) { |
|
| 416 | + $interval = apply_filters($this->identifier.'_cron_interval', 5); |
|
| 417 | 417 | |
| 418 | - if ( property_exists( $this, 'cron_interval' ) ) { |
|
| 419 | - $interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval ); |
|
| 418 | + if (property_exists($this, 'cron_interval')) { |
|
| 419 | + $interval = apply_filters($this->identifier.'_cron_interval', $this->cron_interval); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // Adds every 5 minutes to the existing schedules. |
| 423 | - $schedules[ $this->identifier . '_cron_interval' ] = array( |
|
| 423 | + $schedules[$this->identifier.'_cron_interval'] = array( |
|
| 424 | 424 | 'interval' => MINUTE_IN_SECONDS * $interval, |
| 425 | - 'display' => sprintf( __( 'Every %d Minutes' ), $interval ), |
|
| 425 | + 'display' => sprintf(__('Every %d Minutes'), $interval), |
|
| 426 | 426 | ); |
| 427 | 427 | |
| 428 | 428 | return $schedules; |
@@ -435,12 +435,12 @@ discard block |
||
| 435 | 435 | * and data exists in the queue. |
| 436 | 436 | */ |
| 437 | 437 | public function handle_cron_healthcheck() { |
| 438 | - if ( $this->is_process_running() ) { |
|
| 438 | + if ($this->is_process_running()) { |
|
| 439 | 439 | // Background process already running. |
| 440 | 440 | exit; |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - if ( $this->is_queue_empty() ) { |
|
| 443 | + if ($this->is_queue_empty()) { |
|
| 444 | 444 | // No data to process. |
| 445 | 445 | $this->clear_scheduled_event(); |
| 446 | 446 | exit; |
@@ -455,8 +455,8 @@ discard block |
||
| 455 | 455 | * Schedule event |
| 456 | 456 | */ |
| 457 | 457 | protected function schedule_event() { |
| 458 | - if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { |
|
| 459 | - wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier ); |
|
| 458 | + if ( ! wp_next_scheduled($this->cron_hook_identifier)) { |
|
| 459 | + wp_schedule_event(time(), $this->cron_interval_identifier, $this->cron_hook_identifier); |
|
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | |
@@ -464,10 +464,10 @@ discard block |
||
| 464 | 464 | * Clear scheduled event |
| 465 | 465 | */ |
| 466 | 466 | protected function clear_scheduled_event() { |
| 467 | - $timestamp = wp_next_scheduled( $this->cron_hook_identifier ); |
|
| 467 | + $timestamp = wp_next_scheduled($this->cron_hook_identifier); |
|
| 468 | 468 | |
| 469 | - if ( $timestamp ) { |
|
| 470 | - wp_unschedule_event( $timestamp, $this->cron_hook_identifier ); |
|
| 469 | + if ($timestamp) { |
|
| 470 | + wp_unschedule_event($timestamp, $this->cron_hook_identifier); |
|
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | |
@@ -478,12 +478,12 @@ discard block |
||
| 478 | 478 | * |
| 479 | 479 | */ |
| 480 | 480 | public function cancel_process() { |
| 481 | - if ( ! $this->is_queue_empty() ) { |
|
| 481 | + if ( ! $this->is_queue_empty()) { |
|
| 482 | 482 | $batch = $this->get_batch(); |
| 483 | 483 | |
| 484 | - $this->delete( $batch->key ); |
|
| 484 | + $this->delete($batch->key); |
|
| 485 | 485 | |
| 486 | - wp_clear_scheduled_hook( $this->cron_hook_identifier ); |
|
| 486 | + wp_clear_scheduled_hook($this->cron_hook_identifier); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | } |
@@ -500,6 +500,6 @@ discard block |
||
| 500 | 500 | * |
| 501 | 501 | * @return mixed |
| 502 | 502 | */ |
| 503 | - abstract protected function task( $item ); |
|
| 503 | + abstract protected function task($item); |
|
| 504 | 504 | |
| 505 | 505 | } |
| 506 | 506 | \ No newline at end of file |
@@ -70,6 +70,9 @@ |
||
| 70 | 70 | return self::$instance; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | + /** |
|
| 74 | + * @param string $method |
|
| 75 | + */ |
|
| 73 | 76 | public function request( $method, $url, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) { |
| 74 | 77 | |
| 75 | 78 | // Get the timeout for this request. |
@@ -7,114 +7,114 @@ |
||
| 7 | 7 | namespace Wordlift\Api; |
| 8 | 8 | |
| 9 | 9 | class Default_Api_Service implements Api_Service { |
| 10 | - /** |
|
| 11 | - * @var Default_Api_Service |
|
| 12 | - */ |
|
| 13 | - private static $instance; |
|
| 14 | - |
|
| 15 | - /** |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 18 | - private $wordlift_key; |
|
| 19 | - /** |
|
| 20 | - * @var int |
|
| 21 | - */ |
|
| 22 | - private $timeout; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - private $user_agent; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 32 | - private $headers; |
|
| 33 | - /** |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 36 | - private $base_url; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var \Wordlift_Log_Service |
|
| 40 | - */ |
|
| 41 | - private $log; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Default_Api_Service constructor. |
|
| 45 | - * |
|
| 46 | - * @param string $base_url |
|
| 47 | - * @param int $timeout |
|
| 48 | - * @param string $user_agent |
|
| 49 | - * @param string $wordlift_key |
|
| 50 | - */ |
|
| 51 | - public function __construct( $base_url, $timeout, $user_agent, $wordlift_key ) { |
|
| 52 | - |
|
| 53 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 54 | - |
|
| 55 | - $this->base_url = $base_url; |
|
| 56 | - $this->timeout = $timeout; |
|
| 57 | - $this->user_agent = $user_agent; |
|
| 58 | - $this->wordlift_key = $wordlift_key; |
|
| 59 | - |
|
| 60 | - $this->headers = array( |
|
| 61 | - 'Content-Type' => 'application/json', |
|
| 62 | - 'Authorization' => "Key $wordlift_key", |
|
| 63 | - 'Expect' => '', |
|
| 64 | - ); |
|
| 65 | - |
|
| 66 | - self::$instance = $this; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - public static function get_instance() { |
|
| 70 | - return self::$instance; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - public function request( $method, $url, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) { |
|
| 74 | - |
|
| 75 | - // Get the timeout for this request. |
|
| 76 | - $request_timeout = isset( $timeout ) ? $timeout : $this->timeout; |
|
| 77 | - |
|
| 78 | - // Set the time limit if lesser than our request timeout. |
|
| 79 | - $max_execution_time = ini_get( 'max_execution_time' ); |
|
| 80 | - if ( $max_execution_time < $request_timeout ) { |
|
| 81 | - @set_time_limit( $request_timeout ); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - $request_url = $this->base_url . $url; |
|
| 85 | - |
|
| 86 | - // Create the request args in the following order: |
|
| 87 | - // 1. use `$args` as base if provided. |
|
| 88 | - // 2. set the custom timeout if provided. |
|
| 89 | - // 3. set the custom user-agent if provided. |
|
| 90 | - // 4. merge the API headers to the provided headers. |
|
| 91 | - // 5. add the body. |
|
| 92 | - // |
|
| 93 | - // In this way the user can fully control the request if wanted (using `$args`) and we can add our defaults. |
|
| 94 | - $request_args = $args + array( |
|
| 95 | - 'method' => $method, |
|
| 96 | - 'timeout' => $request_timeout, |
|
| 97 | - 'user-agent' => isset( $user_agent ) ? $user_agent : $this->user_agent, |
|
| 98 | - 'headers' => $headers + $this->headers, |
|
| 99 | - 'body' => $body, |
|
| 100 | - ); |
|
| 101 | - |
|
| 102 | - $response = wp_remote_request( $request_url, $request_args ); |
|
| 103 | - |
|
| 104 | - if ( defined( 'WL_DEBUG' ) && WL_DEBUG ) { |
|
| 105 | - $this->log->trace( |
|
| 106 | - "=== REQUEST ===========================\n" |
|
| 107 | - . var_export( $request_args, true ) |
|
| 108 | - . "=== RESPONSE ===========================\n" |
|
| 109 | - . var_export( $response, true ) ); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - return new Response( $response ); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - public function get( $url, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) { |
|
| 116 | - |
|
| 117 | - return $this->request( 'GET', $url, $headers, $body, $timeout, $user_agent, $args ); |
|
| 118 | - } |
|
| 10 | + /** |
|
| 11 | + * @var Default_Api_Service |
|
| 12 | + */ |
|
| 13 | + private static $instance; |
|
| 14 | + |
|
| 15 | + /** |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | + private $wordlift_key; |
|
| 19 | + /** |
|
| 20 | + * @var int |
|
| 21 | + */ |
|
| 22 | + private $timeout; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + private $user_agent; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | + private $headers; |
|
| 33 | + /** |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | + private $base_url; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var \Wordlift_Log_Service |
|
| 40 | + */ |
|
| 41 | + private $log; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Default_Api_Service constructor. |
|
| 45 | + * |
|
| 46 | + * @param string $base_url |
|
| 47 | + * @param int $timeout |
|
| 48 | + * @param string $user_agent |
|
| 49 | + * @param string $wordlift_key |
|
| 50 | + */ |
|
| 51 | + public function __construct( $base_url, $timeout, $user_agent, $wordlift_key ) { |
|
| 52 | + |
|
| 53 | + $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 54 | + |
|
| 55 | + $this->base_url = $base_url; |
|
| 56 | + $this->timeout = $timeout; |
|
| 57 | + $this->user_agent = $user_agent; |
|
| 58 | + $this->wordlift_key = $wordlift_key; |
|
| 59 | + |
|
| 60 | + $this->headers = array( |
|
| 61 | + 'Content-Type' => 'application/json', |
|
| 62 | + 'Authorization' => "Key $wordlift_key", |
|
| 63 | + 'Expect' => '', |
|
| 64 | + ); |
|
| 65 | + |
|
| 66 | + self::$instance = $this; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + public static function get_instance() { |
|
| 70 | + return self::$instance; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + public function request( $method, $url, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) { |
|
| 74 | + |
|
| 75 | + // Get the timeout for this request. |
|
| 76 | + $request_timeout = isset( $timeout ) ? $timeout : $this->timeout; |
|
| 77 | + |
|
| 78 | + // Set the time limit if lesser than our request timeout. |
|
| 79 | + $max_execution_time = ini_get( 'max_execution_time' ); |
|
| 80 | + if ( $max_execution_time < $request_timeout ) { |
|
| 81 | + @set_time_limit( $request_timeout ); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + $request_url = $this->base_url . $url; |
|
| 85 | + |
|
| 86 | + // Create the request args in the following order: |
|
| 87 | + // 1. use `$args` as base if provided. |
|
| 88 | + // 2. set the custom timeout if provided. |
|
| 89 | + // 3. set the custom user-agent if provided. |
|
| 90 | + // 4. merge the API headers to the provided headers. |
|
| 91 | + // 5. add the body. |
|
| 92 | + // |
|
| 93 | + // In this way the user can fully control the request if wanted (using `$args`) and we can add our defaults. |
|
| 94 | + $request_args = $args + array( |
|
| 95 | + 'method' => $method, |
|
| 96 | + 'timeout' => $request_timeout, |
|
| 97 | + 'user-agent' => isset( $user_agent ) ? $user_agent : $this->user_agent, |
|
| 98 | + 'headers' => $headers + $this->headers, |
|
| 99 | + 'body' => $body, |
|
| 100 | + ); |
|
| 101 | + |
|
| 102 | + $response = wp_remote_request( $request_url, $request_args ); |
|
| 103 | + |
|
| 104 | + if ( defined( 'WL_DEBUG' ) && WL_DEBUG ) { |
|
| 105 | + $this->log->trace( |
|
| 106 | + "=== REQUEST ===========================\n" |
|
| 107 | + . var_export( $request_args, true ) |
|
| 108 | + . "=== RESPONSE ===========================\n" |
|
| 109 | + . var_export( $response, true ) ); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + return new Response( $response ); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + public function get( $url, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) { |
|
| 116 | + |
|
| 117 | + return $this->request( 'GET', $url, $headers, $body, $timeout, $user_agent, $args ); |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | 120 | } |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | * @param string $user_agent |
| 49 | 49 | * @param string $wordlift_key |
| 50 | 50 | */ |
| 51 | - public function __construct( $base_url, $timeout, $user_agent, $wordlift_key ) { |
|
| 51 | + public function __construct($base_url, $timeout, $user_agent, $wordlift_key) { |
|
| 52 | 52 | |
| 53 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 53 | + $this->log = \Wordlift_Log_Service::get_logger(get_class()); |
|
| 54 | 54 | |
| 55 | 55 | $this->base_url = $base_url; |
| 56 | 56 | $this->timeout = $timeout; |
@@ -70,18 +70,18 @@ discard block |
||
| 70 | 70 | return self::$instance; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function request( $method, $url, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) { |
|
| 73 | + public function request($method, $url, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array()) { |
|
| 74 | 74 | |
| 75 | 75 | // Get the timeout for this request. |
| 76 | - $request_timeout = isset( $timeout ) ? $timeout : $this->timeout; |
|
| 76 | + $request_timeout = isset($timeout) ? $timeout : $this->timeout; |
|
| 77 | 77 | |
| 78 | 78 | // Set the time limit if lesser than our request timeout. |
| 79 | - $max_execution_time = ini_get( 'max_execution_time' ); |
|
| 80 | - if ( $max_execution_time < $request_timeout ) { |
|
| 81 | - @set_time_limit( $request_timeout ); |
|
| 79 | + $max_execution_time = ini_get('max_execution_time'); |
|
| 80 | + if ($max_execution_time < $request_timeout) { |
|
| 81 | + @set_time_limit($request_timeout); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $request_url = $this->base_url . $url; |
|
| 84 | + $request_url = $this->base_url.$url; |
|
| 85 | 85 | |
| 86 | 86 | // Create the request args in the following order: |
| 87 | 87 | // 1. use `$args` as base if provided. |
@@ -94,27 +94,27 @@ discard block |
||
| 94 | 94 | $request_args = $args + array( |
| 95 | 95 | 'method' => $method, |
| 96 | 96 | 'timeout' => $request_timeout, |
| 97 | - 'user-agent' => isset( $user_agent ) ? $user_agent : $this->user_agent, |
|
| 97 | + 'user-agent' => isset($user_agent) ? $user_agent : $this->user_agent, |
|
| 98 | 98 | 'headers' => $headers + $this->headers, |
| 99 | 99 | 'body' => $body, |
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | - $response = wp_remote_request( $request_url, $request_args ); |
|
| 102 | + $response = wp_remote_request($request_url, $request_args); |
|
| 103 | 103 | |
| 104 | - if ( defined( 'WL_DEBUG' ) && WL_DEBUG ) { |
|
| 104 | + if (defined('WL_DEBUG') && WL_DEBUG) { |
|
| 105 | 105 | $this->log->trace( |
| 106 | 106 | "=== REQUEST ===========================\n" |
| 107 | - . var_export( $request_args, true ) |
|
| 107 | + . var_export($request_args, true) |
|
| 108 | 108 | . "=== RESPONSE ===========================\n" |
| 109 | - . var_export( $response, true ) ); |
|
| 109 | + . var_export($response, true) ); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - return new Response( $response ); |
|
| 112 | + return new Response($response); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - public function get( $url, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) { |
|
| 115 | + public function get($url, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array()) { |
|
| 116 | 116 | |
| 117 | - return $this->request( 'GET', $url, $headers, $body, $timeout, $user_agent, $args ); |
|
| 117 | + return $this->request('GET', $url, $headers, $body, $timeout, $user_agent, $args); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | /** |
| 22 | 22 | * Sync_Background_Process constructor. |
| 23 | 23 | * |
| 24 | - * @param $sync_service Sync_Service A {@link Sync_Service} instance providing the supporting functions to this background process. |
|
| 24 | + * @param Sync_Service $sync_service Sync_Service A {@link Sync_Service} instance providing the supporting functions to this background process. |
|
| 25 | 25 | */ |
| 26 | 26 | public function __construct( $sync_service ) { |
| 27 | 27 | parent::__construct(); |
@@ -6,183 +6,183 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Sync_Background_Process extends \Wordlift_Plugin_WP_Background_Process { |
| 8 | 8 | |
| 9 | - protected $action = 'wl_dataset__sync'; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @var Sync_Service |
|
| 13 | - */ |
|
| 14 | - private $sync_service; |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * @var \Wordlift_Log_Service |
|
| 18 | - */ |
|
| 19 | - private $log; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Sync_Background_Process constructor. |
|
| 23 | - * |
|
| 24 | - * @param $sync_service Sync_Service A {@link Sync_Service} instance providing the supporting functions to this background process. |
|
| 25 | - */ |
|
| 26 | - public function __construct( $sync_service ) { |
|
| 27 | - parent::__construct(); |
|
| 28 | - |
|
| 29 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 30 | - |
|
| 31 | - $this->sync_service = $sync_service; |
|
| 32 | - |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * This function is called: |
|
| 37 | - * - To start a new Synchronization, by passing a {@link Sync_Start_Message} instance. |
|
| 38 | - * - To synchronize a post, by passing a numeric ID. |
|
| 39 | - * |
|
| 40 | - * This function returns the parameter for the next call or NULL if there are no more posts to process. |
|
| 41 | - * |
|
| 42 | - * @param int $post_id The post ID. |
|
| 43 | - * |
|
| 44 | - * @return int|false The next post ID or false if there are no more. |
|
| 45 | - */ |
|
| 46 | - protected function task( $post_id ) { |
|
| 47 | - |
|
| 48 | - // Check if we must cancel. |
|
| 49 | - if ( $this->must_cancel() ) { |
|
| 50 | - $this->cancel(); |
|
| 51 | - |
|
| 52 | - return false; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - $this->log->debug( "Synchronizing post $post_id..." ); |
|
| 56 | - |
|
| 57 | - // Sync the item. |
|
| 58 | - return $this->sync_item( $post_id ); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Start the background processing. |
|
| 63 | - * |
|
| 64 | - * @return bool True if the process has been started, otherwise false. |
|
| 65 | - */ |
|
| 66 | - public function start() { |
|
| 67 | - |
|
| 68 | - // Create a new Sync_Model state of `started`. |
|
| 69 | - if ( ! $this->is_started( self::get_state() ) ) { |
|
| 70 | - $this->log->debug( "Starting..." ); |
|
| 71 | - |
|
| 72 | - $sync_state = new Sync_State( time(), 0, $this->sync_service->count(), time(), 'started' ); |
|
| 73 | - update_option( '_wl_dataset_sync', $sync_state ); |
|
| 74 | - |
|
| 75 | - $next = $this->sync_service->next(); |
|
| 76 | - $this->push_to_queue( $next ); |
|
| 77 | - $this->save()->dispatch(); |
|
| 78 | - |
|
| 79 | - $this->log->debug( "Started with post ID $next." ); |
|
| 80 | - |
|
| 81 | - return true; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - return false; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Set the transient to cancel the process. The next time the process runs, it'll check whether this transient is |
|
| 89 | - * set and will stop processing. |
|
| 90 | - */ |
|
| 91 | - public function request_cancel() { |
|
| 92 | - |
|
| 93 | - set_transient( "{$this->action}__cancel", true ); |
|
| 94 | - |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Get the sync state. |
|
| 99 | - * |
|
| 100 | - * @return Sync_State The {@link Sync_State}. |
|
| 101 | - */ |
|
| 102 | - public static function get_state() { |
|
| 103 | - |
|
| 104 | - try { |
|
| 105 | - return get_option( '_wl_dataset_sync', Sync_State::unknown() ); |
|
| 106 | - } catch ( Exception $e ) { |
|
| 107 | - return Sync_State::unknown(); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Check whether the provided state is `started` or not. |
|
| 114 | - * |
|
| 115 | - * @param Sync_State $state The {@link Sync_State}. |
|
| 116 | - * |
|
| 117 | - * @return bool True if the state is started. |
|
| 118 | - */ |
|
| 119 | - private function is_started( $state ) { |
|
| 120 | - return $state instanceof Sync_State && 'started' === $state->state && 30 > ( time() - $state->last_update ); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Check whether the process must cancel or not. |
|
| 125 | - * |
|
| 126 | - * @return bool Whether to cancel or not the process. |
|
| 127 | - */ |
|
| 128 | - private function must_cancel() { |
|
| 129 | - |
|
| 130 | - return get_transient( "{$this->action}__cancel" ); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Cancels the current process. |
|
| 135 | - */ |
|
| 136 | - private function cancel() { |
|
| 137 | - |
|
| 138 | - $this->log->debug( "Cancelling synchronization..." ); |
|
| 139 | - |
|
| 140 | - // Cleanup the process data. |
|
| 141 | - $this->cancel_process(); |
|
| 142 | - |
|
| 143 | - // Set the state to cancelled. |
|
| 144 | - $state = self::get_state(); |
|
| 145 | - $state->set_state( 'cancelled' ); |
|
| 146 | - update_option( '_wl_dataset_sync', $state ); |
|
| 147 | - |
|
| 148 | - // Finally delete the transient. |
|
| 149 | - delete_transient( "{$this->action}__cancel" ); |
|
| 150 | - |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Push the post with the provided ID to the remote platform. |
|
| 155 | - * |
|
| 156 | - * @param int $post_id The post ID. |
|
| 157 | - * |
|
| 158 | - * @return int|false The next post ID to process or false if processing is complete. |
|
| 159 | - */ |
|
| 160 | - private function sync_item( $post_id ) { |
|
| 161 | - |
|
| 162 | - // Sync this item. |
|
| 163 | - if ( $this->sync_service->sync_item( $post_id ) ) { |
|
| 164 | - |
|
| 165 | - $next = $this->sync_service->next(); |
|
| 166 | - $next_state = isset( $next ) ? 'started' : 'ended'; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Update the synchronization meta data, by increasing the current index. |
|
| 170 | - * |
|
| 171 | - * @var Sync_State $sync The {@link Sync_State}. |
|
| 172 | - */ |
|
| 173 | - $state = self::get_state() |
|
| 174 | - ->increment_index() |
|
| 175 | - ->set_state( $next_state ); |
|
| 176 | - update_option( '_wl_dataset_sync', $state ); |
|
| 177 | - |
|
| 178 | - // Return the next ID or false if there aren't. |
|
| 179 | - return isset( $next ) ? (int) $next : false; |
|
| 180 | - } else { |
|
| 181 | - // Retry. |
|
| 182 | - // @@todo: put a limit to the number of retries. |
|
| 183 | - return $post_id; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - } |
|
| 9 | + protected $action = 'wl_dataset__sync'; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @var Sync_Service |
|
| 13 | + */ |
|
| 14 | + private $sync_service; |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * @var \Wordlift_Log_Service |
|
| 18 | + */ |
|
| 19 | + private $log; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Sync_Background_Process constructor. |
|
| 23 | + * |
|
| 24 | + * @param $sync_service Sync_Service A {@link Sync_Service} instance providing the supporting functions to this background process. |
|
| 25 | + */ |
|
| 26 | + public function __construct( $sync_service ) { |
|
| 27 | + parent::__construct(); |
|
| 28 | + |
|
| 29 | + $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 30 | + |
|
| 31 | + $this->sync_service = $sync_service; |
|
| 32 | + |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * This function is called: |
|
| 37 | + * - To start a new Synchronization, by passing a {@link Sync_Start_Message} instance. |
|
| 38 | + * - To synchronize a post, by passing a numeric ID. |
|
| 39 | + * |
|
| 40 | + * This function returns the parameter for the next call or NULL if there are no more posts to process. |
|
| 41 | + * |
|
| 42 | + * @param int $post_id The post ID. |
|
| 43 | + * |
|
| 44 | + * @return int|false The next post ID or false if there are no more. |
|
| 45 | + */ |
|
| 46 | + protected function task( $post_id ) { |
|
| 47 | + |
|
| 48 | + // Check if we must cancel. |
|
| 49 | + if ( $this->must_cancel() ) { |
|
| 50 | + $this->cancel(); |
|
| 51 | + |
|
| 52 | + return false; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + $this->log->debug( "Synchronizing post $post_id..." ); |
|
| 56 | + |
|
| 57 | + // Sync the item. |
|
| 58 | + return $this->sync_item( $post_id ); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Start the background processing. |
|
| 63 | + * |
|
| 64 | + * @return bool True if the process has been started, otherwise false. |
|
| 65 | + */ |
|
| 66 | + public function start() { |
|
| 67 | + |
|
| 68 | + // Create a new Sync_Model state of `started`. |
|
| 69 | + if ( ! $this->is_started( self::get_state() ) ) { |
|
| 70 | + $this->log->debug( "Starting..." ); |
|
| 71 | + |
|
| 72 | + $sync_state = new Sync_State( time(), 0, $this->sync_service->count(), time(), 'started' ); |
|
| 73 | + update_option( '_wl_dataset_sync', $sync_state ); |
|
| 74 | + |
|
| 75 | + $next = $this->sync_service->next(); |
|
| 76 | + $this->push_to_queue( $next ); |
|
| 77 | + $this->save()->dispatch(); |
|
| 78 | + |
|
| 79 | + $this->log->debug( "Started with post ID $next." ); |
|
| 80 | + |
|
| 81 | + return true; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Set the transient to cancel the process. The next time the process runs, it'll check whether this transient is |
|
| 89 | + * set and will stop processing. |
|
| 90 | + */ |
|
| 91 | + public function request_cancel() { |
|
| 92 | + |
|
| 93 | + set_transient( "{$this->action}__cancel", true ); |
|
| 94 | + |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Get the sync state. |
|
| 99 | + * |
|
| 100 | + * @return Sync_State The {@link Sync_State}. |
|
| 101 | + */ |
|
| 102 | + public static function get_state() { |
|
| 103 | + |
|
| 104 | + try { |
|
| 105 | + return get_option( '_wl_dataset_sync', Sync_State::unknown() ); |
|
| 106 | + } catch ( Exception $e ) { |
|
| 107 | + return Sync_State::unknown(); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Check whether the provided state is `started` or not. |
|
| 114 | + * |
|
| 115 | + * @param Sync_State $state The {@link Sync_State}. |
|
| 116 | + * |
|
| 117 | + * @return bool True if the state is started. |
|
| 118 | + */ |
|
| 119 | + private function is_started( $state ) { |
|
| 120 | + return $state instanceof Sync_State && 'started' === $state->state && 30 > ( time() - $state->last_update ); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Check whether the process must cancel or not. |
|
| 125 | + * |
|
| 126 | + * @return bool Whether to cancel or not the process. |
|
| 127 | + */ |
|
| 128 | + private function must_cancel() { |
|
| 129 | + |
|
| 130 | + return get_transient( "{$this->action}__cancel" ); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Cancels the current process. |
|
| 135 | + */ |
|
| 136 | + private function cancel() { |
|
| 137 | + |
|
| 138 | + $this->log->debug( "Cancelling synchronization..." ); |
|
| 139 | + |
|
| 140 | + // Cleanup the process data. |
|
| 141 | + $this->cancel_process(); |
|
| 142 | + |
|
| 143 | + // Set the state to cancelled. |
|
| 144 | + $state = self::get_state(); |
|
| 145 | + $state->set_state( 'cancelled' ); |
|
| 146 | + update_option( '_wl_dataset_sync', $state ); |
|
| 147 | + |
|
| 148 | + // Finally delete the transient. |
|
| 149 | + delete_transient( "{$this->action}__cancel" ); |
|
| 150 | + |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Push the post with the provided ID to the remote platform. |
|
| 155 | + * |
|
| 156 | + * @param int $post_id The post ID. |
|
| 157 | + * |
|
| 158 | + * @return int|false The next post ID to process or false if processing is complete. |
|
| 159 | + */ |
|
| 160 | + private function sync_item( $post_id ) { |
|
| 161 | + |
|
| 162 | + // Sync this item. |
|
| 163 | + if ( $this->sync_service->sync_item( $post_id ) ) { |
|
| 164 | + |
|
| 165 | + $next = $this->sync_service->next(); |
|
| 166 | + $next_state = isset( $next ) ? 'started' : 'ended'; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Update the synchronization meta data, by increasing the current index. |
|
| 170 | + * |
|
| 171 | + * @var Sync_State $sync The {@link Sync_State}. |
|
| 172 | + */ |
|
| 173 | + $state = self::get_state() |
|
| 174 | + ->increment_index() |
|
| 175 | + ->set_state( $next_state ); |
|
| 176 | + update_option( '_wl_dataset_sync', $state ); |
|
| 177 | + |
|
| 178 | + // Return the next ID or false if there aren't. |
|
| 179 | + return isset( $next ) ? (int) $next : false; |
|
| 180 | + } else { |
|
| 181 | + // Retry. |
|
| 182 | + // @@todo: put a limit to the number of retries. |
|
| 183 | + return $post_id; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | } |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @param $sync_service Sync_Service A {@link Sync_Service} instance providing the supporting functions to this background process. |
| 25 | 25 | */ |
| 26 | - public function __construct( $sync_service ) { |
|
| 26 | + public function __construct($sync_service) { |
|
| 27 | 27 | parent::__construct(); |
| 28 | 28 | |
| 29 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 29 | + $this->log = \Wordlift_Log_Service::get_logger(get_class()); |
|
| 30 | 30 | |
| 31 | 31 | $this->sync_service = $sync_service; |
| 32 | 32 | |
@@ -43,19 +43,19 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return int|false The next post ID or false if there are no more. |
| 45 | 45 | */ |
| 46 | - protected function task( $post_id ) { |
|
| 46 | + protected function task($post_id) { |
|
| 47 | 47 | |
| 48 | 48 | // Check if we must cancel. |
| 49 | - if ( $this->must_cancel() ) { |
|
| 49 | + if ($this->must_cancel()) { |
|
| 50 | 50 | $this->cancel(); |
| 51 | 51 | |
| 52 | 52 | return false; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $this->log->debug( "Synchronizing post $post_id..." ); |
|
| 55 | + $this->log->debug("Synchronizing post $post_id..."); |
|
| 56 | 56 | |
| 57 | 57 | // Sync the item. |
| 58 | - return $this->sync_item( $post_id ); |
|
| 58 | + return $this->sync_item($post_id); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -66,17 +66,17 @@ discard block |
||
| 66 | 66 | public function start() { |
| 67 | 67 | |
| 68 | 68 | // Create a new Sync_Model state of `started`. |
| 69 | - if ( ! $this->is_started( self::get_state() ) ) { |
|
| 70 | - $this->log->debug( "Starting..." ); |
|
| 69 | + if ( ! $this->is_started(self::get_state())) { |
|
| 70 | + $this->log->debug("Starting..."); |
|
| 71 | 71 | |
| 72 | - $sync_state = new Sync_State( time(), 0, $this->sync_service->count(), time(), 'started' ); |
|
| 73 | - update_option( '_wl_dataset_sync', $sync_state ); |
|
| 72 | + $sync_state = new Sync_State(time(), 0, $this->sync_service->count(), time(), 'started'); |
|
| 73 | + update_option('_wl_dataset_sync', $sync_state); |
|
| 74 | 74 | |
| 75 | 75 | $next = $this->sync_service->next(); |
| 76 | - $this->push_to_queue( $next ); |
|
| 76 | + $this->push_to_queue($next); |
|
| 77 | 77 | $this->save()->dispatch(); |
| 78 | 78 | |
| 79 | - $this->log->debug( "Started with post ID $next." ); |
|
| 79 | + $this->log->debug("Started with post ID $next."); |
|
| 80 | 80 | |
| 81 | 81 | return true; |
| 82 | 82 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function request_cancel() { |
| 92 | 92 | |
| 93 | - set_transient( "{$this->action}__cancel", true ); |
|
| 93 | + set_transient("{$this->action}__cancel", true); |
|
| 94 | 94 | |
| 95 | 95 | } |
| 96 | 96 | |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | public static function get_state() { |
| 103 | 103 | |
| 104 | 104 | try { |
| 105 | - return get_option( '_wl_dataset_sync', Sync_State::unknown() ); |
|
| 106 | - } catch ( Exception $e ) { |
|
| 105 | + return get_option('_wl_dataset_sync', Sync_State::unknown()); |
|
| 106 | + } catch (Exception $e) { |
|
| 107 | 107 | return Sync_State::unknown(); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @return bool True if the state is started. |
| 118 | 118 | */ |
| 119 | - private function is_started( $state ) { |
|
| 120 | - return $state instanceof Sync_State && 'started' === $state->state && 30 > ( time() - $state->last_update ); |
|
| 119 | + private function is_started($state) { |
|
| 120 | + return $state instanceof Sync_State && 'started' === $state->state && 30 > (time() - $state->last_update); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | private function must_cancel() { |
| 129 | 129 | |
| 130 | - return get_transient( "{$this->action}__cancel" ); |
|
| 130 | + return get_transient("{$this->action}__cancel"); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -135,18 +135,18 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | private function cancel() { |
| 137 | 137 | |
| 138 | - $this->log->debug( "Cancelling synchronization..." ); |
|
| 138 | + $this->log->debug("Cancelling synchronization..."); |
|
| 139 | 139 | |
| 140 | 140 | // Cleanup the process data. |
| 141 | 141 | $this->cancel_process(); |
| 142 | 142 | |
| 143 | 143 | // Set the state to cancelled. |
| 144 | 144 | $state = self::get_state(); |
| 145 | - $state->set_state( 'cancelled' ); |
|
| 146 | - update_option( '_wl_dataset_sync', $state ); |
|
| 145 | + $state->set_state('cancelled'); |
|
| 146 | + update_option('_wl_dataset_sync', $state); |
|
| 147 | 147 | |
| 148 | 148 | // Finally delete the transient. |
| 149 | - delete_transient( "{$this->action}__cancel" ); |
|
| 149 | + delete_transient("{$this->action}__cancel"); |
|
| 150 | 150 | |
| 151 | 151 | } |
| 152 | 152 | |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @return int|false The next post ID to process or false if processing is complete. |
| 159 | 159 | */ |
| 160 | - private function sync_item( $post_id ) { |
|
| 160 | + private function sync_item($post_id) { |
|
| 161 | 161 | |
| 162 | 162 | // Sync this item. |
| 163 | - if ( $this->sync_service->sync_item( $post_id ) ) { |
|
| 163 | + if ($this->sync_service->sync_item($post_id)) { |
|
| 164 | 164 | |
| 165 | 165 | $next = $this->sync_service->next(); |
| 166 | - $next_state = isset( $next ) ? 'started' : 'ended'; |
|
| 166 | + $next_state = isset($next) ? 'started' : 'ended'; |
|
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | 169 | * Update the synchronization meta data, by increasing the current index. |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | $state = self::get_state() |
| 174 | 174 | ->increment_index() |
| 175 | - ->set_state( $next_state ); |
|
| 176 | - update_option( '_wl_dataset_sync', $state ); |
|
| 175 | + ->set_state($next_state); |
|
| 176 | + update_option('_wl_dataset_sync', $state); |
|
| 177 | 177 | |
| 178 | 178 | // Return the next ID or false if there aren't. |
| 179 | - return isset( $next ) ? (int) $next : false; |
|
| 179 | + return isset($next) ? (int) $next : false; |
|
| 180 | 180 | } else { |
| 181 | 181 | // Retry. |
| 182 | 182 | // @@todo: put a limit to the number of retries. |
@@ -20,132 +20,132 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class Wordlift_Rebuild_Service extends Wordlift_Listable { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * A {@link Wordlift_Log_Service} instance. |
|
| 25 | - * |
|
| 26 | - * @since 3.6.0 |
|
| 27 | - * @access private |
|
| 28 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 29 | - */ |
|
| 30 | - private $log; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 34 | - * |
|
| 35 | - * @since 3.6.0 |
|
| 36 | - * @access private |
|
| 37 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 38 | - */ |
|
| 39 | - private $sparql_service; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * The {@link Wordlift_Uri_Service} instance. |
|
| 43 | - * |
|
| 44 | - * @since 3.15.0 |
|
| 45 | - * @access private |
|
| 46 | - * @var \Wordlift_Uri_Service $uri_service The {@link Wordlift_Uri_Service} instance. |
|
| 47 | - */ |
|
| 48 | - private $uri_service; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Create an instance of Wordlift_Rebuild_Service. |
|
| 52 | - * |
|
| 53 | - * @param \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance used to query the remote dataset. |
|
| 54 | - * @param \Wordlift_Uri_Service $uri_service |
|
| 55 | - * |
|
| 56 | - * @since 3.6.0 |
|
| 57 | - * |
|
| 58 | - */ |
|
| 59 | - public function __construct( $sparql_service, $uri_service ) { |
|
| 60 | - |
|
| 61 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Rebuild_Service' ); |
|
| 62 | - |
|
| 63 | - $this->sparql_service = $sparql_service; |
|
| 64 | - $this->uri_service = $uri_service; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Rebuild the Linked Data remote dataset by clearing it out and repopulating |
|
| 69 | - * it with local data. |
|
| 70 | - * |
|
| 71 | - * @since 3.6.0 |
|
| 72 | - */ |
|
| 73 | - public function rebuild() { |
|
| 74 | - |
|
| 75 | - ob_clean(); |
|
| 76 | - |
|
| 77 | - // Give ourselves some time to process the data. |
|
| 78 | - set_time_limit( 21600 ); // 6 hours |
|
| 79 | - |
|
| 80 | - // Send textual output. |
|
| 81 | - header( 'Content-type: text/plain; charset=utf-8' ); |
|
| 82 | - |
|
| 83 | - // We start at 0 by default and get to max. |
|
| 84 | - $offset = $_GET['offset'] ?: 0; |
|
| 85 | - $limit = $_GET['limit'] ?: 1; |
|
| 86 | - $max = $offset + $limit; |
|
| 87 | - |
|
| 88 | - // Whether we should run queries asynchronously, this is handled in `wordlift_constants.php`. |
|
| 89 | - $asynchronous = isset( $_GET['wl-async'] ) && 'true' === $_GET['wl-async']; |
|
| 90 | - |
|
| 91 | - // If we're starting at offset 0, then delete existing URIs and data from |
|
| 92 | - // the remote dataset. |
|
| 93 | - if ( 0 === $offset ) { |
|
| 94 | - |
|
| 95 | - // Clear out all generated URIs, since the dataset URI might have changed |
|
| 96 | - // in the process. |
|
| 97 | - $this->uri_service->delete_all(); |
|
| 98 | - |
|
| 99 | - // Delete all the triples in the remote dataset. |
|
| 100 | - $this->sparql_service->execute( 'DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };' ); |
|
| 101 | - |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - // Go through the list of published entities and posts and call the (legacy) |
|
| 105 | - // `wl_linked_data_save_post` function for each one. We're using the `process` |
|
| 106 | - // function which is provided by the parent `Wordlift_Listable` abstract class |
|
| 107 | - // and will cycle through all the posts w/ a very small memory footprint |
|
| 108 | - // in order to avoid memory errors. |
|
| 109 | - |
|
| 110 | - $count = 0; |
|
| 111 | - $log = $this->log; |
|
| 112 | - $this->process( function ( $post ) use ( &$count, $log ) { |
|
| 113 | - $count ++; |
|
| 114 | - $log->trace( "Going to save post $count, ID $post->ID..." ); |
|
| 115 | - if ( function_exists( 'wl_linked_data_save_post' ) ) { |
|
| 116 | - wl_linked_data_save_post( $post->ID ); |
|
| 117 | - } |
|
| 118 | - }, array( |
|
| 119 | - 'post_status' => 'publish', |
|
| 120 | - ), $offset, $max ); |
|
| 121 | - |
|
| 122 | - // Redirect to the next chunk. |
|
| 123 | - if ( $count == $limit ) { |
|
| 124 | - $log->trace( 'Redirecting to post #' . ( $offset + 1 ) . '...' ); |
|
| 125 | - $this->redirect( admin_url( 'admin-ajax.php?action=wl_rebuild&offset=' . ( $offset + $limit ) . '&limit=' . $limit . '&wl-async=' . ( $asynchronous ? 'true' : 'false' ) ) ); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - // Flush the cache. |
|
| 129 | - Wordlift_File_Cache_Service::flush_all(); |
|
| 130 | - |
|
| 131 | - // Rebuild also the references. |
|
| 132 | - $this->redirect( admin_url( 'admin-ajax.php?action=wl_rebuild_references' ) ); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Redirect using a client-side meta to avoid browsers' redirect restrictions. |
|
| 137 | - * |
|
| 138 | - * @param string $url The URL to redirect to. |
|
| 139 | - * |
|
| 140 | - * @since 3.9.8 |
|
| 141 | - * |
|
| 142 | - */ |
|
| 143 | - public function redirect( $url ) { |
|
| 144 | - |
|
| 145 | - ob_clean(); |
|
| 146 | - |
|
| 147 | - @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 148 | - ?> |
|
| 23 | + /** |
|
| 24 | + * A {@link Wordlift_Log_Service} instance. |
|
| 25 | + * |
|
| 26 | + * @since 3.6.0 |
|
| 27 | + * @access private |
|
| 28 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 29 | + */ |
|
| 30 | + private $log; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 34 | + * |
|
| 35 | + * @since 3.6.0 |
|
| 36 | + * @access private |
|
| 37 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 38 | + */ |
|
| 39 | + private $sparql_service; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * The {@link Wordlift_Uri_Service} instance. |
|
| 43 | + * |
|
| 44 | + * @since 3.15.0 |
|
| 45 | + * @access private |
|
| 46 | + * @var \Wordlift_Uri_Service $uri_service The {@link Wordlift_Uri_Service} instance. |
|
| 47 | + */ |
|
| 48 | + private $uri_service; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Create an instance of Wordlift_Rebuild_Service. |
|
| 52 | + * |
|
| 53 | + * @param \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance used to query the remote dataset. |
|
| 54 | + * @param \Wordlift_Uri_Service $uri_service |
|
| 55 | + * |
|
| 56 | + * @since 3.6.0 |
|
| 57 | + * |
|
| 58 | + */ |
|
| 59 | + public function __construct( $sparql_service, $uri_service ) { |
|
| 60 | + |
|
| 61 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Rebuild_Service' ); |
|
| 62 | + |
|
| 63 | + $this->sparql_service = $sparql_service; |
|
| 64 | + $this->uri_service = $uri_service; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Rebuild the Linked Data remote dataset by clearing it out and repopulating |
|
| 69 | + * it with local data. |
|
| 70 | + * |
|
| 71 | + * @since 3.6.0 |
|
| 72 | + */ |
|
| 73 | + public function rebuild() { |
|
| 74 | + |
|
| 75 | + ob_clean(); |
|
| 76 | + |
|
| 77 | + // Give ourselves some time to process the data. |
|
| 78 | + set_time_limit( 21600 ); // 6 hours |
|
| 79 | + |
|
| 80 | + // Send textual output. |
|
| 81 | + header( 'Content-type: text/plain; charset=utf-8' ); |
|
| 82 | + |
|
| 83 | + // We start at 0 by default and get to max. |
|
| 84 | + $offset = $_GET['offset'] ?: 0; |
|
| 85 | + $limit = $_GET['limit'] ?: 1; |
|
| 86 | + $max = $offset + $limit; |
|
| 87 | + |
|
| 88 | + // Whether we should run queries asynchronously, this is handled in `wordlift_constants.php`. |
|
| 89 | + $asynchronous = isset( $_GET['wl-async'] ) && 'true' === $_GET['wl-async']; |
|
| 90 | + |
|
| 91 | + // If we're starting at offset 0, then delete existing URIs and data from |
|
| 92 | + // the remote dataset. |
|
| 93 | + if ( 0 === $offset ) { |
|
| 94 | + |
|
| 95 | + // Clear out all generated URIs, since the dataset URI might have changed |
|
| 96 | + // in the process. |
|
| 97 | + $this->uri_service->delete_all(); |
|
| 98 | + |
|
| 99 | + // Delete all the triples in the remote dataset. |
|
| 100 | + $this->sparql_service->execute( 'DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };' ); |
|
| 101 | + |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + // Go through the list of published entities and posts and call the (legacy) |
|
| 105 | + // `wl_linked_data_save_post` function for each one. We're using the `process` |
|
| 106 | + // function which is provided by the parent `Wordlift_Listable` abstract class |
|
| 107 | + // and will cycle through all the posts w/ a very small memory footprint |
|
| 108 | + // in order to avoid memory errors. |
|
| 109 | + |
|
| 110 | + $count = 0; |
|
| 111 | + $log = $this->log; |
|
| 112 | + $this->process( function ( $post ) use ( &$count, $log ) { |
|
| 113 | + $count ++; |
|
| 114 | + $log->trace( "Going to save post $count, ID $post->ID..." ); |
|
| 115 | + if ( function_exists( 'wl_linked_data_save_post' ) ) { |
|
| 116 | + wl_linked_data_save_post( $post->ID ); |
|
| 117 | + } |
|
| 118 | + }, array( |
|
| 119 | + 'post_status' => 'publish', |
|
| 120 | + ), $offset, $max ); |
|
| 121 | + |
|
| 122 | + // Redirect to the next chunk. |
|
| 123 | + if ( $count == $limit ) { |
|
| 124 | + $log->trace( 'Redirecting to post #' . ( $offset + 1 ) . '...' ); |
|
| 125 | + $this->redirect( admin_url( 'admin-ajax.php?action=wl_rebuild&offset=' . ( $offset + $limit ) . '&limit=' . $limit . '&wl-async=' . ( $asynchronous ? 'true' : 'false' ) ) ); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + // Flush the cache. |
|
| 129 | + Wordlift_File_Cache_Service::flush_all(); |
|
| 130 | + |
|
| 131 | + // Rebuild also the references. |
|
| 132 | + $this->redirect( admin_url( 'admin-ajax.php?action=wl_rebuild_references' ) ); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Redirect using a client-side meta to avoid browsers' redirect restrictions. |
|
| 137 | + * |
|
| 138 | + * @param string $url The URL to redirect to. |
|
| 139 | + * |
|
| 140 | + * @since 3.9.8 |
|
| 141 | + * |
|
| 142 | + */ |
|
| 143 | + public function redirect( $url ) { |
|
| 144 | + |
|
| 145 | + ob_clean(); |
|
| 146 | + |
|
| 147 | + @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 148 | + ?> |
|
| 149 | 149 | <html> |
| 150 | 150 | <head> |
| 151 | 151 | <meta http-equiv="refresh" |
@@ -157,37 +157,37 @@ discard block |
||
| 157 | 157 | </html> |
| 158 | 158 | <?php |
| 159 | 159 | |
| 160 | - exit; |
|
| 161 | - |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * List the items starting at the specified offset and up to the specified limit. |
|
| 166 | - * |
|
| 167 | - * @param int $offset The start offset. |
|
| 168 | - * @param int $limit The maximum number of items to return. |
|
| 169 | - * @param array $args Additional arguments. |
|
| 170 | - * |
|
| 171 | - * @return array A array of items (or an empty array if no items are found). |
|
| 172 | - * @since 3.19.5 remove Polylang hooks. |
|
| 173 | - * @since 3.6.0 |
|
| 174 | - * |
|
| 175 | - */ |
|
| 176 | - function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 177 | - |
|
| 178 | - $actual_args = wp_parse_args( $args, Wordlift_Entity_Service::add_criterias( array( |
|
| 179 | - 'offset' => $offset, |
|
| 180 | - 'numberposts' => $limit, |
|
| 181 | - 'fields' => 'all', |
|
| 182 | - 'orderby' => 'ID', |
|
| 183 | - 'order' => 'ASC', |
|
| 184 | - 'post_status' => 'any', |
|
| 185 | - 'cache_results' => false, |
|
| 186 | - ) ) ); |
|
| 187 | - |
|
| 188 | - $this->log->trace( 'Using ' . var_export( $actual_args, true ) ); |
|
| 189 | - |
|
| 190 | - return get_posts( $actual_args ); |
|
| 191 | - } |
|
| 160 | + exit; |
|
| 161 | + |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * List the items starting at the specified offset and up to the specified limit. |
|
| 166 | + * |
|
| 167 | + * @param int $offset The start offset. |
|
| 168 | + * @param int $limit The maximum number of items to return. |
|
| 169 | + * @param array $args Additional arguments. |
|
| 170 | + * |
|
| 171 | + * @return array A array of items (or an empty array if no items are found). |
|
| 172 | + * @since 3.19.5 remove Polylang hooks. |
|
| 173 | + * @since 3.6.0 |
|
| 174 | + * |
|
| 175 | + */ |
|
| 176 | + function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 177 | + |
|
| 178 | + $actual_args = wp_parse_args( $args, Wordlift_Entity_Service::add_criterias( array( |
|
| 179 | + 'offset' => $offset, |
|
| 180 | + 'numberposts' => $limit, |
|
| 181 | + 'fields' => 'all', |
|
| 182 | + 'orderby' => 'ID', |
|
| 183 | + 'order' => 'ASC', |
|
| 184 | + 'post_status' => 'any', |
|
| 185 | + 'cache_results' => false, |
|
| 186 | + ) ) ); |
|
| 187 | + |
|
| 188 | + $this->log->trace( 'Using ' . var_export( $actual_args, true ) ); |
|
| 189 | + |
|
| 190 | + return get_posts( $actual_args ); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | } |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | * @since 3.6.0 |
| 57 | 57 | * |
| 58 | 58 | */ |
| 59 | - public function __construct( $sparql_service, $uri_service ) { |
|
| 59 | + public function __construct($sparql_service, $uri_service) { |
|
| 60 | 60 | |
| 61 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Rebuild_Service' ); |
|
| 61 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Rebuild_Service'); |
|
| 62 | 62 | |
| 63 | 63 | $this->sparql_service = $sparql_service; |
| 64 | 64 | $this->uri_service = $uri_service; |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | ob_clean(); |
| 76 | 76 | |
| 77 | 77 | // Give ourselves some time to process the data. |
| 78 | - set_time_limit( 21600 ); // 6 hours |
|
| 78 | + set_time_limit(21600); // 6 hours |
|
| 79 | 79 | |
| 80 | 80 | // Send textual output. |
| 81 | - header( 'Content-type: text/plain; charset=utf-8' ); |
|
| 81 | + header('Content-type: text/plain; charset=utf-8'); |
|
| 82 | 82 | |
| 83 | 83 | // We start at 0 by default and get to max. |
| 84 | 84 | $offset = $_GET['offset'] ?: 0; |
@@ -86,18 +86,18 @@ discard block |
||
| 86 | 86 | $max = $offset + $limit; |
| 87 | 87 | |
| 88 | 88 | // Whether we should run queries asynchronously, this is handled in `wordlift_constants.php`. |
| 89 | - $asynchronous = isset( $_GET['wl-async'] ) && 'true' === $_GET['wl-async']; |
|
| 89 | + $asynchronous = isset($_GET['wl-async']) && 'true' === $_GET['wl-async']; |
|
| 90 | 90 | |
| 91 | 91 | // If we're starting at offset 0, then delete existing URIs and data from |
| 92 | 92 | // the remote dataset. |
| 93 | - if ( 0 === $offset ) { |
|
| 93 | + if (0 === $offset) { |
|
| 94 | 94 | |
| 95 | 95 | // Clear out all generated URIs, since the dataset URI might have changed |
| 96 | 96 | // in the process. |
| 97 | 97 | $this->uri_service->delete_all(); |
| 98 | 98 | |
| 99 | 99 | // Delete all the triples in the remote dataset. |
| 100 | - $this->sparql_service->execute( 'DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };' ); |
|
| 100 | + $this->sparql_service->execute('DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };'); |
|
| 101 | 101 | |
| 102 | 102 | } |
| 103 | 103 | |
@@ -109,27 +109,27 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $count = 0; |
| 111 | 111 | $log = $this->log; |
| 112 | - $this->process( function ( $post ) use ( &$count, $log ) { |
|
| 113 | - $count ++; |
|
| 114 | - $log->trace( "Going to save post $count, ID $post->ID..." ); |
|
| 115 | - if ( function_exists( 'wl_linked_data_save_post' ) ) { |
|
| 116 | - wl_linked_data_save_post( $post->ID ); |
|
| 112 | + $this->process(function($post) use (&$count, $log) { |
|
| 113 | + $count++; |
|
| 114 | + $log->trace("Going to save post $count, ID $post->ID..."); |
|
| 115 | + if (function_exists('wl_linked_data_save_post')) { |
|
| 116 | + wl_linked_data_save_post($post->ID); |
|
| 117 | 117 | } |
| 118 | 118 | }, array( |
| 119 | 119 | 'post_status' => 'publish', |
| 120 | - ), $offset, $max ); |
|
| 120 | + ), $offset, $max); |
|
| 121 | 121 | |
| 122 | 122 | // Redirect to the next chunk. |
| 123 | - if ( $count == $limit ) { |
|
| 124 | - $log->trace( 'Redirecting to post #' . ( $offset + 1 ) . '...' ); |
|
| 125 | - $this->redirect( admin_url( 'admin-ajax.php?action=wl_rebuild&offset=' . ( $offset + $limit ) . '&limit=' . $limit . '&wl-async=' . ( $asynchronous ? 'true' : 'false' ) ) ); |
|
| 123 | + if ($count == $limit) { |
|
| 124 | + $log->trace('Redirecting to post #'.($offset + 1).'...'); |
|
| 125 | + $this->redirect(admin_url('admin-ajax.php?action=wl_rebuild&offset='.($offset + $limit).'&limit='.$limit.'&wl-async='.($asynchronous ? 'true' : 'false'))); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Flush the cache. |
| 129 | 129 | Wordlift_File_Cache_Service::flush_all(); |
| 130 | 130 | |
| 131 | 131 | // Rebuild also the references. |
| 132 | - $this->redirect( admin_url( 'admin-ajax.php?action=wl_rebuild_references' ) ); |
|
| 132 | + $this->redirect(admin_url('admin-ajax.php?action=wl_rebuild_references')); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -140,16 +140,16 @@ discard block |
||
| 140 | 140 | * @since 3.9.8 |
| 141 | 141 | * |
| 142 | 142 | */ |
| 143 | - public function redirect( $url ) { |
|
| 143 | + public function redirect($url) { |
|
| 144 | 144 | |
| 145 | 145 | ob_clean(); |
| 146 | 146 | |
| 147 | - @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 147 | + @header('Content-Type: text/html; charset='.get_option('blog_charset')); |
|
| 148 | 148 | ?> |
| 149 | 149 | <html> |
| 150 | 150 | <head> |
| 151 | 151 | <meta http-equiv="refresh" |
| 152 | - content="0; <?php echo esc_attr( $url ); ?>"> |
|
| 152 | + content="0; <?php echo esc_attr($url); ?>"> |
|
| 153 | 153 | </head> |
| 154 | 154 | <body> |
| 155 | 155 | Rebuilding, please wait... |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | * @since 3.6.0 |
| 174 | 174 | * |
| 175 | 175 | */ |
| 176 | - function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 176 | + function find($offset = 0, $limit = 10, $args = array()) { |
|
| 177 | 177 | |
| 178 | - $actual_args = wp_parse_args( $args, Wordlift_Entity_Service::add_criterias( array( |
|
| 178 | + $actual_args = wp_parse_args($args, Wordlift_Entity_Service::add_criterias(array( |
|
| 179 | 179 | 'offset' => $offset, |
| 180 | 180 | 'numberposts' => $limit, |
| 181 | 181 | 'fields' => 'all', |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | 'order' => 'ASC', |
| 184 | 184 | 'post_status' => 'any', |
| 185 | 185 | 'cache_results' => false, |
| 186 | - ) ) ); |
|
| 186 | + ))); |
|
| 187 | 187 | |
| 188 | - $this->log->trace( 'Using ' . var_export( $actual_args, true ) ); |
|
| 188 | + $this->log->trace('Using '.var_export($actual_args, true)); |
|
| 189 | 189 | |
| 190 | - return get_posts( $actual_args ); |
|
| 190 | + return get_posts($actual_args); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | } |
@@ -2,110 +2,110 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Wordlift_Reference_Rebuild_Service extends Wordlift_Rebuild_Service { |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * The {@link Wordlift_Entity_Service} instance. |
|
| 7 | - * |
|
| 8 | - * @since 3.18.0 |
|
| 9 | - * @access private |
|
| 10 | - * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 11 | - */ |
|
| 12 | - private $entity_service; |
|
| 13 | - |
|
| 14 | - /** |
|
| 15 | - * A {@link Wordlift_Log_Service} instance. |
|
| 16 | - * |
|
| 17 | - * @since 3.18.0 |
|
| 18 | - * @access private |
|
| 19 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 20 | - */ |
|
| 21 | - private $log; |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Wordlift_Reference_Rebuild_Service constructor. |
|
| 26 | - * |
|
| 27 | - * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 28 | - */ |
|
| 29 | - public function __construct( $entity_service ) { |
|
| 30 | - |
|
| 31 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Reference_Rebuild_Service' ); |
|
| 32 | - |
|
| 33 | - $this->entity_service = $entity_service; |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - public function rebuild() { |
|
| 37 | - set_time_limit( 21600 ); // 6 hours |
|
| 38 | - |
|
| 39 | - // Send textual output. |
|
| 40 | - header( 'Content-type: text/plain; charset=utf-8' ); |
|
| 41 | - |
|
| 42 | - // We start at 0 by default and get to max. |
|
| 43 | - $offset = $_GET['offset'] ?: 0; |
|
| 44 | - $limit = $_GET['limit'] ?: 1; |
|
| 45 | - $max = $offset + $limit; |
|
| 46 | - |
|
| 47 | - $this->log->debug( 'Processing references...' ); |
|
| 48 | - |
|
| 49 | - // Go through the list of published entities and posts and call the (legacy) |
|
| 50 | - // `wl_linked_data_save_post` function for each one. We're using the `process` |
|
| 51 | - // function which is provided by the parent `Wordlift_Listable` abstract class |
|
| 52 | - // and will cycle through all the posts w/ a very small memory footprint |
|
| 53 | - // in order to avoid memory errors. |
|
| 54 | - |
|
| 55 | - $count = 0; |
|
| 56 | - $log = $this->log; |
|
| 57 | - $entity_service = $this->entity_service; |
|
| 58 | - |
|
| 59 | - $this->process( |
|
| 60 | - function ( $post_id ) use ( &$count, $log, $entity_service ) { |
|
| 61 | - $count ++; |
|
| 62 | - |
|
| 63 | - if ( $entity_service->is_entity( $post_id ) ) { |
|
| 64 | - $log->trace( "Post $post_id is an entity, skipping..." ); |
|
| 65 | - |
|
| 66 | - return; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $log->trace( "Going to save post $count, ID $post_id..." ); |
|
| 70 | - do_action( 'wl_legacy_linked_data__push', $post_id ); |
|
| 71 | - }, |
|
| 72 | - array(), |
|
| 73 | - $offset, |
|
| 74 | - $max |
|
| 75 | - ); |
|
| 76 | - |
|
| 77 | - // Redirect to the next chunk. |
|
| 78 | - if ( $count == $limit ) { |
|
| 79 | - $log->trace( 'Redirecting to post #' . ( $offset + 1 ) . '...' ); |
|
| 80 | - $url = admin_url( 'admin-ajax.php?action=wl_rebuild_references&offset=' . ( $offset + $limit ) . '&limit=' . $limit ); |
|
| 81 | - $this->redirect( $url ); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - $this->log->info( "Rebuild complete" ); |
|
| 85 | - echo( "Rebuild complete" ); |
|
| 86 | - |
|
| 87 | - // If we're being called as AJAX, die here. |
|
| 88 | - if ( DOING_AJAX ) { |
|
| 89 | - wp_die(); |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @inheritdoc |
|
| 95 | - */ |
|
| 96 | - function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 97 | - global $wpdb; |
|
| 98 | - |
|
| 99 | - return $wpdb->get_col( $wpdb->prepare( |
|
| 100 | - " |
|
| 5 | + /** |
|
| 6 | + * The {@link Wordlift_Entity_Service} instance. |
|
| 7 | + * |
|
| 8 | + * @since 3.18.0 |
|
| 9 | + * @access private |
|
| 10 | + * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 11 | + */ |
|
| 12 | + private $entity_service; |
|
| 13 | + |
|
| 14 | + /** |
|
| 15 | + * A {@link Wordlift_Log_Service} instance. |
|
| 16 | + * |
|
| 17 | + * @since 3.18.0 |
|
| 18 | + * @access private |
|
| 19 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 20 | + */ |
|
| 21 | + private $log; |
|
| 22 | + |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Wordlift_Reference_Rebuild_Service constructor. |
|
| 26 | + * |
|
| 27 | + * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 28 | + */ |
|
| 29 | + public function __construct( $entity_service ) { |
|
| 30 | + |
|
| 31 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Reference_Rebuild_Service' ); |
|
| 32 | + |
|
| 33 | + $this->entity_service = $entity_service; |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + public function rebuild() { |
|
| 37 | + set_time_limit( 21600 ); // 6 hours |
|
| 38 | + |
|
| 39 | + // Send textual output. |
|
| 40 | + header( 'Content-type: text/plain; charset=utf-8' ); |
|
| 41 | + |
|
| 42 | + // We start at 0 by default and get to max. |
|
| 43 | + $offset = $_GET['offset'] ?: 0; |
|
| 44 | + $limit = $_GET['limit'] ?: 1; |
|
| 45 | + $max = $offset + $limit; |
|
| 46 | + |
|
| 47 | + $this->log->debug( 'Processing references...' ); |
|
| 48 | + |
|
| 49 | + // Go through the list of published entities and posts and call the (legacy) |
|
| 50 | + // `wl_linked_data_save_post` function for each one. We're using the `process` |
|
| 51 | + // function which is provided by the parent `Wordlift_Listable` abstract class |
|
| 52 | + // and will cycle through all the posts w/ a very small memory footprint |
|
| 53 | + // in order to avoid memory errors. |
|
| 54 | + |
|
| 55 | + $count = 0; |
|
| 56 | + $log = $this->log; |
|
| 57 | + $entity_service = $this->entity_service; |
|
| 58 | + |
|
| 59 | + $this->process( |
|
| 60 | + function ( $post_id ) use ( &$count, $log, $entity_service ) { |
|
| 61 | + $count ++; |
|
| 62 | + |
|
| 63 | + if ( $entity_service->is_entity( $post_id ) ) { |
|
| 64 | + $log->trace( "Post $post_id is an entity, skipping..." ); |
|
| 65 | + |
|
| 66 | + return; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $log->trace( "Going to save post $count, ID $post_id..." ); |
|
| 70 | + do_action( 'wl_legacy_linked_data__push', $post_id ); |
|
| 71 | + }, |
|
| 72 | + array(), |
|
| 73 | + $offset, |
|
| 74 | + $max |
|
| 75 | + ); |
|
| 76 | + |
|
| 77 | + // Redirect to the next chunk. |
|
| 78 | + if ( $count == $limit ) { |
|
| 79 | + $log->trace( 'Redirecting to post #' . ( $offset + 1 ) . '...' ); |
|
| 80 | + $url = admin_url( 'admin-ajax.php?action=wl_rebuild_references&offset=' . ( $offset + $limit ) . '&limit=' . $limit ); |
|
| 81 | + $this->redirect( $url ); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + $this->log->info( "Rebuild complete" ); |
|
| 85 | + echo( "Rebuild complete" ); |
|
| 86 | + |
|
| 87 | + // If we're being called as AJAX, die here. |
|
| 88 | + if ( DOING_AJAX ) { |
|
| 89 | + wp_die(); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @inheritdoc |
|
| 95 | + */ |
|
| 96 | + function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 97 | + global $wpdb; |
|
| 98 | + |
|
| 99 | + return $wpdb->get_col( $wpdb->prepare( |
|
| 100 | + " |
|
| 101 | 101 | SELECT DISTINCT subject_id AS id |
| 102 | 102 | FROM {$wpdb->prefix}wl_relation_instances |
| 103 | 103 | LIMIT %d OFFSET %d |
| 104 | 104 | ", |
| 105 | - $limit, |
|
| 106 | - $offset |
|
| 107 | - ) ); |
|
| 105 | + $limit, |
|
| 106 | + $offset |
|
| 107 | + ) ); |
|
| 108 | 108 | |
| 109 | - } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | 111 | } |
@@ -26,25 +26,25 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
| 28 | 28 | */ |
| 29 | - public function __construct( $entity_service ) { |
|
| 29 | + public function __construct($entity_service) { |
|
| 30 | 30 | |
| 31 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Reference_Rebuild_Service' ); |
|
| 31 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Reference_Rebuild_Service'); |
|
| 32 | 32 | |
| 33 | 33 | $this->entity_service = $entity_service; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function rebuild() { |
| 37 | - set_time_limit( 21600 ); // 6 hours |
|
| 37 | + set_time_limit(21600); // 6 hours |
|
| 38 | 38 | |
| 39 | 39 | // Send textual output. |
| 40 | - header( 'Content-type: text/plain; charset=utf-8' ); |
|
| 40 | + header('Content-type: text/plain; charset=utf-8'); |
|
| 41 | 41 | |
| 42 | 42 | // We start at 0 by default and get to max. |
| 43 | 43 | $offset = $_GET['offset'] ?: 0; |
| 44 | 44 | $limit = $_GET['limit'] ?: 1; |
| 45 | 45 | $max = $offset + $limit; |
| 46 | 46 | |
| 47 | - $this->log->debug( 'Processing references...' ); |
|
| 47 | + $this->log->debug('Processing references...'); |
|
| 48 | 48 | |
| 49 | 49 | // Go through the list of published entities and posts and call the (legacy) |
| 50 | 50 | // `wl_linked_data_save_post` function for each one. We're using the `process` |
@@ -57,17 +57,17 @@ discard block |
||
| 57 | 57 | $entity_service = $this->entity_service; |
| 58 | 58 | |
| 59 | 59 | $this->process( |
| 60 | - function ( $post_id ) use ( &$count, $log, $entity_service ) { |
|
| 61 | - $count ++; |
|
| 60 | + function($post_id) use (&$count, $log, $entity_service) { |
|
| 61 | + $count++; |
|
| 62 | 62 | |
| 63 | - if ( $entity_service->is_entity( $post_id ) ) { |
|
| 64 | - $log->trace( "Post $post_id is an entity, skipping..." ); |
|
| 63 | + if ($entity_service->is_entity($post_id)) { |
|
| 64 | + $log->trace("Post $post_id is an entity, skipping..."); |
|
| 65 | 65 | |
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $log->trace( "Going to save post $count, ID $post_id..." ); |
|
| 70 | - do_action( 'wl_legacy_linked_data__push', $post_id ); |
|
| 69 | + $log->trace("Going to save post $count, ID $post_id..."); |
|
| 70 | + do_action('wl_legacy_linked_data__push', $post_id); |
|
| 71 | 71 | }, |
| 72 | 72 | array(), |
| 73 | 73 | $offset, |
@@ -75,17 +75,17 @@ discard block |
||
| 75 | 75 | ); |
| 76 | 76 | |
| 77 | 77 | // Redirect to the next chunk. |
| 78 | - if ( $count == $limit ) { |
|
| 79 | - $log->trace( 'Redirecting to post #' . ( $offset + 1 ) . '...' ); |
|
| 80 | - $url = admin_url( 'admin-ajax.php?action=wl_rebuild_references&offset=' . ( $offset + $limit ) . '&limit=' . $limit ); |
|
| 81 | - $this->redirect( $url ); |
|
| 78 | + if ($count == $limit) { |
|
| 79 | + $log->trace('Redirecting to post #'.($offset + 1).'...'); |
|
| 80 | + $url = admin_url('admin-ajax.php?action=wl_rebuild_references&offset='.($offset + $limit).'&limit='.$limit); |
|
| 81 | + $this->redirect($url); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $this->log->info( "Rebuild complete" ); |
|
| 85 | - echo( "Rebuild complete" ); |
|
| 84 | + $this->log->info("Rebuild complete"); |
|
| 85 | + echo("Rebuild complete"); |
|
| 86 | 86 | |
| 87 | 87 | // If we're being called as AJAX, die here. |
| 88 | - if ( DOING_AJAX ) { |
|
| 88 | + if (DOING_AJAX) { |
|
| 89 | 89 | wp_die(); |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | /** |
| 94 | 94 | * @inheritdoc |
| 95 | 95 | */ |
| 96 | - function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 96 | + function find($offset = 0, $limit = 10, $args = array()) { |
|
| 97 | 97 | global $wpdb; |
| 98 | 98 | |
| 99 | - return $wpdb->get_col( $wpdb->prepare( |
|
| 99 | + return $wpdb->get_col($wpdb->prepare( |
|
| 100 | 100 | " |
| 101 | 101 | SELECT DISTINCT subject_id AS id |
| 102 | 102 | FROM {$wpdb->prefix}wl_relation_instances |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | ", |
| 105 | 105 | $limit, |
| 106 | 106 | $offset |
| 107 | - ) ); |
|
| 107 | + )); |
|
| 108 | 108 | |
| 109 | 109 | } |
| 110 | 110 | |
@@ -65,1537 +65,1537 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | class Wordlift { |
| 67 | 67 | |
| 68 | - //<editor-fold desc="## FIELDS"> |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 72 | - * the plugin. |
|
| 73 | - * |
|
| 74 | - * @since 1.0.0 |
|
| 75 | - * @access protected |
|
| 76 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 77 | - */ |
|
| 78 | - protected $loader; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * The unique identifier of this plugin. |
|
| 82 | - * |
|
| 83 | - * @since 1.0.0 |
|
| 84 | - * @access protected |
|
| 85 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 86 | - */ |
|
| 87 | - protected $plugin_name; |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * The current version of the plugin. |
|
| 91 | - * |
|
| 92 | - * @since 1.0.0 |
|
| 93 | - * @access protected |
|
| 94 | - * @var string $version The current version of the plugin. |
|
| 95 | - */ |
|
| 96 | - protected $version; |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 100 | - * |
|
| 101 | - * @since 3.12.0 |
|
| 102 | - * @access protected |
|
| 103 | - * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 104 | - */ |
|
| 105 | - protected $tinymce_adapter; |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * The {@link Faq_Tinymce_Adapter} instance |
|
| 109 | - * @since 3.26.0 |
|
| 110 | - * @access protected |
|
| 111 | - * @var Faq_Tinymce_Adapter $faq_tinymce_adapter . |
|
| 112 | - */ |
|
| 113 | - //protected $faq_tinymce_adapter; |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * The Thumbnail service. |
|
| 117 | - * |
|
| 118 | - * @since 3.1.5 |
|
| 119 | - * @access private |
|
| 120 | - * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 121 | - */ |
|
| 122 | - private $thumbnail_service; |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * The UI service. |
|
| 126 | - * |
|
| 127 | - * @since 3.2.0 |
|
| 128 | - * @access private |
|
| 129 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 130 | - */ |
|
| 131 | - private $ui_service; |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * The Schema service. |
|
| 135 | - * |
|
| 136 | - * @since 3.3.0 |
|
| 137 | - * @access protected |
|
| 138 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 139 | - */ |
|
| 140 | - protected $schema_service; |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * The Entity service. |
|
| 144 | - * |
|
| 145 | - * @since 3.1.0 |
|
| 146 | - * @access protected |
|
| 147 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 148 | - */ |
|
| 149 | - protected $entity_service; |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * The Topic Taxonomy service. |
|
| 153 | - * |
|
| 154 | - * @since 3.5.0 |
|
| 155 | - * @access private |
|
| 156 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 157 | - */ |
|
| 158 | - private $topic_taxonomy_service; |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * The Entity Types Taxonomy service. |
|
| 162 | - * |
|
| 163 | - * @since 3.18.0 |
|
| 164 | - * @access private |
|
| 165 | - * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 166 | - */ |
|
| 167 | - private $entity_types_taxonomy_service; |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * The User service. |
|
| 171 | - * |
|
| 172 | - * @since 3.1.7 |
|
| 173 | - * @access protected |
|
| 174 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 175 | - */ |
|
| 176 | - protected $user_service; |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * The Timeline service. |
|
| 180 | - * |
|
| 181 | - * @since 3.1.0 |
|
| 182 | - * @access private |
|
| 183 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 184 | - */ |
|
| 185 | - private $timeline_service; |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * The Redirect service. |
|
| 189 | - * |
|
| 190 | - * @since 3.2.0 |
|
| 191 | - * @access private |
|
| 192 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 193 | - */ |
|
| 194 | - private $redirect_service; |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * The Notice service. |
|
| 198 | - * |
|
| 199 | - * @since 3.3.0 |
|
| 200 | - * @access private |
|
| 201 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 202 | - */ |
|
| 203 | - private $notice_service; |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * The Entity list customization. |
|
| 207 | - * |
|
| 208 | - * @since 3.3.0 |
|
| 209 | - * @access protected |
|
| 210 | - * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 211 | - */ |
|
| 212 | - protected $entity_list_service; |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * The Entity Types Taxonomy Walker. |
|
| 216 | - * |
|
| 217 | - * @since 3.1.0 |
|
| 218 | - * @access private |
|
| 219 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 220 | - */ |
|
| 221 | - private $entity_types_taxonomy_walker; |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * The ShareThis service. |
|
| 225 | - * |
|
| 226 | - * @since 3.2.0 |
|
| 227 | - * @access private |
|
| 228 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 229 | - */ |
|
| 230 | - private $sharethis_service; |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * The PrimaShop adapter. |
|
| 234 | - * |
|
| 235 | - * @since 3.2.3 |
|
| 236 | - * @access private |
|
| 237 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 238 | - */ |
|
| 239 | - private $primashop_adapter; |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * The WordLift Dashboard adapter. |
|
| 243 | - * |
|
| 244 | - * @since 3.4.0 |
|
| 245 | - * @access private |
|
| 246 | - * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 247 | - */ |
|
| 248 | - private $dashboard_service; |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * The entity type service. |
|
| 252 | - * |
|
| 253 | - * @since 3.6.0 |
|
| 254 | - * @access private |
|
| 255 | - * @var \Wordlift_Entity_Post_Type_Service |
|
| 256 | - */ |
|
| 257 | - private $entity_post_type_service; |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 261 | - * |
|
| 262 | - * @since 3.6.0 |
|
| 263 | - * @access private |
|
| 264 | - * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 265 | - */ |
|
| 266 | - private $entity_link_service; |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 270 | - * |
|
| 271 | - * @since 3.6.0 |
|
| 272 | - * @access protected |
|
| 273 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 274 | - */ |
|
| 275 | - protected $sparql_service; |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * A {@link Wordlift_Import_Service} instance. |
|
| 279 | - * |
|
| 280 | - * @since 3.6.0 |
|
| 281 | - * @access private |
|
| 282 | - * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 283 | - */ |
|
| 284 | - private $import_service; |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * A {@link Wordlift_Rebuild_Service} instance. |
|
| 288 | - * |
|
| 289 | - * @since 3.6.0 |
|
| 290 | - * @access private |
|
| 291 | - * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 292 | - */ |
|
| 293 | - private $rebuild_service; |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * A {@link Wordlift_Jsonld_Service} instance. |
|
| 297 | - * |
|
| 298 | - * @since 3.7.0 |
|
| 299 | - * @access protected |
|
| 300 | - * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 301 | - */ |
|
| 302 | - protected $jsonld_service; |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 306 | - * |
|
| 307 | - * @since 3.14.0 |
|
| 308 | - * @access protected |
|
| 309 | - * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 310 | - */ |
|
| 311 | - protected $jsonld_website_converter; |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * A {@link Wordlift_Property_Factory} instance. |
|
| 315 | - * |
|
| 316 | - * @since 3.7.0 |
|
| 317 | - * @access private |
|
| 318 | - * @var \Wordlift_Property_Factory $property_factory |
|
| 319 | - */ |
|
| 320 | - private $property_factory; |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * The 'Download Your Data' page. |
|
| 324 | - * |
|
| 325 | - * @since 3.6.0 |
|
| 326 | - * @access private |
|
| 327 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 328 | - */ |
|
| 329 | - private $download_your_data_page; |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * The 'WordLift Settings' page. |
|
| 333 | - * |
|
| 334 | - * @since 3.11.0 |
|
| 335 | - * @access protected |
|
| 336 | - * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 337 | - */ |
|
| 338 | - protected $settings_page; |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * The install wizard page. |
|
| 342 | - * |
|
| 343 | - * @since 3.9.0 |
|
| 344 | - * @access private |
|
| 345 | - * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 346 | - */ |
|
| 347 | - private $admin_setup; |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 351 | - * linking of entities to their pages. |
|
| 352 | - * |
|
| 353 | - * @since 3.8.0 |
|
| 354 | - * @access private |
|
| 355 | - * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 356 | - */ |
|
| 357 | - private $content_filter_service; |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * The Faq Content filter service |
|
| 361 | - * @since 3.26.0 |
|
| 362 | - * @access private |
|
| 363 | - * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 364 | - */ |
|
| 365 | - private $faq_content_filter_service; |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 369 | - * |
|
| 370 | - * @since 3.9.0 |
|
| 371 | - * @access private |
|
| 372 | - * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 373 | - */ |
|
| 374 | - private $key_validation_service; |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * A {@link Wordlift_Rating_Service} instance. |
|
| 378 | - * |
|
| 379 | - * @since 3.10.0 |
|
| 380 | - * @access private |
|
| 381 | - * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 382 | - */ |
|
| 383 | - private $rating_service; |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 387 | - * |
|
| 388 | - * @since 3.10.0 |
|
| 389 | - * @access protected |
|
| 390 | - * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 391 | - */ |
|
| 392 | - protected $post_to_jsonld_converter; |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 396 | - * |
|
| 397 | - * @since 3.10.0 |
|
| 398 | - * @access protected |
|
| 399 | - * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 400 | - */ |
|
| 401 | - protected $configuration_service; |
|
| 402 | - |
|
| 403 | - /** |
|
| 404 | - * A {@link Wordlift_Install_Service} instance. |
|
| 405 | - * |
|
| 406 | - * @since 3.18.0 |
|
| 407 | - * @access protected |
|
| 408 | - * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 409 | - */ |
|
| 410 | - protected $install_service; |
|
| 411 | - |
|
| 412 | - /** |
|
| 413 | - * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 414 | - * |
|
| 415 | - * @since 3.10.0 |
|
| 416 | - * @access protected |
|
| 417 | - * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 418 | - */ |
|
| 419 | - protected $entity_type_service; |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 423 | - * |
|
| 424 | - * @since 3.10.0 |
|
| 425 | - * @access protected |
|
| 426 | - * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 427 | - */ |
|
| 428 | - protected $entity_post_to_jsonld_converter; |
|
| 429 | - |
|
| 430 | - /** |
|
| 431 | - * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 432 | - * |
|
| 433 | - * @since 3.10.0 |
|
| 434 | - * @access protected |
|
| 435 | - * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 436 | - */ |
|
| 437 | - protected $postid_to_jsonld_converter; |
|
| 438 | - |
|
| 439 | - /** |
|
| 440 | - * The {@link Wordlift_Admin_Status_Page} class. |
|
| 441 | - * |
|
| 442 | - * @since 3.9.8 |
|
| 443 | - * @access private |
|
| 444 | - * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 445 | - */ |
|
| 446 | - private $status_page; |
|
| 447 | - |
|
| 448 | - /** |
|
| 449 | - * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 450 | - * |
|
| 451 | - * @since 3.11.0 |
|
| 452 | - * @access protected |
|
| 453 | - * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 454 | - */ |
|
| 455 | - protected $category_taxonomy_service; |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 459 | - * |
|
| 460 | - * @since 3.11.0 |
|
| 461 | - * @access protected |
|
| 462 | - * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 463 | - */ |
|
| 464 | - protected $entity_page_service; |
|
| 465 | - |
|
| 466 | - /** |
|
| 467 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 468 | - * |
|
| 469 | - * @since 3.11.0 |
|
| 470 | - * @access protected |
|
| 471 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 472 | - */ |
|
| 473 | - protected $settings_page_action_link; |
|
| 474 | - |
|
| 475 | - /** |
|
| 476 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 477 | - * |
|
| 478 | - * @since 3.11.0 |
|
| 479 | - * @access protected |
|
| 480 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 481 | - */ |
|
| 482 | - protected $analytics_settings_page_action_link; |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * The {@link Wordlift_Analytics_Connect} class. |
|
| 486 | - * |
|
| 487 | - * @since 3.11.0 |
|
| 488 | - * @access protected |
|
| 489 | - * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 490 | - */ |
|
| 491 | - protected $analytics_connect; |
|
| 492 | - |
|
| 493 | - /** |
|
| 494 | - * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 495 | - * |
|
| 496 | - * @since 3.11.0 |
|
| 497 | - * @access protected |
|
| 498 | - * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 499 | - */ |
|
| 500 | - protected $publisher_ajax_adapter; |
|
| 501 | - |
|
| 502 | - /** |
|
| 503 | - * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 504 | - * |
|
| 505 | - * @since 3.11.0 |
|
| 506 | - * @access protected |
|
| 507 | - * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 508 | - */ |
|
| 509 | - protected $input_element; |
|
| 510 | - |
|
| 511 | - /** |
|
| 512 | - * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 513 | - * |
|
| 514 | - * @since 3.13.0 |
|
| 515 | - * @access protected |
|
| 516 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 517 | - */ |
|
| 518 | - protected $radio_input_element; |
|
| 519 | - |
|
| 520 | - /** |
|
| 521 | - * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 522 | - * |
|
| 523 | - * @since 3.11.0 |
|
| 524 | - * @access protected |
|
| 525 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 526 | - */ |
|
| 527 | - protected $language_select_element; |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 531 | - * |
|
| 532 | - * @since 3.18.0 |
|
| 533 | - * @access protected |
|
| 534 | - * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 535 | - */ |
|
| 536 | - protected $country_select_element; |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 540 | - * |
|
| 541 | - * @since 3.11.0 |
|
| 542 | - * @access protected |
|
| 543 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 544 | - */ |
|
| 545 | - protected $publisher_element; |
|
| 546 | - |
|
| 547 | - /** |
|
| 548 | - * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 549 | - * |
|
| 550 | - * @since 3.11.0 |
|
| 551 | - * @access protected |
|
| 552 | - * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 553 | - */ |
|
| 554 | - protected $select2_element; |
|
| 555 | - |
|
| 556 | - /** |
|
| 557 | - * The controller for the entity type list admin page |
|
| 558 | - * |
|
| 559 | - * @since 3.11.0 |
|
| 560 | - * @access private |
|
| 561 | - * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 562 | - */ |
|
| 563 | - private $entity_type_admin_page; |
|
| 564 | - |
|
| 565 | - /** |
|
| 566 | - * The controller for the entity type settings admin page |
|
| 567 | - * |
|
| 568 | - * @since 3.11.0 |
|
| 569 | - * @access private |
|
| 570 | - * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 571 | - */ |
|
| 572 | - private $entity_type_settings_admin_page; |
|
| 573 | - |
|
| 574 | - /** |
|
| 575 | - * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 576 | - * |
|
| 577 | - * @since 3.11.0 |
|
| 578 | - * @access protected |
|
| 579 | - * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 580 | - */ |
|
| 581 | - protected $related_entities_cloud_widget; |
|
| 582 | - |
|
| 583 | - /** |
|
| 584 | - * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 585 | - * |
|
| 586 | - * @since 3.14.0 |
|
| 587 | - * @access protected |
|
| 588 | - * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 589 | - */ |
|
| 590 | - protected $author_element; |
|
| 591 | - |
|
| 592 | - /** |
|
| 593 | - * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 594 | - * |
|
| 595 | - * @since 3.12.0 |
|
| 596 | - * @access protected |
|
| 597 | - * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 598 | - */ |
|
| 599 | - protected $sample_data_service; |
|
| 600 | - |
|
| 601 | - /** |
|
| 602 | - * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 603 | - * |
|
| 604 | - * @since 3.12.0 |
|
| 605 | - * @access protected |
|
| 606 | - * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 607 | - */ |
|
| 608 | - protected $sample_data_ajax_adapter; |
|
| 609 | - |
|
| 610 | - /** |
|
| 611 | - * The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 612 | - * |
|
| 613 | - * @since 3.14.3 |
|
| 614 | - * @access private |
|
| 615 | - * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 616 | - */ |
|
| 617 | - private $relation_rebuild_service; |
|
| 618 | - |
|
| 619 | - /** |
|
| 620 | - * The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 621 | - * |
|
| 622 | - * @since 3.14.3 |
|
| 623 | - * @access private |
|
| 624 | - * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 625 | - */ |
|
| 626 | - private $relation_rebuild_adapter; |
|
| 627 | - |
|
| 628 | - /** |
|
| 629 | - * The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 630 | - * |
|
| 631 | - * @since 3.18.0 |
|
| 632 | - * @access private |
|
| 633 | - * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 634 | - */ |
|
| 635 | - private $reference_rebuild_service; |
|
| 636 | - |
|
| 637 | - /** |
|
| 638 | - * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 639 | - * |
|
| 640 | - * @since 3.16.0 |
|
| 641 | - * @access protected |
|
| 642 | - * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 643 | - */ |
|
| 644 | - protected $google_analytics_export_service; |
|
| 645 | - |
|
| 646 | - /** |
|
| 647 | - * {@link Wordlift}'s singleton instance. |
|
| 648 | - * |
|
| 649 | - * @since 3.15.0 |
|
| 650 | - * @access protected |
|
| 651 | - * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 652 | - */ |
|
| 653 | - protected $entity_type_adapter; |
|
| 654 | - |
|
| 655 | - /** |
|
| 656 | - * The {@link Wordlift_Storage_Factory} instance. |
|
| 657 | - * |
|
| 658 | - * @since 3.15.0 |
|
| 659 | - * @access protected |
|
| 660 | - * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 661 | - */ |
|
| 662 | - protected $storage_factory; |
|
| 663 | - |
|
| 664 | - /** |
|
| 665 | - * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 666 | - * |
|
| 667 | - * @since 3.15.0 |
|
| 668 | - * @access protected |
|
| 669 | - * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 670 | - */ |
|
| 671 | - protected $rendition_factory; |
|
| 672 | - |
|
| 673 | - /** |
|
| 674 | - * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 675 | - * |
|
| 676 | - * @since 3.15.0 |
|
| 677 | - * @access private |
|
| 678 | - * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 679 | - */ |
|
| 680 | - private $autocomplete_adapter; |
|
| 681 | - |
|
| 682 | - /** |
|
| 683 | - * The {@link Wordlift_Relation_Service} instance. |
|
| 684 | - * |
|
| 685 | - * @since 3.15.0 |
|
| 686 | - * @access protected |
|
| 687 | - * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance. |
|
| 688 | - */ |
|
| 689 | - protected $relation_service; |
|
| 690 | - |
|
| 691 | - /** |
|
| 692 | - * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 693 | - * |
|
| 694 | - * @since 3.16.0 |
|
| 695 | - * @access protected |
|
| 696 | - * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 697 | - * |
|
| 698 | - */ |
|
| 699 | - protected $cached_postid_to_jsonld_converter; |
|
| 700 | - |
|
| 701 | - /** |
|
| 702 | - * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 703 | - * |
|
| 704 | - * @since 3.16.3 |
|
| 705 | - * @access protected |
|
| 706 | - * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 707 | - */ |
|
| 708 | - protected $entity_uri_service; |
|
| 709 | - |
|
| 710 | - /** |
|
| 711 | - * The {@link Wordlift_Publisher_Service} instance. |
|
| 712 | - * |
|
| 713 | - * @since 3.19.0 |
|
| 714 | - * @access protected |
|
| 715 | - * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 716 | - */ |
|
| 717 | - protected $publisher_service; |
|
| 718 | - |
|
| 719 | - /** |
|
| 720 | - * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 721 | - * |
|
| 722 | - * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 723 | - */ |
|
| 724 | - protected $context_cards_service; |
|
| 725 | - |
|
| 726 | - /** |
|
| 727 | - * {@link Wordlift}'s singleton instance. |
|
| 728 | - * |
|
| 729 | - * @since 3.11.2 |
|
| 730 | - * @access private |
|
| 731 | - * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 732 | - */ |
|
| 733 | - private static $instance; |
|
| 734 | - |
|
| 735 | - //</editor-fold> |
|
| 736 | - |
|
| 737 | - /** |
|
| 738 | - * Define the core functionality of the plugin. |
|
| 739 | - * |
|
| 740 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 741 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 742 | - * the public-facing side of the site. |
|
| 743 | - * |
|
| 744 | - * @since 1.0.0 |
|
| 745 | - */ |
|
| 746 | - public function __construct() { |
|
| 747 | - |
|
| 748 | - self::$instance = $this; |
|
| 749 | - |
|
| 750 | - $this->plugin_name = 'wordlift'; |
|
| 751 | - $this->version = '3.27.5'; |
|
| 752 | - $this->load_dependencies(); |
|
| 753 | - $this->set_locale(); |
|
| 754 | - $this->define_admin_hooks(); |
|
| 755 | - $this->define_public_hooks(); |
|
| 756 | - |
|
| 757 | - // If we're in `WP_CLI` load the related files. |
|
| 758 | - if ( class_exists( 'WP_CLI' ) ) { |
|
| 759 | - $this->load_cli_dependencies(); |
|
| 760 | - } |
|
| 761 | - |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - /** |
|
| 765 | - * Get the singleton instance. |
|
| 766 | - * |
|
| 767 | - * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 768 | - * @since 3.11.2 |
|
| 769 | - * |
|
| 770 | - */ |
|
| 771 | - public static function get_instance() { |
|
| 772 | - |
|
| 773 | - return self::$instance; |
|
| 774 | - } |
|
| 775 | - |
|
| 776 | - /** |
|
| 777 | - * Load the required dependencies for this plugin. |
|
| 778 | - * |
|
| 779 | - * Include the following files that make up the plugin: |
|
| 780 | - * |
|
| 781 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 782 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 783 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 784 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 785 | - * |
|
| 786 | - * Create an instance of the loader which will be used to register the hooks |
|
| 787 | - * with WordPress. |
|
| 788 | - * |
|
| 789 | - * @throws Exception |
|
| 790 | - * @since 1.0.0 |
|
| 791 | - * @access private |
|
| 792 | - */ |
|
| 793 | - private function load_dependencies() { |
|
| 794 | - |
|
| 795 | - /** |
|
| 796 | - * The class responsible for orchestrating the actions and filters of the |
|
| 797 | - * core plugin. |
|
| 798 | - */ |
|
| 799 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 800 | - |
|
| 801 | - // The class responsible for plugin uninstall. |
|
| 802 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 803 | - |
|
| 804 | - /** |
|
| 805 | - * The class responsible for defining internationalization functionality |
|
| 806 | - * of the plugin. |
|
| 807 | - */ |
|
| 808 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 809 | - |
|
| 810 | - /** |
|
| 811 | - * WordLift's supported languages. |
|
| 812 | - */ |
|
| 813 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 814 | - |
|
| 815 | - /** |
|
| 816 | - * WordLift's supported countries. |
|
| 817 | - */ |
|
| 818 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 819 | - |
|
| 820 | - /** |
|
| 821 | - * Provide support functions to sanitize data. |
|
| 822 | - */ |
|
| 823 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 824 | - |
|
| 825 | - /** Services. */ |
|
| 826 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 827 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 829 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 830 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 831 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 833 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 834 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 835 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 836 | - |
|
| 837 | - /** |
|
| 838 | - * The Query builder. |
|
| 839 | - */ |
|
| 840 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 841 | - |
|
| 842 | - /** |
|
| 843 | - * The Schema service. |
|
| 844 | - */ |
|
| 845 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 846 | - |
|
| 847 | - /** |
|
| 848 | - * The schema:url property service. |
|
| 849 | - */ |
|
| 850 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 851 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 852 | - |
|
| 853 | - /** |
|
| 854 | - * The UI service. |
|
| 855 | - */ |
|
| 856 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 857 | - |
|
| 858 | - /** |
|
| 859 | - * The Thumbnail service. |
|
| 860 | - */ |
|
| 861 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 862 | - |
|
| 863 | - /** |
|
| 864 | - * The Entity Types Taxonomy service. |
|
| 865 | - */ |
|
| 866 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 867 | - |
|
| 868 | - /** |
|
| 869 | - * The Entity service. |
|
| 870 | - */ |
|
| 871 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 872 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 873 | - |
|
| 874 | - // Add the entity rating service. |
|
| 875 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 876 | - |
|
| 877 | - /** |
|
| 878 | - * The User service. |
|
| 879 | - */ |
|
| 880 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 881 | - |
|
| 882 | - /** |
|
| 883 | - * The Timeline service. |
|
| 884 | - */ |
|
| 885 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 886 | - |
|
| 887 | - /** |
|
| 888 | - * The Topic Taxonomy service. |
|
| 889 | - */ |
|
| 890 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 891 | - |
|
| 892 | - /** |
|
| 893 | - * The SPARQL service. |
|
| 894 | - */ |
|
| 895 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 896 | - |
|
| 897 | - /** |
|
| 898 | - * The WordLift import service. |
|
| 899 | - */ |
|
| 900 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 901 | - |
|
| 902 | - /** |
|
| 903 | - * The WordLift URI service. |
|
| 904 | - */ |
|
| 905 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 906 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 907 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 908 | - |
|
| 909 | - /** |
|
| 910 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 911 | - */ |
|
| 912 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php'; |
|
| 913 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 914 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 915 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 916 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 917 | - |
|
| 918 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 919 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 920 | - |
|
| 921 | - /** |
|
| 922 | - * Load the converters. |
|
| 923 | - */ |
|
| 924 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 925 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 926 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 927 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 928 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 929 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 930 | - |
|
| 931 | - /** |
|
| 932 | - * Load cache-related files. |
|
| 933 | - */ |
|
| 934 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 935 | - |
|
| 936 | - /** |
|
| 937 | - * Load the content filter. |
|
| 938 | - */ |
|
| 939 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 940 | - |
|
| 941 | - /* |
|
| 68 | + //<editor-fold desc="## FIELDS"> |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 72 | + * the plugin. |
|
| 73 | + * |
|
| 74 | + * @since 1.0.0 |
|
| 75 | + * @access protected |
|
| 76 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 77 | + */ |
|
| 78 | + protected $loader; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * The unique identifier of this plugin. |
|
| 82 | + * |
|
| 83 | + * @since 1.0.0 |
|
| 84 | + * @access protected |
|
| 85 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 86 | + */ |
|
| 87 | + protected $plugin_name; |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * The current version of the plugin. |
|
| 91 | + * |
|
| 92 | + * @since 1.0.0 |
|
| 93 | + * @access protected |
|
| 94 | + * @var string $version The current version of the plugin. |
|
| 95 | + */ |
|
| 96 | + protected $version; |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 100 | + * |
|
| 101 | + * @since 3.12.0 |
|
| 102 | + * @access protected |
|
| 103 | + * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 104 | + */ |
|
| 105 | + protected $tinymce_adapter; |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * The {@link Faq_Tinymce_Adapter} instance |
|
| 109 | + * @since 3.26.0 |
|
| 110 | + * @access protected |
|
| 111 | + * @var Faq_Tinymce_Adapter $faq_tinymce_adapter . |
|
| 112 | + */ |
|
| 113 | + //protected $faq_tinymce_adapter; |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * The Thumbnail service. |
|
| 117 | + * |
|
| 118 | + * @since 3.1.5 |
|
| 119 | + * @access private |
|
| 120 | + * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 121 | + */ |
|
| 122 | + private $thumbnail_service; |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * The UI service. |
|
| 126 | + * |
|
| 127 | + * @since 3.2.0 |
|
| 128 | + * @access private |
|
| 129 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 130 | + */ |
|
| 131 | + private $ui_service; |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * The Schema service. |
|
| 135 | + * |
|
| 136 | + * @since 3.3.0 |
|
| 137 | + * @access protected |
|
| 138 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 139 | + */ |
|
| 140 | + protected $schema_service; |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * The Entity service. |
|
| 144 | + * |
|
| 145 | + * @since 3.1.0 |
|
| 146 | + * @access protected |
|
| 147 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 148 | + */ |
|
| 149 | + protected $entity_service; |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * The Topic Taxonomy service. |
|
| 153 | + * |
|
| 154 | + * @since 3.5.0 |
|
| 155 | + * @access private |
|
| 156 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 157 | + */ |
|
| 158 | + private $topic_taxonomy_service; |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * The Entity Types Taxonomy service. |
|
| 162 | + * |
|
| 163 | + * @since 3.18.0 |
|
| 164 | + * @access private |
|
| 165 | + * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 166 | + */ |
|
| 167 | + private $entity_types_taxonomy_service; |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * The User service. |
|
| 171 | + * |
|
| 172 | + * @since 3.1.7 |
|
| 173 | + * @access protected |
|
| 174 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 175 | + */ |
|
| 176 | + protected $user_service; |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * The Timeline service. |
|
| 180 | + * |
|
| 181 | + * @since 3.1.0 |
|
| 182 | + * @access private |
|
| 183 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 184 | + */ |
|
| 185 | + private $timeline_service; |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * The Redirect service. |
|
| 189 | + * |
|
| 190 | + * @since 3.2.0 |
|
| 191 | + * @access private |
|
| 192 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 193 | + */ |
|
| 194 | + private $redirect_service; |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * The Notice service. |
|
| 198 | + * |
|
| 199 | + * @since 3.3.0 |
|
| 200 | + * @access private |
|
| 201 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 202 | + */ |
|
| 203 | + private $notice_service; |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * The Entity list customization. |
|
| 207 | + * |
|
| 208 | + * @since 3.3.0 |
|
| 209 | + * @access protected |
|
| 210 | + * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 211 | + */ |
|
| 212 | + protected $entity_list_service; |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * The Entity Types Taxonomy Walker. |
|
| 216 | + * |
|
| 217 | + * @since 3.1.0 |
|
| 218 | + * @access private |
|
| 219 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 220 | + */ |
|
| 221 | + private $entity_types_taxonomy_walker; |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * The ShareThis service. |
|
| 225 | + * |
|
| 226 | + * @since 3.2.0 |
|
| 227 | + * @access private |
|
| 228 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 229 | + */ |
|
| 230 | + private $sharethis_service; |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * The PrimaShop adapter. |
|
| 234 | + * |
|
| 235 | + * @since 3.2.3 |
|
| 236 | + * @access private |
|
| 237 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 238 | + */ |
|
| 239 | + private $primashop_adapter; |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * The WordLift Dashboard adapter. |
|
| 243 | + * |
|
| 244 | + * @since 3.4.0 |
|
| 245 | + * @access private |
|
| 246 | + * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 247 | + */ |
|
| 248 | + private $dashboard_service; |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * The entity type service. |
|
| 252 | + * |
|
| 253 | + * @since 3.6.0 |
|
| 254 | + * @access private |
|
| 255 | + * @var \Wordlift_Entity_Post_Type_Service |
|
| 256 | + */ |
|
| 257 | + private $entity_post_type_service; |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 261 | + * |
|
| 262 | + * @since 3.6.0 |
|
| 263 | + * @access private |
|
| 264 | + * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 265 | + */ |
|
| 266 | + private $entity_link_service; |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 270 | + * |
|
| 271 | + * @since 3.6.0 |
|
| 272 | + * @access protected |
|
| 273 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 274 | + */ |
|
| 275 | + protected $sparql_service; |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * A {@link Wordlift_Import_Service} instance. |
|
| 279 | + * |
|
| 280 | + * @since 3.6.0 |
|
| 281 | + * @access private |
|
| 282 | + * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 283 | + */ |
|
| 284 | + private $import_service; |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * A {@link Wordlift_Rebuild_Service} instance. |
|
| 288 | + * |
|
| 289 | + * @since 3.6.0 |
|
| 290 | + * @access private |
|
| 291 | + * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 292 | + */ |
|
| 293 | + private $rebuild_service; |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * A {@link Wordlift_Jsonld_Service} instance. |
|
| 297 | + * |
|
| 298 | + * @since 3.7.0 |
|
| 299 | + * @access protected |
|
| 300 | + * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 301 | + */ |
|
| 302 | + protected $jsonld_service; |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 306 | + * |
|
| 307 | + * @since 3.14.0 |
|
| 308 | + * @access protected |
|
| 309 | + * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 310 | + */ |
|
| 311 | + protected $jsonld_website_converter; |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * A {@link Wordlift_Property_Factory} instance. |
|
| 315 | + * |
|
| 316 | + * @since 3.7.0 |
|
| 317 | + * @access private |
|
| 318 | + * @var \Wordlift_Property_Factory $property_factory |
|
| 319 | + */ |
|
| 320 | + private $property_factory; |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * The 'Download Your Data' page. |
|
| 324 | + * |
|
| 325 | + * @since 3.6.0 |
|
| 326 | + * @access private |
|
| 327 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 328 | + */ |
|
| 329 | + private $download_your_data_page; |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * The 'WordLift Settings' page. |
|
| 333 | + * |
|
| 334 | + * @since 3.11.0 |
|
| 335 | + * @access protected |
|
| 336 | + * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 337 | + */ |
|
| 338 | + protected $settings_page; |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * The install wizard page. |
|
| 342 | + * |
|
| 343 | + * @since 3.9.0 |
|
| 344 | + * @access private |
|
| 345 | + * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 346 | + */ |
|
| 347 | + private $admin_setup; |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 351 | + * linking of entities to their pages. |
|
| 352 | + * |
|
| 353 | + * @since 3.8.0 |
|
| 354 | + * @access private |
|
| 355 | + * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 356 | + */ |
|
| 357 | + private $content_filter_service; |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * The Faq Content filter service |
|
| 361 | + * @since 3.26.0 |
|
| 362 | + * @access private |
|
| 363 | + * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 364 | + */ |
|
| 365 | + private $faq_content_filter_service; |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 369 | + * |
|
| 370 | + * @since 3.9.0 |
|
| 371 | + * @access private |
|
| 372 | + * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 373 | + */ |
|
| 374 | + private $key_validation_service; |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * A {@link Wordlift_Rating_Service} instance. |
|
| 378 | + * |
|
| 379 | + * @since 3.10.0 |
|
| 380 | + * @access private |
|
| 381 | + * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 382 | + */ |
|
| 383 | + private $rating_service; |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 387 | + * |
|
| 388 | + * @since 3.10.0 |
|
| 389 | + * @access protected |
|
| 390 | + * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 391 | + */ |
|
| 392 | + protected $post_to_jsonld_converter; |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 396 | + * |
|
| 397 | + * @since 3.10.0 |
|
| 398 | + * @access protected |
|
| 399 | + * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 400 | + */ |
|
| 401 | + protected $configuration_service; |
|
| 402 | + |
|
| 403 | + /** |
|
| 404 | + * A {@link Wordlift_Install_Service} instance. |
|
| 405 | + * |
|
| 406 | + * @since 3.18.0 |
|
| 407 | + * @access protected |
|
| 408 | + * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 409 | + */ |
|
| 410 | + protected $install_service; |
|
| 411 | + |
|
| 412 | + /** |
|
| 413 | + * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 414 | + * |
|
| 415 | + * @since 3.10.0 |
|
| 416 | + * @access protected |
|
| 417 | + * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 418 | + */ |
|
| 419 | + protected $entity_type_service; |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 423 | + * |
|
| 424 | + * @since 3.10.0 |
|
| 425 | + * @access protected |
|
| 426 | + * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 427 | + */ |
|
| 428 | + protected $entity_post_to_jsonld_converter; |
|
| 429 | + |
|
| 430 | + /** |
|
| 431 | + * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 432 | + * |
|
| 433 | + * @since 3.10.0 |
|
| 434 | + * @access protected |
|
| 435 | + * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 436 | + */ |
|
| 437 | + protected $postid_to_jsonld_converter; |
|
| 438 | + |
|
| 439 | + /** |
|
| 440 | + * The {@link Wordlift_Admin_Status_Page} class. |
|
| 441 | + * |
|
| 442 | + * @since 3.9.8 |
|
| 443 | + * @access private |
|
| 444 | + * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 445 | + */ |
|
| 446 | + private $status_page; |
|
| 447 | + |
|
| 448 | + /** |
|
| 449 | + * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 450 | + * |
|
| 451 | + * @since 3.11.0 |
|
| 452 | + * @access protected |
|
| 453 | + * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 454 | + */ |
|
| 455 | + protected $category_taxonomy_service; |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 459 | + * |
|
| 460 | + * @since 3.11.0 |
|
| 461 | + * @access protected |
|
| 462 | + * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 463 | + */ |
|
| 464 | + protected $entity_page_service; |
|
| 465 | + |
|
| 466 | + /** |
|
| 467 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 468 | + * |
|
| 469 | + * @since 3.11.0 |
|
| 470 | + * @access protected |
|
| 471 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 472 | + */ |
|
| 473 | + protected $settings_page_action_link; |
|
| 474 | + |
|
| 475 | + /** |
|
| 476 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 477 | + * |
|
| 478 | + * @since 3.11.0 |
|
| 479 | + * @access protected |
|
| 480 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 481 | + */ |
|
| 482 | + protected $analytics_settings_page_action_link; |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * The {@link Wordlift_Analytics_Connect} class. |
|
| 486 | + * |
|
| 487 | + * @since 3.11.0 |
|
| 488 | + * @access protected |
|
| 489 | + * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 490 | + */ |
|
| 491 | + protected $analytics_connect; |
|
| 492 | + |
|
| 493 | + /** |
|
| 494 | + * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 495 | + * |
|
| 496 | + * @since 3.11.0 |
|
| 497 | + * @access protected |
|
| 498 | + * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 499 | + */ |
|
| 500 | + protected $publisher_ajax_adapter; |
|
| 501 | + |
|
| 502 | + /** |
|
| 503 | + * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 504 | + * |
|
| 505 | + * @since 3.11.0 |
|
| 506 | + * @access protected |
|
| 507 | + * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 508 | + */ |
|
| 509 | + protected $input_element; |
|
| 510 | + |
|
| 511 | + /** |
|
| 512 | + * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 513 | + * |
|
| 514 | + * @since 3.13.0 |
|
| 515 | + * @access protected |
|
| 516 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 517 | + */ |
|
| 518 | + protected $radio_input_element; |
|
| 519 | + |
|
| 520 | + /** |
|
| 521 | + * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 522 | + * |
|
| 523 | + * @since 3.11.0 |
|
| 524 | + * @access protected |
|
| 525 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 526 | + */ |
|
| 527 | + protected $language_select_element; |
|
| 528 | + |
|
| 529 | + /** |
|
| 530 | + * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 531 | + * |
|
| 532 | + * @since 3.18.0 |
|
| 533 | + * @access protected |
|
| 534 | + * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 535 | + */ |
|
| 536 | + protected $country_select_element; |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 540 | + * |
|
| 541 | + * @since 3.11.0 |
|
| 542 | + * @access protected |
|
| 543 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 544 | + */ |
|
| 545 | + protected $publisher_element; |
|
| 546 | + |
|
| 547 | + /** |
|
| 548 | + * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 549 | + * |
|
| 550 | + * @since 3.11.0 |
|
| 551 | + * @access protected |
|
| 552 | + * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 553 | + */ |
|
| 554 | + protected $select2_element; |
|
| 555 | + |
|
| 556 | + /** |
|
| 557 | + * The controller for the entity type list admin page |
|
| 558 | + * |
|
| 559 | + * @since 3.11.0 |
|
| 560 | + * @access private |
|
| 561 | + * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 562 | + */ |
|
| 563 | + private $entity_type_admin_page; |
|
| 564 | + |
|
| 565 | + /** |
|
| 566 | + * The controller for the entity type settings admin page |
|
| 567 | + * |
|
| 568 | + * @since 3.11.0 |
|
| 569 | + * @access private |
|
| 570 | + * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 571 | + */ |
|
| 572 | + private $entity_type_settings_admin_page; |
|
| 573 | + |
|
| 574 | + /** |
|
| 575 | + * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 576 | + * |
|
| 577 | + * @since 3.11.0 |
|
| 578 | + * @access protected |
|
| 579 | + * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 580 | + */ |
|
| 581 | + protected $related_entities_cloud_widget; |
|
| 582 | + |
|
| 583 | + /** |
|
| 584 | + * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 585 | + * |
|
| 586 | + * @since 3.14.0 |
|
| 587 | + * @access protected |
|
| 588 | + * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 589 | + */ |
|
| 590 | + protected $author_element; |
|
| 591 | + |
|
| 592 | + /** |
|
| 593 | + * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 594 | + * |
|
| 595 | + * @since 3.12.0 |
|
| 596 | + * @access protected |
|
| 597 | + * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 598 | + */ |
|
| 599 | + protected $sample_data_service; |
|
| 600 | + |
|
| 601 | + /** |
|
| 602 | + * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 603 | + * |
|
| 604 | + * @since 3.12.0 |
|
| 605 | + * @access protected |
|
| 606 | + * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 607 | + */ |
|
| 608 | + protected $sample_data_ajax_adapter; |
|
| 609 | + |
|
| 610 | + /** |
|
| 611 | + * The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 612 | + * |
|
| 613 | + * @since 3.14.3 |
|
| 614 | + * @access private |
|
| 615 | + * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance. |
|
| 616 | + */ |
|
| 617 | + private $relation_rebuild_service; |
|
| 618 | + |
|
| 619 | + /** |
|
| 620 | + * The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 621 | + * |
|
| 622 | + * @since 3.14.3 |
|
| 623 | + * @access private |
|
| 624 | + * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance. |
|
| 625 | + */ |
|
| 626 | + private $relation_rebuild_adapter; |
|
| 627 | + |
|
| 628 | + /** |
|
| 629 | + * The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 630 | + * |
|
| 631 | + * @since 3.18.0 |
|
| 632 | + * @access private |
|
| 633 | + * @var \Wordlift_Reference_Rebuild_Service $reference_rebuild_service The {@link Wordlift_Reference_Rebuild_Service} instance. |
|
| 634 | + */ |
|
| 635 | + private $reference_rebuild_service; |
|
| 636 | + |
|
| 637 | + /** |
|
| 638 | + * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 639 | + * |
|
| 640 | + * @since 3.16.0 |
|
| 641 | + * @access protected |
|
| 642 | + * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 643 | + */ |
|
| 644 | + protected $google_analytics_export_service; |
|
| 645 | + |
|
| 646 | + /** |
|
| 647 | + * {@link Wordlift}'s singleton instance. |
|
| 648 | + * |
|
| 649 | + * @since 3.15.0 |
|
| 650 | + * @access protected |
|
| 651 | + * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 652 | + */ |
|
| 653 | + protected $entity_type_adapter; |
|
| 654 | + |
|
| 655 | + /** |
|
| 656 | + * The {@link Wordlift_Storage_Factory} instance. |
|
| 657 | + * |
|
| 658 | + * @since 3.15.0 |
|
| 659 | + * @access protected |
|
| 660 | + * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 661 | + */ |
|
| 662 | + protected $storage_factory; |
|
| 663 | + |
|
| 664 | + /** |
|
| 665 | + * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 666 | + * |
|
| 667 | + * @since 3.15.0 |
|
| 668 | + * @access protected |
|
| 669 | + * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 670 | + */ |
|
| 671 | + protected $rendition_factory; |
|
| 672 | + |
|
| 673 | + /** |
|
| 674 | + * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 675 | + * |
|
| 676 | + * @since 3.15.0 |
|
| 677 | + * @access private |
|
| 678 | + * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 679 | + */ |
|
| 680 | + private $autocomplete_adapter; |
|
| 681 | + |
|
| 682 | + /** |
|
| 683 | + * The {@link Wordlift_Relation_Service} instance. |
|
| 684 | + * |
|
| 685 | + * @since 3.15.0 |
|
| 686 | + * @access protected |
|
| 687 | + * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance. |
|
| 688 | + */ |
|
| 689 | + protected $relation_service; |
|
| 690 | + |
|
| 691 | + /** |
|
| 692 | + * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 693 | + * |
|
| 694 | + * @since 3.16.0 |
|
| 695 | + * @access protected |
|
| 696 | + * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 697 | + * |
|
| 698 | + */ |
|
| 699 | + protected $cached_postid_to_jsonld_converter; |
|
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 703 | + * |
|
| 704 | + * @since 3.16.3 |
|
| 705 | + * @access protected |
|
| 706 | + * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 707 | + */ |
|
| 708 | + protected $entity_uri_service; |
|
| 709 | + |
|
| 710 | + /** |
|
| 711 | + * The {@link Wordlift_Publisher_Service} instance. |
|
| 712 | + * |
|
| 713 | + * @since 3.19.0 |
|
| 714 | + * @access protected |
|
| 715 | + * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 716 | + */ |
|
| 717 | + protected $publisher_service; |
|
| 718 | + |
|
| 719 | + /** |
|
| 720 | + * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 721 | + * |
|
| 722 | + * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 723 | + */ |
|
| 724 | + protected $context_cards_service; |
|
| 725 | + |
|
| 726 | + /** |
|
| 727 | + * {@link Wordlift}'s singleton instance. |
|
| 728 | + * |
|
| 729 | + * @since 3.11.2 |
|
| 730 | + * @access private |
|
| 731 | + * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 732 | + */ |
|
| 733 | + private static $instance; |
|
| 734 | + |
|
| 735 | + //</editor-fold> |
|
| 736 | + |
|
| 737 | + /** |
|
| 738 | + * Define the core functionality of the plugin. |
|
| 739 | + * |
|
| 740 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 741 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 742 | + * the public-facing side of the site. |
|
| 743 | + * |
|
| 744 | + * @since 1.0.0 |
|
| 745 | + */ |
|
| 746 | + public function __construct() { |
|
| 747 | + |
|
| 748 | + self::$instance = $this; |
|
| 749 | + |
|
| 750 | + $this->plugin_name = 'wordlift'; |
|
| 751 | + $this->version = '3.27.5'; |
|
| 752 | + $this->load_dependencies(); |
|
| 753 | + $this->set_locale(); |
|
| 754 | + $this->define_admin_hooks(); |
|
| 755 | + $this->define_public_hooks(); |
|
| 756 | + |
|
| 757 | + // If we're in `WP_CLI` load the related files. |
|
| 758 | + if ( class_exists( 'WP_CLI' ) ) { |
|
| 759 | + $this->load_cli_dependencies(); |
|
| 760 | + } |
|
| 761 | + |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + /** |
|
| 765 | + * Get the singleton instance. |
|
| 766 | + * |
|
| 767 | + * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 768 | + * @since 3.11.2 |
|
| 769 | + * |
|
| 770 | + */ |
|
| 771 | + public static function get_instance() { |
|
| 772 | + |
|
| 773 | + return self::$instance; |
|
| 774 | + } |
|
| 775 | + |
|
| 776 | + /** |
|
| 777 | + * Load the required dependencies for this plugin. |
|
| 778 | + * |
|
| 779 | + * Include the following files that make up the plugin: |
|
| 780 | + * |
|
| 781 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 782 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 783 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 784 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 785 | + * |
|
| 786 | + * Create an instance of the loader which will be used to register the hooks |
|
| 787 | + * with WordPress. |
|
| 788 | + * |
|
| 789 | + * @throws Exception |
|
| 790 | + * @since 1.0.0 |
|
| 791 | + * @access private |
|
| 792 | + */ |
|
| 793 | + private function load_dependencies() { |
|
| 794 | + |
|
| 795 | + /** |
|
| 796 | + * The class responsible for orchestrating the actions and filters of the |
|
| 797 | + * core plugin. |
|
| 798 | + */ |
|
| 799 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 800 | + |
|
| 801 | + // The class responsible for plugin uninstall. |
|
| 802 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 803 | + |
|
| 804 | + /** |
|
| 805 | + * The class responsible for defining internationalization functionality |
|
| 806 | + * of the plugin. |
|
| 807 | + */ |
|
| 808 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 809 | + |
|
| 810 | + /** |
|
| 811 | + * WordLift's supported languages. |
|
| 812 | + */ |
|
| 813 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 814 | + |
|
| 815 | + /** |
|
| 816 | + * WordLift's supported countries. |
|
| 817 | + */ |
|
| 818 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 819 | + |
|
| 820 | + /** |
|
| 821 | + * Provide support functions to sanitize data. |
|
| 822 | + */ |
|
| 823 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 824 | + |
|
| 825 | + /** Services. */ |
|
| 826 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 827 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 828 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 829 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 830 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 831 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 832 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 833 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 834 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 835 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 836 | + |
|
| 837 | + /** |
|
| 838 | + * The Query builder. |
|
| 839 | + */ |
|
| 840 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 841 | + |
|
| 842 | + /** |
|
| 843 | + * The Schema service. |
|
| 844 | + */ |
|
| 845 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 846 | + |
|
| 847 | + /** |
|
| 848 | + * The schema:url property service. |
|
| 849 | + */ |
|
| 850 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 851 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 852 | + |
|
| 853 | + /** |
|
| 854 | + * The UI service. |
|
| 855 | + */ |
|
| 856 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 857 | + |
|
| 858 | + /** |
|
| 859 | + * The Thumbnail service. |
|
| 860 | + */ |
|
| 861 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 862 | + |
|
| 863 | + /** |
|
| 864 | + * The Entity Types Taxonomy service. |
|
| 865 | + */ |
|
| 866 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 867 | + |
|
| 868 | + /** |
|
| 869 | + * The Entity service. |
|
| 870 | + */ |
|
| 871 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 872 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 873 | + |
|
| 874 | + // Add the entity rating service. |
|
| 875 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 876 | + |
|
| 877 | + /** |
|
| 878 | + * The User service. |
|
| 879 | + */ |
|
| 880 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 881 | + |
|
| 882 | + /** |
|
| 883 | + * The Timeline service. |
|
| 884 | + */ |
|
| 885 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 886 | + |
|
| 887 | + /** |
|
| 888 | + * The Topic Taxonomy service. |
|
| 889 | + */ |
|
| 890 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 891 | + |
|
| 892 | + /** |
|
| 893 | + * The SPARQL service. |
|
| 894 | + */ |
|
| 895 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 896 | + |
|
| 897 | + /** |
|
| 898 | + * The WordLift import service. |
|
| 899 | + */ |
|
| 900 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 901 | + |
|
| 902 | + /** |
|
| 903 | + * The WordLift URI service. |
|
| 904 | + */ |
|
| 905 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 906 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 907 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 908 | + |
|
| 909 | + /** |
|
| 910 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 911 | + */ |
|
| 912 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php'; |
|
| 913 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 914 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 915 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 916 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 917 | + |
|
| 918 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 919 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 920 | + |
|
| 921 | + /** |
|
| 922 | + * Load the converters. |
|
| 923 | + */ |
|
| 924 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 925 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 926 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 927 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 928 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 929 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 930 | + |
|
| 931 | + /** |
|
| 932 | + * Load cache-related files. |
|
| 933 | + */ |
|
| 934 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 935 | + |
|
| 936 | + /** |
|
| 937 | + * Load the content filter. |
|
| 938 | + */ |
|
| 939 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 940 | + |
|
| 941 | + /* |
|
| 942 | 942 | * Load the excerpt helper. |
| 943 | 943 | */ |
| 944 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 945 | - |
|
| 946 | - /** |
|
| 947 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 948 | - * |
|
| 949 | - * @since 3.8.0 |
|
| 950 | - */ |
|
| 951 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 952 | - |
|
| 953 | - // The Publisher Service and the AJAX adapter. |
|
| 954 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 955 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 956 | - |
|
| 957 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 958 | - |
|
| 959 | - /** |
|
| 960 | - * Load the WordLift key validation service. |
|
| 961 | - */ |
|
| 962 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 963 | - |
|
| 964 | - // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 965 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 966 | - |
|
| 967 | - // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 968 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 969 | - |
|
| 970 | - /** Linked Data. */ |
|
| 971 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 972 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 973 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 974 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 975 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 976 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 977 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 978 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 979 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 980 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 981 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 982 | - |
|
| 983 | - /** Linked Data Rendition. */ |
|
| 984 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 985 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 986 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 987 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 988 | - |
|
| 989 | - /** Services. */ |
|
| 990 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 991 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 992 | - |
|
| 993 | - /** Adapters. */ |
|
| 994 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 995 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 996 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 997 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 998 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 999 | - |
|
| 1000 | - /** Async Tasks. */ |
|
| 1001 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1002 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1003 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1004 | - |
|
| 1005 | - /** Autocomplete. */ |
|
| 1006 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1007 | - |
|
| 1008 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 1009 | - |
|
| 1010 | - /** Analytics */ |
|
| 1011 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1012 | - |
|
| 1013 | - /** |
|
| 1014 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 1015 | - */ |
|
| 1016 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 1017 | - |
|
| 1018 | - /** |
|
| 1019 | - * The class to customize the entity list admin page. |
|
| 1020 | - */ |
|
| 1021 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 1022 | - |
|
| 1023 | - /** |
|
| 1024 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 1025 | - */ |
|
| 1026 | - global $wp_version; |
|
| 1027 | - if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 1028 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1029 | - } else { |
|
| 1030 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1031 | - } |
|
| 1032 | - |
|
| 1033 | - /** |
|
| 1034 | - * The Notice service. |
|
| 1035 | - */ |
|
| 1036 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 1037 | - |
|
| 1038 | - /** |
|
| 1039 | - * The PrimaShop adapter. |
|
| 1040 | - */ |
|
| 1041 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 1042 | - |
|
| 1043 | - /** |
|
| 1044 | - * The WordLift Dashboard service. |
|
| 1045 | - */ |
|
| 1046 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 1047 | - |
|
| 1048 | - /** |
|
| 1049 | - * The admin 'Install wizard' page. |
|
| 1050 | - */ |
|
| 1051 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 1052 | - |
|
| 1053 | - /** |
|
| 1054 | - * The WordLift entity type list admin page controller. |
|
| 1055 | - */ |
|
| 1056 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1057 | - |
|
| 1058 | - /** |
|
| 1059 | - * The WordLift entity type settings admin page controller. |
|
| 1060 | - */ |
|
| 1061 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 1062 | - |
|
| 1063 | - /** |
|
| 1064 | - * The admin 'Download Your Data' page. |
|
| 1065 | - */ |
|
| 1066 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 1067 | - |
|
| 1068 | - /** |
|
| 1069 | - * The admin 'WordLift Settings' page. |
|
| 1070 | - */ |
|
| 1071 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1072 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1073 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1074 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1075 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1076 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1077 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1078 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1079 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1080 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1081 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 1082 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 1083 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1084 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1085 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1086 | - |
|
| 1087 | - /** Admin Pages */ |
|
| 1088 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1089 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 1090 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-page.php'; |
|
| 1091 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1092 | - |
|
| 1093 | - /** |
|
| 1094 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 1095 | - * side of the site. |
|
| 1096 | - */ |
|
| 1097 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 1098 | - |
|
| 1099 | - /** |
|
| 1100 | - * The shortcode abstract class. |
|
| 1101 | - */ |
|
| 1102 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 1103 | - |
|
| 1104 | - /** |
|
| 1105 | - * The Timeline shortcode. |
|
| 1106 | - */ |
|
| 1107 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 1108 | - |
|
| 1109 | - /** |
|
| 1110 | - * The Navigator shortcode. |
|
| 1111 | - */ |
|
| 1112 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1113 | - |
|
| 1114 | - /** |
|
| 1115 | - * The Products Navigator shortcode. |
|
| 1116 | - */ |
|
| 1117 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1118 | - |
|
| 1119 | - /** |
|
| 1120 | - * The chord shortcode. |
|
| 1121 | - */ |
|
| 1122 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1123 | - |
|
| 1124 | - /** |
|
| 1125 | - * The geomap shortcode. |
|
| 1126 | - */ |
|
| 1127 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1128 | - |
|
| 1129 | - /** |
|
| 1130 | - * The entity cloud shortcode. |
|
| 1131 | - */ |
|
| 1132 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1133 | - |
|
| 1134 | - /** |
|
| 1135 | - * The entity glossary shortcode. |
|
| 1136 | - */ |
|
| 1137 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 1138 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1139 | - |
|
| 1140 | - /** |
|
| 1141 | - * Faceted Search shortcode. |
|
| 1142 | - */ |
|
| 1143 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1144 | - |
|
| 1145 | - /** |
|
| 1146 | - * The ShareThis service. |
|
| 1147 | - */ |
|
| 1148 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1149 | - |
|
| 1150 | - /** |
|
| 1151 | - * The SEO service. |
|
| 1152 | - */ |
|
| 1153 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1154 | - |
|
| 1155 | - /** |
|
| 1156 | - * The AMP service. |
|
| 1157 | - */ |
|
| 1158 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1159 | - |
|
| 1160 | - /** Widgets */ |
|
| 1161 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1162 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1163 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1164 | - |
|
| 1165 | - /* |
|
| 944 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 945 | + |
|
| 946 | + /** |
|
| 947 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 948 | + * |
|
| 949 | + * @since 3.8.0 |
|
| 950 | + */ |
|
| 951 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 952 | + |
|
| 953 | + // The Publisher Service and the AJAX adapter. |
|
| 954 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 955 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 956 | + |
|
| 957 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 958 | + |
|
| 959 | + /** |
|
| 960 | + * Load the WordLift key validation service. |
|
| 961 | + */ |
|
| 962 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 963 | + |
|
| 964 | + // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 965 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 966 | + |
|
| 967 | + // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 968 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 969 | + |
|
| 970 | + /** Linked Data. */ |
|
| 971 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 972 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 973 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 974 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 975 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 976 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 977 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 978 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 979 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 980 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 981 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 982 | + |
|
| 983 | + /** Linked Data Rendition. */ |
|
| 984 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 985 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 986 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 987 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 988 | + |
|
| 989 | + /** Services. */ |
|
| 990 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 991 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 992 | + |
|
| 993 | + /** Adapters. */ |
|
| 994 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 995 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 996 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 997 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 998 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 999 | + |
|
| 1000 | + /** Async Tasks. */ |
|
| 1001 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1002 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1003 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1004 | + |
|
| 1005 | + /** Autocomplete. */ |
|
| 1006 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1007 | + |
|
| 1008 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 1009 | + |
|
| 1010 | + /** Analytics */ |
|
| 1011 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1012 | + |
|
| 1013 | + /** |
|
| 1014 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 1015 | + */ |
|
| 1016 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 1017 | + |
|
| 1018 | + /** |
|
| 1019 | + * The class to customize the entity list admin page. |
|
| 1020 | + */ |
|
| 1021 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 1022 | + |
|
| 1023 | + /** |
|
| 1024 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 1025 | + */ |
|
| 1026 | + global $wp_version; |
|
| 1027 | + if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 1028 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1029 | + } else { |
|
| 1030 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1031 | + } |
|
| 1032 | + |
|
| 1033 | + /** |
|
| 1034 | + * The Notice service. |
|
| 1035 | + */ |
|
| 1036 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 1037 | + |
|
| 1038 | + /** |
|
| 1039 | + * The PrimaShop adapter. |
|
| 1040 | + */ |
|
| 1041 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 1042 | + |
|
| 1043 | + /** |
|
| 1044 | + * The WordLift Dashboard service. |
|
| 1045 | + */ |
|
| 1046 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 1047 | + |
|
| 1048 | + /** |
|
| 1049 | + * The admin 'Install wizard' page. |
|
| 1050 | + */ |
|
| 1051 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 1052 | + |
|
| 1053 | + /** |
|
| 1054 | + * The WordLift entity type list admin page controller. |
|
| 1055 | + */ |
|
| 1056 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1057 | + |
|
| 1058 | + /** |
|
| 1059 | + * The WordLift entity type settings admin page controller. |
|
| 1060 | + */ |
|
| 1061 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 1062 | + |
|
| 1063 | + /** |
|
| 1064 | + * The admin 'Download Your Data' page. |
|
| 1065 | + */ |
|
| 1066 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 1067 | + |
|
| 1068 | + /** |
|
| 1069 | + * The admin 'WordLift Settings' page. |
|
| 1070 | + */ |
|
| 1071 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1072 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1073 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1074 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1075 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1076 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1077 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1078 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1079 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1080 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1081 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 1082 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 1083 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1084 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1085 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1086 | + |
|
| 1087 | + /** Admin Pages */ |
|
| 1088 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1089 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 1090 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-page.php'; |
|
| 1091 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1092 | + |
|
| 1093 | + /** |
|
| 1094 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 1095 | + * side of the site. |
|
| 1096 | + */ |
|
| 1097 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 1098 | + |
|
| 1099 | + /** |
|
| 1100 | + * The shortcode abstract class. |
|
| 1101 | + */ |
|
| 1102 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 1103 | + |
|
| 1104 | + /** |
|
| 1105 | + * The Timeline shortcode. |
|
| 1106 | + */ |
|
| 1107 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 1108 | + |
|
| 1109 | + /** |
|
| 1110 | + * The Navigator shortcode. |
|
| 1111 | + */ |
|
| 1112 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1113 | + |
|
| 1114 | + /** |
|
| 1115 | + * The Products Navigator shortcode. |
|
| 1116 | + */ |
|
| 1117 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1118 | + |
|
| 1119 | + /** |
|
| 1120 | + * The chord shortcode. |
|
| 1121 | + */ |
|
| 1122 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1123 | + |
|
| 1124 | + /** |
|
| 1125 | + * The geomap shortcode. |
|
| 1126 | + */ |
|
| 1127 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1128 | + |
|
| 1129 | + /** |
|
| 1130 | + * The entity cloud shortcode. |
|
| 1131 | + */ |
|
| 1132 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1133 | + |
|
| 1134 | + /** |
|
| 1135 | + * The entity glossary shortcode. |
|
| 1136 | + */ |
|
| 1137 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 1138 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1139 | + |
|
| 1140 | + /** |
|
| 1141 | + * Faceted Search shortcode. |
|
| 1142 | + */ |
|
| 1143 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1144 | + |
|
| 1145 | + /** |
|
| 1146 | + * The ShareThis service. |
|
| 1147 | + */ |
|
| 1148 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1149 | + |
|
| 1150 | + /** |
|
| 1151 | + * The SEO service. |
|
| 1152 | + */ |
|
| 1153 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1154 | + |
|
| 1155 | + /** |
|
| 1156 | + * The AMP service. |
|
| 1157 | + */ |
|
| 1158 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1159 | + |
|
| 1160 | + /** Widgets */ |
|
| 1161 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1162 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1163 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1164 | + |
|
| 1165 | + /* |
|
| 1166 | 1166 | * Schema.org Services. |
| 1167 | 1167 | * |
| 1168 | 1168 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1169 | 1169 | */ |
| 1170 | - if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1171 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1172 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1173 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1174 | - new Wordlift_Schemaorg_Sync_Service(); |
|
| 1175 | - $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service(); |
|
| 1176 | - new Wordlift_Schemaorg_Class_Service(); |
|
| 1177 | - } else { |
|
| 1178 | - $schemaorg_property_service = null; |
|
| 1179 | - } |
|
| 1170 | + if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1171 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1172 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1173 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1174 | + new Wordlift_Schemaorg_Sync_Service(); |
|
| 1175 | + $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service(); |
|
| 1176 | + new Wordlift_Schemaorg_Class_Service(); |
|
| 1177 | + } else { |
|
| 1178 | + $schemaorg_property_service = null; |
|
| 1179 | + } |
|
| 1180 | 1180 | |
| 1181 | - $this->loader = new Wordlift_Loader(); |
|
| 1181 | + $this->loader = new Wordlift_Loader(); |
|
| 1182 | 1182 | |
| 1183 | - // Instantiate a global logger. |
|
| 1184 | - global $wl_logger; |
|
| 1185 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1183 | + // Instantiate a global logger. |
|
| 1184 | + global $wl_logger; |
|
| 1185 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1186 | 1186 | |
| 1187 | - // Load the `wl-api` end-point. |
|
| 1188 | - new Wordlift_Http_Api(); |
|
| 1187 | + // Load the `wl-api` end-point. |
|
| 1188 | + new Wordlift_Http_Api(); |
|
| 1189 | 1189 | |
| 1190 | - // Load the Install Service. |
|
| 1191 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1192 | - $this->install_service = new Wordlift_Install_Service(); |
|
| 1190 | + // Load the Install Service. |
|
| 1191 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1192 | + $this->install_service = new Wordlift_Install_Service(); |
|
| 1193 | 1193 | |
| 1194 | - /** Services. */ |
|
| 1195 | - // Create the configuration service. |
|
| 1196 | - $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 1197 | - $api_service = new Wordlift_Api_Service( $this->configuration_service ); |
|
| 1194 | + /** Services. */ |
|
| 1195 | + // Create the configuration service. |
|
| 1196 | + $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 1197 | + $api_service = new Wordlift_Api_Service( $this->configuration_service ); |
|
| 1198 | 1198 | |
| 1199 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1200 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1199 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1200 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1201 | 1201 | |
| 1202 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1203 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1202 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1203 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1204 | 1204 | |
| 1205 | - // Create an instance of the UI service. |
|
| 1206 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 1205 | + // Create an instance of the UI service. |
|
| 1206 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 1207 | 1207 | |
| 1208 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 1209 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 1208 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 1209 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 1210 | 1210 | |
| 1211 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 1212 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1213 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1214 | - $this->relation_service = new Wordlift_Relation_Service(); |
|
| 1211 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 1212 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1213 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1214 | + $this->relation_service = new Wordlift_Relation_Service(); |
|
| 1215 | 1215 | |
| 1216 | - $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' ); |
|
| 1217 | - $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service ); |
|
| 1218 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service ); |
|
| 1219 | - $this->user_service = new Wordlift_User_Service( $this->sparql_service, $this->entity_service ); |
|
| 1216 | + $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' ); |
|
| 1217 | + $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service ); |
|
| 1218 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service ); |
|
| 1219 | + $this->user_service = new Wordlift_User_Service( $this->sparql_service, $this->entity_service ); |
|
| 1220 | 1220 | |
| 1221 | - // Instantiate the JSON-LD service. |
|
| 1222 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1221 | + // Instantiate the JSON-LD service. |
|
| 1222 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1223 | 1223 | |
| 1224 | - /** Linked Data. */ |
|
| 1225 | - $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1226 | - $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1224 | + /** Linked Data. */ |
|
| 1225 | + $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1226 | + $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1227 | 1227 | |
| 1228 | - $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1228 | + $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1229 | 1229 | |
| 1230 | - // Create a new instance of the Redirect service. |
|
| 1231 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_uri_service ); |
|
| 1232 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1230 | + // Create a new instance of the Redirect service. |
|
| 1231 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_uri_service ); |
|
| 1232 | + $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1233 | 1233 | |
| 1234 | - if ( ! apply_filters( 'wl_features__enable__legacy_linked_data', true ) ) { |
|
| 1235 | - new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service ); |
|
| 1236 | - } |
|
| 1234 | + if ( ! apply_filters( 'wl_features__enable__legacy_linked_data', true ) ) { |
|
| 1235 | + new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service ); |
|
| 1236 | + } |
|
| 1237 | 1237 | |
| 1238 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1239 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1238 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1239 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1240 | 1240 | |
| 1241 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1241 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1242 | 1242 | |
| 1243 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1244 | - $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1243 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1244 | + $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1245 | 1245 | |
| 1246 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1247 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1246 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1247 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1248 | 1248 | |
| 1249 | - // Create an instance of the PrimaShop adapter. |
|
| 1250 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1249 | + // Create an instance of the PrimaShop adapter. |
|
| 1250 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1251 | 1251 | |
| 1252 | - // Create an import service instance to hook later to WP's import function. |
|
| 1253 | - $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() ); |
|
| 1252 | + // Create an import service instance to hook later to WP's import function. |
|
| 1253 | + $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() ); |
|
| 1254 | 1254 | |
| 1255 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1255 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1256 | 1256 | |
| 1257 | - // Create the entity rating service. |
|
| 1258 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1257 | + // Create the entity rating service. |
|
| 1258 | + $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1259 | 1259 | |
| 1260 | - // Create entity list customization (wp-admin/edit.php). |
|
| 1261 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1260 | + // Create entity list customization (wp-admin/edit.php). |
|
| 1261 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1262 | 1262 | |
| 1263 | - // Create a new instance of the Redirect service. |
|
| 1264 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1263 | + // Create a new instance of the Redirect service. |
|
| 1264 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1265 | 1265 | |
| 1266 | - // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1267 | - $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service ); |
|
| 1268 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1269 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1266 | + // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1267 | + $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service ); |
|
| 1268 | + $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1269 | + $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1270 | 1270 | |
| 1271 | - $attachment_service = new Wordlift_Attachment_Service(); |
|
| 1271 | + $attachment_service = new Wordlift_Attachment_Service(); |
|
| 1272 | 1272 | |
| 1273 | - // Instantiate the JSON-LD service. |
|
| 1274 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1275 | - $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 ); |
|
| 1276 | - $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter ); |
|
| 1277 | - $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 ); |
|
| 1278 | - $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1273 | + // Instantiate the JSON-LD service. |
|
| 1274 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1275 | + $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 ); |
|
| 1276 | + $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter ); |
|
| 1277 | + $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 ); |
|
| 1278 | + $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1279 | 1279 | |
| 1280 | - $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1281 | - $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache ); |
|
| 1282 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter ); |
|
| 1280 | + $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1281 | + $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache ); |
|
| 1282 | + $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter ); |
|
| 1283 | 1283 | |
| 1284 | - /* |
|
| 1284 | + /* |
|
| 1285 | 1285 | * Load the `Wordlift_Term_JsonLd_Adapter`. |
| 1286 | 1286 | * |
| 1287 | 1287 | * @see https://github.com/insideout10/wordlift-plugin/issues/892 |
| 1288 | 1288 | * |
| 1289 | 1289 | * @since 3.20.0 |
| 1290 | 1290 | */ |
| 1291 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1292 | - $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service ); |
|
| 1293 | - $jsonld_service = new Jsonld_Service( $this->jsonld_service, $term_jsonld_adapter ); |
|
| 1294 | - new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service ); |
|
| 1295 | - |
|
| 1296 | - // Prints the JSON-LD in the head. |
|
| 1297 | - new Jsonld_Adapter( $this->jsonld_service ); |
|
| 1298 | - |
|
| 1299 | - new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service ); |
|
| 1300 | - |
|
| 1301 | - $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1302 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service ); |
|
| 1303 | - // Creating Faq Content filter service. |
|
| 1304 | - $this->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1305 | - $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1306 | - $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service ); |
|
| 1307 | - $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1308 | - $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->entity_service ); |
|
| 1309 | - |
|
| 1310 | - // Initialize the short-codes. |
|
| 1311 | - new Wordlift_Navigator_Shortcode(); |
|
| 1312 | - new Wordlift_Products_Navigator_Shortcode(); |
|
| 1313 | - new Wordlift_Chord_Shortcode(); |
|
| 1314 | - new Wordlift_Geomap_Shortcode(); |
|
| 1315 | - new Wordlift_Timeline_Shortcode(); |
|
| 1316 | - new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service ); |
|
| 1317 | - new Wordlift_Vocabulary_Shortcode( $this->configuration_service ); |
|
| 1318 | - new Wordlift_Faceted_Search_Shortcode(); |
|
| 1319 | - |
|
| 1320 | - // Initialize the Context Cards Service |
|
| 1321 | - $this->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1322 | - |
|
| 1323 | - // Initialize the SEO service. |
|
| 1324 | - new Wordlift_Seo_Service(); |
|
| 1325 | - |
|
| 1326 | - // Initialize the AMP service. |
|
| 1327 | - new Wordlift_AMP_Service( $this->jsonld_service ); |
|
| 1328 | - |
|
| 1329 | - /** Services. */ |
|
| 1330 | - $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1331 | - new Wordlift_Image_Service(); |
|
| 1332 | - |
|
| 1333 | - /** Adapters. */ |
|
| 1334 | - $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1335 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service ); |
|
| 1336 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1337 | - //$this->faq_tinymce_adapter = new Faq_Tinymce_Adapter(); |
|
| 1338 | - $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1339 | - |
|
| 1340 | - /* |
|
| 1291 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1292 | + $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service ); |
|
| 1293 | + $jsonld_service = new Jsonld_Service( $this->jsonld_service, $term_jsonld_adapter ); |
|
| 1294 | + new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service ); |
|
| 1295 | + |
|
| 1296 | + // Prints the JSON-LD in the head. |
|
| 1297 | + new Jsonld_Adapter( $this->jsonld_service ); |
|
| 1298 | + |
|
| 1299 | + new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service ); |
|
| 1300 | + |
|
| 1301 | + $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1302 | + $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service ); |
|
| 1303 | + // Creating Faq Content filter service. |
|
| 1304 | + $this->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1305 | + $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1306 | + $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service ); |
|
| 1307 | + $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1308 | + $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->entity_service ); |
|
| 1309 | + |
|
| 1310 | + // Initialize the short-codes. |
|
| 1311 | + new Wordlift_Navigator_Shortcode(); |
|
| 1312 | + new Wordlift_Products_Navigator_Shortcode(); |
|
| 1313 | + new Wordlift_Chord_Shortcode(); |
|
| 1314 | + new Wordlift_Geomap_Shortcode(); |
|
| 1315 | + new Wordlift_Timeline_Shortcode(); |
|
| 1316 | + new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service ); |
|
| 1317 | + new Wordlift_Vocabulary_Shortcode( $this->configuration_service ); |
|
| 1318 | + new Wordlift_Faceted_Search_Shortcode(); |
|
| 1319 | + |
|
| 1320 | + // Initialize the Context Cards Service |
|
| 1321 | + $this->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1322 | + |
|
| 1323 | + // Initialize the SEO service. |
|
| 1324 | + new Wordlift_Seo_Service(); |
|
| 1325 | + |
|
| 1326 | + // Initialize the AMP service. |
|
| 1327 | + new Wordlift_AMP_Service( $this->jsonld_service ); |
|
| 1328 | + |
|
| 1329 | + /** Services. */ |
|
| 1330 | + $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1331 | + new Wordlift_Image_Service(); |
|
| 1332 | + |
|
| 1333 | + /** Adapters. */ |
|
| 1334 | + $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1335 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service ); |
|
| 1336 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1337 | + //$this->faq_tinymce_adapter = new Faq_Tinymce_Adapter(); |
|
| 1338 | + $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1339 | + |
|
| 1340 | + /* |
|
| 1341 | 1341 | * Exclude our public js from WP-Rocket. |
| 1342 | 1342 | * |
| 1343 | 1343 | * @since 3.19.4 |
| 1344 | 1344 | * |
| 1345 | 1345 | * @see https://github.com/insideout10/wordlift-plugin/issues/842. |
| 1346 | 1346 | */ |
| 1347 | - new Wordlift_WpRocket_Adapter(); |
|
| 1348 | - |
|
| 1349 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 1350 | - $this->rebuild_service = new Wordlift_Rebuild_Service( |
|
| 1351 | - $this->sparql_service, |
|
| 1352 | - $uri_service |
|
| 1353 | - ); |
|
| 1354 | - |
|
| 1355 | - /** Async Tasks. */ |
|
| 1356 | - new Wordlift_Sparql_Query_Async_Task(); |
|
| 1357 | - new Wordlift_Push_References_Async_Task(); |
|
| 1358 | - |
|
| 1359 | - /** WordPress Admin UI. */ |
|
| 1360 | - |
|
| 1361 | - // UI elements. |
|
| 1362 | - $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1363 | - $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1364 | - $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1365 | - $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1366 | - $this->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1367 | - $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1368 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element ); |
|
| 1369 | - $this->author_element = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element ); |
|
| 1370 | - |
|
| 1371 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1372 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1373 | - |
|
| 1374 | - $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element ); |
|
| 1375 | - $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page ); |
|
| 1376 | - $this->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1377 | - |
|
| 1378 | - // Pages. |
|
| 1379 | - /* |
|
| 1347 | + new Wordlift_WpRocket_Adapter(); |
|
| 1348 | + |
|
| 1349 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 1350 | + $this->rebuild_service = new Wordlift_Rebuild_Service( |
|
| 1351 | + $this->sparql_service, |
|
| 1352 | + $uri_service |
|
| 1353 | + ); |
|
| 1354 | + |
|
| 1355 | + /** Async Tasks. */ |
|
| 1356 | + new Wordlift_Sparql_Query_Async_Task(); |
|
| 1357 | + new Wordlift_Push_References_Async_Task(); |
|
| 1358 | + |
|
| 1359 | + /** WordPress Admin UI. */ |
|
| 1360 | + |
|
| 1361 | + // UI elements. |
|
| 1362 | + $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1363 | + $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1364 | + $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1365 | + $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1366 | + $this->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1367 | + $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1368 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element ); |
|
| 1369 | + $this->author_element = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element ); |
|
| 1370 | + |
|
| 1371 | + $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1372 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1373 | + |
|
| 1374 | + $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element ); |
|
| 1375 | + $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page ); |
|
| 1376 | + $this->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1377 | + |
|
| 1378 | + // Pages. |
|
| 1379 | + /* |
|
| 1380 | 1380 | * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box. |
| 1381 | 1381 | * |
| 1382 | 1382 | * @since 3.20.3 |
| 1383 | 1383 | * |
| 1384 | 1384 | * @see https://github.com/insideout10/wordlift-plugin/issues/914 |
| 1385 | 1385 | */ |
| 1386 | - if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1387 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1388 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1389 | - } |
|
| 1390 | - new Wordlift_Entity_Type_Admin_Service(); |
|
| 1386 | + if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1387 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1388 | + new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1389 | + } |
|
| 1390 | + new Wordlift_Entity_Type_Admin_Service(); |
|
| 1391 | 1391 | |
| 1392 | - // create an instance of the entity type list admin page controller. |
|
| 1393 | - $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1392 | + // create an instance of the entity type list admin page controller. |
|
| 1393 | + $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1394 | 1394 | |
| 1395 | - // create an instance of the entity type setting admin page controller. |
|
| 1396 | - $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1395 | + // create an instance of the entity type setting admin page controller. |
|
| 1396 | + $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1397 | 1397 | |
| 1398 | - /** Widgets */ |
|
| 1399 | - $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1398 | + /** Widgets */ |
|
| 1399 | + $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1400 | 1400 | |
| 1401 | - /* WordPress Admin. */ |
|
| 1402 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1403 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1401 | + /* WordPress Admin. */ |
|
| 1402 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1403 | + $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1404 | 1404 | |
| 1405 | - // Create an instance of the install wizard. |
|
| 1406 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element ); |
|
| 1405 | + // Create an instance of the install wizard. |
|
| 1406 | + $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element ); |
|
| 1407 | 1407 | |
| 1408 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1408 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1409 | 1409 | |
| 1410 | - // User Profile. |
|
| 1411 | - new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1410 | + // User Profile. |
|
| 1411 | + new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1412 | 1412 | |
| 1413 | - $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1413 | + $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1414 | 1414 | |
| 1415 | - // Load the debug service if WP is in debug mode. |
|
| 1416 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1417 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1418 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1419 | - } |
|
| 1415 | + // Load the debug service if WP is in debug mode. |
|
| 1416 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1417 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1418 | + new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1419 | + } |
|
| 1420 | 1420 | |
| 1421 | - // Remote Image Service. |
|
| 1422 | - new Wordlift_Remote_Image_Service(); |
|
| 1421 | + // Remote Image Service. |
|
| 1422 | + new Wordlift_Remote_Image_Service(); |
|
| 1423 | 1423 | |
| 1424 | - /* |
|
| 1424 | + /* |
|
| 1425 | 1425 | * Provides mappings between post types and entity types. |
| 1426 | 1426 | * |
| 1427 | 1427 | * @since 3.20.0 |
| 1428 | 1428 | * |
| 1429 | 1429 | * @see https://github.com/insideout10/wordlift-plugin/issues/852. |
| 1430 | 1430 | */ |
| 1431 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1432 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1433 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1431 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1432 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1433 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1434 | 1434 | |
| 1435 | - // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1436 | - new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1435 | + // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1436 | + new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1437 | 1437 | |
| 1438 | - /* |
|
| 1438 | + /* |
|
| 1439 | 1439 | * Batch Operations. They're similar to Batch Actions but do not require working on post types. |
| 1440 | 1440 | * |
| 1441 | 1441 | * Eventually Batch Actions will become Batch Operations. |
| 1442 | 1442 | * |
| 1443 | 1443 | * @since 3.20.0 |
| 1444 | 1444 | */ |
| 1445 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1446 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1445 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1446 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1447 | 1447 | |
| 1448 | - /* |
|
| 1448 | + /* |
|
| 1449 | 1449 | * Add the Search Keywords taxonomy to manage the Search Keywords on WLS. |
| 1450 | 1450 | * |
| 1451 | 1451 | * @link https://github.com/insideout10/wordlift-plugin/issues/761 |
| 1452 | 1452 | * |
| 1453 | 1453 | * @since 3.20.0 |
| 1454 | 1454 | */ |
| 1455 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php'; |
|
| 1456 | - new Wordlift_Search_Keyword_Taxonomy( $api_service ); |
|
| 1455 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php'; |
|
| 1456 | + new Wordlift_Search_Keyword_Taxonomy( $api_service ); |
|
| 1457 | 1457 | |
| 1458 | - /* |
|
| 1458 | + /* |
|
| 1459 | 1459 | * Load the Mappings JSON-LD post processing. |
| 1460 | 1460 | * |
| 1461 | 1461 | * @since 3.25.0 |
| 1462 | 1462 | */ |
| 1463 | 1463 | |
| 1464 | - $mappings_dbo = new Mappings_DBO(); |
|
| 1465 | - $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1466 | - new Post_Type_Rule_Validator(); |
|
| 1467 | - // Taxonomy term rule validator for validating rules for term pages. |
|
| 1468 | - new Taxonomy_Term_Rule_Validator(); |
|
| 1469 | - $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1470 | - $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1471 | - $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1472 | - |
|
| 1473 | - new Url_To_Entity_Transform_Function( $this->entity_uri_service ); |
|
| 1474 | - new Taxonomy_To_Terms_Transform_Function(); |
|
| 1475 | - new Post_Id_To_Entity_Transform_Function(); |
|
| 1476 | - $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1477 | - |
|
| 1478 | - /** |
|
| 1479 | - * @since 3.27.1 |
|
| 1480 | - * Intiailize the acf group data formatter. |
|
| 1481 | - */ |
|
| 1482 | - new Acf_Group_Formatter(); |
|
| 1483 | - new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1484 | - |
|
| 1485 | - /** |
|
| 1486 | - * @since 3.26.0 |
|
| 1487 | - * Initialize the Faq JSON LD converter here - disabled. |
|
| 1488 | - */ |
|
| 1489 | - // new Faq_To_Jsonld_Converter(); |
|
| 1490 | - /* |
|
| 1464 | + $mappings_dbo = new Mappings_DBO(); |
|
| 1465 | + $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1466 | + new Post_Type_Rule_Validator(); |
|
| 1467 | + // Taxonomy term rule validator for validating rules for term pages. |
|
| 1468 | + new Taxonomy_Term_Rule_Validator(); |
|
| 1469 | + $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1470 | + $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1471 | + $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1472 | + |
|
| 1473 | + new Url_To_Entity_Transform_Function( $this->entity_uri_service ); |
|
| 1474 | + new Taxonomy_To_Terms_Transform_Function(); |
|
| 1475 | + new Post_Id_To_Entity_Transform_Function(); |
|
| 1476 | + $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1477 | + |
|
| 1478 | + /** |
|
| 1479 | + * @since 3.27.1 |
|
| 1480 | + * Intiailize the acf group data formatter. |
|
| 1481 | + */ |
|
| 1482 | + new Acf_Group_Formatter(); |
|
| 1483 | + new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1484 | + |
|
| 1485 | + /** |
|
| 1486 | + * @since 3.26.0 |
|
| 1487 | + * Initialize the Faq JSON LD converter here - disabled. |
|
| 1488 | + */ |
|
| 1489 | + // new Faq_To_Jsonld_Converter(); |
|
| 1490 | + /* |
|
| 1491 | 1491 | * Use the Templates Ajax Endpoint to load HTML templates for the legacy Angular app via admin-ajax.php |
| 1492 | 1492 | * end-point. |
| 1493 | 1493 | * |
| 1494 | 1494 | * @see https://github.com/insideout10/wordlift-plugin/issues/834 |
| 1495 | 1495 | * @since 3.24.4 |
| 1496 | 1496 | */ |
| 1497 | - new Templates_Ajax_Endpoint(); |
|
| 1498 | - // Call this static method to register FAQ routes to rest api - disabled |
|
| 1499 | - //Faq_Rest_Controller::register_routes(); |
|
| 1497 | + new Templates_Ajax_Endpoint(); |
|
| 1498 | + // Call this static method to register FAQ routes to rest api - disabled |
|
| 1499 | + //Faq_Rest_Controller::register_routes(); |
|
| 1500 | 1500 | |
| 1501 | - /* |
|
| 1501 | + /* |
|
| 1502 | 1502 | * Create a singleton for the Analysis_Response_Ops_Factory. |
| 1503 | 1503 | */ |
| 1504 | - $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service ); |
|
| 1505 | - new Analysis_Response_Ops_Factory( |
|
| 1506 | - $this->entity_uri_service, |
|
| 1507 | - $this->entity_service, |
|
| 1508 | - $this->entity_type_service, |
|
| 1509 | - $this->storage_factory->post_images(), |
|
| 1510 | - $entity_helper |
|
| 1511 | - ); |
|
| 1512 | - |
|
| 1513 | - /** WL Autocomplete. */ |
|
| 1514 | - $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1515 | - new Local_Autocomplete_Service(), |
|
| 1516 | - new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ), |
|
| 1517 | - ) ); |
|
| 1518 | - $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1519 | - |
|
| 1520 | - /** |
|
| 1521 | - * @since 3.27.2 |
|
| 1522 | - * Integrate the recipe maker jsonld & set recipe |
|
| 1523 | - * as default entity type to the wprm_recipe CPT. |
|
| 1524 | - */ |
|
| 1525 | - new Recipe_Maker_Post_Type_Hook(); |
|
| 1526 | - $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1527 | - new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1528 | - new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1529 | - new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1530 | - new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1531 | - |
|
| 1532 | - /** |
|
| 1533 | - * @since 3.27.4 |
|
| 1534 | - * Add the faq duplicate markup hook. |
|
| 1535 | - */ |
|
| 1536 | - new Faq_Duplicate_Markup_Remover(); |
|
| 1537 | - } |
|
| 1538 | - |
|
| 1539 | - /** |
|
| 1540 | - * Define the locale for this plugin for internationalization. |
|
| 1541 | - * |
|
| 1542 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1543 | - * with WordPress. |
|
| 1544 | - * |
|
| 1545 | - * @since 1.0.0 |
|
| 1546 | - * @access private |
|
| 1547 | - */ |
|
| 1548 | - private function set_locale() { |
|
| 1549 | - |
|
| 1550 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 1551 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1552 | - |
|
| 1553 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1554 | - |
|
| 1555 | - } |
|
| 1556 | - |
|
| 1557 | - /** |
|
| 1558 | - * Register all of the hooks related to the admin area functionality |
|
| 1559 | - * of the plugin. |
|
| 1560 | - * |
|
| 1561 | - * @since 1.0.0 |
|
| 1562 | - * @access private |
|
| 1563 | - */ |
|
| 1564 | - private function define_admin_hooks() { |
|
| 1565 | - |
|
| 1566 | - $plugin_admin = new Wordlift_Admin( |
|
| 1567 | - $this->get_plugin_name(), |
|
| 1568 | - $this->get_version(), |
|
| 1569 | - $this->configuration_service, |
|
| 1570 | - $this->notice_service, |
|
| 1571 | - $this->user_service |
|
| 1572 | - ); |
|
| 1573 | - |
|
| 1574 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1575 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1576 | - |
|
| 1577 | - // Hook the init action to taxonomy services. |
|
| 1578 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1579 | - $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1580 | - |
|
| 1581 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1582 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1583 | - |
|
| 1584 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 1585 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1586 | - |
|
| 1587 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1588 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1589 | - |
|
| 1590 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1591 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1592 | - |
|
| 1593 | - // Register custom allowed redirect hosts. |
|
| 1594 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1595 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1596 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1597 | - |
|
| 1598 | - /* |
|
| 1504 | + $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service ); |
|
| 1505 | + new Analysis_Response_Ops_Factory( |
|
| 1506 | + $this->entity_uri_service, |
|
| 1507 | + $this->entity_service, |
|
| 1508 | + $this->entity_type_service, |
|
| 1509 | + $this->storage_factory->post_images(), |
|
| 1510 | + $entity_helper |
|
| 1511 | + ); |
|
| 1512 | + |
|
| 1513 | + /** WL Autocomplete. */ |
|
| 1514 | + $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1515 | + new Local_Autocomplete_Service(), |
|
| 1516 | + new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ), |
|
| 1517 | + ) ); |
|
| 1518 | + $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1519 | + |
|
| 1520 | + /** |
|
| 1521 | + * @since 3.27.2 |
|
| 1522 | + * Integrate the recipe maker jsonld & set recipe |
|
| 1523 | + * as default entity type to the wprm_recipe CPT. |
|
| 1524 | + */ |
|
| 1525 | + new Recipe_Maker_Post_Type_Hook(); |
|
| 1526 | + $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1527 | + new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1528 | + new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1529 | + new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1530 | + new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1531 | + |
|
| 1532 | + /** |
|
| 1533 | + * @since 3.27.4 |
|
| 1534 | + * Add the faq duplicate markup hook. |
|
| 1535 | + */ |
|
| 1536 | + new Faq_Duplicate_Markup_Remover(); |
|
| 1537 | + } |
|
| 1538 | + |
|
| 1539 | + /** |
|
| 1540 | + * Define the locale for this plugin for internationalization. |
|
| 1541 | + * |
|
| 1542 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1543 | + * with WordPress. |
|
| 1544 | + * |
|
| 1545 | + * @since 1.0.0 |
|
| 1546 | + * @access private |
|
| 1547 | + */ |
|
| 1548 | + private function set_locale() { |
|
| 1549 | + |
|
| 1550 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 1551 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1552 | + |
|
| 1553 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1554 | + |
|
| 1555 | + } |
|
| 1556 | + |
|
| 1557 | + /** |
|
| 1558 | + * Register all of the hooks related to the admin area functionality |
|
| 1559 | + * of the plugin. |
|
| 1560 | + * |
|
| 1561 | + * @since 1.0.0 |
|
| 1562 | + * @access private |
|
| 1563 | + */ |
|
| 1564 | + private function define_admin_hooks() { |
|
| 1565 | + |
|
| 1566 | + $plugin_admin = new Wordlift_Admin( |
|
| 1567 | + $this->get_plugin_name(), |
|
| 1568 | + $this->get_version(), |
|
| 1569 | + $this->configuration_service, |
|
| 1570 | + $this->notice_service, |
|
| 1571 | + $this->user_service |
|
| 1572 | + ); |
|
| 1573 | + |
|
| 1574 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1575 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1576 | + |
|
| 1577 | + // Hook the init action to taxonomy services. |
|
| 1578 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1579 | + $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1580 | + |
|
| 1581 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1582 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1583 | + |
|
| 1584 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 1585 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1586 | + |
|
| 1587 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1588 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1589 | + |
|
| 1590 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1591 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1592 | + |
|
| 1593 | + // Register custom allowed redirect hosts. |
|
| 1594 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1595 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1596 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1597 | + |
|
| 1598 | + /* |
|
| 1599 | 1599 | * The old dashboard is replaced with dashboard v2. |
| 1600 | 1600 | * |
| 1601 | 1601 | * The old dashboard service is still loaded because its functions are used. |
@@ -1604,326 +1604,326 @@ discard block |
||
| 1604 | 1604 | * |
| 1605 | 1605 | * @since 3.20.0 |
| 1606 | 1606 | */ |
| 1607 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1608 | - // $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1609 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1610 | - // $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1611 | - |
|
| 1612 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1613 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1614 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1615 | - $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1616 | - |
|
| 1617 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1618 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1619 | - |
|
| 1620 | - // Entity listing customization (wp-admin/edit.php) |
|
| 1621 | - // Add custom columns. |
|
| 1622 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1623 | - // no explicit entity as it prevents handling of other post types. |
|
| 1624 | - $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1625 | - // Add 4W selection. |
|
| 1626 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1627 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1628 | - $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1629 | - $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1630 | - |
|
| 1631 | - /* |
|
| 1607 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1608 | + // $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1609 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1610 | + // $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1611 | + |
|
| 1612 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1613 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1614 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1615 | + $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1616 | + |
|
| 1617 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1618 | + $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1619 | + |
|
| 1620 | + // Entity listing customization (wp-admin/edit.php) |
|
| 1621 | + // Add custom columns. |
|
| 1622 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1623 | + // no explicit entity as it prevents handling of other post types. |
|
| 1624 | + $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1625 | + // Add 4W selection. |
|
| 1626 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1627 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1628 | + $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1629 | + $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1630 | + |
|
| 1631 | + /* |
|
| 1632 | 1632 | * If `All Entity Types` is disable, use the radio button Walker. |
| 1633 | 1633 | * |
| 1634 | 1634 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1635 | 1635 | */ |
| 1636 | - if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1637 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1638 | - } |
|
| 1636 | + if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1637 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1638 | + } |
|
| 1639 | 1639 | |
| 1640 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1641 | - // entities. |
|
| 1642 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1640 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1641 | + // entities. |
|
| 1642 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1643 | 1643 | |
| 1644 | - // Filter imported post meta. |
|
| 1645 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1644 | + // Filter imported post meta. |
|
| 1645 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1646 | 1646 | |
| 1647 | - // Notify the import service when an import starts and ends. |
|
| 1648 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1649 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1647 | + // Notify the import service when an import starts and ends. |
|
| 1648 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1649 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1650 | 1650 | |
| 1651 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1652 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1653 | - $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' ); |
|
| 1651 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1652 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1653 | + $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' ); |
|
| 1654 | 1654 | |
| 1655 | - // Hook the menu to the Download Your Data page. |
|
| 1656 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1657 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1658 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1655 | + // Hook the menu to the Download Your Data page. |
|
| 1656 | + $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1657 | + $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1658 | + $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1659 | 1659 | |
| 1660 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1661 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1660 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1661 | + $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1662 | 1662 | |
| 1663 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1664 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1665 | - $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1666 | - $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1663 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1664 | + $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1665 | + $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1666 | + $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1667 | 1667 | |
| 1668 | - // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1669 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1668 | + // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1669 | + $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1670 | 1670 | |
| 1671 | - // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1672 | - $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' ); |
|
| 1671 | + // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1672 | + $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' ); |
|
| 1673 | 1673 | |
| 1674 | - // Hook the `admin_init` function to the Admin Setup. |
|
| 1675 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1674 | + // Hook the `admin_init` function to the Admin Setup. |
|
| 1675 | + $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1676 | 1676 | |
| 1677 | - // Hook the admin_init to the settings page. |
|
| 1678 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1679 | - $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' ); |
|
| 1677 | + // Hook the admin_init to the settings page. |
|
| 1678 | + $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1679 | + $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' ); |
|
| 1680 | 1680 | |
| 1681 | - $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' ); |
|
| 1681 | + $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' ); |
|
| 1682 | 1682 | |
| 1683 | - // Hook the menu creation on the general wordlift menu creation. |
|
| 1684 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1683 | + // Hook the menu creation on the general wordlift menu creation. |
|
| 1684 | + $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1685 | 1685 | |
| 1686 | - /* |
|
| 1686 | + /* |
|
| 1687 | 1687 | * Display the `Wordlift_Admin_Search_Rankings_Page` page. |
| 1688 | 1688 | * |
| 1689 | 1689 | * @link https://github.com/insideout10/wordlift-plugin/issues/761 |
| 1690 | 1690 | * |
| 1691 | 1691 | * @since 3.20.0 |
| 1692 | 1692 | */ |
| 1693 | - if ( in_array( $this->configuration_service->get_package_type(), array( 'editorial', 'business' ) ) ) { |
|
| 1694 | - $admin_search_rankings_page = new Wordlift_Admin_Search_Rankings_Page(); |
|
| 1695 | - $this->loader->add_action( 'wl_admin_menu', $admin_search_rankings_page, 'admin_menu' ); |
|
| 1696 | - } |
|
| 1693 | + if ( in_array( $this->configuration_service->get_package_type(), array( 'editorial', 'business' ) ) ) { |
|
| 1694 | + $admin_search_rankings_page = new Wordlift_Admin_Search_Rankings_Page(); |
|
| 1695 | + $this->loader->add_action( 'wl_admin_menu', $admin_search_rankings_page, 'admin_menu' ); |
|
| 1696 | + } |
|
| 1697 | 1697 | |
| 1698 | - // Hook key update. |
|
| 1699 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1700 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1698 | + // Hook key update. |
|
| 1699 | + $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1700 | + $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1701 | 1701 | |
| 1702 | - // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1703 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1702 | + // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1703 | + $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1704 | 1704 | |
| 1705 | - /* |
|
| 1705 | + /* |
|
| 1706 | 1706 | * Remove the Analytics Settings link from the plugin page. |
| 1707 | 1707 | * |
| 1708 | 1708 | * @see https://github.com/insideout10/wordlift-plugin/issues/932 |
| 1709 | 1709 | * @since 3.21.1 |
| 1710 | 1710 | */ |
| 1711 | - // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1712 | - |
|
| 1713 | - // Hook the AJAX `wl_publisher` action name. |
|
| 1714 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1715 | - |
|
| 1716 | - // Hook row actions for the entity type list admin. |
|
| 1717 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1718 | - |
|
| 1719 | - /** Ajax actions. */ |
|
| 1720 | - $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1721 | - |
|
| 1722 | - // Hook capabilities manipulation to allow access to entity type admin |
|
| 1723 | - // page on WordPress versions before 4.7. |
|
| 1724 | - global $wp_version; |
|
| 1725 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1726 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1727 | - } |
|
| 1728 | - |
|
| 1729 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1730 | - |
|
| 1731 | - /** Adapters. */ |
|
| 1732 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1733 | - /** |
|
| 1734 | - * Disabling Faq temporarily. |
|
| 1735 | - * Load the tinymce editor button on the tool bar. |
|
| 1736 | - * @since 3.26.0 |
|
| 1737 | - */ |
|
| 1738 | - //$this->loader->add_filter( 'tiny_mce_before_init', $this->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1739 | - //$this->loader->add_filter( 'mce_buttons', $this->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1740 | - //$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1741 | - |
|
| 1742 | - |
|
| 1743 | - $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' ); |
|
| 1744 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1745 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1746 | - /** |
|
| 1747 | - * @since 3.26.0 |
|
| 1748 | - * Post excerpt meta box would be only loaded when the language is set |
|
| 1749 | - * to english |
|
| 1750 | - */ |
|
| 1751 | - if ( $this->configuration_service->get_language_code() === 'en' ) { |
|
| 1752 | - $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1753 | - $this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1754 | - // Adding Rest route for the post excerpt |
|
| 1755 | - Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1756 | - } |
|
| 1757 | - |
|
| 1758 | - $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 ); |
|
| 1759 | - $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 ); |
|
| 1760 | - |
|
| 1761 | - // Handle the autocomplete request. |
|
| 1762 | - add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1763 | - $this->autocomplete_adapter, |
|
| 1764 | - 'wl_autocomplete', |
|
| 1765 | - ) ); |
|
| 1766 | - add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1767 | - $this->autocomplete_adapter, |
|
| 1768 | - 'wl_autocomplete', |
|
| 1769 | - ) ); |
|
| 1770 | - |
|
| 1771 | - // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1772 | - if ( is_multisite() ) { |
|
| 1773 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1774 | - } |
|
| 1775 | - |
|
| 1776 | - $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service ); |
|
| 1777 | - |
|
| 1778 | - add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1779 | - add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1780 | - add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) ); |
|
| 1781 | - |
|
| 1782 | - /** |
|
| 1783 | - * Always allow the `wordlift/classification` block. |
|
| 1784 | - * |
|
| 1785 | - * @since 3.23.0 |
|
| 1786 | - */ |
|
| 1787 | - add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1788 | - |
|
| 1789 | - if ( true === $value ) { |
|
| 1790 | - return $value; |
|
| 1791 | - } |
|
| 1792 | - |
|
| 1793 | - return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1794 | - }, PHP_INT_MAX ); |
|
| 1795 | - } |
|
| 1796 | - |
|
| 1797 | - /** |
|
| 1798 | - * Register all of the hooks related to the public-facing functionality |
|
| 1799 | - * of the plugin. |
|
| 1800 | - * |
|
| 1801 | - * @since 1.0.0 |
|
| 1802 | - * @access private |
|
| 1803 | - */ |
|
| 1804 | - private function define_public_hooks() { |
|
| 1805 | - |
|
| 1806 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1807 | - |
|
| 1808 | - // Register the entity post type. |
|
| 1809 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1810 | - |
|
| 1811 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 1812 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1813 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1814 | - $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 ); |
|
| 1815 | - $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 ); |
|
| 1816 | - |
|
| 1817 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1818 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1819 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' ); |
|
| 1820 | - |
|
| 1821 | - // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1822 | - $this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1823 | - // Hook the content filter service to add entity links. |
|
| 1824 | - if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1825 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1826 | - } |
|
| 1827 | - |
|
| 1828 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1829 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1830 | - |
|
| 1831 | - // Hook the ShareThis service. |
|
| 1832 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1833 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1834 | - |
|
| 1835 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1836 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1837 | - |
|
| 1838 | - // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1839 | - // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1840 | - // to categories. |
|
| 1841 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1842 | - |
|
| 1843 | - /* |
|
| 1711 | + // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1712 | + |
|
| 1713 | + // Hook the AJAX `wl_publisher` action name. |
|
| 1714 | + $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1715 | + |
|
| 1716 | + // Hook row actions for the entity type list admin. |
|
| 1717 | + $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1718 | + |
|
| 1719 | + /** Ajax actions. */ |
|
| 1720 | + $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1721 | + |
|
| 1722 | + // Hook capabilities manipulation to allow access to entity type admin |
|
| 1723 | + // page on WordPress versions before 4.7. |
|
| 1724 | + global $wp_version; |
|
| 1725 | + if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1726 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1727 | + } |
|
| 1728 | + |
|
| 1729 | + $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1730 | + |
|
| 1731 | + /** Adapters. */ |
|
| 1732 | + $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1733 | + /** |
|
| 1734 | + * Disabling Faq temporarily. |
|
| 1735 | + * Load the tinymce editor button on the tool bar. |
|
| 1736 | + * @since 3.26.0 |
|
| 1737 | + */ |
|
| 1738 | + //$this->loader->add_filter( 'tiny_mce_before_init', $this->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1739 | + //$this->loader->add_filter( 'mce_buttons', $this->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1740 | + //$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1741 | + |
|
| 1742 | + |
|
| 1743 | + $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' ); |
|
| 1744 | + $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1745 | + $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1746 | + /** |
|
| 1747 | + * @since 3.26.0 |
|
| 1748 | + * Post excerpt meta box would be only loaded when the language is set |
|
| 1749 | + * to english |
|
| 1750 | + */ |
|
| 1751 | + if ( $this->configuration_service->get_language_code() === 'en' ) { |
|
| 1752 | + $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1753 | + $this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1754 | + // Adding Rest route for the post excerpt |
|
| 1755 | + Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1756 | + } |
|
| 1757 | + |
|
| 1758 | + $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 ); |
|
| 1759 | + $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 ); |
|
| 1760 | + |
|
| 1761 | + // Handle the autocomplete request. |
|
| 1762 | + add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1763 | + $this->autocomplete_adapter, |
|
| 1764 | + 'wl_autocomplete', |
|
| 1765 | + ) ); |
|
| 1766 | + add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1767 | + $this->autocomplete_adapter, |
|
| 1768 | + 'wl_autocomplete', |
|
| 1769 | + ) ); |
|
| 1770 | + |
|
| 1771 | + // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1772 | + if ( is_multisite() ) { |
|
| 1773 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1774 | + } |
|
| 1775 | + |
|
| 1776 | + $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service ); |
|
| 1777 | + |
|
| 1778 | + add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1779 | + add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1780 | + add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) ); |
|
| 1781 | + |
|
| 1782 | + /** |
|
| 1783 | + * Always allow the `wordlift/classification` block. |
|
| 1784 | + * |
|
| 1785 | + * @since 3.23.0 |
|
| 1786 | + */ |
|
| 1787 | + add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1788 | + |
|
| 1789 | + if ( true === $value ) { |
|
| 1790 | + return $value; |
|
| 1791 | + } |
|
| 1792 | + |
|
| 1793 | + return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1794 | + }, PHP_INT_MAX ); |
|
| 1795 | + } |
|
| 1796 | + |
|
| 1797 | + /** |
|
| 1798 | + * Register all of the hooks related to the public-facing functionality |
|
| 1799 | + * of the plugin. |
|
| 1800 | + * |
|
| 1801 | + * @since 1.0.0 |
|
| 1802 | + * @access private |
|
| 1803 | + */ |
|
| 1804 | + private function define_public_hooks() { |
|
| 1805 | + |
|
| 1806 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1807 | + |
|
| 1808 | + // Register the entity post type. |
|
| 1809 | + $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1810 | + |
|
| 1811 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 1812 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1813 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1814 | + $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 ); |
|
| 1815 | + $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 ); |
|
| 1816 | + |
|
| 1817 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1818 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1819 | + $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' ); |
|
| 1820 | + |
|
| 1821 | + // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1822 | + $this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1823 | + // Hook the content filter service to add entity links. |
|
| 1824 | + if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1825 | + $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1826 | + } |
|
| 1827 | + |
|
| 1828 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1829 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1830 | + |
|
| 1831 | + // Hook the ShareThis service. |
|
| 1832 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1833 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1834 | + |
|
| 1835 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1836 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1837 | + |
|
| 1838 | + // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1839 | + // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1840 | + // to categories. |
|
| 1841 | + $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1842 | + |
|
| 1843 | + /* |
|
| 1844 | 1844 | * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service` |
| 1845 | 1845 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1846 | 1846 | * order of start time. |
| 1847 | 1847 | */ |
| 1848 | - $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1849 | - |
|
| 1850 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1851 | - |
|
| 1852 | - // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1853 | - $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1854 | - |
|
| 1855 | - // Analytics Script Frontend. |
|
| 1856 | - if ( $this->configuration_service->is_analytics_enable() ) { |
|
| 1857 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 1858 | - } |
|
| 1859 | - |
|
| 1860 | - } |
|
| 1861 | - |
|
| 1862 | - /** |
|
| 1863 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 1864 | - * |
|
| 1865 | - * @since 1.0.0 |
|
| 1866 | - */ |
|
| 1867 | - public function run() { |
|
| 1868 | - $this->loader->run(); |
|
| 1869 | - } |
|
| 1870 | - |
|
| 1871 | - /** |
|
| 1872 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 1873 | - * WordPress and to define internationalization functionality. |
|
| 1874 | - * |
|
| 1875 | - * @return string The name of the plugin. |
|
| 1876 | - * @since 1.0.0 |
|
| 1877 | - */ |
|
| 1878 | - public function get_plugin_name() { |
|
| 1879 | - return $this->plugin_name; |
|
| 1880 | - } |
|
| 1881 | - |
|
| 1882 | - /** |
|
| 1883 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1884 | - * |
|
| 1885 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1886 | - * @since 1.0.0 |
|
| 1887 | - */ |
|
| 1888 | - public function get_loader() { |
|
| 1889 | - return $this->loader; |
|
| 1890 | - } |
|
| 1891 | - |
|
| 1892 | - /** |
|
| 1893 | - * Retrieve the version number of the plugin. |
|
| 1894 | - * |
|
| 1895 | - * @return string The version number of the plugin. |
|
| 1896 | - * @since 1.0.0 |
|
| 1897 | - */ |
|
| 1898 | - public function get_version() { |
|
| 1899 | - return $this->version; |
|
| 1900 | - } |
|
| 1901 | - |
|
| 1902 | - /** |
|
| 1903 | - * Load dependencies for WP-CLI. |
|
| 1904 | - * |
|
| 1905 | - * @throws Exception |
|
| 1906 | - * @since 3.18.0 |
|
| 1907 | - */ |
|
| 1908 | - private function load_cli_dependencies() { |
|
| 1909 | - |
|
| 1910 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php'; |
|
| 1911 | - |
|
| 1912 | - $push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service ); |
|
| 1913 | - |
|
| 1914 | - WP_CLI::add_command( 'wl references push', $push_reference_data_command ); |
|
| 1915 | - |
|
| 1916 | - } |
|
| 1917 | - |
|
| 1918 | - /** |
|
| 1919 | - * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions. |
|
| 1920 | - * |
|
| 1921 | - * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance. |
|
| 1922 | - * @since 3.20.0 |
|
| 1923 | - */ |
|
| 1924 | - public function get_dashboard_service() { |
|
| 1925 | - |
|
| 1926 | - return $this->dashboard_service; |
|
| 1927 | - } |
|
| 1848 | + $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1849 | + |
|
| 1850 | + $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1851 | + |
|
| 1852 | + // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1853 | + $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1854 | + |
|
| 1855 | + // Analytics Script Frontend. |
|
| 1856 | + if ( $this->configuration_service->is_analytics_enable() ) { |
|
| 1857 | + $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 1858 | + } |
|
| 1859 | + |
|
| 1860 | + } |
|
| 1861 | + |
|
| 1862 | + /** |
|
| 1863 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 1864 | + * |
|
| 1865 | + * @since 1.0.0 |
|
| 1866 | + */ |
|
| 1867 | + public function run() { |
|
| 1868 | + $this->loader->run(); |
|
| 1869 | + } |
|
| 1870 | + |
|
| 1871 | + /** |
|
| 1872 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 1873 | + * WordPress and to define internationalization functionality. |
|
| 1874 | + * |
|
| 1875 | + * @return string The name of the plugin. |
|
| 1876 | + * @since 1.0.0 |
|
| 1877 | + */ |
|
| 1878 | + public function get_plugin_name() { |
|
| 1879 | + return $this->plugin_name; |
|
| 1880 | + } |
|
| 1881 | + |
|
| 1882 | + /** |
|
| 1883 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1884 | + * |
|
| 1885 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1886 | + * @since 1.0.0 |
|
| 1887 | + */ |
|
| 1888 | + public function get_loader() { |
|
| 1889 | + return $this->loader; |
|
| 1890 | + } |
|
| 1891 | + |
|
| 1892 | + /** |
|
| 1893 | + * Retrieve the version number of the plugin. |
|
| 1894 | + * |
|
| 1895 | + * @return string The version number of the plugin. |
|
| 1896 | + * @since 1.0.0 |
|
| 1897 | + */ |
|
| 1898 | + public function get_version() { |
|
| 1899 | + return $this->version; |
|
| 1900 | + } |
|
| 1901 | + |
|
| 1902 | + /** |
|
| 1903 | + * Load dependencies for WP-CLI. |
|
| 1904 | + * |
|
| 1905 | + * @throws Exception |
|
| 1906 | + * @since 3.18.0 |
|
| 1907 | + */ |
|
| 1908 | + private function load_cli_dependencies() { |
|
| 1909 | + |
|
| 1910 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php'; |
|
| 1911 | + |
|
| 1912 | + $push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service ); |
|
| 1913 | + |
|
| 1914 | + WP_CLI::add_command( 'wl references push', $push_reference_data_command ); |
|
| 1915 | + |
|
| 1916 | + } |
|
| 1917 | + |
|
| 1918 | + /** |
|
| 1919 | + * Get the {@link \Wordlift_Dashboard_Service} to allow others to use its functions. |
|
| 1920 | + * |
|
| 1921 | + * @return \Wordlift_Dashboard_Service The {@link \Wordlift_Dashboard_Service} instance. |
|
| 1922 | + * @since 3.20.0 |
|
| 1923 | + */ |
|
| 1924 | + public function get_dashboard_service() { |
|
| 1925 | + |
|
| 1926 | + return $this->dashboard_service; |
|
| 1927 | + } |
|
| 1928 | 1928 | |
| 1929 | 1929 | } |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | $this->define_public_hooks(); |
| 756 | 756 | |
| 757 | 757 | // If we're in `WP_CLI` load the related files. |
| 758 | - if ( class_exists( 'WP_CLI' ) ) { |
|
| 758 | + if (class_exists('WP_CLI')) { |
|
| 759 | 759 | $this->load_cli_dependencies(); |
| 760 | 760 | } |
| 761 | 761 | |
@@ -796,381 +796,381 @@ discard block |
||
| 796 | 796 | * The class responsible for orchestrating the actions and filters of the |
| 797 | 797 | * core plugin. |
| 798 | 798 | */ |
| 799 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 799 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php'; |
|
| 800 | 800 | |
| 801 | 801 | // The class responsible for plugin uninstall. |
| 802 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 802 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-deactivator-feedback.php'; |
|
| 803 | 803 | |
| 804 | 804 | /** |
| 805 | 805 | * The class responsible for defining internationalization functionality |
| 806 | 806 | * of the plugin. |
| 807 | 807 | */ |
| 808 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 808 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php'; |
|
| 809 | 809 | |
| 810 | 810 | /** |
| 811 | 811 | * WordLift's supported languages. |
| 812 | 812 | */ |
| 813 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 813 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-languages.php'; |
|
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | 816 | * WordLift's supported countries. |
| 817 | 817 | */ |
| 818 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 818 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-countries.php'; |
|
| 819 | 819 | |
| 820 | 820 | /** |
| 821 | 821 | * Provide support functions to sanitize data. |
| 822 | 822 | */ |
| 823 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 823 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php'; |
|
| 824 | 824 | |
| 825 | 825 | /** Services. */ |
| 826 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 827 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 829 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 830 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 831 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 833 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php'; |
|
| 834 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 835 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 826 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php'; |
|
| 827 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-http-api.php'; |
|
| 828 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php'; |
|
| 829 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php'; |
|
| 830 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-type-service.php'; |
|
| 831 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php'; |
|
| 832 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php'; |
|
| 833 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-linked-data-service.php'; |
|
| 834 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-relation-service.php'; |
|
| 835 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-image-service.php'; |
|
| 836 | 836 | |
| 837 | 837 | /** |
| 838 | 838 | * The Query builder. |
| 839 | 839 | */ |
| 840 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 840 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php'; |
|
| 841 | 841 | |
| 842 | 842 | /** |
| 843 | 843 | * The Schema service. |
| 844 | 844 | */ |
| 845 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 845 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php'; |
|
| 846 | 846 | |
| 847 | 847 | /** |
| 848 | 848 | * The schema:url property service. |
| 849 | 849 | */ |
| 850 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 851 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 850 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-service.php'; |
|
| 851 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-url-property-service.php'; |
|
| 852 | 852 | |
| 853 | 853 | /** |
| 854 | 854 | * The UI service. |
| 855 | 855 | */ |
| 856 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 856 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php'; |
|
| 857 | 857 | |
| 858 | 858 | /** |
| 859 | 859 | * The Thumbnail service. |
| 860 | 860 | */ |
| 861 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 861 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php'; |
|
| 862 | 862 | |
| 863 | 863 | /** |
| 864 | 864 | * The Entity Types Taxonomy service. |
| 865 | 865 | */ |
| 866 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 866 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 867 | 867 | |
| 868 | 868 | /** |
| 869 | 869 | * The Entity service. |
| 870 | 870 | */ |
| 871 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 872 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 871 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-uri-service.php'; |
|
| 872 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php'; |
|
| 873 | 873 | |
| 874 | 874 | // Add the entity rating service. |
| 875 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 875 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rating-service.php'; |
|
| 876 | 876 | |
| 877 | 877 | /** |
| 878 | 878 | * The User service. |
| 879 | 879 | */ |
| 880 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 880 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php'; |
|
| 881 | 881 | |
| 882 | 882 | /** |
| 883 | 883 | * The Timeline service. |
| 884 | 884 | */ |
| 885 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 885 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php'; |
|
| 886 | 886 | |
| 887 | 887 | /** |
| 888 | 888 | * The Topic Taxonomy service. |
| 889 | 889 | */ |
| 890 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 890 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 891 | 891 | |
| 892 | 892 | /** |
| 893 | 893 | * The SPARQL service. |
| 894 | 894 | */ |
| 895 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 895 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php'; |
|
| 896 | 896 | |
| 897 | 897 | /** |
| 898 | 898 | * The WordLift import service. |
| 899 | 899 | */ |
| 900 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 900 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php'; |
|
| 901 | 901 | |
| 902 | 902 | /** |
| 903 | 903 | * The WordLift URI service. |
| 904 | 904 | */ |
| 905 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 906 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 907 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 905 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php'; |
|
| 906 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-factory.php'; |
|
| 907 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sample-data-service.php'; |
|
| 908 | 908 | |
| 909 | 909 | /** |
| 910 | 910 | * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
| 911 | 911 | */ |
| 912 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-listable.php'; |
|
| 913 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 914 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 915 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 916 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 912 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-listable.php'; |
|
| 913 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-rebuild-service.php'; |
|
| 914 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-reference-rebuild-service.php'; |
|
| 915 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-relation-rebuild-service.php'; |
|
| 916 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/rebuild/class-wordlift-relation-rebuild-adapter.php'; |
|
| 917 | 917 | |
| 918 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 919 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 918 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 919 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-attachment-service.php'; |
|
| 920 | 920 | |
| 921 | 921 | /** |
| 922 | 922 | * Load the converters. |
| 923 | 923 | */ |
| 924 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 925 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 926 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 927 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 928 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 929 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 924 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/intf-wordlift-post-converter.php'; |
|
| 925 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 926 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 927 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 928 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 929 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 930 | 930 | |
| 931 | 931 | /** |
| 932 | 932 | * Load cache-related files. |
| 933 | 933 | */ |
| 934 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 934 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/cache/require.php'; |
|
| 935 | 935 | |
| 936 | 936 | /** |
| 937 | 937 | * Load the content filter. |
| 938 | 938 | */ |
| 939 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 939 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-content-filter-service.php'; |
|
| 940 | 940 | |
| 941 | 941 | /* |
| 942 | 942 | * Load the excerpt helper. |
| 943 | 943 | */ |
| 944 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 944 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 945 | 945 | |
| 946 | 946 | /** |
| 947 | 947 | * Load the JSON-LD service to publish entities using JSON-LD.s |
| 948 | 948 | * |
| 949 | 949 | * @since 3.8.0 |
| 950 | 950 | */ |
| 951 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 951 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-service.php'; |
|
| 952 | 952 | |
| 953 | 953 | // The Publisher Service and the AJAX adapter. |
| 954 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 955 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 954 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-service.php'; |
|
| 955 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 956 | 956 | |
| 957 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 957 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-adapter.php'; |
|
| 958 | 958 | |
| 959 | 959 | /** |
| 960 | 960 | * Load the WordLift key validation service. |
| 961 | 961 | */ |
| 962 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 962 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-key-validation-service.php'; |
|
| 963 | 963 | |
| 964 | 964 | // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
| 965 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 965 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 966 | 966 | |
| 967 | 967 | // Load the `Wordlift_Entity_Page_Service` class definition. |
| 968 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 968 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-page-service.php'; |
|
| 969 | 969 | |
| 970 | 970 | /** Linked Data. */ |
| 971 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 972 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 973 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 974 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 975 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 976 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 977 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 978 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 979 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 980 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 981 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 971 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 972 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 973 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 974 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 975 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 976 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 977 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 978 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 979 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 980 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 981 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 982 | 982 | |
| 983 | 983 | /** Linked Data Rendition. */ |
| 984 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 985 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 986 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 987 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 984 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php'; |
|
| 985 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-default-sparql-tuple-rendition.php'; |
|
| 986 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-address-sparql-tuple-rendition.php'; |
|
| 987 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php'; |
|
| 988 | 988 | |
| 989 | 989 | /** Services. */ |
| 990 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 991 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 990 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 991 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-api-service.php'; |
|
| 992 | 992 | |
| 993 | 993 | /** Adapters. */ |
| 994 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 995 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 996 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 997 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 998 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 994 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-tinymce-adapter.php'; |
|
| 995 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-newrelic-adapter.php'; |
|
| 996 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 997 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-adapter.php'; |
|
| 998 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-wprocket-adapter.php'; |
|
| 999 | 999 | |
| 1000 | 1000 | /** Async Tasks. */ |
| 1001 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1002 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1003 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1001 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-async-task.php'; |
|
| 1002 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 1003 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-push-references-async-task.php'; |
|
| 1004 | 1004 | |
| 1005 | 1005 | /** Autocomplete. */ |
| 1006 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1006 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 1007 | 1007 | |
| 1008 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 1008 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-remote-image-service.php'; |
|
| 1009 | 1009 | |
| 1010 | 1010 | /** Analytics */ |
| 1011 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1011 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 1012 | 1012 | |
| 1013 | 1013 | /** |
| 1014 | 1014 | * The class responsible for defining all actions that occur in the admin area. |
| 1015 | 1015 | */ |
| 1016 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 1016 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php'; |
|
| 1017 | 1017 | |
| 1018 | 1018 | /** |
| 1019 | 1019 | * The class to customize the entity list admin page. |
| 1020 | 1020 | */ |
| 1021 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 1021 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php'; |
|
| 1022 | 1022 | |
| 1023 | 1023 | /** |
| 1024 | 1024 | * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
| 1025 | 1025 | */ |
| 1026 | 1026 | global $wp_version; |
| 1027 | - if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 1028 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1027 | + if (version_compare($wp_version, '5.3', '<')) { |
|
| 1028 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 1029 | 1029 | } else { |
| 1030 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1030 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | /** |
| 1034 | 1034 | * The Notice service. |
| 1035 | 1035 | */ |
| 1036 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 1036 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php'; |
|
| 1037 | 1037 | |
| 1038 | 1038 | /** |
| 1039 | 1039 | * The PrimaShop adapter. |
| 1040 | 1040 | */ |
| 1041 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 1041 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php'; |
|
| 1042 | 1042 | |
| 1043 | 1043 | /** |
| 1044 | 1044 | * The WordLift Dashboard service. |
| 1045 | 1045 | */ |
| 1046 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 1046 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php'; |
|
| 1047 | 1047 | |
| 1048 | 1048 | /** |
| 1049 | 1049 | * The admin 'Install wizard' page. |
| 1050 | 1050 | */ |
| 1051 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 1051 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-setup.php'; |
|
| 1052 | 1052 | |
| 1053 | 1053 | /** |
| 1054 | 1054 | * The WordLift entity type list admin page controller. |
| 1055 | 1055 | */ |
| 1056 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1056 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 1057 | 1057 | |
| 1058 | 1058 | /** |
| 1059 | 1059 | * The WordLift entity type settings admin page controller. |
| 1060 | 1060 | */ |
| 1061 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 1061 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-settings.php'; |
|
| 1062 | 1062 | |
| 1063 | 1063 | /** |
| 1064 | 1064 | * The admin 'Download Your Data' page. |
| 1065 | 1065 | */ |
| 1066 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 1066 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php'; |
|
| 1067 | 1067 | |
| 1068 | 1068 | /** |
| 1069 | 1069 | * The admin 'WordLift Settings' page. |
| 1070 | 1070 | */ |
| 1071 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1072 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1073 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1074 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1075 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1076 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1077 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1078 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1079 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1080 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1081 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 1082 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 1083 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1084 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1085 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1071 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/intf-wordlift-admin-element.php'; |
|
| 1072 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 1073 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 1074 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 1075 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 1076 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 1077 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 1078 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 1079 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 1080 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 1081 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-page.php'; |
|
| 1082 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page.php'; |
|
| 1083 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 1084 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 1085 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 1086 | 1086 | |
| 1087 | 1087 | /** Admin Pages */ |
| 1088 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1089 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 1090 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-page.php'; |
|
| 1091 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1088 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 1089 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-status-page.php'; |
|
| 1090 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-search-rankings-page.php'; |
|
| 1091 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 1092 | 1092 | |
| 1093 | 1093 | /** |
| 1094 | 1094 | * The class responsible for defining all actions that occur in the public-facing |
| 1095 | 1095 | * side of the site. |
| 1096 | 1096 | */ |
| 1097 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 1097 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php'; |
|
| 1098 | 1098 | |
| 1099 | 1099 | /** |
| 1100 | 1100 | * The shortcode abstract class. |
| 1101 | 1101 | */ |
| 1102 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 1102 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php'; |
|
| 1103 | 1103 | |
| 1104 | 1104 | /** |
| 1105 | 1105 | * The Timeline shortcode. |
| 1106 | 1106 | */ |
| 1107 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 1107 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php'; |
|
| 1108 | 1108 | |
| 1109 | 1109 | /** |
| 1110 | 1110 | * The Navigator shortcode. |
| 1111 | 1111 | */ |
| 1112 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 1112 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php'; |
|
| 1113 | 1113 | |
| 1114 | 1114 | /** |
| 1115 | 1115 | * The Products Navigator shortcode. |
| 1116 | 1116 | */ |
| 1117 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1117 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 1118 | 1118 | |
| 1119 | 1119 | /** |
| 1120 | 1120 | * The chord shortcode. |
| 1121 | 1121 | */ |
| 1122 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 1122 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php'; |
|
| 1123 | 1123 | |
| 1124 | 1124 | /** |
| 1125 | 1125 | * The geomap shortcode. |
| 1126 | 1126 | */ |
| 1127 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 1127 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php'; |
|
| 1128 | 1128 | |
| 1129 | 1129 | /** |
| 1130 | 1130 | * The entity cloud shortcode. |
| 1131 | 1131 | */ |
| 1132 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1132 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 1133 | 1133 | |
| 1134 | 1134 | /** |
| 1135 | 1135 | * The entity glossary shortcode. |
| 1136 | 1136 | */ |
| 1137 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 1138 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1137 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-alphabet-service.php'; |
|
| 1138 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 1139 | 1139 | |
| 1140 | 1140 | /** |
| 1141 | 1141 | * Faceted Search shortcode. |
| 1142 | 1142 | */ |
| 1143 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1143 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 1144 | 1144 | |
| 1145 | 1145 | /** |
| 1146 | 1146 | * The ShareThis service. |
| 1147 | 1147 | */ |
| 1148 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 1148 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php'; |
|
| 1149 | 1149 | |
| 1150 | 1150 | /** |
| 1151 | 1151 | * The SEO service. |
| 1152 | 1152 | */ |
| 1153 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1153 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-seo-service.php'; |
|
| 1154 | 1154 | |
| 1155 | 1155 | /** |
| 1156 | 1156 | * The AMP service. |
| 1157 | 1157 | */ |
| 1158 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1158 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-amp-service.php'; |
|
| 1159 | 1159 | |
| 1160 | 1160 | /** Widgets */ |
| 1161 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1162 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1163 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1161 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-widget.php'; |
|
| 1162 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1163 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-context-cards.php'; |
|
| 1164 | 1164 | |
| 1165 | 1165 | /* |
| 1166 | 1166 | * Schema.org Services. |
| 1167 | 1167 | * |
| 1168 | 1168 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1169 | 1169 | */ |
| 1170 | - if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1171 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1172 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1173 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1170 | + if (WL_ALL_ENTITY_TYPES) { |
|
| 1171 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1172 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1173 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1174 | 1174 | new Wordlift_Schemaorg_Sync_Service(); |
| 1175 | 1175 | $schemaorg_property_service = new Wordlift_Schemaorg_Property_Service(); |
| 1176 | 1176 | new Wordlift_Schemaorg_Class_Service(); |
@@ -1182,25 +1182,25 @@ discard block |
||
| 1182 | 1182 | |
| 1183 | 1183 | // Instantiate a global logger. |
| 1184 | 1184 | global $wl_logger; |
| 1185 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1185 | + $wl_logger = Wordlift_Log_Service::get_logger('WordLift'); |
|
| 1186 | 1186 | |
| 1187 | 1187 | // Load the `wl-api` end-point. |
| 1188 | 1188 | new Wordlift_Http_Api(); |
| 1189 | 1189 | |
| 1190 | 1190 | // Load the Install Service. |
| 1191 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1191 | + require_once plugin_dir_path(dirname(__FILE__)).'install/class-wordlift-install-service.php'; |
|
| 1192 | 1192 | $this->install_service = new Wordlift_Install_Service(); |
| 1193 | 1193 | |
| 1194 | 1194 | /** Services. */ |
| 1195 | 1195 | // Create the configuration service. |
| 1196 | 1196 | $this->configuration_service = new Wordlift_Configuration_Service(); |
| 1197 | - $api_service = new Wordlift_Api_Service( $this->configuration_service ); |
|
| 1197 | + $api_service = new Wordlift_Api_Service($this->configuration_service); |
|
| 1198 | 1198 | |
| 1199 | 1199 | // Create an entity type service instance. It'll be later bound to the init action. |
| 1200 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 1200 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path()); |
|
| 1201 | 1201 | |
| 1202 | 1202 | // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
| 1203 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 1203 | + $this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_post_type_service, $this->configuration_service->get_entity_base_path()); |
|
| 1204 | 1204 | |
| 1205 | 1205 | // Create an instance of the UI service. |
| 1206 | 1206 | $this->ui_service = new Wordlift_UI_Service(); |
@@ -1209,34 +1209,34 @@ discard block |
||
| 1209 | 1209 | $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
| 1210 | 1210 | |
| 1211 | 1211 | $this->sparql_service = new Wordlift_Sparql_Service(); |
| 1212 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 1212 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service($this->sparql_service); |
|
| 1213 | 1213 | $this->notice_service = new Wordlift_Notice_Service(); |
| 1214 | 1214 | $this->relation_service = new Wordlift_Relation_Service(); |
| 1215 | 1215 | |
| 1216 | - $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' ); |
|
| 1217 | - $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service( $this->configuration_service, $entity_uri_cache_service ); |
|
| 1218 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service, $this->entity_uri_service ); |
|
| 1219 | - $this->user_service = new Wordlift_User_Service( $this->sparql_service, $this->entity_service ); |
|
| 1216 | + $entity_uri_cache_service = new Wordlift_File_Cache_Service(WL_TEMP_DIR.'entity_uri/'); |
|
| 1217 | + $this->entity_uri_service = new Wordlift_Cached_Entity_Uri_Service($this->configuration_service, $entity_uri_cache_service); |
|
| 1218 | + $this->entity_service = new Wordlift_Entity_Service($this->ui_service, $this->relation_service, $this->entity_uri_service); |
|
| 1219 | + $this->user_service = new Wordlift_User_Service($this->sparql_service, $this->entity_service); |
|
| 1220 | 1220 | |
| 1221 | 1221 | // Instantiate the JSON-LD service. |
| 1222 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1222 | + $property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service); |
|
| 1223 | 1223 | |
| 1224 | 1224 | /** Linked Data. */ |
| 1225 | - $this->storage_factory = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter ); |
|
| 1226 | - $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service ); |
|
| 1225 | + $this->storage_factory = new Wordlift_Storage_Factory($this->entity_service, $this->user_service, $property_getter); |
|
| 1226 | + $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory($this->entity_service); |
|
| 1227 | 1227 | |
| 1228 | - $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service ); |
|
| 1228 | + $this->schema_service = new Wordlift_Schema_Service($this->storage_factory, $this->rendition_factory, $this->configuration_service); |
|
| 1229 | 1229 | |
| 1230 | 1230 | // Create a new instance of the Redirect service. |
| 1231 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_uri_service ); |
|
| 1232 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 1231 | + $this->redirect_service = new Wordlift_Redirect_Service($this->entity_uri_service); |
|
| 1232 | + $this->entity_type_service = new Wordlift_Entity_Type_Service($this->schema_service); |
|
| 1233 | 1233 | |
| 1234 | - if ( ! apply_filters( 'wl_features__enable__legacy_linked_data', true ) ) { |
|
| 1235 | - new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service ); |
|
| 1234 | + if ( ! apply_filters('wl_features__enable__legacy_linked_data', true)) { |
|
| 1235 | + new Wordlift_Linked_Data_Service($this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service); |
|
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | 1238 | // Create a new instance of the Timeline service and Timeline shortcode. |
| 1239 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service ); |
|
| 1239 | + $this->timeline_service = new Wordlift_Timeline_Service($this->entity_service, $this->entity_type_service); |
|
| 1240 | 1240 | |
| 1241 | 1241 | $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
| 1242 | 1242 | |
@@ -1250,36 +1250,36 @@ discard block |
||
| 1250 | 1250 | $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
| 1251 | 1251 | |
| 1252 | 1252 | // Create an import service instance to hook later to WP's import function. |
| 1253 | - $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() ); |
|
| 1253 | + $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()); |
|
| 1254 | 1254 | |
| 1255 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1255 | + $uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']); |
|
| 1256 | 1256 | |
| 1257 | 1257 | // Create the entity rating service. |
| 1258 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 1258 | + $this->rating_service = new Wordlift_Rating_Service($this->entity_service, $this->entity_type_service, $this->notice_service); |
|
| 1259 | 1259 | |
| 1260 | 1260 | // Create entity list customization (wp-admin/edit.php). |
| 1261 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 1261 | + $this->entity_list_service = new Wordlift_Entity_List_Service($this->rating_service); |
|
| 1262 | 1262 | |
| 1263 | 1263 | // Create a new instance of the Redirect service. |
| 1264 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service ); |
|
| 1264 | + $this->dashboard_service = new Wordlift_Dashboard_Service($this->rating_service, $this->entity_service); |
|
| 1265 | 1265 | |
| 1266 | 1266 | // Create an instance of the Publisher Service and the AJAX Adapter. |
| 1267 | - $this->publisher_service = new Wordlift_Publisher_Service( $this->configuration_service ); |
|
| 1268 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1269 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1267 | + $this->publisher_service = new Wordlift_Publisher_Service($this->configuration_service); |
|
| 1268 | + $this->property_factory = new Wordlift_Property_Factory($schema_url_property_service); |
|
| 1269 | + $this->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service); |
|
| 1270 | 1270 | |
| 1271 | 1271 | $attachment_service = new Wordlift_Attachment_Service(); |
| 1272 | 1272 | |
| 1273 | 1273 | // Instantiate the JSON-LD service. |
| 1274 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 1275 | - $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 ); |
|
| 1276 | - $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter ); |
|
| 1277 | - $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 ); |
|
| 1278 | - $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service ); |
|
| 1274 | + $property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service); |
|
| 1275 | + $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); |
|
| 1276 | + $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter($this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $this->post_to_jsonld_converter); |
|
| 1277 | + $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); |
|
| 1278 | + $this->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter($this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service); |
|
| 1279 | 1279 | |
| 1280 | - $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1281 | - $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache ); |
|
| 1282 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter ); |
|
| 1280 | + $jsonld_cache = new Ttl_Cache('jsonld', 86400); |
|
| 1281 | + $this->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter($this->postid_to_jsonld_converter, $this->configuration_service, $jsonld_cache); |
|
| 1282 | + $this->jsonld_service = new Wordlift_Jsonld_Service($this->entity_service, $this->cached_postid_to_jsonld_converter, $this->jsonld_website_converter); |
|
| 1283 | 1283 | |
| 1284 | 1284 | /* |
| 1285 | 1285 | * Load the `Wordlift_Term_JsonLd_Adapter`. |
@@ -1288,24 +1288,24 @@ discard block |
||
| 1288 | 1288 | * |
| 1289 | 1289 | * @since 3.20.0 |
| 1290 | 1290 | */ |
| 1291 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1292 | - $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $this->entity_uri_service, $this->jsonld_service ); |
|
| 1293 | - $jsonld_service = new Jsonld_Service( $this->jsonld_service, $term_jsonld_adapter ); |
|
| 1294 | - new Jsonld_Endpoint( $jsonld_service, $this->entity_uri_service ); |
|
| 1291 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1292 | + $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter($this->entity_uri_service, $this->jsonld_service); |
|
| 1293 | + $jsonld_service = new Jsonld_Service($this->jsonld_service, $term_jsonld_adapter); |
|
| 1294 | + new Jsonld_Endpoint($jsonld_service, $this->entity_uri_service); |
|
| 1295 | 1295 | |
| 1296 | 1296 | // Prints the JSON-LD in the head. |
| 1297 | - new Jsonld_Adapter( $this->jsonld_service ); |
|
| 1297 | + new Jsonld_Adapter($this->jsonld_service); |
|
| 1298 | 1298 | |
| 1299 | - new Jsonld_By_Id_Endpoint( $this->jsonld_service, $this->entity_uri_service ); |
|
| 1299 | + new Jsonld_By_Id_Endpoint($this->jsonld_service, $this->entity_uri_service); |
|
| 1300 | 1300 | |
| 1301 | - $this->key_validation_service = new Wordlift_Key_Validation_Service( $this->configuration_service ); |
|
| 1302 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service, $this->entity_uri_service ); |
|
| 1301 | + $this->key_validation_service = new Wordlift_Key_Validation_Service($this->configuration_service); |
|
| 1302 | + $this->content_filter_service = new Wordlift_Content_Filter_Service($this->entity_service, $this->configuration_service, $this->entity_uri_service); |
|
| 1303 | 1303 | // Creating Faq Content filter service. |
| 1304 | 1304 | $this->faq_content_filter_service = new Faq_Content_Filter(); |
| 1305 | - $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service ); |
|
| 1306 | - $this->sample_data_service = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service, $this->user_service ); |
|
| 1307 | - $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service ); |
|
| 1308 | - $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service( $this->entity_service ); |
|
| 1305 | + $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service($this->content_filter_service, $this->entity_service); |
|
| 1306 | + $this->sample_data_service = new Wordlift_Sample_Data_Service($this->entity_type_service, $this->configuration_service, $this->user_service); |
|
| 1307 | + $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter($this->sample_data_service); |
|
| 1308 | + $this->reference_rebuild_service = new Wordlift_Reference_Rebuild_Service($this->entity_service); |
|
| 1309 | 1309 | |
| 1310 | 1310 | // Initialize the short-codes. |
| 1311 | 1311 | new Wordlift_Navigator_Shortcode(); |
@@ -1313,8 +1313,8 @@ discard block |
||
| 1313 | 1313 | new Wordlift_Chord_Shortcode(); |
| 1314 | 1314 | new Wordlift_Geomap_Shortcode(); |
| 1315 | 1315 | new Wordlift_Timeline_Shortcode(); |
| 1316 | - new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service ); |
|
| 1317 | - new Wordlift_Vocabulary_Shortcode( $this->configuration_service ); |
|
| 1316 | + new Wordlift_Related_Entities_Cloud_Shortcode($this->relation_service); |
|
| 1317 | + new Wordlift_Vocabulary_Shortcode($this->configuration_service); |
|
| 1318 | 1318 | new Wordlift_Faceted_Search_Shortcode(); |
| 1319 | 1319 | |
| 1320 | 1320 | // Initialize the Context Cards Service |
@@ -1324,18 +1324,18 @@ discard block |
||
| 1324 | 1324 | new Wordlift_Seo_Service(); |
| 1325 | 1325 | |
| 1326 | 1326 | // Initialize the AMP service. |
| 1327 | - new Wordlift_AMP_Service( $this->jsonld_service ); |
|
| 1327 | + new Wordlift_AMP_Service($this->jsonld_service); |
|
| 1328 | 1328 | |
| 1329 | 1329 | /** Services. */ |
| 1330 | 1330 | $this->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
| 1331 | 1331 | new Wordlift_Image_Service(); |
| 1332 | 1332 | |
| 1333 | 1333 | /** Adapters. */ |
| 1334 | - $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter( $this->entity_type_service ); |
|
| 1335 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $this->publisher_service ); |
|
| 1336 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 1334 | + $this->entity_type_adapter = new Wordlift_Entity_Type_Adapter($this->entity_type_service); |
|
| 1335 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter($this->publisher_service); |
|
| 1336 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter($this); |
|
| 1337 | 1337 | //$this->faq_tinymce_adapter = new Faq_Tinymce_Adapter(); |
| 1338 | - $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service ); |
|
| 1338 | + $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter($this->relation_rebuild_service); |
|
| 1339 | 1339 | |
| 1340 | 1340 | /* |
| 1341 | 1341 | * Exclude our public js from WP-Rocket. |
@@ -1365,14 +1365,14 @@ discard block |
||
| 1365 | 1365 | $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
| 1366 | 1366 | $this->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
| 1367 | 1367 | $tabs_element = new Wordlift_Admin_Tabs_Element(); |
| 1368 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element ); |
|
| 1369 | - $this->author_element = new Wordlift_Admin_Author_Element( $this->publisher_service, $this->select2_element ); |
|
| 1368 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element($this->configuration_service, $this->publisher_service, $tabs_element, $this->select2_element); |
|
| 1369 | + $this->author_element = new Wordlift_Admin_Author_Element($this->publisher_service, $this->select2_element); |
|
| 1370 | 1370 | |
| 1371 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 1372 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 1371 | + $this->settings_page = new Wordlift_Admin_Settings_Page($this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->country_select_element, $this->publisher_element, $this->radio_input_element); |
|
| 1372 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link($this->settings_page); |
|
| 1373 | 1373 | |
| 1374 | - $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $this->configuration_service, $this->input_element, $this->radio_input_element ); |
|
| 1375 | - $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $this->analytics_settings_page ); |
|
| 1374 | + $this->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page($this->configuration_service, $this->input_element, $this->radio_input_element); |
|
| 1375 | + $this->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link($this->analytics_settings_page); |
|
| 1376 | 1376 | $this->analytics_connect = new Wordlift_Analytics_Connect(); |
| 1377 | 1377 | |
| 1378 | 1378 | // Pages. |
@@ -1383,9 +1383,9 @@ discard block |
||
| 1383 | 1383 | * |
| 1384 | 1384 | * @see https://github.com/insideout10/wordlift-plugin/issues/914 |
| 1385 | 1385 | */ |
| 1386 | - if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1387 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1388 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 1386 | + if (apply_filters('wl_can_see_classification_box', true)) { |
|
| 1387 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1388 | + new Wordlift_Admin_Post_Edit_Page($this); |
|
| 1389 | 1389 | } |
| 1390 | 1390 | new Wordlift_Entity_Type_Admin_Service(); |
| 1391 | 1391 | |
@@ -1399,23 +1399,23 @@ discard block |
||
| 1399 | 1399 | $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
| 1400 | 1400 | |
| 1401 | 1401 | /* WordPress Admin. */ |
| 1402 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 1403 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 1402 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service); |
|
| 1403 | + $this->status_page = new Wordlift_Admin_Status_Page($this->entity_service, $this->sparql_service); |
|
| 1404 | 1404 | |
| 1405 | 1405 | // Create an instance of the install wizard. |
| 1406 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element ); |
|
| 1406 | + $this->admin_setup = new Wordlift_Admin_Setup($this->configuration_service, $this->key_validation_service, $this->entity_service, $this->language_select_element, $this->country_select_element); |
|
| 1407 | 1407 | |
| 1408 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 1408 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service($this->entity_post_type_service); |
|
| 1409 | 1409 | |
| 1410 | 1410 | // User Profile. |
| 1411 | - new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service ); |
|
| 1411 | + new Wordlift_Admin_User_Profile_Page($this->author_element, $this->user_service); |
|
| 1412 | 1412 | |
| 1413 | 1413 | $this->entity_page_service = new Wordlift_Entity_Page_Service(); |
| 1414 | 1414 | |
| 1415 | 1415 | // Load the debug service if WP is in debug mode. |
| 1416 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1417 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1418 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1416 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
| 1417 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-debug-service.php'; |
|
| 1418 | + new Wordlift_Debug_Service($this->entity_service, $uri_service); |
|
| 1419 | 1419 | } |
| 1420 | 1420 | |
| 1421 | 1421 | // Remote Image Service. |
@@ -1428,12 +1428,12 @@ discard block |
||
| 1428 | 1428 | * |
| 1429 | 1429 | * @see https://github.com/insideout10/wordlift-plugin/issues/852. |
| 1430 | 1430 | */ |
| 1431 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1432 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1433 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1431 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-batch-action.php'; |
|
| 1432 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1433 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1434 | 1434 | |
| 1435 | 1435 | // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
| 1436 | - new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1436 | + new Wordlift_Mapping_Ajax_Adapter(new Wordlift_Mapping_Service(Wordlift_Entity_Type_Service::get_instance())); |
|
| 1437 | 1437 | |
| 1438 | 1438 | /* |
| 1439 | 1439 | * Batch Operations. They're similar to Batch Actions but do not require working on post types. |
@@ -1442,8 +1442,8 @@ discard block |
||
| 1442 | 1442 | * |
| 1443 | 1443 | * @since 3.20.0 |
| 1444 | 1444 | */ |
| 1445 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1446 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1445 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1446 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1447 | 1447 | |
| 1448 | 1448 | /* |
| 1449 | 1449 | * Add the Search Keywords taxonomy to manage the Search Keywords on WLS. |
@@ -1452,8 +1452,8 @@ discard block |
||
| 1452 | 1452 | * |
| 1453 | 1453 | * @since 3.20.0 |
| 1454 | 1454 | */ |
| 1455 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php'; |
|
| 1456 | - new Wordlift_Search_Keyword_Taxonomy( $api_service ); |
|
| 1455 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/search-keywords/class-wordlift-search-keyword-taxonomy.php'; |
|
| 1456 | + new Wordlift_Search_Keyword_Taxonomy($api_service); |
|
| 1457 | 1457 | |
| 1458 | 1458 | /* |
| 1459 | 1459 | * Load the Mappings JSON-LD post processing. |
@@ -1466,11 +1466,11 @@ discard block |
||
| 1466 | 1466 | new Post_Type_Rule_Validator(); |
| 1467 | 1467 | // Taxonomy term rule validator for validating rules for term pages. |
| 1468 | 1468 | new Taxonomy_Term_Rule_Validator(); |
| 1469 | - $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1470 | - $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1471 | - $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1469 | + $rule_validators_registry = new Rule_Validators_Registry($default_rule_validator); |
|
| 1470 | + $rule_groups_validator = new Rule_Groups_Validator($rule_validators_registry); |
|
| 1471 | + $mappings_validator = new Mappings_Validator($mappings_dbo, $rule_groups_validator); |
|
| 1472 | 1472 | |
| 1473 | - new Url_To_Entity_Transform_Function( $this->entity_uri_service ); |
|
| 1473 | + new Url_To_Entity_Transform_Function($this->entity_uri_service); |
|
| 1474 | 1474 | new Taxonomy_To_Terms_Transform_Function(); |
| 1475 | 1475 | new Post_Id_To_Entity_Transform_Function(); |
| 1476 | 1476 | $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
@@ -1480,7 +1480,7 @@ discard block |
||
| 1480 | 1480 | * Intiailize the acf group data formatter. |
| 1481 | 1481 | */ |
| 1482 | 1482 | new Acf_Group_Formatter(); |
| 1483 | - new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1483 | + new Jsonld_Converter($mappings_validator, $mappings_transform_functions_registry); |
|
| 1484 | 1484 | |
| 1485 | 1485 | /** |
| 1486 | 1486 | * @since 3.26.0 |
@@ -1501,7 +1501,7 @@ discard block |
||
| 1501 | 1501 | /* |
| 1502 | 1502 | * Create a singleton for the Analysis_Response_Ops_Factory. |
| 1503 | 1503 | */ |
| 1504 | - $entity_helper = new Entity_Helper( $this->entity_uri_service, $this->entity_service ); |
|
| 1504 | + $entity_helper = new Entity_Helper($this->entity_uri_service, $this->entity_service); |
|
| 1505 | 1505 | new Analysis_Response_Ops_Factory( |
| 1506 | 1506 | $this->entity_uri_service, |
| 1507 | 1507 | $this->entity_service, |
@@ -1511,11 +1511,11 @@ discard block |
||
| 1511 | 1511 | ); |
| 1512 | 1512 | |
| 1513 | 1513 | /** WL Autocomplete. */ |
| 1514 | - $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1514 | + $autocomplete_service = new All_Autocomplete_Service(array( |
|
| 1515 | 1515 | new Local_Autocomplete_Service(), |
| 1516 | - new Linked_Data_Autocomplete_Service( $this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service ), |
|
| 1517 | - ) ); |
|
| 1518 | - $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1516 | + new Linked_Data_Autocomplete_Service($this->configuration_service, $entity_helper, $this->entity_uri_service, $this->entity_service), |
|
| 1517 | + )); |
|
| 1518 | + $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter($autocomplete_service); |
|
| 1519 | 1519 | |
| 1520 | 1520 | /** |
| 1521 | 1521 | * @since 3.27.2 |
@@ -1524,10 +1524,10 @@ discard block |
||
| 1524 | 1524 | */ |
| 1525 | 1525 | new Recipe_Maker_Post_Type_Hook(); |
| 1526 | 1526 | $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
| 1527 | - new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1528 | - new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1529 | - new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1530 | - new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1527 | + new Recipe_Maker_Jsonld_Hook($attachment_service, $recipe_maker_validation_service); |
|
| 1528 | + new Recipe_Maker_After_Get_Jsonld_Hook($recipe_maker_validation_service); |
|
| 1529 | + new Recipe_Maker_Warning($recipe_maker_validation_service); |
|
| 1530 | + new Yoast_Jsonld($recipe_maker_validation_service); |
|
| 1531 | 1531 | |
| 1532 | 1532 | /** |
| 1533 | 1533 | * @since 3.27.4 |
@@ -1548,9 +1548,9 @@ discard block |
||
| 1548 | 1548 | private function set_locale() { |
| 1549 | 1549 | |
| 1550 | 1550 | $plugin_i18n = new Wordlift_i18n(); |
| 1551 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1551 | + $plugin_i18n->set_domain($this->get_plugin_name()); |
|
| 1552 | 1552 | |
| 1553 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1553 | + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
| 1554 | 1554 | |
| 1555 | 1555 | } |
| 1556 | 1556 | |
@@ -1571,29 +1571,29 @@ discard block |
||
| 1571 | 1571 | $this->user_service |
| 1572 | 1572 | ); |
| 1573 | 1573 | |
| 1574 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1575 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1574 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
| 1575 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11); |
|
| 1576 | 1576 | |
| 1577 | 1577 | // Hook the init action to taxonomy services. |
| 1578 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1579 | - $this->loader->add_action( 'init', $this->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1578 | + $this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0); |
|
| 1579 | + $this->loader->add_action('init', $this->entity_types_taxonomy_service, 'init', 0); |
|
| 1580 | 1580 | |
| 1581 | 1581 | // Hook the deleted_post_meta action to the Thumbnail service. |
| 1582 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1582 | + $this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4); |
|
| 1583 | 1583 | |
| 1584 | 1584 | // Hook the added_post_meta action to the Thumbnail service. |
| 1585 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1585 | + $this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1586 | 1586 | |
| 1587 | 1587 | // Hook the updated_post_meta action to the Thumbnail service. |
| 1588 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1588 | + $this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1589 | 1589 | |
| 1590 | 1590 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1591 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1591 | + $this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1592 | 1592 | |
| 1593 | 1593 | // Register custom allowed redirect hosts. |
| 1594 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1594 | + $this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts'); |
|
| 1595 | 1595 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1596 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1596 | + $this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect'); |
|
| 1597 | 1597 | |
| 1598 | 1598 | /* |
| 1599 | 1599 | * The old dashboard is replaced with dashboard v2. |
@@ -1611,77 +1611,77 @@ discard block |
||
| 1611 | 1611 | |
| 1612 | 1612 | // Hook save_post to the entity service to update custom fields (such as alternate labels). |
| 1613 | 1613 | // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
| 1614 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1615 | - $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1614 | + $this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3); |
|
| 1615 | + $this->loader->add_action('save_post', $this->rating_service, 'set_rating_for', 20, 1); |
|
| 1616 | 1616 | |
| 1617 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1618 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1617 | + $this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1); |
|
| 1618 | + $this->loader->add_action('in_admin_header', $this->rating_service, 'in_admin_header'); |
|
| 1619 | 1619 | |
| 1620 | 1620 | // Entity listing customization (wp-admin/edit.php) |
| 1621 | 1621 | // Add custom columns. |
| 1622 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1622 | + $this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns'); |
|
| 1623 | 1623 | // no explicit entity as it prevents handling of other post types. |
| 1624 | - $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1624 | + $this->loader->add_filter('manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2); |
|
| 1625 | 1625 | // Add 4W selection. |
| 1626 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1627 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1628 | - $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' ); |
|
| 1629 | - $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' ); |
|
| 1626 | + $this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope'); |
|
| 1627 | + $this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope'); |
|
| 1628 | + $this->loader->add_action('pre_get_posts', $this->entity_list_service, 'pre_get_posts'); |
|
| 1629 | + $this->loader->add_action('load-edit.php', $this->entity_list_service, 'load_edit'); |
|
| 1630 | 1630 | |
| 1631 | 1631 | /* |
| 1632 | 1632 | * If `All Entity Types` is disable, use the radio button Walker. |
| 1633 | 1633 | * |
| 1634 | 1634 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1635 | 1635 | */ |
| 1636 | - if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1637 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1636 | + if ( ! WL_ALL_ENTITY_TYPES) { |
|
| 1637 | + $this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args'); |
|
| 1638 | 1638 | } |
| 1639 | 1639 | |
| 1640 | 1640 | // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
| 1641 | 1641 | // entities. |
| 1642 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1642 | + $this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2); |
|
| 1643 | 1643 | |
| 1644 | 1644 | // Filter imported post meta. |
| 1645 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1645 | + $this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3); |
|
| 1646 | 1646 | |
| 1647 | 1647 | // Notify the import service when an import starts and ends. |
| 1648 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1649 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1648 | + $this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0); |
|
| 1649 | + $this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0); |
|
| 1650 | 1650 | |
| 1651 | 1651 | // Hook the AJAX wl_rebuild action to the Rebuild Service. |
| 1652 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1653 | - $this->loader->add_action( 'wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild' ); |
|
| 1652 | + $this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild'); |
|
| 1653 | + $this->loader->add_action('wp_ajax_wl_rebuild_references', $this->reference_rebuild_service, 'rebuild'); |
|
| 1654 | 1654 | |
| 1655 | 1655 | // Hook the menu to the Download Your Data page. |
| 1656 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1657 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1658 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1656 | + $this->loader->add_action('admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0); |
|
| 1657 | + $this->loader->add_action('admin_menu', $this->status_page, 'admin_menu', 100, 0); |
|
| 1658 | + $this->loader->add_action('admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0); |
|
| 1659 | 1659 | |
| 1660 | 1660 | // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
| 1661 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1661 | + $this->loader->add_action('wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10); |
|
| 1662 | 1662 | |
| 1663 | 1663 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1664 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1665 | - $this->loader->add_action( 'admin_post_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1666 | - $this->loader->add_action( 'admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1664 | + $this->loader->add_action('wp_ajax_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1665 | + $this->loader->add_action('admin_post_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1666 | + $this->loader->add_action('admin_post_nopriv_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1667 | 1667 | |
| 1668 | 1668 | // Hook the AJAX wl_validate_key action to the Key Validation service. |
| 1669 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1669 | + $this->loader->add_action('wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key'); |
|
| 1670 | 1670 | |
| 1671 | 1671 | // Hook the AJAX wl_update_country_options action to the countries. |
| 1672 | - $this->loader->add_action( 'wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html' ); |
|
| 1672 | + $this->loader->add_action('wp_ajax_wl_update_country_options', $this->country_select_element, 'get_options_html'); |
|
| 1673 | 1673 | |
| 1674 | 1674 | // Hook the `admin_init` function to the Admin Setup. |
| 1675 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1675 | + $this->loader->add_action('admin_init', $this->admin_setup, 'admin_init'); |
|
| 1676 | 1676 | |
| 1677 | 1677 | // Hook the admin_init to the settings page. |
| 1678 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1679 | - $this->loader->add_action( 'admin_init', $this->analytics_settings_page, 'admin_init' ); |
|
| 1678 | + $this->loader->add_action('admin_init', $this->settings_page, 'admin_init'); |
|
| 1679 | + $this->loader->add_action('admin_init', $this->analytics_settings_page, 'admin_init'); |
|
| 1680 | 1680 | |
| 1681 | - $this->loader->add_filter( 'admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction' ); |
|
| 1681 | + $this->loader->add_filter('admin_post_thumbnail_html', $this->publisher_service, 'add_featured_image_instruction'); |
|
| 1682 | 1682 | |
| 1683 | 1683 | // Hook the menu creation on the general wordlift menu creation. |
| 1684 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1684 | + $this->loader->add_action('wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2); |
|
| 1685 | 1685 | |
| 1686 | 1686 | /* |
| 1687 | 1687 | * Display the `Wordlift_Admin_Search_Rankings_Page` page. |
@@ -1690,17 +1690,17 @@ discard block |
||
| 1690 | 1690 | * |
| 1691 | 1691 | * @since 3.20.0 |
| 1692 | 1692 | */ |
| 1693 | - if ( in_array( $this->configuration_service->get_package_type(), array( 'editorial', 'business' ) ) ) { |
|
| 1693 | + if (in_array($this->configuration_service->get_package_type(), array('editorial', 'business'))) { |
|
| 1694 | 1694 | $admin_search_rankings_page = new Wordlift_Admin_Search_Rankings_Page(); |
| 1695 | - $this->loader->add_action( 'wl_admin_menu', $admin_search_rankings_page, 'admin_menu' ); |
|
| 1695 | + $this->loader->add_action('wl_admin_menu', $admin_search_rankings_page, 'admin_menu'); |
|
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | 1698 | // Hook key update. |
| 1699 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1700 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1699 | + $this->loader->add_action('pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2); |
|
| 1700 | + $this->loader->add_action('update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2); |
|
| 1701 | 1701 | |
| 1702 | 1702 | // Add additional action links to the WordLift plugin in the plugins page. |
| 1703 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1703 | + $this->loader->add_filter('plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1); |
|
| 1704 | 1704 | |
| 1705 | 1705 | /* |
| 1706 | 1706 | * Remove the Analytics Settings link from the plugin page. |
@@ -1711,25 +1711,25 @@ discard block |
||
| 1711 | 1711 | // $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
| 1712 | 1712 | |
| 1713 | 1713 | // Hook the AJAX `wl_publisher` action name. |
| 1714 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1714 | + $this->loader->add_action('wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher'); |
|
| 1715 | 1715 | |
| 1716 | 1716 | // Hook row actions for the entity type list admin. |
| 1717 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1717 | + $this->loader->add_filter('wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2); |
|
| 1718 | 1718 | |
| 1719 | 1719 | /** Ajax actions. */ |
| 1720 | - $this->loader->add_action( 'wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export' ); |
|
| 1720 | + $this->loader->add_action('wp_ajax_wl_google_analytics_export', $this->google_analytics_export_service, 'export'); |
|
| 1721 | 1721 | |
| 1722 | 1722 | // Hook capabilities manipulation to allow access to entity type admin |
| 1723 | 1723 | // page on WordPress versions before 4.7. |
| 1724 | 1724 | global $wp_version; |
| 1725 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1726 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1725 | + if (version_compare($wp_version, '4.7', '<')) { |
|
| 1726 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4); |
|
| 1727 | 1727 | } |
| 1728 | 1728 | |
| 1729 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1729 | + $this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1); |
|
| 1730 | 1730 | |
| 1731 | 1731 | /** Adapters. */ |
| 1732 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1732 | + $this->loader->add_filter('mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1); |
|
| 1733 | 1733 | /** |
| 1734 | 1734 | * Disabling Faq temporarily. |
| 1735 | 1735 | * Load the tinymce editor button on the tool bar. |
@@ -1740,58 +1740,58 @@ discard block |
||
| 1740 | 1740 | //$this->loader->add_filter( 'mce_external_plugins', $this->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
| 1741 | 1741 | |
| 1742 | 1742 | |
| 1743 | - $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all' ); |
|
| 1744 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' ); |
|
| 1745 | - $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' ); |
|
| 1743 | + $this->loader->add_action('wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all'); |
|
| 1744 | + $this->loader->add_action('wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create'); |
|
| 1745 | + $this->loader->add_action('wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete'); |
|
| 1746 | 1746 | /** |
| 1747 | 1747 | * @since 3.26.0 |
| 1748 | 1748 | * Post excerpt meta box would be only loaded when the language is set |
| 1749 | 1749 | * to english |
| 1750 | 1750 | */ |
| 1751 | - if ( $this->configuration_service->get_language_code() === 'en' ) { |
|
| 1751 | + if ($this->configuration_service->get_language_code() === 'en') { |
|
| 1752 | 1752 | $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
| 1753 | - $this->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1753 | + $this->loader->add_action('do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box'); |
|
| 1754 | 1754 | // Adding Rest route for the post excerpt |
| 1755 | 1755 | Post_Excerpt_Rest_Controller::register_routes(); |
| 1756 | 1756 | } |
| 1757 | 1757 | |
| 1758 | - $this->loader->add_action( 'update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5 ); |
|
| 1759 | - $this->loader->add_action( 'delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5 ); |
|
| 1758 | + $this->loader->add_action('update_user_metadata', $this->user_service, 'update_user_metadata', 10, 5); |
|
| 1759 | + $this->loader->add_action('delete_user_metadata', $this->user_service, 'delete_user_metadata', 10, 5); |
|
| 1760 | 1760 | |
| 1761 | 1761 | // Handle the autocomplete request. |
| 1762 | - add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1762 | + add_action('wp_ajax_wl_autocomplete', array( |
|
| 1763 | 1763 | $this->autocomplete_adapter, |
| 1764 | 1764 | 'wl_autocomplete', |
| 1765 | - ) ); |
|
| 1766 | - add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1765 | + )); |
|
| 1766 | + add_action('wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1767 | 1767 | $this->autocomplete_adapter, |
| 1768 | 1768 | 'wl_autocomplete', |
| 1769 | - ) ); |
|
| 1769 | + )); |
|
| 1770 | 1770 | |
| 1771 | 1771 | // Hooks to restrict multisite super admin from manipulating entity types. |
| 1772 | - if ( is_multisite() ) { |
|
| 1773 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1772 | + if (is_multisite()) { |
|
| 1773 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4); |
|
| 1774 | 1774 | } |
| 1775 | 1775 | |
| 1776 | - $deactivator_feedback = new Wordlift_Deactivator_Feedback( $this->configuration_service ); |
|
| 1776 | + $deactivator_feedback = new Wordlift_Deactivator_Feedback($this->configuration_service); |
|
| 1777 | 1777 | |
| 1778 | - add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1779 | - add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1780 | - add_action( 'wp_ajax_wl_deactivation_feedback', array( $deactivator_feedback, 'wl_deactivation_feedback' ) ); |
|
| 1778 | + add_action('admin_footer', array($deactivator_feedback, 'render_feedback_popup')); |
|
| 1779 | + add_action('admin_enqueue_scripts', array($deactivator_feedback, 'enqueue_popup_scripts')); |
|
| 1780 | + add_action('wp_ajax_wl_deactivation_feedback', array($deactivator_feedback, 'wl_deactivation_feedback')); |
|
| 1781 | 1781 | |
| 1782 | 1782 | /** |
| 1783 | 1783 | * Always allow the `wordlift/classification` block. |
| 1784 | 1784 | * |
| 1785 | 1785 | * @since 3.23.0 |
| 1786 | 1786 | */ |
| 1787 | - add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1787 | + add_filter('allowed_block_types', function($value) { |
|
| 1788 | 1788 | |
| 1789 | - if ( true === $value ) { |
|
| 1789 | + if (true === $value) { |
|
| 1790 | 1790 | return $value; |
| 1791 | 1791 | } |
| 1792 | 1792 | |
| 1793 | - return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1794 | - }, PHP_INT_MAX ); |
|
| 1793 | + return array_merge((array) $value, array('wordlift/classification')); |
|
| 1794 | + }, PHP_INT_MAX); |
|
| 1795 | 1795 | } |
| 1796 | 1796 | |
| 1797 | 1797 | /** |
@@ -1803,58 +1803,58 @@ discard block |
||
| 1803 | 1803 | */ |
| 1804 | 1804 | private function define_public_hooks() { |
| 1805 | 1805 | |
| 1806 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1806 | + $plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version()); |
|
| 1807 | 1807 | |
| 1808 | 1808 | // Register the entity post type. |
| 1809 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1809 | + $this->loader->add_action('init', $this->entity_post_type_service, 'register'); |
|
| 1810 | 1810 | |
| 1811 | 1811 | // Bind the link generation and handling hooks to the entity link service. |
| 1812 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1813 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1814 | - $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 ); |
|
| 1815 | - $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 ); |
|
| 1812 | + $this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4); |
|
| 1813 | + $this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1); |
|
| 1814 | + $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); |
|
| 1815 | + $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); |
|
| 1816 | 1816 | |
| 1817 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1818 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1819 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts' ); |
|
| 1817 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
| 1818 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
| 1819 | + $this->loader->add_action('wp_enqueue_scripts', $this->context_cards_service, 'enqueue_scripts'); |
|
| 1820 | 1820 | |
| 1821 | 1821 | // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
| 1822 | - $this->loader->add_filter( 'the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1822 | + $this->loader->add_filter('the_content', $this->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags'); |
|
| 1823 | 1823 | // Hook the content filter service to add entity links. |
| 1824 | - if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1825 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1824 | + if ( ! defined('WL_DISABLE_CONTENT_FILTER') || ! WL_DISABLE_CONTENT_FILTER) { |
|
| 1825 | + $this->loader->add_filter('the_content', $this->content_filter_service, 'the_content'); |
|
| 1826 | 1826 | } |
| 1827 | 1827 | |
| 1828 | 1828 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1829 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1829 | + $this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1830 | 1830 | |
| 1831 | 1831 | // Hook the ShareThis service. |
| 1832 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1833 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1832 | + $this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99); |
|
| 1833 | + $this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99); |
|
| 1834 | 1834 | |
| 1835 | 1835 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1836 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1836 | + $this->loader->add_action('wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1837 | 1837 | |
| 1838 | 1838 | // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
| 1839 | 1839 | // in order to tweak WP's `WP_Query` to include entities in queries related |
| 1840 | 1840 | // to categories. |
| 1841 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1841 | + $this->loader->add_action('pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1); |
|
| 1842 | 1842 | |
| 1843 | 1843 | /* |
| 1844 | 1844 | * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service` |
| 1845 | 1845 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1846 | 1846 | * order of start time. |
| 1847 | 1847 | */ |
| 1848 | - $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1848 | + $this->loader->add_action('pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1); |
|
| 1849 | 1849 | |
| 1850 | - $this->loader->add_action( 'wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1850 | + $this->loader->add_action('wl_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1); |
|
| 1851 | 1851 | |
| 1852 | 1852 | // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
| 1853 | - $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1853 | + $this->loader->add_action('save_post', $this->entity_type_adapter, 'save_post', 9, 3); |
|
| 1854 | 1854 | |
| 1855 | 1855 | // Analytics Script Frontend. |
| 1856 | - if ( $this->configuration_service->is_analytics_enable() ) { |
|
| 1857 | - $this->loader->add_action( 'wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 1856 | + if ($this->configuration_service->is_analytics_enable()) { |
|
| 1857 | + $this->loader->add_action('wp_enqueue_scripts', $this->analytics_connect, 'enqueue_scripts', 10); |
|
| 1858 | 1858 | } |
| 1859 | 1859 | |
| 1860 | 1860 | } |
@@ -1907,11 +1907,11 @@ discard block |
||
| 1907 | 1907 | */ |
| 1908 | 1908 | private function load_cli_dependencies() { |
| 1909 | 1909 | |
| 1910 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'cli/class-wordlift-push-reference-data-command.php'; |
|
| 1910 | + require_once plugin_dir_path(dirname(__FILE__)).'cli/class-wordlift-push-reference-data-command.php'; |
|
| 1911 | 1911 | |
| 1912 | - $push_reference_data_command = new Wordlift_Push_Reference_Data_Command( $this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service ); |
|
| 1912 | + $push_reference_data_command = new Wordlift_Push_Reference_Data_Command($this->relation_service, $this->entity_service, $this->sparql_service, $this->configuration_service, $this->entity_type_service); |
|
| 1913 | 1913 | |
| 1914 | - WP_CLI::add_command( 'wl references push', $push_reference_data_command ); |
|
| 1914 | + WP_CLI::add_command('wl references push', $push_reference_data_command); |
|
| 1915 | 1915 | |
| 1916 | 1916 | } |
| 1917 | 1917 | |
@@ -18,336 +18,336 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Linked_Data_Service { |
| 20 | 20 | |
| 21 | - //<editor-fold desc="## FIELDS"> |
|
| 22 | - /** |
|
| 23 | - * A {@link Wordlift_Log_Service} instance. |
|
| 24 | - * |
|
| 25 | - * @since 3.15.0 |
|
| 26 | - * @access private |
|
| 27 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 28 | - */ |
|
| 29 | - private $log; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * The {@link Wordlift_Entity_Service} instance. |
|
| 33 | - * |
|
| 34 | - * @since 3.15.0 |
|
| 35 | - * @access private |
|
| 36 | - * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 37 | - */ |
|
| 38 | - private $entity_service; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * The {@link Wordlift_Entity_Type_Service} instance. |
|
| 42 | - * |
|
| 43 | - * @since 3.15.0 |
|
| 44 | - * @access private |
|
| 45 | - * @var \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance. |
|
| 46 | - */ |
|
| 47 | - private $entity_type_service; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * The {@link Wordlift_Schema_Service} instance. |
|
| 51 | - * |
|
| 52 | - * @since 3.15.0 |
|
| 53 | - * @access private |
|
| 54 | - * @var \Wordlift_Schema_Service $schema_service The {@link Wordlift_Schema_Service} instance. |
|
| 55 | - */ |
|
| 56 | - private $schema_service; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * The {@link Wordlift_Sparql_Service} instance. |
|
| 60 | - * |
|
| 61 | - * @since 3.15.0 |
|
| 62 | - * @access private |
|
| 63 | - * @var \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance. |
|
| 64 | - */ |
|
| 65 | - private $sparql_service; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * The {@link Wordlift_Linked_Data_Service} singleton instance. |
|
| 69 | - * |
|
| 70 | - * @since 3.15.0 |
|
| 71 | - * @access private |
|
| 72 | - * @var \Wordlift_Linked_Data_Service $instance The {@link Wordlift_Linked_Data_Service} singleton instance. |
|
| 73 | - */ |
|
| 74 | - private static $instance; |
|
| 75 | - //</editor-fold> |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Create a {@link Wordlift_Linked_Data_Service} instance. |
|
| 79 | - * |
|
| 80 | - * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 81 | - * @param \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance. |
|
| 82 | - * @param \Wordlift_Schema_Service $schema_service The {@link Wordlift_Schema_Service} instance. |
|
| 83 | - * @param \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance. |
|
| 84 | - * |
|
| 85 | - * @since 3.15.0 |
|
| 86 | - * |
|
| 87 | - */ |
|
| 88 | - public function __construct( $entity_service, $entity_type_service, $schema_service, $sparql_service ) { |
|
| 89 | - |
|
| 90 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Linked_Data_Service' ); |
|
| 91 | - |
|
| 92 | - $this->entity_service = $entity_service; |
|
| 93 | - $this->entity_type_service = $entity_type_service; |
|
| 94 | - $this->schema_service = $schema_service; |
|
| 95 | - $this->sparql_service = $sparql_service; |
|
| 96 | - |
|
| 97 | - /* |
|
| 21 | + //<editor-fold desc="## FIELDS"> |
|
| 22 | + /** |
|
| 23 | + * A {@link Wordlift_Log_Service} instance. |
|
| 24 | + * |
|
| 25 | + * @since 3.15.0 |
|
| 26 | + * @access private |
|
| 27 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 28 | + */ |
|
| 29 | + private $log; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * The {@link Wordlift_Entity_Service} instance. |
|
| 33 | + * |
|
| 34 | + * @since 3.15.0 |
|
| 35 | + * @access private |
|
| 36 | + * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 37 | + */ |
|
| 38 | + private $entity_service; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * The {@link Wordlift_Entity_Type_Service} instance. |
|
| 42 | + * |
|
| 43 | + * @since 3.15.0 |
|
| 44 | + * @access private |
|
| 45 | + * @var \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance. |
|
| 46 | + */ |
|
| 47 | + private $entity_type_service; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * The {@link Wordlift_Schema_Service} instance. |
|
| 51 | + * |
|
| 52 | + * @since 3.15.0 |
|
| 53 | + * @access private |
|
| 54 | + * @var \Wordlift_Schema_Service $schema_service The {@link Wordlift_Schema_Service} instance. |
|
| 55 | + */ |
|
| 56 | + private $schema_service; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * The {@link Wordlift_Sparql_Service} instance. |
|
| 60 | + * |
|
| 61 | + * @since 3.15.0 |
|
| 62 | + * @access private |
|
| 63 | + * @var \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance. |
|
| 64 | + */ |
|
| 65 | + private $sparql_service; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * The {@link Wordlift_Linked_Data_Service} singleton instance. |
|
| 69 | + * |
|
| 70 | + * @since 3.15.0 |
|
| 71 | + * @access private |
|
| 72 | + * @var \Wordlift_Linked_Data_Service $instance The {@link Wordlift_Linked_Data_Service} singleton instance. |
|
| 73 | + */ |
|
| 74 | + private static $instance; |
|
| 75 | + //</editor-fold> |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Create a {@link Wordlift_Linked_Data_Service} instance. |
|
| 79 | + * |
|
| 80 | + * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 81 | + * @param \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance. |
|
| 82 | + * @param \Wordlift_Schema_Service $schema_service The {@link Wordlift_Schema_Service} instance. |
|
| 83 | + * @param \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance. |
|
| 84 | + * |
|
| 85 | + * @since 3.15.0 |
|
| 86 | + * |
|
| 87 | + */ |
|
| 88 | + public function __construct( $entity_service, $entity_type_service, $schema_service, $sparql_service ) { |
|
| 89 | + |
|
| 90 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Linked_Data_Service' ); |
|
| 91 | + |
|
| 92 | + $this->entity_service = $entity_service; |
|
| 93 | + $this->entity_type_service = $entity_type_service; |
|
| 94 | + $this->schema_service = $schema_service; |
|
| 95 | + $this->sparql_service = $sparql_service; |
|
| 96 | + |
|
| 97 | + /* |
|
| 98 | 98 | * Allow callers to call the `push` and `remove` methods using WordPress' hooks. |
| 99 | 99 | * |
| 100 | 100 | * @since 3.28.0 |
| 101 | 101 | */ |
| 102 | - add_action( 'wl_legacy_linked_data__push', array( $this, 'push' ) ); |
|
| 103 | - add_action( 'wl_legacy_linked_data__remove', array( $this, 'remove' ) ); |
|
| 104 | - |
|
| 105 | - self::$instance = $this; |
|
| 106 | - |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Get the singleton instance of {@link Wordlift_Linked_Data_Service}. |
|
| 111 | - * |
|
| 112 | - * @return Wordlift_Linked_Data_Service The singleton instance of <a href='psi_element://Wordlift_Linked_Data_Service'>Wordlift_Linked_Data_Service</a>. |
|
| 113 | - * @since 3.15.0 |
|
| 114 | - * |
|
| 115 | - */ |
|
| 116 | - public static function get_instance() { |
|
| 117 | - |
|
| 118 | - return self::$instance; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - //<editor-fold desc="## FUNCTIONS"> |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Push a {@link WP_Post} to the Linked Data store. |
|
| 125 | - * |
|
| 126 | - * If the {@link WP_Post} is an entity and it's not of the `Article` type, |
|
| 127 | - * then it is pushed to the remote Linked Data store. |
|
| 128 | - * |
|
| 129 | - * @param int $post_id The {@link WP_Post}'s id. |
|
| 130 | - * |
|
| 131 | - * @since 3.15.0 |
|
| 132 | - * |
|
| 133 | - */ |
|
| 134 | - public function push( $post_id ) { |
|
| 135 | - |
|
| 136 | - $this->log->debug( "Pushing post $post_id..." ); |
|
| 137 | - |
|
| 138 | - // @since 3.18.0 we don't check anymore if the post is an entity, i.e. |
|
| 139 | - // we removed the following: |
|
| 140 | - // if ( ! $this->entity_service->is_entity( $post_id ) ) { |
|
| 141 | - // $this->log->debug( "Post $post_id is not an entity." ); |
|
| 142 | - // |
|
| 143 | - // return; |
|
| 144 | - // } |
|
| 145 | - |
|
| 146 | - // Get the post and push it to the Linked Data store. |
|
| 147 | - $this->do_push( $post_id ); |
|
| 148 | - |
|
| 149 | - // Reindex the triple store if buffering is turned off. |
|
| 150 | - if ( false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) { |
|
| 151 | - wordlift_reindex_triple_store(); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Push an entity to the Linked Data store. |
|
| 158 | - * |
|
| 159 | - * @param int $post_id The {@link WP_Post}'s id. |
|
| 160 | - * |
|
| 161 | - * @since 3.15.0 |
|
| 162 | - * |
|
| 163 | - */ |
|
| 164 | - private function do_push( $post_id ) { |
|
| 165 | - $this->log->debug( "Doing post $post_id push..." ); |
|
| 166 | - |
|
| 167 | - // Get the post. |
|
| 168 | - $post = get_post( $post_id ); |
|
| 169 | - |
|
| 170 | - // Bail out if the post isn't found. |
|
| 171 | - if ( null === $post ) { |
|
| 172 | - $this->log->warn( "Post $post_id not found." ); |
|
| 173 | - |
|
| 174 | - return; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - // Bail out if the post isn't published. |
|
| 178 | - if ( 'publish' !== $post->post_status ) { |
|
| 179 | - $this->log->info( "Post $post_id not published." ); |
|
| 180 | - |
|
| 181 | - return; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - // Bail out if the URI isn't valid. |
|
| 185 | - if ( ! $this->has_valid_uri( $post_id ) ) { |
|
| 186 | - $this->log->warn( "Post $post_id URI invalid." ); |
|
| 187 | - |
|
| 188 | - return; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - // First remove the post data. |
|
| 192 | - $this->remove( $post_id ); |
|
| 193 | - |
|
| 194 | - // Then execute the insert query. |
|
| 195 | - $this->insert( $post_id ); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * Check if an entity's {@link WP_Post} has a valid URI. |
|
| 200 | - * |
|
| 201 | - * @param int $post_id The entity's {@link WP_Post}'s id. |
|
| 202 | - * |
|
| 203 | - * @return bool True if the URI is valid otherwise false. |
|
| 204 | - * @since 3.15.0 |
|
| 205 | - * |
|
| 206 | - */ |
|
| 207 | - private function has_valid_uri( $post_id ) { |
|
| 208 | - |
|
| 209 | - // Get the entity's URI. |
|
| 210 | - $uri = $this->entity_service->get_uri( $post_id ); |
|
| 211 | - |
|
| 212 | - // If the URI isn't found, return false. |
|
| 213 | - if ( null === $uri ) { |
|
| 214 | - return false; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - // If the URI ends with a trailing slash, return false. |
|
| 218 | - if ( '/' === substr( $uri, - 1 ) ) { |
|
| 219 | - return false; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - // URI is valid. |
|
| 223 | - return true; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Remove the specified {@link WP_Post} from the Linked Data. |
|
| 228 | - * |
|
| 229 | - * @param int $post_id The {@link WP_Post}'s id. |
|
| 230 | - * |
|
| 231 | - * @since 3.18.0 |
|
| 232 | - * |
|
| 233 | - */ |
|
| 234 | - public function remove( $post_id ) { |
|
| 235 | - $delete_query = ''; |
|
| 236 | - |
|
| 237 | - // Get the delete statements. |
|
| 238 | - $triples = $this->get_delete_triples( $post_id ); |
|
| 239 | - |
|
| 240 | - // Loop through all triples and add the statement to delete query. |
|
| 241 | - foreach ( $triples as $item ) { |
|
| 242 | - $delete_query .= "DELETE { $item } WHERE { $item }; \n"; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - $this->log->trace( "Delete Query generated [ $delete_query ]." ); |
|
| 246 | - |
|
| 247 | - $this->sparql_service->execute( $delete_query ); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * Insert the specific {@link WP_Post} to Linked Data store. |
|
| 252 | - * |
|
| 253 | - * @param int $post_id The {@link WP_Post}'s id. |
|
| 254 | - * |
|
| 255 | - * @since 3.18.0 |
|
| 256 | - * |
|
| 257 | - */ |
|
| 258 | - private function insert( $post_id ) { |
|
| 259 | - // Get the insert statements. |
|
| 260 | - $insert_triples = $this->get_insert_triples( $post_id ); |
|
| 261 | - |
|
| 262 | - // Convert all statements to single string. |
|
| 263 | - $insert_query_body = implode( "\n", $insert_triples ); |
|
| 264 | - |
|
| 265 | - // Build the insert query. |
|
| 266 | - $insert_query = "INSERT DATA { $insert_query_body };"; |
|
| 267 | - |
|
| 268 | - $this->log->trace( "Insert Query generated [ $insert_query ]." ); |
|
| 269 | - |
|
| 270 | - $this->sparql_service->execute( $insert_query ); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * Get the delete statements. |
|
| 275 | - * |
|
| 276 | - * @param int $post_id The {@link WP_Post}'s id. |
|
| 277 | - * |
|
| 278 | - * @return array An array of delete statements. |
|
| 279 | - * @since 3.18.0 |
|
| 280 | - * |
|
| 281 | - */ |
|
| 282 | - private function get_delete_triples( $post_id ) { |
|
| 283 | - $delete_triples = array(); |
|
| 284 | - |
|
| 285 | - // Loop through all renditions and get the triples. |
|
| 286 | - foreach ( $this->schema_service->get_renditions() as $rendition ) { |
|
| 287 | - // Push the rendition delete triple to $delete_triples. |
|
| 288 | - $delete_triples = array_merge( |
|
| 289 | - $delete_triples, |
|
| 290 | - (array) $rendition->get_delete_triples( $post_id ) |
|
| 291 | - ); |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * Filter: 'wl_delete_triples' - Allow third parties to hook and add additional delete triples. |
|
| 296 | - * |
|
| 297 | - * @param array $delete_triples Delete triples. |
|
| 298 | - * @param int $post_id The current post ID. |
|
| 299 | - * |
|
| 300 | - * @since 3.18.0 |
|
| 301 | - * |
|
| 302 | - */ |
|
| 303 | - return apply_filters( 'wl_delete_triples', array_unique( $delete_triples ), $post_id ); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * Get the SPARQL insert triples ( ?s ?p ?o ) for the specified {@link WP_Post}. |
|
| 308 | - * |
|
| 309 | - * @param int $post_id The {@link WP_Post}'s id. |
|
| 310 | - * |
|
| 311 | - * @return array An array of insert triples. |
|
| 312 | - * @since 3.15.0 |
|
| 313 | - * |
|
| 314 | - */ |
|
| 315 | - private function get_insert_triples( $post_id ) { |
|
| 316 | - |
|
| 317 | - // Get the entity type. |
|
| 318 | - $type = $this->entity_type_service->get( $post_id ); |
|
| 319 | - |
|
| 320 | - // Get the `linked_data` parameter. |
|
| 321 | - $properties = $type['linked_data']; |
|
| 322 | - |
|
| 323 | - // Accumulate the triples. |
|
| 324 | - $triples = array(); |
|
| 325 | - |
|
| 326 | - /** @var Wordlift_Default_Sparql_Tuple_Rendition $property A {@link Wordlift_Sparql_Tuple_Rendition} instance. */ |
|
| 327 | - foreach ( $properties as $property ) { |
|
| 328 | - foreach ( $property->get_insert_triples( $post_id ) as $triple ) { |
|
| 329 | - $triples[] = $triple; |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - $this->log->trace( count( $properties ) . ' properties and ' . count( $triples ) . " triples found for post $post_id." ); |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * Get the INSERT triples properties. |
|
| 337 | - * |
|
| 338 | - * The `wl_insert_triples` filter allows 3rd parties to extend |
|
| 339 | - * the list of triples for SPARQL INSERT statements. |
|
| 340 | - * |
|
| 341 | - * @param array $linked_data A {@link Wordlift_Sparql_Tuple_Rendition} instances. |
|
| 342 | - * @param \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance. |
|
| 343 | - * @param int $post_id The {@link WP_Post}'s id. |
|
| 344 | - * |
|
| 345 | - * @since 3.18.0 The hook has been renamed from `wl_insert_tuples_properties` to `wl_insert_triples`. |
|
| 346 | - * |
|
| 347 | - * @since 3.17.0 |
|
| 348 | - */ |
|
| 349 | - return apply_filters( 'wl_insert_triples', $triples, $this->entity_service, $post_id ); |
|
| 350 | - } |
|
| 351 | - //</editor-fold> |
|
| 102 | + add_action( 'wl_legacy_linked_data__push', array( $this, 'push' ) ); |
|
| 103 | + add_action( 'wl_legacy_linked_data__remove', array( $this, 'remove' ) ); |
|
| 104 | + |
|
| 105 | + self::$instance = $this; |
|
| 106 | + |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Get the singleton instance of {@link Wordlift_Linked_Data_Service}. |
|
| 111 | + * |
|
| 112 | + * @return Wordlift_Linked_Data_Service The singleton instance of <a href='psi_element://Wordlift_Linked_Data_Service'>Wordlift_Linked_Data_Service</a>. |
|
| 113 | + * @since 3.15.0 |
|
| 114 | + * |
|
| 115 | + */ |
|
| 116 | + public static function get_instance() { |
|
| 117 | + |
|
| 118 | + return self::$instance; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + //<editor-fold desc="## FUNCTIONS"> |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Push a {@link WP_Post} to the Linked Data store. |
|
| 125 | + * |
|
| 126 | + * If the {@link WP_Post} is an entity and it's not of the `Article` type, |
|
| 127 | + * then it is pushed to the remote Linked Data store. |
|
| 128 | + * |
|
| 129 | + * @param int $post_id The {@link WP_Post}'s id. |
|
| 130 | + * |
|
| 131 | + * @since 3.15.0 |
|
| 132 | + * |
|
| 133 | + */ |
|
| 134 | + public function push( $post_id ) { |
|
| 135 | + |
|
| 136 | + $this->log->debug( "Pushing post $post_id..." ); |
|
| 137 | + |
|
| 138 | + // @since 3.18.0 we don't check anymore if the post is an entity, i.e. |
|
| 139 | + // we removed the following: |
|
| 140 | + // if ( ! $this->entity_service->is_entity( $post_id ) ) { |
|
| 141 | + // $this->log->debug( "Post $post_id is not an entity." ); |
|
| 142 | + // |
|
| 143 | + // return; |
|
| 144 | + // } |
|
| 145 | + |
|
| 146 | + // Get the post and push it to the Linked Data store. |
|
| 147 | + $this->do_push( $post_id ); |
|
| 148 | + |
|
| 149 | + // Reindex the triple store if buffering is turned off. |
|
| 150 | + if ( false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) { |
|
| 151 | + wordlift_reindex_triple_store(); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Push an entity to the Linked Data store. |
|
| 158 | + * |
|
| 159 | + * @param int $post_id The {@link WP_Post}'s id. |
|
| 160 | + * |
|
| 161 | + * @since 3.15.0 |
|
| 162 | + * |
|
| 163 | + */ |
|
| 164 | + private function do_push( $post_id ) { |
|
| 165 | + $this->log->debug( "Doing post $post_id push..." ); |
|
| 166 | + |
|
| 167 | + // Get the post. |
|
| 168 | + $post = get_post( $post_id ); |
|
| 169 | + |
|
| 170 | + // Bail out if the post isn't found. |
|
| 171 | + if ( null === $post ) { |
|
| 172 | + $this->log->warn( "Post $post_id not found." ); |
|
| 173 | + |
|
| 174 | + return; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + // Bail out if the post isn't published. |
|
| 178 | + if ( 'publish' !== $post->post_status ) { |
|
| 179 | + $this->log->info( "Post $post_id not published." ); |
|
| 180 | + |
|
| 181 | + return; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + // Bail out if the URI isn't valid. |
|
| 185 | + if ( ! $this->has_valid_uri( $post_id ) ) { |
|
| 186 | + $this->log->warn( "Post $post_id URI invalid." ); |
|
| 187 | + |
|
| 188 | + return; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + // First remove the post data. |
|
| 192 | + $this->remove( $post_id ); |
|
| 193 | + |
|
| 194 | + // Then execute the insert query. |
|
| 195 | + $this->insert( $post_id ); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * Check if an entity's {@link WP_Post} has a valid URI. |
|
| 200 | + * |
|
| 201 | + * @param int $post_id The entity's {@link WP_Post}'s id. |
|
| 202 | + * |
|
| 203 | + * @return bool True if the URI is valid otherwise false. |
|
| 204 | + * @since 3.15.0 |
|
| 205 | + * |
|
| 206 | + */ |
|
| 207 | + private function has_valid_uri( $post_id ) { |
|
| 208 | + |
|
| 209 | + // Get the entity's URI. |
|
| 210 | + $uri = $this->entity_service->get_uri( $post_id ); |
|
| 211 | + |
|
| 212 | + // If the URI isn't found, return false. |
|
| 213 | + if ( null === $uri ) { |
|
| 214 | + return false; |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + // If the URI ends with a trailing slash, return false. |
|
| 218 | + if ( '/' === substr( $uri, - 1 ) ) { |
|
| 219 | + return false; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + // URI is valid. |
|
| 223 | + return true; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Remove the specified {@link WP_Post} from the Linked Data. |
|
| 228 | + * |
|
| 229 | + * @param int $post_id The {@link WP_Post}'s id. |
|
| 230 | + * |
|
| 231 | + * @since 3.18.0 |
|
| 232 | + * |
|
| 233 | + */ |
|
| 234 | + public function remove( $post_id ) { |
|
| 235 | + $delete_query = ''; |
|
| 236 | + |
|
| 237 | + // Get the delete statements. |
|
| 238 | + $triples = $this->get_delete_triples( $post_id ); |
|
| 239 | + |
|
| 240 | + // Loop through all triples and add the statement to delete query. |
|
| 241 | + foreach ( $triples as $item ) { |
|
| 242 | + $delete_query .= "DELETE { $item } WHERE { $item }; \n"; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + $this->log->trace( "Delete Query generated [ $delete_query ]." ); |
|
| 246 | + |
|
| 247 | + $this->sparql_service->execute( $delete_query ); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * Insert the specific {@link WP_Post} to Linked Data store. |
|
| 252 | + * |
|
| 253 | + * @param int $post_id The {@link WP_Post}'s id. |
|
| 254 | + * |
|
| 255 | + * @since 3.18.0 |
|
| 256 | + * |
|
| 257 | + */ |
|
| 258 | + private function insert( $post_id ) { |
|
| 259 | + // Get the insert statements. |
|
| 260 | + $insert_triples = $this->get_insert_triples( $post_id ); |
|
| 261 | + |
|
| 262 | + // Convert all statements to single string. |
|
| 263 | + $insert_query_body = implode( "\n", $insert_triples ); |
|
| 264 | + |
|
| 265 | + // Build the insert query. |
|
| 266 | + $insert_query = "INSERT DATA { $insert_query_body };"; |
|
| 267 | + |
|
| 268 | + $this->log->trace( "Insert Query generated [ $insert_query ]." ); |
|
| 269 | + |
|
| 270 | + $this->sparql_service->execute( $insert_query ); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * Get the delete statements. |
|
| 275 | + * |
|
| 276 | + * @param int $post_id The {@link WP_Post}'s id. |
|
| 277 | + * |
|
| 278 | + * @return array An array of delete statements. |
|
| 279 | + * @since 3.18.0 |
|
| 280 | + * |
|
| 281 | + */ |
|
| 282 | + private function get_delete_triples( $post_id ) { |
|
| 283 | + $delete_triples = array(); |
|
| 284 | + |
|
| 285 | + // Loop through all renditions and get the triples. |
|
| 286 | + foreach ( $this->schema_service->get_renditions() as $rendition ) { |
|
| 287 | + // Push the rendition delete triple to $delete_triples. |
|
| 288 | + $delete_triples = array_merge( |
|
| 289 | + $delete_triples, |
|
| 290 | + (array) $rendition->get_delete_triples( $post_id ) |
|
| 291 | + ); |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * Filter: 'wl_delete_triples' - Allow third parties to hook and add additional delete triples. |
|
| 296 | + * |
|
| 297 | + * @param array $delete_triples Delete triples. |
|
| 298 | + * @param int $post_id The current post ID. |
|
| 299 | + * |
|
| 300 | + * @since 3.18.0 |
|
| 301 | + * |
|
| 302 | + */ |
|
| 303 | + return apply_filters( 'wl_delete_triples', array_unique( $delete_triples ), $post_id ); |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * Get the SPARQL insert triples ( ?s ?p ?o ) for the specified {@link WP_Post}. |
|
| 308 | + * |
|
| 309 | + * @param int $post_id The {@link WP_Post}'s id. |
|
| 310 | + * |
|
| 311 | + * @return array An array of insert triples. |
|
| 312 | + * @since 3.15.0 |
|
| 313 | + * |
|
| 314 | + */ |
|
| 315 | + private function get_insert_triples( $post_id ) { |
|
| 316 | + |
|
| 317 | + // Get the entity type. |
|
| 318 | + $type = $this->entity_type_service->get( $post_id ); |
|
| 319 | + |
|
| 320 | + // Get the `linked_data` parameter. |
|
| 321 | + $properties = $type['linked_data']; |
|
| 322 | + |
|
| 323 | + // Accumulate the triples. |
|
| 324 | + $triples = array(); |
|
| 325 | + |
|
| 326 | + /** @var Wordlift_Default_Sparql_Tuple_Rendition $property A {@link Wordlift_Sparql_Tuple_Rendition} instance. */ |
|
| 327 | + foreach ( $properties as $property ) { |
|
| 328 | + foreach ( $property->get_insert_triples( $post_id ) as $triple ) { |
|
| 329 | + $triples[] = $triple; |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + $this->log->trace( count( $properties ) . ' properties and ' . count( $triples ) . " triples found for post $post_id." ); |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * Get the INSERT triples properties. |
|
| 337 | + * |
|
| 338 | + * The `wl_insert_triples` filter allows 3rd parties to extend |
|
| 339 | + * the list of triples for SPARQL INSERT statements. |
|
| 340 | + * |
|
| 341 | + * @param array $linked_data A {@link Wordlift_Sparql_Tuple_Rendition} instances. |
|
| 342 | + * @param \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance. |
|
| 343 | + * @param int $post_id The {@link WP_Post}'s id. |
|
| 344 | + * |
|
| 345 | + * @since 3.18.0 The hook has been renamed from `wl_insert_tuples_properties` to `wl_insert_triples`. |
|
| 346 | + * |
|
| 347 | + * @since 3.17.0 |
|
| 348 | + */ |
|
| 349 | + return apply_filters( 'wl_insert_triples', $triples, $this->entity_service, $post_id ); |
|
| 350 | + } |
|
| 351 | + //</editor-fold> |
|
| 352 | 352 | |
| 353 | 353 | } |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | * @since 3.15.0 |
| 86 | 86 | * |
| 87 | 87 | */ |
| 88 | - public function __construct( $entity_service, $entity_type_service, $schema_service, $sparql_service ) { |
|
| 88 | + public function __construct($entity_service, $entity_type_service, $schema_service, $sparql_service) { |
|
| 89 | 89 | |
| 90 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Linked_Data_Service' ); |
|
| 90 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Linked_Data_Service'); |
|
| 91 | 91 | |
| 92 | 92 | $this->entity_service = $entity_service; |
| 93 | 93 | $this->entity_type_service = $entity_type_service; |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @since 3.28.0 |
| 101 | 101 | */ |
| 102 | - add_action( 'wl_legacy_linked_data__push', array( $this, 'push' ) ); |
|
| 103 | - add_action( 'wl_legacy_linked_data__remove', array( $this, 'remove' ) ); |
|
| 102 | + add_action('wl_legacy_linked_data__push', array($this, 'push')); |
|
| 103 | + add_action('wl_legacy_linked_data__remove', array($this, 'remove')); |
|
| 104 | 104 | |
| 105 | 105 | self::$instance = $this; |
| 106 | 106 | |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | * @since 3.15.0 |
| 132 | 132 | * |
| 133 | 133 | */ |
| 134 | - public function push( $post_id ) { |
|
| 134 | + public function push($post_id) { |
|
| 135 | 135 | |
| 136 | - $this->log->debug( "Pushing post $post_id..." ); |
|
| 136 | + $this->log->debug("Pushing post $post_id..."); |
|
| 137 | 137 | |
| 138 | 138 | // @since 3.18.0 we don't check anymore if the post is an entity, i.e. |
| 139 | 139 | // we removed the following: |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | // } |
| 145 | 145 | |
| 146 | 146 | // Get the post and push it to the Linked Data store. |
| 147 | - $this->do_push( $post_id ); |
|
| 147 | + $this->do_push($post_id); |
|
| 148 | 148 | |
| 149 | 149 | // Reindex the triple store if buffering is turned off. |
| 150 | - if ( false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) { |
|
| 150 | + if (false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING) { |
|
| 151 | 151 | wordlift_reindex_triple_store(); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -161,38 +161,38 @@ discard block |
||
| 161 | 161 | * @since 3.15.0 |
| 162 | 162 | * |
| 163 | 163 | */ |
| 164 | - private function do_push( $post_id ) { |
|
| 165 | - $this->log->debug( "Doing post $post_id push..." ); |
|
| 164 | + private function do_push($post_id) { |
|
| 165 | + $this->log->debug("Doing post $post_id push..."); |
|
| 166 | 166 | |
| 167 | 167 | // Get the post. |
| 168 | - $post = get_post( $post_id ); |
|
| 168 | + $post = get_post($post_id); |
|
| 169 | 169 | |
| 170 | 170 | // Bail out if the post isn't found. |
| 171 | - if ( null === $post ) { |
|
| 172 | - $this->log->warn( "Post $post_id not found." ); |
|
| 171 | + if (null === $post) { |
|
| 172 | + $this->log->warn("Post $post_id not found."); |
|
| 173 | 173 | |
| 174 | 174 | return; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // Bail out if the post isn't published. |
| 178 | - if ( 'publish' !== $post->post_status ) { |
|
| 179 | - $this->log->info( "Post $post_id not published." ); |
|
| 178 | + if ('publish' !== $post->post_status) { |
|
| 179 | + $this->log->info("Post $post_id not published."); |
|
| 180 | 180 | |
| 181 | 181 | return; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // Bail out if the URI isn't valid. |
| 185 | - if ( ! $this->has_valid_uri( $post_id ) ) { |
|
| 186 | - $this->log->warn( "Post $post_id URI invalid." ); |
|
| 185 | + if ( ! $this->has_valid_uri($post_id)) { |
|
| 186 | + $this->log->warn("Post $post_id URI invalid."); |
|
| 187 | 187 | |
| 188 | 188 | return; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | // First remove the post data. |
| 192 | - $this->remove( $post_id ); |
|
| 192 | + $this->remove($post_id); |
|
| 193 | 193 | |
| 194 | 194 | // Then execute the insert query. |
| 195 | - $this->insert( $post_id ); |
|
| 195 | + $this->insert($post_id); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -204,18 +204,18 @@ discard block |
||
| 204 | 204 | * @since 3.15.0 |
| 205 | 205 | * |
| 206 | 206 | */ |
| 207 | - private function has_valid_uri( $post_id ) { |
|
| 207 | + private function has_valid_uri($post_id) { |
|
| 208 | 208 | |
| 209 | 209 | // Get the entity's URI. |
| 210 | - $uri = $this->entity_service->get_uri( $post_id ); |
|
| 210 | + $uri = $this->entity_service->get_uri($post_id); |
|
| 211 | 211 | |
| 212 | 212 | // If the URI isn't found, return false. |
| 213 | - if ( null === $uri ) { |
|
| 213 | + if (null === $uri) { |
|
| 214 | 214 | return false; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // If the URI ends with a trailing slash, return false. |
| 218 | - if ( '/' === substr( $uri, - 1 ) ) { |
|
| 218 | + if ('/' === substr($uri, - 1)) { |
|
| 219 | 219 | return false; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -231,20 +231,20 @@ discard block |
||
| 231 | 231 | * @since 3.18.0 |
| 232 | 232 | * |
| 233 | 233 | */ |
| 234 | - public function remove( $post_id ) { |
|
| 234 | + public function remove($post_id) { |
|
| 235 | 235 | $delete_query = ''; |
| 236 | 236 | |
| 237 | 237 | // Get the delete statements. |
| 238 | - $triples = $this->get_delete_triples( $post_id ); |
|
| 238 | + $triples = $this->get_delete_triples($post_id); |
|
| 239 | 239 | |
| 240 | 240 | // Loop through all triples and add the statement to delete query. |
| 241 | - foreach ( $triples as $item ) { |
|
| 241 | + foreach ($triples as $item) { |
|
| 242 | 242 | $delete_query .= "DELETE { $item } WHERE { $item }; \n"; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - $this->log->trace( "Delete Query generated [ $delete_query ]." ); |
|
| 245 | + $this->log->trace("Delete Query generated [ $delete_query ]."); |
|
| 246 | 246 | |
| 247 | - $this->sparql_service->execute( $delete_query ); |
|
| 247 | + $this->sparql_service->execute($delete_query); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -255,19 +255,19 @@ discard block |
||
| 255 | 255 | * @since 3.18.0 |
| 256 | 256 | * |
| 257 | 257 | */ |
| 258 | - private function insert( $post_id ) { |
|
| 258 | + private function insert($post_id) { |
|
| 259 | 259 | // Get the insert statements. |
| 260 | - $insert_triples = $this->get_insert_triples( $post_id ); |
|
| 260 | + $insert_triples = $this->get_insert_triples($post_id); |
|
| 261 | 261 | |
| 262 | 262 | // Convert all statements to single string. |
| 263 | - $insert_query_body = implode( "\n", $insert_triples ); |
|
| 263 | + $insert_query_body = implode("\n", $insert_triples); |
|
| 264 | 264 | |
| 265 | 265 | // Build the insert query. |
| 266 | 266 | $insert_query = "INSERT DATA { $insert_query_body };"; |
| 267 | 267 | |
| 268 | - $this->log->trace( "Insert Query generated [ $insert_query ]." ); |
|
| 268 | + $this->log->trace("Insert Query generated [ $insert_query ]."); |
|
| 269 | 269 | |
| 270 | - $this->sparql_service->execute( $insert_query ); |
|
| 270 | + $this->sparql_service->execute($insert_query); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -279,15 +279,15 @@ discard block |
||
| 279 | 279 | * @since 3.18.0 |
| 280 | 280 | * |
| 281 | 281 | */ |
| 282 | - private function get_delete_triples( $post_id ) { |
|
| 282 | + private function get_delete_triples($post_id) { |
|
| 283 | 283 | $delete_triples = array(); |
| 284 | 284 | |
| 285 | 285 | // Loop through all renditions and get the triples. |
| 286 | - foreach ( $this->schema_service->get_renditions() as $rendition ) { |
|
| 286 | + foreach ($this->schema_service->get_renditions() as $rendition) { |
|
| 287 | 287 | // Push the rendition delete triple to $delete_triples. |
| 288 | 288 | $delete_triples = array_merge( |
| 289 | 289 | $delete_triples, |
| 290 | - (array) $rendition->get_delete_triples( $post_id ) |
|
| 290 | + (array) $rendition->get_delete_triples($post_id) |
|
| 291 | 291 | ); |
| 292 | 292 | } |
| 293 | 293 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * @since 3.18.0 |
| 301 | 301 | * |
| 302 | 302 | */ |
| 303 | - return apply_filters( 'wl_delete_triples', array_unique( $delete_triples ), $post_id ); |
|
| 303 | + return apply_filters('wl_delete_triples', array_unique($delete_triples), $post_id); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | * @since 3.15.0 |
| 313 | 313 | * |
| 314 | 314 | */ |
| 315 | - private function get_insert_triples( $post_id ) { |
|
| 315 | + private function get_insert_triples($post_id) { |
|
| 316 | 316 | |
| 317 | 317 | // Get the entity type. |
| 318 | - $type = $this->entity_type_service->get( $post_id ); |
|
| 318 | + $type = $this->entity_type_service->get($post_id); |
|
| 319 | 319 | |
| 320 | 320 | // Get the `linked_data` parameter. |
| 321 | 321 | $properties = $type['linked_data']; |
@@ -324,13 +324,13 @@ discard block |
||
| 324 | 324 | $triples = array(); |
| 325 | 325 | |
| 326 | 326 | /** @var Wordlift_Default_Sparql_Tuple_Rendition $property A {@link Wordlift_Sparql_Tuple_Rendition} instance. */ |
| 327 | - foreach ( $properties as $property ) { |
|
| 328 | - foreach ( $property->get_insert_triples( $post_id ) as $triple ) { |
|
| 327 | + foreach ($properties as $property) { |
|
| 328 | + foreach ($property->get_insert_triples($post_id) as $triple) { |
|
| 329 | 329 | $triples[] = $triple; |
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - $this->log->trace( count( $properties ) . ' properties and ' . count( $triples ) . " triples found for post $post_id." ); |
|
| 333 | + $this->log->trace(count($properties).' properties and '.count($triples)." triples found for post $post_id."); |
|
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * Get the INSERT triples properties. |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * |
| 347 | 347 | * @since 3.17.0 |
| 348 | 348 | */ |
| 349 | - return apply_filters( 'wl_insert_triples', $triples, $this->entity_service, $post_id ); |
|
| 349 | + return apply_filters('wl_insert_triples', $triples, $this->entity_service, $post_id); |
|
| 350 | 350 | } |
| 351 | 351 | //</editor-fold> |
| 352 | 352 | |
@@ -15,114 +15,114 @@ |
||
| 15 | 15 | * @subpackage Wordlift/install |
| 16 | 16 | */ |
| 17 | 17 | class Wordlift_Install_3_18_0 extends Wordlift_Install { |
| 18 | - /** |
|
| 19 | - * @inheritdoc |
|
| 20 | - */ |
|
| 21 | - protected static $version = '3.18.0'; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * @inheritdoc |
|
| 25 | - */ |
|
| 26 | - public function __construct() { |
|
| 27 | - parent::__construct(); |
|
| 28 | - |
|
| 29 | - add_action( 'wl_async_wl_push_references', array( |
|
| 30 | - $this, |
|
| 31 | - 'push_references', |
|
| 32 | - ) ); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @inheritdoc |
|
| 37 | - */ |
|
| 38 | - public function install() { |
|
| 39 | - $this->add_offer_entity_type(); |
|
| 40 | - $this->add_editors_read_wordlift_entity_capability(); |
|
| 41 | - do_action( 'wl_push_references' ); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Creates references for articles *referencing* entities |
|
| 46 | - * |
|
| 47 | - * @return void |
|
| 48 | - * @since 3.18.0 |
|
| 49 | - * |
|
| 50 | - */ |
|
| 51 | - public function push_references() { |
|
| 52 | - // Get relations. |
|
| 53 | - $relations = Wordlift_Relation_Service::get_instance()->find_all_grouped_by_subject_id(); |
|
| 54 | - |
|
| 55 | - $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 56 | - |
|
| 57 | - // Loop through all relations and push the references. |
|
| 58 | - foreach ( $relations as $relation ) { |
|
| 59 | - |
|
| 60 | - $post = get_post( $relation->subject_id ); |
|
| 61 | - |
|
| 62 | - // Bail out if it's an entity: we're only interested in articles |
|
| 63 | - // *referencing* entities. |
|
| 64 | - if ( $entity_service->is_entity( $post->ID ) ) { |
|
| 65 | - continue; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - // Push the references. |
|
| 69 | - do_action( 'wl_legacy_linked_data__push', $post->ID ); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Adds the new `Offer` entity type. |
|
| 76 | - * |
|
| 77 | - * @return void |
|
| 78 | - * @since 3.18.0 |
|
| 79 | - * |
|
| 80 | - */ |
|
| 81 | - public function add_offer_entity_type() { |
|
| 82 | - // Check whether the `offer` term exists. |
|
| 83 | - $offer = get_term_by( |
|
| 84 | - 'slug', |
|
| 85 | - 'offer', |
|
| 86 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME |
|
| 87 | - ); |
|
| 88 | - |
|
| 89 | - // The `offer` term doesn't exists, so create it. |
|
| 90 | - if ( empty( $offer ) ) { |
|
| 91 | - wp_insert_term( |
|
| 92 | - 'Offer', |
|
| 93 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 94 | - array( |
|
| 95 | - 'slug' => 'offer', |
|
| 96 | - 'description' => 'An Offer.', |
|
| 97 | - ) |
|
| 98 | - ); |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Add additional `read_wordlift_entity` capability to editors. |
|
| 104 | - * |
|
| 105 | - * @return void |
|
| 106 | - * @since 3.18.0 |
|
| 107 | - * |
|
| 108 | - */ |
|
| 109 | - public function add_editors_read_wordlift_entity_capability() { |
|
| 110 | - // Get the editor roles. |
|
| 111 | - $admins = get_role( 'administrator' ); |
|
| 112 | - $admins->add_cap( 'read_wordlift_entity' ); |
|
| 113 | - |
|
| 114 | - /* |
|
| 18 | + /** |
|
| 19 | + * @inheritdoc |
|
| 20 | + */ |
|
| 21 | + protected static $version = '3.18.0'; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * @inheritdoc |
|
| 25 | + */ |
|
| 26 | + public function __construct() { |
|
| 27 | + parent::__construct(); |
|
| 28 | + |
|
| 29 | + add_action( 'wl_async_wl_push_references', array( |
|
| 30 | + $this, |
|
| 31 | + 'push_references', |
|
| 32 | + ) ); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @inheritdoc |
|
| 37 | + */ |
|
| 38 | + public function install() { |
|
| 39 | + $this->add_offer_entity_type(); |
|
| 40 | + $this->add_editors_read_wordlift_entity_capability(); |
|
| 41 | + do_action( 'wl_push_references' ); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Creates references for articles *referencing* entities |
|
| 46 | + * |
|
| 47 | + * @return void |
|
| 48 | + * @since 3.18.0 |
|
| 49 | + * |
|
| 50 | + */ |
|
| 51 | + public function push_references() { |
|
| 52 | + // Get relations. |
|
| 53 | + $relations = Wordlift_Relation_Service::get_instance()->find_all_grouped_by_subject_id(); |
|
| 54 | + |
|
| 55 | + $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 56 | + |
|
| 57 | + // Loop through all relations and push the references. |
|
| 58 | + foreach ( $relations as $relation ) { |
|
| 59 | + |
|
| 60 | + $post = get_post( $relation->subject_id ); |
|
| 61 | + |
|
| 62 | + // Bail out if it's an entity: we're only interested in articles |
|
| 63 | + // *referencing* entities. |
|
| 64 | + if ( $entity_service->is_entity( $post->ID ) ) { |
|
| 65 | + continue; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + // Push the references. |
|
| 69 | + do_action( 'wl_legacy_linked_data__push', $post->ID ); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Adds the new `Offer` entity type. |
|
| 76 | + * |
|
| 77 | + * @return void |
|
| 78 | + * @since 3.18.0 |
|
| 79 | + * |
|
| 80 | + */ |
|
| 81 | + public function add_offer_entity_type() { |
|
| 82 | + // Check whether the `offer` term exists. |
|
| 83 | + $offer = get_term_by( |
|
| 84 | + 'slug', |
|
| 85 | + 'offer', |
|
| 86 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME |
|
| 87 | + ); |
|
| 88 | + |
|
| 89 | + // The `offer` term doesn't exists, so create it. |
|
| 90 | + if ( empty( $offer ) ) { |
|
| 91 | + wp_insert_term( |
|
| 92 | + 'Offer', |
|
| 93 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 94 | + array( |
|
| 95 | + 'slug' => 'offer', |
|
| 96 | + 'description' => 'An Offer.', |
|
| 97 | + ) |
|
| 98 | + ); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Add additional `read_wordlift_entity` capability to editors. |
|
| 104 | + * |
|
| 105 | + * @return void |
|
| 106 | + * @since 3.18.0 |
|
| 107 | + * |
|
| 108 | + */ |
|
| 109 | + public function add_editors_read_wordlift_entity_capability() { |
|
| 110 | + // Get the editor roles. |
|
| 111 | + $admins = get_role( 'administrator' ); |
|
| 112 | + $admins->add_cap( 'read_wordlift_entity' ); |
|
| 113 | + |
|
| 114 | + /* |
|
| 115 | 115 | * Check that the `editor` role exists before using it. |
| 116 | 116 | * |
| 117 | 117 | * @since 3.19.6 |
| 118 | 118 | * |
| 119 | 119 | * @see https://github.com/insideout10/wordlift-plugin/issues/886 |
| 120 | 120 | */ |
| 121 | - $editors = get_role( 'editor' ); |
|
| 122 | - if ( isset( $editors ) ) { |
|
| 123 | - $editors->add_cap( 'read_wordlift_entity' ); |
|
| 124 | - } |
|
| 121 | + $editors = get_role( 'editor' ); |
|
| 122 | + if ( isset( $editors ) ) { |
|
| 123 | + $editors->add_cap( 'read_wordlift_entity' ); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - } |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | } |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | public function __construct() { |
| 27 | 27 | parent::__construct(); |
| 28 | 28 | |
| 29 | - add_action( 'wl_async_wl_push_references', array( |
|
| 29 | + add_action('wl_async_wl_push_references', array( |
|
| 30 | 30 | $this, |
| 31 | 31 | 'push_references', |
| 32 | - ) ); |
|
| 32 | + )); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | public function install() { |
| 39 | 39 | $this->add_offer_entity_type(); |
| 40 | 40 | $this->add_editors_read_wordlift_entity_capability(); |
| 41 | - do_action( 'wl_push_references' ); |
|
| 41 | + do_action('wl_push_references'); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -55,18 +55,18 @@ discard block |
||
| 55 | 55 | $entity_service = Wordlift_Entity_Service::get_instance(); |
| 56 | 56 | |
| 57 | 57 | // Loop through all relations and push the references. |
| 58 | - foreach ( $relations as $relation ) { |
|
| 58 | + foreach ($relations as $relation) { |
|
| 59 | 59 | |
| 60 | - $post = get_post( $relation->subject_id ); |
|
| 60 | + $post = get_post($relation->subject_id); |
|
| 61 | 61 | |
| 62 | 62 | // Bail out if it's an entity: we're only interested in articles |
| 63 | 63 | // *referencing* entities. |
| 64 | - if ( $entity_service->is_entity( $post->ID ) ) { |
|
| 64 | + if ($entity_service->is_entity($post->ID)) { |
|
| 65 | 65 | continue; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Push the references. |
| 69 | - do_action( 'wl_legacy_linked_data__push', $post->ID ); |
|
| 69 | + do_action('wl_legacy_linked_data__push', $post->ID); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | 89 | // The `offer` term doesn't exists, so create it. |
| 90 | - if ( empty( $offer ) ) { |
|
| 90 | + if (empty($offer)) { |
|
| 91 | 91 | wp_insert_term( |
| 92 | 92 | 'Offer', |
| 93 | 93 | Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function add_editors_read_wordlift_entity_capability() { |
| 110 | 110 | // Get the editor roles. |
| 111 | - $admins = get_role( 'administrator' ); |
|
| 112 | - $admins->add_cap( 'read_wordlift_entity' ); |
|
| 111 | + $admins = get_role('administrator'); |
|
| 112 | + $admins->add_cap('read_wordlift_entity'); |
|
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | * Check that the `editor` role exists before using it. |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | * |
| 119 | 119 | * @see https://github.com/insideout10/wordlift-plugin/issues/886 |
| 120 | 120 | */ |
| 121 | - $editors = get_role( 'editor' ); |
|
| 122 | - if ( isset( $editors ) ) { |
|
| 123 | - $editors->add_cap( 'read_wordlift_entity' ); |
|
| 121 | + $editors = get_role('editor'); |
|
| 122 | + if (isset($editors)) { |
|
| 123 | + $editors->add_cap('read_wordlift_entity'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | } |
@@ -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 | - do_action( 'wl_legacy_linked_data__push', $first_id ); |
|
| 17 | + $first_id = key( $not_found_uris ); |
|
| 18 | + // Re-push the entity to the Linked Data Cloud. |
|
| 19 | + do_action( 'wl_legacy_linked_data__push', $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 | - do_action( 'wl_legacy_linked_data__push', $first_id ); |
|
| 19 | + do_action('wl_legacy_linked_data__push', $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> |