@@ -11,279 +11,279 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Wordlift_Sparql_Service { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * A {@link Wordlift_Log_Service} instance. |
|
| 16 | - * |
|
| 17 | - * @since 3.6.0 |
|
| 18 | - * @access private |
|
| 19 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 20 | - */ |
|
| 21 | - private $log; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * The {@link Wordlift_Sparql_Service} singleton instance. |
|
| 25 | - * |
|
| 26 | - * @since 3.6.0 |
|
| 27 | - * @access private |
|
| 28 | - * @var \Wordlift_Sparql_Service $instance The {@link Wordlift_Sparql_Service} singleton instance. |
|
| 29 | - */ |
|
| 30 | - private static $instance; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Create a {@link Wordlift_Sparql_Service} instance. |
|
| 34 | - * |
|
| 35 | - * @since 3.6.0 |
|
| 36 | - */ |
|
| 37 | - public function __construct() { |
|
| 38 | - |
|
| 39 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Sparql_Service' ); |
|
| 40 | - |
|
| 41 | - self::$instance = $this; |
|
| 42 | - |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Get the singleton instance of the {@link Wordlift_Sparql_Service}. |
|
| 47 | - * |
|
| 48 | - * @since 3.6.0 |
|
| 49 | - * @return \Wordlift_Sparql_Service |
|
| 50 | - */ |
|
| 51 | - public static function get_instance() { |
|
| 52 | - |
|
| 53 | - return self::$instance; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Queue a SPARQL statement for execution. |
|
| 58 | - * |
|
| 59 | - * @since 3.6.0 |
|
| 60 | - * |
|
| 61 | - * @param string $stmt The SPARQL statement. |
|
| 62 | - * @param bool $queue Whether to queue the statement for asynchronous |
|
| 63 | - * execution. |
|
| 64 | - */ |
|
| 65 | - public function execute( $stmt, $queue = WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) { |
|
| 66 | - |
|
| 67 | - rl_execute_sparql_update_query( $stmt, $queue ); |
|
| 68 | - |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Run the SPARQL queries buffered for the specified request id. |
|
| 73 | - * |
|
| 74 | - * @since 3.13.2 |
|
| 75 | - * |
|
| 76 | - * @param string $request_id A unique request id. |
|
| 77 | - */ |
|
| 78 | - public function run_sparql_query( $request_id ) { |
|
| 79 | - |
|
| 80 | - $this->log->debug( "Running SPARQL queries..." ); |
|
| 81 | - |
|
| 82 | - // Look for a free temporary filename. |
|
| 83 | - for ( $index = 1; $index < 1000; $index ++ ) { |
|
| 84 | - $filename = WL_TEMP_DIR . $request_id . "-$index.sparql"; |
|
| 85 | - |
|
| 86 | - // Bail out if there are no files left. |
|
| 87 | - if ( ! file_exists( $filename ) ) { |
|
| 88 | - break; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - $this->log->debug( "Running SPARQL from $filename..." ); |
|
| 92 | - |
|
| 93 | - // Get the query saved in the file. |
|
| 94 | - $query = file_get_contents( $filename ); |
|
| 95 | - |
|
| 96 | - // Execute the SPARQL query. |
|
| 97 | - rl_execute_sparql_update_query( $query, false ); |
|
| 98 | - |
|
| 99 | - // Delete the temporary file. |
|
| 100 | - unlink( $filename ); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // Reindex the triple store. |
|
| 104 | - wordlift_reindex_triple_store(); |
|
| 105 | - |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Queue a SPARQL statement for asynchronous execution. |
|
| 110 | - * |
|
| 111 | - * @since 3.13.2 |
|
| 112 | - * |
|
| 113 | - * @param string $stmt The SPARQL statement. |
|
| 114 | - */ |
|
| 115 | - public function queue( $stmt ) { |
|
| 116 | - |
|
| 117 | - // Get a temporary filename. |
|
| 118 | - $filename = $this->get_temporary_file_for_sparql(); |
|
| 14 | + /** |
|
| 15 | + * A {@link Wordlift_Log_Service} instance. |
|
| 16 | + * |
|
| 17 | + * @since 3.6.0 |
|
| 18 | + * @access private |
|
| 19 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 20 | + */ |
|
| 21 | + private $log; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * The {@link Wordlift_Sparql_Service} singleton instance. |
|
| 25 | + * |
|
| 26 | + * @since 3.6.0 |
|
| 27 | + * @access private |
|
| 28 | + * @var \Wordlift_Sparql_Service $instance The {@link Wordlift_Sparql_Service} singleton instance. |
|
| 29 | + */ |
|
| 30 | + private static $instance; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Create a {@link Wordlift_Sparql_Service} instance. |
|
| 34 | + * |
|
| 35 | + * @since 3.6.0 |
|
| 36 | + */ |
|
| 37 | + public function __construct() { |
|
| 38 | + |
|
| 39 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Sparql_Service' ); |
|
| 40 | + |
|
| 41 | + self::$instance = $this; |
|
| 42 | + |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Get the singleton instance of the {@link Wordlift_Sparql_Service}. |
|
| 47 | + * |
|
| 48 | + * @since 3.6.0 |
|
| 49 | + * @return \Wordlift_Sparql_Service |
|
| 50 | + */ |
|
| 51 | + public static function get_instance() { |
|
| 52 | + |
|
| 53 | + return self::$instance; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Queue a SPARQL statement for execution. |
|
| 58 | + * |
|
| 59 | + * @since 3.6.0 |
|
| 60 | + * |
|
| 61 | + * @param string $stmt The SPARQL statement. |
|
| 62 | + * @param bool $queue Whether to queue the statement for asynchronous |
|
| 63 | + * execution. |
|
| 64 | + */ |
|
| 65 | + public function execute( $stmt, $queue = WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) { |
|
| 66 | + |
|
| 67 | + rl_execute_sparql_update_query( $stmt, $queue ); |
|
| 68 | + |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Run the SPARQL queries buffered for the specified request id. |
|
| 73 | + * |
|
| 74 | + * @since 3.13.2 |
|
| 75 | + * |
|
| 76 | + * @param string $request_id A unique request id. |
|
| 77 | + */ |
|
| 78 | + public function run_sparql_query( $request_id ) { |
|
| 79 | + |
|
| 80 | + $this->log->debug( "Running SPARQL queries..." ); |
|
| 81 | + |
|
| 82 | + // Look for a free temporary filename. |
|
| 83 | + for ( $index = 1; $index < 1000; $index ++ ) { |
|
| 84 | + $filename = WL_TEMP_DIR . $request_id . "-$index.sparql"; |
|
| 85 | + |
|
| 86 | + // Bail out if there are no files left. |
|
| 87 | + if ( ! file_exists( $filename ) ) { |
|
| 88 | + break; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + $this->log->debug( "Running SPARQL from $filename..." ); |
|
| 92 | + |
|
| 93 | + // Get the query saved in the file. |
|
| 94 | + $query = file_get_contents( $filename ); |
|
| 95 | + |
|
| 96 | + // Execute the SPARQL query. |
|
| 97 | + rl_execute_sparql_update_query( $query, false ); |
|
| 98 | + |
|
| 99 | + // Delete the temporary file. |
|
| 100 | + unlink( $filename ); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // Reindex the triple store. |
|
| 104 | + wordlift_reindex_triple_store(); |
|
| 105 | + |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Queue a SPARQL statement for asynchronous execution. |
|
| 110 | + * |
|
| 111 | + * @since 3.13.2 |
|
| 112 | + * |
|
| 113 | + * @param string $stmt The SPARQL statement. |
|
| 114 | + */ |
|
| 115 | + public function queue( $stmt ) { |
|
| 116 | + |
|
| 117 | + // Get a temporary filename. |
|
| 118 | + $filename = $this->get_temporary_file_for_sparql(); |
|
| 119 | 119 | |
| 120 | - $this->log->debug( "Buffering SPARQL to file $filename..." ); |
|
| 120 | + $this->log->debug( "Buffering SPARQL to file $filename..." ); |
|
| 121 | 121 | |
| 122 | - // Write the contents to the temporary filename. |
|
| 123 | - file_put_contents( $filename, $stmt . "\n", FILE_APPEND ); |
|
| 122 | + // Write the contents to the temporary filename. |
|
| 123 | + file_put_contents( $filename, $stmt . "\n", FILE_APPEND ); |
|
| 124 | 124 | |
| 125 | - } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Get a temporary filename where to store SPARQL queries. |
|
| 129 | - * |
|
| 130 | - * @since 3.13.2 |
|
| 131 | - * |
|
| 132 | - * @return string The filename. |
|
| 133 | - * @throws Exception An exception is thrown if there are already 1.000 |
|
| 134 | - * temporary files for this request. |
|
| 135 | - */ |
|
| 136 | - private function get_temporary_file_for_sparql() { |
|
| 127 | + /** |
|
| 128 | + * Get a temporary filename where to store SPARQL queries. |
|
| 129 | + * |
|
| 130 | + * @since 3.13.2 |
|
| 131 | + * |
|
| 132 | + * @return string The filename. |
|
| 133 | + * @throws Exception An exception is thrown if there are already 1.000 |
|
| 134 | + * temporary files for this request. |
|
| 135 | + */ |
|
| 136 | + private function get_temporary_file_for_sparql() { |
|
| 137 | 137 | |
| 138 | - // Look for a free temporary filename. |
|
| 139 | - for ( $index = 1; $index < 1000; $index ++ ) { |
|
| 140 | - $filename = WL_TEMP_DIR . WL_REQUEST_ID . "-$index.sparql"; |
|
| 138 | + // Look for a free temporary filename. |
|
| 139 | + for ( $index = 1; $index < 1000; $index ++ ) { |
|
| 140 | + $filename = WL_TEMP_DIR . WL_REQUEST_ID . "-$index.sparql"; |
|
| 141 | 141 | |
| 142 | - if ( ! file_exists( $filename ) ) { |
|
| 142 | + if ( ! file_exists( $filename ) ) { |
|
| 143 | 143 | |
| 144 | - // Only if this it the first buffered SPARQL, then launch the |
|
| 145 | - // action which will be handled by the Async Task. The Async |
|
| 146 | - // Task will take care of all the buffered files. |
|
| 147 | - if ( 1 === $index ) { |
|
| 148 | - do_action( 'wl_run_sparql_query', WL_REQUEST_ID ); |
|
| 149 | - } |
|
| 144 | + // Only if this it the first buffered SPARQL, then launch the |
|
| 145 | + // action which will be handled by the Async Task. The Async |
|
| 146 | + // Task will take care of all the buffered files. |
|
| 147 | + if ( 1 === $index ) { |
|
| 148 | + do_action( 'wl_run_sparql_query', WL_REQUEST_ID ); |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - // Return the temporary filename. |
|
| 152 | - return $filename; |
|
| 153 | - } |
|
| 154 | - } |
|
| 151 | + // Return the temporary filename. |
|
| 152 | + return $filename; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - throw new Exception( 'Cannot create a temporary file.' ); |
|
| 157 | - } |
|
| 156 | + throw new Exception( 'Cannot create a temporary file.' ); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Execute the SELECT query. |
|
| 161 | - * |
|
| 162 | - * @since 3.12.2 |
|
| 163 | - * |
|
| 164 | - * @param string $query The SELECT query to execute. |
|
| 165 | - * |
|
| 166 | - * @return WP_Error|array The response or WP_Error on failure. |
|
| 167 | - */ |
|
| 168 | - public function select( $query ) { |
|
| 159 | + /** |
|
| 160 | + * Execute the SELECT query. |
|
| 161 | + * |
|
| 162 | + * @since 3.12.2 |
|
| 163 | + * |
|
| 164 | + * @param string $query The SELECT query to execute. |
|
| 165 | + * |
|
| 166 | + * @return WP_Error|array The response or WP_Error on failure. |
|
| 167 | + */ |
|
| 168 | + public function select( $query ) { |
|
| 169 | 169 | |
| 170 | - // Prepare the SPARQL statement by prepending the default namespaces. |
|
| 171 | - $sparql = rl_sparql_prefixes() . "\n" . $query; |
|
| 170 | + // Prepare the SPARQL statement by prepending the default namespaces. |
|
| 171 | + $sparql = rl_sparql_prefixes() . "\n" . $query; |
|
| 172 | 172 | |
| 173 | - // Get the SPARQL SELECT URL. |
|
| 174 | - $url = wl_configuration_get_query_select_url( 'csv' ) . urlencode( $sparql ); |
|
| 173 | + // Get the SPARQL SELECT URL. |
|
| 174 | + $url = wl_configuration_get_query_select_url( 'csv' ) . urlencode( $sparql ); |
|
| 175 | 175 | |
| 176 | - // Prepare the request. |
|
| 177 | - $args = unserialize( WL_REDLINK_API_HTTP_OPTIONS ); |
|
| 176 | + // Prepare the request. |
|
| 177 | + $args = unserialize( WL_REDLINK_API_HTTP_OPTIONS ); |
|
| 178 | 178 | |
| 179 | - return wp_remote_get( $url, $args ); |
|
| 180 | - } |
|
| 179 | + return wp_remote_get( $url, $args ); |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Formats the provided value according to the specified type in order to |
|
| 184 | - * insert the value using SPARQL. The value is also escaped. |
|
| 185 | - * |
|
| 186 | - * @since 3.6.0 |
|
| 187 | - * |
|
| 188 | - * @param string $value The value. |
|
| 189 | - * @param string $type The value type. |
|
| 190 | - * |
|
| 191 | - * @return string The formatted value for SPARQL statements. |
|
| 192 | - */ |
|
| 193 | - public function format( $value, $type ) { |
|
| 182 | + /** |
|
| 183 | + * Formats the provided value according to the specified type in order to |
|
| 184 | + * insert the value using SPARQL. The value is also escaped. |
|
| 185 | + * |
|
| 186 | + * @since 3.6.0 |
|
| 187 | + * |
|
| 188 | + * @param string $value The value. |
|
| 189 | + * @param string $type The value type. |
|
| 190 | + * |
|
| 191 | + * @return string The formatted value for SPARQL statements. |
|
| 192 | + */ |
|
| 193 | + public function format( $value, $type ) { |
|
| 194 | 194 | |
| 195 | - // see https://www.w3.org/TR/sparql11-query/. |
|
| 196 | - |
|
| 197 | - switch ( $type ) { |
|
| 195 | + // see https://www.w3.org/TR/sparql11-query/. |
|
| 196 | + |
|
| 197 | + switch ( $type ) { |
|
| 198 | 198 | |
| 199 | - case Wordlift_Schema_Service::DATA_TYPE_BOOLEAN: |
|
| 200 | - |
|
| 201 | - // SPARQL supports 'true' and 'false', so we evaluate the $value |
|
| 202 | - // and return true/false accordingly. |
|
| 203 | - return $value ? 'true' : 'false'; |
|
| 204 | - |
|
| 205 | - case Wordlift_Schema_Service::DATA_TYPE_DATE: |
|
| 206 | - |
|
| 207 | - return sprintf( '"%s"^^xsd:date', self::escape( $value ) ); |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - case Wordlift_Schema_Service::DATA_TYPE_DOUBLE: |
|
| 211 | - |
|
| 212 | - return sprintf( '"%s"^^xsd:double', self::escape( $value ) ); |
|
| 199 | + case Wordlift_Schema_Service::DATA_TYPE_BOOLEAN: |
|
| 200 | + |
|
| 201 | + // SPARQL supports 'true' and 'false', so we evaluate the $value |
|
| 202 | + // and return true/false accordingly. |
|
| 203 | + return $value ? 'true' : 'false'; |
|
| 204 | + |
|
| 205 | + case Wordlift_Schema_Service::DATA_TYPE_DATE: |
|
| 206 | + |
|
| 207 | + return sprintf( '"%s"^^xsd:date', self::escape( $value ) ); |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + case Wordlift_Schema_Service::DATA_TYPE_DOUBLE: |
|
| 211 | + |
|
| 212 | + return sprintf( '"%s"^^xsd:double', self::escape( $value ) ); |
|
| 213 | 213 | |
| 214 | - case Wordlift_Schema_Service::DATA_TYPE_INTEGER: |
|
| 214 | + case Wordlift_Schema_Service::DATA_TYPE_INTEGER: |
|
| 215 | 215 | |
| 216 | - return sprintf( '"%s"^^xsd:integer', self::escape( $value ) ); |
|
| 216 | + return sprintf( '"%s"^^xsd:integer', self::escape( $value ) ); |
|
| 217 | 217 | |
| 218 | - case Wordlift_Schema_Service::DATA_TYPE_STRING: |
|
| 218 | + case Wordlift_Schema_Service::DATA_TYPE_STRING: |
|
| 219 | 219 | |
| 220 | - return sprintf( '"%s"^^xsd:string', self::escape( $value ) ); |
|
| 220 | + return sprintf( '"%s"^^xsd:string', self::escape( $value ) ); |
|
| 221 | 221 | |
| 222 | - case Wordlift_Schema_Service::DATA_TYPE_URI: |
|
| 223 | - |
|
| 224 | - return sprintf( '<%s>', self::escape_uri( $value ) ); |
|
| 225 | - |
|
| 226 | - default: |
|
| 227 | - |
|
| 228 | - $this->log->warn( "Unknown data type [ type :: $type ]" ); |
|
| 229 | - |
|
| 230 | - // Try to insert the value anyway. |
|
| 231 | - return sprintf( '"%s"', self::escape( $value ) ); |
|
| 232 | - } |
|
| 222 | + case Wordlift_Schema_Service::DATA_TYPE_URI: |
|
| 223 | + |
|
| 224 | + return sprintf( '<%s>', self::escape_uri( $value ) ); |
|
| 225 | + |
|
| 226 | + default: |
|
| 227 | + |
|
| 228 | + $this->log->warn( "Unknown data type [ type :: $type ]" ); |
|
| 229 | + |
|
| 230 | + // Try to insert the value anyway. |
|
| 231 | + return sprintf( '"%s"', self::escape( $value ) ); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - } |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * Escapes an URI for a SPARQL statement. |
|
| 238 | - * |
|
| 239 | - * @since 3.6.0 |
|
| 240 | - * |
|
| 241 | - * @param string $uri The URI to escape. |
|
| 242 | - * |
|
| 243 | - * @return string The escaped URI. |
|
| 244 | - */ |
|
| 245 | - public static function escape_uri( $uri ) { |
|
| 236 | + /** |
|
| 237 | + * Escapes an URI for a SPARQL statement. |
|
| 238 | + * |
|
| 239 | + * @since 3.6.0 |
|
| 240 | + * |
|
| 241 | + * @param string $uri The URI to escape. |
|
| 242 | + * |
|
| 243 | + * @return string The escaped URI. |
|
| 244 | + */ |
|
| 245 | + public static function escape_uri( $uri ) { |
|
| 246 | 246 | |
| 247 | - // Should we validate the IRI? |
|
| 248 | - // http://www.w3.org/TR/sparql11-query/#QSynIRI |
|
| 247 | + // Should we validate the IRI? |
|
| 248 | + // http://www.w3.org/TR/sparql11-query/#QSynIRI |
|
| 249 | 249 | |
| 250 | - $uri = str_replace( '<', '\<', $uri ); |
|
| 251 | - $uri = str_replace( '>', '\>', $uri ); |
|
| 250 | + $uri = str_replace( '<', '\<', $uri ); |
|
| 251 | + $uri = str_replace( '>', '\>', $uri ); |
|
| 252 | 252 | |
| 253 | - return $uri; |
|
| 254 | - } |
|
| 253 | + return $uri; |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - /** |
|
| 257 | - * Escapes a string for a SPARQL statement. |
|
| 258 | - * |
|
| 259 | - * @since 3.6.0 |
|
| 260 | - * |
|
| 261 | - * @param string $string The string to escape. |
|
| 262 | - * |
|
| 263 | - * @return string The escaped string. |
|
| 264 | - */ |
|
| 265 | - public static function escape( $string ) { |
|
| 256 | + /** |
|
| 257 | + * Escapes a string for a SPARQL statement. |
|
| 258 | + * |
|
| 259 | + * @since 3.6.0 |
|
| 260 | + * |
|
| 261 | + * @param string $string The string to escape. |
|
| 262 | + * |
|
| 263 | + * @return string The escaped string. |
|
| 264 | + */ |
|
| 265 | + public static function escape( $string ) { |
|
| 266 | 266 | |
| 267 | - // see http://www.w3.org/TR/rdf-sparql-query/ |
|
| 268 | - // '\t' U+0009 (tab) |
|
| 269 | - // '\n' U+000A (line feed) |
|
| 270 | - // '\r' U+000D (carriage return) |
|
| 271 | - // '\b' U+0008 (backspace) |
|
| 272 | - // '\f' U+000C (form feed) |
|
| 273 | - // '\"' U+0022 (quotation mark, double quote mark) |
|
| 274 | - // "\'" U+0027 (apostrophe-quote, single quote mark) |
|
| 275 | - // '\\' U+005C (backslash) |
|
| 267 | + // see http://www.w3.org/TR/rdf-sparql-query/ |
|
| 268 | + // '\t' U+0009 (tab) |
|
| 269 | + // '\n' U+000A (line feed) |
|
| 270 | + // '\r' U+000D (carriage return) |
|
| 271 | + // '\b' U+0008 (backspace) |
|
| 272 | + // '\f' U+000C (form feed) |
|
| 273 | + // '\"' U+0022 (quotation mark, double quote mark) |
|
| 274 | + // "\'" U+0027 (apostrophe-quote, single quote mark) |
|
| 275 | + // '\\' U+005C (backslash) |
|
| 276 | 276 | |
| 277 | - $string = str_replace( '\\', '\\\\', $string ); |
|
| 278 | - $string = str_replace( '\'', '\\\'', $string ); |
|
| 279 | - $string = str_replace( '"', '\\"', $string ); |
|
| 280 | - $string = str_replace( "\f", '\\f', $string ); |
|
| 281 | - $string = str_replace( "\b", '\\b', $string ); |
|
| 282 | - $string = str_replace( "\r", '\\r', $string ); |
|
| 283 | - $string = str_replace( "\n", '\\n', $string ); |
|
| 284 | - $string = str_replace( "\t", '\\t', $string ); |
|
| 277 | + $string = str_replace( '\\', '\\\\', $string ); |
|
| 278 | + $string = str_replace( '\'', '\\\'', $string ); |
|
| 279 | + $string = str_replace( '"', '\\"', $string ); |
|
| 280 | + $string = str_replace( "\f", '\\f', $string ); |
|
| 281 | + $string = str_replace( "\b", '\\b', $string ); |
|
| 282 | + $string = str_replace( "\r", '\\r', $string ); |
|
| 283 | + $string = str_replace( "\n", '\\n', $string ); |
|
| 284 | + $string = str_replace( "\t", '\\t', $string ); |
|
| 285 | 285 | |
| 286 | - return $string; |
|
| 287 | - } |
|
| 286 | + return $string; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | 289 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function __construct() { |
| 38 | 38 | |
| 39 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Sparql_Service' ); |
|
| 39 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Sparql_Service'); |
|
| 40 | 40 | |
| 41 | 41 | self::$instance = $this; |
| 42 | 42 | |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | * @param bool $queue Whether to queue the statement for asynchronous |
| 63 | 63 | * execution. |
| 64 | 64 | */ |
| 65 | - public function execute( $stmt, $queue = WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) { |
|
| 65 | + public function execute($stmt, $queue = WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING) { |
|
| 66 | 66 | |
| 67 | - rl_execute_sparql_update_query( $stmt, $queue ); |
|
| 67 | + rl_execute_sparql_update_query($stmt, $queue); |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
@@ -75,29 +75,29 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @param string $request_id A unique request id. |
| 77 | 77 | */ |
| 78 | - public function run_sparql_query( $request_id ) { |
|
| 78 | + public function run_sparql_query($request_id) { |
|
| 79 | 79 | |
| 80 | - $this->log->debug( "Running SPARQL queries..." ); |
|
| 80 | + $this->log->debug("Running SPARQL queries..."); |
|
| 81 | 81 | |
| 82 | 82 | // Look for a free temporary filename. |
| 83 | - for ( $index = 1; $index < 1000; $index ++ ) { |
|
| 84 | - $filename = WL_TEMP_DIR . $request_id . "-$index.sparql"; |
|
| 83 | + for ($index = 1; $index < 1000; $index++) { |
|
| 84 | + $filename = WL_TEMP_DIR.$request_id."-$index.sparql"; |
|
| 85 | 85 | |
| 86 | 86 | // Bail out if there are no files left. |
| 87 | - if ( ! file_exists( $filename ) ) { |
|
| 87 | + if ( ! file_exists($filename)) { |
|
| 88 | 88 | break; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - $this->log->debug( "Running SPARQL from $filename..." ); |
|
| 91 | + $this->log->debug("Running SPARQL from $filename..."); |
|
| 92 | 92 | |
| 93 | 93 | // Get the query saved in the file. |
| 94 | - $query = file_get_contents( $filename ); |
|
| 94 | + $query = file_get_contents($filename); |
|
| 95 | 95 | |
| 96 | 96 | // Execute the SPARQL query. |
| 97 | - rl_execute_sparql_update_query( $query, false ); |
|
| 97 | + rl_execute_sparql_update_query($query, false); |
|
| 98 | 98 | |
| 99 | 99 | // Delete the temporary file. |
| 100 | - unlink( $filename ); |
|
| 100 | + unlink($filename); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Reindex the triple store. |
@@ -112,15 +112,15 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @param string $stmt The SPARQL statement. |
| 114 | 114 | */ |
| 115 | - public function queue( $stmt ) { |
|
| 115 | + public function queue($stmt) { |
|
| 116 | 116 | |
| 117 | 117 | // Get a temporary filename. |
| 118 | 118 | $filename = $this->get_temporary_file_for_sparql(); |
| 119 | 119 | |
| 120 | - $this->log->debug( "Buffering SPARQL to file $filename..." ); |
|
| 120 | + $this->log->debug("Buffering SPARQL to file $filename..."); |
|
| 121 | 121 | |
| 122 | 122 | // Write the contents to the temporary filename. |
| 123 | - file_put_contents( $filename, $stmt . "\n", FILE_APPEND ); |
|
| 123 | + file_put_contents($filename, $stmt."\n", FILE_APPEND); |
|
| 124 | 124 | |
| 125 | 125 | } |
| 126 | 126 | |
@@ -136,16 +136,16 @@ discard block |
||
| 136 | 136 | private function get_temporary_file_for_sparql() { |
| 137 | 137 | |
| 138 | 138 | // Look for a free temporary filename. |
| 139 | - for ( $index = 1; $index < 1000; $index ++ ) { |
|
| 140 | - $filename = WL_TEMP_DIR . WL_REQUEST_ID . "-$index.sparql"; |
|
| 139 | + for ($index = 1; $index < 1000; $index++) { |
|
| 140 | + $filename = WL_TEMP_DIR.WL_REQUEST_ID."-$index.sparql"; |
|
| 141 | 141 | |
| 142 | - if ( ! file_exists( $filename ) ) { |
|
| 142 | + if ( ! file_exists($filename)) { |
|
| 143 | 143 | |
| 144 | 144 | // Only if this it the first buffered SPARQL, then launch the |
| 145 | 145 | // action which will be handled by the Async Task. The Async |
| 146 | 146 | // Task will take care of all the buffered files. |
| 147 | - if ( 1 === $index ) { |
|
| 148 | - do_action( 'wl_run_sparql_query', WL_REQUEST_ID ); |
|
| 147 | + if (1 === $index) { |
|
| 148 | + do_action('wl_run_sparql_query', WL_REQUEST_ID); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Return the temporary filename. |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - throw new Exception( 'Cannot create a temporary file.' ); |
|
| 156 | + throw new Exception('Cannot create a temporary file.'); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -165,18 +165,18 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @return WP_Error|array The response or WP_Error on failure. |
| 167 | 167 | */ |
| 168 | - public function select( $query ) { |
|
| 168 | + public function select($query) { |
|
| 169 | 169 | |
| 170 | 170 | // Prepare the SPARQL statement by prepending the default namespaces. |
| 171 | - $sparql = rl_sparql_prefixes() . "\n" . $query; |
|
| 171 | + $sparql = rl_sparql_prefixes()."\n".$query; |
|
| 172 | 172 | |
| 173 | 173 | // Get the SPARQL SELECT URL. |
| 174 | - $url = wl_configuration_get_query_select_url( 'csv' ) . urlencode( $sparql ); |
|
| 174 | + $url = wl_configuration_get_query_select_url('csv').urlencode($sparql); |
|
| 175 | 175 | |
| 176 | 176 | // Prepare the request. |
| 177 | - $args = unserialize( WL_REDLINK_API_HTTP_OPTIONS ); |
|
| 177 | + $args = unserialize(WL_REDLINK_API_HTTP_OPTIONS); |
|
| 178 | 178 | |
| 179 | - return wp_remote_get( $url, $args ); |
|
| 179 | + return wp_remote_get($url, $args); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return string The formatted value for SPARQL statements. |
| 192 | 192 | */ |
| 193 | - public function format( $value, $type ) { |
|
| 193 | + public function format($value, $type) { |
|
| 194 | 194 | |
| 195 | 195 | // see https://www.w3.org/TR/sparql11-query/. |
| 196 | 196 | |
| 197 | - switch ( $type ) { |
|
| 197 | + switch ($type) { |
|
| 198 | 198 | |
| 199 | 199 | case Wordlift_Schema_Service::DATA_TYPE_BOOLEAN: |
| 200 | 200 | |
@@ -204,31 +204,31 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | case Wordlift_Schema_Service::DATA_TYPE_DATE: |
| 206 | 206 | |
| 207 | - return sprintf( '"%s"^^xsd:date', self::escape( $value ) ); |
|
| 207 | + return sprintf('"%s"^^xsd:date', self::escape($value)); |
|
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | case Wordlift_Schema_Service::DATA_TYPE_DOUBLE: |
| 211 | 211 | |
| 212 | - return sprintf( '"%s"^^xsd:double', self::escape( $value ) ); |
|
| 212 | + return sprintf('"%s"^^xsd:double', self::escape($value)); |
|
| 213 | 213 | |
| 214 | 214 | case Wordlift_Schema_Service::DATA_TYPE_INTEGER: |
| 215 | 215 | |
| 216 | - return sprintf( '"%s"^^xsd:integer', self::escape( $value ) ); |
|
| 216 | + return sprintf('"%s"^^xsd:integer', self::escape($value)); |
|
| 217 | 217 | |
| 218 | 218 | case Wordlift_Schema_Service::DATA_TYPE_STRING: |
| 219 | 219 | |
| 220 | - return sprintf( '"%s"^^xsd:string', self::escape( $value ) ); |
|
| 220 | + return sprintf('"%s"^^xsd:string', self::escape($value)); |
|
| 221 | 221 | |
| 222 | 222 | case Wordlift_Schema_Service::DATA_TYPE_URI: |
| 223 | 223 | |
| 224 | - return sprintf( '<%s>', self::escape_uri( $value ) ); |
|
| 224 | + return sprintf('<%s>', self::escape_uri($value)); |
|
| 225 | 225 | |
| 226 | 226 | default: |
| 227 | 227 | |
| 228 | - $this->log->warn( "Unknown data type [ type :: $type ]" ); |
|
| 228 | + $this->log->warn("Unknown data type [ type :: $type ]"); |
|
| 229 | 229 | |
| 230 | 230 | // Try to insert the value anyway. |
| 231 | - return sprintf( '"%s"', self::escape( $value ) ); |
|
| 231 | + return sprintf('"%s"', self::escape($value)); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | } |
@@ -242,13 +242,13 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @return string The escaped URI. |
| 244 | 244 | */ |
| 245 | - public static function escape_uri( $uri ) { |
|
| 245 | + public static function escape_uri($uri) { |
|
| 246 | 246 | |
| 247 | 247 | // Should we validate the IRI? |
| 248 | 248 | // http://www.w3.org/TR/sparql11-query/#QSynIRI |
| 249 | 249 | |
| 250 | - $uri = str_replace( '<', '\<', $uri ); |
|
| 251 | - $uri = str_replace( '>', '\>', $uri ); |
|
| 250 | + $uri = str_replace('<', '\<', $uri); |
|
| 251 | + $uri = str_replace('>', '\>', $uri); |
|
| 252 | 252 | |
| 253 | 253 | return $uri; |
| 254 | 254 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * |
| 263 | 263 | * @return string The escaped string. |
| 264 | 264 | */ |
| 265 | - public static function escape( $string ) { |
|
| 265 | + public static function escape($string) { |
|
| 266 | 266 | |
| 267 | 267 | // see http://www.w3.org/TR/rdf-sparql-query/ |
| 268 | 268 | // '\t' U+0009 (tab) |
@@ -274,14 +274,14 @@ discard block |
||
| 274 | 274 | // "\'" U+0027 (apostrophe-quote, single quote mark) |
| 275 | 275 | // '\\' U+005C (backslash) |
| 276 | 276 | |
| 277 | - $string = str_replace( '\\', '\\\\', $string ); |
|
| 278 | - $string = str_replace( '\'', '\\\'', $string ); |
|
| 279 | - $string = str_replace( '"', '\\"', $string ); |
|
| 280 | - $string = str_replace( "\f", '\\f', $string ); |
|
| 281 | - $string = str_replace( "\b", '\\b', $string ); |
|
| 282 | - $string = str_replace( "\r", '\\r', $string ); |
|
| 283 | - $string = str_replace( "\n", '\\n', $string ); |
|
| 284 | - $string = str_replace( "\t", '\\t', $string ); |
|
| 277 | + $string = str_replace('\\', '\\\\', $string); |
|
| 278 | + $string = str_replace('\'', '\\\'', $string); |
|
| 279 | + $string = str_replace('"', '\\"', $string); |
|
| 280 | + $string = str_replace("\f", '\\f', $string); |
|
| 281 | + $string = str_replace("\b", '\\b', $string); |
|
| 282 | + $string = str_replace("\r", '\\r', $string); |
|
| 283 | + $string = str_replace("\n", '\\n', $string); |
|
| 284 | + $string = str_replace("\t", '\\t', $string); |
|
| 285 | 285 | |
| 286 | 286 | return $string; |
| 287 | 287 | } |
@@ -12,181 +12,181 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Wordlift_Import_Service { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * A {@link Wordlift_Log_Service} instance. |
|
| 17 | - * |
|
| 18 | - * @since 3.6.0 |
|
| 19 | - * @access private |
|
| 20 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 21 | - */ |
|
| 22 | - private $log; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 26 | - * |
|
| 27 | - * @since 3.6.0 |
|
| 28 | - * @access private |
|
| 29 | - * @var \Wordlift_Entity_Post_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 30 | - */ |
|
| 31 | - private $entity_type_service; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * The entity service instance. |
|
| 35 | - * |
|
| 36 | - * @since 3.6.0 |
|
| 37 | - * @access private |
|
| 38 | - * @var \Wordlift_Entity_Service $entity_service The entity service instance. |
|
| 39 | - */ |
|
| 40 | - private $entity_service; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The schema service instance. |
|
| 44 | - * |
|
| 45 | - * @since 3.6.0 |
|
| 46 | - * @access private |
|
| 47 | - * @var \Wordlift_Schema_Service $schema_service The schema service instance. |
|
| 48 | - */ |
|
| 49 | - private $schema_service; |
|
| 50 | - |
|
| 51 | - private $sparql_service; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * The dataset URI for this WordPress web site. |
|
| 55 | - * |
|
| 56 | - * @since 3.6.0 |
|
| 57 | - * @access private |
|
| 58 | - * @var string $dataset_uri The dataset URI for this WordPress web site. |
|
| 59 | - */ |
|
| 60 | - private $dataset_uri; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Create a Wordlift_Import_Service instance. |
|
| 64 | - * |
|
| 65 | - * @since 3.6.0 |
|
| 66 | - * |
|
| 67 | - * @param \Wordlift_Entity_Post_Type_Service $entity_type_service |
|
| 68 | - * @param \Wordlift_Entity_Service $entity_service |
|
| 69 | - * @param \Wordlift_Schema_Service $schema_service |
|
| 70 | - * @param \Wordlift_Sparql_Service $sparql_service |
|
| 71 | - * @param string $dataset_uri |
|
| 72 | - */ |
|
| 73 | - public function __construct( $entity_type_service, $entity_service, $schema_service, $sparql_service, $dataset_uri ) { |
|
| 74 | - |
|
| 75 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Import_Service' ); |
|
| 76 | - |
|
| 77 | - $this->entity_type_service = $entity_type_service; |
|
| 78 | - $this->entity_service = $entity_service; |
|
| 79 | - $this->schema_service = $schema_service; |
|
| 80 | - $this->sparql_service = $sparql_service; |
|
| 81 | - $this->dataset_uri = $dataset_uri; |
|
| 82 | - |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Handle the `wp_import_post_meta` filter by checking the `entity_url` meta. |
|
| 87 | - * If the `entity_url` meta value is not within the WP web site dataset URI, |
|
| 88 | - * it is changed into an `entity_same_as` meta key. |
|
| 89 | - * |
|
| 90 | - * @since 3.6.0 |
|
| 91 | - * |
|
| 92 | - * @param array $postmeta An array of indexed post meta. |
|
| 93 | - * @param int $post_id The post ID being imported. |
|
| 94 | - * @param array $post An array of post properties. |
|
| 95 | - * |
|
| 96 | - * @return array An array of indexed post meta. |
|
| 97 | - */ |
|
| 98 | - public function wp_import_post_meta( $postmeta, $post_id, $post ) { |
|
| 99 | - |
|
| 100 | - // If we're not dealing with entity posts, return the original post meta. |
|
| 101 | - if ( $post['post_type'] !== $this->entity_type_service->get_post_type() ) { |
|
| 102 | - return $postmeta; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - // Get a reference to the entity URL meta. |
|
| 106 | - $entity_url_meta = NULL; |
|
| 107 | - |
|
| 108 | - foreach ( $postmeta as &$meta ) { |
|
| 109 | - if ( 'entity_url' === $meta['key'] ) { |
|
| 110 | - $entity_url_meta = &$meta; |
|
| 111 | - break; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - // If the entity URI is within the dataset URI, we don't change anything. |
|
| 116 | - if ( NULL === $entity_url_meta || 0 === strpos( $entity_url_meta['value'], $this->dataset_uri ) ) { |
|
| 117 | - return $postmeta; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - // Since the entity URL doesn't belong to this WP install, as the dataset |
|
| 121 | - // URI doesn't match the start of the entity URL, we turn the entity URL |
|
| 122 | - // meta to an entity sameAs. $entity_url_meta is a reference so it should |
|
| 123 | - // update the item in the postmeta array directly. |
|
| 124 | - $entity_url_meta['key'] = 'entity_same_as'; |
|
| 125 | - |
|
| 126 | - return $postmeta; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * Catch post meta updates. |
|
| 131 | - * |
|
| 132 | - * @since 3.6.0 |
|
| 133 | - * |
|
| 134 | - * @param int $mid The meta ID after successful update. |
|
| 135 | - * @param int $object_id Object ID. |
|
| 136 | - * @param string $meta_key Meta key. |
|
| 137 | - * @param mixed $meta_value Meta value. |
|
| 138 | - */ |
|
| 139 | - public function added_post_meta( $mid, $object_id, $meta_key, $meta_value ) { |
|
| 140 | - |
|
| 141 | - // Get the entity URI. |
|
| 142 | - $s = $this->entity_service->get_uri( $object_id ); |
|
| 143 | - |
|
| 144 | - // Get the field with the specified meta key. Return if the field is not defined. |
|
| 145 | - if ( NULL === ( $field = $this->schema_service->get_field( $meta_key ) ) ) { |
|
| 146 | - return; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - // Get the field predicate. |
|
| 150 | - $p = $field['predicate']; |
|
| 151 | - |
|
| 152 | - // Format the object value according to the field type. |
|
| 153 | - $o = $this->sparql_service->format( $meta_value, $field['type'] ); |
|
| 154 | - |
|
| 155 | - // Create the statement. |
|
| 156 | - $stmt = sprintf( 'INSERT DATA { <%s> <%s> %s };', Wordlift_Sparql_Service::escape_uri( $s ), Wordlift_Sparql_Service::escape_uri( $p ), $o ); |
|
| 157 | - |
|
| 158 | - // Finally queue the statement. |
|
| 159 | - $this->sparql_service->execute( $stmt ); |
|
| 160 | - |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * When an import is running, hook the {@link added_post_meta} function in order |
|
| 165 | - * to insert metadata from an import in Linked Data. |
|
| 166 | - * |
|
| 167 | - * @since 3.6.0 |
|
| 168 | - */ |
|
| 169 | - public function import_start() { |
|
| 170 | - |
|
| 171 | - add_action( 'added_post_meta', array( |
|
| 172 | - $this, |
|
| 173 | - 'added_post_meta' |
|
| 174 | - ), 10, 4 ); |
|
| 175 | - |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * When an import ends, remove the hook previously added by {@link import_start}. |
|
| 180 | - * |
|
| 181 | - * @since 3.6.0 |
|
| 182 | - */ |
|
| 183 | - public function import_end() { |
|
| 184 | - |
|
| 185 | - remove_action( 'added_post_meta', array( |
|
| 186 | - $this, |
|
| 187 | - 'added_post_meta' |
|
| 188 | - ), 10 ); |
|
| 189 | - |
|
| 190 | - } |
|
| 15 | + /** |
|
| 16 | + * A {@link Wordlift_Log_Service} instance. |
|
| 17 | + * |
|
| 18 | + * @since 3.6.0 |
|
| 19 | + * @access private |
|
| 20 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 21 | + */ |
|
| 22 | + private $log; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 26 | + * |
|
| 27 | + * @since 3.6.0 |
|
| 28 | + * @access private |
|
| 29 | + * @var \Wordlift_Entity_Post_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 30 | + */ |
|
| 31 | + private $entity_type_service; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * The entity service instance. |
|
| 35 | + * |
|
| 36 | + * @since 3.6.0 |
|
| 37 | + * @access private |
|
| 38 | + * @var \Wordlift_Entity_Service $entity_service The entity service instance. |
|
| 39 | + */ |
|
| 40 | + private $entity_service; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The schema service instance. |
|
| 44 | + * |
|
| 45 | + * @since 3.6.0 |
|
| 46 | + * @access private |
|
| 47 | + * @var \Wordlift_Schema_Service $schema_service The schema service instance. |
|
| 48 | + */ |
|
| 49 | + private $schema_service; |
|
| 50 | + |
|
| 51 | + private $sparql_service; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * The dataset URI for this WordPress web site. |
|
| 55 | + * |
|
| 56 | + * @since 3.6.0 |
|
| 57 | + * @access private |
|
| 58 | + * @var string $dataset_uri The dataset URI for this WordPress web site. |
|
| 59 | + */ |
|
| 60 | + private $dataset_uri; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Create a Wordlift_Import_Service instance. |
|
| 64 | + * |
|
| 65 | + * @since 3.6.0 |
|
| 66 | + * |
|
| 67 | + * @param \Wordlift_Entity_Post_Type_Service $entity_type_service |
|
| 68 | + * @param \Wordlift_Entity_Service $entity_service |
|
| 69 | + * @param \Wordlift_Schema_Service $schema_service |
|
| 70 | + * @param \Wordlift_Sparql_Service $sparql_service |
|
| 71 | + * @param string $dataset_uri |
|
| 72 | + */ |
|
| 73 | + public function __construct( $entity_type_service, $entity_service, $schema_service, $sparql_service, $dataset_uri ) { |
|
| 74 | + |
|
| 75 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Import_Service' ); |
|
| 76 | + |
|
| 77 | + $this->entity_type_service = $entity_type_service; |
|
| 78 | + $this->entity_service = $entity_service; |
|
| 79 | + $this->schema_service = $schema_service; |
|
| 80 | + $this->sparql_service = $sparql_service; |
|
| 81 | + $this->dataset_uri = $dataset_uri; |
|
| 82 | + |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Handle the `wp_import_post_meta` filter by checking the `entity_url` meta. |
|
| 87 | + * If the `entity_url` meta value is not within the WP web site dataset URI, |
|
| 88 | + * it is changed into an `entity_same_as` meta key. |
|
| 89 | + * |
|
| 90 | + * @since 3.6.0 |
|
| 91 | + * |
|
| 92 | + * @param array $postmeta An array of indexed post meta. |
|
| 93 | + * @param int $post_id The post ID being imported. |
|
| 94 | + * @param array $post An array of post properties. |
|
| 95 | + * |
|
| 96 | + * @return array An array of indexed post meta. |
|
| 97 | + */ |
|
| 98 | + public function wp_import_post_meta( $postmeta, $post_id, $post ) { |
|
| 99 | + |
|
| 100 | + // If we're not dealing with entity posts, return the original post meta. |
|
| 101 | + if ( $post['post_type'] !== $this->entity_type_service->get_post_type() ) { |
|
| 102 | + return $postmeta; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + // Get a reference to the entity URL meta. |
|
| 106 | + $entity_url_meta = NULL; |
|
| 107 | + |
|
| 108 | + foreach ( $postmeta as &$meta ) { |
|
| 109 | + if ( 'entity_url' === $meta['key'] ) { |
|
| 110 | + $entity_url_meta = &$meta; |
|
| 111 | + break; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + // If the entity URI is within the dataset URI, we don't change anything. |
|
| 116 | + if ( NULL === $entity_url_meta || 0 === strpos( $entity_url_meta['value'], $this->dataset_uri ) ) { |
|
| 117 | + return $postmeta; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + // Since the entity URL doesn't belong to this WP install, as the dataset |
|
| 121 | + // URI doesn't match the start of the entity URL, we turn the entity URL |
|
| 122 | + // meta to an entity sameAs. $entity_url_meta is a reference so it should |
|
| 123 | + // update the item in the postmeta array directly. |
|
| 124 | + $entity_url_meta['key'] = 'entity_same_as'; |
|
| 125 | + |
|
| 126 | + return $postmeta; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * Catch post meta updates. |
|
| 131 | + * |
|
| 132 | + * @since 3.6.0 |
|
| 133 | + * |
|
| 134 | + * @param int $mid The meta ID after successful update. |
|
| 135 | + * @param int $object_id Object ID. |
|
| 136 | + * @param string $meta_key Meta key. |
|
| 137 | + * @param mixed $meta_value Meta value. |
|
| 138 | + */ |
|
| 139 | + public function added_post_meta( $mid, $object_id, $meta_key, $meta_value ) { |
|
| 140 | + |
|
| 141 | + // Get the entity URI. |
|
| 142 | + $s = $this->entity_service->get_uri( $object_id ); |
|
| 143 | + |
|
| 144 | + // Get the field with the specified meta key. Return if the field is not defined. |
|
| 145 | + if ( NULL === ( $field = $this->schema_service->get_field( $meta_key ) ) ) { |
|
| 146 | + return; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + // Get the field predicate. |
|
| 150 | + $p = $field['predicate']; |
|
| 151 | + |
|
| 152 | + // Format the object value according to the field type. |
|
| 153 | + $o = $this->sparql_service->format( $meta_value, $field['type'] ); |
|
| 154 | + |
|
| 155 | + // Create the statement. |
|
| 156 | + $stmt = sprintf( 'INSERT DATA { <%s> <%s> %s };', Wordlift_Sparql_Service::escape_uri( $s ), Wordlift_Sparql_Service::escape_uri( $p ), $o ); |
|
| 157 | + |
|
| 158 | + // Finally queue the statement. |
|
| 159 | + $this->sparql_service->execute( $stmt ); |
|
| 160 | + |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * When an import is running, hook the {@link added_post_meta} function in order |
|
| 165 | + * to insert metadata from an import in Linked Data. |
|
| 166 | + * |
|
| 167 | + * @since 3.6.0 |
|
| 168 | + */ |
|
| 169 | + public function import_start() { |
|
| 170 | + |
|
| 171 | + add_action( 'added_post_meta', array( |
|
| 172 | + $this, |
|
| 173 | + 'added_post_meta' |
|
| 174 | + ), 10, 4 ); |
|
| 175 | + |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * When an import ends, remove the hook previously added by {@link import_start}. |
|
| 180 | + * |
|
| 181 | + * @since 3.6.0 |
|
| 182 | + */ |
|
| 183 | + public function import_end() { |
|
| 184 | + |
|
| 185 | + remove_action( 'added_post_meta', array( |
|
| 186 | + $this, |
|
| 187 | + 'added_post_meta' |
|
| 188 | + ), 10 ); |
|
| 189 | + |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | 192 | } |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | * @param \Wordlift_Sparql_Service $sparql_service |
| 71 | 71 | * @param string $dataset_uri |
| 72 | 72 | */ |
| 73 | - public function __construct( $entity_type_service, $entity_service, $schema_service, $sparql_service, $dataset_uri ) { |
|
| 73 | + public function __construct($entity_type_service, $entity_service, $schema_service, $sparql_service, $dataset_uri) { |
|
| 74 | 74 | |
| 75 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Import_Service' ); |
|
| 75 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Import_Service'); |
|
| 76 | 76 | |
| 77 | 77 | $this->entity_type_service = $entity_type_service; |
| 78 | 78 | $this->entity_service = $entity_service; |
@@ -95,25 +95,25 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @return array An array of indexed post meta. |
| 97 | 97 | */ |
| 98 | - public function wp_import_post_meta( $postmeta, $post_id, $post ) { |
|
| 98 | + public function wp_import_post_meta($postmeta, $post_id, $post) { |
|
| 99 | 99 | |
| 100 | 100 | // If we're not dealing with entity posts, return the original post meta. |
| 101 | - if ( $post['post_type'] !== $this->entity_type_service->get_post_type() ) { |
|
| 101 | + if ($post['post_type'] !== $this->entity_type_service->get_post_type()) { |
|
| 102 | 102 | return $postmeta; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Get a reference to the entity URL meta. |
| 106 | 106 | $entity_url_meta = NULL; |
| 107 | 107 | |
| 108 | - foreach ( $postmeta as &$meta ) { |
|
| 109 | - if ( 'entity_url' === $meta['key'] ) { |
|
| 108 | + foreach ($postmeta as &$meta) { |
|
| 109 | + if ('entity_url' === $meta['key']) { |
|
| 110 | 110 | $entity_url_meta = &$meta; |
| 111 | 111 | break; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // If the entity URI is within the dataset URI, we don't change anything. |
| 116 | - if ( NULL === $entity_url_meta || 0 === strpos( $entity_url_meta['value'], $this->dataset_uri ) ) { |
|
| 116 | + if (NULL === $entity_url_meta || 0 === strpos($entity_url_meta['value'], $this->dataset_uri)) { |
|
| 117 | 117 | return $postmeta; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | * @param string $meta_key Meta key. |
| 137 | 137 | * @param mixed $meta_value Meta value. |
| 138 | 138 | */ |
| 139 | - public function added_post_meta( $mid, $object_id, $meta_key, $meta_value ) { |
|
| 139 | + public function added_post_meta($mid, $object_id, $meta_key, $meta_value) { |
|
| 140 | 140 | |
| 141 | 141 | // Get the entity URI. |
| 142 | - $s = $this->entity_service->get_uri( $object_id ); |
|
| 142 | + $s = $this->entity_service->get_uri($object_id); |
|
| 143 | 143 | |
| 144 | 144 | // Get the field with the specified meta key. Return if the field is not defined. |
| 145 | - if ( NULL === ( $field = $this->schema_service->get_field( $meta_key ) ) ) { |
|
| 145 | + if (NULL === ($field = $this->schema_service->get_field($meta_key))) { |
|
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | $p = $field['predicate']; |
| 151 | 151 | |
| 152 | 152 | // Format the object value according to the field type. |
| 153 | - $o = $this->sparql_service->format( $meta_value, $field['type'] ); |
|
| 153 | + $o = $this->sparql_service->format($meta_value, $field['type']); |
|
| 154 | 154 | |
| 155 | 155 | // Create the statement. |
| 156 | - $stmt = sprintf( 'INSERT DATA { <%s> <%s> %s };', Wordlift_Sparql_Service::escape_uri( $s ), Wordlift_Sparql_Service::escape_uri( $p ), $o ); |
|
| 156 | + $stmt = sprintf('INSERT DATA { <%s> <%s> %s };', Wordlift_Sparql_Service::escape_uri($s), Wordlift_Sparql_Service::escape_uri($p), $o); |
|
| 157 | 157 | |
| 158 | 158 | // Finally queue the statement. |
| 159 | - $this->sparql_service->execute( $stmt ); |
|
| 159 | + $this->sparql_service->execute($stmt); |
|
| 160 | 160 | |
| 161 | 161 | } |
| 162 | 162 | |
@@ -168,10 +168,10 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function import_start() { |
| 170 | 170 | |
| 171 | - add_action( 'added_post_meta', array( |
|
| 171 | + add_action('added_post_meta', array( |
|
| 172 | 172 | $this, |
| 173 | 173 | 'added_post_meta' |
| 174 | - ), 10, 4 ); |
|
| 174 | + ), 10, 4); |
|
| 175 | 175 | |
| 176 | 176 | } |
| 177 | 177 | |
@@ -182,10 +182,10 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | public function import_end() { |
| 184 | 184 | |
| 185 | - remove_action( 'added_post_meta', array( |
|
| 185 | + remove_action('added_post_meta', array( |
|
| 186 | 186 | $this, |
| 187 | 187 | 'added_post_meta' |
| 188 | - ), 10 ); |
|
| 188 | + ), 10); |
|
| 189 | 189 | |
| 190 | 190 | } |
| 191 | 191 | |
@@ -8,276 +8,276 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | if ( ! class_exists( 'WP_Async_Task' ) ) { |
| 11 | - abstract class WP_Async_Task { |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * Constant identifier for a task that should be available to logged-in users |
|
| 15 | - * |
|
| 16 | - * See constructor documentation for more details. |
|
| 17 | - */ |
|
| 18 | - const LOGGED_IN = 1; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Constant identifier for a task that should be available to logged-out users |
|
| 22 | - * |
|
| 23 | - * See constructor documentation for more details. |
|
| 24 | - */ |
|
| 25 | - const LOGGED_OUT = 2; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Constant identifier for a task that should be available to all users regardless of auth status |
|
| 29 | - * |
|
| 30 | - * See constructor documentation for more details. |
|
| 31 | - */ |
|
| 32 | - const BOTH = 3; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * This is the argument count for the main action set in the constructor. It |
|
| 36 | - * is set to an arbitrarily high value of twenty, but can be overridden if |
|
| 37 | - * necessary |
|
| 38 | - * |
|
| 39 | - * @var int |
|
| 40 | - */ |
|
| 41 | - protected $argument_count = 20; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Priority to fire intermediate action. |
|
| 45 | - * |
|
| 46 | - * @var int |
|
| 47 | - */ |
|
| 48 | - protected $priority = 10; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 53 | - protected $action; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @var array |
|
| 57 | - */ |
|
| 58 | - protected $_body_data; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Constructor to wire up the necessary actions |
|
| 62 | - * |
|
| 63 | - * Which hooks the asynchronous postback happens on can be set by the |
|
| 64 | - * $auth_level parameter. There are essentially three options: logged in users |
|
| 65 | - * only, logged out users only, or both. Set this when you instantiate an |
|
| 66 | - * object by using one of the three class constants to do so: |
|
| 67 | - * - LOGGED_IN |
|
| 68 | - * - LOGGED_OUT |
|
| 69 | - * - BOTH |
|
| 70 | - * $auth_level defaults to BOTH |
|
| 71 | - * |
|
| 72 | - * @throws Exception If the class' $action value hasn't been set |
|
| 73 | - * |
|
| 74 | - * @param int $auth_level The authentication level to use (see above) |
|
| 75 | - */ |
|
| 76 | - public function __construct( $auth_level = self::BOTH ) { |
|
| 77 | - if ( empty( $this->action ) ) { |
|
| 78 | - throw new Exception( 'Action not defined for class ' . __CLASS__ ); |
|
| 79 | - } |
|
| 80 | - add_action( $this->action, array( |
|
| 81 | - $this, |
|
| 82 | - 'launch', |
|
| 83 | - ), (int) $this->priority, (int) $this->argument_count ); |
|
| 84 | - if ( $auth_level & self::LOGGED_IN ) { |
|
| 85 | - add_action( "admin_post_wp_async_$this->action", array( |
|
| 86 | - $this, |
|
| 87 | - 'handle_postback', |
|
| 88 | - ) ); |
|
| 89 | - } |
|
| 90 | - if ( $auth_level & self::LOGGED_OUT ) { |
|
| 91 | - add_action( "admin_post_nopriv_wp_async_$this->action", array( |
|
| 92 | - $this, |
|
| 93 | - 'handle_postback', |
|
| 94 | - ) ); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Add the shutdown action for launching the real postback if we don't |
|
| 100 | - * get an exception thrown by prepare_data(). |
|
| 101 | - * |
|
| 102 | - * @uses func_get_args() To grab any arguments passed by the action |
|
| 103 | - */ |
|
| 104 | - public function launch() { |
|
| 105 | - $data = func_get_args(); |
|
| 106 | - try { |
|
| 107 | - $data = $this->prepare_data( $data ); |
|
| 108 | - } catch ( Exception $e ) { |
|
| 109 | - return; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $data['action'] = "wp_async_$this->action"; |
|
| 113 | - $data['_nonce'] = $this->create_async_nonce(); |
|
| 114 | - |
|
| 115 | - $this->_body_data = $data; |
|
| 116 | - |
|
| 117 | - if ( ! has_action( 'shutdown', array( |
|
| 118 | - $this, |
|
| 119 | - 'launch_on_shutdown', |
|
| 120 | - ) ) |
|
| 121 | - ) { |
|
| 122 | - add_action( 'shutdown', array( $this, 'launch_on_shutdown' ) ); |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Launch the request on the WordPress shutdown hook |
|
| 128 | - * |
|
| 129 | - * On VIP we got into data races due to the postback sometimes completing |
|
| 130 | - * faster than the data could propogate to the database server cluster. |
|
| 131 | - * This made WordPress get empty data sets from the database without |
|
| 132 | - * failing. On their advice, we're moving the actual firing of the async |
|
| 133 | - * postback to the shutdown hook. Supposedly that will ensure that the |
|
| 134 | - * data at least has time to get into the object cache. |
|
| 135 | - * |
|
| 136 | - * @uses $_COOKIE To send a cookie header for async postback |
|
| 137 | - * @uses apply_filters() |
|
| 138 | - * @uses admin_url() |
|
| 139 | - * @uses wp_remote_post() |
|
| 140 | - */ |
|
| 141 | - public function launch_on_shutdown() { |
|
| 142 | - if ( ! empty( $this->_body_data ) ) { |
|
| 143 | - $cookies = array(); |
|
| 144 | - foreach ( $_COOKIE as $name => $value ) { |
|
| 145 | - $cookies[] = "$name=" . urlencode( is_array( $value ) ? serialize( $value ) : $value ); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - $request_args = array( |
|
| 149 | - 'timeout' => 0.01, |
|
| 150 | - 'blocking' => false, |
|
| 151 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', true ), |
|
| 152 | - 'body' => $this->_body_data, |
|
| 153 | - 'headers' => array( |
|
| 154 | - 'cookie' => implode( '; ', $cookies ), |
|
| 155 | - ), |
|
| 156 | - ); |
|
| 157 | - |
|
| 158 | - $url = admin_url( 'admin-post.php' ); |
|
| 159 | - |
|
| 160 | - error_log( "Launching [ url :: $url ][ " . var_export( $request_args, true ) . " ]..." ); |
|
| 161 | - error_log( var_export( wp_remote_post( $url, $request_args ), true ) ); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Verify the postback is valid, then fire any scheduled events. |
|
| 167 | - * |
|
| 168 | - * @uses $_POST['_nonce'] |
|
| 169 | - * @uses is_user_logged_in() |
|
| 170 | - * @uses add_filter() |
|
| 171 | - * @uses wp_die() |
|
| 172 | - */ |
|
| 173 | - public function handle_postback() { |
|
| 174 | - if ( isset( $_POST['_nonce'] ) && $this->verify_async_nonce( $_POST['_nonce'] ) ) { |
|
| 175 | - if ( ! is_user_logged_in() ) { |
|
| 176 | - $this->action = "nopriv_$this->action"; |
|
| 177 | - } |
|
| 178 | - $this->run_action(); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - add_filter( 'wp_die_handler', function () { |
|
| 182 | - die(); |
|
| 183 | - } ); |
|
| 184 | - wp_die(); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Create a random, one time use token. |
|
| 189 | - * |
|
| 190 | - * Based entirely on wp_create_nonce() but does not tie the nonce to the |
|
| 191 | - * current logged-in user. |
|
| 192 | - * |
|
| 193 | - * @uses wp_nonce_tick() |
|
| 194 | - * @uses wp_hash() |
|
| 195 | - * |
|
| 196 | - * @return string The one-time use token |
|
| 197 | - */ |
|
| 198 | - protected function create_async_nonce() { |
|
| 199 | - $action = $this->get_nonce_action(); |
|
| 200 | - $i = wp_nonce_tick(); |
|
| 201 | - |
|
| 202 | - return substr( wp_hash( $i . $action . get_class( $this ), 'nonce' ), - 12, 10 ); |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * Verify that the correct nonce was used within the time limit. |
|
| 207 | - * |
|
| 208 | - * @uses wp_nonce_tick() |
|
| 209 | - * @uses wp_hash() |
|
| 210 | - * |
|
| 211 | - * @param string $nonce Nonce to be verified |
|
| 212 | - * |
|
| 213 | - * @return bool Whether the nonce check passed or failed |
|
| 214 | - */ |
|
| 215 | - protected function verify_async_nonce( $nonce ) { |
|
| 216 | - $action = $this->get_nonce_action(); |
|
| 217 | - $i = wp_nonce_tick(); |
|
| 218 | - |
|
| 219 | - // Nonce generated 0-12 hours ago |
|
| 220 | - if ( substr( wp_hash( $i . $action . get_class( $this ), 'nonce' ), - 12, 10 ) == $nonce ) { |
|
| 221 | - return 1; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - // Nonce generated 12-24 hours ago |
|
| 225 | - if ( substr( wp_hash( ( $i - 1 ) . $action . get_class( $this ), 'nonce' ), - 12, 10 ) == $nonce ) { |
|
| 226 | - return 2; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - // Invalid nonce |
|
| 230 | - return false; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * Get a nonce action based on the $action property of the class |
|
| 235 | - * |
|
| 236 | - * @return string The nonce action for the current instance |
|
| 237 | - */ |
|
| 238 | - protected function get_nonce_action() { |
|
| 239 | - $action = $this->action; |
|
| 240 | - if ( substr( $action, 0, 7 ) === 'nopriv_' ) { |
|
| 241 | - $action = substr( $action, 7 ); |
|
| 242 | - } |
|
| 243 | - $action = "wp_async_$action"; |
|
| 244 | - |
|
| 245 | - return $action; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * Prepare any data to be passed to the asynchronous postback |
|
| 250 | - * |
|
| 251 | - * The array this function receives will be a numerically keyed array from |
|
| 252 | - * func_get_args(). It is expected that you will return an associative array |
|
| 253 | - * so that the $_POST values used in the asynchronous call will make sense. |
|
| 254 | - * |
|
| 255 | - * The array you send back may or may not have anything to do with the data |
|
| 256 | - * passed into this method. It all depends on the implementation details and |
|
| 257 | - * what data is needed in the asynchronous postback. |
|
| 258 | - * |
|
| 259 | - * Do not set values for 'action' or '_nonce', as those will get overwritten |
|
| 260 | - * later in launch(). |
|
| 261 | - * |
|
| 262 | - * @throws Exception If the postback should not occur for any reason |
|
| 263 | - * |
|
| 264 | - * @param array $data The raw data received by the launch method |
|
| 265 | - * |
|
| 266 | - * @return array The prepared data |
|
| 267 | - */ |
|
| 268 | - abstract protected function prepare_data( $data ); |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * Run the do_action function for the asynchronous postback. |
|
| 272 | - * |
|
| 273 | - * This method needs to fetch and sanitize any and all data from the $_POST |
|
| 274 | - * superglobal and provide them to the do_action call. |
|
| 275 | - * |
|
| 276 | - * The action should be constructed as "wp_async_task_$this->action" |
|
| 277 | - */ |
|
| 278 | - abstract protected function run_action(); |
|
| 279 | - |
|
| 280 | - } |
|
| 11 | + abstract class WP_Async_Task { |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * Constant identifier for a task that should be available to logged-in users |
|
| 15 | + * |
|
| 16 | + * See constructor documentation for more details. |
|
| 17 | + */ |
|
| 18 | + const LOGGED_IN = 1; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Constant identifier for a task that should be available to logged-out users |
|
| 22 | + * |
|
| 23 | + * See constructor documentation for more details. |
|
| 24 | + */ |
|
| 25 | + const LOGGED_OUT = 2; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Constant identifier for a task that should be available to all users regardless of auth status |
|
| 29 | + * |
|
| 30 | + * See constructor documentation for more details. |
|
| 31 | + */ |
|
| 32 | + const BOTH = 3; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * This is the argument count for the main action set in the constructor. It |
|
| 36 | + * is set to an arbitrarily high value of twenty, but can be overridden if |
|
| 37 | + * necessary |
|
| 38 | + * |
|
| 39 | + * @var int |
|
| 40 | + */ |
|
| 41 | + protected $argument_count = 20; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Priority to fire intermediate action. |
|
| 45 | + * |
|
| 46 | + * @var int |
|
| 47 | + */ |
|
| 48 | + protected $priority = 10; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | + protected $action; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @var array |
|
| 57 | + */ |
|
| 58 | + protected $_body_data; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Constructor to wire up the necessary actions |
|
| 62 | + * |
|
| 63 | + * Which hooks the asynchronous postback happens on can be set by the |
|
| 64 | + * $auth_level parameter. There are essentially three options: logged in users |
|
| 65 | + * only, logged out users only, or both. Set this when you instantiate an |
|
| 66 | + * object by using one of the three class constants to do so: |
|
| 67 | + * - LOGGED_IN |
|
| 68 | + * - LOGGED_OUT |
|
| 69 | + * - BOTH |
|
| 70 | + * $auth_level defaults to BOTH |
|
| 71 | + * |
|
| 72 | + * @throws Exception If the class' $action value hasn't been set |
|
| 73 | + * |
|
| 74 | + * @param int $auth_level The authentication level to use (see above) |
|
| 75 | + */ |
|
| 76 | + public function __construct( $auth_level = self::BOTH ) { |
|
| 77 | + if ( empty( $this->action ) ) { |
|
| 78 | + throw new Exception( 'Action not defined for class ' . __CLASS__ ); |
|
| 79 | + } |
|
| 80 | + add_action( $this->action, array( |
|
| 81 | + $this, |
|
| 82 | + 'launch', |
|
| 83 | + ), (int) $this->priority, (int) $this->argument_count ); |
|
| 84 | + if ( $auth_level & self::LOGGED_IN ) { |
|
| 85 | + add_action( "admin_post_wp_async_$this->action", array( |
|
| 86 | + $this, |
|
| 87 | + 'handle_postback', |
|
| 88 | + ) ); |
|
| 89 | + } |
|
| 90 | + if ( $auth_level & self::LOGGED_OUT ) { |
|
| 91 | + add_action( "admin_post_nopriv_wp_async_$this->action", array( |
|
| 92 | + $this, |
|
| 93 | + 'handle_postback', |
|
| 94 | + ) ); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Add the shutdown action for launching the real postback if we don't |
|
| 100 | + * get an exception thrown by prepare_data(). |
|
| 101 | + * |
|
| 102 | + * @uses func_get_args() To grab any arguments passed by the action |
|
| 103 | + */ |
|
| 104 | + public function launch() { |
|
| 105 | + $data = func_get_args(); |
|
| 106 | + try { |
|
| 107 | + $data = $this->prepare_data( $data ); |
|
| 108 | + } catch ( Exception $e ) { |
|
| 109 | + return; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $data['action'] = "wp_async_$this->action"; |
|
| 113 | + $data['_nonce'] = $this->create_async_nonce(); |
|
| 114 | + |
|
| 115 | + $this->_body_data = $data; |
|
| 116 | + |
|
| 117 | + if ( ! has_action( 'shutdown', array( |
|
| 118 | + $this, |
|
| 119 | + 'launch_on_shutdown', |
|
| 120 | + ) ) |
|
| 121 | + ) { |
|
| 122 | + add_action( 'shutdown', array( $this, 'launch_on_shutdown' ) ); |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Launch the request on the WordPress shutdown hook |
|
| 128 | + * |
|
| 129 | + * On VIP we got into data races due to the postback sometimes completing |
|
| 130 | + * faster than the data could propogate to the database server cluster. |
|
| 131 | + * This made WordPress get empty data sets from the database without |
|
| 132 | + * failing. On their advice, we're moving the actual firing of the async |
|
| 133 | + * postback to the shutdown hook. Supposedly that will ensure that the |
|
| 134 | + * data at least has time to get into the object cache. |
|
| 135 | + * |
|
| 136 | + * @uses $_COOKIE To send a cookie header for async postback |
|
| 137 | + * @uses apply_filters() |
|
| 138 | + * @uses admin_url() |
|
| 139 | + * @uses wp_remote_post() |
|
| 140 | + */ |
|
| 141 | + public function launch_on_shutdown() { |
|
| 142 | + if ( ! empty( $this->_body_data ) ) { |
|
| 143 | + $cookies = array(); |
|
| 144 | + foreach ( $_COOKIE as $name => $value ) { |
|
| 145 | + $cookies[] = "$name=" . urlencode( is_array( $value ) ? serialize( $value ) : $value ); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + $request_args = array( |
|
| 149 | + 'timeout' => 0.01, |
|
| 150 | + 'blocking' => false, |
|
| 151 | + 'sslverify' => apply_filters( 'https_local_ssl_verify', true ), |
|
| 152 | + 'body' => $this->_body_data, |
|
| 153 | + 'headers' => array( |
|
| 154 | + 'cookie' => implode( '; ', $cookies ), |
|
| 155 | + ), |
|
| 156 | + ); |
|
| 157 | + |
|
| 158 | + $url = admin_url( 'admin-post.php' ); |
|
| 159 | + |
|
| 160 | + error_log( "Launching [ url :: $url ][ " . var_export( $request_args, true ) . " ]..." ); |
|
| 161 | + error_log( var_export( wp_remote_post( $url, $request_args ), true ) ); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Verify the postback is valid, then fire any scheduled events. |
|
| 167 | + * |
|
| 168 | + * @uses $_POST['_nonce'] |
|
| 169 | + * @uses is_user_logged_in() |
|
| 170 | + * @uses add_filter() |
|
| 171 | + * @uses wp_die() |
|
| 172 | + */ |
|
| 173 | + public function handle_postback() { |
|
| 174 | + if ( isset( $_POST['_nonce'] ) && $this->verify_async_nonce( $_POST['_nonce'] ) ) { |
|
| 175 | + if ( ! is_user_logged_in() ) { |
|
| 176 | + $this->action = "nopriv_$this->action"; |
|
| 177 | + } |
|
| 178 | + $this->run_action(); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + add_filter( 'wp_die_handler', function () { |
|
| 182 | + die(); |
|
| 183 | + } ); |
|
| 184 | + wp_die(); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Create a random, one time use token. |
|
| 189 | + * |
|
| 190 | + * Based entirely on wp_create_nonce() but does not tie the nonce to the |
|
| 191 | + * current logged-in user. |
|
| 192 | + * |
|
| 193 | + * @uses wp_nonce_tick() |
|
| 194 | + * @uses wp_hash() |
|
| 195 | + * |
|
| 196 | + * @return string The one-time use token |
|
| 197 | + */ |
|
| 198 | + protected function create_async_nonce() { |
|
| 199 | + $action = $this->get_nonce_action(); |
|
| 200 | + $i = wp_nonce_tick(); |
|
| 201 | + |
|
| 202 | + return substr( wp_hash( $i . $action . get_class( $this ), 'nonce' ), - 12, 10 ); |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * Verify that the correct nonce was used within the time limit. |
|
| 207 | + * |
|
| 208 | + * @uses wp_nonce_tick() |
|
| 209 | + * @uses wp_hash() |
|
| 210 | + * |
|
| 211 | + * @param string $nonce Nonce to be verified |
|
| 212 | + * |
|
| 213 | + * @return bool Whether the nonce check passed or failed |
|
| 214 | + */ |
|
| 215 | + protected function verify_async_nonce( $nonce ) { |
|
| 216 | + $action = $this->get_nonce_action(); |
|
| 217 | + $i = wp_nonce_tick(); |
|
| 218 | + |
|
| 219 | + // Nonce generated 0-12 hours ago |
|
| 220 | + if ( substr( wp_hash( $i . $action . get_class( $this ), 'nonce' ), - 12, 10 ) == $nonce ) { |
|
| 221 | + return 1; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + // Nonce generated 12-24 hours ago |
|
| 225 | + if ( substr( wp_hash( ( $i - 1 ) . $action . get_class( $this ), 'nonce' ), - 12, 10 ) == $nonce ) { |
|
| 226 | + return 2; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + // Invalid nonce |
|
| 230 | + return false; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * Get a nonce action based on the $action property of the class |
|
| 235 | + * |
|
| 236 | + * @return string The nonce action for the current instance |
|
| 237 | + */ |
|
| 238 | + protected function get_nonce_action() { |
|
| 239 | + $action = $this->action; |
|
| 240 | + if ( substr( $action, 0, 7 ) === 'nopriv_' ) { |
|
| 241 | + $action = substr( $action, 7 ); |
|
| 242 | + } |
|
| 243 | + $action = "wp_async_$action"; |
|
| 244 | + |
|
| 245 | + return $action; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * Prepare any data to be passed to the asynchronous postback |
|
| 250 | + * |
|
| 251 | + * The array this function receives will be a numerically keyed array from |
|
| 252 | + * func_get_args(). It is expected that you will return an associative array |
|
| 253 | + * so that the $_POST values used in the asynchronous call will make sense. |
|
| 254 | + * |
|
| 255 | + * The array you send back may or may not have anything to do with the data |
|
| 256 | + * passed into this method. It all depends on the implementation details and |
|
| 257 | + * what data is needed in the asynchronous postback. |
|
| 258 | + * |
|
| 259 | + * Do not set values for 'action' or '_nonce', as those will get overwritten |
|
| 260 | + * later in launch(). |
|
| 261 | + * |
|
| 262 | + * @throws Exception If the postback should not occur for any reason |
|
| 263 | + * |
|
| 264 | + * @param array $data The raw data received by the launch method |
|
| 265 | + * |
|
| 266 | + * @return array The prepared data |
|
| 267 | + */ |
|
| 268 | + abstract protected function prepare_data( $data ); |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * Run the do_action function for the asynchronous postback. |
|
| 272 | + * |
|
| 273 | + * This method needs to fetch and sanitize any and all data from the $_POST |
|
| 274 | + * superglobal and provide them to the do_action call. |
|
| 275 | + * |
|
| 276 | + * The action should be constructed as "wp_async_task_$this->action" |
|
| 277 | + */ |
|
| 278 | + abstract protected function run_action(); |
|
| 279 | + |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | 282 | } |
| 283 | 283 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * License: MIT |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! class_exists( 'WP_Async_Task' ) ) { |
|
| 10 | +if ( ! class_exists('WP_Async_Task')) { |
|
| 11 | 11 | abstract class WP_Async_Task { |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -73,25 +73,25 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @param int $auth_level The authentication level to use (see above) |
| 75 | 75 | */ |
| 76 | - public function __construct( $auth_level = self::BOTH ) { |
|
| 77 | - if ( empty( $this->action ) ) { |
|
| 78 | - throw new Exception( 'Action not defined for class ' . __CLASS__ ); |
|
| 76 | + public function __construct($auth_level = self::BOTH) { |
|
| 77 | + if (empty($this->action)) { |
|
| 78 | + throw new Exception('Action not defined for class '.__CLASS__); |
|
| 79 | 79 | } |
| 80 | - add_action( $this->action, array( |
|
| 80 | + add_action($this->action, array( |
|
| 81 | 81 | $this, |
| 82 | 82 | 'launch', |
| 83 | - ), (int) $this->priority, (int) $this->argument_count ); |
|
| 84 | - if ( $auth_level & self::LOGGED_IN ) { |
|
| 85 | - add_action( "admin_post_wp_async_$this->action", array( |
|
| 83 | + ), (int) $this->priority, (int) $this->argument_count); |
|
| 84 | + if ($auth_level & self::LOGGED_IN) { |
|
| 85 | + add_action("admin_post_wp_async_$this->action", array( |
|
| 86 | 86 | $this, |
| 87 | 87 | 'handle_postback', |
| 88 | - ) ); |
|
| 88 | + )); |
|
| 89 | 89 | } |
| 90 | - if ( $auth_level & self::LOGGED_OUT ) { |
|
| 91 | - add_action( "admin_post_nopriv_wp_async_$this->action", array( |
|
| 90 | + if ($auth_level & self::LOGGED_OUT) { |
|
| 91 | + add_action("admin_post_nopriv_wp_async_$this->action", array( |
|
| 92 | 92 | $this, |
| 93 | 93 | 'handle_postback', |
| 94 | - ) ); |
|
| 94 | + )); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | public function launch() { |
| 105 | 105 | $data = func_get_args(); |
| 106 | 106 | try { |
| 107 | - $data = $this->prepare_data( $data ); |
|
| 108 | - } catch ( Exception $e ) { |
|
| 107 | + $data = $this->prepare_data($data); |
|
| 108 | + } catch (Exception $e) { |
|
| 109 | 109 | return; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | $this->_body_data = $data; |
| 116 | 116 | |
| 117 | - if ( ! has_action( 'shutdown', array( |
|
| 117 | + if ( ! has_action('shutdown', array( |
|
| 118 | 118 | $this, |
| 119 | 119 | 'launch_on_shutdown', |
| 120 | - ) ) |
|
| 120 | + )) |
|
| 121 | 121 | ) { |
| 122 | - add_action( 'shutdown', array( $this, 'launch_on_shutdown' ) ); |
|
| 122 | + add_action('shutdown', array($this, 'launch_on_shutdown')); |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
@@ -139,26 +139,26 @@ discard block |
||
| 139 | 139 | * @uses wp_remote_post() |
| 140 | 140 | */ |
| 141 | 141 | public function launch_on_shutdown() { |
| 142 | - if ( ! empty( $this->_body_data ) ) { |
|
| 142 | + if ( ! empty($this->_body_data)) { |
|
| 143 | 143 | $cookies = array(); |
| 144 | - foreach ( $_COOKIE as $name => $value ) { |
|
| 145 | - $cookies[] = "$name=" . urlencode( is_array( $value ) ? serialize( $value ) : $value ); |
|
| 144 | + foreach ($_COOKIE as $name => $value) { |
|
| 145 | + $cookies[] = "$name=".urlencode(is_array($value) ? serialize($value) : $value); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $request_args = array( |
| 149 | 149 | 'timeout' => 0.01, |
| 150 | 150 | 'blocking' => false, |
| 151 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', true ), |
|
| 151 | + 'sslverify' => apply_filters('https_local_ssl_verify', true), |
|
| 152 | 152 | 'body' => $this->_body_data, |
| 153 | 153 | 'headers' => array( |
| 154 | - 'cookie' => implode( '; ', $cookies ), |
|
| 154 | + 'cookie' => implode('; ', $cookies), |
|
| 155 | 155 | ), |
| 156 | 156 | ); |
| 157 | 157 | |
| 158 | - $url = admin_url( 'admin-post.php' ); |
|
| 158 | + $url = admin_url('admin-post.php'); |
|
| 159 | 159 | |
| 160 | - error_log( "Launching [ url :: $url ][ " . var_export( $request_args, true ) . " ]..." ); |
|
| 161 | - error_log( var_export( wp_remote_post( $url, $request_args ), true ) ); |
|
| 160 | + error_log("Launching [ url :: $url ][ ".var_export($request_args, true)." ]..."); |
|
| 161 | + error_log(var_export(wp_remote_post($url, $request_args), true)); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
@@ -171,14 +171,14 @@ discard block |
||
| 171 | 171 | * @uses wp_die() |
| 172 | 172 | */ |
| 173 | 173 | public function handle_postback() { |
| 174 | - if ( isset( $_POST['_nonce'] ) && $this->verify_async_nonce( $_POST['_nonce'] ) ) { |
|
| 175 | - if ( ! is_user_logged_in() ) { |
|
| 174 | + if (isset($_POST['_nonce']) && $this->verify_async_nonce($_POST['_nonce'])) { |
|
| 175 | + if ( ! is_user_logged_in()) { |
|
| 176 | 176 | $this->action = "nopriv_$this->action"; |
| 177 | 177 | } |
| 178 | 178 | $this->run_action(); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - add_filter( 'wp_die_handler', function () { |
|
| 181 | + add_filter('wp_die_handler', function() { |
|
| 182 | 182 | die(); |
| 183 | 183 | } ); |
| 184 | 184 | wp_die(); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $action = $this->get_nonce_action(); |
| 200 | 200 | $i = wp_nonce_tick(); |
| 201 | 201 | |
| 202 | - return substr( wp_hash( $i . $action . get_class( $this ), 'nonce' ), - 12, 10 ); |
|
| 202 | + return substr(wp_hash($i.$action.get_class($this), 'nonce'), - 12, 10); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -212,17 +212,17 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @return bool Whether the nonce check passed or failed |
| 214 | 214 | */ |
| 215 | - protected function verify_async_nonce( $nonce ) { |
|
| 215 | + protected function verify_async_nonce($nonce) { |
|
| 216 | 216 | $action = $this->get_nonce_action(); |
| 217 | 217 | $i = wp_nonce_tick(); |
| 218 | 218 | |
| 219 | 219 | // Nonce generated 0-12 hours ago |
| 220 | - if ( substr( wp_hash( $i . $action . get_class( $this ), 'nonce' ), - 12, 10 ) == $nonce ) { |
|
| 220 | + if (substr(wp_hash($i.$action.get_class($this), 'nonce'), - 12, 10) == $nonce) { |
|
| 221 | 221 | return 1; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // Nonce generated 12-24 hours ago |
| 225 | - if ( substr( wp_hash( ( $i - 1 ) . $action . get_class( $this ), 'nonce' ), - 12, 10 ) == $nonce ) { |
|
| 225 | + if (substr(wp_hash(($i - 1).$action.get_class($this), 'nonce'), - 12, 10) == $nonce) { |
|
| 226 | 226 | return 2; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -237,8 +237,8 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | protected function get_nonce_action() { |
| 239 | 239 | $action = $this->action; |
| 240 | - if ( substr( $action, 0, 7 ) === 'nopriv_' ) { |
|
| 241 | - $action = substr( $action, 7 ); |
|
| 240 | + if (substr($action, 0, 7) === 'nopriv_') { |
|
| 241 | + $action = substr($action, 7); |
|
| 242 | 242 | } |
| 243 | 243 | $action = "wp_async_$action"; |
| 244 | 244 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @return array The prepared data |
| 267 | 267 | */ |
| 268 | - abstract protected function prepare_data( $data ); |
|
| 268 | + abstract protected function prepare_data($data); |
|
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * Run the do_action function for the asynchronous postback. |
@@ -18,68 +18,68 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Sparql_Query_Async_Task extends WP_Async_Task { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The protected $action property should be set to the action to which you |
|
| 23 | - * wish to attach the asynchronous task. For example, if you want to spin |
|
| 24 | - * off an asynchronous task whenever a post gets saved, you would set this |
|
| 25 | - * to save_post. |
|
| 26 | - * |
|
| 27 | - * @since 3.13.2 |
|
| 28 | - * @access protected |
|
| 29 | - * @var string $action The action to which you wish to attach the |
|
| 30 | - * asynchronous task. |
|
| 31 | - */ |
|
| 32 | - protected $action = 'wl_run_sparql_query'; |
|
| 21 | + /** |
|
| 22 | + * The protected $action property should be set to the action to which you |
|
| 23 | + * wish to attach the asynchronous task. For example, if you want to spin |
|
| 24 | + * off an asynchronous task whenever a post gets saved, you would set this |
|
| 25 | + * to save_post. |
|
| 26 | + * |
|
| 27 | + * @since 3.13.2 |
|
| 28 | + * @access protected |
|
| 29 | + * @var string $action The action to which you wish to attach the |
|
| 30 | + * asynchronous task. |
|
| 31 | + */ |
|
| 32 | + protected $action = 'wl_run_sparql_query'; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * A {@link Wordlift_Log_Service} instance. |
|
| 36 | - * |
|
| 37 | - * @since 3.13.2 |
|
| 38 | - * @access private |
|
| 39 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 40 | - */ |
|
| 41 | - private $log; |
|
| 34 | + /** |
|
| 35 | + * A {@link Wordlift_Log_Service} instance. |
|
| 36 | + * |
|
| 37 | + * @since 3.13.2 |
|
| 38 | + * @access private |
|
| 39 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 40 | + */ |
|
| 41 | + private $log; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Create a {@link Wordlift_Sparql_Query_Async_Task} instance. |
|
| 45 | - * |
|
| 46 | - * @since 3.13.2 |
|
| 47 | - * |
|
| 48 | - * @param int $auth_level The authentication level to use (see above) |
|
| 49 | - */ |
|
| 50 | - public function __construct( $auth_level = self::BOTH ) { |
|
| 51 | - parent::__construct( $auth_level ); |
|
| 43 | + /** |
|
| 44 | + * Create a {@link Wordlift_Sparql_Query_Async_Task} instance. |
|
| 45 | + * |
|
| 46 | + * @since 3.13.2 |
|
| 47 | + * |
|
| 48 | + * @param int $auth_level The authentication level to use (see above) |
|
| 49 | + */ |
|
| 50 | + public function __construct( $auth_level = self::BOTH ) { |
|
| 51 | + parent::__construct( $auth_level ); |
|
| 52 | 52 | |
| 53 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Sparql_Query_Async_Task' ); |
|
| 53 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Sparql_Query_Async_Task' ); |
|
| 54 | 54 | |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @inheritdoc |
|
| 60 | - */ |
|
| 61 | - protected function prepare_data( $data ) { |
|
| 58 | + /** |
|
| 59 | + * @inheritdoc |
|
| 60 | + */ |
|
| 61 | + protected function prepare_data( $data ) { |
|
| 62 | 62 | |
| 63 | - // Return the request id, which is used to get the sparql queries stored |
|
| 64 | - // in the temporary files. |
|
| 65 | - return array( 'request_id' => $data[0] ); |
|
| 66 | - } |
|
| 63 | + // Return the request id, which is used to get the sparql queries stored |
|
| 64 | + // in the temporary files. |
|
| 65 | + return array( 'request_id' => $data[0] ); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @inheritdoc |
|
| 70 | - */ |
|
| 71 | - protected function run_action() { |
|
| 68 | + /** |
|
| 69 | + * @inheritdoc |
|
| 70 | + */ |
|
| 71 | + protected function run_action() { |
|
| 72 | 72 | |
| 73 | - // Bail out if there's no request id. |
|
| 74 | - if ( ! isset( $_POST['request_id'] ) ) { |
|
| 75 | - $this->log->warn( 'Request Id not found.' ); |
|
| 73 | + // Bail out if there's no request id. |
|
| 74 | + if ( ! isset( $_POST['request_id'] ) ) { |
|
| 75 | + $this->log->warn( 'Request Id not found.' ); |
|
| 76 | 76 | |
| 77 | - return; |
|
| 78 | - } |
|
| 77 | + return; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - // Run the asynchronous action. |
|
| 81 | - do_action( "wp_async_$this->action", $_POST['request_id'] ); |
|
| 80 | + // Run the asynchronous action. |
|
| 81 | + do_action( "wp_async_$this->action", $_POST['request_id'] ); |
|
| 82 | 82 | |
| 83 | - } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | } |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @param int $auth_level The authentication level to use (see above) |
| 49 | 49 | */ |
| 50 | - public function __construct( $auth_level = self::BOTH ) { |
|
| 51 | - parent::__construct( $auth_level ); |
|
| 50 | + public function __construct($auth_level = self::BOTH) { |
|
| 51 | + parent::__construct($auth_level); |
|
| 52 | 52 | |
| 53 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Sparql_Query_Async_Task' ); |
|
| 53 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Sparql_Query_Async_Task'); |
|
| 54 | 54 | |
| 55 | 55 | } |
| 56 | 56 | |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | /** |
| 59 | 59 | * @inheritdoc |
| 60 | 60 | */ |
| 61 | - protected function prepare_data( $data ) { |
|
| 61 | + protected function prepare_data($data) { |
|
| 62 | 62 | |
| 63 | 63 | // Return the request id, which is used to get the sparql queries stored |
| 64 | 64 | // in the temporary files. |
| 65 | - return array( 'request_id' => $data[0] ); |
|
| 65 | + return array('request_id' => $data[0]); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | protected function run_action() { |
| 72 | 72 | |
| 73 | 73 | // Bail out if there's no request id. |
| 74 | - if ( ! isset( $_POST['request_id'] ) ) { |
|
| 75 | - $this->log->warn( 'Request Id not found.' ); |
|
| 74 | + if ( ! isset($_POST['request_id'])) { |
|
| 75 | + $this->log->warn('Request Id not found.'); |
|
| 76 | 76 | |
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // Run the asynchronous action. |
| 81 | - do_action( "wp_async_$this->action", $_POST['request_id'] ); |
|
| 81 | + do_action("wp_async_$this->action", $_POST['request_id']); |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
@@ -13,124 +13,124 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | class Wordlift_Rebuild_Service extends Wordlift_Listable { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * A {@link Wordlift_Log_Service} instance. |
|
| 18 | - * |
|
| 19 | - * @since 3.6.0 |
|
| 20 | - * @access private |
|
| 21 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 22 | - */ |
|
| 23 | - private $log; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 27 | - * @since 3.6.0 |
|
| 28 | - * @access private |
|
| 29 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 30 | - */ |
|
| 31 | - private $sparql_service; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var \Wordlift_Uri_Service |
|
| 35 | - */ |
|
| 36 | - private $uri_service; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Create an instance of Wordlift_Rebuild_Service. |
|
| 40 | - * |
|
| 41 | - * @since 3.6.0 |
|
| 42 | - * |
|
| 43 | - * @param \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance used to query the remote dataset. |
|
| 44 | - * @param \Wordlift_Uri_Service $uri_service |
|
| 45 | - */ |
|
| 46 | - public function __construct( $sparql_service, $uri_service ) { |
|
| 47 | - |
|
| 48 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Rebuild_Service' ); |
|
| 49 | - |
|
| 50 | - $this->sparql_service = $sparql_service; |
|
| 51 | - $this->uri_service = $uri_service; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Rebuild the Linked Data remote dataset by clearing it out and repopulating |
|
| 56 | - * it with local data. |
|
| 57 | - * |
|
| 58 | - * @since 3.6.0 |
|
| 59 | - */ |
|
| 60 | - public function rebuild() { |
|
| 61 | - |
|
| 62 | - ob_clean(); |
|
| 63 | - |
|
| 64 | - // Give ourselves some time to process the data. |
|
| 65 | - set_time_limit( 21600 ); // 6 hours |
|
| 66 | - |
|
| 67 | - // Send textual output. |
|
| 68 | - header( 'Content-type: text/plain; charset=utf-8' ); |
|
| 69 | - |
|
| 70 | - // We start at 0 by default and get to max. |
|
| 71 | - $offset = $_GET['offset'] ?: 0; |
|
| 72 | - $limit = $_GET['limit'] ?: 1; |
|
| 73 | - $entity_only = isset( $_GET['entity_only'] ) && '1' === $_GET['entity_only']; |
|
| 74 | - $max = $offset + $limit; |
|
| 75 | - |
|
| 76 | - // If we're starting at offset 0, then delete existing URIs and data from |
|
| 77 | - // the remote dataset. |
|
| 78 | - if ( 0 === $offset ) { |
|
| 79 | - |
|
| 80 | - // Clear out all generated URIs, since the dataset URI might have changed |
|
| 81 | - // in the process. |
|
| 82 | - $this->uri_service->delete_all(); |
|
| 83 | - |
|
| 84 | - // Delete all the triples in the remote dataset. |
|
| 85 | - $this->sparql_service->execute( 'DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };' ); |
|
| 86 | - |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - // Go through the list of published entities and posts and call the (legacy) |
|
| 90 | - // `wl_linked_data_save_post` function for each one. We're using the `process` |
|
| 91 | - // function which is provided by the parent `Wordlift_Listable` abstract class |
|
| 92 | - // and will cycle through all the posts w/ a very small memory footprint |
|
| 93 | - // in order to avoid memory errors. |
|
| 94 | - |
|
| 95 | - $count = 0; |
|
| 96 | - $this->process( function ( $post ) use ( &$count ) { |
|
| 97 | - $count ++; |
|
| 98 | - wl_linked_data_save_post( $post->ID ); |
|
| 99 | - }, array( |
|
| 100 | - 'post_status' => 'publish', |
|
| 101 | - 'post_type' => $entity_only ? 'entity' : array( |
|
| 102 | - 'entity', |
|
| 103 | - 'post', |
|
| 104 | - ), |
|
| 105 | - ), $offset, $max ); |
|
| 106 | - |
|
| 107 | - // Redirect to the next chunk. |
|
| 108 | - if ( $count == $limit ) { |
|
| 109 | - $this->redirect( admin_url( 'admin-ajax.php?action=wl_rebuild&offset=' . ( $offset + $limit ) . '&limit=' . $limit . '&entity_only=' . ( $entity_only ? '1' : '0' ) ) ); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - echo( "Rebuild complete [ count :: $count ][ limit :: $limit ]" ); |
|
| 113 | - |
|
| 114 | - // If we're being called as AJAX, die here. |
|
| 115 | - if ( DOING_AJAX ) { |
|
| 116 | - wp_die(); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Redirect using a client-side meta to avoid browsers' redirect restrictions. |
|
| 123 | - * |
|
| 124 | - * @since 3.9.8 |
|
| 125 | - * |
|
| 126 | - * @param string $url The URL to redirect to. |
|
| 127 | - */ |
|
| 128 | - private function redirect( $url ) { |
|
| 129 | - |
|
| 130 | - ob_clean(); |
|
| 131 | - |
|
| 132 | - @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 133 | - ?> |
|
| 16 | + /** |
|
| 17 | + * A {@link Wordlift_Log_Service} instance. |
|
| 18 | + * |
|
| 19 | + * @since 3.6.0 |
|
| 20 | + * @access private |
|
| 21 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 22 | + */ |
|
| 23 | + private $log; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 27 | + * @since 3.6.0 |
|
| 28 | + * @access private |
|
| 29 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 30 | + */ |
|
| 31 | + private $sparql_service; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var \Wordlift_Uri_Service |
|
| 35 | + */ |
|
| 36 | + private $uri_service; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Create an instance of Wordlift_Rebuild_Service. |
|
| 40 | + * |
|
| 41 | + * @since 3.6.0 |
|
| 42 | + * |
|
| 43 | + * @param \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance used to query the remote dataset. |
|
| 44 | + * @param \Wordlift_Uri_Service $uri_service |
|
| 45 | + */ |
|
| 46 | + public function __construct( $sparql_service, $uri_service ) { |
|
| 47 | + |
|
| 48 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Rebuild_Service' ); |
|
| 49 | + |
|
| 50 | + $this->sparql_service = $sparql_service; |
|
| 51 | + $this->uri_service = $uri_service; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Rebuild the Linked Data remote dataset by clearing it out and repopulating |
|
| 56 | + * it with local data. |
|
| 57 | + * |
|
| 58 | + * @since 3.6.0 |
|
| 59 | + */ |
|
| 60 | + public function rebuild() { |
|
| 61 | + |
|
| 62 | + ob_clean(); |
|
| 63 | + |
|
| 64 | + // Give ourselves some time to process the data. |
|
| 65 | + set_time_limit( 21600 ); // 6 hours |
|
| 66 | + |
|
| 67 | + // Send textual output. |
|
| 68 | + header( 'Content-type: text/plain; charset=utf-8' ); |
|
| 69 | + |
|
| 70 | + // We start at 0 by default and get to max. |
|
| 71 | + $offset = $_GET['offset'] ?: 0; |
|
| 72 | + $limit = $_GET['limit'] ?: 1; |
|
| 73 | + $entity_only = isset( $_GET['entity_only'] ) && '1' === $_GET['entity_only']; |
|
| 74 | + $max = $offset + $limit; |
|
| 75 | + |
|
| 76 | + // If we're starting at offset 0, then delete existing URIs and data from |
|
| 77 | + // the remote dataset. |
|
| 78 | + if ( 0 === $offset ) { |
|
| 79 | + |
|
| 80 | + // Clear out all generated URIs, since the dataset URI might have changed |
|
| 81 | + // in the process. |
|
| 82 | + $this->uri_service->delete_all(); |
|
| 83 | + |
|
| 84 | + // Delete all the triples in the remote dataset. |
|
| 85 | + $this->sparql_service->execute( 'DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };' ); |
|
| 86 | + |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + // Go through the list of published entities and posts and call the (legacy) |
|
| 90 | + // `wl_linked_data_save_post` function for each one. We're using the `process` |
|
| 91 | + // function which is provided by the parent `Wordlift_Listable` abstract class |
|
| 92 | + // and will cycle through all the posts w/ a very small memory footprint |
|
| 93 | + // in order to avoid memory errors. |
|
| 94 | + |
|
| 95 | + $count = 0; |
|
| 96 | + $this->process( function ( $post ) use ( &$count ) { |
|
| 97 | + $count ++; |
|
| 98 | + wl_linked_data_save_post( $post->ID ); |
|
| 99 | + }, array( |
|
| 100 | + 'post_status' => 'publish', |
|
| 101 | + 'post_type' => $entity_only ? 'entity' : array( |
|
| 102 | + 'entity', |
|
| 103 | + 'post', |
|
| 104 | + ), |
|
| 105 | + ), $offset, $max ); |
|
| 106 | + |
|
| 107 | + // Redirect to the next chunk. |
|
| 108 | + if ( $count == $limit ) { |
|
| 109 | + $this->redirect( admin_url( 'admin-ajax.php?action=wl_rebuild&offset=' . ( $offset + $limit ) . '&limit=' . $limit . '&entity_only=' . ( $entity_only ? '1' : '0' ) ) ); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + echo( "Rebuild complete [ count :: $count ][ limit :: $limit ]" ); |
|
| 113 | + |
|
| 114 | + // If we're being called as AJAX, die here. |
|
| 115 | + if ( DOING_AJAX ) { |
|
| 116 | + wp_die(); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Redirect using a client-side meta to avoid browsers' redirect restrictions. |
|
| 123 | + * |
|
| 124 | + * @since 3.9.8 |
|
| 125 | + * |
|
| 126 | + * @param string $url The URL to redirect to. |
|
| 127 | + */ |
|
| 128 | + private function redirect( $url ) { |
|
| 129 | + |
|
| 130 | + ob_clean(); |
|
| 131 | + |
|
| 132 | + @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 133 | + ?> |
|
| 134 | 134 | <html> |
| 135 | 135 | <head> |
| 136 | 136 | <meta http-equiv="refresh" |
@@ -142,32 +142,32 @@ discard block |
||
| 142 | 142 | </html> |
| 143 | 143 | <?php |
| 144 | 144 | |
| 145 | - exit; |
|
| 146 | - |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * List the items starting at the specified offset and up to the specified limit. |
|
| 151 | - * |
|
| 152 | - * @since 3.6.0 |
|
| 153 | - * |
|
| 154 | - * @param int $offset The start offset. |
|
| 155 | - * @param int $limit The maximum number of items to return. |
|
| 156 | - * @param array $args Additional arguments. |
|
| 157 | - * |
|
| 158 | - * @return array A array of items (or an empty array if no items are found). |
|
| 159 | - */ |
|
| 160 | - function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 161 | - |
|
| 162 | - return get_posts( wp_parse_args( $args, array( |
|
| 163 | - 'offset' => $offset, |
|
| 164 | - 'numberposts' => $limit, |
|
| 165 | - 'fields' => 'all', |
|
| 166 | - 'orderby' => 'ID', |
|
| 167 | - 'order' => 'ASC', |
|
| 168 | - 'post_status' => 'any', |
|
| 169 | - 'post_type' => 'post', |
|
| 170 | - ) ) ); |
|
| 171 | - } |
|
| 145 | + exit; |
|
| 146 | + |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * List the items starting at the specified offset and up to the specified limit. |
|
| 151 | + * |
|
| 152 | + * @since 3.6.0 |
|
| 153 | + * |
|
| 154 | + * @param int $offset The start offset. |
|
| 155 | + * @param int $limit The maximum number of items to return. |
|
| 156 | + * @param array $args Additional arguments. |
|
| 157 | + * |
|
| 158 | + * @return array A array of items (or an empty array if no items are found). |
|
| 159 | + */ |
|
| 160 | + function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 161 | + |
|
| 162 | + return get_posts( wp_parse_args( $args, array( |
|
| 163 | + 'offset' => $offset, |
|
| 164 | + 'numberposts' => $limit, |
|
| 165 | + 'fields' => 'all', |
|
| 166 | + 'orderby' => 'ID', |
|
| 167 | + 'order' => 'ASC', |
|
| 168 | + 'post_status' => 'any', |
|
| 169 | + 'post_type' => 'post', |
|
| 170 | + ) ) ); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | 173 | } |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | * @param \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance used to query the remote dataset. |
| 44 | 44 | * @param \Wordlift_Uri_Service $uri_service |
| 45 | 45 | */ |
| 46 | - public function __construct( $sparql_service, $uri_service ) { |
|
| 46 | + public function __construct($sparql_service, $uri_service) { |
|
| 47 | 47 | |
| 48 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Rebuild_Service' ); |
|
| 48 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Rebuild_Service'); |
|
| 49 | 49 | |
| 50 | 50 | $this->sparql_service = $sparql_service; |
| 51 | 51 | $this->uri_service = $uri_service; |
@@ -62,27 +62,27 @@ discard block |
||
| 62 | 62 | ob_clean(); |
| 63 | 63 | |
| 64 | 64 | // Give ourselves some time to process the data. |
| 65 | - set_time_limit( 21600 ); // 6 hours |
|
| 65 | + set_time_limit(21600); // 6 hours |
|
| 66 | 66 | |
| 67 | 67 | // Send textual output. |
| 68 | - header( 'Content-type: text/plain; charset=utf-8' ); |
|
| 68 | + header('Content-type: text/plain; charset=utf-8'); |
|
| 69 | 69 | |
| 70 | 70 | // We start at 0 by default and get to max. |
| 71 | 71 | $offset = $_GET['offset'] ?: 0; |
| 72 | 72 | $limit = $_GET['limit'] ?: 1; |
| 73 | - $entity_only = isset( $_GET['entity_only'] ) && '1' === $_GET['entity_only']; |
|
| 73 | + $entity_only = isset($_GET['entity_only']) && '1' === $_GET['entity_only']; |
|
| 74 | 74 | $max = $offset + $limit; |
| 75 | 75 | |
| 76 | 76 | // If we're starting at offset 0, then delete existing URIs and data from |
| 77 | 77 | // the remote dataset. |
| 78 | - if ( 0 === $offset ) { |
|
| 78 | + if (0 === $offset) { |
|
| 79 | 79 | |
| 80 | 80 | // Clear out all generated URIs, since the dataset URI might have changed |
| 81 | 81 | // in the process. |
| 82 | 82 | $this->uri_service->delete_all(); |
| 83 | 83 | |
| 84 | 84 | // Delete all the triples in the remote dataset. |
| 85 | - $this->sparql_service->execute( 'DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };' ); |
|
| 85 | + $this->sparql_service->execute('DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };'); |
|
| 86 | 86 | |
| 87 | 87 | } |
| 88 | 88 | |
@@ -93,26 +93,26 @@ discard block |
||
| 93 | 93 | // in order to avoid memory errors. |
| 94 | 94 | |
| 95 | 95 | $count = 0; |
| 96 | - $this->process( function ( $post ) use ( &$count ) { |
|
| 97 | - $count ++; |
|
| 98 | - wl_linked_data_save_post( $post->ID ); |
|
| 96 | + $this->process(function($post) use (&$count) { |
|
| 97 | + $count++; |
|
| 98 | + wl_linked_data_save_post($post->ID); |
|
| 99 | 99 | }, array( |
| 100 | 100 | 'post_status' => 'publish', |
| 101 | 101 | 'post_type' => $entity_only ? 'entity' : array( |
| 102 | 102 | 'entity', |
| 103 | 103 | 'post', |
| 104 | 104 | ), |
| 105 | - ), $offset, $max ); |
|
| 105 | + ), $offset, $max); |
|
| 106 | 106 | |
| 107 | 107 | // Redirect to the next chunk. |
| 108 | - if ( $count == $limit ) { |
|
| 109 | - $this->redirect( admin_url( 'admin-ajax.php?action=wl_rebuild&offset=' . ( $offset + $limit ) . '&limit=' . $limit . '&entity_only=' . ( $entity_only ? '1' : '0' ) ) ); |
|
| 108 | + if ($count == $limit) { |
|
| 109 | + $this->redirect(admin_url('admin-ajax.php?action=wl_rebuild&offset='.($offset + $limit).'&limit='.$limit.'&entity_only='.($entity_only ? '1' : '0'))); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - echo( "Rebuild complete [ count :: $count ][ limit :: $limit ]" ); |
|
| 112 | + echo("Rebuild complete [ count :: $count ][ limit :: $limit ]"); |
|
| 113 | 113 | |
| 114 | 114 | // If we're being called as AJAX, die here. |
| 115 | - if ( DOING_AJAX ) { |
|
| 115 | + if (DOING_AJAX) { |
|
| 116 | 116 | wp_die(); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -125,16 +125,16 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @param string $url The URL to redirect to. |
| 127 | 127 | */ |
| 128 | - private function redirect( $url ) { |
|
| 128 | + private function redirect($url) { |
|
| 129 | 129 | |
| 130 | 130 | ob_clean(); |
| 131 | 131 | |
| 132 | - @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 132 | + @header('Content-Type: text/html; charset='.get_option('blog_charset')); |
|
| 133 | 133 | ?> |
| 134 | 134 | <html> |
| 135 | 135 | <head> |
| 136 | 136 | <meta http-equiv="refresh" |
| 137 | - content="0; <?php echo esc_attr( $url ); ?>"> |
|
| 137 | + content="0; <?php echo esc_attr($url); ?>"> |
|
| 138 | 138 | </head> |
| 139 | 139 | <body> |
| 140 | 140 | Rebuilding, please wait... |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @return array A array of items (or an empty array if no items are found). |
| 159 | 159 | */ |
| 160 | - function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 160 | + function find($offset = 0, $limit = 10, $args = array()) { |
|
| 161 | 161 | |
| 162 | - return get_posts( wp_parse_args( $args, array( |
|
| 162 | + return get_posts(wp_parse_args($args, array( |
|
| 163 | 163 | 'offset' => $offset, |
| 164 | 164 | 'numberposts' => $limit, |
| 165 | 165 | 'fields' => 'all', |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | 'order' => 'ASC', |
| 168 | 168 | 'post_status' => 'any', |
| 169 | 169 | 'post_type' => 'post', |
| 170 | - ) ) ); |
|
| 170 | + ))); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | } |
@@ -538,327 +538,327 @@ discard block |
||
| 538 | 538 | * The class responsible for orchestrating the actions and filters of the |
| 539 | 539 | * core plugin. |
| 540 | 540 | */ |
| 541 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 541 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php'; |
|
| 542 | 542 | |
| 543 | 543 | /** |
| 544 | 544 | * The class responsible for defining internationalization functionality |
| 545 | 545 | * of the plugin. |
| 546 | 546 | */ |
| 547 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 547 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php'; |
|
| 548 | 548 | |
| 549 | 549 | /** |
| 550 | 550 | * WordLift's supported languages. |
| 551 | 551 | */ |
| 552 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 552 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-languages.php'; |
|
| 553 | 553 | |
| 554 | 554 | /** |
| 555 | 555 | * Provide support functions to sanitize data. |
| 556 | 556 | */ |
| 557 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 557 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php'; |
|
| 558 | 558 | |
| 559 | 559 | /** |
| 560 | 560 | * The Redirect service. |
| 561 | 561 | */ |
| 562 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 562 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php'; |
|
| 563 | 563 | |
| 564 | 564 | /** |
| 565 | 565 | * The Log service. |
| 566 | 566 | */ |
| 567 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 567 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php'; |
|
| 568 | 568 | |
| 569 | 569 | /** |
| 570 | 570 | * The configuration service. |
| 571 | 571 | */ |
| 572 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 572 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php'; |
|
| 573 | 573 | |
| 574 | 574 | /** |
| 575 | 575 | * The entity post type service (this is the WordPress post type, not the entity schema type). |
| 576 | 576 | */ |
| 577 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 577 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-type-service.php'; |
|
| 578 | 578 | |
| 579 | 579 | /** |
| 580 | 580 | * The entity type service (i.e. the schema type). |
| 581 | 581 | */ |
| 582 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 582 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php'; |
|
| 583 | 583 | |
| 584 | 584 | /** |
| 585 | 585 | * The entity link service. |
| 586 | 586 | */ |
| 587 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 587 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php'; |
|
| 588 | 588 | |
| 589 | 589 | /** |
| 590 | 590 | * The Query builder. |
| 591 | 591 | */ |
| 592 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 592 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php'; |
|
| 593 | 593 | |
| 594 | 594 | /** |
| 595 | 595 | * The Schema service. |
| 596 | 596 | */ |
| 597 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 597 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php'; |
|
| 598 | 598 | |
| 599 | 599 | /** |
| 600 | 600 | * The schema:url property service. |
| 601 | 601 | */ |
| 602 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 603 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 602 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-service.php'; |
|
| 603 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-url-property-service.php'; |
|
| 604 | 604 | |
| 605 | 605 | /** |
| 606 | 606 | * The UI service. |
| 607 | 607 | */ |
| 608 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 608 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php'; |
|
| 609 | 609 | |
| 610 | 610 | /** |
| 611 | 611 | * The Thumbnail service. |
| 612 | 612 | */ |
| 613 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 613 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php'; |
|
| 614 | 614 | |
| 615 | 615 | /** |
| 616 | 616 | * The Entity Types Taxonomy service. |
| 617 | 617 | */ |
| 618 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 618 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 619 | 619 | |
| 620 | 620 | /** |
| 621 | 621 | * The Entity service. |
| 622 | 622 | */ |
| 623 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 623 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php'; |
|
| 624 | 624 | |
| 625 | 625 | // Add the entity rating service. |
| 626 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 626 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rating-service.php'; |
|
| 627 | 627 | |
| 628 | 628 | /** |
| 629 | 629 | * The User service. |
| 630 | 630 | */ |
| 631 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 631 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php'; |
|
| 632 | 632 | |
| 633 | 633 | /** |
| 634 | 634 | * The Timeline service. |
| 635 | 635 | */ |
| 636 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 636 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php'; |
|
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | 639 | * The Topic Taxonomy service. |
| 640 | 640 | */ |
| 641 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 641 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 642 | 642 | |
| 643 | 643 | /** |
| 644 | 644 | * The SPARQL service. |
| 645 | 645 | */ |
| 646 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 646 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php'; |
|
| 647 | 647 | |
| 648 | 648 | /** |
| 649 | 649 | * The WordLift import service. |
| 650 | 650 | */ |
| 651 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 651 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php'; |
|
| 652 | 652 | |
| 653 | 653 | /** |
| 654 | 654 | * The WordLift URI service. |
| 655 | 655 | */ |
| 656 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 656 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php'; |
|
| 657 | 657 | |
| 658 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 658 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-listable.php'; |
|
| 659 | 659 | |
| 660 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 660 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-property-factory.php'; |
|
| 661 | 661 | |
| 662 | 662 | /** |
| 663 | 663 | * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
| 664 | 664 | */ |
| 665 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 665 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rebuild-service.php'; |
|
| 666 | 666 | |
| 667 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 667 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 668 | 668 | |
| 669 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 669 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-attachment-service.php'; |
|
| 670 | 670 | |
| 671 | 671 | /** |
| 672 | 672 | * Load the converters. |
| 673 | 673 | */ |
| 674 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 675 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 676 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 677 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 678 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 674 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/intf-wordlift-post-converter.php'; |
|
| 675 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 676 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 677 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 678 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 679 | 679 | |
| 680 | 680 | /** |
| 681 | 681 | * Load the content filter. |
| 682 | 682 | */ |
| 683 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 683 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-content-filter-service.php'; |
|
| 684 | 684 | |
| 685 | 685 | /* |
| 686 | 686 | * Load the excerpt helper. |
| 687 | 687 | */ |
| 688 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 688 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 689 | 689 | |
| 690 | 690 | /** |
| 691 | 691 | * Load the JSON-LD service to publish entities using JSON-LD.s |
| 692 | 692 | * |
| 693 | 693 | * @since 3.8.0 |
| 694 | 694 | */ |
| 695 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 695 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-jsonld-service.php'; |
|
| 696 | 696 | |
| 697 | 697 | // The Publisher Service and the AJAX adapter. |
| 698 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 699 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 698 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-service.php'; |
|
| 699 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 700 | 700 | |
| 701 | 701 | /** |
| 702 | 702 | * Load the WordLift key validation service. |
| 703 | 703 | */ |
| 704 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 704 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-key-validation-service.php'; |
|
| 705 | 705 | |
| 706 | 706 | // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
| 707 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 707 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 708 | 708 | |
| 709 | 709 | // Load the `Wordlift_Event_Entity_Page_Service` class definition. |
| 710 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-event-entity-page-service.php'; |
|
| 710 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-event-entity-page-service.php'; |
|
| 711 | 711 | |
| 712 | 712 | /** Adapters. */ |
| 713 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 714 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 713 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-tinymce-adapter.php'; |
|
| 714 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-newrelic-adapter.php'; |
|
| 715 | 715 | |
| 716 | 716 | /** Async Tasks. */ |
| 717 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/wp-async-task.php'; |
|
| 718 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 717 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/wp-async-task.php'; |
|
| 718 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 719 | 719 | |
| 720 | 720 | /** |
| 721 | 721 | * The class responsible for defining all actions that occur in the admin area. |
| 722 | 722 | */ |
| 723 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 723 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php'; |
|
| 724 | 724 | |
| 725 | 725 | /** |
| 726 | 726 | * The class to customize the entity list admin page. |
| 727 | 727 | */ |
| 728 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 728 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php'; |
|
| 729 | 729 | |
| 730 | 730 | /** |
| 731 | 731 | * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
| 732 | 732 | */ |
| 733 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 733 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 734 | 734 | |
| 735 | 735 | /** |
| 736 | 736 | * The Notice service. |
| 737 | 737 | */ |
| 738 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 738 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php'; |
|
| 739 | 739 | |
| 740 | 740 | /** |
| 741 | 741 | * The PrimaShop adapter. |
| 742 | 742 | */ |
| 743 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 743 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php'; |
|
| 744 | 744 | |
| 745 | 745 | /** |
| 746 | 746 | * The WordLift Dashboard service. |
| 747 | 747 | */ |
| 748 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 748 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php'; |
|
| 749 | 749 | |
| 750 | 750 | /** |
| 751 | 751 | * The admin 'Install wizard' page. |
| 752 | 752 | */ |
| 753 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 753 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-setup.php'; |
|
| 754 | 754 | |
| 755 | 755 | /** |
| 756 | 756 | * The WordLift entity type list admin page controller. |
| 757 | 757 | */ |
| 758 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 758 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 759 | 759 | |
| 760 | 760 | /** |
| 761 | 761 | * The WordLift entity type settings admin page controller. |
| 762 | 762 | */ |
| 763 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 763 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-type-settings.php'; |
|
| 764 | 764 | |
| 765 | 765 | /** |
| 766 | 766 | * The admin 'Download Your Data' page. |
| 767 | 767 | */ |
| 768 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 768 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php'; |
|
| 769 | 769 | |
| 770 | 770 | /** |
| 771 | 771 | * The admin 'Download Your Data' page. |
| 772 | 772 | */ |
| 773 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 773 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-download-your-data-page.php'; |
|
| 774 | 774 | |
| 775 | 775 | /** |
| 776 | 776 | * The admin 'WordLift Settings' page. |
| 777 | 777 | */ |
| 778 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 779 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 780 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 781 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 782 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 783 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 784 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 785 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 786 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 787 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 778 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/intf-wordlift-admin-element.php'; |
|
| 779 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-input-element.php'; |
|
| 780 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 781 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-select2-element.php'; |
|
| 782 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-language-select-element.php'; |
|
| 783 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-tabs-element.php'; |
|
| 784 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-publisher-element.php'; |
|
| 785 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-page.php'; |
|
| 786 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page.php'; |
|
| 787 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 788 | 788 | |
| 789 | 789 | /** Admin Pages */ |
| 790 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 791 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 790 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 791 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-status-page.php'; |
|
| 792 | 792 | |
| 793 | 793 | /** |
| 794 | 794 | * The class responsible for defining all actions that occur in the public-facing |
| 795 | 795 | * side of the site. |
| 796 | 796 | */ |
| 797 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 797 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php'; |
|
| 798 | 798 | |
| 799 | 799 | /** |
| 800 | 800 | * The shortcode abstract class. |
| 801 | 801 | */ |
| 802 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 802 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php'; |
|
| 803 | 803 | |
| 804 | 804 | /** |
| 805 | 805 | * The Timeline shortcode. |
| 806 | 806 | */ |
| 807 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 807 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php'; |
|
| 808 | 808 | |
| 809 | 809 | /** |
| 810 | 810 | * The Navigator shortcode. |
| 811 | 811 | */ |
| 812 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 812 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php'; |
|
| 813 | 813 | |
| 814 | 814 | /** |
| 815 | 815 | * The chord shortcode. |
| 816 | 816 | */ |
| 817 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 817 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php'; |
|
| 818 | 818 | |
| 819 | 819 | /** |
| 820 | 820 | * The geomap shortcode. |
| 821 | 821 | */ |
| 822 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 822 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php'; |
|
| 823 | 823 | |
| 824 | 824 | /** |
| 825 | 825 | * The entity cloud shortcode. |
| 826 | 826 | */ |
| 827 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 827 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 828 | 828 | |
| 829 | 829 | /** |
| 830 | 830 | * The ShareThis service. |
| 831 | 831 | */ |
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 832 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php'; |
|
| 833 | 833 | |
| 834 | 834 | /** |
| 835 | 835 | * The SEO service. |
| 836 | 836 | */ |
| 837 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 837 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-seo-service.php'; |
|
| 838 | 838 | |
| 839 | 839 | /** |
| 840 | 840 | * The AMP service. |
| 841 | 841 | */ |
| 842 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 842 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-amp-service.php'; |
|
| 843 | 843 | |
| 844 | 844 | /** Widgets */ |
| 845 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 846 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 845 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-widget.php'; |
|
| 846 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 847 | 847 | |
| 848 | 848 | $this->loader = new Wordlift_Loader(); |
| 849 | 849 | |
| 850 | 850 | // Instantiate a global logger. |
| 851 | 851 | global $wl_logger; |
| 852 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 852 | + $wl_logger = Wordlift_Log_Service::get_logger('WordLift'); |
|
| 853 | 853 | |
| 854 | 854 | // Create the configuration service. |
| 855 | 855 | $this->configuration_service = new Wordlift_Configuration_Service(); |
| 856 | 856 | |
| 857 | 857 | // Create an entity type service instance. It'll be later bound to the init action. |
| 858 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 858 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path()); |
|
| 859 | 859 | |
| 860 | 860 | // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
| 861 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 861 | + $this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_post_type_service, $this->configuration_service->get_entity_base_path()); |
|
| 862 | 862 | |
| 863 | 863 | // Create an instance of the UI service. |
| 864 | 864 | $this->ui_service = new Wordlift_UI_Service(); |
@@ -869,23 +869,23 @@ discard block |
||
| 869 | 869 | $this->sparql_service = new Wordlift_Sparql_Service(); |
| 870 | 870 | |
| 871 | 871 | // Create an instance of the Schema service. |
| 872 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 872 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service($this->sparql_service); |
|
| 873 | 873 | $this->schema_service = new Wordlift_Schema_Service(); |
| 874 | 874 | |
| 875 | 875 | // Create an instance of the Notice service. |
| 876 | 876 | $this->notice_service = new Wordlift_Notice_Service(); |
| 877 | 877 | |
| 878 | 878 | // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
| 879 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service ); |
|
| 879 | + $this->entity_service = new Wordlift_Entity_Service($this->ui_service); |
|
| 880 | 880 | |
| 881 | 881 | // Create an instance of the User service. |
| 882 | 882 | $this->user_service = new Wordlift_User_Service(); |
| 883 | 883 | |
| 884 | 884 | // Create a new instance of the Timeline service and Timeline shortcode. |
| 885 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 885 | + $this->timeline_service = new Wordlift_Timeline_Service($this->entity_service); |
|
| 886 | 886 | |
| 887 | 887 | // Create a new instance of the Redirect service. |
| 888 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 888 | + $this->redirect_service = new Wordlift_Redirect_Service($this->entity_service); |
|
| 889 | 889 | |
| 890 | 890 | // Initialize the shortcodes. |
| 891 | 891 | new Wordlift_Navigator_Shortcode(); |
@@ -911,45 +911,45 @@ discard block |
||
| 911 | 911 | $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
| 912 | 912 | |
| 913 | 913 | // Create an import service instance to hook later to WP's import function. |
| 914 | - $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() ); |
|
| 914 | + $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()); |
|
| 915 | 915 | |
| 916 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 916 | + $uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']); |
|
| 917 | 917 | |
| 918 | 918 | // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
| 919 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 919 | + $this->rebuild_service = new Wordlift_Rebuild_Service($this->sparql_service, $uri_service); |
|
| 920 | 920 | |
| 921 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 921 | + $this->entity_type_service = new Wordlift_Entity_Type_Service($this->schema_service); |
|
| 922 | 922 | |
| 923 | 923 | // Create the entity rating service. |
| 924 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 924 | + $this->rating_service = new Wordlift_Rating_Service($this->entity_service, $this->entity_type_service, $this->notice_service); |
|
| 925 | 925 | |
| 926 | 926 | // Create entity list customization (wp-admin/edit.php) |
| 927 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 927 | + $this->entity_list_service = new Wordlift_Entity_List_Service($this->rating_service); |
|
| 928 | 928 | |
| 929 | 929 | // Create a new instance of the Redirect service. |
| 930 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service ); |
|
| 930 | + $this->dashboard_service = new Wordlift_Dashboard_Service($this->rating_service); |
|
| 931 | 931 | |
| 932 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 933 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 932 | + $this->property_factory = new Wordlift_Property_Factory($schema_url_property_service); |
|
| 933 | + $this->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service); |
|
| 934 | 934 | |
| 935 | 935 | $attachment_service = new Wordlift_Attachment_Service(); |
| 936 | 936 | |
| 937 | 937 | // Instantiate the JSON-LD service. |
| 938 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 939 | - $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 ); |
|
| 940 | - $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 ); |
|
| 941 | - $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 ); |
|
| 942 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter ); |
|
| 938 | + $property_getter = Wordlift_Property_Getter_Factory::create($this->entity_service); |
|
| 939 | + $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); |
|
| 940 | + $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); |
|
| 941 | + $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); |
|
| 942 | + $this->jsonld_service = new Wordlift_Jsonld_Service($this->entity_service, $this->postid_to_jsonld_converter); |
|
| 943 | 943 | |
| 944 | 944 | // Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins). |
| 945 | 945 | $this->key_validation_service = new Wordlift_Key_Validation_Service(); |
| 946 | 946 | |
| 947 | 947 | // Create an instance of the Publisher Service and the AJAX Adapter. |
| 948 | 948 | $publisher_service = new Wordlift_Publisher_Service(); |
| 949 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 949 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter($publisher_service); |
|
| 950 | 950 | |
| 951 | 951 | /** Adapters. */ |
| 952 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 952 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter($this); |
|
| 953 | 953 | |
| 954 | 954 | /** Async Tasks. */ |
| 955 | 955 | new Wordlift_Sparql_Query_Async_Task(); |
@@ -962,14 +962,14 @@ discard block |
||
| 962 | 962 | $this->select2_element = new Wordlift_Admin_Select2_Element(); |
| 963 | 963 | $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
| 964 | 964 | $tabs_element = new Wordlift_Admin_Tabs_Element(); |
| 965 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 965 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element($this->configuration_service, $publisher_service, $tabs_element, $this->select2_element); |
|
| 966 | 966 | |
| 967 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 968 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 969 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 967 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service); |
|
| 968 | + $this->settings_page = new Wordlift_Admin_Settings_Page($this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element); |
|
| 969 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link($this->settings_page); |
|
| 970 | 970 | |
| 971 | 971 | // Pages. |
| 972 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 972 | + new Wordlift_Admin_Post_Edit_Page($this); |
|
| 973 | 973 | |
| 974 | 974 | // create an instance of the entity type list admin page controller. |
| 975 | 975 | $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
@@ -981,23 +981,23 @@ discard block |
||
| 981 | 981 | $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
| 982 | 982 | |
| 983 | 983 | //** WordPress Admin */ |
| 984 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 985 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 984 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page($this->configuration_service); |
|
| 985 | + $this->status_page = new Wordlift_Admin_Status_Page($this->entity_service, $this->sparql_service); |
|
| 986 | 986 | |
| 987 | 987 | // Create an instance of the install wizard. |
| 988 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 988 | + $this->admin_setup = new Wordlift_Admin_Setup($this->configuration_service, $this->key_validation_service, $this->entity_service); |
|
| 989 | 989 | |
| 990 | 990 | // Create an instance of the content filter service. |
| 991 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service ); |
|
| 991 | + $this->content_filter_service = new Wordlift_Content_Filter_Service($this->entity_service, $this->configuration_service); |
|
| 992 | 992 | |
| 993 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 993 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service($this->entity_post_type_service); |
|
| 994 | 994 | |
| 995 | 995 | $this->event_entity_page_service = new Wordlift_Event_Entity_Page_Service(); |
| 996 | 996 | |
| 997 | 997 | // Load the debug service if WP is in debug mode. |
| 998 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 999 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1000 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 998 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
| 999 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-debug-service.php'; |
|
| 1000 | + new Wordlift_Debug_Service($this->entity_service, $uri_service); |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | } |
@@ -1014,9 +1014,9 @@ discard block |
||
| 1014 | 1014 | private function set_locale() { |
| 1015 | 1015 | |
| 1016 | 1016 | $plugin_i18n = new Wordlift_i18n(); |
| 1017 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1017 | + $plugin_i18n->set_domain($this->get_plugin_name()); |
|
| 1018 | 1018 | |
| 1019 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1019 | + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
| 1020 | 1020 | |
| 1021 | 1021 | } |
| 1022 | 1022 | |
@@ -1036,119 +1036,119 @@ discard block |
||
| 1036 | 1036 | $this->notice_service |
| 1037 | 1037 | ); |
| 1038 | 1038 | |
| 1039 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1040 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1039 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
| 1040 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); |
|
| 1041 | 1041 | |
| 1042 | 1042 | // Hook the init action to the Topic Taxonomy service. |
| 1043 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1043 | + $this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0); |
|
| 1044 | 1044 | |
| 1045 | 1045 | // Hook the deleted_post_meta action to the Thumbnail service. |
| 1046 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1046 | + $this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4); |
|
| 1047 | 1047 | |
| 1048 | 1048 | // Hook the added_post_meta action to the Thumbnail service. |
| 1049 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1049 | + $this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1050 | 1050 | |
| 1051 | 1051 | // Hook the updated_post_meta action to the Thumbnail service. |
| 1052 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1052 | + $this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 1053 | 1053 | |
| 1054 | 1054 | // Hook posts inserts (or updates) to the user service. |
| 1055 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 1055 | + $this->loader->add_action('wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3); |
|
| 1056 | 1056 | |
| 1057 | 1057 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1058 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1058 | + $this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1059 | 1059 | |
| 1060 | 1060 | // Register custom allowed redirect hosts. |
| 1061 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1061 | + $this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts'); |
|
| 1062 | 1062 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1063 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1063 | + $this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect'); |
|
| 1064 | 1064 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1065 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1065 | + $this->loader->add_action('wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats'); |
|
| 1066 | 1066 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 1067 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1067 | + $this->loader->add_action('wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets'); |
|
| 1068 | 1068 | |
| 1069 | 1069 | // Hook save_post to the entity service to update custom fields (such as alternate labels). |
| 1070 | 1070 | // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
| 1071 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1072 | - $this->loader->add_action( 'save_post_entity', $this->rating_service, 'set_rating_for', 10, 1 ); |
|
| 1071 | + $this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3); |
|
| 1072 | + $this->loader->add_action('save_post_entity', $this->rating_service, 'set_rating_for', 10, 1); |
|
| 1073 | 1073 | |
| 1074 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1075 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1074 | + $this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1); |
|
| 1075 | + $this->loader->add_action('in_admin_header', $this->rating_service, 'in_admin_header'); |
|
| 1076 | 1076 | |
| 1077 | 1077 | // Entity listing customization (wp-admin/edit.php) |
| 1078 | 1078 | // Add custom columns |
| 1079 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1080 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1079 | + $this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns'); |
|
| 1080 | + $this->loader->add_filter('manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2); |
|
| 1081 | 1081 | // Add 4W selection |
| 1082 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1083 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1082 | + $this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope'); |
|
| 1083 | + $this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope'); |
|
| 1084 | 1084 | |
| 1085 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1085 | + $this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args'); |
|
| 1086 | 1086 | |
| 1087 | 1087 | // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
| 1088 | 1088 | // entities. |
| 1089 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1089 | + $this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2); |
|
| 1090 | 1090 | |
| 1091 | 1091 | // Filter imported post meta. |
| 1092 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1092 | + $this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3); |
|
| 1093 | 1093 | |
| 1094 | 1094 | // Notify the import service when an import starts and ends. |
| 1095 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1096 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1095 | + $this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0); |
|
| 1096 | + $this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0); |
|
| 1097 | 1097 | |
| 1098 | 1098 | // Hook the AJAX wl_rebuild action to the Rebuild Service. |
| 1099 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1099 | + $this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild'); |
|
| 1100 | 1100 | |
| 1101 | 1101 | // Hook the menu to the Download Your Data page. |
| 1102 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1103 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1104 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1102 | + $this->loader->add_action('admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0); |
|
| 1103 | + $this->loader->add_action('admin_menu', $this->status_page, 'admin_menu', 100, 0); |
|
| 1104 | + $this->loader->add_action('admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0); |
|
| 1105 | 1105 | |
| 1106 | 1106 | // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
| 1107 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1107 | + $this->loader->add_action('wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10); |
|
| 1108 | 1108 | |
| 1109 | 1109 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1110 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1110 | + $this->loader->add_action('wp_ajax_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1111 | 1111 | |
| 1112 | 1112 | // Hook the AJAX wl_validate_key action to the Key Validation service. |
| 1113 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1113 | + $this->loader->add_action('wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key'); |
|
| 1114 | 1114 | |
| 1115 | 1115 | // Hook the `admin_init` function to the Admin Setup. |
| 1116 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1116 | + $this->loader->add_action('admin_init', $this->admin_setup, 'admin_init'); |
|
| 1117 | 1117 | |
| 1118 | 1118 | // Hook the admin_init to the settings page. |
| 1119 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1119 | + $this->loader->add_action('admin_init', $this->settings_page, 'admin_init'); |
|
| 1120 | 1120 | |
| 1121 | 1121 | // Hook the menu creation on the general wordlift menu creation |
| 1122 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1122 | + $this->loader->add_action('wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2); |
|
| 1123 | 1123 | |
| 1124 | 1124 | // Hook key update. |
| 1125 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1126 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1125 | + $this->loader->add_action('pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2); |
|
| 1126 | + $this->loader->add_action('update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2); |
|
| 1127 | 1127 | |
| 1128 | 1128 | // Add additional action links to the WordLift plugin in the plugins page. |
| 1129 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1129 | + $this->loader->add_filter('plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1); |
|
| 1130 | 1130 | |
| 1131 | 1131 | // Hook the AJAX `wl_publisher` action name. |
| 1132 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1132 | + $this->loader->add_action('wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher'); |
|
| 1133 | 1133 | |
| 1134 | 1134 | // Hook row actions for the entity type list admin. |
| 1135 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1135 | + $this->loader->add_filter('wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2); |
|
| 1136 | 1136 | |
| 1137 | 1137 | // Hook capabilities manipulation to allow access to entity type admin |
| 1138 | 1138 | // page on wordpress versions before 4.7. |
| 1139 | 1139 | global $wp_version; |
| 1140 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1141 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1140 | + if (version_compare($wp_version, '4.7', '<')) { |
|
| 1141 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4); |
|
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | /** Adapters. */ |
| 1145 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1145 | + $this->loader->add_filter('mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1); |
|
| 1146 | 1146 | |
| 1147 | - $this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1147 | + $this->loader->add_action('wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1); |
|
| 1148 | 1148 | |
| 1149 | 1149 | // Hooks to restrict multisite super admin from manipulating entity types. |
| 1150 | - if ( is_multisite() ) { |
|
| 1151 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1150 | + if (is_multisite()) { |
|
| 1151 | + $this->loader->add_filter('map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4); |
|
| 1152 | 1152 | } |
| 1153 | 1153 | } |
| 1154 | 1154 | |
@@ -1161,46 +1161,46 @@ discard block |
||
| 1161 | 1161 | */ |
| 1162 | 1162 | private function define_public_hooks() { |
| 1163 | 1163 | |
| 1164 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1164 | + $plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version()); |
|
| 1165 | 1165 | |
| 1166 | 1166 | // Register the entity post type. |
| 1167 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1167 | + $this->loader->add_action('init', $this->entity_post_type_service, 'register'); |
|
| 1168 | 1168 | |
| 1169 | 1169 | // Bind the link generation and handling hooks to the entity link service. |
| 1170 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1171 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1172 | - $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 ); |
|
| 1173 | - $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 ); |
|
| 1170 | + $this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4); |
|
| 1171 | + $this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1); |
|
| 1172 | + $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); |
|
| 1173 | + $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); |
|
| 1174 | 1174 | |
| 1175 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1176 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1175 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
| 1176 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
| 1177 | 1177 | |
| 1178 | 1178 | // Hook the content filter service to add entity links. |
| 1179 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1179 | + $this->loader->add_filter('the_content', $this->content_filter_service, 'the_content'); |
|
| 1180 | 1180 | |
| 1181 | 1181 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 1182 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1182 | + $this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 1183 | 1183 | |
| 1184 | 1184 | // Hook the ShareThis service. |
| 1185 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1186 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1185 | + $this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99); |
|
| 1186 | + $this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99); |
|
| 1187 | 1187 | |
| 1188 | 1188 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
| 1189 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1189 | + $this->loader->add_action('wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get'); |
|
| 1190 | 1190 | |
| 1191 | 1191 | // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
| 1192 | 1192 | // in order to tweak WP's `WP_Query` to include entities in queries related |
| 1193 | 1193 | // to categories. |
| 1194 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1194 | + $this->loader->add_action('pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1); |
|
| 1195 | 1195 | |
| 1196 | 1196 | /* |
| 1197 | 1197 | * Hook the `pre_get_posts` action to the `Wordlift_Event_Entity_Page_Service` |
| 1198 | 1198 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1199 | 1199 | * order of start time. |
| 1200 | 1200 | */ |
| 1201 | - $this->loader->add_action( 'pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1201 | + $this->loader->add_action('pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1); |
|
| 1202 | 1202 | |
| 1203 | - $this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1203 | + $this->loader->add_action('wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1); |
|
| 1204 | 1204 | |
| 1205 | 1205 | } |
| 1206 | 1206 | |
@@ -29,1219 +29,1219 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class Wordlift { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | - * the plugin. |
|
| 35 | - * |
|
| 36 | - * @since 1.0.0 |
|
| 37 | - * @access protected |
|
| 38 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | - */ |
|
| 40 | - protected $loader; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The unique identifier of this plugin. |
|
| 44 | - * |
|
| 45 | - * @since 1.0.0 |
|
| 46 | - * @access protected |
|
| 47 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | - */ |
|
| 49 | - protected $plugin_name; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * The current version of the plugin. |
|
| 53 | - * |
|
| 54 | - * @since 1.0.0 |
|
| 55 | - * @access protected |
|
| 56 | - * @var string $version The current version of the plugin. |
|
| 57 | - */ |
|
| 58 | - protected $version; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 62 | - * |
|
| 63 | - * @since 3.12.0 |
|
| 64 | - * @access protected |
|
| 65 | - * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 66 | - */ |
|
| 67 | - protected $tinymce_adapter; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * The Thumbnail service. |
|
| 71 | - * |
|
| 72 | - * @since 3.1.5 |
|
| 73 | - * @access private |
|
| 74 | - * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 75 | - */ |
|
| 76 | - private $thumbnail_service; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * The UI service. |
|
| 80 | - * |
|
| 81 | - * @since 3.2.0 |
|
| 82 | - * @access private |
|
| 83 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 84 | - */ |
|
| 85 | - private $ui_service; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * The Schema service. |
|
| 89 | - * |
|
| 90 | - * @since 3.3.0 |
|
| 91 | - * @access private |
|
| 92 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 93 | - */ |
|
| 94 | - private $schema_service; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * The Entity service. |
|
| 98 | - * |
|
| 99 | - * @since 3.1.0 |
|
| 100 | - * @access protected |
|
| 101 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 102 | - */ |
|
| 103 | - protected $entity_service; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * The Topic Taxonomy service. |
|
| 107 | - * |
|
| 108 | - * @since 3.5.0 |
|
| 109 | - * @access private |
|
| 110 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 111 | - */ |
|
| 112 | - private $topic_taxonomy_service; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * The User service. |
|
| 116 | - * |
|
| 117 | - * @since 3.1.7 |
|
| 118 | - * @access protected |
|
| 119 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 120 | - */ |
|
| 121 | - protected $user_service; |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * The Timeline service. |
|
| 125 | - * |
|
| 126 | - * @since 3.1.0 |
|
| 127 | - * @access private |
|
| 128 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 129 | - */ |
|
| 130 | - private $timeline_service; |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * The Redirect service. |
|
| 134 | - * |
|
| 135 | - * @since 3.2.0 |
|
| 136 | - * @access private |
|
| 137 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 138 | - */ |
|
| 139 | - private $redirect_service; |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * The Notice service. |
|
| 143 | - * |
|
| 144 | - * @since 3.3.0 |
|
| 145 | - * @access private |
|
| 146 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 147 | - */ |
|
| 148 | - private $notice_service; |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * The Entity list customization. |
|
| 152 | - * |
|
| 153 | - * @since 3.3.0 |
|
| 154 | - * @access private |
|
| 155 | - * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 156 | - */ |
|
| 157 | - private $entity_list_service; |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * The Entity Types Taxonomy Walker. |
|
| 161 | - * |
|
| 162 | - * @since 3.1.0 |
|
| 163 | - * @access private |
|
| 164 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 165 | - */ |
|
| 166 | - private $entity_types_taxonomy_walker; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * The ShareThis service. |
|
| 170 | - * |
|
| 171 | - * @since 3.2.0 |
|
| 172 | - * @access private |
|
| 173 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 174 | - */ |
|
| 175 | - private $sharethis_service; |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * The PrimaShop adapter. |
|
| 179 | - * |
|
| 180 | - * @since 3.2.3 |
|
| 181 | - * @access private |
|
| 182 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 183 | - */ |
|
| 184 | - private $primashop_adapter; |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * The WordLift Dashboard adapter. |
|
| 188 | - * |
|
| 189 | - * @since 3.4.0 |
|
| 190 | - * @access private |
|
| 191 | - * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 192 | - */ |
|
| 193 | - private $dashboard_service; |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * The entity type service. |
|
| 197 | - * |
|
| 198 | - * @since 3.6.0 |
|
| 199 | - * @access private |
|
| 200 | - * @var \Wordlift_Entity_Post_Type_Service |
|
| 201 | - */ |
|
| 202 | - private $entity_post_type_service; |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 206 | - * |
|
| 207 | - * @since 3.6.0 |
|
| 208 | - * @access private |
|
| 209 | - * @var \Wordlift_Entity_Link_Service |
|
| 210 | - */ |
|
| 211 | - private $entity_link_service; |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 215 | - * |
|
| 216 | - * @var 3.6.0 |
|
| 217 | - * @access protected |
|
| 218 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 219 | - */ |
|
| 220 | - protected $sparql_service; |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * A {@link Wordlift_Import_Service} instance. |
|
| 224 | - * |
|
| 225 | - * @since 3.6.0 |
|
| 226 | - * @access private |
|
| 227 | - * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 228 | - */ |
|
| 229 | - private $import_service; |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * A {@link Wordlift_Rebuild_Service} instance. |
|
| 233 | - * |
|
| 234 | - * @since 3.6.0 |
|
| 235 | - * @access private |
|
| 236 | - * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 237 | - */ |
|
| 238 | - private $rebuild_service; |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * A {@link Wordlift_Jsonld_Service} instance. |
|
| 242 | - * |
|
| 243 | - * @since 3.7.0 |
|
| 244 | - * @access protected |
|
| 245 | - * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 246 | - */ |
|
| 247 | - protected $jsonld_service; |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * |
|
| 251 | - * @since 3.7.0 |
|
| 252 | - * @access private |
|
| 253 | - * @var \Wordlift_Property_Factory $property_factory |
|
| 254 | - */ |
|
| 255 | - private $property_factory; |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * The 'Download Your Data' page. |
|
| 259 | - * |
|
| 260 | - * @since 3.6.0 |
|
| 261 | - * @access private |
|
| 262 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 263 | - */ |
|
| 264 | - private $download_your_data_page; |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * The 'WordLift Settings' page. |
|
| 268 | - * |
|
| 269 | - * @since 3.11.0 |
|
| 270 | - * @access protected |
|
| 271 | - * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 272 | - */ |
|
| 273 | - protected $settings_page; |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * The install wizard page. |
|
| 277 | - * |
|
| 278 | - * @since 3.9.0 |
|
| 279 | - * @access private |
|
| 280 | - * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 281 | - */ |
|
| 282 | - private $admin_setup; |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 286 | - * linking of entities to their pages. |
|
| 287 | - * |
|
| 288 | - * @since 3.8.0 |
|
| 289 | - * @access private |
|
| 290 | - * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 291 | - */ |
|
| 292 | - private $content_filter_service; |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 296 | - * |
|
| 297 | - * @since 3.9.0 |
|
| 298 | - * @access private |
|
| 299 | - * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 300 | - */ |
|
| 301 | - private $key_validation_service; |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * A {@link Wordlift_Rating_Service} instance. |
|
| 305 | - * |
|
| 306 | - * @since 3.10.0 |
|
| 307 | - * @access private |
|
| 308 | - * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 309 | - */ |
|
| 310 | - private $rating_service; |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 314 | - * |
|
| 315 | - * @since 3.10.0 |
|
| 316 | - * @access protected |
|
| 317 | - * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 318 | - */ |
|
| 319 | - protected $post_to_jsonld_converter; |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 323 | - * |
|
| 324 | - * @since 3.10.0 |
|
| 325 | - * @access protected |
|
| 326 | - * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 327 | - */ |
|
| 328 | - protected $configuration_service; |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 332 | - * |
|
| 333 | - * @since 3.10.0 |
|
| 334 | - * @access protected |
|
| 335 | - * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 336 | - */ |
|
| 337 | - protected $entity_type_service; |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 341 | - * |
|
| 342 | - * @since 3.10.0 |
|
| 343 | - * @access protected |
|
| 344 | - * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 345 | - */ |
|
| 346 | - protected $entity_post_to_jsonld_converter; |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 350 | - * |
|
| 351 | - * @since 3.10.0 |
|
| 352 | - * @access protected |
|
| 353 | - * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 354 | - */ |
|
| 355 | - protected $postid_to_jsonld_converter; |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * The {@link Wordlift_Admin_Status_Page} class. |
|
| 359 | - * |
|
| 360 | - * @since 3.9.8 |
|
| 361 | - * @access private |
|
| 362 | - * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 363 | - */ |
|
| 364 | - private $status_page; |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 368 | - * |
|
| 369 | - * @since 3.11.0 |
|
| 370 | - * @access protected |
|
| 371 | - * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 372 | - */ |
|
| 373 | - protected $category_taxonomy_service; |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * The {@link Wordlift_Event_Entity_Page_Service} instance. |
|
| 377 | - * |
|
| 378 | - * @since 3.11.0 |
|
| 379 | - * @access protected |
|
| 380 | - * @var \Wordlift_Event_Entity_Page_Service $event_entity_page_service The {@link Wordlift_Event_Entity_Page_Service} instance. |
|
| 381 | - */ |
|
| 382 | - protected $event_entity_page_service; |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 386 | - * |
|
| 387 | - * @since 3.11.0 |
|
| 388 | - * @access protected |
|
| 389 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 390 | - */ |
|
| 391 | - protected $settings_page_action_link; |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 395 | - * |
|
| 396 | - * @since 3.11.0 |
|
| 397 | - * @access protected |
|
| 398 | - * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 399 | - */ |
|
| 400 | - protected $publisher_ajax_adapter; |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 404 | - * |
|
| 405 | - * @since 3.11.0 |
|
| 406 | - * @access protected |
|
| 407 | - * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 408 | - */ |
|
| 409 | - protected $input_element; |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 413 | - * |
|
| 414 | - * @since 3.13.0 |
|
| 415 | - * @access protected |
|
| 416 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 417 | - */ |
|
| 418 | - protected $radio_input_element; |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 422 | - * |
|
| 423 | - * @since 3.11.0 |
|
| 424 | - * @access protected |
|
| 425 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 426 | - */ |
|
| 427 | - protected $language_select_element; |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 431 | - * |
|
| 432 | - * @since 3.11.0 |
|
| 433 | - * @access protected |
|
| 434 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 435 | - */ |
|
| 436 | - protected $publisher_element; |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 440 | - * |
|
| 441 | - * @since 3.11.0 |
|
| 442 | - * @access protected |
|
| 443 | - * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 444 | - */ |
|
| 445 | - protected $select2_element; |
|
| 446 | - |
|
| 447 | - /** |
|
| 448 | - * The controller for the entity type list admin page |
|
| 449 | - * |
|
| 450 | - * @since 3.11.0 |
|
| 451 | - * @access private |
|
| 452 | - * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 453 | - */ |
|
| 454 | - private $entity_type_admin_page; |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * The controller for the entity type settings admin page |
|
| 458 | - * |
|
| 459 | - * @since 3.11.0 |
|
| 460 | - * @access private |
|
| 461 | - * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 462 | - */ |
|
| 463 | - private $entity_type_settings_admin_page; |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 467 | - * |
|
| 468 | - * @since 3.11.0 |
|
| 469 | - * @access protected |
|
| 470 | - * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 471 | - */ |
|
| 472 | - protected $related_entities_cloud_widget; |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * {@link Wordlift}'s singleton instance. |
|
| 476 | - * |
|
| 477 | - * @since 3.11.2 |
|
| 478 | - * |
|
| 479 | - * @since 3.11.2 |
|
| 480 | - * @access private |
|
| 481 | - * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 482 | - */ |
|
| 483 | - private static $instance; |
|
| 484 | - |
|
| 485 | - /** |
|
| 486 | - * Define the core functionality of the plugin. |
|
| 487 | - * |
|
| 488 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 489 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 490 | - * the public-facing side of the site. |
|
| 491 | - * |
|
| 492 | - * @since 1.0.0 |
|
| 493 | - */ |
|
| 494 | - public function __construct() { |
|
| 495 | - |
|
| 496 | - $this->plugin_name = 'wordlift'; |
|
| 497 | - $this->version = '3.14.0-dev'; |
|
| 498 | - $this->load_dependencies(); |
|
| 499 | - $this->set_locale(); |
|
| 500 | - $this->define_admin_hooks(); |
|
| 501 | - $this->define_public_hooks(); |
|
| 502 | - |
|
| 503 | - self::$instance = $this; |
|
| 504 | - |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - /** |
|
| 508 | - * Get the singleton instance. |
|
| 509 | - * |
|
| 510 | - * @since 3.11.2 |
|
| 511 | - * |
|
| 512 | - * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 513 | - */ |
|
| 514 | - public static function get_instance() { |
|
| 515 | - |
|
| 516 | - return self::$instance; |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - /** |
|
| 520 | - * Load the required dependencies for this plugin. |
|
| 521 | - * |
|
| 522 | - * Include the following files that make up the plugin: |
|
| 523 | - * |
|
| 524 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 525 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 526 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 527 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 528 | - * |
|
| 529 | - * Create an instance of the loader which will be used to register the hooks |
|
| 530 | - * with WordPress. |
|
| 531 | - * |
|
| 532 | - * @since 1.0.0 |
|
| 533 | - * @access private |
|
| 534 | - */ |
|
| 535 | - private function load_dependencies() { |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * The class responsible for orchestrating the actions and filters of the |
|
| 539 | - * core plugin. |
|
| 540 | - */ |
|
| 541 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 542 | - |
|
| 543 | - /** |
|
| 544 | - * The class responsible for defining internationalization functionality |
|
| 545 | - * of the plugin. |
|
| 546 | - */ |
|
| 547 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 548 | - |
|
| 549 | - /** |
|
| 550 | - * WordLift's supported languages. |
|
| 551 | - */ |
|
| 552 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 553 | - |
|
| 554 | - /** |
|
| 555 | - * Provide support functions to sanitize data. |
|
| 556 | - */ |
|
| 557 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * The Redirect service. |
|
| 561 | - */ |
|
| 562 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 563 | - |
|
| 564 | - /** |
|
| 565 | - * The Log service. |
|
| 566 | - */ |
|
| 567 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 568 | - |
|
| 569 | - /** |
|
| 570 | - * The configuration service. |
|
| 571 | - */ |
|
| 572 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 573 | - |
|
| 574 | - /** |
|
| 575 | - * The entity post type service (this is the WordPress post type, not the entity schema type). |
|
| 576 | - */ |
|
| 577 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 578 | - |
|
| 579 | - /** |
|
| 580 | - * The entity type service (i.e. the schema type). |
|
| 581 | - */ |
|
| 582 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 583 | - |
|
| 584 | - /** |
|
| 585 | - * The entity link service. |
|
| 586 | - */ |
|
| 587 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 588 | - |
|
| 589 | - /** |
|
| 590 | - * The Query builder. |
|
| 591 | - */ |
|
| 592 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 593 | - |
|
| 594 | - /** |
|
| 595 | - * The Schema service. |
|
| 596 | - */ |
|
| 597 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 598 | - |
|
| 599 | - /** |
|
| 600 | - * The schema:url property service. |
|
| 601 | - */ |
|
| 602 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 603 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 604 | - |
|
| 605 | - /** |
|
| 606 | - * The UI service. |
|
| 607 | - */ |
|
| 608 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 609 | - |
|
| 610 | - /** |
|
| 611 | - * The Thumbnail service. |
|
| 612 | - */ |
|
| 613 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 614 | - |
|
| 615 | - /** |
|
| 616 | - * The Entity Types Taxonomy service. |
|
| 617 | - */ |
|
| 618 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 619 | - |
|
| 620 | - /** |
|
| 621 | - * The Entity service. |
|
| 622 | - */ |
|
| 623 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 624 | - |
|
| 625 | - // Add the entity rating service. |
|
| 626 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 627 | - |
|
| 628 | - /** |
|
| 629 | - * The User service. |
|
| 630 | - */ |
|
| 631 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 632 | - |
|
| 633 | - /** |
|
| 634 | - * The Timeline service. |
|
| 635 | - */ |
|
| 636 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 637 | - |
|
| 638 | - /** |
|
| 639 | - * The Topic Taxonomy service. |
|
| 640 | - */ |
|
| 641 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 642 | - |
|
| 643 | - /** |
|
| 644 | - * The SPARQL service. |
|
| 645 | - */ |
|
| 646 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 647 | - |
|
| 648 | - /** |
|
| 649 | - * The WordLift import service. |
|
| 650 | - */ |
|
| 651 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 652 | - |
|
| 653 | - /** |
|
| 654 | - * The WordLift URI service. |
|
| 655 | - */ |
|
| 656 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 657 | - |
|
| 658 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 659 | - |
|
| 660 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 661 | - |
|
| 662 | - /** |
|
| 663 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 664 | - */ |
|
| 665 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 666 | - |
|
| 667 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 668 | - |
|
| 669 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 670 | - |
|
| 671 | - /** |
|
| 672 | - * Load the converters. |
|
| 673 | - */ |
|
| 674 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 675 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 676 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 677 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 678 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 679 | - |
|
| 680 | - /** |
|
| 681 | - * Load the content filter. |
|
| 682 | - */ |
|
| 683 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 684 | - |
|
| 685 | - /* |
|
| 32 | + /** |
|
| 33 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | + * the plugin. |
|
| 35 | + * |
|
| 36 | + * @since 1.0.0 |
|
| 37 | + * @access protected |
|
| 38 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | + */ |
|
| 40 | + protected $loader; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The unique identifier of this plugin. |
|
| 44 | + * |
|
| 45 | + * @since 1.0.0 |
|
| 46 | + * @access protected |
|
| 47 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | + */ |
|
| 49 | + protected $plugin_name; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * The current version of the plugin. |
|
| 53 | + * |
|
| 54 | + * @since 1.0.0 |
|
| 55 | + * @access protected |
|
| 56 | + * @var string $version The current version of the plugin. |
|
| 57 | + */ |
|
| 58 | + protected $version; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 62 | + * |
|
| 63 | + * @since 3.12.0 |
|
| 64 | + * @access protected |
|
| 65 | + * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 66 | + */ |
|
| 67 | + protected $tinymce_adapter; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The Thumbnail service. |
|
| 71 | + * |
|
| 72 | + * @since 3.1.5 |
|
| 73 | + * @access private |
|
| 74 | + * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 75 | + */ |
|
| 76 | + private $thumbnail_service; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * The UI service. |
|
| 80 | + * |
|
| 81 | + * @since 3.2.0 |
|
| 82 | + * @access private |
|
| 83 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 84 | + */ |
|
| 85 | + private $ui_service; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * The Schema service. |
|
| 89 | + * |
|
| 90 | + * @since 3.3.0 |
|
| 91 | + * @access private |
|
| 92 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 93 | + */ |
|
| 94 | + private $schema_service; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * The Entity service. |
|
| 98 | + * |
|
| 99 | + * @since 3.1.0 |
|
| 100 | + * @access protected |
|
| 101 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 102 | + */ |
|
| 103 | + protected $entity_service; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * The Topic Taxonomy service. |
|
| 107 | + * |
|
| 108 | + * @since 3.5.0 |
|
| 109 | + * @access private |
|
| 110 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 111 | + */ |
|
| 112 | + private $topic_taxonomy_service; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * The User service. |
|
| 116 | + * |
|
| 117 | + * @since 3.1.7 |
|
| 118 | + * @access protected |
|
| 119 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 120 | + */ |
|
| 121 | + protected $user_service; |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * The Timeline service. |
|
| 125 | + * |
|
| 126 | + * @since 3.1.0 |
|
| 127 | + * @access private |
|
| 128 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 129 | + */ |
|
| 130 | + private $timeline_service; |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * The Redirect service. |
|
| 134 | + * |
|
| 135 | + * @since 3.2.0 |
|
| 136 | + * @access private |
|
| 137 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 138 | + */ |
|
| 139 | + private $redirect_service; |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * The Notice service. |
|
| 143 | + * |
|
| 144 | + * @since 3.3.0 |
|
| 145 | + * @access private |
|
| 146 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 147 | + */ |
|
| 148 | + private $notice_service; |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * The Entity list customization. |
|
| 152 | + * |
|
| 153 | + * @since 3.3.0 |
|
| 154 | + * @access private |
|
| 155 | + * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 156 | + */ |
|
| 157 | + private $entity_list_service; |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * The Entity Types Taxonomy Walker. |
|
| 161 | + * |
|
| 162 | + * @since 3.1.0 |
|
| 163 | + * @access private |
|
| 164 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 165 | + */ |
|
| 166 | + private $entity_types_taxonomy_walker; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * The ShareThis service. |
|
| 170 | + * |
|
| 171 | + * @since 3.2.0 |
|
| 172 | + * @access private |
|
| 173 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 174 | + */ |
|
| 175 | + private $sharethis_service; |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * The PrimaShop adapter. |
|
| 179 | + * |
|
| 180 | + * @since 3.2.3 |
|
| 181 | + * @access private |
|
| 182 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 183 | + */ |
|
| 184 | + private $primashop_adapter; |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * The WordLift Dashboard adapter. |
|
| 188 | + * |
|
| 189 | + * @since 3.4.0 |
|
| 190 | + * @access private |
|
| 191 | + * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 192 | + */ |
|
| 193 | + private $dashboard_service; |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * The entity type service. |
|
| 197 | + * |
|
| 198 | + * @since 3.6.0 |
|
| 199 | + * @access private |
|
| 200 | + * @var \Wordlift_Entity_Post_Type_Service |
|
| 201 | + */ |
|
| 202 | + private $entity_post_type_service; |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 206 | + * |
|
| 207 | + * @since 3.6.0 |
|
| 208 | + * @access private |
|
| 209 | + * @var \Wordlift_Entity_Link_Service |
|
| 210 | + */ |
|
| 211 | + private $entity_link_service; |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 215 | + * |
|
| 216 | + * @var 3.6.0 |
|
| 217 | + * @access protected |
|
| 218 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 219 | + */ |
|
| 220 | + protected $sparql_service; |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * A {@link Wordlift_Import_Service} instance. |
|
| 224 | + * |
|
| 225 | + * @since 3.6.0 |
|
| 226 | + * @access private |
|
| 227 | + * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 228 | + */ |
|
| 229 | + private $import_service; |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * A {@link Wordlift_Rebuild_Service} instance. |
|
| 233 | + * |
|
| 234 | + * @since 3.6.0 |
|
| 235 | + * @access private |
|
| 236 | + * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 237 | + */ |
|
| 238 | + private $rebuild_service; |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * A {@link Wordlift_Jsonld_Service} instance. |
|
| 242 | + * |
|
| 243 | + * @since 3.7.0 |
|
| 244 | + * @access protected |
|
| 245 | + * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 246 | + */ |
|
| 247 | + protected $jsonld_service; |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * |
|
| 251 | + * @since 3.7.0 |
|
| 252 | + * @access private |
|
| 253 | + * @var \Wordlift_Property_Factory $property_factory |
|
| 254 | + */ |
|
| 255 | + private $property_factory; |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * The 'Download Your Data' page. |
|
| 259 | + * |
|
| 260 | + * @since 3.6.0 |
|
| 261 | + * @access private |
|
| 262 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 263 | + */ |
|
| 264 | + private $download_your_data_page; |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * The 'WordLift Settings' page. |
|
| 268 | + * |
|
| 269 | + * @since 3.11.0 |
|
| 270 | + * @access protected |
|
| 271 | + * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 272 | + */ |
|
| 273 | + protected $settings_page; |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * The install wizard page. |
|
| 277 | + * |
|
| 278 | + * @since 3.9.0 |
|
| 279 | + * @access private |
|
| 280 | + * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 281 | + */ |
|
| 282 | + private $admin_setup; |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 286 | + * linking of entities to their pages. |
|
| 287 | + * |
|
| 288 | + * @since 3.8.0 |
|
| 289 | + * @access private |
|
| 290 | + * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 291 | + */ |
|
| 292 | + private $content_filter_service; |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 296 | + * |
|
| 297 | + * @since 3.9.0 |
|
| 298 | + * @access private |
|
| 299 | + * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 300 | + */ |
|
| 301 | + private $key_validation_service; |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * A {@link Wordlift_Rating_Service} instance. |
|
| 305 | + * |
|
| 306 | + * @since 3.10.0 |
|
| 307 | + * @access private |
|
| 308 | + * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 309 | + */ |
|
| 310 | + private $rating_service; |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 314 | + * |
|
| 315 | + * @since 3.10.0 |
|
| 316 | + * @access protected |
|
| 317 | + * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 318 | + */ |
|
| 319 | + protected $post_to_jsonld_converter; |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 323 | + * |
|
| 324 | + * @since 3.10.0 |
|
| 325 | + * @access protected |
|
| 326 | + * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 327 | + */ |
|
| 328 | + protected $configuration_service; |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 332 | + * |
|
| 333 | + * @since 3.10.0 |
|
| 334 | + * @access protected |
|
| 335 | + * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 336 | + */ |
|
| 337 | + protected $entity_type_service; |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 341 | + * |
|
| 342 | + * @since 3.10.0 |
|
| 343 | + * @access protected |
|
| 344 | + * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 345 | + */ |
|
| 346 | + protected $entity_post_to_jsonld_converter; |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 350 | + * |
|
| 351 | + * @since 3.10.0 |
|
| 352 | + * @access protected |
|
| 353 | + * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 354 | + */ |
|
| 355 | + protected $postid_to_jsonld_converter; |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * The {@link Wordlift_Admin_Status_Page} class. |
|
| 359 | + * |
|
| 360 | + * @since 3.9.8 |
|
| 361 | + * @access private |
|
| 362 | + * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class. |
|
| 363 | + */ |
|
| 364 | + private $status_page; |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 368 | + * |
|
| 369 | + * @since 3.11.0 |
|
| 370 | + * @access protected |
|
| 371 | + * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 372 | + */ |
|
| 373 | + protected $category_taxonomy_service; |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * The {@link Wordlift_Event_Entity_Page_Service} instance. |
|
| 377 | + * |
|
| 378 | + * @since 3.11.0 |
|
| 379 | + * @access protected |
|
| 380 | + * @var \Wordlift_Event_Entity_Page_Service $event_entity_page_service The {@link Wordlift_Event_Entity_Page_Service} instance. |
|
| 381 | + */ |
|
| 382 | + protected $event_entity_page_service; |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 386 | + * |
|
| 387 | + * @since 3.11.0 |
|
| 388 | + * @access protected |
|
| 389 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 390 | + */ |
|
| 391 | + protected $settings_page_action_link; |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 395 | + * |
|
| 396 | + * @since 3.11.0 |
|
| 397 | + * @access protected |
|
| 398 | + * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 399 | + */ |
|
| 400 | + protected $publisher_ajax_adapter; |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 404 | + * |
|
| 405 | + * @since 3.11.0 |
|
| 406 | + * @access protected |
|
| 407 | + * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 408 | + */ |
|
| 409 | + protected $input_element; |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 413 | + * |
|
| 414 | + * @since 3.13.0 |
|
| 415 | + * @access protected |
|
| 416 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 417 | + */ |
|
| 418 | + protected $radio_input_element; |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 422 | + * |
|
| 423 | + * @since 3.11.0 |
|
| 424 | + * @access protected |
|
| 425 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 426 | + */ |
|
| 427 | + protected $language_select_element; |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 431 | + * |
|
| 432 | + * @since 3.11.0 |
|
| 433 | + * @access protected |
|
| 434 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 435 | + */ |
|
| 436 | + protected $publisher_element; |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 440 | + * |
|
| 441 | + * @since 3.11.0 |
|
| 442 | + * @access protected |
|
| 443 | + * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 444 | + */ |
|
| 445 | + protected $select2_element; |
|
| 446 | + |
|
| 447 | + /** |
|
| 448 | + * The controller for the entity type list admin page |
|
| 449 | + * |
|
| 450 | + * @since 3.11.0 |
|
| 451 | + * @access private |
|
| 452 | + * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 453 | + */ |
|
| 454 | + private $entity_type_admin_page; |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * The controller for the entity type settings admin page |
|
| 458 | + * |
|
| 459 | + * @since 3.11.0 |
|
| 460 | + * @access private |
|
| 461 | + * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 462 | + */ |
|
| 463 | + private $entity_type_settings_admin_page; |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 467 | + * |
|
| 468 | + * @since 3.11.0 |
|
| 469 | + * @access protected |
|
| 470 | + * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 471 | + */ |
|
| 472 | + protected $related_entities_cloud_widget; |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * {@link Wordlift}'s singleton instance. |
|
| 476 | + * |
|
| 477 | + * @since 3.11.2 |
|
| 478 | + * |
|
| 479 | + * @since 3.11.2 |
|
| 480 | + * @access private |
|
| 481 | + * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 482 | + */ |
|
| 483 | + private static $instance; |
|
| 484 | + |
|
| 485 | + /** |
|
| 486 | + * Define the core functionality of the plugin. |
|
| 487 | + * |
|
| 488 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 489 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 490 | + * the public-facing side of the site. |
|
| 491 | + * |
|
| 492 | + * @since 1.0.0 |
|
| 493 | + */ |
|
| 494 | + public function __construct() { |
|
| 495 | + |
|
| 496 | + $this->plugin_name = 'wordlift'; |
|
| 497 | + $this->version = '3.14.0-dev'; |
|
| 498 | + $this->load_dependencies(); |
|
| 499 | + $this->set_locale(); |
|
| 500 | + $this->define_admin_hooks(); |
|
| 501 | + $this->define_public_hooks(); |
|
| 502 | + |
|
| 503 | + self::$instance = $this; |
|
| 504 | + |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + /** |
|
| 508 | + * Get the singleton instance. |
|
| 509 | + * |
|
| 510 | + * @since 3.11.2 |
|
| 511 | + * |
|
| 512 | + * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 513 | + */ |
|
| 514 | + public static function get_instance() { |
|
| 515 | + |
|
| 516 | + return self::$instance; |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + /** |
|
| 520 | + * Load the required dependencies for this plugin. |
|
| 521 | + * |
|
| 522 | + * Include the following files that make up the plugin: |
|
| 523 | + * |
|
| 524 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 525 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 526 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 527 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 528 | + * |
|
| 529 | + * Create an instance of the loader which will be used to register the hooks |
|
| 530 | + * with WordPress. |
|
| 531 | + * |
|
| 532 | + * @since 1.0.0 |
|
| 533 | + * @access private |
|
| 534 | + */ |
|
| 535 | + private function load_dependencies() { |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * The class responsible for orchestrating the actions and filters of the |
|
| 539 | + * core plugin. |
|
| 540 | + */ |
|
| 541 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 542 | + |
|
| 543 | + /** |
|
| 544 | + * The class responsible for defining internationalization functionality |
|
| 545 | + * of the plugin. |
|
| 546 | + */ |
|
| 547 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 548 | + |
|
| 549 | + /** |
|
| 550 | + * WordLift's supported languages. |
|
| 551 | + */ |
|
| 552 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 553 | + |
|
| 554 | + /** |
|
| 555 | + * Provide support functions to sanitize data. |
|
| 556 | + */ |
|
| 557 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * The Redirect service. |
|
| 561 | + */ |
|
| 562 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 563 | + |
|
| 564 | + /** |
|
| 565 | + * The Log service. |
|
| 566 | + */ |
|
| 567 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 568 | + |
|
| 569 | + /** |
|
| 570 | + * The configuration service. |
|
| 571 | + */ |
|
| 572 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 573 | + |
|
| 574 | + /** |
|
| 575 | + * The entity post type service (this is the WordPress post type, not the entity schema type). |
|
| 576 | + */ |
|
| 577 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 578 | + |
|
| 579 | + /** |
|
| 580 | + * The entity type service (i.e. the schema type). |
|
| 581 | + */ |
|
| 582 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 583 | + |
|
| 584 | + /** |
|
| 585 | + * The entity link service. |
|
| 586 | + */ |
|
| 587 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 588 | + |
|
| 589 | + /** |
|
| 590 | + * The Query builder. |
|
| 591 | + */ |
|
| 592 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 593 | + |
|
| 594 | + /** |
|
| 595 | + * The Schema service. |
|
| 596 | + */ |
|
| 597 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 598 | + |
|
| 599 | + /** |
|
| 600 | + * The schema:url property service. |
|
| 601 | + */ |
|
| 602 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 603 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 604 | + |
|
| 605 | + /** |
|
| 606 | + * The UI service. |
|
| 607 | + */ |
|
| 608 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 609 | + |
|
| 610 | + /** |
|
| 611 | + * The Thumbnail service. |
|
| 612 | + */ |
|
| 613 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 614 | + |
|
| 615 | + /** |
|
| 616 | + * The Entity Types Taxonomy service. |
|
| 617 | + */ |
|
| 618 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 619 | + |
|
| 620 | + /** |
|
| 621 | + * The Entity service. |
|
| 622 | + */ |
|
| 623 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 624 | + |
|
| 625 | + // Add the entity rating service. |
|
| 626 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 627 | + |
|
| 628 | + /** |
|
| 629 | + * The User service. |
|
| 630 | + */ |
|
| 631 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 632 | + |
|
| 633 | + /** |
|
| 634 | + * The Timeline service. |
|
| 635 | + */ |
|
| 636 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 637 | + |
|
| 638 | + /** |
|
| 639 | + * The Topic Taxonomy service. |
|
| 640 | + */ |
|
| 641 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 642 | + |
|
| 643 | + /** |
|
| 644 | + * The SPARQL service. |
|
| 645 | + */ |
|
| 646 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 647 | + |
|
| 648 | + /** |
|
| 649 | + * The WordLift import service. |
|
| 650 | + */ |
|
| 651 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 652 | + |
|
| 653 | + /** |
|
| 654 | + * The WordLift URI service. |
|
| 655 | + */ |
|
| 656 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 657 | + |
|
| 658 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 659 | + |
|
| 660 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 661 | + |
|
| 662 | + /** |
|
| 663 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 664 | + */ |
|
| 665 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 666 | + |
|
| 667 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 668 | + |
|
| 669 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 670 | + |
|
| 671 | + /** |
|
| 672 | + * Load the converters. |
|
| 673 | + */ |
|
| 674 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 675 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 676 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 677 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 678 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 679 | + |
|
| 680 | + /** |
|
| 681 | + * Load the content filter. |
|
| 682 | + */ |
|
| 683 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 684 | + |
|
| 685 | + /* |
|
| 686 | 686 | * Load the excerpt helper. |
| 687 | 687 | */ |
| 688 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 689 | - |
|
| 690 | - /** |
|
| 691 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 692 | - * |
|
| 693 | - * @since 3.8.0 |
|
| 694 | - */ |
|
| 695 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 696 | - |
|
| 697 | - // The Publisher Service and the AJAX adapter. |
|
| 698 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 699 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 700 | - |
|
| 701 | - /** |
|
| 702 | - * Load the WordLift key validation service. |
|
| 703 | - */ |
|
| 704 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 705 | - |
|
| 706 | - // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 707 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 708 | - |
|
| 709 | - // Load the `Wordlift_Event_Entity_Page_Service` class definition. |
|
| 710 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-event-entity-page-service.php'; |
|
| 711 | - |
|
| 712 | - /** Adapters. */ |
|
| 713 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 714 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 715 | - |
|
| 716 | - /** Async Tasks. */ |
|
| 717 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/wp-async-task.php'; |
|
| 718 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 719 | - |
|
| 720 | - /** |
|
| 721 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 722 | - */ |
|
| 723 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 724 | - |
|
| 725 | - /** |
|
| 726 | - * The class to customize the entity list admin page. |
|
| 727 | - */ |
|
| 728 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 732 | - */ |
|
| 733 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 734 | - |
|
| 735 | - /** |
|
| 736 | - * The Notice service. |
|
| 737 | - */ |
|
| 738 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 739 | - |
|
| 740 | - /** |
|
| 741 | - * The PrimaShop adapter. |
|
| 742 | - */ |
|
| 743 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 744 | - |
|
| 745 | - /** |
|
| 746 | - * The WordLift Dashboard service. |
|
| 747 | - */ |
|
| 748 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 749 | - |
|
| 750 | - /** |
|
| 751 | - * The admin 'Install wizard' page. |
|
| 752 | - */ |
|
| 753 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 688 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 689 | + |
|
| 690 | + /** |
|
| 691 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 692 | + * |
|
| 693 | + * @since 3.8.0 |
|
| 694 | + */ |
|
| 695 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 696 | + |
|
| 697 | + // The Publisher Service and the AJAX adapter. |
|
| 698 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 699 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * Load the WordLift key validation service. |
|
| 703 | + */ |
|
| 704 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 705 | + |
|
| 706 | + // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 707 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 708 | + |
|
| 709 | + // Load the `Wordlift_Event_Entity_Page_Service` class definition. |
|
| 710 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-event-entity-page-service.php'; |
|
| 711 | + |
|
| 712 | + /** Adapters. */ |
|
| 713 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 714 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 715 | + |
|
| 716 | + /** Async Tasks. */ |
|
| 717 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/wp-async-task.php'; |
|
| 718 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php'; |
|
| 719 | + |
|
| 720 | + /** |
|
| 721 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 722 | + */ |
|
| 723 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 724 | + |
|
| 725 | + /** |
|
| 726 | + * The class to customize the entity list admin page. |
|
| 727 | + */ |
|
| 728 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 732 | + */ |
|
| 733 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 734 | + |
|
| 735 | + /** |
|
| 736 | + * The Notice service. |
|
| 737 | + */ |
|
| 738 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 739 | + |
|
| 740 | + /** |
|
| 741 | + * The PrimaShop adapter. |
|
| 742 | + */ |
|
| 743 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 744 | + |
|
| 745 | + /** |
|
| 746 | + * The WordLift Dashboard service. |
|
| 747 | + */ |
|
| 748 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 749 | + |
|
| 750 | + /** |
|
| 751 | + * The admin 'Install wizard' page. |
|
| 752 | + */ |
|
| 753 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 754 | + |
|
| 755 | + /** |
|
| 756 | + * The WordLift entity type list admin page controller. |
|
| 757 | + */ |
|
| 758 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 759 | + |
|
| 760 | + /** |
|
| 761 | + * The WordLift entity type settings admin page controller. |
|
| 762 | + */ |
|
| 763 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 764 | + |
|
| 765 | + /** |
|
| 766 | + * The admin 'Download Your Data' page. |
|
| 767 | + */ |
|
| 768 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 769 | + |
|
| 770 | + /** |
|
| 771 | + * The admin 'Download Your Data' page. |
|
| 772 | + */ |
|
| 773 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 774 | + |
|
| 775 | + /** |
|
| 776 | + * The admin 'WordLift Settings' page. |
|
| 777 | + */ |
|
| 778 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 779 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 780 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 781 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 782 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 783 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 784 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 785 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 786 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 787 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 788 | + |
|
| 789 | + /** Admin Pages */ |
|
| 790 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 791 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 792 | + |
|
| 793 | + /** |
|
| 794 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 795 | + * side of the site. |
|
| 796 | + */ |
|
| 797 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 798 | + |
|
| 799 | + /** |
|
| 800 | + * The shortcode abstract class. |
|
| 801 | + */ |
|
| 802 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 803 | + |
|
| 804 | + /** |
|
| 805 | + * The Timeline shortcode. |
|
| 806 | + */ |
|
| 807 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 808 | + |
|
| 809 | + /** |
|
| 810 | + * The Navigator shortcode. |
|
| 811 | + */ |
|
| 812 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 813 | + |
|
| 814 | + /** |
|
| 815 | + * The chord shortcode. |
|
| 816 | + */ |
|
| 817 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 818 | + |
|
| 819 | + /** |
|
| 820 | + * The geomap shortcode. |
|
| 821 | + */ |
|
| 822 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 823 | + |
|
| 824 | + /** |
|
| 825 | + * The entity cloud shortcode. |
|
| 826 | + */ |
|
| 827 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 754 | 828 | |
| 755 | - /** |
|
| 756 | - * The WordLift entity type list admin page controller. |
|
| 757 | - */ |
|
| 758 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 759 | - |
|
| 760 | - /** |
|
| 761 | - * The WordLift entity type settings admin page controller. |
|
| 762 | - */ |
|
| 763 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 764 | - |
|
| 765 | - /** |
|
| 766 | - * The admin 'Download Your Data' page. |
|
| 767 | - */ |
|
| 768 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 769 | - |
|
| 770 | - /** |
|
| 771 | - * The admin 'Download Your Data' page. |
|
| 772 | - */ |
|
| 773 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 774 | - |
|
| 775 | - /** |
|
| 776 | - * The admin 'WordLift Settings' page. |
|
| 777 | - */ |
|
| 778 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php'; |
|
| 779 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php'; |
|
| 780 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php'; |
|
| 781 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php'; |
|
| 782 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php'; |
|
| 783 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php'; |
|
| 784 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php'; |
|
| 785 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 786 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 787 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 788 | - |
|
| 789 | - /** Admin Pages */ |
|
| 790 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 791 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php'; |
|
| 792 | - |
|
| 793 | - /** |
|
| 794 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 795 | - * side of the site. |
|
| 796 | - */ |
|
| 797 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 798 | - |
|
| 799 | - /** |
|
| 800 | - * The shortcode abstract class. |
|
| 801 | - */ |
|
| 802 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 803 | - |
|
| 804 | - /** |
|
| 805 | - * The Timeline shortcode. |
|
| 806 | - */ |
|
| 807 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 808 | - |
|
| 809 | - /** |
|
| 810 | - * The Navigator shortcode. |
|
| 811 | - */ |
|
| 812 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 829 | + /** |
|
| 830 | + * The ShareThis service. |
|
| 831 | + */ |
|
| 832 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 813 | 833 | |
| 814 | - /** |
|
| 815 | - * The chord shortcode. |
|
| 816 | - */ |
|
| 817 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 834 | + /** |
|
| 835 | + * The SEO service. |
|
| 836 | + */ |
|
| 837 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 818 | 838 | |
| 819 | - /** |
|
| 820 | - * The geomap shortcode. |
|
| 821 | - */ |
|
| 822 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 823 | - |
|
| 824 | - /** |
|
| 825 | - * The entity cloud shortcode. |
|
| 826 | - */ |
|
| 827 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 828 | - |
|
| 829 | - /** |
|
| 830 | - * The ShareThis service. |
|
| 831 | - */ |
|
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 833 | - |
|
| 834 | - /** |
|
| 835 | - * The SEO service. |
|
| 836 | - */ |
|
| 837 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 838 | - |
|
| 839 | - /** |
|
| 840 | - * The AMP service. |
|
| 841 | - */ |
|
| 842 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 839 | + /** |
|
| 840 | + * The AMP service. |
|
| 841 | + */ |
|
| 842 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 843 | 843 | |
| 844 | - /** Widgets */ |
|
| 845 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 846 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 844 | + /** Widgets */ |
|
| 845 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 846 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 847 | 847 | |
| 848 | - $this->loader = new Wordlift_Loader(); |
|
| 848 | + $this->loader = new Wordlift_Loader(); |
|
| 849 | 849 | |
| 850 | - // Instantiate a global logger. |
|
| 851 | - global $wl_logger; |
|
| 852 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 850 | + // Instantiate a global logger. |
|
| 851 | + global $wl_logger; |
|
| 852 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 853 | 853 | |
| 854 | - // Create the configuration service. |
|
| 855 | - $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 854 | + // Create the configuration service. |
|
| 855 | + $this->configuration_service = new Wordlift_Configuration_Service(); |
|
| 856 | 856 | |
| 857 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 858 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 857 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 858 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() ); |
|
| 859 | 859 | |
| 860 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 861 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 860 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 861 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() ); |
|
| 862 | 862 | |
| 863 | - // Create an instance of the UI service. |
|
| 864 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 863 | + // Create an instance of the UI service. |
|
| 864 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 865 | 865 | |
| 866 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 867 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 866 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 867 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 868 | 868 | |
| 869 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 869 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 870 | 870 | |
| 871 | - // Create an instance of the Schema service. |
|
| 872 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 873 | - $this->schema_service = new Wordlift_Schema_Service(); |
|
| 871 | + // Create an instance of the Schema service. |
|
| 872 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 873 | + $this->schema_service = new Wordlift_Schema_Service(); |
|
| 874 | 874 | |
| 875 | - // Create an instance of the Notice service. |
|
| 876 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 875 | + // Create an instance of the Notice service. |
|
| 876 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 877 | 877 | |
| 878 | - // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 879 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service ); |
|
| 878 | + // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 879 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service ); |
|
| 880 | 880 | |
| 881 | - // Create an instance of the User service. |
|
| 882 | - $this->user_service = new Wordlift_User_Service(); |
|
| 881 | + // Create an instance of the User service. |
|
| 882 | + $this->user_service = new Wordlift_User_Service(); |
|
| 883 | 883 | |
| 884 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 885 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 884 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 885 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 886 | 886 | |
| 887 | - // Create a new instance of the Redirect service. |
|
| 888 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 887 | + // Create a new instance of the Redirect service. |
|
| 888 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 889 | 889 | |
| 890 | - // Initialize the shortcodes. |
|
| 891 | - new Wordlift_Navigator_Shortcode(); |
|
| 892 | - new Wordlift_Chord_Shortcode(); |
|
| 893 | - new Wordlift_Geomap_Shortcode(); |
|
| 894 | - new Wordlift_Timeline_Shortcode(); |
|
| 895 | - new Wordlift_Related_Entities_Cloud_Shortcode(); |
|
| 890 | + // Initialize the shortcodes. |
|
| 891 | + new Wordlift_Navigator_Shortcode(); |
|
| 892 | + new Wordlift_Chord_Shortcode(); |
|
| 893 | + new Wordlift_Geomap_Shortcode(); |
|
| 894 | + new Wordlift_Timeline_Shortcode(); |
|
| 895 | + new Wordlift_Related_Entities_Cloud_Shortcode(); |
|
| 896 | 896 | |
| 897 | - // Initialize the SEO service. |
|
| 898 | - new Wordlift_Seo_Service(); |
|
| 897 | + // Initialize the SEO service. |
|
| 898 | + new Wordlift_Seo_Service(); |
|
| 899 | 899 | |
| 900 | - // Initialize the AMP service. |
|
| 901 | - new Wordlift_AMP_Service(); |
|
| 900 | + // Initialize the AMP service. |
|
| 901 | + new Wordlift_AMP_Service(); |
|
| 902 | 902 | |
| 903 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 903 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 904 | 904 | |
| 905 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 905 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 906 | 906 | |
| 907 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 908 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 907 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 908 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 909 | 909 | |
| 910 | - // Create an instance of the PrimaShop adapter. |
|
| 911 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 910 | + // Create an instance of the PrimaShop adapter. |
|
| 911 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 912 | 912 | |
| 913 | - // Create an import service instance to hook later to WP's import function. |
|
| 914 | - $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() ); |
|
| 913 | + // Create an import service instance to hook later to WP's import function. |
|
| 914 | + $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() ); |
|
| 915 | 915 | |
| 916 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 916 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 917 | 917 | |
| 918 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 919 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 918 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 919 | + $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 920 | 920 | |
| 921 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 921 | + $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 922 | 922 | |
| 923 | - // Create the entity rating service. |
|
| 924 | - $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 923 | + // Create the entity rating service. |
|
| 924 | + $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service ); |
|
| 925 | 925 | |
| 926 | - // Create entity list customization (wp-admin/edit.php) |
|
| 927 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 926 | + // Create entity list customization (wp-admin/edit.php) |
|
| 927 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service ); |
|
| 928 | 928 | |
| 929 | - // Create a new instance of the Redirect service. |
|
| 930 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service ); |
|
| 929 | + // Create a new instance of the Redirect service. |
|
| 930 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service ); |
|
| 931 | 931 | |
| 932 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 933 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 932 | + $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 933 | + $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 934 | 934 | |
| 935 | - $attachment_service = new Wordlift_Attachment_Service(); |
|
| 935 | + $attachment_service = new Wordlift_Attachment_Service(); |
|
| 936 | 936 | |
| 937 | - // Instantiate the JSON-LD service. |
|
| 938 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 939 | - $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 ); |
|
| 940 | - $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 ); |
|
| 941 | - $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 ); |
|
| 942 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter ); |
|
| 937 | + // Instantiate the JSON-LD service. |
|
| 938 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 939 | + $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 ); |
|
| 940 | + $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 ); |
|
| 941 | + $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 ); |
|
| 942 | + $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter ); |
|
| 943 | 943 | |
| 944 | - // Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins). |
|
| 945 | - $this->key_validation_service = new Wordlift_Key_Validation_Service(); |
|
| 944 | + // Create an instance of the Key Validation service. This service is later hooked to provide an AJAX call (only for admins). |
|
| 945 | + $this->key_validation_service = new Wordlift_Key_Validation_Service(); |
|
| 946 | 946 | |
| 947 | - // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 948 | - $publisher_service = new Wordlift_Publisher_Service(); |
|
| 949 | - $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 947 | + // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 948 | + $publisher_service = new Wordlift_Publisher_Service(); |
|
| 949 | + $this->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $publisher_service ); |
|
| 950 | 950 | |
| 951 | - /** Adapters. */ |
|
| 952 | - $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 951 | + /** Adapters. */ |
|
| 952 | + $this->tinymce_adapter = new Wordlift_Tinymce_Adapter( $this ); |
|
| 953 | 953 | |
| 954 | - /** Async Tasks. */ |
|
| 955 | - new Wordlift_Sparql_Query_Async_Task(); |
|
| 954 | + /** Async Tasks. */ |
|
| 955 | + new Wordlift_Sparql_Query_Async_Task(); |
|
| 956 | 956 | |
| 957 | - /** WordPress Admin UI. */ |
|
| 957 | + /** WordPress Admin UI. */ |
|
| 958 | 958 | |
| 959 | - // UI elements. |
|
| 960 | - $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 961 | - $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 962 | - $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 963 | - $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 964 | - $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 965 | - $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 959 | + // UI elements. |
|
| 960 | + $this->input_element = new Wordlift_Admin_Input_Element(); |
|
| 961 | + $this->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 962 | + $this->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 963 | + $this->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 964 | + $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 965 | + $this->publisher_element = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element ); |
|
| 966 | 966 | |
| 967 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 968 | - $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 969 | - $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 967 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 968 | + $this->settings_page = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element ); |
|
| 969 | + $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page ); |
|
| 970 | 970 | |
| 971 | - // Pages. |
|
| 972 | - new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 971 | + // Pages. |
|
| 972 | + new Wordlift_Admin_Post_Edit_Page( $this ); |
|
| 973 | 973 | |
| 974 | - // create an instance of the entity type list admin page controller. |
|
| 975 | - $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 974 | + // create an instance of the entity type list admin page controller. |
|
| 975 | + $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 976 | 976 | |
| 977 | - // create an instance of the entity type etting admin page controller. |
|
| 978 | - $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 977 | + // create an instance of the entity type etting admin page controller. |
|
| 978 | + $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 979 | 979 | |
| 980 | - /** Widgets */ |
|
| 981 | - $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 980 | + /** Widgets */ |
|
| 981 | + $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 982 | 982 | |
| 983 | - //** WordPress Admin */ |
|
| 984 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 985 | - $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 983 | + //** WordPress Admin */ |
|
| 984 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service ); |
|
| 985 | + $this->status_page = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service ); |
|
| 986 | 986 | |
| 987 | - // Create an instance of the install wizard. |
|
| 988 | - $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 987 | + // Create an instance of the install wizard. |
|
| 988 | + $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service ); |
|
| 989 | 989 | |
| 990 | - // Create an instance of the content filter service. |
|
| 991 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service ); |
|
| 990 | + // Create an instance of the content filter service. |
|
| 991 | + $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service ); |
|
| 992 | 992 | |
| 993 | - $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 993 | + $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service ); |
|
| 994 | 994 | |
| 995 | - $this->event_entity_page_service = new Wordlift_Event_Entity_Page_Service(); |
|
| 995 | + $this->event_entity_page_service = new Wordlift_Event_Entity_Page_Service(); |
|
| 996 | 996 | |
| 997 | - // Load the debug service if WP is in debug mode. |
|
| 998 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 999 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1000 | - new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1001 | - } |
|
| 997 | + // Load the debug service if WP is in debug mode. |
|
| 998 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 999 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1000 | + new Wordlift_Debug_Service( $this->entity_service, $uri_service ); |
|
| 1001 | + } |
|
| 1002 | 1002 | |
| 1003 | - } |
|
| 1003 | + } |
|
| 1004 | 1004 | |
| 1005 | - /** |
|
| 1006 | - * Define the locale for this plugin for internationalization. |
|
| 1007 | - * |
|
| 1008 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1009 | - * with WordPress. |
|
| 1010 | - * |
|
| 1011 | - * @since 1.0.0 |
|
| 1012 | - * @access private |
|
| 1013 | - */ |
|
| 1014 | - private function set_locale() { |
|
| 1005 | + /** |
|
| 1006 | + * Define the locale for this plugin for internationalization. |
|
| 1007 | + * |
|
| 1008 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1009 | + * with WordPress. |
|
| 1010 | + * |
|
| 1011 | + * @since 1.0.0 |
|
| 1012 | + * @access private |
|
| 1013 | + */ |
|
| 1014 | + private function set_locale() { |
|
| 1015 | 1015 | |
| 1016 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 1017 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1016 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 1017 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1018 | 1018 | |
| 1019 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1019 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1020 | 1020 | |
| 1021 | - } |
|
| 1021 | + } |
|
| 1022 | 1022 | |
| 1023 | - /** |
|
| 1024 | - * Register all of the hooks related to the admin area functionality |
|
| 1025 | - * of the plugin. |
|
| 1026 | - * |
|
| 1027 | - * @since 1.0.0 |
|
| 1028 | - * @access private |
|
| 1029 | - */ |
|
| 1030 | - private function define_admin_hooks() { |
|
| 1023 | + /** |
|
| 1024 | + * Register all of the hooks related to the admin area functionality |
|
| 1025 | + * of the plugin. |
|
| 1026 | + * |
|
| 1027 | + * @since 1.0.0 |
|
| 1028 | + * @access private |
|
| 1029 | + */ |
|
| 1030 | + private function define_admin_hooks() { |
|
| 1031 | 1031 | |
| 1032 | - $plugin_admin = new Wordlift_Admin( |
|
| 1033 | - $this->get_plugin_name(), |
|
| 1034 | - $this->get_version(), |
|
| 1035 | - $this->configuration_service, |
|
| 1036 | - $this->notice_service |
|
| 1037 | - ); |
|
| 1032 | + $plugin_admin = new Wordlift_Admin( |
|
| 1033 | + $this->get_plugin_name(), |
|
| 1034 | + $this->get_version(), |
|
| 1035 | + $this->configuration_service, |
|
| 1036 | + $this->notice_service |
|
| 1037 | + ); |
|
| 1038 | 1038 | |
| 1039 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1040 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1039 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1040 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 1041 | 1041 | |
| 1042 | - // Hook the init action to the Topic Taxonomy service. |
|
| 1043 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1042 | + // Hook the init action to the Topic Taxonomy service. |
|
| 1043 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 1044 | 1044 | |
| 1045 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1046 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1045 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 1046 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 1047 | 1047 | |
| 1048 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 1049 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1048 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 1049 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1050 | 1050 | |
| 1051 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1052 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1051 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 1052 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 1053 | 1053 | |
| 1054 | - // Hook posts inserts (or updates) to the user service. |
|
| 1055 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 1054 | + // Hook posts inserts (or updates) to the user service. |
|
| 1055 | + $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 1056 | 1056 | |
| 1057 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1058 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1057 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1058 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1059 | 1059 | |
| 1060 | - // Register custom allowed redirect hosts. |
|
| 1061 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1062 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1063 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1064 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1065 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1066 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1067 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1060 | + // Register custom allowed redirect hosts. |
|
| 1061 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1062 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1063 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 1064 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1065 | + $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 1066 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1067 | + $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 1068 | 1068 | |
| 1069 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1070 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1071 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1072 | - $this->loader->add_action( 'save_post_entity', $this->rating_service, 'set_rating_for', 10, 1 ); |
|
| 1069 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1070 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1071 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 1072 | + $this->loader->add_action( 'save_post_entity', $this->rating_service, 'set_rating_for', 10, 1 ); |
|
| 1073 | 1073 | |
| 1074 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1075 | - $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1074 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 1075 | + $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' ); |
|
| 1076 | 1076 | |
| 1077 | - // Entity listing customization (wp-admin/edit.php) |
|
| 1078 | - // Add custom columns |
|
| 1079 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1080 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1081 | - // Add 4W selection |
|
| 1082 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1083 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1077 | + // Entity listing customization (wp-admin/edit.php) |
|
| 1078 | + // Add custom columns |
|
| 1079 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 1080 | + $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1081 | + // Add 4W selection |
|
| 1082 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1083 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1084 | 1084 | |
| 1085 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1085 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1086 | 1086 | |
| 1087 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1088 | - // entities. |
|
| 1089 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1087 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1088 | + // entities. |
|
| 1089 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1090 | 1090 | |
| 1091 | - // Filter imported post meta. |
|
| 1092 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1091 | + // Filter imported post meta. |
|
| 1092 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 1093 | 1093 | |
| 1094 | - // Notify the import service when an import starts and ends. |
|
| 1095 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1096 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1097 | - |
|
| 1098 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1099 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1094 | + // Notify the import service when an import starts and ends. |
|
| 1095 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 1096 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 1097 | + |
|
| 1098 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 1099 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 1100 | 1100 | |
| 1101 | - // Hook the menu to the Download Your Data page. |
|
| 1102 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1103 | - $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1104 | - $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1105 | - |
|
| 1106 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1107 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1101 | + // Hook the menu to the Download Your Data page. |
|
| 1102 | + $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 1103 | + $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 ); |
|
| 1104 | + $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 ); |
|
| 1105 | + |
|
| 1106 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1107 | + $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 1108 | 1108 | |
| 1109 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1110 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1109 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1110 | + $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1111 | 1111 | |
| 1112 | - // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1113 | - $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1112 | + // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1113 | + $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' ); |
|
| 1114 | 1114 | |
| 1115 | - // Hook the `admin_init` function to the Admin Setup. |
|
| 1116 | - $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1115 | + // Hook the `admin_init` function to the Admin Setup. |
|
| 1116 | + $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' ); |
|
| 1117 | 1117 | |
| 1118 | - // Hook the admin_init to the settings page. |
|
| 1119 | - $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1118 | + // Hook the admin_init to the settings page. |
|
| 1119 | + $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' ); |
|
| 1120 | 1120 | |
| 1121 | - // Hook the menu creation on the general wordlift menu creation |
|
| 1122 | - $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1121 | + // Hook the menu creation on the general wordlift menu creation |
|
| 1122 | + $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 ); |
|
| 1123 | 1123 | |
| 1124 | - // Hook key update. |
|
| 1125 | - $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1126 | - $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1124 | + // Hook key update. |
|
| 1125 | + $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1126 | + $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 ); |
|
| 1127 | 1127 | |
| 1128 | - // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1129 | - $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1128 | + // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1129 | + $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1130 | 1130 | |
| 1131 | - // Hook the AJAX `wl_publisher` action name. |
|
| 1132 | - $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1131 | + // Hook the AJAX `wl_publisher` action name. |
|
| 1132 | + $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' ); |
|
| 1133 | 1133 | |
| 1134 | - // Hook row actions for the entity type list admin. |
|
| 1135 | - $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1134 | + // Hook row actions for the entity type list admin. |
|
| 1135 | + $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1136 | 1136 | |
| 1137 | - // Hook capabilities manipulation to allow access to entity type admin |
|
| 1138 | - // page on wordpress versions before 4.7. |
|
| 1139 | - global $wp_version; |
|
| 1140 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1141 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1142 | - } |
|
| 1137 | + // Hook capabilities manipulation to allow access to entity type admin |
|
| 1138 | + // page on wordpress versions before 4.7. |
|
| 1139 | + global $wp_version; |
|
| 1140 | + if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1141 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1142 | + } |
|
| 1143 | 1143 | |
| 1144 | - /** Adapters. */ |
|
| 1145 | - $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1144 | + /** Adapters. */ |
|
| 1145 | + $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1146 | 1146 | |
| 1147 | - $this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1147 | + $this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1148 | 1148 | |
| 1149 | - // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1150 | - if ( is_multisite() ) { |
|
| 1151 | - $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1152 | - } |
|
| 1153 | - } |
|
| 1149 | + // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1150 | + if ( is_multisite() ) { |
|
| 1151 | + $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1152 | + } |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | - /** |
|
| 1156 | - * Register all of the hooks related to the public-facing functionality |
|
| 1157 | - * of the plugin. |
|
| 1158 | - * |
|
| 1159 | - * @since 1.0.0 |
|
| 1160 | - * @access private |
|
| 1161 | - */ |
|
| 1162 | - private function define_public_hooks() { |
|
| 1155 | + /** |
|
| 1156 | + * Register all of the hooks related to the public-facing functionality |
|
| 1157 | + * of the plugin. |
|
| 1158 | + * |
|
| 1159 | + * @since 1.0.0 |
|
| 1160 | + * @access private |
|
| 1161 | + */ |
|
| 1162 | + private function define_public_hooks() { |
|
| 1163 | 1163 | |
| 1164 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1164 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 1165 | 1165 | |
| 1166 | - // Register the entity post type. |
|
| 1167 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1166 | + // Register the entity post type. |
|
| 1167 | + $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 1168 | 1168 | |
| 1169 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 1170 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1171 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1172 | - $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 ); |
|
| 1173 | - $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 ); |
|
| 1169 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 1170 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1171 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1172 | + $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 ); |
|
| 1173 | + $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 ); |
|
| 1174 | 1174 | |
| 1175 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1176 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1175 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1176 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1177 | 1177 | |
| 1178 | - // Hook the content filter service to add entity links. |
|
| 1179 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1178 | + // Hook the content filter service to add entity links. |
|
| 1179 | + $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' ); |
|
| 1180 | 1180 | |
| 1181 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1182 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1181 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1182 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 1183 | 1183 | |
| 1184 | - // Hook the ShareThis service. |
|
| 1185 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1186 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1184 | + // Hook the ShareThis service. |
|
| 1185 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 1186 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 1187 | 1187 | |
| 1188 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1189 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1188 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1189 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 1190 | 1190 | |
| 1191 | - // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1192 | - // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1193 | - // to categories. |
|
| 1194 | - $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1191 | + // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1192 | + // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1193 | + // to categories. |
|
| 1194 | + $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1195 | 1195 | |
| 1196 | - /* |
|
| 1196 | + /* |
|
| 1197 | 1197 | * Hook the `pre_get_posts` action to the `Wordlift_Event_Entity_Page_Service` |
| 1198 | 1198 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1199 | 1199 | * order of start time. |
| 1200 | 1200 | */ |
| 1201 | - $this->loader->add_action( 'pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1202 | - |
|
| 1203 | - $this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1204 | - |
|
| 1205 | - } |
|
| 1206 | - |
|
| 1207 | - /** |
|
| 1208 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 1209 | - * |
|
| 1210 | - * @since 1.0.0 |
|
| 1211 | - */ |
|
| 1212 | - public function run() { |
|
| 1213 | - $this->loader->run(); |
|
| 1214 | - } |
|
| 1215 | - |
|
| 1216 | - /** |
|
| 1217 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 1218 | - * WordPress and to define internationalization functionality. |
|
| 1219 | - * |
|
| 1220 | - * @since 1.0.0 |
|
| 1221 | - * @return string The name of the plugin. |
|
| 1222 | - */ |
|
| 1223 | - public function get_plugin_name() { |
|
| 1224 | - return $this->plugin_name; |
|
| 1225 | - } |
|
| 1226 | - |
|
| 1227 | - /** |
|
| 1228 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1229 | - * |
|
| 1230 | - * @since 1.0.0 |
|
| 1231 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1232 | - */ |
|
| 1233 | - public function get_loader() { |
|
| 1234 | - return $this->loader; |
|
| 1235 | - } |
|
| 1236 | - |
|
| 1237 | - /** |
|
| 1238 | - * Retrieve the version number of the plugin. |
|
| 1239 | - * |
|
| 1240 | - * @since 1.0.0 |
|
| 1241 | - * @return string The version number of the plugin. |
|
| 1242 | - */ |
|
| 1243 | - public function get_version() { |
|
| 1244 | - return $this->version; |
|
| 1245 | - } |
|
| 1201 | + $this->loader->add_action( 'pre_get_posts', $this->event_entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1202 | + |
|
| 1203 | + $this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 ); |
|
| 1204 | + |
|
| 1205 | + } |
|
| 1206 | + |
|
| 1207 | + /** |
|
| 1208 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 1209 | + * |
|
| 1210 | + * @since 1.0.0 |
|
| 1211 | + */ |
|
| 1212 | + public function run() { |
|
| 1213 | + $this->loader->run(); |
|
| 1214 | + } |
|
| 1215 | + |
|
| 1216 | + /** |
|
| 1217 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 1218 | + * WordPress and to define internationalization functionality. |
|
| 1219 | + * |
|
| 1220 | + * @since 1.0.0 |
|
| 1221 | + * @return string The name of the plugin. |
|
| 1222 | + */ |
|
| 1223 | + public function get_plugin_name() { |
|
| 1224 | + return $this->plugin_name; |
|
| 1225 | + } |
|
| 1226 | + |
|
| 1227 | + /** |
|
| 1228 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1229 | + * |
|
| 1230 | + * @since 1.0.0 |
|
| 1231 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1232 | + */ |
|
| 1233 | + public function get_loader() { |
|
| 1234 | + return $this->loader; |
|
| 1235 | + } |
|
| 1236 | + |
|
| 1237 | + /** |
|
| 1238 | + * Retrieve the version number of the plugin. |
|
| 1239 | + * |
|
| 1240 | + * @since 1.0.0 |
|
| 1241 | + * @return string The version number of the plugin. |
|
| 1242 | + */ |
|
| 1243 | + public function get_version() { |
|
| 1244 | + return $this->version; |
|
| 1245 | + } |
|
| 1246 | 1246 | |
| 1247 | 1247 | } |
@@ -26,189 +26,189 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class Wordlift_Entity_Link_Service { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * The entity type service. |
|
| 31 | - * |
|
| 32 | - * @since 3.6.0 |
|
| 33 | - * @access private |
|
| 34 | - * @var Wordlift_Entity_Post_Type_Service $entity_type_service The entity type service. |
|
| 35 | - */ |
|
| 36 | - private $entity_type_service; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * The entity post type slug. |
|
| 40 | - * |
|
| 41 | - * @since 3.6.0 |
|
| 42 | - * @access private |
|
| 43 | - * @var string $slug The entity post type slug. |
|
| 44 | - */ |
|
| 45 | - private $slug; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * A logger instance. |
|
| 49 | - * |
|
| 50 | - * @since 3.6.0 |
|
| 51 | - * @access private |
|
| 52 | - * @var Wordlift_Log_Service |
|
| 53 | - */ |
|
| 54 | - private $log; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Wordlift_Entity_Link_Service constructor. |
|
| 58 | - * |
|
| 59 | - * @since 3.6.0 |
|
| 60 | - * |
|
| 61 | - * @param Wordlift_Entity_Post_Type_Service $entity_type_service |
|
| 62 | - * @param string $slug The entity post type slug. |
|
| 63 | - */ |
|
| 64 | - public function __construct( $entity_type_service, $slug ) { |
|
| 65 | - |
|
| 66 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Link_Service' ); |
|
| 67 | - |
|
| 68 | - $this->entity_type_service = $entity_type_service; |
|
| 69 | - $this->slug = $slug; |
|
| 70 | - |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Intercept link generation to posts in order to customize links to entities. |
|
| 75 | - * |
|
| 76 | - * @since 3.6.0 |
|
| 77 | - * |
|
| 78 | - * @param string $post_link The post's permalink. |
|
| 79 | - * @param WP_Post $post The post in question. |
|
| 80 | - * @param bool $leavename Whether to keep the post name. |
|
| 81 | - * @param bool $sample Is it a sample permalink. |
|
| 82 | - * |
|
| 83 | - * @return string The link to the post. |
|
| 84 | - */ |
|
| 85 | - public function post_type_link( $post_link, $post, $leavename, $sample ) { |
|
| 86 | - |
|
| 87 | - // Return the post link if this is not our post type. |
|
| 88 | - if ( ! empty( $this->slug ) || $this->entity_type_service->get_post_type() !== get_post_type( $post ) ) { |
|
| 89 | - return $post_link; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // Replace /slug/post_name/ with /post_name/ |
|
| 93 | - // The slug comes from the Entity Type Service since that service is responsible for registering the default |
|
| 94 | - // slug. |
|
| 95 | - return str_replace( "/{$this->entity_type_service->get_slug()}/$post->post_name/", "/$post->post_name/", $post_link ); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Alter the query to look for our own custom type. |
|
| 100 | - * |
|
| 101 | - * @since 3.6.0 |
|
| 102 | - * |
|
| 103 | - * @param WP_Query $query |
|
| 104 | - */ |
|
| 105 | - public function pre_get_posts( $query ) { |
|
| 106 | - |
|
| 107 | - // If a slug has been set, we don't need to alter the query. |
|
| 108 | - if ( ! empty( $this->slug ) ) { |
|
| 109 | - return; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - // Check if it's a query we should extend with our own custom post type. |
|
| 113 | - // |
|
| 114 | - // The `$query->query` count could be > 2 if the preview parameter is passed too. |
|
| 115 | - // |
|
| 116 | - // See https://github.com/insideout10/wordlift-plugin/issues/439 |
|
| 117 | - if ( ! $query->is_main_query() || 2 > count( $query->query ) || ! isset( $query->query['page'] ) || empty( $query->query['name'] ) ) { |
|
| 118 | - return; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // Add our own post type to the query. |
|
| 122 | - $post_types = '' === $query->get( 'post_type' ) |
|
| 123 | - ? $this->get_default_post_types() |
|
| 124 | - : array_merge( (array) $query->get( 'post_type' ), (array) $this->entity_type_service->get_post_type() ); |
|
| 125 | - $query->set( 'post_type', $post_types ); |
|
| 126 | - |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - private function get_default_post_types() { |
|
| 130 | - |
|
| 131 | - return array( |
|
| 132 | - 'post', |
|
| 133 | - $this->entity_type_service->get_post_type(), |
|
| 134 | - 'page', |
|
| 135 | - ); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Hook to WordPress' wp_unique_post_slug_is_bad_flat_slug filter. This is called when a page is saved. |
|
| 140 | - * |
|
| 141 | - * @since 3.6.0 |
|
| 142 | - * |
|
| 143 | - * @param bool $bad_slug Whether the post slug would be bad as a flat slug. |
|
| 144 | - * @param string $slug The post slug. |
|
| 145 | - * @param string $post_type Post type. |
|
| 146 | - * |
|
| 147 | - * @return bool Whether the slug is bad. |
|
| 148 | - */ |
|
| 149 | - public function wp_unique_post_slug_is_bad_flat_slug( $bad_slug, $slug, $post_type ) { |
|
| 150 | - |
|
| 151 | - // The list of post types that might have conflicting slugs. |
|
| 152 | - $post_types = array( |
|
| 153 | - 'post', |
|
| 154 | - 'page', |
|
| 155 | - $this->entity_type_service->get_post_type(), |
|
| 156 | - ); |
|
| 157 | - |
|
| 158 | - // Ignore post types different from the ones we need to check. |
|
| 159 | - if ( ! in_array( $post_type, $post_types ) ) { |
|
| 160 | - return $bad_slug; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - $exists = $this->slug_exists( $slug, array_diff( $post_types, array( $post_type ) ) ); |
|
| 164 | - |
|
| 165 | - $this->log->debug( "Checking if a slug exists [ post type :: $post_type ][ slug :: $slug ][ exists :: " . ( $exists ? "yes" : "no" ) . " ]" ); |
|
| 166 | - |
|
| 167 | - return $exists; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Hook to WordPress' wp_unique_post_slug_is_bad_hierarchical_slug filter. This is called when a page is saved. |
|
| 172 | - * |
|
| 173 | - * @since 3.6.0 |
|
| 174 | - * |
|
| 175 | - * @param bool $bad_slug Whether the post slug would be bad as a flat slug. |
|
| 176 | - * @param string $slug The post slug. |
|
| 177 | - * @param string $post_type Post type. |
|
| 178 | - * @param int $post_parent |
|
| 179 | - * |
|
| 180 | - * @return bool Whether the slug is bad. |
|
| 181 | - */ |
|
| 182 | - public function wp_unique_post_slug_is_bad_hierarchical_slug( $bad_slug, $slug, $post_type, $post_parent ) { |
|
| 183 | - |
|
| 184 | - // We only care about pages here. |
|
| 185 | - if ( 'page' !== $post_type ) { |
|
| 186 | - return $bad_slug; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - // We redirect the call to the flat hook, this means that this check is going to solve also the 6-years old issue |
|
| 190 | - // about overlapping slugs among pages and posts: |
|
| 191 | - // https://core.trac.wordpress.org/ticket/13459 |
|
| 192 | - return $this->wp_unique_post_slug_is_bad_flat_slug( $bad_slug, $slug, $post_type ); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Check whether a slug exists already for the specified post types. |
|
| 197 | - * |
|
| 198 | - * @since 3.6.0 |
|
| 199 | - * |
|
| 200 | - * @param string $slug The slug. |
|
| 201 | - * @param array $post_types An array of post types. |
|
| 202 | - * |
|
| 203 | - * @return bool True if the slug exists, otherwise false. |
|
| 204 | - */ |
|
| 205 | - private function slug_exists( $slug, $post_types ) { |
|
| 206 | - global $wpdb; |
|
| 207 | - |
|
| 208 | - // Post slugs must be unique across all posts. |
|
| 209 | - $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ('" . implode( "', '", array_map( 'esc_sql', $post_types ) ) . "') LIMIT 1"; |
|
| 210 | - |
|
| 211 | - return null !== $wpdb->get_var( $wpdb->prepare( $check_sql, $slug ) ); |
|
| 212 | - } |
|
| 29 | + /** |
|
| 30 | + * The entity type service. |
|
| 31 | + * |
|
| 32 | + * @since 3.6.0 |
|
| 33 | + * @access private |
|
| 34 | + * @var Wordlift_Entity_Post_Type_Service $entity_type_service The entity type service. |
|
| 35 | + */ |
|
| 36 | + private $entity_type_service; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * The entity post type slug. |
|
| 40 | + * |
|
| 41 | + * @since 3.6.0 |
|
| 42 | + * @access private |
|
| 43 | + * @var string $slug The entity post type slug. |
|
| 44 | + */ |
|
| 45 | + private $slug; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * A logger instance. |
|
| 49 | + * |
|
| 50 | + * @since 3.6.0 |
|
| 51 | + * @access private |
|
| 52 | + * @var Wordlift_Log_Service |
|
| 53 | + */ |
|
| 54 | + private $log; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Wordlift_Entity_Link_Service constructor. |
|
| 58 | + * |
|
| 59 | + * @since 3.6.0 |
|
| 60 | + * |
|
| 61 | + * @param Wordlift_Entity_Post_Type_Service $entity_type_service |
|
| 62 | + * @param string $slug The entity post type slug. |
|
| 63 | + */ |
|
| 64 | + public function __construct( $entity_type_service, $slug ) { |
|
| 65 | + |
|
| 66 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Link_Service' ); |
|
| 67 | + |
|
| 68 | + $this->entity_type_service = $entity_type_service; |
|
| 69 | + $this->slug = $slug; |
|
| 70 | + |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Intercept link generation to posts in order to customize links to entities. |
|
| 75 | + * |
|
| 76 | + * @since 3.6.0 |
|
| 77 | + * |
|
| 78 | + * @param string $post_link The post's permalink. |
|
| 79 | + * @param WP_Post $post The post in question. |
|
| 80 | + * @param bool $leavename Whether to keep the post name. |
|
| 81 | + * @param bool $sample Is it a sample permalink. |
|
| 82 | + * |
|
| 83 | + * @return string The link to the post. |
|
| 84 | + */ |
|
| 85 | + public function post_type_link( $post_link, $post, $leavename, $sample ) { |
|
| 86 | + |
|
| 87 | + // Return the post link if this is not our post type. |
|
| 88 | + if ( ! empty( $this->slug ) || $this->entity_type_service->get_post_type() !== get_post_type( $post ) ) { |
|
| 89 | + return $post_link; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // Replace /slug/post_name/ with /post_name/ |
|
| 93 | + // The slug comes from the Entity Type Service since that service is responsible for registering the default |
|
| 94 | + // slug. |
|
| 95 | + return str_replace( "/{$this->entity_type_service->get_slug()}/$post->post_name/", "/$post->post_name/", $post_link ); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Alter the query to look for our own custom type. |
|
| 100 | + * |
|
| 101 | + * @since 3.6.0 |
|
| 102 | + * |
|
| 103 | + * @param WP_Query $query |
|
| 104 | + */ |
|
| 105 | + public function pre_get_posts( $query ) { |
|
| 106 | + |
|
| 107 | + // If a slug has been set, we don't need to alter the query. |
|
| 108 | + if ( ! empty( $this->slug ) ) { |
|
| 109 | + return; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + // Check if it's a query we should extend with our own custom post type. |
|
| 113 | + // |
|
| 114 | + // The `$query->query` count could be > 2 if the preview parameter is passed too. |
|
| 115 | + // |
|
| 116 | + // See https://github.com/insideout10/wordlift-plugin/issues/439 |
|
| 117 | + if ( ! $query->is_main_query() || 2 > count( $query->query ) || ! isset( $query->query['page'] ) || empty( $query->query['name'] ) ) { |
|
| 118 | + return; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // Add our own post type to the query. |
|
| 122 | + $post_types = '' === $query->get( 'post_type' ) |
|
| 123 | + ? $this->get_default_post_types() |
|
| 124 | + : array_merge( (array) $query->get( 'post_type' ), (array) $this->entity_type_service->get_post_type() ); |
|
| 125 | + $query->set( 'post_type', $post_types ); |
|
| 126 | + |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + private function get_default_post_types() { |
|
| 130 | + |
|
| 131 | + return array( |
|
| 132 | + 'post', |
|
| 133 | + $this->entity_type_service->get_post_type(), |
|
| 134 | + 'page', |
|
| 135 | + ); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Hook to WordPress' wp_unique_post_slug_is_bad_flat_slug filter. This is called when a page is saved. |
|
| 140 | + * |
|
| 141 | + * @since 3.6.0 |
|
| 142 | + * |
|
| 143 | + * @param bool $bad_slug Whether the post slug would be bad as a flat slug. |
|
| 144 | + * @param string $slug The post slug. |
|
| 145 | + * @param string $post_type Post type. |
|
| 146 | + * |
|
| 147 | + * @return bool Whether the slug is bad. |
|
| 148 | + */ |
|
| 149 | + public function wp_unique_post_slug_is_bad_flat_slug( $bad_slug, $slug, $post_type ) { |
|
| 150 | + |
|
| 151 | + // The list of post types that might have conflicting slugs. |
|
| 152 | + $post_types = array( |
|
| 153 | + 'post', |
|
| 154 | + 'page', |
|
| 155 | + $this->entity_type_service->get_post_type(), |
|
| 156 | + ); |
|
| 157 | + |
|
| 158 | + // Ignore post types different from the ones we need to check. |
|
| 159 | + if ( ! in_array( $post_type, $post_types ) ) { |
|
| 160 | + return $bad_slug; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + $exists = $this->slug_exists( $slug, array_diff( $post_types, array( $post_type ) ) ); |
|
| 164 | + |
|
| 165 | + $this->log->debug( "Checking if a slug exists [ post type :: $post_type ][ slug :: $slug ][ exists :: " . ( $exists ? "yes" : "no" ) . " ]" ); |
|
| 166 | + |
|
| 167 | + return $exists; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Hook to WordPress' wp_unique_post_slug_is_bad_hierarchical_slug filter. This is called when a page is saved. |
|
| 172 | + * |
|
| 173 | + * @since 3.6.0 |
|
| 174 | + * |
|
| 175 | + * @param bool $bad_slug Whether the post slug would be bad as a flat slug. |
|
| 176 | + * @param string $slug The post slug. |
|
| 177 | + * @param string $post_type Post type. |
|
| 178 | + * @param int $post_parent |
|
| 179 | + * |
|
| 180 | + * @return bool Whether the slug is bad. |
|
| 181 | + */ |
|
| 182 | + public function wp_unique_post_slug_is_bad_hierarchical_slug( $bad_slug, $slug, $post_type, $post_parent ) { |
|
| 183 | + |
|
| 184 | + // We only care about pages here. |
|
| 185 | + if ( 'page' !== $post_type ) { |
|
| 186 | + return $bad_slug; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + // We redirect the call to the flat hook, this means that this check is going to solve also the 6-years old issue |
|
| 190 | + // about overlapping slugs among pages and posts: |
|
| 191 | + // https://core.trac.wordpress.org/ticket/13459 |
|
| 192 | + return $this->wp_unique_post_slug_is_bad_flat_slug( $bad_slug, $slug, $post_type ); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Check whether a slug exists already for the specified post types. |
|
| 197 | + * |
|
| 198 | + * @since 3.6.0 |
|
| 199 | + * |
|
| 200 | + * @param string $slug The slug. |
|
| 201 | + * @param array $post_types An array of post types. |
|
| 202 | + * |
|
| 203 | + * @return bool True if the slug exists, otherwise false. |
|
| 204 | + */ |
|
| 205 | + private function slug_exists( $slug, $post_types ) { |
|
| 206 | + global $wpdb; |
|
| 207 | + |
|
| 208 | + // Post slugs must be unique across all posts. |
|
| 209 | + $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ('" . implode( "', '", array_map( 'esc_sql', $post_types ) ) . "') LIMIT 1"; |
|
| 210 | + |
|
| 211 | + return null !== $wpdb->get_var( $wpdb->prepare( $check_sql, $slug ) ); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | 214 | } |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | * @param Wordlift_Entity_Post_Type_Service $entity_type_service |
| 62 | 62 | * @param string $slug The entity post type slug. |
| 63 | 63 | */ |
| 64 | - public function __construct( $entity_type_service, $slug ) { |
|
| 64 | + public function __construct($entity_type_service, $slug) { |
|
| 65 | 65 | |
| 66 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Link_Service' ); |
|
| 66 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Entity_Link_Service'); |
|
| 67 | 67 | |
| 68 | 68 | $this->entity_type_service = $entity_type_service; |
| 69 | 69 | $this->slug = $slug; |
@@ -82,17 +82,17 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return string The link to the post. |
| 84 | 84 | */ |
| 85 | - public function post_type_link( $post_link, $post, $leavename, $sample ) { |
|
| 85 | + public function post_type_link($post_link, $post, $leavename, $sample) { |
|
| 86 | 86 | |
| 87 | 87 | // Return the post link if this is not our post type. |
| 88 | - if ( ! empty( $this->slug ) || $this->entity_type_service->get_post_type() !== get_post_type( $post ) ) { |
|
| 88 | + if ( ! empty($this->slug) || $this->entity_type_service->get_post_type() !== get_post_type($post)) { |
|
| 89 | 89 | return $post_link; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // Replace /slug/post_name/ with /post_name/ |
| 93 | 93 | // The slug comes from the Entity Type Service since that service is responsible for registering the default |
| 94 | 94 | // slug. |
| 95 | - return str_replace( "/{$this->entity_type_service->get_slug()}/$post->post_name/", "/$post->post_name/", $post_link ); |
|
| 95 | + return str_replace("/{$this->entity_type_service->get_slug()}/$post->post_name/", "/$post->post_name/", $post_link); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @param WP_Query $query |
| 104 | 104 | */ |
| 105 | - public function pre_get_posts( $query ) { |
|
| 105 | + public function pre_get_posts($query) { |
|
| 106 | 106 | |
| 107 | 107 | // If a slug has been set, we don't need to alter the query. |
| 108 | - if ( ! empty( $this->slug ) ) { |
|
| 108 | + if ( ! empty($this->slug)) { |
|
| 109 | 109 | return; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,15 +114,15 @@ discard block |
||
| 114 | 114 | // The `$query->query` count could be > 2 if the preview parameter is passed too. |
| 115 | 115 | // |
| 116 | 116 | // See https://github.com/insideout10/wordlift-plugin/issues/439 |
| 117 | - if ( ! $query->is_main_query() || 2 > count( $query->query ) || ! isset( $query->query['page'] ) || empty( $query->query['name'] ) ) { |
|
| 117 | + if ( ! $query->is_main_query() || 2 > count($query->query) || ! isset($query->query['page']) || empty($query->query['name'])) { |
|
| 118 | 118 | return; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // Add our own post type to the query. |
| 122 | - $post_types = '' === $query->get( 'post_type' ) |
|
| 122 | + $post_types = '' === $query->get('post_type') |
|
| 123 | 123 | ? $this->get_default_post_types() |
| 124 | - : array_merge( (array) $query->get( 'post_type' ), (array) $this->entity_type_service->get_post_type() ); |
|
| 125 | - $query->set( 'post_type', $post_types ); |
|
| 124 | + : array_merge((array) $query->get('post_type'), (array) $this->entity_type_service->get_post_type()); |
|
| 125 | + $query->set('post_type', $post_types); |
|
| 126 | 126 | |
| 127 | 127 | } |
| 128 | 128 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @return bool Whether the slug is bad. |
| 148 | 148 | */ |
| 149 | - public function wp_unique_post_slug_is_bad_flat_slug( $bad_slug, $slug, $post_type ) { |
|
| 149 | + public function wp_unique_post_slug_is_bad_flat_slug($bad_slug, $slug, $post_type) { |
|
| 150 | 150 | |
| 151 | 151 | // The list of post types that might have conflicting slugs. |
| 152 | 152 | $post_types = array( |
@@ -156,13 +156,13 @@ discard block |
||
| 156 | 156 | ); |
| 157 | 157 | |
| 158 | 158 | // Ignore post types different from the ones we need to check. |
| 159 | - if ( ! in_array( $post_type, $post_types ) ) { |
|
| 159 | + if ( ! in_array($post_type, $post_types)) { |
|
| 160 | 160 | return $bad_slug; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $exists = $this->slug_exists( $slug, array_diff( $post_types, array( $post_type ) ) ); |
|
| 163 | + $exists = $this->slug_exists($slug, array_diff($post_types, array($post_type))); |
|
| 164 | 164 | |
| 165 | - $this->log->debug( "Checking if a slug exists [ post type :: $post_type ][ slug :: $slug ][ exists :: " . ( $exists ? "yes" : "no" ) . " ]" ); |
|
| 165 | + $this->log->debug("Checking if a slug exists [ post type :: $post_type ][ slug :: $slug ][ exists :: ".($exists ? "yes" : "no")." ]"); |
|
| 166 | 166 | |
| 167 | 167 | return $exists; |
| 168 | 168 | } |
@@ -179,17 +179,17 @@ discard block |
||
| 179 | 179 | * |
| 180 | 180 | * @return bool Whether the slug is bad. |
| 181 | 181 | */ |
| 182 | - public function wp_unique_post_slug_is_bad_hierarchical_slug( $bad_slug, $slug, $post_type, $post_parent ) { |
|
| 182 | + public function wp_unique_post_slug_is_bad_hierarchical_slug($bad_slug, $slug, $post_type, $post_parent) { |
|
| 183 | 183 | |
| 184 | 184 | // We only care about pages here. |
| 185 | - if ( 'page' !== $post_type ) { |
|
| 185 | + if ('page' !== $post_type) { |
|
| 186 | 186 | return $bad_slug; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | // We redirect the call to the flat hook, this means that this check is going to solve also the 6-years old issue |
| 190 | 190 | // about overlapping slugs among pages and posts: |
| 191 | 191 | // https://core.trac.wordpress.org/ticket/13459 |
| 192 | - return $this->wp_unique_post_slug_is_bad_flat_slug( $bad_slug, $slug, $post_type ); |
|
| 192 | + return $this->wp_unique_post_slug_is_bad_flat_slug($bad_slug, $slug, $post_type); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -202,13 +202,13 @@ discard block |
||
| 202 | 202 | * |
| 203 | 203 | * @return bool True if the slug exists, otherwise false. |
| 204 | 204 | */ |
| 205 | - private function slug_exists( $slug, $post_types ) { |
|
| 205 | + private function slug_exists($slug, $post_types) { |
|
| 206 | 206 | global $wpdb; |
| 207 | 207 | |
| 208 | 208 | // Post slugs must be unique across all posts. |
| 209 | - $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ('" . implode( "', '", array_map( 'esc_sql', $post_types ) ) . "') LIMIT 1"; |
|
| 209 | + $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ('".implode("', '", array_map('esc_sql', $post_types))."') LIMIT 1"; |
|
| 210 | 210 | |
| 211 | - return null !== $wpdb->get_var( $wpdb->prepare( $check_sql, $slug ) ); |
|
| 211 | + return null !== $wpdb->get_var($wpdb->prepare($check_sql, $slug)); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | } |
@@ -18,54 +18,54 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | function rl_execute_sparql_update_query( $query, $queue = WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) { |
| 20 | 20 | |
| 21 | - if ( get_transient( 'DISABLE_ENTITY_PUSH' ) ) { |
|
| 22 | - return true; |
|
| 23 | - } |
|
| 21 | + if ( get_transient( 'DISABLE_ENTITY_PUSH' ) ) { |
|
| 22 | + return true; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - // Queue the update query. |
|
| 26 | - if ( $queue ) { |
|
| 25 | + // Queue the update query. |
|
| 26 | + if ( $queue ) { |
|
| 27 | 27 | |
| 28 | - Wordlift_Sparql_Service::get_instance()->queue( $query ); |
|
| 28 | + Wordlift_Sparql_Service::get_instance()->queue( $query ); |
|
| 29 | 29 | |
| 30 | - return true; |
|
| 31 | - } |
|
| 30 | + return true; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - // Get the update end-point. |
|
| 34 | - $url = wl_configuration_get_query_update_url(); |
|
| 33 | + // Get the update end-point. |
|
| 34 | + $url = wl_configuration_get_query_update_url(); |
|
| 35 | 35 | |
| 36 | - // Prepare the request. |
|
| 37 | - $args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array( |
|
| 38 | - 'method' => 'POST', |
|
| 39 | - 'headers' => array( |
|
| 40 | - 'Accept' => 'application/json', |
|
| 41 | - 'Content-type' => 'application/sparql-update; charset=utf-8', |
|
| 42 | - ), |
|
| 43 | - 'body' => $query, |
|
| 44 | - ) ); |
|
| 36 | + // Prepare the request. |
|
| 37 | + $args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array( |
|
| 38 | + 'method' => 'POST', |
|
| 39 | + 'headers' => array( |
|
| 40 | + 'Accept' => 'application/json', |
|
| 41 | + 'Content-type' => 'application/sparql-update; charset=utf-8', |
|
| 42 | + ), |
|
| 43 | + 'body' => $query, |
|
| 44 | + ) ); |
|
| 45 | 45 | |
| 46 | - // Send the request. |
|
| 47 | - $response = wp_remote_post( $url, $args ); |
|
| 46 | + // Send the request. |
|
| 47 | + $response = wp_remote_post( $url, $args ); |
|
| 48 | 48 | |
| 49 | - // If an error has been raised, return the error. |
|
| 50 | - if ( is_wp_error( $response ) || 200 !== (int) $response['response']['code'] ) { |
|
| 49 | + // If an error has been raised, return the error. |
|
| 50 | + if ( is_wp_error( $response ) || 200 !== (int) $response['response']['code'] ) { |
|
| 51 | 51 | |
| 52 | - $body = ( is_wp_error( $response ) ? $response->get_error_message() : $response['body'] ); |
|
| 52 | + $body = ( is_wp_error( $response ) ? $response->get_error_message() : $response['body'] ); |
|
| 53 | 53 | |
| 54 | - wl_write_log( "rl_execute_sparql_update_query : error [ url :: $url ][ args :: " ); |
|
| 55 | - wl_write_log( "\n" . var_export( $args, true ) ); |
|
| 56 | - wl_write_log( "[ response :: " ); |
|
| 57 | - wl_write_log( "\n" . var_export( $response, true ) ); |
|
| 58 | - wl_write_log( "][ body :: " ); |
|
| 59 | - wl_write_log( "\n" . $body ); |
|
| 60 | - wl_write_log( "]" ); |
|
| 54 | + wl_write_log( "rl_execute_sparql_update_query : error [ url :: $url ][ args :: " ); |
|
| 55 | + wl_write_log( "\n" . var_export( $args, true ) ); |
|
| 56 | + wl_write_log( "[ response :: " ); |
|
| 57 | + wl_write_log( "\n" . var_export( $response, true ) ); |
|
| 58 | + wl_write_log( "][ body :: " ); |
|
| 59 | + wl_write_log( "\n" . $body ); |
|
| 60 | + wl_write_log( "]" ); |
|
| 61 | 61 | |
| 62 | - return false; |
|
| 63 | - } |
|
| 62 | + return false; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - if ( WP_DEBUG ) { |
|
| 66 | - global $wl_logger; |
|
| 67 | - $wl_logger->trace( "Query executed successfully [ query :: $query ]" ); |
|
| 68 | - } |
|
| 65 | + if ( WP_DEBUG ) { |
|
| 66 | + global $wl_logger; |
|
| 67 | + $wl_logger->trace( "Query executed successfully [ query :: $query ]" ); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - return true; |
|
| 70 | + return true; |
|
| 71 | 71 | } |
@@ -16,16 +16,16 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @return bool True if successful otherwise false. |
| 18 | 18 | */ |
| 19 | -function rl_execute_sparql_update_query( $query, $queue = WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) { |
|
| 19 | +function rl_execute_sparql_update_query($query, $queue = WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING) { |
|
| 20 | 20 | |
| 21 | - if ( get_transient( 'DISABLE_ENTITY_PUSH' ) ) { |
|
| 21 | + if (get_transient('DISABLE_ENTITY_PUSH')) { |
|
| 22 | 22 | return true; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | // Queue the update query. |
| 26 | - if ( $queue ) { |
|
| 26 | + if ($queue) { |
|
| 27 | 27 | |
| 28 | - Wordlift_Sparql_Service::get_instance()->queue( $query ); |
|
| 28 | + Wordlift_Sparql_Service::get_instance()->queue($query); |
|
| 29 | 29 | |
| 30 | 30 | return true; |
| 31 | 31 | } |
@@ -34,37 +34,37 @@ discard block |
||
| 34 | 34 | $url = wl_configuration_get_query_update_url(); |
| 35 | 35 | |
| 36 | 36 | // Prepare the request. |
| 37 | - $args = array_merge_recursive( unserialize( WL_REDLINK_API_HTTP_OPTIONS ), array( |
|
| 37 | + $args = array_merge_recursive(unserialize(WL_REDLINK_API_HTTP_OPTIONS), array( |
|
| 38 | 38 | 'method' => 'POST', |
| 39 | 39 | 'headers' => array( |
| 40 | 40 | 'Accept' => 'application/json', |
| 41 | 41 | 'Content-type' => 'application/sparql-update; charset=utf-8', |
| 42 | 42 | ), |
| 43 | 43 | 'body' => $query, |
| 44 | - ) ); |
|
| 44 | + )); |
|
| 45 | 45 | |
| 46 | 46 | // Send the request. |
| 47 | - $response = wp_remote_post( $url, $args ); |
|
| 47 | + $response = wp_remote_post($url, $args); |
|
| 48 | 48 | |
| 49 | 49 | // If an error has been raised, return the error. |
| 50 | - if ( is_wp_error( $response ) || 200 !== (int) $response['response']['code'] ) { |
|
| 50 | + if (is_wp_error($response) || 200 !== (int) $response['response']['code']) { |
|
| 51 | 51 | |
| 52 | - $body = ( is_wp_error( $response ) ? $response->get_error_message() : $response['body'] ); |
|
| 52 | + $body = (is_wp_error($response) ? $response->get_error_message() : $response['body']); |
|
| 53 | 53 | |
| 54 | - wl_write_log( "rl_execute_sparql_update_query : error [ url :: $url ][ args :: " ); |
|
| 55 | - wl_write_log( "\n" . var_export( $args, true ) ); |
|
| 56 | - wl_write_log( "[ response :: " ); |
|
| 57 | - wl_write_log( "\n" . var_export( $response, true ) ); |
|
| 58 | - wl_write_log( "][ body :: " ); |
|
| 59 | - wl_write_log( "\n" . $body ); |
|
| 60 | - wl_write_log( "]" ); |
|
| 54 | + wl_write_log("rl_execute_sparql_update_query : error [ url :: $url ][ args :: "); |
|
| 55 | + wl_write_log("\n".var_export($args, true)); |
|
| 56 | + wl_write_log("[ response :: "); |
|
| 57 | + wl_write_log("\n".var_export($response, true)); |
|
| 58 | + wl_write_log("][ body :: "); |
|
| 59 | + wl_write_log("\n".$body); |
|
| 60 | + wl_write_log("]"); |
|
| 61 | 61 | |
| 62 | 62 | return false; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if ( WP_DEBUG ) { |
|
| 65 | + if (WP_DEBUG) { |
|
| 66 | 66 | global $wl_logger; |
| 67 | - $wl_logger->trace( "Query executed successfully [ query :: $query ]" ); |
|
| 67 | + $wl_logger->trace("Query executed successfully [ query :: $query ]"); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | return true; |
@@ -4,36 +4,36 @@ discard block |
||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | // Define the basic options for HTTP calls to REDLINK. |
| 7 | -define( 'WL_REDLINK_API_HTTP_OPTIONS', serialize( array( |
|
| 7 | +define('WL_REDLINK_API_HTTP_OPTIONS', serialize(array( |
|
| 8 | 8 | 'timeout' => 300, |
| 9 | 9 | 'redirection' => 5, |
| 10 | 10 | 'httpversion' => '1.1', |
| 11 | 11 | 'blocking' => true, |
| 12 | 12 | 'cookies' => array(), |
| 13 | - 'sslverify' => ( 'false' === getenv( 'WL_SSL_VERIFY_ENABLED' ) ) ? false : true, |
|
| 14 | - 'sslcertificates' => dirname( __FILE__ ) . '/ssl/ca-bundle.crt', |
|
| 13 | + 'sslverify' => ('false' === getenv('WL_SSL_VERIFY_ENABLED')) ? false : true, |
|
| 14 | + 'sslcertificates' => dirname(__FILE__).'/ssl/ca-bundle.crt', |
|
| 15 | 15 | 'decompress' => false, |
| 16 | -) ) ); |
|
| 16 | +))); |
|
| 17 | 17 | |
| 18 | 18 | // Create a unique ID for this request, useful to hook async HTTP requests. |
| 19 | -define( 'WL_REQUEST_ID', uniqid( true ) ); |
|
| 19 | +define('WL_REQUEST_ID', uniqid(true)); |
|
| 20 | 20 | |
| 21 | 21 | // Set the temporary files folder. |
| 22 | -defined( 'WL_TEMP_DIR' ) || define( 'WL_TEMP_DIR', get_temp_dir() ); |
|
| 22 | +defined('WL_TEMP_DIR') || define('WL_TEMP_DIR', get_temp_dir()); |
|
| 23 | 23 | |
| 24 | -define( 'WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING', 'true' !== getenv( 'WL_DISABLE_SPARQL_UPDATE_QUERIES_BUFFERING' ) ); |
|
| 24 | +define('WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING', 'true' !== getenv('WL_DISABLE_SPARQL_UPDATE_QUERIES_BUFFERING')); |
|
| 25 | 25 | |
| 26 | 26 | // Define the meta name used to store the entity URL. |
| 27 | -define( 'WL_ENTITY_URL_META_NAME', 'entity_url' ); |
|
| 27 | +define('WL_ENTITY_URL_META_NAME', 'entity_url'); |
|
| 28 | 28 | |
| 29 | 29 | // Max number of recursions when printing microdata |
| 30 | -define( 'WL_RECURSION_DEPTH_ON_ENTITY_METADATA_PRINTING', 3 ); |
|
| 30 | +define('WL_RECURSION_DEPTH_ON_ENTITY_METADATA_PRINTING', 3); |
|
| 31 | 31 | |
| 32 | 32 | // 3.13.0, we use by default WLS 1.11 which provides us with the new, faster |
| 33 | 33 | // chunked analysis. |
| 34 | -define( 'WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE', defined( 'WORDLIFT_API_URL' ) ? WORDLIFT_API_URL . '/' : 'https://api.wordlift.it/' ); |
|
| 34 | +define('WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE', defined('WORDLIFT_API_URL') ? WORDLIFT_API_URL.'/' : 'https://api.wordlift.it/'); |
|
| 35 | 35 | |
| 36 | -define( 'WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL', 'https://developers.google.com/structured-data/testing-tool/?url=' ); |
|
| 36 | +define('WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL', 'https://developers.google.com/structured-data/testing-tool/?url='); |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | $items = wl_prefixes_list(); |
| 47 | 47 | $prefixes = array(); |
| 48 | 48 | |
| 49 | - foreach ( $items as $item ) { |
|
| 50 | - $prefixes[ $item['prefix'] ] = $item['namespace']; |
|
| 49 | + foreach ($items as $item) { |
|
| 50 | + $prefixes[$item['prefix']] = $item['namespace']; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | return $prefixes; |