@@ -16,189 +16,189 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Wordlift_Api_Service { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * The {@link Wordlift_Api_Service} singleton instance. |
|
| 21 | - * |
|
| 22 | - * @since 3.20.0 |
|
| 23 | - * @access private |
|
| 24 | - * @var \Wordlift_Api_Service $instance The singleton instance. |
|
| 25 | - */ |
|
| 26 | - private static $instance; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Create a {@link Wordlift_Api_Service} instance. |
|
| 30 | - * |
|
| 31 | - * @since 3.20.0 |
|
| 32 | - * |
|
| 33 | - */ |
|
| 34 | - public function __construct() { |
|
| 35 | - self::$instance = $this; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Get the {@link Wordlift_Api_Service} singleton instance. |
|
| 40 | - * |
|
| 41 | - * @return \Wordlift_Api_Service The {@link Wordlift_Api_Service} singleton instance. |
|
| 42 | - * @since 3.20.0 |
|
| 43 | - * |
|
| 44 | - */ |
|
| 45 | - public static function get_instance() { |
|
| 46 | - |
|
| 47 | - return self::$instance; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Perform a `GET` request towards the requested path. |
|
| 52 | - * |
|
| 53 | - * @param string $path The relative path. |
|
| 54 | - * |
|
| 55 | - * @return array|WP_Error |
|
| 56 | - * @since 3.20.0 |
|
| 57 | - * |
|
| 58 | - */ |
|
| 59 | - public function get( $path ) { |
|
| 60 | - |
|
| 61 | - // Prepare the target URL. |
|
| 62 | - $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
| 63 | - |
|
| 64 | - // Get the response value. |
|
| 65 | - $response = wp_remote_get( $url, array( |
|
| 66 | - 'user-agent' => User_Agent::get_user_agent(), |
|
| 67 | - 'headers' => array( |
|
| 68 | - 'X-Authorization' => Wordlift_Configuration_Service::get_instance()->get_key(), |
|
| 69 | - ), |
|
| 70 | - /* |
|
| 19 | + /** |
|
| 20 | + * The {@link Wordlift_Api_Service} singleton instance. |
|
| 21 | + * |
|
| 22 | + * @since 3.20.0 |
|
| 23 | + * @access private |
|
| 24 | + * @var \Wordlift_Api_Service $instance The singleton instance. |
|
| 25 | + */ |
|
| 26 | + private static $instance; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Create a {@link Wordlift_Api_Service} instance. |
|
| 30 | + * |
|
| 31 | + * @since 3.20.0 |
|
| 32 | + * |
|
| 33 | + */ |
|
| 34 | + public function __construct() { |
|
| 35 | + self::$instance = $this; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Get the {@link Wordlift_Api_Service} singleton instance. |
|
| 40 | + * |
|
| 41 | + * @return \Wordlift_Api_Service The {@link Wordlift_Api_Service} singleton instance. |
|
| 42 | + * @since 3.20.0 |
|
| 43 | + * |
|
| 44 | + */ |
|
| 45 | + public static function get_instance() { |
|
| 46 | + |
|
| 47 | + return self::$instance; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Perform a `GET` request towards the requested path. |
|
| 52 | + * |
|
| 53 | + * @param string $path The relative path. |
|
| 54 | + * |
|
| 55 | + * @return array|WP_Error |
|
| 56 | + * @since 3.20.0 |
|
| 57 | + * |
|
| 58 | + */ |
|
| 59 | + public function get( $path ) { |
|
| 60 | + |
|
| 61 | + // Prepare the target URL. |
|
| 62 | + $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
| 63 | + |
|
| 64 | + // Get the response value. |
|
| 65 | + $response = wp_remote_get( $url, array( |
|
| 66 | + 'user-agent' => User_Agent::get_user_agent(), |
|
| 67 | + 'headers' => array( |
|
| 68 | + 'X-Authorization' => Wordlift_Configuration_Service::get_instance()->get_key(), |
|
| 69 | + ), |
|
| 70 | + /* |
|
| 71 | 71 | * Increase the timeout from the default of 5 to 30 secs. |
| 72 | 72 | * |
| 73 | 73 | * @see https://github.com/insideout10/wordlift-plugin/issues/906 |
| 74 | 74 | * |
| 75 | 75 | * @since 3.20.1 |
| 76 | 76 | */ |
| 77 | - 'timeout' => 30, |
|
| 78 | - ) ); |
|
| 79 | - |
|
| 80 | - return self::get_message_or_error( $response ); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Perform a `POST` request towards the requested path. |
|
| 85 | - * |
|
| 86 | - * @param string $path The relative path. |
|
| 87 | - * @param array|object $body The request body (will be serialized to JSON). |
|
| 88 | - * |
|
| 89 | - * @return array|WP_Error |
|
| 90 | - * @since 3.20.0 |
|
| 91 | - * |
|
| 92 | - */ |
|
| 93 | - public function post( $path, $body ) { |
|
| 94 | - |
|
| 95 | - return $this->post_custom_content_type( |
|
| 96 | - $path, json_encode( $body ), 'application/json; ' . get_bloginfo( 'charset' ) |
|
| 97 | - ); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - public function post_custom_content_type( $path, $body, $content_type ) { |
|
| 101 | - |
|
| 102 | - // Prepare the target URL. |
|
| 103 | - $url = apply_filters( 'wl_api_service_api_url_path', Wordlift_Configuration_Service::get_instance()->get_api_url() . $path ); |
|
| 104 | - |
|
| 105 | - // Give some time for the operation to complete, more than the time we give to the HTTP operation to complete. |
|
| 106 | - @set_time_limit( 90 ); |
|
| 107 | - |
|
| 108 | - // Get the response value. |
|
| 109 | - $key = Wordlift_Configuration_Service::get_instance()->get_key(); |
|
| 110 | - $response = wp_remote_post( $url, array( |
|
| 111 | - 'timeout' => 60, |
|
| 112 | - 'user-agent' => User_Agent::get_user_agent(), |
|
| 113 | - 'headers' => array( |
|
| 114 | - 'Content-Type' => $content_type, |
|
| 115 | - 'X-Authorization' => $key, |
|
| 116 | - 'Authorization' => "Key $key", |
|
| 117 | - /* |
|
| 77 | + 'timeout' => 30, |
|
| 78 | + ) ); |
|
| 79 | + |
|
| 80 | + return self::get_message_or_error( $response ); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Perform a `POST` request towards the requested path. |
|
| 85 | + * |
|
| 86 | + * @param string $path The relative path. |
|
| 87 | + * @param array|object $body The request body (will be serialized to JSON). |
|
| 88 | + * |
|
| 89 | + * @return array|WP_Error |
|
| 90 | + * @since 3.20.0 |
|
| 91 | + * |
|
| 92 | + */ |
|
| 93 | + public function post( $path, $body ) { |
|
| 94 | + |
|
| 95 | + return $this->post_custom_content_type( |
|
| 96 | + $path, json_encode( $body ), 'application/json; ' . get_bloginfo( 'charset' ) |
|
| 97 | + ); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + public function post_custom_content_type( $path, $body, $content_type ) { |
|
| 101 | + |
|
| 102 | + // Prepare the target URL. |
|
| 103 | + $url = apply_filters( 'wl_api_service_api_url_path', Wordlift_Configuration_Service::get_instance()->get_api_url() . $path ); |
|
| 104 | + |
|
| 105 | + // Give some time for the operation to complete, more than the time we give to the HTTP operation to complete. |
|
| 106 | + @set_time_limit( 90 ); |
|
| 107 | + |
|
| 108 | + // Get the response value. |
|
| 109 | + $key = Wordlift_Configuration_Service::get_instance()->get_key(); |
|
| 110 | + $response = wp_remote_post( $url, array( |
|
| 111 | + 'timeout' => 60, |
|
| 112 | + 'user-agent' => User_Agent::get_user_agent(), |
|
| 113 | + 'headers' => array( |
|
| 114 | + 'Content-Type' => $content_type, |
|
| 115 | + 'X-Authorization' => $key, |
|
| 116 | + 'Authorization' => "Key $key", |
|
| 117 | + /* |
|
| 118 | 118 | * This is required to avoid CURL receiving 502 Bad Gateway errors. |
| 119 | 119 | * |
| 120 | 120 | * @see https://stackoverflow.com/questions/30601075/curl-to-google-compute-load-balancer-gets-error-502 |
| 121 | 121 | */ |
| 122 | - 'Expect' => '', |
|
| 123 | - ), |
|
| 124 | - 'body' => $body, |
|
| 125 | - ) ); |
|
| 126 | - |
|
| 127 | - return self::get_message_or_error( $response ); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - public function delete( $path ) { |
|
| 131 | - |
|
| 132 | - // Prepare the target URL. |
|
| 133 | - $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
| 134 | - |
|
| 135 | - // Get the response value. |
|
| 136 | - $response = wp_remote_request( $url, array( |
|
| 137 | - 'method' => 'DELETE', |
|
| 138 | - 'user-agent' => User_Agent::get_user_agent(), |
|
| 139 | - 'headers' => array( |
|
| 140 | - 'X-Authorization' => Wordlift_Configuration_Service::get_instance()->get_key(), |
|
| 141 | - ), |
|
| 142 | - ) ); |
|
| 143 | - |
|
| 144 | - return self::get_message_or_error( $response ); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * Return the {@link WP_Error} in case of error or the actual reply if successful. |
|
| 149 | - * |
|
| 150 | - * @param array|WP_Error $response The response of an http call. |
|
| 151 | - * |
|
| 152 | - * @return string|object|WP_Error A {@link WP_Error} instance or the actual response content. |
|
| 153 | - * @since 3.20.0 |
|
| 154 | - * |
|
| 155 | - */ |
|
| 156 | - private static function get_message_or_error( $response ) { |
|
| 157 | - |
|
| 158 | - // Result is WP_Error. |
|
| 159 | - if ( is_wp_error( $response ) ) { |
|
| 160 | - return $response; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - // `code` not set or not numeric. |
|
| 164 | - $code = wp_remote_retrieve_response_code( $response ); |
|
| 165 | - $message = @wp_remote_retrieve_response_message( $response ); |
|
| 166 | - |
|
| 167 | - if ( empty( $code ) || ! is_numeric( $code ) ) { |
|
| 168 | - return new WP_Error( 0, $message ); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - // Code not 2xx. |
|
| 172 | - if ( 2 !== intval( $code / 100 ) ) { |
|
| 173 | - return new WP_Error( $code, $message ); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - // Everything's fine, return the message. |
|
| 177 | - return self::try_json_decode( $response ); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * Try to decode the json response |
|
| 182 | - * |
|
| 183 | - * @param array $response The response array. |
|
| 184 | - * |
|
| 185 | - * @return array|mixed|object The decoded response or the original response body. |
|
| 186 | - * @since 3.20.0 |
|
| 187 | - * |
|
| 188 | - */ |
|
| 189 | - private static function try_json_decode( $response ) { |
|
| 190 | - |
|
| 191 | - // Get the headers. |
|
| 192 | - $content_type = wp_remote_retrieve_header( $response, 'content-type' ); |
|
| 193 | - $body = wp_remote_retrieve_body( $response ); |
|
| 194 | - |
|
| 195 | - // If it's not an `application/json` return the plain response body. |
|
| 196 | - if ( 0 !== strpos( strtolower( $content_type ), 'application/json' ) ) { |
|
| 197 | - return $body; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - // Decode and return the structured result. |
|
| 201 | - return json_decode( $body ); |
|
| 202 | - } |
|
| 122 | + 'Expect' => '', |
|
| 123 | + ), |
|
| 124 | + 'body' => $body, |
|
| 125 | + ) ); |
|
| 126 | + |
|
| 127 | + return self::get_message_or_error( $response ); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + public function delete( $path ) { |
|
| 131 | + |
|
| 132 | + // Prepare the target URL. |
|
| 133 | + $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
| 134 | + |
|
| 135 | + // Get the response value. |
|
| 136 | + $response = wp_remote_request( $url, array( |
|
| 137 | + 'method' => 'DELETE', |
|
| 138 | + 'user-agent' => User_Agent::get_user_agent(), |
|
| 139 | + 'headers' => array( |
|
| 140 | + 'X-Authorization' => Wordlift_Configuration_Service::get_instance()->get_key(), |
|
| 141 | + ), |
|
| 142 | + ) ); |
|
| 143 | + |
|
| 144 | + return self::get_message_or_error( $response ); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * Return the {@link WP_Error} in case of error or the actual reply if successful. |
|
| 149 | + * |
|
| 150 | + * @param array|WP_Error $response The response of an http call. |
|
| 151 | + * |
|
| 152 | + * @return string|object|WP_Error A {@link WP_Error} instance or the actual response content. |
|
| 153 | + * @since 3.20.0 |
|
| 154 | + * |
|
| 155 | + */ |
|
| 156 | + private static function get_message_or_error( $response ) { |
|
| 157 | + |
|
| 158 | + // Result is WP_Error. |
|
| 159 | + if ( is_wp_error( $response ) ) { |
|
| 160 | + return $response; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + // `code` not set or not numeric. |
|
| 164 | + $code = wp_remote_retrieve_response_code( $response ); |
|
| 165 | + $message = @wp_remote_retrieve_response_message( $response ); |
|
| 166 | + |
|
| 167 | + if ( empty( $code ) || ! is_numeric( $code ) ) { |
|
| 168 | + return new WP_Error( 0, $message ); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + // Code not 2xx. |
|
| 172 | + if ( 2 !== intval( $code / 100 ) ) { |
|
| 173 | + return new WP_Error( $code, $message ); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + // Everything's fine, return the message. |
|
| 177 | + return self::try_json_decode( $response ); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * Try to decode the json response |
|
| 182 | + * |
|
| 183 | + * @param array $response The response array. |
|
| 184 | + * |
|
| 185 | + * @return array|mixed|object The decoded response or the original response body. |
|
| 186 | + * @since 3.20.0 |
|
| 187 | + * |
|
| 188 | + */ |
|
| 189 | + private static function try_json_decode( $response ) { |
|
| 190 | + |
|
| 191 | + // Get the headers. |
|
| 192 | + $content_type = wp_remote_retrieve_header( $response, 'content-type' ); |
|
| 193 | + $body = wp_remote_retrieve_body( $response ); |
|
| 194 | + |
|
| 195 | + // If it's not an `application/json` return the plain response body. |
|
| 196 | + if ( 0 !== strpos( strtolower( $content_type ), 'application/json' ) ) { |
|
| 197 | + return $body; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + // Decode and return the structured result. |
|
| 201 | + return json_decode( $body ); |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | } |
@@ -56,13 +56,13 @@ discard block |
||
| 56 | 56 | * @since 3.20.0 |
| 57 | 57 | * |
| 58 | 58 | */ |
| 59 | - public function get( $path ) { |
|
| 59 | + public function get($path) { |
|
| 60 | 60 | |
| 61 | 61 | // Prepare the target URL. |
| 62 | - $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
| 62 | + $url = Wordlift_Configuration_Service::get_instance()->get_api_url().$path; |
|
| 63 | 63 | |
| 64 | 64 | // Get the response value. |
| 65 | - $response = wp_remote_get( $url, array( |
|
| 65 | + $response = wp_remote_get($url, array( |
|
| 66 | 66 | 'user-agent' => User_Agent::get_user_agent(), |
| 67 | 67 | 'headers' => array( |
| 68 | 68 | 'X-Authorization' => Wordlift_Configuration_Service::get_instance()->get_key(), |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | * @since 3.20.1 |
| 76 | 76 | */ |
| 77 | 77 | 'timeout' => 30, |
| 78 | - ) ); |
|
| 78 | + )); |
|
| 79 | 79 | |
| 80 | - return self::get_message_or_error( $response ); |
|
| 80 | + return self::get_message_or_error($response); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -90,24 +90,24 @@ discard block |
||
| 90 | 90 | * @since 3.20.0 |
| 91 | 91 | * |
| 92 | 92 | */ |
| 93 | - public function post( $path, $body ) { |
|
| 93 | + public function post($path, $body) { |
|
| 94 | 94 | |
| 95 | 95 | return $this->post_custom_content_type( |
| 96 | - $path, json_encode( $body ), 'application/json; ' . get_bloginfo( 'charset' ) |
|
| 96 | + $path, json_encode($body), 'application/json; '.get_bloginfo('charset') |
|
| 97 | 97 | ); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function post_custom_content_type( $path, $body, $content_type ) { |
|
| 100 | + public function post_custom_content_type($path, $body, $content_type) { |
|
| 101 | 101 | |
| 102 | 102 | // Prepare the target URL. |
| 103 | - $url = apply_filters( 'wl_api_service_api_url_path', Wordlift_Configuration_Service::get_instance()->get_api_url() . $path ); |
|
| 103 | + $url = apply_filters('wl_api_service_api_url_path', Wordlift_Configuration_Service::get_instance()->get_api_url().$path); |
|
| 104 | 104 | |
| 105 | 105 | // Give some time for the operation to complete, more than the time we give to the HTTP operation to complete. |
| 106 | - @set_time_limit( 90 ); |
|
| 106 | + @set_time_limit(90); |
|
| 107 | 107 | |
| 108 | 108 | // Get the response value. |
| 109 | 109 | $key = Wordlift_Configuration_Service::get_instance()->get_key(); |
| 110 | - $response = wp_remote_post( $url, array( |
|
| 110 | + $response = wp_remote_post($url, array( |
|
| 111 | 111 | 'timeout' => 60, |
| 112 | 112 | 'user-agent' => User_Agent::get_user_agent(), |
| 113 | 113 | 'headers' => array( |
@@ -122,26 +122,26 @@ discard block |
||
| 122 | 122 | 'Expect' => '', |
| 123 | 123 | ), |
| 124 | 124 | 'body' => $body, |
| 125 | - ) ); |
|
| 125 | + )); |
|
| 126 | 126 | |
| 127 | - return self::get_message_or_error( $response ); |
|
| 127 | + return self::get_message_or_error($response); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public function delete( $path ) { |
|
| 130 | + public function delete($path) { |
|
| 131 | 131 | |
| 132 | 132 | // Prepare the target URL. |
| 133 | - $url = Wordlift_Configuration_Service::get_instance()->get_api_url() . $path; |
|
| 133 | + $url = Wordlift_Configuration_Service::get_instance()->get_api_url().$path; |
|
| 134 | 134 | |
| 135 | 135 | // Get the response value. |
| 136 | - $response = wp_remote_request( $url, array( |
|
| 136 | + $response = wp_remote_request($url, array( |
|
| 137 | 137 | 'method' => 'DELETE', |
| 138 | 138 | 'user-agent' => User_Agent::get_user_agent(), |
| 139 | 139 | 'headers' => array( |
| 140 | 140 | 'X-Authorization' => Wordlift_Configuration_Service::get_instance()->get_key(), |
| 141 | 141 | ), |
| 142 | - ) ); |
|
| 142 | + )); |
|
| 143 | 143 | |
| 144 | - return self::get_message_or_error( $response ); |
|
| 144 | + return self::get_message_or_error($response); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -153,28 +153,28 @@ discard block |
||
| 153 | 153 | * @since 3.20.0 |
| 154 | 154 | * |
| 155 | 155 | */ |
| 156 | - private static function get_message_or_error( $response ) { |
|
| 156 | + private static function get_message_or_error($response) { |
|
| 157 | 157 | |
| 158 | 158 | // Result is WP_Error. |
| 159 | - if ( is_wp_error( $response ) ) { |
|
| 159 | + if (is_wp_error($response)) { |
|
| 160 | 160 | return $response; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // `code` not set or not numeric. |
| 164 | - $code = wp_remote_retrieve_response_code( $response ); |
|
| 165 | - $message = @wp_remote_retrieve_response_message( $response ); |
|
| 164 | + $code = wp_remote_retrieve_response_code($response); |
|
| 165 | + $message = @wp_remote_retrieve_response_message($response); |
|
| 166 | 166 | |
| 167 | - if ( empty( $code ) || ! is_numeric( $code ) ) { |
|
| 168 | - return new WP_Error( 0, $message ); |
|
| 167 | + if (empty($code) || ! is_numeric($code)) { |
|
| 168 | + return new WP_Error(0, $message); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // Code not 2xx. |
| 172 | - if ( 2 !== intval( $code / 100 ) ) { |
|
| 173 | - return new WP_Error( $code, $message ); |
|
| 172 | + if (2 !== intval($code / 100)) { |
|
| 173 | + return new WP_Error($code, $message); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // Everything's fine, return the message. |
| 177 | - return self::try_json_decode( $response ); |
|
| 177 | + return self::try_json_decode($response); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -186,19 +186,19 @@ discard block |
||
| 186 | 186 | * @since 3.20.0 |
| 187 | 187 | * |
| 188 | 188 | */ |
| 189 | - private static function try_json_decode( $response ) { |
|
| 189 | + private static function try_json_decode($response) { |
|
| 190 | 190 | |
| 191 | 191 | // Get the headers. |
| 192 | - $content_type = wp_remote_retrieve_header( $response, 'content-type' ); |
|
| 193 | - $body = wp_remote_retrieve_body( $response ); |
|
| 192 | + $content_type = wp_remote_retrieve_header($response, 'content-type'); |
|
| 193 | + $body = wp_remote_retrieve_body($response); |
|
| 194 | 194 | |
| 195 | 195 | // If it's not an `application/json` return the plain response body. |
| 196 | - if ( 0 !== strpos( strtolower( $content_type ), 'application/json' ) ) { |
|
| 196 | + if (0 !== strpos(strtolower($content_type), 'application/json')) { |
|
| 197 | 197 | return $body; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // Decode and return the structured result. |
| 201 | - return json_decode( $body ); |
|
| 201 | + return json_decode($body); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | - exit; |
|
| 14 | + exit; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -21,529 +21,529 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class Wordlift_Countries { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * An array that will contain country codes => country names pairs. It gets lazily loaded the first time by the |
|
| 26 | - * `get_countries` function. |
|
| 27 | - * |
|
| 28 | - * @since 3.18.0 |
|
| 29 | - * @var array An array of country codes => country names pairs or NULL if not initialized yet. |
|
| 30 | - */ |
|
| 31 | - private static $countries = array(); |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * The list of supported country codes, this is populated by self::lazy_populate_codes_and_country_codes_array. |
|
| 35 | - * |
|
| 36 | - * WARNING! If you change the list of supported countries, *you have* to add the related flag |
|
| 37 | - * in the images/flags folder. |
|
| 38 | - * |
|
| 39 | - * @since 3.18.0 |
|
| 40 | - * |
|
| 41 | - * @var array An array of country codes => supported_languages_array |
|
| 42 | - */ |
|
| 43 | - public static $codes = array(); |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * The list of country codes, this is populated by self::lazy_populate_codes_and_country_codes_array. |
|
| 47 | - * |
|
| 48 | - * WARNING! If you change the list of supported countries, *you have* to add the related flag |
|
| 49 | - * in the images/flags folder. |
|
| 50 | - * |
|
| 51 | - * @since 3.18.0 |
|
| 52 | - * |
|
| 53 | - * @var array An array of country codes => country names. |
|
| 54 | - */ |
|
| 55 | - private static $country_codes = array(); |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * An array of flag filenames. |
|
| 59 | - * |
|
| 60 | - * @since 3.20.0 |
|
| 61 | - * |
|
| 62 | - * @var array An array of flag filenames. |
|
| 63 | - */ |
|
| 64 | - private static $country_flags = array( |
|
| 65 | - 'af' => 'Afghanistan', |
|
| 66 | - 'ax' => 'Aland', |
|
| 67 | - 'al' => 'Albania', |
|
| 68 | - 'dz' => 'Algeria', |
|
| 69 | - 'as' => 'American-Samoa', |
|
| 70 | - 'ad' => 'Andorra', |
|
| 71 | - 'ao' => 'Angola', |
|
| 72 | - 'ai' => 'Anguilla', |
|
| 73 | - 'aq' => 'Antarctica', |
|
| 74 | - 'ag' => 'Antigua-and-Barbuda', |
|
| 75 | - 'ar' => 'Argentina', |
|
| 76 | - 'am' => 'Armenia', |
|
| 77 | - 'aw' => 'Aruba', |
|
| 78 | - 'au' => 'Australia', |
|
| 79 | - 'at' => 'Austria', |
|
| 80 | - 'az' => 'Azerbaijan', |
|
| 81 | - 'bs' => 'Bahamas', |
|
| 82 | - 'bh' => 'Bahrain', |
|
| 83 | - 'bd' => 'Bangladesh', |
|
| 84 | - 'bb' => 'Barbados', |
|
| 85 | - 'by' => 'Belarus', |
|
| 86 | - 'be' => 'Belgium', |
|
| 87 | - 'bz' => 'Belize', |
|
| 88 | - 'bj' => 'Benin', |
|
| 89 | - 'bm' => 'Bermuda', |
|
| 90 | - 'bt' => 'Bhutan', |
|
| 91 | - 'bo' => 'Bolivia', |
|
| 92 | - // Uses Netherlands' flag, see https://en.wikipedia.org/wiki/Caribbean_Netherlands. |
|
| 93 | - 'bq' => 'Netherlands', |
|
| 94 | - 'ba' => 'Bosnia-and-Herzegovina', |
|
| 95 | - 'bw' => 'Botswana', |
|
| 96 | - 'bv' => 'Bouvet Island', |
|
| 97 | - 'br' => 'Brazil', |
|
| 98 | - 'io' => null, |
|
| 99 | - 'bn' => 'Brunei', |
|
| 100 | - 'bg' => 'Bulgaria', |
|
| 101 | - 'bf' => 'Burkina-Faso', |
|
| 102 | - 'bi' => 'Burundi', |
|
| 103 | - 'kh' => 'Cambodia', |
|
| 104 | - 'cm' => 'Cameroon', |
|
| 105 | - 'ca' => 'Canada', |
|
| 106 | - 'cv' => 'Cape-Verde', |
|
| 107 | - 'ky' => 'Cayman-Islands', |
|
| 108 | - 'cf' => 'Central-African-Republic', |
|
| 109 | - 'td' => 'Chad', |
|
| 110 | - 'cl' => 'Chile', |
|
| 111 | - 'cn' => 'China', |
|
| 112 | - 'cx' => 'Christmas-Island', |
|
| 113 | - 'cc' => 'Cocos-Keeling-Islands', |
|
| 114 | - 'co' => 'Colombia', |
|
| 115 | - 'km' => 'Comoros', |
|
| 116 | - 'cg' => 'Republic-of-the-Congo', |
|
| 117 | - 'cd' => 'Democratic-Republic-of-the-Congo', |
|
| 118 | - 'ck' => 'Cook-Islands', |
|
| 119 | - 'cr' => 'Costa-Rica', |
|
| 120 | - 'ci' => 'Cote-dIvoire', |
|
| 121 | - 'hr' => 'Croatia', |
|
| 122 | - 'cu' => 'Cuba', |
|
| 123 | - 'cw' => 'Curacao', |
|
| 124 | - 'cy' => 'Cyprus', |
|
| 125 | - 'cz' => 'Czech-Republic', |
|
| 126 | - 'dk' => 'Denmark', |
|
| 127 | - 'dj' => 'Djibouti', |
|
| 128 | - 'dm' => 'Dominica', |
|
| 129 | - 'do' => 'Dominican-Republic', |
|
| 130 | - 'ec' => 'Ecuador', |
|
| 131 | - 'eg' => 'Egypt', |
|
| 132 | - 'sv' => 'El-Salvador', |
|
| 133 | - 'gq' => 'Equatorial-Guinea', |
|
| 134 | - 'er' => 'Eritrea', |
|
| 135 | - 'ee' => 'Estonia', |
|
| 136 | - 'et' => 'Ethiopia', |
|
| 137 | - 'fk' => 'Falkland-Islands', |
|
| 138 | - 'fo' => 'Faroes', |
|
| 139 | - 'fj' => 'Fiji', |
|
| 140 | - 'fi' => 'Finland', |
|
| 141 | - 'fr' => 'France', |
|
| 142 | - // Uses France's flag, see https://en.wikipedia.org/wiki/French_Guiana. |
|
| 143 | - 'gf' => 'France', |
|
| 144 | - 'pf' => 'French-Polynesia', |
|
| 145 | - 'tf' => 'French-Southern-Territories', |
|
| 146 | - 'ga' => 'Gabon', |
|
| 147 | - 'gm' => 'Gambia', |
|
| 148 | - 'ge' => 'Georgia', |
|
| 149 | - 'de' => 'Germany', |
|
| 150 | - 'gh' => 'Ghana', |
|
| 151 | - 'gi' => 'Gibraltar', |
|
| 152 | - 'gr' => 'Greece', |
|
| 153 | - 'gl' => 'Greenland', |
|
| 154 | - 'gd' => 'Grenada', |
|
| 155 | - // Uses France's flag, see https://en.wikipedia.org/wiki/Guadeloupe. |
|
| 156 | - 'gp' => 'France', |
|
| 157 | - 'gu' => 'Guam', |
|
| 158 | - 'gt' => 'Guatemala', |
|
| 159 | - 'gg' => 'Guernsey', |
|
| 160 | - 'gn' => 'Guinea', |
|
| 161 | - 'gw' => 'Guinea-Bissau', |
|
| 162 | - 'gy' => 'Guyana', |
|
| 163 | - 'ht' => 'Haiti', |
|
| 164 | - // Uses Australia's flag, see https://en.wikipedia.org/wiki/Heard_Island_and_McDonald_Islands. |
|
| 165 | - 'hm' => 'Australia', |
|
| 166 | - 'va' => 'Vatican-City', |
|
| 167 | - 'hn' => 'Honduras', |
|
| 168 | - 'hk' => 'Hong-Kong', |
|
| 169 | - 'hu' => 'Hungary', |
|
| 170 | - 'is' => 'Iceland', |
|
| 171 | - 'in' => 'India', |
|
| 172 | - 'id' => 'Indonesia', |
|
| 173 | - 'ir' => 'Iran', |
|
| 174 | - 'iq' => 'Iraq', |
|
| 175 | - 'ie' => 'Ireland', |
|
| 176 | - 'im' => 'Isle-of-Man', |
|
| 177 | - 'il' => 'Israel', |
|
| 178 | - 'it' => 'Italy', |
|
| 179 | - 'jm' => 'Jamaica', |
|
| 180 | - 'jp' => 'Japan', |
|
| 181 | - 'je' => 'Jersey', |
|
| 182 | - 'jo' => 'Jordan', |
|
| 183 | - 'kz' => 'Kazakhstan', |
|
| 184 | - 'ke' => 'Kenya', |
|
| 185 | - 'ki' => 'Kiribati', |
|
| 186 | - 'kp' => 'North-Korea', |
|
| 187 | - 'kr' => 'South-Korea', |
|
| 188 | - 'kw' => 'Kuwait', |
|
| 189 | - 'kg' => 'Kyrgyzstan', |
|
| 190 | - 'la' => 'Laos', |
|
| 191 | - 'lv' => 'Latvia', |
|
| 192 | - 'lb' => 'Lebanon', |
|
| 193 | - 'ls' => 'Lesotho', |
|
| 194 | - 'lr' => 'Liberia', |
|
| 195 | - 'ly' => 'Libya', |
|
| 196 | - 'li' => 'Liechtenstein', |
|
| 197 | - 'lt' => 'Lithuania', |
|
| 198 | - 'lu' => 'Luxembourg', |
|
| 199 | - 'mo' => 'Macau', |
|
| 200 | - 'mk' => 'Macedonia', |
|
| 201 | - 'mg' => 'Madagascar', |
|
| 202 | - 'mw' => 'Malawi', |
|
| 203 | - 'my' => 'Malaysia', |
|
| 204 | - 'mv' => 'Maldives', |
|
| 205 | - 'ml' => 'Mali', |
|
| 206 | - 'mt' => 'Malta', |
|
| 207 | - 'mh' => 'Marshall-Islands', |
|
| 208 | - 'mq' => 'Martinique', |
|
| 209 | - 'mr' => 'Mauritania', |
|
| 210 | - 'mu' => 'Mauritius', |
|
| 211 | - 'yt' => 'Mayotte', |
|
| 212 | - 'mx' => 'Mexico', |
|
| 213 | - 'fm' => 'Micronesia', |
|
| 214 | - 'md' => 'Moldova', |
|
| 215 | - 'mc' => 'Monaco', |
|
| 216 | - 'mn' => 'Mongolia', |
|
| 217 | - 'me' => 'Montenegro', |
|
| 218 | - 'ms' => 'Montserrat', |
|
| 219 | - 'ma' => 'Morocco', |
|
| 220 | - 'mz' => 'Mozambique', |
|
| 221 | - 'mm' => 'Myanmar', |
|
| 222 | - 'na' => 'Namibia', |
|
| 223 | - 'nr' => 'Nauru', |
|
| 224 | - 'np' => 'Nepal', |
|
| 225 | - 'nl' => 'Netherlands', |
|
| 226 | - 'nc' => 'New-Caledonia', |
|
| 227 | - 'nz' => 'New-Zealand', |
|
| 228 | - 'ni' => 'Nicaragua', |
|
| 229 | - 'ne' => 'Niger', |
|
| 230 | - 'ng' => 'Nigeria', |
|
| 231 | - 'nu' => 'Niue', |
|
| 232 | - 'nf' => 'Norfolk-Island', |
|
| 233 | - 'mp' => 'Northern-Mariana-Islands', |
|
| 234 | - 'no' => 'Norway', |
|
| 235 | - 'om' => 'Oman', |
|
| 236 | - 'pk' => 'Pakistan', |
|
| 237 | - 'pw' => 'Palau', |
|
| 238 | - 'ps' => 'Palestine', |
|
| 239 | - 'pa' => 'Panama', |
|
| 240 | - 'pg' => 'Papua-New-Guinea', |
|
| 241 | - 'py' => 'Paraguay', |
|
| 242 | - 'pe' => 'Peru', |
|
| 243 | - 'ph' => 'Philippines', |
|
| 244 | - 'pn' => 'Pitcairn-Islands', |
|
| 245 | - 'pl' => 'Poland', |
|
| 246 | - 'pt' => 'Portugal', |
|
| 247 | - 'pr' => 'Puerto Rico', |
|
| 248 | - 'qa' => 'Qatar', |
|
| 249 | - // Uses France's flag, see https://en.wikipedia.org/wiki/R%C3%A9union. |
|
| 250 | - 're' => 'France', |
|
| 251 | - 'ro' => 'Romania', |
|
| 252 | - 'ru' => 'Russia', |
|
| 253 | - 'rw' => 'Rwanda', |
|
| 254 | - 'bl' => 'Saint-Barthelemy', |
|
| 255 | - 'sh' => 'Saint-Helena', |
|
| 256 | - 'kn' => 'Saint-Kitts-and-Nevis', |
|
| 257 | - 'lc' => 'Saint-Lucia', |
|
| 258 | - 'mf' => 'Saint-Martin', |
|
| 259 | - // Uses France's flag, see https://en.wikipedia.org/wiki/Saint_Pierre_and_Miquelon. |
|
| 260 | - 'pm' => 'France', |
|
| 261 | - 'vc' => 'Saint-Vincent-and-the-Grenadines', |
|
| 262 | - 'ws' => 'Samoa', |
|
| 263 | - 'sm' => 'San-Marino', |
|
| 264 | - 'st' => 'Sao-Tome-and-Principe', |
|
| 265 | - 'sa' => 'Saudi-Arabia', |
|
| 266 | - 'sn' => 'Senegal', |
|
| 267 | - 'rs' => 'Serbia', |
|
| 268 | - 'sc' => 'Seychelles', |
|
| 269 | - 'sl' => 'Sierra-Leone', |
|
| 270 | - 'sg' => 'Singapore', |
|
| 271 | - 'sx' => null, |
|
| 272 | - 'sk' => 'Slovakia', |
|
| 273 | - 'si' => 'Slovenia', |
|
| 274 | - 'sb' => 'Solomon-Islands', |
|
| 275 | - 'so' => 'Somalia', |
|
| 276 | - 'za' => 'South-Africa', |
|
| 277 | - 'gs' => 'South-Georgia-and-the-South-Sandwich-Islands', |
|
| 278 | - 'ss' => 'South-Sudan', |
|
| 279 | - 'es' => 'Spain', |
|
| 280 | - 'lk' => 'Sri-Lanka', |
|
| 281 | - 'sd' => 'Sudan', |
|
| 282 | - 'sr' => 'Suriname', |
|
| 283 | - // Uses Norway's flag, see https://en.wikipedia.org/wiki/Svalbard_and_Jan_Mayen. |
|
| 284 | - 'sj' => 'Norway', |
|
| 285 | - 'sz' => 'Swaziland', |
|
| 286 | - 'se' => 'Sweden', |
|
| 287 | - 'ch' => 'Switzerland', |
|
| 288 | - 'sy' => 'Syria', |
|
| 289 | - 'tw' => 'Taiwan', |
|
| 290 | - 'tj' => 'Tajikistan', |
|
| 291 | - 'tz' => 'Tanzania', |
|
| 292 | - 'th' => 'Thailand', |
|
| 293 | - 'tl' => 'East-Timor', |
|
| 294 | - 'tg' => 'Togo', |
|
| 295 | - 'tk' => 'Tokelau', |
|
| 296 | - 'to' => 'Tonga', |
|
| 297 | - 'tt' => 'Trinidad-and-Tobago', |
|
| 298 | - 'tn' => 'Tunisia', |
|
| 299 | - 'tr' => 'Turkey', |
|
| 300 | - 'tm' => 'Turkmenistan', |
|
| 301 | - 'tc' => 'Turks-and-Caicos-Islands', |
|
| 302 | - 'tv' => 'Tuvalu', |
|
| 303 | - 'ug' => 'Uganda', |
|
| 304 | - 'ua' => 'Ukraine', |
|
| 305 | - 'ae' => 'United-Arab-Emirates', |
|
| 306 | - 'gb' => 'United-Kingdom', |
|
| 307 | - 'uk' => 'United-Kingdom', |
|
| 308 | - 'us' => 'United-States', |
|
| 309 | - 'um' => 'United-States', |
|
| 310 | - 'uy' => 'Uruguay', |
|
| 311 | - 'uz' => 'Uzbekistan', |
|
| 312 | - 'vu' => 'Vanuatu', |
|
| 313 | - 've' => 'Venezuela', |
|
| 314 | - 'vn' => 'Vietnam', |
|
| 315 | - 'vg' => 'British-Virgin-Islands', |
|
| 316 | - 'vi' => 'US-Virgin-Islands', |
|
| 317 | - 'wf' => 'Wallis-And-Futuna', |
|
| 318 | - 'eh' => 'Western-Sahara', |
|
| 319 | - 'ye' => 'Yemen', |
|
| 320 | - 'zm' => 'Zambia', |
|
| 321 | - 'zw' => 'Zimbabwe', |
|
| 322 | - ); |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * Parse_country_code_json_file_to_array. |
|
| 326 | - * |
|
| 327 | - * @param string $file_name The json file name where the supported country |
|
| 328 | - * and languages are present. |
|
| 329 | - * |
|
| 330 | - * @return array An Array having two maps, country_code_language_map and country_code_name_map. |
|
| 331 | - */ |
|
| 332 | - public static function parse_country_code_json_file_to_array( $file_name ) { |
|
| 333 | - $json_file_contents = file_get_contents( $file_name ); |
|
| 334 | - $decoded_array = json_decode( $json_file_contents, true ); |
|
| 335 | - // decoded array would be null if the json_decode parses |
|
| 336 | - // invalid content. |
|
| 337 | - if ( null === $decoded_array ) { |
|
| 338 | - return array( |
|
| 339 | - 'country_code_name_map' => array(), |
|
| 340 | - 'country_code_language_map' => array(), |
|
| 341 | - ); |
|
| 342 | - } |
|
| 343 | - $result = array(); |
|
| 344 | - // country_code => country_language map. |
|
| 345 | - $country_code_language_map = array(); |
|
| 346 | - // country_code => country_name map. |
|
| 347 | - $country_code_name_map = array(); |
|
| 348 | - foreach ( $decoded_array as $key => $value ) { |
|
| 349 | - $country_code_language_map[ $key ] = $value['supportedLang']; |
|
| 350 | - $country_code_name_map [ $key ] = $value['defaultLoc']['loc_name']; |
|
| 351 | - } |
|
| 352 | - $result['country_code_language_map'] = $country_code_language_map; |
|
| 353 | - $result['country_code_name_map'] = $country_code_name_map; |
|
| 354 | - |
|
| 355 | - return $result; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * Get the list of WordLift's supported country codes from json file mapping country_code => languages. |
|
| 360 | - * |
|
| 361 | - * @param string $file_name The json file where the supported country codes and language_codes are stored. |
|
| 362 | - * |
|
| 363 | - * @return array An Array having two maps, country_code_language_map and country_code_name_map. |
|
| 364 | - * @since 3.22.5.1 |
|
| 365 | - * |
|
| 366 | - */ |
|
| 367 | - public static function get_codes_from_json_file( $file_name ) { |
|
| 368 | - if ( file_exists( $file_name ) ) { |
|
| 369 | - return self::parse_country_code_json_file_to_array( $file_name ); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - return array( |
|
| 373 | - 'country_code_name_map' => array(), |
|
| 374 | - 'country_code_language_map' => array(), |
|
| 375 | - ); |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * Returns the country language pairs. |
|
| 380 | - * |
|
| 381 | - * @return array The country language pairs. |
|
| 382 | - * @since 3.18.0 |
|
| 383 | - * |
|
| 384 | - */ |
|
| 385 | - public static function get_codes() { |
|
| 386 | - return self::$codes; |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * Populate self::codes and self::country_codes if not done before. |
|
| 391 | - * |
|
| 392 | - * @param string $file_name The json file where the supported country codes and language_codes are stored. |
|
| 393 | - * |
|
| 394 | - * @return void |
|
| 395 | - * @since 3.22.5.1 |
|
| 396 | - * |
|
| 397 | - */ |
|
| 398 | - private static function lazy_populate_codes_and_country_codes_array( $file_name ) { |
|
| 399 | - if ( null === $file_name ) { |
|
| 400 | - $file_name = __DIR__ . '/supported-countries.json'; |
|
| 401 | - } |
|
| 402 | - if ( 0 === count( self::$codes ) || 0 === count( self::$country_codes ) ) { |
|
| 403 | - // populate the two arrays. |
|
| 404 | - $result_array = self::get_codes_from_json_file( $file_name ); |
|
| 405 | - self::$codes = $result_array['country_code_language_map']; |
|
| 406 | - self::$country_codes = $result_array['country_code_name_map']; |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * Reset codes_and_country_codes static variable, used for testing |
|
| 413 | - * |
|
| 414 | - * @return void |
|
| 415 | - * @since 3.22.5.1 |
|
| 416 | - * |
|
| 417 | - */ |
|
| 418 | - public static function reset_codes_and_country_codes() { |
|
| 419 | - self::$codes = array(); |
|
| 420 | - self::$country_codes = array(); |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * Get the list of WordLift's supported countries in an array with country code => country name pairs. |
|
| 426 | - * |
|
| 427 | - * @param string|false $lang Optional. The language code we are looking for. Default `any`. |
|
| 428 | - * |
|
| 429 | - * @param string|null $file_name Optional. The json file containing country codes |
|
| 430 | - * and language data. |
|
| 431 | - * |
|
| 432 | - * @return array An array with country code => country name pairs. |
|
| 433 | - * @since 3.18.0 |
|
| 434 | - * |
|
| 435 | - */ |
|
| 436 | - public static function get_countries( $lang = false, $file_name = null ) { |
|
| 437 | - |
|
| 438 | - // populate the codes and countries array if it is not done before. |
|
| 439 | - self::lazy_populate_codes_and_country_codes_array( $file_name ); |
|
| 440 | - |
|
| 441 | - // Lazily load the countries. |
|
| 24 | + /** |
|
| 25 | + * An array that will contain country codes => country names pairs. It gets lazily loaded the first time by the |
|
| 26 | + * `get_countries` function. |
|
| 27 | + * |
|
| 28 | + * @since 3.18.0 |
|
| 29 | + * @var array An array of country codes => country names pairs or NULL if not initialized yet. |
|
| 30 | + */ |
|
| 31 | + private static $countries = array(); |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * The list of supported country codes, this is populated by self::lazy_populate_codes_and_country_codes_array. |
|
| 35 | + * |
|
| 36 | + * WARNING! If you change the list of supported countries, *you have* to add the related flag |
|
| 37 | + * in the images/flags folder. |
|
| 38 | + * |
|
| 39 | + * @since 3.18.0 |
|
| 40 | + * |
|
| 41 | + * @var array An array of country codes => supported_languages_array |
|
| 42 | + */ |
|
| 43 | + public static $codes = array(); |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * The list of country codes, this is populated by self::lazy_populate_codes_and_country_codes_array. |
|
| 47 | + * |
|
| 48 | + * WARNING! If you change the list of supported countries, *you have* to add the related flag |
|
| 49 | + * in the images/flags folder. |
|
| 50 | + * |
|
| 51 | + * @since 3.18.0 |
|
| 52 | + * |
|
| 53 | + * @var array An array of country codes => country names. |
|
| 54 | + */ |
|
| 55 | + private static $country_codes = array(); |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * An array of flag filenames. |
|
| 59 | + * |
|
| 60 | + * @since 3.20.0 |
|
| 61 | + * |
|
| 62 | + * @var array An array of flag filenames. |
|
| 63 | + */ |
|
| 64 | + private static $country_flags = array( |
|
| 65 | + 'af' => 'Afghanistan', |
|
| 66 | + 'ax' => 'Aland', |
|
| 67 | + 'al' => 'Albania', |
|
| 68 | + 'dz' => 'Algeria', |
|
| 69 | + 'as' => 'American-Samoa', |
|
| 70 | + 'ad' => 'Andorra', |
|
| 71 | + 'ao' => 'Angola', |
|
| 72 | + 'ai' => 'Anguilla', |
|
| 73 | + 'aq' => 'Antarctica', |
|
| 74 | + 'ag' => 'Antigua-and-Barbuda', |
|
| 75 | + 'ar' => 'Argentina', |
|
| 76 | + 'am' => 'Armenia', |
|
| 77 | + 'aw' => 'Aruba', |
|
| 78 | + 'au' => 'Australia', |
|
| 79 | + 'at' => 'Austria', |
|
| 80 | + 'az' => 'Azerbaijan', |
|
| 81 | + 'bs' => 'Bahamas', |
|
| 82 | + 'bh' => 'Bahrain', |
|
| 83 | + 'bd' => 'Bangladesh', |
|
| 84 | + 'bb' => 'Barbados', |
|
| 85 | + 'by' => 'Belarus', |
|
| 86 | + 'be' => 'Belgium', |
|
| 87 | + 'bz' => 'Belize', |
|
| 88 | + 'bj' => 'Benin', |
|
| 89 | + 'bm' => 'Bermuda', |
|
| 90 | + 'bt' => 'Bhutan', |
|
| 91 | + 'bo' => 'Bolivia', |
|
| 92 | + // Uses Netherlands' flag, see https://en.wikipedia.org/wiki/Caribbean_Netherlands. |
|
| 93 | + 'bq' => 'Netherlands', |
|
| 94 | + 'ba' => 'Bosnia-and-Herzegovina', |
|
| 95 | + 'bw' => 'Botswana', |
|
| 96 | + 'bv' => 'Bouvet Island', |
|
| 97 | + 'br' => 'Brazil', |
|
| 98 | + 'io' => null, |
|
| 99 | + 'bn' => 'Brunei', |
|
| 100 | + 'bg' => 'Bulgaria', |
|
| 101 | + 'bf' => 'Burkina-Faso', |
|
| 102 | + 'bi' => 'Burundi', |
|
| 103 | + 'kh' => 'Cambodia', |
|
| 104 | + 'cm' => 'Cameroon', |
|
| 105 | + 'ca' => 'Canada', |
|
| 106 | + 'cv' => 'Cape-Verde', |
|
| 107 | + 'ky' => 'Cayman-Islands', |
|
| 108 | + 'cf' => 'Central-African-Republic', |
|
| 109 | + 'td' => 'Chad', |
|
| 110 | + 'cl' => 'Chile', |
|
| 111 | + 'cn' => 'China', |
|
| 112 | + 'cx' => 'Christmas-Island', |
|
| 113 | + 'cc' => 'Cocos-Keeling-Islands', |
|
| 114 | + 'co' => 'Colombia', |
|
| 115 | + 'km' => 'Comoros', |
|
| 116 | + 'cg' => 'Republic-of-the-Congo', |
|
| 117 | + 'cd' => 'Democratic-Republic-of-the-Congo', |
|
| 118 | + 'ck' => 'Cook-Islands', |
|
| 119 | + 'cr' => 'Costa-Rica', |
|
| 120 | + 'ci' => 'Cote-dIvoire', |
|
| 121 | + 'hr' => 'Croatia', |
|
| 122 | + 'cu' => 'Cuba', |
|
| 123 | + 'cw' => 'Curacao', |
|
| 124 | + 'cy' => 'Cyprus', |
|
| 125 | + 'cz' => 'Czech-Republic', |
|
| 126 | + 'dk' => 'Denmark', |
|
| 127 | + 'dj' => 'Djibouti', |
|
| 128 | + 'dm' => 'Dominica', |
|
| 129 | + 'do' => 'Dominican-Republic', |
|
| 130 | + 'ec' => 'Ecuador', |
|
| 131 | + 'eg' => 'Egypt', |
|
| 132 | + 'sv' => 'El-Salvador', |
|
| 133 | + 'gq' => 'Equatorial-Guinea', |
|
| 134 | + 'er' => 'Eritrea', |
|
| 135 | + 'ee' => 'Estonia', |
|
| 136 | + 'et' => 'Ethiopia', |
|
| 137 | + 'fk' => 'Falkland-Islands', |
|
| 138 | + 'fo' => 'Faroes', |
|
| 139 | + 'fj' => 'Fiji', |
|
| 140 | + 'fi' => 'Finland', |
|
| 141 | + 'fr' => 'France', |
|
| 142 | + // Uses France's flag, see https://en.wikipedia.org/wiki/French_Guiana. |
|
| 143 | + 'gf' => 'France', |
|
| 144 | + 'pf' => 'French-Polynesia', |
|
| 145 | + 'tf' => 'French-Southern-Territories', |
|
| 146 | + 'ga' => 'Gabon', |
|
| 147 | + 'gm' => 'Gambia', |
|
| 148 | + 'ge' => 'Georgia', |
|
| 149 | + 'de' => 'Germany', |
|
| 150 | + 'gh' => 'Ghana', |
|
| 151 | + 'gi' => 'Gibraltar', |
|
| 152 | + 'gr' => 'Greece', |
|
| 153 | + 'gl' => 'Greenland', |
|
| 154 | + 'gd' => 'Grenada', |
|
| 155 | + // Uses France's flag, see https://en.wikipedia.org/wiki/Guadeloupe. |
|
| 156 | + 'gp' => 'France', |
|
| 157 | + 'gu' => 'Guam', |
|
| 158 | + 'gt' => 'Guatemala', |
|
| 159 | + 'gg' => 'Guernsey', |
|
| 160 | + 'gn' => 'Guinea', |
|
| 161 | + 'gw' => 'Guinea-Bissau', |
|
| 162 | + 'gy' => 'Guyana', |
|
| 163 | + 'ht' => 'Haiti', |
|
| 164 | + // Uses Australia's flag, see https://en.wikipedia.org/wiki/Heard_Island_and_McDonald_Islands. |
|
| 165 | + 'hm' => 'Australia', |
|
| 166 | + 'va' => 'Vatican-City', |
|
| 167 | + 'hn' => 'Honduras', |
|
| 168 | + 'hk' => 'Hong-Kong', |
|
| 169 | + 'hu' => 'Hungary', |
|
| 170 | + 'is' => 'Iceland', |
|
| 171 | + 'in' => 'India', |
|
| 172 | + 'id' => 'Indonesia', |
|
| 173 | + 'ir' => 'Iran', |
|
| 174 | + 'iq' => 'Iraq', |
|
| 175 | + 'ie' => 'Ireland', |
|
| 176 | + 'im' => 'Isle-of-Man', |
|
| 177 | + 'il' => 'Israel', |
|
| 178 | + 'it' => 'Italy', |
|
| 179 | + 'jm' => 'Jamaica', |
|
| 180 | + 'jp' => 'Japan', |
|
| 181 | + 'je' => 'Jersey', |
|
| 182 | + 'jo' => 'Jordan', |
|
| 183 | + 'kz' => 'Kazakhstan', |
|
| 184 | + 'ke' => 'Kenya', |
|
| 185 | + 'ki' => 'Kiribati', |
|
| 186 | + 'kp' => 'North-Korea', |
|
| 187 | + 'kr' => 'South-Korea', |
|
| 188 | + 'kw' => 'Kuwait', |
|
| 189 | + 'kg' => 'Kyrgyzstan', |
|
| 190 | + 'la' => 'Laos', |
|
| 191 | + 'lv' => 'Latvia', |
|
| 192 | + 'lb' => 'Lebanon', |
|
| 193 | + 'ls' => 'Lesotho', |
|
| 194 | + 'lr' => 'Liberia', |
|
| 195 | + 'ly' => 'Libya', |
|
| 196 | + 'li' => 'Liechtenstein', |
|
| 197 | + 'lt' => 'Lithuania', |
|
| 198 | + 'lu' => 'Luxembourg', |
|
| 199 | + 'mo' => 'Macau', |
|
| 200 | + 'mk' => 'Macedonia', |
|
| 201 | + 'mg' => 'Madagascar', |
|
| 202 | + 'mw' => 'Malawi', |
|
| 203 | + 'my' => 'Malaysia', |
|
| 204 | + 'mv' => 'Maldives', |
|
| 205 | + 'ml' => 'Mali', |
|
| 206 | + 'mt' => 'Malta', |
|
| 207 | + 'mh' => 'Marshall-Islands', |
|
| 208 | + 'mq' => 'Martinique', |
|
| 209 | + 'mr' => 'Mauritania', |
|
| 210 | + 'mu' => 'Mauritius', |
|
| 211 | + 'yt' => 'Mayotte', |
|
| 212 | + 'mx' => 'Mexico', |
|
| 213 | + 'fm' => 'Micronesia', |
|
| 214 | + 'md' => 'Moldova', |
|
| 215 | + 'mc' => 'Monaco', |
|
| 216 | + 'mn' => 'Mongolia', |
|
| 217 | + 'me' => 'Montenegro', |
|
| 218 | + 'ms' => 'Montserrat', |
|
| 219 | + 'ma' => 'Morocco', |
|
| 220 | + 'mz' => 'Mozambique', |
|
| 221 | + 'mm' => 'Myanmar', |
|
| 222 | + 'na' => 'Namibia', |
|
| 223 | + 'nr' => 'Nauru', |
|
| 224 | + 'np' => 'Nepal', |
|
| 225 | + 'nl' => 'Netherlands', |
|
| 226 | + 'nc' => 'New-Caledonia', |
|
| 227 | + 'nz' => 'New-Zealand', |
|
| 228 | + 'ni' => 'Nicaragua', |
|
| 229 | + 'ne' => 'Niger', |
|
| 230 | + 'ng' => 'Nigeria', |
|
| 231 | + 'nu' => 'Niue', |
|
| 232 | + 'nf' => 'Norfolk-Island', |
|
| 233 | + 'mp' => 'Northern-Mariana-Islands', |
|
| 234 | + 'no' => 'Norway', |
|
| 235 | + 'om' => 'Oman', |
|
| 236 | + 'pk' => 'Pakistan', |
|
| 237 | + 'pw' => 'Palau', |
|
| 238 | + 'ps' => 'Palestine', |
|
| 239 | + 'pa' => 'Panama', |
|
| 240 | + 'pg' => 'Papua-New-Guinea', |
|
| 241 | + 'py' => 'Paraguay', |
|
| 242 | + 'pe' => 'Peru', |
|
| 243 | + 'ph' => 'Philippines', |
|
| 244 | + 'pn' => 'Pitcairn-Islands', |
|
| 245 | + 'pl' => 'Poland', |
|
| 246 | + 'pt' => 'Portugal', |
|
| 247 | + 'pr' => 'Puerto Rico', |
|
| 248 | + 'qa' => 'Qatar', |
|
| 249 | + // Uses France's flag, see https://en.wikipedia.org/wiki/R%C3%A9union. |
|
| 250 | + 're' => 'France', |
|
| 251 | + 'ro' => 'Romania', |
|
| 252 | + 'ru' => 'Russia', |
|
| 253 | + 'rw' => 'Rwanda', |
|
| 254 | + 'bl' => 'Saint-Barthelemy', |
|
| 255 | + 'sh' => 'Saint-Helena', |
|
| 256 | + 'kn' => 'Saint-Kitts-and-Nevis', |
|
| 257 | + 'lc' => 'Saint-Lucia', |
|
| 258 | + 'mf' => 'Saint-Martin', |
|
| 259 | + // Uses France's flag, see https://en.wikipedia.org/wiki/Saint_Pierre_and_Miquelon. |
|
| 260 | + 'pm' => 'France', |
|
| 261 | + 'vc' => 'Saint-Vincent-and-the-Grenadines', |
|
| 262 | + 'ws' => 'Samoa', |
|
| 263 | + 'sm' => 'San-Marino', |
|
| 264 | + 'st' => 'Sao-Tome-and-Principe', |
|
| 265 | + 'sa' => 'Saudi-Arabia', |
|
| 266 | + 'sn' => 'Senegal', |
|
| 267 | + 'rs' => 'Serbia', |
|
| 268 | + 'sc' => 'Seychelles', |
|
| 269 | + 'sl' => 'Sierra-Leone', |
|
| 270 | + 'sg' => 'Singapore', |
|
| 271 | + 'sx' => null, |
|
| 272 | + 'sk' => 'Slovakia', |
|
| 273 | + 'si' => 'Slovenia', |
|
| 274 | + 'sb' => 'Solomon-Islands', |
|
| 275 | + 'so' => 'Somalia', |
|
| 276 | + 'za' => 'South-Africa', |
|
| 277 | + 'gs' => 'South-Georgia-and-the-South-Sandwich-Islands', |
|
| 278 | + 'ss' => 'South-Sudan', |
|
| 279 | + 'es' => 'Spain', |
|
| 280 | + 'lk' => 'Sri-Lanka', |
|
| 281 | + 'sd' => 'Sudan', |
|
| 282 | + 'sr' => 'Suriname', |
|
| 283 | + // Uses Norway's flag, see https://en.wikipedia.org/wiki/Svalbard_and_Jan_Mayen. |
|
| 284 | + 'sj' => 'Norway', |
|
| 285 | + 'sz' => 'Swaziland', |
|
| 286 | + 'se' => 'Sweden', |
|
| 287 | + 'ch' => 'Switzerland', |
|
| 288 | + 'sy' => 'Syria', |
|
| 289 | + 'tw' => 'Taiwan', |
|
| 290 | + 'tj' => 'Tajikistan', |
|
| 291 | + 'tz' => 'Tanzania', |
|
| 292 | + 'th' => 'Thailand', |
|
| 293 | + 'tl' => 'East-Timor', |
|
| 294 | + 'tg' => 'Togo', |
|
| 295 | + 'tk' => 'Tokelau', |
|
| 296 | + 'to' => 'Tonga', |
|
| 297 | + 'tt' => 'Trinidad-and-Tobago', |
|
| 298 | + 'tn' => 'Tunisia', |
|
| 299 | + 'tr' => 'Turkey', |
|
| 300 | + 'tm' => 'Turkmenistan', |
|
| 301 | + 'tc' => 'Turks-and-Caicos-Islands', |
|
| 302 | + 'tv' => 'Tuvalu', |
|
| 303 | + 'ug' => 'Uganda', |
|
| 304 | + 'ua' => 'Ukraine', |
|
| 305 | + 'ae' => 'United-Arab-Emirates', |
|
| 306 | + 'gb' => 'United-Kingdom', |
|
| 307 | + 'uk' => 'United-Kingdom', |
|
| 308 | + 'us' => 'United-States', |
|
| 309 | + 'um' => 'United-States', |
|
| 310 | + 'uy' => 'Uruguay', |
|
| 311 | + 'uz' => 'Uzbekistan', |
|
| 312 | + 'vu' => 'Vanuatu', |
|
| 313 | + 've' => 'Venezuela', |
|
| 314 | + 'vn' => 'Vietnam', |
|
| 315 | + 'vg' => 'British-Virgin-Islands', |
|
| 316 | + 'vi' => 'US-Virgin-Islands', |
|
| 317 | + 'wf' => 'Wallis-And-Futuna', |
|
| 318 | + 'eh' => 'Western-Sahara', |
|
| 319 | + 'ye' => 'Yemen', |
|
| 320 | + 'zm' => 'Zambia', |
|
| 321 | + 'zw' => 'Zimbabwe', |
|
| 322 | + ); |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * Parse_country_code_json_file_to_array. |
|
| 326 | + * |
|
| 327 | + * @param string $file_name The json file name where the supported country |
|
| 328 | + * and languages are present. |
|
| 329 | + * |
|
| 330 | + * @return array An Array having two maps, country_code_language_map and country_code_name_map. |
|
| 331 | + */ |
|
| 332 | + public static function parse_country_code_json_file_to_array( $file_name ) { |
|
| 333 | + $json_file_contents = file_get_contents( $file_name ); |
|
| 334 | + $decoded_array = json_decode( $json_file_contents, true ); |
|
| 335 | + // decoded array would be null if the json_decode parses |
|
| 336 | + // invalid content. |
|
| 337 | + if ( null === $decoded_array ) { |
|
| 338 | + return array( |
|
| 339 | + 'country_code_name_map' => array(), |
|
| 340 | + 'country_code_language_map' => array(), |
|
| 341 | + ); |
|
| 342 | + } |
|
| 343 | + $result = array(); |
|
| 344 | + // country_code => country_language map. |
|
| 345 | + $country_code_language_map = array(); |
|
| 346 | + // country_code => country_name map. |
|
| 347 | + $country_code_name_map = array(); |
|
| 348 | + foreach ( $decoded_array as $key => $value ) { |
|
| 349 | + $country_code_language_map[ $key ] = $value['supportedLang']; |
|
| 350 | + $country_code_name_map [ $key ] = $value['defaultLoc']['loc_name']; |
|
| 351 | + } |
|
| 352 | + $result['country_code_language_map'] = $country_code_language_map; |
|
| 353 | + $result['country_code_name_map'] = $country_code_name_map; |
|
| 354 | + |
|
| 355 | + return $result; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * Get the list of WordLift's supported country codes from json file mapping country_code => languages. |
|
| 360 | + * |
|
| 361 | + * @param string $file_name The json file where the supported country codes and language_codes are stored. |
|
| 362 | + * |
|
| 363 | + * @return array An Array having two maps, country_code_language_map and country_code_name_map. |
|
| 364 | + * @since 3.22.5.1 |
|
| 365 | + * |
|
| 366 | + */ |
|
| 367 | + public static function get_codes_from_json_file( $file_name ) { |
|
| 368 | + if ( file_exists( $file_name ) ) { |
|
| 369 | + return self::parse_country_code_json_file_to_array( $file_name ); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + return array( |
|
| 373 | + 'country_code_name_map' => array(), |
|
| 374 | + 'country_code_language_map' => array(), |
|
| 375 | + ); |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * Returns the country language pairs. |
|
| 380 | + * |
|
| 381 | + * @return array The country language pairs. |
|
| 382 | + * @since 3.18.0 |
|
| 383 | + * |
|
| 384 | + */ |
|
| 385 | + public static function get_codes() { |
|
| 386 | + return self::$codes; |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * Populate self::codes and self::country_codes if not done before. |
|
| 391 | + * |
|
| 392 | + * @param string $file_name The json file where the supported country codes and language_codes are stored. |
|
| 393 | + * |
|
| 394 | + * @return void |
|
| 395 | + * @since 3.22.5.1 |
|
| 396 | + * |
|
| 397 | + */ |
|
| 398 | + private static function lazy_populate_codes_and_country_codes_array( $file_name ) { |
|
| 399 | + if ( null === $file_name ) { |
|
| 400 | + $file_name = __DIR__ . '/supported-countries.json'; |
|
| 401 | + } |
|
| 402 | + if ( 0 === count( self::$codes ) || 0 === count( self::$country_codes ) ) { |
|
| 403 | + // populate the two arrays. |
|
| 404 | + $result_array = self::get_codes_from_json_file( $file_name ); |
|
| 405 | + self::$codes = $result_array['country_code_language_map']; |
|
| 406 | + self::$country_codes = $result_array['country_code_name_map']; |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * Reset codes_and_country_codes static variable, used for testing |
|
| 413 | + * |
|
| 414 | + * @return void |
|
| 415 | + * @since 3.22.5.1 |
|
| 416 | + * |
|
| 417 | + */ |
|
| 418 | + public static function reset_codes_and_country_codes() { |
|
| 419 | + self::$codes = array(); |
|
| 420 | + self::$country_codes = array(); |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * Get the list of WordLift's supported countries in an array with country code => country name pairs. |
|
| 426 | + * |
|
| 427 | + * @param string|false $lang Optional. The language code we are looking for. Default `any`. |
|
| 428 | + * |
|
| 429 | + * @param string|null $file_name Optional. The json file containing country codes |
|
| 430 | + * and language data. |
|
| 431 | + * |
|
| 432 | + * @return array An array with country code => country name pairs. |
|
| 433 | + * @since 3.18.0 |
|
| 434 | + * |
|
| 435 | + */ |
|
| 436 | + public static function get_countries( $lang = false, $file_name = null ) { |
|
| 437 | + |
|
| 438 | + // populate the codes and countries array if it is not done before. |
|
| 439 | + self::lazy_populate_codes_and_country_codes_array( $file_name ); |
|
| 440 | + |
|
| 441 | + // Lazily load the countries. |
|
| 442 | 442 | // $lang_key = false === $lang ? 'any' : $lang; |
| 443 | - $lang_key = 'any'; |
|
| 444 | - $lang = ''; |
|
| 445 | - |
|
| 446 | - if ( isset( self::$countries[ $lang_key ] ) ) { |
|
| 447 | - return self::$countries[ $lang_key ]; |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - // Prepare the array. |
|
| 451 | - self::$countries[ $lang ] = array(); |
|
| 452 | - |
|
| 453 | - // Get the country names from WP's own (multisite) function. |
|
| 454 | - foreach ( self::$codes as $key => $languages ) { |
|
| 455 | - if ( |
|
| 456 | - // Process all countries if there is no language specified. |
|
| 457 | - empty( $lang ) || |
|
| 458 | - |
|
| 459 | - // Or if there are no language limitations for current country. |
|
| 460 | - empty( self::$codes[ $key ] ) || |
|
| 461 | - |
|
| 462 | - // Or if the language code exists for current country. |
|
| 463 | - ! empty( $lang ) && in_array( $lang, self::$codes[ $key ] ) |
|
| 464 | - ) { |
|
| 465 | - self::$countries[ $lang_key ][ $key ] = self::format_country_code( $key ); |
|
| 466 | - } |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - // Sort by country name. |
|
| 470 | - asort( self::$countries[ $lang_key ] ); |
|
| 471 | - |
|
| 472 | - // We don't sort here because `asort` returns bool instead of sorted array. |
|
| 473 | - return self::$countries[ $lang_key ]; |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - /** |
|
| 477 | - * Returns the country for a country code. This function is a clone of WP's function provided in `ms.php`. |
|
| 478 | - * |
|
| 479 | - * @param string $code Optional. The two-letter country code. Default empty. |
|
| 480 | - * |
|
| 481 | - * @return string The country corresponding to $code if it exists. If it does not exist, |
|
| 482 | - * then the first two letters of $code is returned. |
|
| 483 | - * @since 3.18.0 |
|
| 484 | - * |
|
| 485 | - */ |
|
| 486 | - private static function format_country_code( $code = '' ) { |
|
| 487 | - |
|
| 488 | - $code = strtolower( substr( $code, 0, 2 ) ); |
|
| 489 | - /** |
|
| 490 | - * Filters the country codes. |
|
| 491 | - * |
|
| 492 | - * @param array $country_codes Key/value pair of country codes where key is the short version. |
|
| 493 | - * @param string $code A two-letter designation of the country. |
|
| 494 | - * |
|
| 495 | - * @since 3.18.0 |
|
| 496 | - * |
|
| 497 | - */ |
|
| 498 | - $country_codes = apply_filters( 'country_code', self::$country_codes, $code ); |
|
| 499 | - |
|
| 500 | - return strtr( $code, $country_codes ); |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * Get a flag URL. |
|
| 505 | - * |
|
| 506 | - * @param string $country_code The country code. |
|
| 507 | - * |
|
| 508 | - * @return string|null The flag url or null if not available. |
|
| 509 | - * @since 3.20.0 |
|
| 510 | - * |
|
| 511 | - */ |
|
| 512 | - public static function get_flag_url( $country_code ) { |
|
| 513 | - |
|
| 514 | - // Bail out if we don't have the flag. |
|
| 515 | - if ( ! isset( self::$country_flags[ $country_code ] ) |
|
| 516 | - || is_null( self::$country_flags[ $country_code ] ) ) { |
|
| 517 | - return null; |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - return plugin_dir_url( dirname( __FILE__ ) ) |
|
| 521 | - . 'images/flags/16/' |
|
| 522 | - . self::$country_flags[ $country_code ] |
|
| 523 | - . '.png'; |
|
| 524 | - } |
|
| 525 | - |
|
| 526 | - /** |
|
| 527 | - * Get a country name given a country code. |
|
| 528 | - * |
|
| 529 | - * @param string $country_code The 2-letters country code. |
|
| 530 | - * |
|
| 531 | - * @return null|string The country name (in English) or null if not found. |
|
| 532 | - * @since 3.20.0 |
|
| 533 | - * |
|
| 534 | - */ |
|
| 535 | - public static function get_country_name( $country_code ) { |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * @since 3.27.6 |
|
| 539 | - * |
|
| 540 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1188 |
|
| 541 | - */ |
|
| 542 | - if ( ! isset( self::$country_codes[ $country_code ] ) ) { |
|
| 543 | - return ''; |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - return self::$country_codes[ $country_code ]; |
|
| 547 | - } |
|
| 443 | + $lang_key = 'any'; |
|
| 444 | + $lang = ''; |
|
| 445 | + |
|
| 446 | + if ( isset( self::$countries[ $lang_key ] ) ) { |
|
| 447 | + return self::$countries[ $lang_key ]; |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + // Prepare the array. |
|
| 451 | + self::$countries[ $lang ] = array(); |
|
| 452 | + |
|
| 453 | + // Get the country names from WP's own (multisite) function. |
|
| 454 | + foreach ( self::$codes as $key => $languages ) { |
|
| 455 | + if ( |
|
| 456 | + // Process all countries if there is no language specified. |
|
| 457 | + empty( $lang ) || |
|
| 458 | + |
|
| 459 | + // Or if there are no language limitations for current country. |
|
| 460 | + empty( self::$codes[ $key ] ) || |
|
| 461 | + |
|
| 462 | + // Or if the language code exists for current country. |
|
| 463 | + ! empty( $lang ) && in_array( $lang, self::$codes[ $key ] ) |
|
| 464 | + ) { |
|
| 465 | + self::$countries[ $lang_key ][ $key ] = self::format_country_code( $key ); |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + // Sort by country name. |
|
| 470 | + asort( self::$countries[ $lang_key ] ); |
|
| 471 | + |
|
| 472 | + // We don't sort here because `asort` returns bool instead of sorted array. |
|
| 473 | + return self::$countries[ $lang_key ]; |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + /** |
|
| 477 | + * Returns the country for a country code. This function is a clone of WP's function provided in `ms.php`. |
|
| 478 | + * |
|
| 479 | + * @param string $code Optional. The two-letter country code. Default empty. |
|
| 480 | + * |
|
| 481 | + * @return string The country corresponding to $code if it exists. If it does not exist, |
|
| 482 | + * then the first two letters of $code is returned. |
|
| 483 | + * @since 3.18.0 |
|
| 484 | + * |
|
| 485 | + */ |
|
| 486 | + private static function format_country_code( $code = '' ) { |
|
| 487 | + |
|
| 488 | + $code = strtolower( substr( $code, 0, 2 ) ); |
|
| 489 | + /** |
|
| 490 | + * Filters the country codes. |
|
| 491 | + * |
|
| 492 | + * @param array $country_codes Key/value pair of country codes where key is the short version. |
|
| 493 | + * @param string $code A two-letter designation of the country. |
|
| 494 | + * |
|
| 495 | + * @since 3.18.0 |
|
| 496 | + * |
|
| 497 | + */ |
|
| 498 | + $country_codes = apply_filters( 'country_code', self::$country_codes, $code ); |
|
| 499 | + |
|
| 500 | + return strtr( $code, $country_codes ); |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * Get a flag URL. |
|
| 505 | + * |
|
| 506 | + * @param string $country_code The country code. |
|
| 507 | + * |
|
| 508 | + * @return string|null The flag url or null if not available. |
|
| 509 | + * @since 3.20.0 |
|
| 510 | + * |
|
| 511 | + */ |
|
| 512 | + public static function get_flag_url( $country_code ) { |
|
| 513 | + |
|
| 514 | + // Bail out if we don't have the flag. |
|
| 515 | + if ( ! isset( self::$country_flags[ $country_code ] ) |
|
| 516 | + || is_null( self::$country_flags[ $country_code ] ) ) { |
|
| 517 | + return null; |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + return plugin_dir_url( dirname( __FILE__ ) ) |
|
| 521 | + . 'images/flags/16/' |
|
| 522 | + . self::$country_flags[ $country_code ] |
|
| 523 | + . '.png'; |
|
| 524 | + } |
|
| 525 | + |
|
| 526 | + /** |
|
| 527 | + * Get a country name given a country code. |
|
| 528 | + * |
|
| 529 | + * @param string $country_code The 2-letters country code. |
|
| 530 | + * |
|
| 531 | + * @return null|string The country name (in English) or null if not found. |
|
| 532 | + * @since 3.20.0 |
|
| 533 | + * |
|
| 534 | + */ |
|
| 535 | + public static function get_country_name( $country_code ) { |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * @since 3.27.6 |
|
| 539 | + * |
|
| 540 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1188 |
|
| 541 | + */ |
|
| 542 | + if ( ! isset( self::$country_codes[ $country_code ] ) ) { |
|
| 543 | + return ''; |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + return self::$country_codes[ $country_code ]; |
|
| 547 | + } |
|
| 548 | 548 | |
| 549 | 549 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @since 3.18.0 |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -329,12 +329,12 @@ discard block |
||
| 329 | 329 | * |
| 330 | 330 | * @return array An Array having two maps, country_code_language_map and country_code_name_map. |
| 331 | 331 | */ |
| 332 | - public static function parse_country_code_json_file_to_array( $file_name ) { |
|
| 333 | - $json_file_contents = file_get_contents( $file_name ); |
|
| 334 | - $decoded_array = json_decode( $json_file_contents, true ); |
|
| 332 | + public static function parse_country_code_json_file_to_array($file_name) { |
|
| 333 | + $json_file_contents = file_get_contents($file_name); |
|
| 334 | + $decoded_array = json_decode($json_file_contents, true); |
|
| 335 | 335 | // decoded array would be null if the json_decode parses |
| 336 | 336 | // invalid content. |
| 337 | - if ( null === $decoded_array ) { |
|
| 337 | + if (null === $decoded_array) { |
|
| 338 | 338 | return array( |
| 339 | 339 | 'country_code_name_map' => array(), |
| 340 | 340 | 'country_code_language_map' => array(), |
@@ -345,9 +345,9 @@ discard block |
||
| 345 | 345 | $country_code_language_map = array(); |
| 346 | 346 | // country_code => country_name map. |
| 347 | 347 | $country_code_name_map = array(); |
| 348 | - foreach ( $decoded_array as $key => $value ) { |
|
| 349 | - $country_code_language_map[ $key ] = $value['supportedLang']; |
|
| 350 | - $country_code_name_map [ $key ] = $value['defaultLoc']['loc_name']; |
|
| 348 | + foreach ($decoded_array as $key => $value) { |
|
| 349 | + $country_code_language_map[$key] = $value['supportedLang']; |
|
| 350 | + $country_code_name_map [$key] = $value['defaultLoc']['loc_name']; |
|
| 351 | 351 | } |
| 352 | 352 | $result['country_code_language_map'] = $country_code_language_map; |
| 353 | 353 | $result['country_code_name_map'] = $country_code_name_map; |
@@ -364,9 +364,9 @@ discard block |
||
| 364 | 364 | * @since 3.22.5.1 |
| 365 | 365 | * |
| 366 | 366 | */ |
| 367 | - public static function get_codes_from_json_file( $file_name ) { |
|
| 368 | - if ( file_exists( $file_name ) ) { |
|
| 369 | - return self::parse_country_code_json_file_to_array( $file_name ); |
|
| 367 | + public static function get_codes_from_json_file($file_name) { |
|
| 368 | + if (file_exists($file_name)) { |
|
| 369 | + return self::parse_country_code_json_file_to_array($file_name); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | return array( |
@@ -395,13 +395,13 @@ discard block |
||
| 395 | 395 | * @since 3.22.5.1 |
| 396 | 396 | * |
| 397 | 397 | */ |
| 398 | - private static function lazy_populate_codes_and_country_codes_array( $file_name ) { |
|
| 399 | - if ( null === $file_name ) { |
|
| 400 | - $file_name = __DIR__ . '/supported-countries.json'; |
|
| 398 | + private static function lazy_populate_codes_and_country_codes_array($file_name) { |
|
| 399 | + if (null === $file_name) { |
|
| 400 | + $file_name = __DIR__.'/supported-countries.json'; |
|
| 401 | 401 | } |
| 402 | - if ( 0 === count( self::$codes ) || 0 === count( self::$country_codes ) ) { |
|
| 402 | + if (0 === count(self::$codes) || 0 === count(self::$country_codes)) { |
|
| 403 | 403 | // populate the two arrays. |
| 404 | - $result_array = self::get_codes_from_json_file( $file_name ); |
|
| 404 | + $result_array = self::get_codes_from_json_file($file_name); |
|
| 405 | 405 | self::$codes = $result_array['country_code_language_map']; |
| 406 | 406 | self::$country_codes = $result_array['country_code_name_map']; |
| 407 | 407 | } |
@@ -433,44 +433,44 @@ discard block |
||
| 433 | 433 | * @since 3.18.0 |
| 434 | 434 | * |
| 435 | 435 | */ |
| 436 | - public static function get_countries( $lang = false, $file_name = null ) { |
|
| 436 | + public static function get_countries($lang = false, $file_name = null) { |
|
| 437 | 437 | |
| 438 | 438 | // populate the codes and countries array if it is not done before. |
| 439 | - self::lazy_populate_codes_and_country_codes_array( $file_name ); |
|
| 439 | + self::lazy_populate_codes_and_country_codes_array($file_name); |
|
| 440 | 440 | |
| 441 | 441 | // Lazily load the countries. |
| 442 | 442 | // $lang_key = false === $lang ? 'any' : $lang; |
| 443 | 443 | $lang_key = 'any'; |
| 444 | 444 | $lang = ''; |
| 445 | 445 | |
| 446 | - if ( isset( self::$countries[ $lang_key ] ) ) { |
|
| 447 | - return self::$countries[ $lang_key ]; |
|
| 446 | + if (isset(self::$countries[$lang_key])) { |
|
| 447 | + return self::$countries[$lang_key]; |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | // Prepare the array. |
| 451 | - self::$countries[ $lang ] = array(); |
|
| 451 | + self::$countries[$lang] = array(); |
|
| 452 | 452 | |
| 453 | 453 | // Get the country names from WP's own (multisite) function. |
| 454 | - foreach ( self::$codes as $key => $languages ) { |
|
| 454 | + foreach (self::$codes as $key => $languages) { |
|
| 455 | 455 | if ( |
| 456 | 456 | // Process all countries if there is no language specified. |
| 457 | - empty( $lang ) || |
|
| 457 | + empty($lang) || |
|
| 458 | 458 | |
| 459 | 459 | // Or if there are no language limitations for current country. |
| 460 | - empty( self::$codes[ $key ] ) || |
|
| 460 | + empty(self::$codes[$key]) || |
|
| 461 | 461 | |
| 462 | 462 | // Or if the language code exists for current country. |
| 463 | - ! empty( $lang ) && in_array( $lang, self::$codes[ $key ] ) |
|
| 463 | + ! empty($lang) && in_array($lang, self::$codes[$key]) |
|
| 464 | 464 | ) { |
| 465 | - self::$countries[ $lang_key ][ $key ] = self::format_country_code( $key ); |
|
| 465 | + self::$countries[$lang_key][$key] = self::format_country_code($key); |
|
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | // Sort by country name. |
| 470 | - asort( self::$countries[ $lang_key ] ); |
|
| 470 | + asort(self::$countries[$lang_key]); |
|
| 471 | 471 | |
| 472 | 472 | // We don't sort here because `asort` returns bool instead of sorted array. |
| 473 | - return self::$countries[ $lang_key ]; |
|
| 473 | + return self::$countries[$lang_key]; |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -483,9 +483,9 @@ discard block |
||
| 483 | 483 | * @since 3.18.0 |
| 484 | 484 | * |
| 485 | 485 | */ |
| 486 | - private static function format_country_code( $code = '' ) { |
|
| 486 | + private static function format_country_code($code = '') { |
|
| 487 | 487 | |
| 488 | - $code = strtolower( substr( $code, 0, 2 ) ); |
|
| 488 | + $code = strtolower(substr($code, 0, 2)); |
|
| 489 | 489 | /** |
| 490 | 490 | * Filters the country codes. |
| 491 | 491 | * |
@@ -495,9 +495,9 @@ discard block |
||
| 495 | 495 | * @since 3.18.0 |
| 496 | 496 | * |
| 497 | 497 | */ |
| 498 | - $country_codes = apply_filters( 'country_code', self::$country_codes, $code ); |
|
| 498 | + $country_codes = apply_filters('country_code', self::$country_codes, $code); |
|
| 499 | 499 | |
| 500 | - return strtr( $code, $country_codes ); |
|
| 500 | + return strtr($code, $country_codes); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | /** |
@@ -509,17 +509,17 @@ discard block |
||
| 509 | 509 | * @since 3.20.0 |
| 510 | 510 | * |
| 511 | 511 | */ |
| 512 | - public static function get_flag_url( $country_code ) { |
|
| 512 | + public static function get_flag_url($country_code) { |
|
| 513 | 513 | |
| 514 | 514 | // Bail out if we don't have the flag. |
| 515 | - if ( ! isset( self::$country_flags[ $country_code ] ) |
|
| 516 | - || is_null( self::$country_flags[ $country_code ] ) ) { |
|
| 515 | + if ( ! isset(self::$country_flags[$country_code]) |
|
| 516 | + || is_null(self::$country_flags[$country_code])) { |
|
| 517 | 517 | return null; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - return plugin_dir_url( dirname( __FILE__ ) ) |
|
| 520 | + return plugin_dir_url(dirname(__FILE__)) |
|
| 521 | 521 | . 'images/flags/16/' |
| 522 | - . self::$country_flags[ $country_code ] |
|
| 522 | + . self::$country_flags[$country_code] |
|
| 523 | 523 | . '.png'; |
| 524 | 524 | } |
| 525 | 525 | |
@@ -532,18 +532,18 @@ discard block |
||
| 532 | 532 | * @since 3.20.0 |
| 533 | 533 | * |
| 534 | 534 | */ |
| 535 | - public static function get_country_name( $country_code ) { |
|
| 535 | + public static function get_country_name($country_code) { |
|
| 536 | 536 | |
| 537 | 537 | /** |
| 538 | 538 | * @since 3.27.6 |
| 539 | 539 | * |
| 540 | 540 | * @see https://github.com/insideout10/wordlift-plugin/issues/1188 |
| 541 | 541 | */ |
| 542 | - if ( ! isset( self::$country_codes[ $country_code ] ) ) { |
|
| 542 | + if ( ! isset(self::$country_codes[$country_code])) { |
|
| 543 | 543 | return ''; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - return self::$country_codes[ $country_code ]; |
|
| 546 | + return self::$country_codes[$country_code]; |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | } |
@@ -82,1755 +82,1755 @@ |
||
| 82 | 82 | */ |
| 83 | 83 | class Wordlift { |
| 84 | 84 | |
| 85 | - //<editor-fold desc="## FIELDS"> |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 89 | - * the plugin. |
|
| 90 | - * |
|
| 91 | - * @since 1.0.0 |
|
| 92 | - * @access protected |
|
| 93 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 94 | - */ |
|
| 95 | - protected $loader; |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * The unique identifier of this plugin. |
|
| 99 | - * |
|
| 100 | - * @since 1.0.0 |
|
| 101 | - * @access protected |
|
| 102 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 103 | - */ |
|
| 104 | - protected $plugin_name; |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * The current version of the plugin. |
|
| 108 | - * |
|
| 109 | - * @since 1.0.0 |
|
| 110 | - * @access protected |
|
| 111 | - * @var string $version The current version of the plugin. |
|
| 112 | - */ |
|
| 113 | - protected $version; |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 117 | - * |
|
| 118 | - * @since 3.12.0 |
|
| 119 | - * @access protected |
|
| 120 | - * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 121 | - */ |
|
| 122 | - protected $tinymce_adapter; |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * The Schema service. |
|
| 126 | - * |
|
| 127 | - * @since 3.3.0 |
|
| 128 | - * @access protected |
|
| 129 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 130 | - */ |
|
| 131 | - protected $schema_service; |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * The Topic Taxonomy service. |
|
| 135 | - * |
|
| 136 | - * @since 3.5.0 |
|
| 137 | - * @access private |
|
| 138 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 139 | - */ |
|
| 140 | - private $topic_taxonomy_service; |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * The Entity Types Taxonomy service. |
|
| 144 | - * |
|
| 145 | - * @since 3.18.0 |
|
| 146 | - * @access private |
|
| 147 | - * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 148 | - */ |
|
| 149 | - private $entity_types_taxonomy_service; |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * The User service. |
|
| 153 | - * |
|
| 154 | - * @since 3.1.7 |
|
| 155 | - * @access protected |
|
| 156 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 157 | - */ |
|
| 158 | - protected $user_service; |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * The Timeline service. |
|
| 162 | - * |
|
| 163 | - * @since 3.1.0 |
|
| 164 | - * @access private |
|
| 165 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 166 | - */ |
|
| 167 | - private $timeline_service; |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * The Redirect service. |
|
| 171 | - * |
|
| 172 | - * @since 3.2.0 |
|
| 173 | - * @access private |
|
| 174 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 175 | - */ |
|
| 176 | - private $redirect_service; |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * The Notice service. |
|
| 180 | - * |
|
| 181 | - * @since 3.3.0 |
|
| 182 | - * @access private |
|
| 183 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 184 | - */ |
|
| 185 | - private $notice_service; |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * The Entity list customization. |
|
| 189 | - * |
|
| 190 | - * @since 3.3.0 |
|
| 191 | - * @access protected |
|
| 192 | - * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 193 | - */ |
|
| 194 | - protected $entity_list_service; |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * The Entity Types Taxonomy Walker. |
|
| 198 | - * |
|
| 199 | - * @since 3.1.0 |
|
| 200 | - * @access private |
|
| 201 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 202 | - */ |
|
| 203 | - private $entity_types_taxonomy_walker; |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * The ShareThis service. |
|
| 207 | - * |
|
| 208 | - * @since 3.2.0 |
|
| 209 | - * @access private |
|
| 210 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 211 | - */ |
|
| 212 | - private $sharethis_service; |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * The PrimaShop adapter. |
|
| 216 | - * |
|
| 217 | - * @since 3.2.3 |
|
| 218 | - * @access private |
|
| 219 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 220 | - */ |
|
| 221 | - private $primashop_adapter; |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * The entity type service. |
|
| 225 | - * |
|
| 226 | - * @since 3.6.0 |
|
| 227 | - * @access private |
|
| 228 | - * @var \Wordlift_Entity_Post_Type_Service |
|
| 229 | - */ |
|
| 230 | - private $entity_post_type_service; |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 234 | - * |
|
| 235 | - * @since 3.6.0 |
|
| 236 | - * @access private |
|
| 237 | - * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 238 | - */ |
|
| 239 | - private $entity_link_service; |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * A {@link Wordlift_Jsonld_Service} instance. |
|
| 243 | - * |
|
| 244 | - * @since 3.7.0 |
|
| 245 | - * @access protected |
|
| 246 | - * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 247 | - */ |
|
| 248 | - protected $jsonld_service; |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 252 | - * |
|
| 253 | - * @since 3.14.0 |
|
| 254 | - * @access protected |
|
| 255 | - * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 256 | - */ |
|
| 257 | - protected $jsonld_website_converter; |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * A {@link Wordlift_Property_Factory} instance. |
|
| 261 | - * |
|
| 262 | - * @since 3.7.0 |
|
| 263 | - * @access private |
|
| 264 | - * @var \Wordlift_Property_Factory $property_factory |
|
| 265 | - */ |
|
| 266 | - private $property_factory; |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * The 'Download Your Data' page. |
|
| 270 | - * |
|
| 271 | - * @since 3.6.0 |
|
| 272 | - * @access private |
|
| 273 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 274 | - */ |
|
| 275 | - private $download_your_data_page; |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * The 'WordLift Settings' page. |
|
| 279 | - * |
|
| 280 | - * @since 3.11.0 |
|
| 281 | - * @access protected |
|
| 282 | - * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 283 | - */ |
|
| 284 | - protected $settings_page; |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * The install wizard page. |
|
| 288 | - * |
|
| 289 | - * @since 3.9.0 |
|
| 290 | - * @access private |
|
| 291 | - * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 292 | - */ |
|
| 293 | - public $admin_setup; |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 297 | - * linking of entities to their pages. |
|
| 298 | - * |
|
| 299 | - * @since 3.8.0 |
|
| 300 | - * @access private |
|
| 301 | - * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 302 | - */ |
|
| 303 | - private $content_filter_service; |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * The Faq Content filter service |
|
| 307 | - * @since 3.26.0 |
|
| 308 | - * @access private |
|
| 309 | - * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 310 | - */ |
|
| 311 | - private $faq_content_filter_service; |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 315 | - * |
|
| 316 | - * @since 3.9.0 |
|
| 317 | - * @access private |
|
| 318 | - * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 319 | - */ |
|
| 320 | - private $key_validation_service; |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * A {@link Wordlift_Rating_Service} instance. |
|
| 324 | - * |
|
| 325 | - * @since 3.10.0 |
|
| 326 | - * @access private |
|
| 327 | - * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 328 | - */ |
|
| 329 | - private $rating_service; |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 333 | - * |
|
| 334 | - * @since 3.10.0 |
|
| 335 | - * @access protected |
|
| 336 | - * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 337 | - */ |
|
| 338 | - protected $post_to_jsonld_converter; |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * A {@link Wordlift_Install_Service} instance. |
|
| 342 | - * |
|
| 343 | - * @since 3.18.0 |
|
| 344 | - * @access protected |
|
| 345 | - * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 346 | - */ |
|
| 347 | - protected $install_service; |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 351 | - * |
|
| 352 | - * @since 3.10.0 |
|
| 353 | - * @access protected |
|
| 354 | - * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 355 | - */ |
|
| 356 | - protected $entity_post_to_jsonld_converter; |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 360 | - * |
|
| 361 | - * @since 3.10.0 |
|
| 362 | - * @access protected |
|
| 363 | - * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 364 | - */ |
|
| 365 | - protected $postid_to_jsonld_converter; |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 369 | - * |
|
| 370 | - * @since 3.11.0 |
|
| 371 | - * @access protected |
|
| 372 | - * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 373 | - */ |
|
| 374 | - protected $category_taxonomy_service; |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 378 | - * |
|
| 379 | - * @since 3.11.0 |
|
| 380 | - * @access protected |
|
| 381 | - * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 382 | - */ |
|
| 383 | - protected $entity_page_service; |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 387 | - * |
|
| 388 | - * @since 3.11.0 |
|
| 389 | - * @access protected |
|
| 390 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 391 | - */ |
|
| 392 | - protected $settings_page_action_link; |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 396 | - * |
|
| 397 | - * @since 3.11.0 |
|
| 398 | - * @access protected |
|
| 399 | - * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 400 | - */ |
|
| 401 | - protected $analytics_settings_page_action_link; |
|
| 402 | - |
|
| 403 | - /** |
|
| 404 | - * The {@link Wordlift_Analytics_Connect} class. |
|
| 405 | - * |
|
| 406 | - * @since 3.11.0 |
|
| 407 | - * @access protected |
|
| 408 | - * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 409 | - */ |
|
| 410 | - protected $analytics_connect; |
|
| 411 | - |
|
| 412 | - /** |
|
| 413 | - * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 414 | - * |
|
| 415 | - * @since 3.11.0 |
|
| 416 | - * @access protected |
|
| 417 | - * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 418 | - */ |
|
| 419 | - protected $publisher_ajax_adapter; |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 423 | - * |
|
| 424 | - * @since 3.11.0 |
|
| 425 | - * @access protected |
|
| 426 | - * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 427 | - */ |
|
| 428 | - protected $input_element; |
|
| 429 | - |
|
| 430 | - /** |
|
| 431 | - * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 432 | - * |
|
| 433 | - * @since 3.13.0 |
|
| 434 | - * @access protected |
|
| 435 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 436 | - */ |
|
| 437 | - protected $radio_input_element; |
|
| 438 | - |
|
| 439 | - /** |
|
| 440 | - * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 441 | - * |
|
| 442 | - * @since 3.11.0 |
|
| 443 | - * @access protected |
|
| 444 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 445 | - */ |
|
| 446 | - protected $language_select_element; |
|
| 447 | - |
|
| 448 | - /** |
|
| 449 | - * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 450 | - * |
|
| 451 | - * @since 3.18.0 |
|
| 452 | - * @access protected |
|
| 453 | - * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 454 | - */ |
|
| 455 | - protected $country_select_element; |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 459 | - * |
|
| 460 | - * @since 3.11.0 |
|
| 461 | - * @access protected |
|
| 462 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 463 | - */ |
|
| 464 | - protected $publisher_element; |
|
| 465 | - |
|
| 466 | - /** |
|
| 467 | - * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 468 | - * |
|
| 469 | - * @since 3.11.0 |
|
| 470 | - * @access protected |
|
| 471 | - * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 472 | - */ |
|
| 473 | - protected $select2_element; |
|
| 474 | - |
|
| 475 | - /** |
|
| 476 | - * The controller for the entity type list admin page |
|
| 477 | - * |
|
| 478 | - * @since 3.11.0 |
|
| 479 | - * @access private |
|
| 480 | - * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 481 | - */ |
|
| 482 | - private $entity_type_admin_page; |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * The controller for the entity type settings admin page |
|
| 486 | - * |
|
| 487 | - * @since 3.11.0 |
|
| 488 | - * @access private |
|
| 489 | - * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 490 | - */ |
|
| 491 | - private $entity_type_settings_admin_page; |
|
| 492 | - |
|
| 493 | - /** |
|
| 494 | - * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 495 | - * |
|
| 496 | - * @since 3.11.0 |
|
| 497 | - * @access protected |
|
| 498 | - * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 499 | - */ |
|
| 500 | - protected $related_entities_cloud_widget; |
|
| 501 | - |
|
| 502 | - /** |
|
| 503 | - * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 504 | - * |
|
| 505 | - * @since 3.14.0 |
|
| 506 | - * @access protected |
|
| 507 | - * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 508 | - */ |
|
| 509 | - protected $author_element; |
|
| 510 | - |
|
| 511 | - /** |
|
| 512 | - * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 513 | - * |
|
| 514 | - * @since 3.12.0 |
|
| 515 | - * @access protected |
|
| 516 | - * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 517 | - */ |
|
| 518 | - protected $sample_data_service; |
|
| 519 | - |
|
| 520 | - /** |
|
| 521 | - * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 522 | - * |
|
| 523 | - * @since 3.12.0 |
|
| 524 | - * @access protected |
|
| 525 | - * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 526 | - */ |
|
| 527 | - protected $sample_data_ajax_adapter; |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 531 | - * |
|
| 532 | - * @since 3.16.0 |
|
| 533 | - * @access protected |
|
| 534 | - * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 535 | - */ |
|
| 536 | - protected $google_analytics_export_service; |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * {@link Wordlift}'s singleton instance. |
|
| 540 | - * |
|
| 541 | - * @since 3.15.0 |
|
| 542 | - * @access protected |
|
| 543 | - * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 544 | - */ |
|
| 545 | - protected $entity_type_adapter; |
|
| 546 | - |
|
| 547 | - /** |
|
| 548 | - * The {@link Wordlift_Storage_Factory} instance. |
|
| 549 | - * |
|
| 550 | - * @since 3.15.0 |
|
| 551 | - * @access protected |
|
| 552 | - * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 553 | - */ |
|
| 554 | - protected $storage_factory; |
|
| 555 | - |
|
| 556 | - /** |
|
| 557 | - * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 558 | - * |
|
| 559 | - * @since 3.15.0 |
|
| 560 | - * @access private |
|
| 561 | - * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 562 | - */ |
|
| 563 | - private $autocomplete_adapter; |
|
| 564 | - |
|
| 565 | - /** |
|
| 566 | - * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 567 | - * |
|
| 568 | - * @since 3.16.0 |
|
| 569 | - * @access protected |
|
| 570 | - * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 571 | - * |
|
| 572 | - */ |
|
| 573 | - protected $cached_postid_to_jsonld_converter; |
|
| 574 | - |
|
| 575 | - /** |
|
| 576 | - * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 577 | - * |
|
| 578 | - * @since 3.16.3 |
|
| 579 | - * @access protected |
|
| 580 | - * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 581 | - */ |
|
| 582 | - protected $entity_uri_service; |
|
| 583 | - |
|
| 584 | - /** |
|
| 585 | - * The {@link Wordlift_Publisher_Service} instance. |
|
| 586 | - * |
|
| 587 | - * @since 3.19.0 |
|
| 588 | - * @access protected |
|
| 589 | - * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 590 | - */ |
|
| 591 | - protected $publisher_service; |
|
| 592 | - |
|
| 593 | - /** |
|
| 594 | - * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 595 | - * |
|
| 596 | - * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 597 | - */ |
|
| 598 | - protected $context_cards_service; |
|
| 599 | - |
|
| 600 | - /** |
|
| 601 | - * {@link Wordlift}'s singleton instance. |
|
| 602 | - * |
|
| 603 | - * @since 3.11.2 |
|
| 604 | - * @access private |
|
| 605 | - * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 606 | - */ |
|
| 607 | - private static $instance; |
|
| 608 | - |
|
| 609 | - /** |
|
| 610 | - * A singleton instance of features registry. |
|
| 611 | - * @since 3.30.0 |
|
| 612 | - * @var Features_Registry |
|
| 613 | - */ |
|
| 614 | - private $features_registry; |
|
| 615 | - |
|
| 616 | - private $analytics_settings_page; |
|
| 617 | - //</editor-fold> |
|
| 618 | - |
|
| 619 | - // Experimental code added by Nishit for feature request 1496 |
|
| 620 | - private $webhook_loader; |
|
| 621 | - // Experimental code ents here |
|
| 622 | - |
|
| 623 | - /** |
|
| 624 | - * Define the core functionality of the plugin. |
|
| 625 | - * |
|
| 626 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 627 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 628 | - * the public-facing side of the site. |
|
| 629 | - * |
|
| 630 | - * @since 1.0.0 |
|
| 631 | - */ |
|
| 632 | - public function __construct() { |
|
| 633 | - |
|
| 634 | - self::$instance = $this; |
|
| 635 | - |
|
| 636 | - $this->plugin_name = 'wordlift'; |
|
| 637 | - $this->version = '3.34.0'; |
|
| 638 | - $this->load_dependencies(); |
|
| 639 | - $this->set_locale(); |
|
| 640 | - |
|
| 641 | - $that = $this; |
|
| 642 | - add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 643 | - $that->define_admin_hooks( $that ); |
|
| 644 | - $that->define_public_hooks( $that ); |
|
| 645 | - }, 4 ); |
|
| 646 | - |
|
| 647 | - // If we're in `WP_CLI` load the related files. |
|
| 648 | - if ( class_exists( 'WP_CLI' ) ) { |
|
| 649 | - $this->load_cli_dependencies(); |
|
| 650 | - } |
|
| 651 | - |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - /** |
|
| 655 | - * Get the singleton instance. |
|
| 656 | - * |
|
| 657 | - * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 658 | - * @since 3.11.2 |
|
| 659 | - * |
|
| 660 | - */ |
|
| 661 | - public static function get_instance() { |
|
| 662 | - |
|
| 663 | - return self::$instance; |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - /** |
|
| 667 | - * Load the required dependencies for this plugin. |
|
| 668 | - * |
|
| 669 | - * Include the following files that make up the plugin: |
|
| 670 | - * |
|
| 671 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 672 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 673 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 674 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 675 | - * |
|
| 676 | - * Create an instance of the loader which will be used to register the hooks |
|
| 677 | - * with WordPress. |
|
| 678 | - * |
|
| 679 | - * @throws Exception |
|
| 680 | - * @since 1.0.0 |
|
| 681 | - * @access private |
|
| 682 | - */ |
|
| 683 | - private function load_dependencies() { |
|
| 684 | - |
|
| 685 | - /** |
|
| 686 | - * The class responsible for orchestrating the actions and filters of the |
|
| 687 | - * core plugin. |
|
| 688 | - */ |
|
| 689 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 690 | - |
|
| 691 | - // The class responsible for plugin uninstall. |
|
| 692 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 693 | - |
|
| 694 | - /** |
|
| 695 | - * The class responsible for defining internationalization functionality |
|
| 696 | - * of the plugin. |
|
| 697 | - */ |
|
| 698 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 699 | - |
|
| 700 | - /** |
|
| 701 | - * WordLift's supported languages. |
|
| 702 | - */ |
|
| 703 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 704 | - |
|
| 705 | - /** |
|
| 706 | - * WordLift's supported countries. |
|
| 707 | - */ |
|
| 708 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 709 | - |
|
| 710 | - /** |
|
| 711 | - * Provide support functions to sanitize data. |
|
| 712 | - */ |
|
| 713 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 714 | - |
|
| 715 | - /** Services. */ |
|
| 716 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 717 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 718 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 719 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 720 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 721 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 722 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 723 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 724 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 725 | - |
|
| 726 | - /** |
|
| 727 | - * The Schema service. |
|
| 728 | - */ |
|
| 729 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 730 | - |
|
| 731 | - /** |
|
| 732 | - * The schema:url property service. |
|
| 733 | - */ |
|
| 734 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 735 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 736 | - |
|
| 737 | - /** |
|
| 738 | - * The UI service. |
|
| 739 | - */ |
|
| 740 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 741 | - |
|
| 742 | - /** |
|
| 743 | - * The Entity Types Taxonomy service. |
|
| 744 | - */ |
|
| 745 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 746 | - |
|
| 747 | - /** |
|
| 748 | - * The Entity service. |
|
| 749 | - */ |
|
| 750 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 751 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 752 | - |
|
| 753 | - // Add the entity rating service. |
|
| 754 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 755 | - |
|
| 756 | - /** |
|
| 757 | - * The User service. |
|
| 758 | - */ |
|
| 759 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 760 | - |
|
| 761 | - /** |
|
| 762 | - * The Timeline service. |
|
| 763 | - */ |
|
| 764 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 765 | - |
|
| 766 | - /** |
|
| 767 | - * The Topic Taxonomy service. |
|
| 768 | - */ |
|
| 769 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 770 | - |
|
| 771 | - /** |
|
| 772 | - * The WordLift URI service. |
|
| 773 | - */ |
|
| 774 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 775 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 776 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 777 | - |
|
| 778 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 779 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 780 | - |
|
| 781 | - /** |
|
| 782 | - * Load the converters. |
|
| 783 | - */ |
|
| 784 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 785 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 786 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 787 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 788 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 789 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 790 | - |
|
| 791 | - /** |
|
| 792 | - * Load cache-related files. |
|
| 793 | - */ |
|
| 794 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 795 | - |
|
| 796 | - /** |
|
| 797 | - * Load the content filter. |
|
| 798 | - */ |
|
| 799 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 800 | - |
|
| 801 | - /* |
|
| 85 | + //<editor-fold desc="## FIELDS"> |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 89 | + * the plugin. |
|
| 90 | + * |
|
| 91 | + * @since 1.0.0 |
|
| 92 | + * @access protected |
|
| 93 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 94 | + */ |
|
| 95 | + protected $loader; |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * The unique identifier of this plugin. |
|
| 99 | + * |
|
| 100 | + * @since 1.0.0 |
|
| 101 | + * @access protected |
|
| 102 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 103 | + */ |
|
| 104 | + protected $plugin_name; |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * The current version of the plugin. |
|
| 108 | + * |
|
| 109 | + * @since 1.0.0 |
|
| 110 | + * @access protected |
|
| 111 | + * @var string $version The current version of the plugin. |
|
| 112 | + */ |
|
| 113 | + protected $version; |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 117 | + * |
|
| 118 | + * @since 3.12.0 |
|
| 119 | + * @access protected |
|
| 120 | + * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance. |
|
| 121 | + */ |
|
| 122 | + protected $tinymce_adapter; |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * The Schema service. |
|
| 126 | + * |
|
| 127 | + * @since 3.3.0 |
|
| 128 | + * @access protected |
|
| 129 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 130 | + */ |
|
| 131 | + protected $schema_service; |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * The Topic Taxonomy service. |
|
| 135 | + * |
|
| 136 | + * @since 3.5.0 |
|
| 137 | + * @access private |
|
| 138 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 139 | + */ |
|
| 140 | + private $topic_taxonomy_service; |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * The Entity Types Taxonomy service. |
|
| 144 | + * |
|
| 145 | + * @since 3.18.0 |
|
| 146 | + * @access private |
|
| 147 | + * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service. |
|
| 148 | + */ |
|
| 149 | + private $entity_types_taxonomy_service; |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * The User service. |
|
| 153 | + * |
|
| 154 | + * @since 3.1.7 |
|
| 155 | + * @access protected |
|
| 156 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 157 | + */ |
|
| 158 | + protected $user_service; |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * The Timeline service. |
|
| 162 | + * |
|
| 163 | + * @since 3.1.0 |
|
| 164 | + * @access private |
|
| 165 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 166 | + */ |
|
| 167 | + private $timeline_service; |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * The Redirect service. |
|
| 171 | + * |
|
| 172 | + * @since 3.2.0 |
|
| 173 | + * @access private |
|
| 174 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 175 | + */ |
|
| 176 | + private $redirect_service; |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * The Notice service. |
|
| 180 | + * |
|
| 181 | + * @since 3.3.0 |
|
| 182 | + * @access private |
|
| 183 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 184 | + */ |
|
| 185 | + private $notice_service; |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * The Entity list customization. |
|
| 189 | + * |
|
| 190 | + * @since 3.3.0 |
|
| 191 | + * @access protected |
|
| 192 | + * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service. |
|
| 193 | + */ |
|
| 194 | + protected $entity_list_service; |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * The Entity Types Taxonomy Walker. |
|
| 198 | + * |
|
| 199 | + * @since 3.1.0 |
|
| 200 | + * @access private |
|
| 201 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 202 | + */ |
|
| 203 | + private $entity_types_taxonomy_walker; |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * The ShareThis service. |
|
| 207 | + * |
|
| 208 | + * @since 3.2.0 |
|
| 209 | + * @access private |
|
| 210 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 211 | + */ |
|
| 212 | + private $sharethis_service; |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * The PrimaShop adapter. |
|
| 216 | + * |
|
| 217 | + * @since 3.2.3 |
|
| 218 | + * @access private |
|
| 219 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 220 | + */ |
|
| 221 | + private $primashop_adapter; |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * The entity type service. |
|
| 225 | + * |
|
| 226 | + * @since 3.6.0 |
|
| 227 | + * @access private |
|
| 228 | + * @var \Wordlift_Entity_Post_Type_Service |
|
| 229 | + */ |
|
| 230 | + private $entity_post_type_service; |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 234 | + * |
|
| 235 | + * @since 3.6.0 |
|
| 236 | + * @access private |
|
| 237 | + * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance. |
|
| 238 | + */ |
|
| 239 | + private $entity_link_service; |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * A {@link Wordlift_Jsonld_Service} instance. |
|
| 243 | + * |
|
| 244 | + * @since 3.7.0 |
|
| 245 | + * @access protected |
|
| 246 | + * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 247 | + */ |
|
| 248 | + protected $jsonld_service; |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 252 | + * |
|
| 253 | + * @since 3.14.0 |
|
| 254 | + * @access protected |
|
| 255 | + * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance. |
|
| 256 | + */ |
|
| 257 | + protected $jsonld_website_converter; |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * A {@link Wordlift_Property_Factory} instance. |
|
| 261 | + * |
|
| 262 | + * @since 3.7.0 |
|
| 263 | + * @access private |
|
| 264 | + * @var \Wordlift_Property_Factory $property_factory |
|
| 265 | + */ |
|
| 266 | + private $property_factory; |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * The 'Download Your Data' page. |
|
| 270 | + * |
|
| 271 | + * @since 3.6.0 |
|
| 272 | + * @access private |
|
| 273 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 274 | + */ |
|
| 275 | + private $download_your_data_page; |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * The 'WordLift Settings' page. |
|
| 279 | + * |
|
| 280 | + * @since 3.11.0 |
|
| 281 | + * @access protected |
|
| 282 | + * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page. |
|
| 283 | + */ |
|
| 284 | + protected $settings_page; |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * The install wizard page. |
|
| 288 | + * |
|
| 289 | + * @since 3.9.0 |
|
| 290 | + * @access private |
|
| 291 | + * @var \Wordlift_Admin_Setup $admin_setup The Install wizard. |
|
| 292 | + */ |
|
| 293 | + public $admin_setup; |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 297 | + * linking of entities to their pages. |
|
| 298 | + * |
|
| 299 | + * @since 3.8.0 |
|
| 300 | + * @access private |
|
| 301 | + * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 302 | + */ |
|
| 303 | + private $content_filter_service; |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * The Faq Content filter service |
|
| 307 | + * @since 3.26.0 |
|
| 308 | + * @access private |
|
| 309 | + * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance. |
|
| 310 | + */ |
|
| 311 | + private $faq_content_filter_service; |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 315 | + * |
|
| 316 | + * @since 3.9.0 |
|
| 317 | + * @access private |
|
| 318 | + * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 319 | + */ |
|
| 320 | + private $key_validation_service; |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * A {@link Wordlift_Rating_Service} instance. |
|
| 324 | + * |
|
| 325 | + * @since 3.10.0 |
|
| 326 | + * @access private |
|
| 327 | + * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 328 | + */ |
|
| 329 | + private $rating_service; |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 333 | + * |
|
| 334 | + * @since 3.10.0 |
|
| 335 | + * @access protected |
|
| 336 | + * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance. |
|
| 337 | + */ |
|
| 338 | + protected $post_to_jsonld_converter; |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * A {@link Wordlift_Install_Service} instance. |
|
| 342 | + * |
|
| 343 | + * @since 3.18.0 |
|
| 344 | + * @access protected |
|
| 345 | + * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance. |
|
| 346 | + */ |
|
| 347 | + protected $install_service; |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 351 | + * |
|
| 352 | + * @since 3.10.0 |
|
| 353 | + * @access protected |
|
| 354 | + * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance. |
|
| 355 | + */ |
|
| 356 | + protected $entity_post_to_jsonld_converter; |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 360 | + * |
|
| 361 | + * @since 3.10.0 |
|
| 362 | + * @access protected |
|
| 363 | + * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance. |
|
| 364 | + */ |
|
| 365 | + protected $postid_to_jsonld_converter; |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 369 | + * |
|
| 370 | + * @since 3.11.0 |
|
| 371 | + * @access protected |
|
| 372 | + * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance. |
|
| 373 | + */ |
|
| 374 | + protected $category_taxonomy_service; |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * The {@link Wordlift_Entity_Page_Service} instance. |
|
| 378 | + * |
|
| 379 | + * @since 3.11.0 |
|
| 380 | + * @access protected |
|
| 381 | + * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance. |
|
| 382 | + */ |
|
| 383 | + protected $entity_page_service; |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 387 | + * |
|
| 388 | + * @since 3.11.0 |
|
| 389 | + * @access protected |
|
| 390 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 391 | + */ |
|
| 392 | + protected $settings_page_action_link; |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 396 | + * |
|
| 397 | + * @since 3.11.0 |
|
| 398 | + * @access protected |
|
| 399 | + * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class. |
|
| 400 | + */ |
|
| 401 | + protected $analytics_settings_page_action_link; |
|
| 402 | + |
|
| 403 | + /** |
|
| 404 | + * The {@link Wordlift_Analytics_Connect} class. |
|
| 405 | + * |
|
| 406 | + * @since 3.11.0 |
|
| 407 | + * @access protected |
|
| 408 | + * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class. |
|
| 409 | + */ |
|
| 410 | + protected $analytics_connect; |
|
| 411 | + |
|
| 412 | + /** |
|
| 413 | + * The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 414 | + * |
|
| 415 | + * @since 3.11.0 |
|
| 416 | + * @access protected |
|
| 417 | + * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance. |
|
| 418 | + */ |
|
| 419 | + protected $publisher_ajax_adapter; |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 423 | + * |
|
| 424 | + * @since 3.11.0 |
|
| 425 | + * @access protected |
|
| 426 | + * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 427 | + */ |
|
| 428 | + protected $input_element; |
|
| 429 | + |
|
| 430 | + /** |
|
| 431 | + * The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 432 | + * |
|
| 433 | + * @since 3.13.0 |
|
| 434 | + * @access protected |
|
| 435 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 436 | + */ |
|
| 437 | + protected $radio_input_element; |
|
| 438 | + |
|
| 439 | + /** |
|
| 440 | + * The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 441 | + * |
|
| 442 | + * @since 3.11.0 |
|
| 443 | + * @access protected |
|
| 444 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 445 | + */ |
|
| 446 | + protected $language_select_element; |
|
| 447 | + |
|
| 448 | + /** |
|
| 449 | + * The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 450 | + * |
|
| 451 | + * @since 3.18.0 |
|
| 452 | + * @access protected |
|
| 453 | + * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 454 | + */ |
|
| 455 | + protected $country_select_element; |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 459 | + * |
|
| 460 | + * @since 3.11.0 |
|
| 461 | + * @access protected |
|
| 462 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 463 | + */ |
|
| 464 | + protected $publisher_element; |
|
| 465 | + |
|
| 466 | + /** |
|
| 467 | + * The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 468 | + * |
|
| 469 | + * @since 3.11.0 |
|
| 470 | + * @access protected |
|
| 471 | + * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer. |
|
| 472 | + */ |
|
| 473 | + protected $select2_element; |
|
| 474 | + |
|
| 475 | + /** |
|
| 476 | + * The controller for the entity type list admin page |
|
| 477 | + * |
|
| 478 | + * @since 3.11.0 |
|
| 479 | + * @access private |
|
| 480 | + * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class. |
|
| 481 | + */ |
|
| 482 | + private $entity_type_admin_page; |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * The controller for the entity type settings admin page |
|
| 486 | + * |
|
| 487 | + * @since 3.11.0 |
|
| 488 | + * @access private |
|
| 489 | + * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class. |
|
| 490 | + */ |
|
| 491 | + private $entity_type_settings_admin_page; |
|
| 492 | + |
|
| 493 | + /** |
|
| 494 | + * The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 495 | + * |
|
| 496 | + * @since 3.11.0 |
|
| 497 | + * @access protected |
|
| 498 | + * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
| 499 | + */ |
|
| 500 | + protected $related_entities_cloud_widget; |
|
| 501 | + |
|
| 502 | + /** |
|
| 503 | + * The {@link Wordlift_Admin_Author_Element} instance. |
|
| 504 | + * |
|
| 505 | + * @since 3.14.0 |
|
| 506 | + * @access protected |
|
| 507 | + * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance. |
|
| 508 | + */ |
|
| 509 | + protected $author_element; |
|
| 510 | + |
|
| 511 | + /** |
|
| 512 | + * The {@link Wordlift_Sample_Data_Service} instance. |
|
| 513 | + * |
|
| 514 | + * @since 3.12.0 |
|
| 515 | + * @access protected |
|
| 516 | + * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance. |
|
| 517 | + */ |
|
| 518 | + protected $sample_data_service; |
|
| 519 | + |
|
| 520 | + /** |
|
| 521 | + * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 522 | + * |
|
| 523 | + * @since 3.12.0 |
|
| 524 | + * @access protected |
|
| 525 | + * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance. |
|
| 526 | + */ |
|
| 527 | + protected $sample_data_ajax_adapter; |
|
| 528 | + |
|
| 529 | + /** |
|
| 530 | + * The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 531 | + * |
|
| 532 | + * @since 3.16.0 |
|
| 533 | + * @access protected |
|
| 534 | + * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance. |
|
| 535 | + */ |
|
| 536 | + protected $google_analytics_export_service; |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * {@link Wordlift}'s singleton instance. |
|
| 540 | + * |
|
| 541 | + * @since 3.15.0 |
|
| 542 | + * @access protected |
|
| 543 | + * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance. |
|
| 544 | + */ |
|
| 545 | + protected $entity_type_adapter; |
|
| 546 | + |
|
| 547 | + /** |
|
| 548 | + * The {@link Wordlift_Storage_Factory} instance. |
|
| 549 | + * |
|
| 550 | + * @since 3.15.0 |
|
| 551 | + * @access protected |
|
| 552 | + * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance. |
|
| 553 | + */ |
|
| 554 | + protected $storage_factory; |
|
| 555 | + |
|
| 556 | + /** |
|
| 557 | + * The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 558 | + * |
|
| 559 | + * @since 3.15.0 |
|
| 560 | + * @access private |
|
| 561 | + * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance. |
|
| 562 | + */ |
|
| 563 | + private $autocomplete_adapter; |
|
| 564 | + |
|
| 565 | + /** |
|
| 566 | + * The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 567 | + * |
|
| 568 | + * @since 3.16.0 |
|
| 569 | + * @access protected |
|
| 570 | + * @var \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance. |
|
| 571 | + * |
|
| 572 | + */ |
|
| 573 | + protected $cached_postid_to_jsonld_converter; |
|
| 574 | + |
|
| 575 | + /** |
|
| 576 | + * The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 577 | + * |
|
| 578 | + * @since 3.16.3 |
|
| 579 | + * @access protected |
|
| 580 | + * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance. |
|
| 581 | + */ |
|
| 582 | + protected $entity_uri_service; |
|
| 583 | + |
|
| 584 | + /** |
|
| 585 | + * The {@link Wordlift_Publisher_Service} instance. |
|
| 586 | + * |
|
| 587 | + * @since 3.19.0 |
|
| 588 | + * @access protected |
|
| 589 | + * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 590 | + */ |
|
| 591 | + protected $publisher_service; |
|
| 592 | + |
|
| 593 | + /** |
|
| 594 | + * The {@link Wordlift_Context_Cards_Service} instance. |
|
| 595 | + * |
|
| 596 | + * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance. |
|
| 597 | + */ |
|
| 598 | + protected $context_cards_service; |
|
| 599 | + |
|
| 600 | + /** |
|
| 601 | + * {@link Wordlift}'s singleton instance. |
|
| 602 | + * |
|
| 603 | + * @since 3.11.2 |
|
| 604 | + * @access private |
|
| 605 | + * @var Wordlift $instance {@link Wordlift}'s singleton instance. |
|
| 606 | + */ |
|
| 607 | + private static $instance; |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * A singleton instance of features registry. |
|
| 611 | + * @since 3.30.0 |
|
| 612 | + * @var Features_Registry |
|
| 613 | + */ |
|
| 614 | + private $features_registry; |
|
| 615 | + |
|
| 616 | + private $analytics_settings_page; |
|
| 617 | + //</editor-fold> |
|
| 618 | + |
|
| 619 | + // Experimental code added by Nishit for feature request 1496 |
|
| 620 | + private $webhook_loader; |
|
| 621 | + // Experimental code ents here |
|
| 622 | + |
|
| 623 | + /** |
|
| 624 | + * Define the core functionality of the plugin. |
|
| 625 | + * |
|
| 626 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 627 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 628 | + * the public-facing side of the site. |
|
| 629 | + * |
|
| 630 | + * @since 1.0.0 |
|
| 631 | + */ |
|
| 632 | + public function __construct() { |
|
| 633 | + |
|
| 634 | + self::$instance = $this; |
|
| 635 | + |
|
| 636 | + $this->plugin_name = 'wordlift'; |
|
| 637 | + $this->version = '3.34.0'; |
|
| 638 | + $this->load_dependencies(); |
|
| 639 | + $this->set_locale(); |
|
| 640 | + |
|
| 641 | + $that = $this; |
|
| 642 | + add_action( 'plugins_loaded', function () use ( $that ) { |
|
| 643 | + $that->define_admin_hooks( $that ); |
|
| 644 | + $that->define_public_hooks( $that ); |
|
| 645 | + }, 4 ); |
|
| 646 | + |
|
| 647 | + // If we're in `WP_CLI` load the related files. |
|
| 648 | + if ( class_exists( 'WP_CLI' ) ) { |
|
| 649 | + $this->load_cli_dependencies(); |
|
| 650 | + } |
|
| 651 | + |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + /** |
|
| 655 | + * Get the singleton instance. |
|
| 656 | + * |
|
| 657 | + * @return Wordlift The {@link Wordlift} singleton instance. |
|
| 658 | + * @since 3.11.2 |
|
| 659 | + * |
|
| 660 | + */ |
|
| 661 | + public static function get_instance() { |
|
| 662 | + |
|
| 663 | + return self::$instance; |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + /** |
|
| 667 | + * Load the required dependencies for this plugin. |
|
| 668 | + * |
|
| 669 | + * Include the following files that make up the plugin: |
|
| 670 | + * |
|
| 671 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 672 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 673 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 674 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 675 | + * |
|
| 676 | + * Create an instance of the loader which will be used to register the hooks |
|
| 677 | + * with WordPress. |
|
| 678 | + * |
|
| 679 | + * @throws Exception |
|
| 680 | + * @since 1.0.0 |
|
| 681 | + * @access private |
|
| 682 | + */ |
|
| 683 | + private function load_dependencies() { |
|
| 684 | + |
|
| 685 | + /** |
|
| 686 | + * The class responsible for orchestrating the actions and filters of the |
|
| 687 | + * core plugin. |
|
| 688 | + */ |
|
| 689 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 690 | + |
|
| 691 | + // The class responsible for plugin uninstall. |
|
| 692 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
| 693 | + |
|
| 694 | + /** |
|
| 695 | + * The class responsible for defining internationalization functionality |
|
| 696 | + * of the plugin. |
|
| 697 | + */ |
|
| 698 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 699 | + |
|
| 700 | + /** |
|
| 701 | + * WordLift's supported languages. |
|
| 702 | + */ |
|
| 703 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php'; |
|
| 704 | + |
|
| 705 | + /** |
|
| 706 | + * WordLift's supported countries. |
|
| 707 | + */ |
|
| 708 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php'; |
|
| 709 | + |
|
| 710 | + /** |
|
| 711 | + * Provide support functions to sanitize data. |
|
| 712 | + */ |
|
| 713 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 714 | + |
|
| 715 | + /** Services. */ |
|
| 716 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 717 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php'; |
|
| 718 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 719 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 720 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 721 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 722 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 723 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php'; |
|
| 724 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php'; |
|
| 725 | + |
|
| 726 | + /** |
|
| 727 | + * The Schema service. |
|
| 728 | + */ |
|
| 729 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 730 | + |
|
| 731 | + /** |
|
| 732 | + * The schema:url property service. |
|
| 733 | + */ |
|
| 734 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 735 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 736 | + |
|
| 737 | + /** |
|
| 738 | + * The UI service. |
|
| 739 | + */ |
|
| 740 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 741 | + |
|
| 742 | + /** |
|
| 743 | + * The Entity Types Taxonomy service. |
|
| 744 | + */ |
|
| 745 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
| 746 | + |
|
| 747 | + /** |
|
| 748 | + * The Entity service. |
|
| 749 | + */ |
|
| 750 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
| 751 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 752 | + |
|
| 753 | + // Add the entity rating service. |
|
| 754 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php'; |
|
| 755 | + |
|
| 756 | + /** |
|
| 757 | + * The User service. |
|
| 758 | + */ |
|
| 759 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 760 | + |
|
| 761 | + /** |
|
| 762 | + * The Timeline service. |
|
| 763 | + */ |
|
| 764 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 765 | + |
|
| 766 | + /** |
|
| 767 | + * The Topic Taxonomy service. |
|
| 768 | + */ |
|
| 769 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 770 | + |
|
| 771 | + /** |
|
| 772 | + * The WordLift URI service. |
|
| 773 | + */ |
|
| 774 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 775 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 776 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php'; |
|
| 777 | + |
|
| 778 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 779 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php'; |
|
| 780 | + |
|
| 781 | + /** |
|
| 782 | + * Load the converters. |
|
| 783 | + */ |
|
| 784 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php'; |
|
| 785 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
| 786 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
| 787 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 788 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
| 789 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php'; |
|
| 790 | + |
|
| 791 | + /** |
|
| 792 | + * Load cache-related files. |
|
| 793 | + */ |
|
| 794 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php'; |
|
| 795 | + |
|
| 796 | + /** |
|
| 797 | + * Load the content filter. |
|
| 798 | + */ |
|
| 799 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 800 | + |
|
| 801 | + /* |
|
| 802 | 802 | * Load the excerpt helper. |
| 803 | 803 | */ |
| 804 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 805 | - |
|
| 806 | - /** |
|
| 807 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 808 | - * |
|
| 809 | - * @since 3.8.0 |
|
| 810 | - */ |
|
| 811 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 812 | - |
|
| 813 | - // The Publisher Service and the AJAX adapter. |
|
| 814 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 815 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 816 | - |
|
| 817 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 818 | - |
|
| 819 | - /** |
|
| 820 | - * Load the WordLift key validation service. |
|
| 821 | - */ |
|
| 822 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 823 | - |
|
| 824 | - // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 825 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 826 | - |
|
| 827 | - // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 828 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 829 | - |
|
| 830 | - /** Linked Data. */ |
|
| 831 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 832 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 833 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 834 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 835 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 836 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 837 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 838 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 839 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 840 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 841 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 842 | - |
|
| 843 | - /** Services. */ |
|
| 844 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 845 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 846 | - |
|
| 847 | - /** Adapters. */ |
|
| 848 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 849 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 850 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 851 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 852 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 853 | - |
|
| 854 | - /** Autocomplete. */ |
|
| 855 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 856 | - |
|
| 857 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 858 | - |
|
| 859 | - /** Analytics */ |
|
| 860 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 861 | - |
|
| 862 | - /** |
|
| 863 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 864 | - */ |
|
| 865 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 866 | - |
|
| 867 | - /** |
|
| 868 | - * The class to customize the entity list admin page. |
|
| 869 | - */ |
|
| 870 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 871 | - |
|
| 872 | - /** |
|
| 873 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 874 | - */ |
|
| 875 | - global $wp_version; |
|
| 876 | - if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 877 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 878 | - } else { |
|
| 879 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 880 | - } |
|
| 881 | - |
|
| 882 | - /** |
|
| 883 | - * The Notice service. |
|
| 884 | - */ |
|
| 885 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 886 | - |
|
| 887 | - /** |
|
| 888 | - * The PrimaShop adapter. |
|
| 889 | - */ |
|
| 890 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 891 | - |
|
| 892 | - /** |
|
| 893 | - * The WordLift Dashboard service. |
|
| 894 | - */ |
|
| 895 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 896 | - |
|
| 897 | - /** |
|
| 898 | - * The admin 'Install wizard' page. |
|
| 899 | - */ |
|
| 900 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 901 | - |
|
| 902 | - /** |
|
| 903 | - * The WordLift entity type list admin page controller. |
|
| 904 | - */ |
|
| 905 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 906 | - |
|
| 907 | - /** |
|
| 908 | - * The WordLift entity type settings admin page controller. |
|
| 909 | - */ |
|
| 910 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 911 | - |
|
| 912 | - /** |
|
| 913 | - * The admin 'Download Your Data' page. |
|
| 914 | - */ |
|
| 915 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 916 | - |
|
| 917 | - /** |
|
| 918 | - * The admin 'WordLift Settings' page. |
|
| 919 | - */ |
|
| 920 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 921 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 922 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 923 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 924 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 925 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 926 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 927 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 928 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 929 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 930 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 931 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 932 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 933 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 934 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 935 | - |
|
| 936 | - /** Admin Pages */ |
|
| 937 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 938 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 939 | - |
|
| 940 | - /** |
|
| 941 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 942 | - * side of the site. |
|
| 943 | - */ |
|
| 944 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 945 | - |
|
| 946 | - /** |
|
| 947 | - * The shortcode abstract class. |
|
| 948 | - */ |
|
| 949 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 950 | - |
|
| 951 | - /** |
|
| 952 | - * The Timeline shortcode. |
|
| 953 | - */ |
|
| 954 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 955 | - |
|
| 956 | - /** |
|
| 957 | - * The Navigator shortcode. |
|
| 958 | - */ |
|
| 959 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 960 | - |
|
| 961 | - /** |
|
| 962 | - * The Products Navigator shortcode. |
|
| 963 | - */ |
|
| 964 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 965 | - |
|
| 966 | - /** |
|
| 967 | - * The chord shortcode. |
|
| 968 | - */ |
|
| 969 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 970 | - |
|
| 971 | - /** |
|
| 972 | - * The geomap shortcode. |
|
| 973 | - */ |
|
| 974 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 975 | - |
|
| 976 | - /** |
|
| 977 | - * The entity cloud shortcode. |
|
| 978 | - */ |
|
| 979 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 980 | - |
|
| 981 | - /** |
|
| 982 | - * The entity glossary shortcode. |
|
| 983 | - */ |
|
| 984 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 985 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 986 | - |
|
| 987 | - /** |
|
| 988 | - * Faceted Search shortcode. |
|
| 989 | - */ |
|
| 990 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 991 | - |
|
| 992 | - /** |
|
| 993 | - * The ShareThis service. |
|
| 994 | - */ |
|
| 995 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 996 | - |
|
| 997 | - /** |
|
| 998 | - * The SEO service. |
|
| 999 | - */ |
|
| 1000 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1001 | - |
|
| 1002 | - /** |
|
| 1003 | - * The AMP service. |
|
| 1004 | - */ |
|
| 1005 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1006 | - |
|
| 1007 | - /** Widgets */ |
|
| 1008 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1009 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1010 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1011 | - |
|
| 1012 | - /* |
|
| 804 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
| 805 | + |
|
| 806 | + /** |
|
| 807 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 808 | + * |
|
| 809 | + * @since 3.8.0 |
|
| 810 | + */ |
|
| 811 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 812 | + |
|
| 813 | + // The Publisher Service and the AJAX adapter. |
|
| 814 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php'; |
|
| 815 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
| 816 | + |
|
| 817 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php'; |
|
| 818 | + |
|
| 819 | + /** |
|
| 820 | + * Load the WordLift key validation service. |
|
| 821 | + */ |
|
| 822 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php'; |
|
| 823 | + |
|
| 824 | + // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
|
| 825 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
| 826 | + |
|
| 827 | + // Load the `Wordlift_Entity_Page_Service` class definition. |
|
| 828 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php'; |
|
| 829 | + |
|
| 830 | + /** Linked Data. */ |
|
| 831 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
| 832 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
| 833 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
| 834 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
| 835 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
| 836 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
| 837 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
| 838 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
| 839 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
| 840 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
| 841 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
| 842 | + |
|
| 843 | + /** Services. */ |
|
| 844 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
| 845 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php'; |
|
| 846 | + |
|
| 847 | + /** Adapters. */ |
|
| 848 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
| 849 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
| 850 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
| 851 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
| 852 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
| 853 | + |
|
| 854 | + /** Autocomplete. */ |
|
| 855 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
| 856 | + |
|
| 857 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php'; |
|
| 858 | + |
|
| 859 | + /** Analytics */ |
|
| 860 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
| 861 | + |
|
| 862 | + /** |
|
| 863 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 864 | + */ |
|
| 865 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 866 | + |
|
| 867 | + /** |
|
| 868 | + * The class to customize the entity list admin page. |
|
| 869 | + */ |
|
| 870 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 871 | + |
|
| 872 | + /** |
|
| 873 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 874 | + */ |
|
| 875 | + global $wp_version; |
|
| 876 | + if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
| 877 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 878 | + } else { |
|
| 879 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
| 880 | + } |
|
| 881 | + |
|
| 882 | + /** |
|
| 883 | + * The Notice service. |
|
| 884 | + */ |
|
| 885 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 886 | + |
|
| 887 | + /** |
|
| 888 | + * The PrimaShop adapter. |
|
| 889 | + */ |
|
| 890 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 891 | + |
|
| 892 | + /** |
|
| 893 | + * The WordLift Dashboard service. |
|
| 894 | + */ |
|
| 895 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 896 | + |
|
| 897 | + /** |
|
| 898 | + * The admin 'Install wizard' page. |
|
| 899 | + */ |
|
| 900 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php'; |
|
| 901 | + |
|
| 902 | + /** |
|
| 903 | + * The WordLift entity type list admin page controller. |
|
| 904 | + */ |
|
| 905 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
| 906 | + |
|
| 907 | + /** |
|
| 908 | + * The WordLift entity type settings admin page controller. |
|
| 909 | + */ |
|
| 910 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php'; |
|
| 911 | + |
|
| 912 | + /** |
|
| 913 | + * The admin 'Download Your Data' page. |
|
| 914 | + */ |
|
| 915 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 916 | + |
|
| 917 | + /** |
|
| 918 | + * The admin 'WordLift Settings' page. |
|
| 919 | + */ |
|
| 920 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
| 921 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
| 922 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php'; |
|
| 923 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
| 924 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
| 925 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
| 926 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
| 927 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
| 928 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
| 929 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
| 930 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php'; |
|
| 931 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
| 932 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
| 933 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
| 934 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
| 935 | + |
|
| 936 | + /** Admin Pages */ |
|
| 937 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
| 938 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
| 939 | + |
|
| 940 | + /** |
|
| 941 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 942 | + * side of the site. |
|
| 943 | + */ |
|
| 944 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 945 | + |
|
| 946 | + /** |
|
| 947 | + * The shortcode abstract class. |
|
| 948 | + */ |
|
| 949 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 950 | + |
|
| 951 | + /** |
|
| 952 | + * The Timeline shortcode. |
|
| 953 | + */ |
|
| 954 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 955 | + |
|
| 956 | + /** |
|
| 957 | + * The Navigator shortcode. |
|
| 958 | + */ |
|
| 959 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 960 | + |
|
| 961 | + /** |
|
| 962 | + * The Products Navigator shortcode. |
|
| 963 | + */ |
|
| 964 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
| 965 | + |
|
| 966 | + /** |
|
| 967 | + * The chord shortcode. |
|
| 968 | + */ |
|
| 969 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 970 | + |
|
| 971 | + /** |
|
| 972 | + * The geomap shortcode. |
|
| 973 | + */ |
|
| 974 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 975 | + |
|
| 976 | + /** |
|
| 977 | + * The entity cloud shortcode. |
|
| 978 | + */ |
|
| 979 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
| 980 | + |
|
| 981 | + /** |
|
| 982 | + * The entity glossary shortcode. |
|
| 983 | + */ |
|
| 984 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php'; |
|
| 985 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
| 986 | + |
|
| 987 | + /** |
|
| 988 | + * Faceted Search shortcode. |
|
| 989 | + */ |
|
| 990 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
| 991 | + |
|
| 992 | + /** |
|
| 993 | + * The ShareThis service. |
|
| 994 | + */ |
|
| 995 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 996 | + |
|
| 997 | + /** |
|
| 998 | + * The SEO service. |
|
| 999 | + */ |
|
| 1000 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php'; |
|
| 1001 | + |
|
| 1002 | + /** |
|
| 1003 | + * The AMP service. |
|
| 1004 | + */ |
|
| 1005 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php'; |
|
| 1006 | + |
|
| 1007 | + /** Widgets */ |
|
| 1008 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php'; |
|
| 1009 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
| 1010 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php'; |
|
| 1011 | + |
|
| 1012 | + /* |
|
| 1013 | 1013 | * Batch Operations. They're similar to Batch Actions but do not require working on post types. |
| 1014 | 1014 | * |
| 1015 | 1015 | * Eventually Batch Actions will become Batch Operations. |
| 1016 | 1016 | * |
| 1017 | 1017 | * @since 3.20.0 |
| 1018 | 1018 | */ |
| 1019 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1020 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1019 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
| 1020 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
| 1021 | 1021 | |
| 1022 | - /* |
|
| 1022 | + /* |
|
| 1023 | 1023 | * Schema.org Services. |
| 1024 | 1024 | * |
| 1025 | 1025 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1026 | 1026 | */ |
| 1027 | - if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1028 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1029 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1030 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1031 | - new Wordlift_Schemaorg_Sync_Service(); |
|
| 1032 | - $schemaorg_property_service = Wordlift_Schemaorg_Property_Service::get_instance(); |
|
| 1033 | - new Wordlift_Schemaorg_Class_Service(); |
|
| 1034 | - } else { |
|
| 1035 | - $schemaorg_property_service = null; |
|
| 1036 | - } |
|
| 1037 | - |
|
| 1038 | - $this->loader = new Wordlift_Loader(); |
|
| 1039 | - /** |
|
| 1040 | - * @since 3.30.0 |
|
| 1041 | - */ |
|
| 1042 | - $this->features_registry = Features_Registry::get_instance(); |
|
| 1043 | - |
|
| 1044 | - // Instantiate a global logger. |
|
| 1045 | - global $wl_logger; |
|
| 1046 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1047 | - |
|
| 1048 | - // Load the `wl-api` end-point. |
|
| 1049 | - new Wordlift_Http_Api(); |
|
| 1050 | - |
|
| 1051 | - // Load the Install Service. |
|
| 1052 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1053 | - $this->install_service = new Wordlift_Install_Service(); |
|
| 1054 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1055 | - $this->user_service = Wordlift_User_Service::get_instance(); |
|
| 1056 | - // create an instance of the entity type list admin page controller. |
|
| 1057 | - $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1058 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1059 | - $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1060 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1061 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( |
|
| 1062 | - Wordlift_Entity_Service::TYPE_NAME, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() ); |
|
| 1063 | - /* WordPress Admin. */ |
|
| 1064 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page(); |
|
| 1065 | - // create an instance of the entity type setting admin page controller. |
|
| 1066 | - $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1067 | - |
|
| 1068 | - |
|
| 1069 | - $that = $this; |
|
| 1070 | - add_action( 'plugins_loaded', function () use ( &$that, $schemaorg_property_service ) { |
|
| 1071 | - |
|
| 1072 | - /** Services. */ |
|
| 1073 | - // Create the configuration service. |
|
| 1074 | - $api_service = new Wordlift_Api_Service(); |
|
| 1075 | - |
|
| 1076 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1077 | - $that->entity_link_service = new Wordlift_Entity_Link_Service( $that->entity_post_type_service, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() ); |
|
| 1078 | - |
|
| 1079 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service(); |
|
| 1080 | - |
|
| 1081 | - $that->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance(); |
|
| 1082 | - |
|
| 1083 | - // Create a new instance of the Redirect service. |
|
| 1084 | - $that->redirect_service = new Wordlift_Redirect_Service( $that->entity_uri_service ); |
|
| 1085 | - |
|
| 1086 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1087 | - $that->timeline_service = new Wordlift_Timeline_Service(); |
|
| 1088 | - |
|
| 1089 | - $that->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1090 | - |
|
| 1091 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1092 | - $that->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1093 | - |
|
| 1094 | - // Create an instance of the PrimaShop adapter. |
|
| 1095 | - $that->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1096 | - |
|
| 1097 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1098 | - |
|
| 1099 | - // Create the entity rating service. |
|
| 1100 | - $that->rating_service = new Wordlift_Rating_Service( Wordlift_Entity_Type_Service::get_instance(), $that->notice_service ); |
|
| 1101 | - |
|
| 1102 | - // Create entity list customization (wp-admin/edit.php). |
|
| 1103 | - $that->entity_list_service = new Wordlift_Entity_List_Service( $that->rating_service ); |
|
| 1104 | - |
|
| 1105 | - // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1106 | - $that->publisher_service = Wordlift_Publisher_Service::get_instance(); |
|
| 1107 | - $that->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1108 | - $that->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1109 | - |
|
| 1110 | - $attachment_service = Wordlift_Attachment_Service::get_instance(); |
|
| 1111 | - |
|
| 1112 | - // Instantiate the JSON-LD service. |
|
| 1113 | - $property_getter = Wordlift_Property_Getter_Factory::create(); |
|
| 1114 | - $that->post_to_jsonld_converter = new Wordlift_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service ); |
|
| 1115 | - $that->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $that->post_to_jsonld_converter ); |
|
| 1116 | - $that->postid_to_jsonld_converter = new Wordlift_Postid_To_Jsonld_Converter( $that->entity_post_to_jsonld_converter, $that->post_to_jsonld_converter ); |
|
| 1117 | - $that->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service ); |
|
| 1118 | - |
|
| 1119 | - $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1120 | - $that->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $that->postid_to_jsonld_converter, $jsonld_cache ); |
|
| 1121 | - /* |
|
| 1027 | + if ( WL_ALL_ENTITY_TYPES ) { |
|
| 1028 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
| 1029 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
| 1030 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
| 1031 | + new Wordlift_Schemaorg_Sync_Service(); |
|
| 1032 | + $schemaorg_property_service = Wordlift_Schemaorg_Property_Service::get_instance(); |
|
| 1033 | + new Wordlift_Schemaorg_Class_Service(); |
|
| 1034 | + } else { |
|
| 1035 | + $schemaorg_property_service = null; |
|
| 1036 | + } |
|
| 1037 | + |
|
| 1038 | + $this->loader = new Wordlift_Loader(); |
|
| 1039 | + /** |
|
| 1040 | + * @since 3.30.0 |
|
| 1041 | + */ |
|
| 1042 | + $this->features_registry = Features_Registry::get_instance(); |
|
| 1043 | + |
|
| 1044 | + // Instantiate a global logger. |
|
| 1045 | + global $wl_logger; |
|
| 1046 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 1047 | + |
|
| 1048 | + // Load the `wl-api` end-point. |
|
| 1049 | + new Wordlift_Http_Api(); |
|
| 1050 | + |
|
| 1051 | + // Load the Install Service. |
|
| 1052 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php'; |
|
| 1053 | + $this->install_service = new Wordlift_Install_Service(); |
|
| 1054 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 1055 | + $this->user_service = Wordlift_User_Service::get_instance(); |
|
| 1056 | + // create an instance of the entity type list admin page controller. |
|
| 1057 | + $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page(); |
|
| 1058 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 1059 | + $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service(); |
|
| 1060 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 1061 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( |
|
| 1062 | + Wordlift_Entity_Service::TYPE_NAME, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() ); |
|
| 1063 | + /* WordPress Admin. */ |
|
| 1064 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page(); |
|
| 1065 | + // create an instance of the entity type setting admin page controller. |
|
| 1066 | + $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings(); |
|
| 1067 | + |
|
| 1068 | + |
|
| 1069 | + $that = $this; |
|
| 1070 | + add_action( 'plugins_loaded', function () use ( &$that, $schemaorg_property_service ) { |
|
| 1071 | + |
|
| 1072 | + /** Services. */ |
|
| 1073 | + // Create the configuration service. |
|
| 1074 | + $api_service = new Wordlift_Api_Service(); |
|
| 1075 | + |
|
| 1076 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 1077 | + $that->entity_link_service = new Wordlift_Entity_Link_Service( $that->entity_post_type_service, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() ); |
|
| 1078 | + |
|
| 1079 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service(); |
|
| 1080 | + |
|
| 1081 | + $that->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance(); |
|
| 1082 | + |
|
| 1083 | + // Create a new instance of the Redirect service. |
|
| 1084 | + $that->redirect_service = new Wordlift_Redirect_Service( $that->entity_uri_service ); |
|
| 1085 | + |
|
| 1086 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 1087 | + $that->timeline_service = new Wordlift_Timeline_Service(); |
|
| 1088 | + |
|
| 1089 | + $that->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 1090 | + |
|
| 1091 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 1092 | + $that->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 1093 | + |
|
| 1094 | + // Create an instance of the PrimaShop adapter. |
|
| 1095 | + $that->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 1096 | + |
|
| 1097 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 1098 | + |
|
| 1099 | + // Create the entity rating service. |
|
| 1100 | + $that->rating_service = new Wordlift_Rating_Service( Wordlift_Entity_Type_Service::get_instance(), $that->notice_service ); |
|
| 1101 | + |
|
| 1102 | + // Create entity list customization (wp-admin/edit.php). |
|
| 1103 | + $that->entity_list_service = new Wordlift_Entity_List_Service( $that->rating_service ); |
|
| 1104 | + |
|
| 1105 | + // Create an instance of the Publisher Service and the AJAX Adapter. |
|
| 1106 | + $that->publisher_service = Wordlift_Publisher_Service::get_instance(); |
|
| 1107 | + $that->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 1108 | + $that->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 1109 | + |
|
| 1110 | + $attachment_service = Wordlift_Attachment_Service::get_instance(); |
|
| 1111 | + |
|
| 1112 | + // Instantiate the JSON-LD service. |
|
| 1113 | + $property_getter = Wordlift_Property_Getter_Factory::create(); |
|
| 1114 | + $that->post_to_jsonld_converter = new Wordlift_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service ); |
|
| 1115 | + $that->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $that->post_to_jsonld_converter ); |
|
| 1116 | + $that->postid_to_jsonld_converter = new Wordlift_Postid_To_Jsonld_Converter( $that->entity_post_to_jsonld_converter, $that->post_to_jsonld_converter ); |
|
| 1117 | + $that->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service ); |
|
| 1118 | + |
|
| 1119 | + $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
| 1120 | + $that->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $that->postid_to_jsonld_converter, $jsonld_cache ); |
|
| 1121 | + /* |
|
| 1122 | 1122 | * Load the `Wordlift_Term_JsonLd_Adapter`. |
| 1123 | 1123 | * |
| 1124 | 1124 | * @see https://github.com/insideout10/wordlift-plugin/issues/892 |
| 1125 | 1125 | * |
| 1126 | 1126 | * @since 3.20.0 |
| 1127 | 1127 | */ |
| 1128 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1129 | - |
|
| 1130 | - $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $that->entity_uri_service, $that->cached_postid_to_jsonld_converter ); |
|
| 1131 | - $that->jsonld_service = new Wordlift_Jsonld_Service( Wordlift_Entity_Service::get_instance(), $that->cached_postid_to_jsonld_converter, $that->jsonld_website_converter, $term_jsonld_adapter ); |
|
| 1132 | - |
|
| 1133 | - $jsonld_service = new Jsonld_Service( |
|
| 1134 | - $that->jsonld_service, |
|
| 1135 | - $term_jsonld_adapter, |
|
| 1136 | - new Jsonld_User_Service( $that->user_service ) ); |
|
| 1137 | - new Jsonld_Endpoint( $jsonld_service, $that->entity_uri_service ); |
|
| 1138 | - |
|
| 1139 | - // Prints the JSON-LD in the head. |
|
| 1140 | - new Jsonld_Adapter( $that->jsonld_service ); |
|
| 1141 | - |
|
| 1142 | - new Jsonld_By_Id_Endpoint( $that->jsonld_service, $that->entity_uri_service ); |
|
| 1143 | - |
|
| 1144 | - $that->key_validation_service = new Wordlift_Key_Validation_Service(); |
|
| 1145 | - $that->content_filter_service = Wordlift_Content_Filter_Service::get_instance(); |
|
| 1146 | - // Creating Faq Content filter service. |
|
| 1147 | - $that->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1148 | - $that->sample_data_service = Wordlift_Sample_Data_Service::get_instance(); |
|
| 1149 | - $that->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $that->sample_data_service ); |
|
| 1150 | - |
|
| 1151 | - $that->loader->add_action( 'enqueue_block_editor_assets', $that, 'add_wl_enabled_blocks' ); |
|
| 1152 | - $that->loader->add_action( 'admin_enqueue_scripts', $that, 'add_wl_enabled_blocks' ); |
|
| 1153 | - |
|
| 1154 | - /** |
|
| 1155 | - * Filter: wl_feature__enable__blocks. |
|
| 1156 | - * |
|
| 1157 | - * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1158 | - * |
|
| 1159 | - * @return bool |
|
| 1160 | - * @since 3.27.6 |
|
| 1161 | - */ |
|
| 1162 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1163 | - // Initialize the short-codes. |
|
| 1164 | - new Async_Template_Decorator( new Wordlift_Navigator_Shortcode() ); |
|
| 1165 | - new Wordlift_Chord_Shortcode(); |
|
| 1166 | - new Wordlift_Geomap_Shortcode(); |
|
| 1167 | - new Wordlift_Timeline_Shortcode(); |
|
| 1168 | - new Wordlift_Related_Entities_Cloud_Shortcode( Wordlift_Relation_Service::get_instance(), Wordlift_Entity_Service::get_instance() ); |
|
| 1169 | - new Wordlift_Vocabulary_Shortcode(); |
|
| 1170 | - new Async_Template_Decorator( new Wordlift_Faceted_Search_Shortcode() ); |
|
| 1171 | - } |
|
| 1172 | - |
|
| 1173 | - new Wordlift_Products_Navigator_Shortcode(); |
|
| 1174 | - |
|
| 1175 | - |
|
| 1176 | - // Initialize the Context Cards Service |
|
| 1177 | - $that->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1178 | - |
|
| 1179 | - // Initialize the SEO service. |
|
| 1180 | - new Wordlift_Seo_Service(); |
|
| 1181 | - |
|
| 1182 | - // Initialize the AMP service. |
|
| 1183 | - new Wordlift_AMP_Service( $that->jsonld_service ); |
|
| 1184 | - |
|
| 1185 | - /** Services. */ |
|
| 1186 | - $that->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1187 | - new Wordlift_Image_Service(); |
|
| 1188 | - |
|
| 1189 | - /** Adapters. */ |
|
| 1190 | - $that->entity_type_adapter = new Wordlift_Entity_Type_Adapter( Wordlift_Entity_Type_Service::get_instance() ); |
|
| 1191 | - $that->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $that->publisher_service ); |
|
| 1192 | - $that->tinymce_adapter = new Wordlift_Tinymce_Adapter( $that ); |
|
| 1193 | - |
|
| 1194 | - /* |
|
| 1128 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
| 1129 | + |
|
| 1130 | + $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $that->entity_uri_service, $that->cached_postid_to_jsonld_converter ); |
|
| 1131 | + $that->jsonld_service = new Wordlift_Jsonld_Service( Wordlift_Entity_Service::get_instance(), $that->cached_postid_to_jsonld_converter, $that->jsonld_website_converter, $term_jsonld_adapter ); |
|
| 1132 | + |
|
| 1133 | + $jsonld_service = new Jsonld_Service( |
|
| 1134 | + $that->jsonld_service, |
|
| 1135 | + $term_jsonld_adapter, |
|
| 1136 | + new Jsonld_User_Service( $that->user_service ) ); |
|
| 1137 | + new Jsonld_Endpoint( $jsonld_service, $that->entity_uri_service ); |
|
| 1138 | + |
|
| 1139 | + // Prints the JSON-LD in the head. |
|
| 1140 | + new Jsonld_Adapter( $that->jsonld_service ); |
|
| 1141 | + |
|
| 1142 | + new Jsonld_By_Id_Endpoint( $that->jsonld_service, $that->entity_uri_service ); |
|
| 1143 | + |
|
| 1144 | + $that->key_validation_service = new Wordlift_Key_Validation_Service(); |
|
| 1145 | + $that->content_filter_service = Wordlift_Content_Filter_Service::get_instance(); |
|
| 1146 | + // Creating Faq Content filter service. |
|
| 1147 | + $that->faq_content_filter_service = new Faq_Content_Filter(); |
|
| 1148 | + $that->sample_data_service = Wordlift_Sample_Data_Service::get_instance(); |
|
| 1149 | + $that->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $that->sample_data_service ); |
|
| 1150 | + |
|
| 1151 | + $that->loader->add_action( 'enqueue_block_editor_assets', $that, 'add_wl_enabled_blocks' ); |
|
| 1152 | + $that->loader->add_action( 'admin_enqueue_scripts', $that, 'add_wl_enabled_blocks' ); |
|
| 1153 | + |
|
| 1154 | + /** |
|
| 1155 | + * Filter: wl_feature__enable__blocks. |
|
| 1156 | + * |
|
| 1157 | + * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1158 | + * |
|
| 1159 | + * @return bool |
|
| 1160 | + * @since 3.27.6 |
|
| 1161 | + */ |
|
| 1162 | + if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1163 | + // Initialize the short-codes. |
|
| 1164 | + new Async_Template_Decorator( new Wordlift_Navigator_Shortcode() ); |
|
| 1165 | + new Wordlift_Chord_Shortcode(); |
|
| 1166 | + new Wordlift_Geomap_Shortcode(); |
|
| 1167 | + new Wordlift_Timeline_Shortcode(); |
|
| 1168 | + new Wordlift_Related_Entities_Cloud_Shortcode( Wordlift_Relation_Service::get_instance(), Wordlift_Entity_Service::get_instance() ); |
|
| 1169 | + new Wordlift_Vocabulary_Shortcode(); |
|
| 1170 | + new Async_Template_Decorator( new Wordlift_Faceted_Search_Shortcode() ); |
|
| 1171 | + } |
|
| 1172 | + |
|
| 1173 | + new Wordlift_Products_Navigator_Shortcode(); |
|
| 1174 | + |
|
| 1175 | + |
|
| 1176 | + // Initialize the Context Cards Service |
|
| 1177 | + $that->context_cards_service = new Wordlift_Context_Cards_Service(); |
|
| 1178 | + |
|
| 1179 | + // Initialize the SEO service. |
|
| 1180 | + new Wordlift_Seo_Service(); |
|
| 1181 | + |
|
| 1182 | + // Initialize the AMP service. |
|
| 1183 | + new Wordlift_AMP_Service( $that->jsonld_service ); |
|
| 1184 | + |
|
| 1185 | + /** Services. */ |
|
| 1186 | + $that->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
|
| 1187 | + new Wordlift_Image_Service(); |
|
| 1188 | + |
|
| 1189 | + /** Adapters. */ |
|
| 1190 | + $that->entity_type_adapter = new Wordlift_Entity_Type_Adapter( Wordlift_Entity_Type_Service::get_instance() ); |
|
| 1191 | + $that->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $that->publisher_service ); |
|
| 1192 | + $that->tinymce_adapter = new Wordlift_Tinymce_Adapter( $that ); |
|
| 1193 | + |
|
| 1194 | + /* |
|
| 1195 | 1195 | * Exclude our public js from WP-Rocket. |
| 1196 | 1196 | * |
| 1197 | 1197 | * @since 3.19.4 |
| 1198 | 1198 | * |
| 1199 | 1199 | * @see https://github.com/insideout10/wordlift-plugin/issues/842. |
| 1200 | 1200 | */ |
| 1201 | - new Wordlift_WpRocket_Adapter(); |
|
| 1201 | + new Wordlift_WpRocket_Adapter(); |
|
| 1202 | 1202 | |
| 1203 | - /** WordPress Admin UI. */ |
|
| 1203 | + /** WordPress Admin UI. */ |
|
| 1204 | 1204 | |
| 1205 | - // UI elements. |
|
| 1206 | - $that->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1207 | - $that->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1208 | - $that->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1209 | - $that->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1210 | - $that->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1211 | - $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1212 | - $that->publisher_element = new Wordlift_Admin_Publisher_Element( $that->publisher_service, $tabs_element, $that->select2_element ); |
|
| 1213 | - $that->author_element = new Wordlift_Admin_Author_Element( $that->publisher_service, $that->select2_element ); |
|
| 1205 | + // UI elements. |
|
| 1206 | + $that->input_element = new Wordlift_Admin_Input_Element(); |
|
| 1207 | + $that->radio_input_element = new Wordlift_Admin_Radio_Input_Element(); |
|
| 1208 | + $that->select2_element = new Wordlift_Admin_Select2_Element(); |
|
| 1209 | + $that->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
|
| 1210 | + $that->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
|
| 1211 | + $tabs_element = new Wordlift_Admin_Tabs_Element(); |
|
| 1212 | + $that->publisher_element = new Wordlift_Admin_Publisher_Element( $that->publisher_service, $tabs_element, $that->select2_element ); |
|
| 1213 | + $that->author_element = new Wordlift_Admin_Author_Element( $that->publisher_service, $that->select2_element ); |
|
| 1214 | 1214 | |
| 1215 | - $that->settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
|
| 1216 | - $that->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $that->settings_page ); |
|
| 1215 | + $that->settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
|
| 1216 | + $that->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $that->settings_page ); |
|
| 1217 | 1217 | |
| 1218 | - $that->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $that->input_element, $that->radio_input_element ); |
|
| 1219 | - $that->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $that->analytics_settings_page ); |
|
| 1220 | - $that->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1218 | + $that->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $that->input_element, $that->radio_input_element ); |
|
| 1219 | + $that->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $that->analytics_settings_page ); |
|
| 1220 | + $that->analytics_connect = new Wordlift_Analytics_Connect(); |
|
| 1221 | 1221 | |
| 1222 | - // Pages. |
|
| 1223 | - /* |
|
| 1222 | + // Pages. |
|
| 1223 | + /* |
|
| 1224 | 1224 | * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box. |
| 1225 | 1225 | * |
| 1226 | 1226 | * @since 3.20.3 |
| 1227 | 1227 | * |
| 1228 | 1228 | * @see https://github.com/insideout10/wordlift-plugin/issues/914 |
| 1229 | 1229 | */ |
| 1230 | - if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1231 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1232 | - new Wordlift_Admin_Post_Edit_Page( $that ); |
|
| 1233 | - } |
|
| 1234 | - new Wordlift_Entity_Type_Admin_Service(); |
|
| 1230 | + if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
| 1231 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
| 1232 | + new Wordlift_Admin_Post_Edit_Page( $that ); |
|
| 1233 | + } |
|
| 1234 | + new Wordlift_Entity_Type_Admin_Service(); |
|
| 1235 | 1235 | |
| 1236 | - /** Widgets */ |
|
| 1237 | - $that->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1236 | + /** Widgets */ |
|
| 1237 | + $that->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
|
| 1238 | 1238 | |
| 1239 | - // Create an instance of the install wizard. |
|
| 1240 | - $that->admin_setup = new Wordlift_Admin_Setup( $that->key_validation_service, Wordlift_Entity_Service::get_instance(), $that->language_select_element, $that->country_select_element ); |
|
| 1239 | + // Create an instance of the install wizard. |
|
| 1240 | + $that->admin_setup = new Wordlift_Admin_Setup( $that->key_validation_service, Wordlift_Entity_Service::get_instance(), $that->language_select_element, $that->country_select_element ); |
|
| 1241 | 1241 | |
| 1242 | - $that->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $that->entity_post_type_service ); |
|
| 1242 | + $that->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $that->entity_post_type_service ); |
|
| 1243 | 1243 | |
| 1244 | - // User Profile. |
|
| 1245 | - new Wordlift_Admin_User_Profile_Page( $that->author_element, $that->user_service ); |
|
| 1244 | + // User Profile. |
|
| 1245 | + new Wordlift_Admin_User_Profile_Page( $that->author_element, $that->user_service ); |
|
| 1246 | 1246 | |
| 1247 | - $that->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1247 | + $that->entity_page_service = new Wordlift_Entity_Page_Service(); |
|
| 1248 | 1248 | |
| 1249 | - // Load the debug service if WP is in debug mode. |
|
| 1250 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1251 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1252 | - new Wordlift_Debug_Service( Wordlift_Entity_Service::get_instance(), $uri_service ); |
|
| 1253 | - } |
|
| 1249 | + // Load the debug service if WP is in debug mode. |
|
| 1250 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 1251 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php'; |
|
| 1252 | + new Wordlift_Debug_Service( Wordlift_Entity_Service::get_instance(), $uri_service ); |
|
| 1253 | + } |
|
| 1254 | 1254 | |
| 1255 | - // Remote Image Service. |
|
| 1256 | - new Wordlift_Remote_Image_Service(); |
|
| 1255 | + // Remote Image Service. |
|
| 1256 | + new Wordlift_Remote_Image_Service(); |
|
| 1257 | 1257 | |
| 1258 | - /* |
|
| 1258 | + /* |
|
| 1259 | 1259 | * Provides mappings between post types and entity types. |
| 1260 | 1260 | * |
| 1261 | 1261 | * @since 3.20.0 |
| 1262 | 1262 | * |
| 1263 | 1263 | * @see https://github.com/insideout10/wordlift-plugin/issues/852. |
| 1264 | 1264 | */ |
| 1265 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1266 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1267 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1265 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php'; |
|
| 1266 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
| 1267 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
| 1268 | 1268 | |
| 1269 | - // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1270 | - new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1269 | + // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
|
| 1270 | + new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
| 1271 | 1271 | |
| 1272 | - /* |
|
| 1272 | + /* |
|
| 1273 | 1273 | * Load the Mappings JSON-LD post processing. |
| 1274 | 1274 | * |
| 1275 | 1275 | * @since 3.25.0 |
| 1276 | 1276 | */ |
| 1277 | 1277 | |
| 1278 | - $mappings_dbo = new Mappings_DBO(); |
|
| 1279 | - $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1280 | - new Post_Type_Rule_Validator(); |
|
| 1281 | - // Taxonomy term rule validator for validating rules for term pages. |
|
| 1282 | - new Taxonomy_Term_Rule_Validator(); |
|
| 1283 | - new Post_Taxonomy_Term_Rule_Validator(); |
|
| 1284 | - $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1285 | - $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1286 | - $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1287 | - |
|
| 1288 | - new Url_To_Entity_Transform_Function( $that->entity_uri_service ); |
|
| 1289 | - new Taxonomy_To_Terms_Transform_Function(); |
|
| 1290 | - new Post_Id_To_Entity_Transform_Function(); |
|
| 1291 | - $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1292 | - |
|
| 1293 | - /** |
|
| 1294 | - * @since 3.27.1 |
|
| 1295 | - * Intiailize the acf group data formatter. |
|
| 1296 | - */ |
|
| 1297 | - new Acf_Group_Formatter(); |
|
| 1298 | - new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1299 | - |
|
| 1300 | - /** |
|
| 1301 | - * @since 3.26.0 |
|
| 1302 | - * Initialize the Faq JSON LD converter here - disabled. |
|
| 1303 | - */ |
|
| 1304 | - // new Faq_To_Jsonld_Converter(); |
|
| 1305 | - /* |
|
| 1278 | + $mappings_dbo = new Mappings_DBO(); |
|
| 1279 | + $default_rule_validator = new Taxonomy_Rule_Validator(); |
|
| 1280 | + new Post_Type_Rule_Validator(); |
|
| 1281 | + // Taxonomy term rule validator for validating rules for term pages. |
|
| 1282 | + new Taxonomy_Term_Rule_Validator(); |
|
| 1283 | + new Post_Taxonomy_Term_Rule_Validator(); |
|
| 1284 | + $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
| 1285 | + $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
| 1286 | + $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
| 1287 | + |
|
| 1288 | + new Url_To_Entity_Transform_Function( $that->entity_uri_service ); |
|
| 1289 | + new Taxonomy_To_Terms_Transform_Function(); |
|
| 1290 | + new Post_Id_To_Entity_Transform_Function(); |
|
| 1291 | + $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
|
| 1292 | + |
|
| 1293 | + /** |
|
| 1294 | + * @since 3.27.1 |
|
| 1295 | + * Intiailize the acf group data formatter. |
|
| 1296 | + */ |
|
| 1297 | + new Acf_Group_Formatter(); |
|
| 1298 | + new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
| 1299 | + |
|
| 1300 | + /** |
|
| 1301 | + * @since 3.26.0 |
|
| 1302 | + * Initialize the Faq JSON LD converter here - disabled. |
|
| 1303 | + */ |
|
| 1304 | + // new Faq_To_Jsonld_Converter(); |
|
| 1305 | + /* |
|
| 1306 | 1306 | * Use the Templates Ajax Endpoint to load HTML templates for the legacy Angular app via admin-ajax.php |
| 1307 | 1307 | * end-point. |
| 1308 | 1308 | * |
| 1309 | 1309 | * @see https://github.com/insideout10/wordlift-plugin/issues/834 |
| 1310 | 1310 | * @since 3.24.4 |
| 1311 | 1311 | */ |
| 1312 | - new Templates_Ajax_Endpoint(); |
|
| 1313 | - // Call this static method to register FAQ routes to rest api - disabled |
|
| 1314 | - //Faq_Rest_Controller::register_routes(); |
|
| 1315 | - |
|
| 1316 | - $that->storage_factory = new Wordlift_Storage_Factory( Wordlift_Entity_Service::get_instance(), $that->user_service, $property_getter ); |
|
| 1317 | - |
|
| 1318 | - /** WL Autocomplete. */ |
|
| 1319 | - $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1320 | - new Local_Autocomplete_Service(), |
|
| 1321 | - new Linked_Data_Autocomplete_Service( Entity_Helper::get_instance(), $that->entity_uri_service, Wordlift_Entity_Service::get_instance() ), |
|
| 1322 | - ) ); |
|
| 1323 | - $that->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1324 | - |
|
| 1325 | - /** |
|
| 1326 | - * @since 3.27.2 |
|
| 1327 | - * Integrate the recipe maker jsonld & set recipe |
|
| 1328 | - * as default entity type to the wprm_recipe CPT. |
|
| 1329 | - */ |
|
| 1330 | - new Recipe_Maker_Post_Type_Hook(); |
|
| 1331 | - $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1332 | - new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1333 | - new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1334 | - new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1335 | - new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1336 | - |
|
| 1337 | - /** |
|
| 1338 | - * @since 3.27.4 |
|
| 1339 | - * Add the faq duplicate markup hook. |
|
| 1340 | - */ |
|
| 1341 | - new Faq_Duplicate_Markup_Remover(); |
|
| 1342 | - /** |
|
| 1343 | - * @since 3.33.1 |
|
| 1344 | - * Remove the duplicate HowTo Markup. |
|
| 1345 | - */ |
|
| 1346 | - new How_To_Duplicate_Markup_Remover(); |
|
| 1347 | - |
|
| 1348 | - /** |
|
| 1349 | - * @since 3.27.8 |
|
| 1350 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1248 |
|
| 1351 | - */ |
|
| 1352 | - new Key_Validation_Notice( $that->key_validation_service, Wordlift_Configuration_Service::get_instance() ); |
|
| 1353 | - /** |
|
| 1354 | - * @since 3.28.0 |
|
| 1355 | - * @see https://github.com/insideout10/wordlift-plugin/issues?q=assignee%3Anaveen17797+is%3Aopen |
|
| 1356 | - */ |
|
| 1357 | - new Entity_No_Index_Flag(); |
|
| 1358 | - |
|
| 1359 | - /** |
|
| 1360 | - * @since 3.29.0 |
|
| 1361 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1304 |
|
| 1362 | - */ |
|
| 1363 | - new Entity_Rest_Service( Wordlift_Entity_Type_Service::get_instance() ); |
|
| 1364 | - |
|
| 1365 | - /** |
|
| 1366 | - * Expand author in to references. |
|
| 1367 | - * @since 3.30.0 |
|
| 1368 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1318 |
|
| 1369 | - */ |
|
| 1370 | - |
|
| 1371 | - |
|
| 1372 | - if ( apply_filters( 'wl_feature__enable__article-wrapper', false ) ) { |
|
| 1373 | - new Jsonld_Article_Wrapper( Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter ); |
|
| 1374 | - } |
|
| 1375 | - |
|
| 1376 | - |
|
| 1377 | - if ( apply_filters( 'wl_feature__enable__match-terms', false ) ) { |
|
| 1378 | - $vocabulary_loader = new Vocabulary_Loader(); |
|
| 1379 | - $vocabulary_loader->init_vocabulary(); |
|
| 1380 | - } |
|
| 1381 | - |
|
| 1382 | - /** |
|
| 1383 | - *Added for feature request 1496 (Webhooks) |
|
| 1384 | - */ |
|
| 1385 | - if ( apply_filters( 'wl_feature__enable__webhooks', false ) ) { |
|
| 1386 | - $that->webhook_loader = new Webhooks_Loader(); |
|
| 1387 | - $that->webhook_loader->init(); |
|
| 1388 | - } |
|
| 1389 | - |
|
| 1390 | - /** |
|
| 1391 | - * @since 3.30.0 |
|
| 1392 | - * Add a checkbox to user option screen for wordlift admin. |
|
| 1393 | - */ |
|
| 1394 | - $wordlift_admin_checkbox = new Admin_User_Option(); |
|
| 1395 | - $wordlift_admin_checkbox->connect_hook(); |
|
| 1396 | - |
|
| 1397 | - /** |
|
| 1398 | - * @since 3.31.0 |
|
| 1399 | - * Init loader class for videoobject. |
|
| 1400 | - */ |
|
| 1401 | - $videoobject_loader = new Loader(); |
|
| 1402 | - $videoobject_loader->init_feature(); |
|
| 1403 | - /** |
|
| 1404 | - * @since 3.31.5 |
|
| 1405 | - * Create configuration endpoint for webapp to configure. |
|
| 1406 | - */ |
|
| 1407 | - new Config( $that->admin_setup, $that->key_validation_service ); |
|
| 1408 | - /** |
|
| 1409 | - * @since 3.31.7 |
|
| 1410 | - * Remove duplicate videoobject. |
|
| 1411 | - */ |
|
| 1412 | - new Videoobject_Duplicate_Remover(); |
|
| 1413 | - $synonym_loader = new \Wordlift\Synonym\Loader(); |
|
| 1414 | - $synonym_loader->init_feature(); |
|
| 1415 | - /** |
|
| 1416 | - * @since 3.32.0 |
|
| 1417 | - * Create loader for vocabulary terms. |
|
| 1418 | - */ |
|
| 1419 | - $vocabulary_terms_loader = new Vocabulary_Terms_Loader( Wordlift_Entity_Type_Service::get_instance(), $property_getter ); |
|
| 1420 | - $vocabulary_terms_loader->init_feature(); |
|
| 1421 | - |
|
| 1422 | - new Entity_Type_Change_Handler( |
|
| 1423 | - Wordlift_Entity_Service::get_instance(), |
|
| 1424 | - Wordlift_Entity_Type_Service::get_instance() |
|
| 1425 | - ); |
|
| 1426 | - |
|
| 1427 | - }, 3 ); |
|
| 1428 | - |
|
| 1429 | - |
|
| 1430 | - new Entity_Type_Setter(); |
|
| 1431 | - $no_editor_analysis_loader = new \Wordlift\No_Editor_Analysis\Loader(); |
|
| 1432 | - $no_editor_analysis_loader->init_feature(); |
|
| 1433 | - } |
|
| 1434 | - |
|
| 1435 | - /** |
|
| 1436 | - * Define the locale for this plugin for internationalization. |
|
| 1437 | - * |
|
| 1438 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1439 | - * with WordPress. |
|
| 1440 | - * |
|
| 1441 | - * @since 1.0.0 |
|
| 1442 | - * @access private |
|
| 1443 | - */ |
|
| 1444 | - private function set_locale() { |
|
| 1445 | - |
|
| 1446 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 1447 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1448 | - |
|
| 1449 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1450 | - |
|
| 1451 | - } |
|
| 1452 | - |
|
| 1453 | - /** |
|
| 1454 | - * Register all of the hooks related to the admin area functionality |
|
| 1455 | - * of the plugin. |
|
| 1456 | - * |
|
| 1457 | - * @since 1.0.0 |
|
| 1458 | - * @access private |
|
| 1459 | - */ |
|
| 1460 | - private function define_admin_hooks( $that ) { |
|
| 1461 | - $plugin_admin = new |
|
| 1462 | - Wordlift_Admin( |
|
| 1463 | - $that->get_plugin_name(), |
|
| 1464 | - $that->get_version(), |
|
| 1465 | - $that->notice_service, |
|
| 1466 | - $that->user_service |
|
| 1467 | - ); |
|
| 1468 | - |
|
| 1469 | - $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1470 | - $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1471 | - |
|
| 1472 | - // Hook the `admin_init` function to the Admin Setup. |
|
| 1473 | - Assertions::is_set( $that->admin_setup, '`admin_setup` must be set' ); |
|
| 1474 | - $that->loader->add_action( 'admin_init', $that->admin_setup, 'admin_init' ); |
|
| 1475 | - |
|
| 1476 | - // Hook the admin_init to the settings page. |
|
| 1477 | - Assertions::is_set( $that->settings_page, '`setting_page` must be set' ); |
|
| 1478 | - $that->loader->add_action( 'admin_init', $that->settings_page, 'admin_init' ); |
|
| 1479 | - |
|
| 1480 | - // Hook the init action to taxonomy services. |
|
| 1481 | - $that->loader->add_action( 'init', $that->topic_taxonomy_service, 'init', 0 ); |
|
| 1482 | - $that->loader->add_action( 'init', $that->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1483 | - |
|
| 1484 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1485 | - $that->loader->add_action( 'wp_ajax_wl_timeline', $that->timeline_service, 'ajax_timeline' ); |
|
| 1486 | - |
|
| 1487 | - // Register custom allowed redirect hosts. |
|
| 1488 | - $that->loader->add_filter( 'allowed_redirect_hosts', $that->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1489 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1490 | - $that->loader->add_action( 'wp_ajax_wordlift_redirect', $that->redirect_service, 'ajax_redirect' ); |
|
| 1491 | - |
|
| 1492 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1493 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1494 | - $that->loader->add_action( 'save_post', Wordlift_Entity_Service::get_instance(), 'save_post', 9, 3 ); |
|
| 1495 | - $that->loader->add_action( 'save_post', $that->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1496 | - |
|
| 1497 | - $that->loader->add_action( 'edit_form_before_permalink', Wordlift_Entity_Service::get_instance(), 'edit_form_before_permalink', 10, 1 ); |
|
| 1498 | - $that->loader->add_action( 'in_admin_header', $that->rating_service, 'in_admin_header' ); |
|
| 1499 | - |
|
| 1500 | - // Entity listing customization (wp-admin/edit.php) |
|
| 1501 | - // Add custom columns. |
|
| 1502 | - $that->loader->add_filter( 'manage_entity_posts_columns', $that->entity_list_service, 'register_custom_columns' ); |
|
| 1503 | - // no explicit entity as it prevents handling of other post types. |
|
| 1504 | - $that->loader->add_filter( 'manage_posts_custom_column', $that->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1505 | - // Add 4W selection. |
|
| 1506 | - $that->loader->add_action( 'restrict_manage_posts', $that->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1507 | - $that->loader->add_filter( 'posts_clauses', $that->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1508 | - $that->loader->add_action( 'pre_get_posts', $that->entity_list_service, 'pre_get_posts' ); |
|
| 1509 | - $that->loader->add_action( 'load-edit.php', $that->entity_list_service, 'load_edit' ); |
|
| 1510 | - |
|
| 1511 | - /* |
|
| 1312 | + new Templates_Ajax_Endpoint(); |
|
| 1313 | + // Call this static method to register FAQ routes to rest api - disabled |
|
| 1314 | + //Faq_Rest_Controller::register_routes(); |
|
| 1315 | + |
|
| 1316 | + $that->storage_factory = new Wordlift_Storage_Factory( Wordlift_Entity_Service::get_instance(), $that->user_service, $property_getter ); |
|
| 1317 | + |
|
| 1318 | + /** WL Autocomplete. */ |
|
| 1319 | + $autocomplete_service = new All_Autocomplete_Service( array( |
|
| 1320 | + new Local_Autocomplete_Service(), |
|
| 1321 | + new Linked_Data_Autocomplete_Service( Entity_Helper::get_instance(), $that->entity_uri_service, Wordlift_Entity_Service::get_instance() ), |
|
| 1322 | + ) ); |
|
| 1323 | + $that->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
| 1324 | + |
|
| 1325 | + /** |
|
| 1326 | + * @since 3.27.2 |
|
| 1327 | + * Integrate the recipe maker jsonld & set recipe |
|
| 1328 | + * as default entity type to the wprm_recipe CPT. |
|
| 1329 | + */ |
|
| 1330 | + new Recipe_Maker_Post_Type_Hook(); |
|
| 1331 | + $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
|
| 1332 | + new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
| 1333 | + new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
| 1334 | + new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
| 1335 | + new Yoast_Jsonld( $recipe_maker_validation_service ); |
|
| 1336 | + |
|
| 1337 | + /** |
|
| 1338 | + * @since 3.27.4 |
|
| 1339 | + * Add the faq duplicate markup hook. |
|
| 1340 | + */ |
|
| 1341 | + new Faq_Duplicate_Markup_Remover(); |
|
| 1342 | + /** |
|
| 1343 | + * @since 3.33.1 |
|
| 1344 | + * Remove the duplicate HowTo Markup. |
|
| 1345 | + */ |
|
| 1346 | + new How_To_Duplicate_Markup_Remover(); |
|
| 1347 | + |
|
| 1348 | + /** |
|
| 1349 | + * @since 3.27.8 |
|
| 1350 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1248 |
|
| 1351 | + */ |
|
| 1352 | + new Key_Validation_Notice( $that->key_validation_service, Wordlift_Configuration_Service::get_instance() ); |
|
| 1353 | + /** |
|
| 1354 | + * @since 3.28.0 |
|
| 1355 | + * @see https://github.com/insideout10/wordlift-plugin/issues?q=assignee%3Anaveen17797+is%3Aopen |
|
| 1356 | + */ |
|
| 1357 | + new Entity_No_Index_Flag(); |
|
| 1358 | + |
|
| 1359 | + /** |
|
| 1360 | + * @since 3.29.0 |
|
| 1361 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1304 |
|
| 1362 | + */ |
|
| 1363 | + new Entity_Rest_Service( Wordlift_Entity_Type_Service::get_instance() ); |
|
| 1364 | + |
|
| 1365 | + /** |
|
| 1366 | + * Expand author in to references. |
|
| 1367 | + * @since 3.30.0 |
|
| 1368 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1318 |
|
| 1369 | + */ |
|
| 1370 | + |
|
| 1371 | + |
|
| 1372 | + if ( apply_filters( 'wl_feature__enable__article-wrapper', false ) ) { |
|
| 1373 | + new Jsonld_Article_Wrapper( Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter ); |
|
| 1374 | + } |
|
| 1375 | + |
|
| 1376 | + |
|
| 1377 | + if ( apply_filters( 'wl_feature__enable__match-terms', false ) ) { |
|
| 1378 | + $vocabulary_loader = new Vocabulary_Loader(); |
|
| 1379 | + $vocabulary_loader->init_vocabulary(); |
|
| 1380 | + } |
|
| 1381 | + |
|
| 1382 | + /** |
|
| 1383 | + *Added for feature request 1496 (Webhooks) |
|
| 1384 | + */ |
|
| 1385 | + if ( apply_filters( 'wl_feature__enable__webhooks', false ) ) { |
|
| 1386 | + $that->webhook_loader = new Webhooks_Loader(); |
|
| 1387 | + $that->webhook_loader->init(); |
|
| 1388 | + } |
|
| 1389 | + |
|
| 1390 | + /** |
|
| 1391 | + * @since 3.30.0 |
|
| 1392 | + * Add a checkbox to user option screen for wordlift admin. |
|
| 1393 | + */ |
|
| 1394 | + $wordlift_admin_checkbox = new Admin_User_Option(); |
|
| 1395 | + $wordlift_admin_checkbox->connect_hook(); |
|
| 1396 | + |
|
| 1397 | + /** |
|
| 1398 | + * @since 3.31.0 |
|
| 1399 | + * Init loader class for videoobject. |
|
| 1400 | + */ |
|
| 1401 | + $videoobject_loader = new Loader(); |
|
| 1402 | + $videoobject_loader->init_feature(); |
|
| 1403 | + /** |
|
| 1404 | + * @since 3.31.5 |
|
| 1405 | + * Create configuration endpoint for webapp to configure. |
|
| 1406 | + */ |
|
| 1407 | + new Config( $that->admin_setup, $that->key_validation_service ); |
|
| 1408 | + /** |
|
| 1409 | + * @since 3.31.7 |
|
| 1410 | + * Remove duplicate videoobject. |
|
| 1411 | + */ |
|
| 1412 | + new Videoobject_Duplicate_Remover(); |
|
| 1413 | + $synonym_loader = new \Wordlift\Synonym\Loader(); |
|
| 1414 | + $synonym_loader->init_feature(); |
|
| 1415 | + /** |
|
| 1416 | + * @since 3.32.0 |
|
| 1417 | + * Create loader for vocabulary terms. |
|
| 1418 | + */ |
|
| 1419 | + $vocabulary_terms_loader = new Vocabulary_Terms_Loader( Wordlift_Entity_Type_Service::get_instance(), $property_getter ); |
|
| 1420 | + $vocabulary_terms_loader->init_feature(); |
|
| 1421 | + |
|
| 1422 | + new Entity_Type_Change_Handler( |
|
| 1423 | + Wordlift_Entity_Service::get_instance(), |
|
| 1424 | + Wordlift_Entity_Type_Service::get_instance() |
|
| 1425 | + ); |
|
| 1426 | + |
|
| 1427 | + }, 3 ); |
|
| 1428 | + |
|
| 1429 | + |
|
| 1430 | + new Entity_Type_Setter(); |
|
| 1431 | + $no_editor_analysis_loader = new \Wordlift\No_Editor_Analysis\Loader(); |
|
| 1432 | + $no_editor_analysis_loader->init_feature(); |
|
| 1433 | + } |
|
| 1434 | + |
|
| 1435 | + /** |
|
| 1436 | + * Define the locale for this plugin for internationalization. |
|
| 1437 | + * |
|
| 1438 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 1439 | + * with WordPress. |
|
| 1440 | + * |
|
| 1441 | + * @since 1.0.0 |
|
| 1442 | + * @access private |
|
| 1443 | + */ |
|
| 1444 | + private function set_locale() { |
|
| 1445 | + |
|
| 1446 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 1447 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 1448 | + |
|
| 1449 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 1450 | + |
|
| 1451 | + } |
|
| 1452 | + |
|
| 1453 | + /** |
|
| 1454 | + * Register all of the hooks related to the admin area functionality |
|
| 1455 | + * of the plugin. |
|
| 1456 | + * |
|
| 1457 | + * @since 1.0.0 |
|
| 1458 | + * @access private |
|
| 1459 | + */ |
|
| 1460 | + private function define_admin_hooks( $that ) { |
|
| 1461 | + $plugin_admin = new |
|
| 1462 | + Wordlift_Admin( |
|
| 1463 | + $that->get_plugin_name(), |
|
| 1464 | + $that->get_version(), |
|
| 1465 | + $that->notice_service, |
|
| 1466 | + $that->user_service |
|
| 1467 | + ); |
|
| 1468 | + |
|
| 1469 | + $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 1470 | + $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
| 1471 | + |
|
| 1472 | + // Hook the `admin_init` function to the Admin Setup. |
|
| 1473 | + Assertions::is_set( $that->admin_setup, '`admin_setup` must be set' ); |
|
| 1474 | + $that->loader->add_action( 'admin_init', $that->admin_setup, 'admin_init' ); |
|
| 1475 | + |
|
| 1476 | + // Hook the admin_init to the settings page. |
|
| 1477 | + Assertions::is_set( $that->settings_page, '`setting_page` must be set' ); |
|
| 1478 | + $that->loader->add_action( 'admin_init', $that->settings_page, 'admin_init' ); |
|
| 1479 | + |
|
| 1480 | + // Hook the init action to taxonomy services. |
|
| 1481 | + $that->loader->add_action( 'init', $that->topic_taxonomy_service, 'init', 0 ); |
|
| 1482 | + $that->loader->add_action( 'init', $that->entity_types_taxonomy_service, 'init', 0 ); |
|
| 1483 | + |
|
| 1484 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1485 | + $that->loader->add_action( 'wp_ajax_wl_timeline', $that->timeline_service, 'ajax_timeline' ); |
|
| 1486 | + |
|
| 1487 | + // Register custom allowed redirect hosts. |
|
| 1488 | + $that->loader->add_filter( 'allowed_redirect_hosts', $that->redirect_service, 'allowed_redirect_hosts' ); |
|
| 1489 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 1490 | + $that->loader->add_action( 'wp_ajax_wordlift_redirect', $that->redirect_service, 'ajax_redirect' ); |
|
| 1491 | + |
|
| 1492 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 1493 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 1494 | + $that->loader->add_action( 'save_post', Wordlift_Entity_Service::get_instance(), 'save_post', 9, 3 ); |
|
| 1495 | + $that->loader->add_action( 'save_post', $that->rating_service, 'set_rating_for', 20, 1 ); |
|
| 1496 | + |
|
| 1497 | + $that->loader->add_action( 'edit_form_before_permalink', Wordlift_Entity_Service::get_instance(), 'edit_form_before_permalink', 10, 1 ); |
|
| 1498 | + $that->loader->add_action( 'in_admin_header', $that->rating_service, 'in_admin_header' ); |
|
| 1499 | + |
|
| 1500 | + // Entity listing customization (wp-admin/edit.php) |
|
| 1501 | + // Add custom columns. |
|
| 1502 | + $that->loader->add_filter( 'manage_entity_posts_columns', $that->entity_list_service, 'register_custom_columns' ); |
|
| 1503 | + // no explicit entity as it prevents handling of other post types. |
|
| 1504 | + $that->loader->add_filter( 'manage_posts_custom_column', $that->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 1505 | + // Add 4W selection. |
|
| 1506 | + $that->loader->add_action( 'restrict_manage_posts', $that->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 1507 | + $that->loader->add_filter( 'posts_clauses', $that->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 1508 | + $that->loader->add_action( 'pre_get_posts', $that->entity_list_service, 'pre_get_posts' ); |
|
| 1509 | + $that->loader->add_action( 'load-edit.php', $that->entity_list_service, 'load_edit' ); |
|
| 1510 | + |
|
| 1511 | + /* |
|
| 1512 | 1512 | * If `All Entity Types` is disable, use the radio button Walker. |
| 1513 | 1513 | * |
| 1514 | 1514 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 1515 | 1515 | */ |
| 1516 | - if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1517 | - $that->loader->add_filter( 'wp_terms_checklist_args', $that->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1518 | - } |
|
| 1519 | - |
|
| 1520 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1521 | - // entities. |
|
| 1522 | - $that->loader->add_filter( 'prima_metabox_entity_header_args', $that->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1523 | - |
|
| 1524 | - /** |
|
| 1525 | - * Filter: wl_feature__enable__settings-download. |
|
| 1526 | - * |
|
| 1527 | - * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1528 | - * |
|
| 1529 | - * @return bool |
|
| 1530 | - * @since 3.27.6 |
|
| 1531 | - */ |
|
| 1532 | - $that->features_registry->register_feature_from_slug( 'settings-download', true, array( |
|
| 1533 | - $that, |
|
| 1534 | - 'register_screens' |
|
| 1535 | - ) ); |
|
| 1536 | - |
|
| 1537 | - |
|
| 1538 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1539 | - $that->loader->add_action( 'wp_ajax_wl_download_your_data', $that->download_your_data_page, 'download_your_data', 10 ); |
|
| 1540 | - |
|
| 1541 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1542 | - $that->loader->add_action( 'wp_ajax_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1543 | - $that->loader->add_action( 'admin_post_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1544 | - $that->loader->add_action( 'admin_post_nopriv_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1545 | - |
|
| 1546 | - // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1547 | - $that->loader->add_action( 'wp_ajax_wl_validate_key', $that->key_validation_service, 'validate_key' ); |
|
| 1548 | - |
|
| 1549 | - // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1550 | - $that->loader->add_action( 'wp_ajax_wl_update_country_options', $that->country_select_element, 'get_options_html' ); |
|
| 1551 | - |
|
| 1552 | - $that->loader->add_filter( 'admin_post_thumbnail_html', $that->publisher_service, 'add_featured_image_instruction' ); |
|
| 1553 | - |
|
| 1554 | - // Hook the menu creation on the general wordlift menu creation. |
|
| 1555 | - /** |
|
| 1556 | - * Filter: wl_feature__enable__screens. |
|
| 1557 | - * |
|
| 1558 | - * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1559 | - * |
|
| 1560 | - * @return bool |
|
| 1561 | - * @since 3.27.6 |
|
| 1562 | - * |
|
| 1563 | - * Since 3.30.0 this feature is registered using registry. |
|
| 1564 | - */ |
|
| 1565 | - if ( apply_filters( 'wl_feature__enable__settings-screen', true ) || Admin_User_Option::is_wordlift_admin() ) { |
|
| 1566 | - add_action( 'wl_admin_menu', array( $that->settings_page, 'admin_menu' ), 10, 2 ); |
|
| 1567 | - } |
|
| 1568 | - |
|
| 1569 | - // Hook key update. |
|
| 1570 | - $that->loader->add_action( 'pre_update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1571 | - $that->loader->add_action( 'update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'update_key', 10, 2 ); |
|
| 1572 | - |
|
| 1573 | - // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1574 | - $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1575 | - |
|
| 1576 | - /* |
|
| 1516 | + if ( ! WL_ALL_ENTITY_TYPES ) { |
|
| 1517 | + $that->loader->add_filter( 'wp_terms_checklist_args', $that->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 1518 | + } |
|
| 1519 | + |
|
| 1520 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 1521 | + // entities. |
|
| 1522 | + $that->loader->add_filter( 'prima_metabox_entity_header_args', $that->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 1523 | + |
|
| 1524 | + /** |
|
| 1525 | + * Filter: wl_feature__enable__settings-download. |
|
| 1526 | + * |
|
| 1527 | + * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1528 | + * |
|
| 1529 | + * @return bool |
|
| 1530 | + * @since 3.27.6 |
|
| 1531 | + */ |
|
| 1532 | + $that->features_registry->register_feature_from_slug( 'settings-download', true, array( |
|
| 1533 | + $that, |
|
| 1534 | + 'register_screens' |
|
| 1535 | + ) ); |
|
| 1536 | + |
|
| 1537 | + |
|
| 1538 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 1539 | + $that->loader->add_action( 'wp_ajax_wl_download_your_data', $that->download_your_data_page, 'download_your_data', 10 ); |
|
| 1540 | + |
|
| 1541 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1542 | + $that->loader->add_action( 'wp_ajax_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1543 | + $that->loader->add_action( 'admin_post_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1544 | + $that->loader->add_action( 'admin_post_nopriv_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1545 | + |
|
| 1546 | + // Hook the AJAX wl_validate_key action to the Key Validation service. |
|
| 1547 | + $that->loader->add_action( 'wp_ajax_wl_validate_key', $that->key_validation_service, 'validate_key' ); |
|
| 1548 | + |
|
| 1549 | + // Hook the AJAX wl_update_country_options action to the countries. |
|
| 1550 | + $that->loader->add_action( 'wp_ajax_wl_update_country_options', $that->country_select_element, 'get_options_html' ); |
|
| 1551 | + |
|
| 1552 | + $that->loader->add_filter( 'admin_post_thumbnail_html', $that->publisher_service, 'add_featured_image_instruction' ); |
|
| 1553 | + |
|
| 1554 | + // Hook the menu creation on the general wordlift menu creation. |
|
| 1555 | + /** |
|
| 1556 | + * Filter: wl_feature__enable__screens. |
|
| 1557 | + * |
|
| 1558 | + * @param bool whether the screens needed to be registered, defaults to true. |
|
| 1559 | + * |
|
| 1560 | + * @return bool |
|
| 1561 | + * @since 3.27.6 |
|
| 1562 | + * |
|
| 1563 | + * Since 3.30.0 this feature is registered using registry. |
|
| 1564 | + */ |
|
| 1565 | + if ( apply_filters( 'wl_feature__enable__settings-screen', true ) || Admin_User_Option::is_wordlift_admin() ) { |
|
| 1566 | + add_action( 'wl_admin_menu', array( $that->settings_page, 'admin_menu' ), 10, 2 ); |
|
| 1567 | + } |
|
| 1568 | + |
|
| 1569 | + // Hook key update. |
|
| 1570 | + $that->loader->add_action( 'pre_update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'maybe_update_dataset_uri', 10, 2 ); |
|
| 1571 | + $that->loader->add_action( 'update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'update_key', 10, 2 ); |
|
| 1572 | + |
|
| 1573 | + // Add additional action links to the WordLift plugin in the plugins page. |
|
| 1574 | + $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1575 | + |
|
| 1576 | + /* |
|
| 1577 | 1577 | * Remove the Analytics Settings link from the plugin page. |
| 1578 | 1578 | * |
| 1579 | 1579 | * @see https://github.com/insideout10/wordlift-plugin/issues/932 |
| 1580 | 1580 | * @since 3.21.1 |
| 1581 | 1581 | */ |
| 1582 | - // $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1583 | - |
|
| 1584 | - // Hook the AJAX `wl_publisher` action name. |
|
| 1585 | - $that->loader->add_action( 'wp_ajax_wl_publisher', $that->publisher_ajax_adapter, 'publisher' ); |
|
| 1586 | - |
|
| 1587 | - // Hook row actions for the entity type list admin. |
|
| 1588 | - $that->loader->add_filter( 'wl_entity_type_row_actions', $that->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1589 | - |
|
| 1590 | - /** Ajax actions. */ |
|
| 1591 | - $that->loader->add_action( 'wp_ajax_wl_google_analytics_export', $that->google_analytics_export_service, 'export' ); |
|
| 1592 | - |
|
| 1593 | - // Hook capabilities manipulation to allow access to entity type admin |
|
| 1594 | - // page on WordPress versions before 4.7. |
|
| 1595 | - global $wp_version; |
|
| 1596 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1597 | - $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1598 | - } |
|
| 1599 | - |
|
| 1600 | - /** Adapters. */ |
|
| 1601 | - $that->loader->add_filter( 'mce_external_plugins', $that->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1602 | - /** |
|
| 1603 | - * Disabling Faq temporarily. |
|
| 1604 | - * Load the tinymce editor button on the tool bar. |
|
| 1605 | - * @since 3.26.0 |
|
| 1606 | - */ |
|
| 1607 | - //$that->loader->add_filter( 'tiny_mce_before_init', $that->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1608 | - //$that->loader->add_filter( 'mce_buttons', $that->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1609 | - //$that->loader->add_filter( 'mce_external_plugins', $that->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1610 | - |
|
| 1611 | - |
|
| 1612 | - $that->loader->add_action( 'wp_ajax_wl_sample_data_create', $that->sample_data_ajax_adapter, 'create' ); |
|
| 1613 | - $that->loader->add_action( 'wp_ajax_wl_sample_data_delete', $that->sample_data_ajax_adapter, 'delete' ); |
|
| 1614 | - |
|
| 1615 | - /** |
|
| 1616 | - * @since 3.26.0 |
|
| 1617 | - */ |
|
| 1618 | - $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1619 | - $that->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1620 | - // Adding Rest route for the post excerpt |
|
| 1621 | - Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1622 | - |
|
| 1623 | - // Handle the autocomplete request. |
|
| 1624 | - add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1625 | - $that->autocomplete_adapter, |
|
| 1626 | - 'wl_autocomplete', |
|
| 1627 | - ) ); |
|
| 1628 | - add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1629 | - $that->autocomplete_adapter, |
|
| 1630 | - 'wl_autocomplete', |
|
| 1631 | - ) ); |
|
| 1632 | - |
|
| 1633 | - // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1634 | - if ( is_multisite() ) { |
|
| 1635 | - $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1636 | - } |
|
| 1637 | - |
|
| 1638 | - $deactivator_feedback = new Wordlift_Deactivator_Feedback(); |
|
| 1639 | - |
|
| 1640 | - add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1641 | - add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1642 | - add_action( 'wp_ajax_wl_deactivation_feedback', array( |
|
| 1643 | - $deactivator_feedback, |
|
| 1644 | - 'wl_deactivation_feedback' |
|
| 1645 | - ) ); |
|
| 1646 | - |
|
| 1647 | - /** |
|
| 1648 | - * Always allow the `wordlift/classification` block. |
|
| 1649 | - * |
|
| 1650 | - * @since 3.23.0 |
|
| 1651 | - */ |
|
| 1652 | - add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1653 | - |
|
| 1654 | - if ( true === $value ) { |
|
| 1655 | - return $value; |
|
| 1656 | - } |
|
| 1657 | - |
|
| 1658 | - return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1659 | - }, PHP_INT_MAX ); |
|
| 1660 | - |
|
| 1661 | - /** |
|
| 1662 | - * @since 3.27.7 |
|
| 1663 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 1664 | - */ |
|
| 1665 | - new Top_Entities(); |
|
| 1666 | - |
|
| 1667 | - } |
|
| 1668 | - |
|
| 1669 | - /** |
|
| 1670 | - * Register all of the hooks related to the public-facing functionality |
|
| 1671 | - * of the plugin. |
|
| 1672 | - * |
|
| 1673 | - * @since 1.0.0 |
|
| 1674 | - * @access private |
|
| 1675 | - */ |
|
| 1676 | - private function define_public_hooks( $that ) { |
|
| 1677 | - |
|
| 1678 | - $plugin_public = new Wordlift_Public( $that->get_plugin_name(), $that->get_version() ); |
|
| 1679 | - |
|
| 1680 | - // Register the entity post type. |
|
| 1681 | - $that->loader->add_action( 'init', $that->entity_post_type_service, 'register' ); |
|
| 1682 | - |
|
| 1683 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 1684 | - $that->loader->add_filter( 'post_type_link', $that->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1685 | - $that->loader->add_action( 'pre_get_posts', $that->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1686 | - // $that->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 1687 | - // $that->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 1688 | - |
|
| 1689 | - $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1690 | - $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1691 | - $that->loader->add_action( 'wp_enqueue_scripts', $that->context_cards_service, 'enqueue_scripts' ); |
|
| 1692 | - |
|
| 1693 | - // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1694 | - $that->loader->add_filter( 'the_content', $that->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1695 | - // Hook the content filter service to add entity links. |
|
| 1696 | - if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1697 | - $that->loader->add_filter( 'the_content', $that->content_filter_service, 'the_content' ); |
|
| 1698 | - } |
|
| 1699 | - |
|
| 1700 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1701 | - $that->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $that->timeline_service, 'ajax_timeline' ); |
|
| 1702 | - |
|
| 1703 | - // Hook the ShareThis service. |
|
| 1704 | - $that->loader->add_filter( 'the_content', $that->sharethis_service, 'the_content', 99 ); |
|
| 1705 | - $that->loader->add_filter( 'the_excerpt', $that->sharethis_service, 'the_excerpt', 99 ); |
|
| 1706 | - |
|
| 1707 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1708 | - $that->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1709 | - |
|
| 1710 | - // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1711 | - // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1712 | - // to categories. |
|
| 1713 | - $that->loader->add_action( 'pre_get_posts', $that->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1714 | - |
|
| 1715 | - /* |
|
| 1582 | + // $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
|
| 1583 | + |
|
| 1584 | + // Hook the AJAX `wl_publisher` action name. |
|
| 1585 | + $that->loader->add_action( 'wp_ajax_wl_publisher', $that->publisher_ajax_adapter, 'publisher' ); |
|
| 1586 | + |
|
| 1587 | + // Hook row actions for the entity type list admin. |
|
| 1588 | + $that->loader->add_filter( 'wl_entity_type_row_actions', $that->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
| 1589 | + |
|
| 1590 | + /** Ajax actions. */ |
|
| 1591 | + $that->loader->add_action( 'wp_ajax_wl_google_analytics_export', $that->google_analytics_export_service, 'export' ); |
|
| 1592 | + |
|
| 1593 | + // Hook capabilities manipulation to allow access to entity type admin |
|
| 1594 | + // page on WordPress versions before 4.7. |
|
| 1595 | + global $wp_version; |
|
| 1596 | + if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
| 1597 | + $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 ); |
|
| 1598 | + } |
|
| 1599 | + |
|
| 1600 | + /** Adapters. */ |
|
| 1601 | + $that->loader->add_filter( 'mce_external_plugins', $that->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
| 1602 | + /** |
|
| 1603 | + * Disabling Faq temporarily. |
|
| 1604 | + * Load the tinymce editor button on the tool bar. |
|
| 1605 | + * @since 3.26.0 |
|
| 1606 | + */ |
|
| 1607 | + //$that->loader->add_filter( 'tiny_mce_before_init', $that->faq_tinymce_adapter, 'register_custom_tags' ); |
|
| 1608 | + //$that->loader->add_filter( 'mce_buttons', $that->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
|
| 1609 | + //$that->loader->add_filter( 'mce_external_plugins', $that->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
|
| 1610 | + |
|
| 1611 | + |
|
| 1612 | + $that->loader->add_action( 'wp_ajax_wl_sample_data_create', $that->sample_data_ajax_adapter, 'create' ); |
|
| 1613 | + $that->loader->add_action( 'wp_ajax_wl_sample_data_delete', $that->sample_data_ajax_adapter, 'delete' ); |
|
| 1614 | + |
|
| 1615 | + /** |
|
| 1616 | + * @since 3.26.0 |
|
| 1617 | + */ |
|
| 1618 | + $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
|
| 1619 | + $that->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
| 1620 | + // Adding Rest route for the post excerpt |
|
| 1621 | + Post_Excerpt_Rest_Controller::register_routes(); |
|
| 1622 | + |
|
| 1623 | + // Handle the autocomplete request. |
|
| 1624 | + add_action( 'wp_ajax_wl_autocomplete', array( |
|
| 1625 | + $that->autocomplete_adapter, |
|
| 1626 | + 'wl_autocomplete', |
|
| 1627 | + ) ); |
|
| 1628 | + add_action( 'wp_ajax_nopriv_wl_autocomplete', array( |
|
| 1629 | + $that->autocomplete_adapter, |
|
| 1630 | + 'wl_autocomplete', |
|
| 1631 | + ) ); |
|
| 1632 | + |
|
| 1633 | + // Hooks to restrict multisite super admin from manipulating entity types. |
|
| 1634 | + if ( is_multisite() ) { |
|
| 1635 | + $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'restrict_super_admin', 10, 4 ); |
|
| 1636 | + } |
|
| 1637 | + |
|
| 1638 | + $deactivator_feedback = new Wordlift_Deactivator_Feedback(); |
|
| 1639 | + |
|
| 1640 | + add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
| 1641 | + add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) ); |
|
| 1642 | + add_action( 'wp_ajax_wl_deactivation_feedback', array( |
|
| 1643 | + $deactivator_feedback, |
|
| 1644 | + 'wl_deactivation_feedback' |
|
| 1645 | + ) ); |
|
| 1646 | + |
|
| 1647 | + /** |
|
| 1648 | + * Always allow the `wordlift/classification` block. |
|
| 1649 | + * |
|
| 1650 | + * @since 3.23.0 |
|
| 1651 | + */ |
|
| 1652 | + add_filter( 'allowed_block_types', function ( $value ) { |
|
| 1653 | + |
|
| 1654 | + if ( true === $value ) { |
|
| 1655 | + return $value; |
|
| 1656 | + } |
|
| 1657 | + |
|
| 1658 | + return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
| 1659 | + }, PHP_INT_MAX ); |
|
| 1660 | + |
|
| 1661 | + /** |
|
| 1662 | + * @since 3.27.7 |
|
| 1663 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 1664 | + */ |
|
| 1665 | + new Top_Entities(); |
|
| 1666 | + |
|
| 1667 | + } |
|
| 1668 | + |
|
| 1669 | + /** |
|
| 1670 | + * Register all of the hooks related to the public-facing functionality |
|
| 1671 | + * of the plugin. |
|
| 1672 | + * |
|
| 1673 | + * @since 1.0.0 |
|
| 1674 | + * @access private |
|
| 1675 | + */ |
|
| 1676 | + private function define_public_hooks( $that ) { |
|
| 1677 | + |
|
| 1678 | + $plugin_public = new Wordlift_Public( $that->get_plugin_name(), $that->get_version() ); |
|
| 1679 | + |
|
| 1680 | + // Register the entity post type. |
|
| 1681 | + $that->loader->add_action( 'init', $that->entity_post_type_service, 'register' ); |
|
| 1682 | + |
|
| 1683 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 1684 | + $that->loader->add_filter( 'post_type_link', $that->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 1685 | + $that->loader->add_action( 'pre_get_posts', $that->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
| 1686 | + // $that->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 1687 | + // $that->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 1688 | + |
|
| 1689 | + $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 1690 | + $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 1691 | + $that->loader->add_action( 'wp_enqueue_scripts', $that->context_cards_service, 'enqueue_scripts' ); |
|
| 1692 | + |
|
| 1693 | + // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
|
| 1694 | + $that->loader->add_filter( 'the_content', $that->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
| 1695 | + // Hook the content filter service to add entity links. |
|
| 1696 | + if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
| 1697 | + $that->loader->add_filter( 'the_content', $that->content_filter_service, 'the_content' ); |
|
| 1698 | + } |
|
| 1699 | + |
|
| 1700 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 1701 | + $that->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $that->timeline_service, 'ajax_timeline' ); |
|
| 1702 | + |
|
| 1703 | + // Hook the ShareThis service. |
|
| 1704 | + $that->loader->add_filter( 'the_content', $that->sharethis_service, 'the_content', 99 ); |
|
| 1705 | + $that->loader->add_filter( 'the_excerpt', $that->sharethis_service, 'the_excerpt', 99 ); |
|
| 1706 | + |
|
| 1707 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 1708 | + $that->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $that->jsonld_service, 'get' ); |
|
| 1709 | + |
|
| 1710 | + // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
|
| 1711 | + // in order to tweak WP's `WP_Query` to include entities in queries related |
|
| 1712 | + // to categories. |
|
| 1713 | + $that->loader->add_action( 'pre_get_posts', $that->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
| 1714 | + |
|
| 1715 | + /* |
|
| 1716 | 1716 | * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service` |
| 1717 | 1717 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
| 1718 | 1718 | * order of start time. |
| 1719 | 1719 | */ |
| 1720 | - $that->loader->add_action( 'pre_get_posts', $that->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1721 | - |
|
| 1722 | - // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1723 | - $that->loader->add_action( 'save_post', $that->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1724 | - |
|
| 1725 | - // Analytics Script Frontend. |
|
| 1726 | - if ( apply_filters( 'wl_feature__enable__analytics', true ) && Wordlift_Configuration_Service::get_instance()->is_analytics_enable() ) { |
|
| 1727 | - $that->loader->add_action( 'wp_enqueue_scripts', $that->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 1728 | - } |
|
| 1729 | - |
|
| 1730 | - } |
|
| 1731 | - |
|
| 1732 | - /** |
|
| 1733 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 1734 | - * |
|
| 1735 | - * @since 1.0.0 |
|
| 1736 | - */ |
|
| 1737 | - public function run() { |
|
| 1738 | - $this->loader->run(); |
|
| 1739 | - } |
|
| 1740 | - |
|
| 1741 | - /** |
|
| 1742 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 1743 | - * WordPress and to define internationalization functionality. |
|
| 1744 | - * |
|
| 1745 | - * @return string The name of the plugin. |
|
| 1746 | - * @since 1.0.0 |
|
| 1747 | - */ |
|
| 1748 | - public function get_plugin_name() { |
|
| 1749 | - return $this->plugin_name; |
|
| 1750 | - } |
|
| 1751 | - |
|
| 1752 | - /** |
|
| 1753 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1754 | - * |
|
| 1755 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1756 | - * @since 1.0.0 |
|
| 1757 | - */ |
|
| 1758 | - public function get_loader() { |
|
| 1759 | - return $this->loader; |
|
| 1760 | - } |
|
| 1761 | - |
|
| 1762 | - /** |
|
| 1763 | - * Retrieve the version number of the plugin. |
|
| 1764 | - * |
|
| 1765 | - * @return string The version number of the plugin. |
|
| 1766 | - * @since 1.0.0 |
|
| 1767 | - */ |
|
| 1768 | - public function get_version() { |
|
| 1769 | - return $this->version; |
|
| 1770 | - } |
|
| 1771 | - |
|
| 1772 | - /** |
|
| 1773 | - * Load dependencies for WP-CLI. |
|
| 1774 | - * |
|
| 1775 | - * @throws Exception |
|
| 1776 | - * @since 3.18.0 |
|
| 1777 | - */ |
|
| 1778 | - private function load_cli_dependencies() { |
|
| 1779 | - |
|
| 1780 | - } |
|
| 1781 | - |
|
| 1782 | - public function add_wl_enabled_blocks() { |
|
| 1783 | - /** |
|
| 1784 | - * Filter: wl_feature__enable__blocks. |
|
| 1785 | - * |
|
| 1786 | - * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1787 | - * |
|
| 1788 | - * @return bool |
|
| 1789 | - * @since 3.27.6 |
|
| 1790 | - */ |
|
| 1791 | - |
|
| 1792 | - wp_register_script( 'wl_enabled_blocks', false ); |
|
| 1793 | - |
|
| 1794 | - $enabled_blocks = array(); |
|
| 1795 | - |
|
| 1796 | - /** |
|
| 1797 | - * Filter name: wl_feature__enable__product-navigator |
|
| 1798 | - * @since 3.32.3 |
|
| 1799 | - */ |
|
| 1800 | - if ( apply_filters( 'wl_feature__enable__product-navigator', true ) ) { |
|
| 1801 | - $enabled_blocks[] = 'wordlift/products-navigator'; |
|
| 1802 | - } |
|
| 1803 | - |
|
| 1804 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1805 | - // To intimate JS |
|
| 1806 | - $enabled_blocks = array_merge( $enabled_blocks, array( |
|
| 1807 | - 'wordlift/navigator', |
|
| 1808 | - 'wordlift/chord', |
|
| 1809 | - 'wordlift/geomap', |
|
| 1810 | - 'wordlift/timeline', |
|
| 1811 | - 'wordlift/cloud', |
|
| 1812 | - 'wordlift/vocabulary', |
|
| 1813 | - 'wordlift/faceted-search' |
|
| 1814 | - ) ); |
|
| 1815 | - } |
|
| 1816 | - |
|
| 1817 | - wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
| 1818 | - wp_enqueue_script( 'wl_enabled_blocks' ); |
|
| 1819 | - } |
|
| 1820 | - |
|
| 1821 | - /** |
|
| 1822 | - * Register screens based on the filter. |
|
| 1823 | - */ |
|
| 1824 | - public function register_screens() { |
|
| 1825 | - // Hook the menu to the Download Your Data page. |
|
| 1826 | - if ( apply_filters( 'wl_feature__enable__settings-download', true ) ) { |
|
| 1827 | - Assertions::is_set( $this->download_your_data_page, "`download_your_data_page` can't be null" ); |
|
| 1828 | - add_action( 'admin_menu', array( $this->download_your_data_page, 'admin_menu' ), 100, 0 ); |
|
| 1829 | - } |
|
| 1830 | - |
|
| 1831 | - Assertions::is_set( $this->entity_type_settings_admin_page, "`entity_type_settings_admin_page` can't be null" ); |
|
| 1832 | - add_action( 'admin_menu', array( $this->entity_type_settings_admin_page, 'admin_menu' ), 100, 0 ); |
|
| 1833 | - |
|
| 1834 | - } |
|
| 1720 | + $that->loader->add_action( 'pre_get_posts', $that->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
| 1721 | + |
|
| 1722 | + // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
|
| 1723 | + $that->loader->add_action( 'save_post', $that->entity_type_adapter, 'save_post', 9, 3 ); |
|
| 1724 | + |
|
| 1725 | + // Analytics Script Frontend. |
|
| 1726 | + if ( apply_filters( 'wl_feature__enable__analytics', true ) && Wordlift_Configuration_Service::get_instance()->is_analytics_enable() ) { |
|
| 1727 | + $that->loader->add_action( 'wp_enqueue_scripts', $that->analytics_connect, 'enqueue_scripts', 10 ); |
|
| 1728 | + } |
|
| 1729 | + |
|
| 1730 | + } |
|
| 1731 | + |
|
| 1732 | + /** |
|
| 1733 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 1734 | + * |
|
| 1735 | + * @since 1.0.0 |
|
| 1736 | + */ |
|
| 1737 | + public function run() { |
|
| 1738 | + $this->loader->run(); |
|
| 1739 | + } |
|
| 1740 | + |
|
| 1741 | + /** |
|
| 1742 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 1743 | + * WordPress and to define internationalization functionality. |
|
| 1744 | + * |
|
| 1745 | + * @return string The name of the plugin. |
|
| 1746 | + * @since 1.0.0 |
|
| 1747 | + */ |
|
| 1748 | + public function get_plugin_name() { |
|
| 1749 | + return $this->plugin_name; |
|
| 1750 | + } |
|
| 1751 | + |
|
| 1752 | + /** |
|
| 1753 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 1754 | + * |
|
| 1755 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 1756 | + * @since 1.0.0 |
|
| 1757 | + */ |
|
| 1758 | + public function get_loader() { |
|
| 1759 | + return $this->loader; |
|
| 1760 | + } |
|
| 1761 | + |
|
| 1762 | + /** |
|
| 1763 | + * Retrieve the version number of the plugin. |
|
| 1764 | + * |
|
| 1765 | + * @return string The version number of the plugin. |
|
| 1766 | + * @since 1.0.0 |
|
| 1767 | + */ |
|
| 1768 | + public function get_version() { |
|
| 1769 | + return $this->version; |
|
| 1770 | + } |
|
| 1771 | + |
|
| 1772 | + /** |
|
| 1773 | + * Load dependencies for WP-CLI. |
|
| 1774 | + * |
|
| 1775 | + * @throws Exception |
|
| 1776 | + * @since 3.18.0 |
|
| 1777 | + */ |
|
| 1778 | + private function load_cli_dependencies() { |
|
| 1779 | + |
|
| 1780 | + } |
|
| 1781 | + |
|
| 1782 | + public function add_wl_enabled_blocks() { |
|
| 1783 | + /** |
|
| 1784 | + * Filter: wl_feature__enable__blocks. |
|
| 1785 | + * |
|
| 1786 | + * @param bool whether the blocks needed to be registered, defaults to true. |
|
| 1787 | + * |
|
| 1788 | + * @return bool |
|
| 1789 | + * @since 3.27.6 |
|
| 1790 | + */ |
|
| 1791 | + |
|
| 1792 | + wp_register_script( 'wl_enabled_blocks', false ); |
|
| 1793 | + |
|
| 1794 | + $enabled_blocks = array(); |
|
| 1795 | + |
|
| 1796 | + /** |
|
| 1797 | + * Filter name: wl_feature__enable__product-navigator |
|
| 1798 | + * @since 3.32.3 |
|
| 1799 | + */ |
|
| 1800 | + if ( apply_filters( 'wl_feature__enable__product-navigator', true ) ) { |
|
| 1801 | + $enabled_blocks[] = 'wordlift/products-navigator'; |
|
| 1802 | + } |
|
| 1803 | + |
|
| 1804 | + if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
| 1805 | + // To intimate JS |
|
| 1806 | + $enabled_blocks = array_merge( $enabled_blocks, array( |
|
| 1807 | + 'wordlift/navigator', |
|
| 1808 | + 'wordlift/chord', |
|
| 1809 | + 'wordlift/geomap', |
|
| 1810 | + 'wordlift/timeline', |
|
| 1811 | + 'wordlift/cloud', |
|
| 1812 | + 'wordlift/vocabulary', |
|
| 1813 | + 'wordlift/faceted-search' |
|
| 1814 | + ) ); |
|
| 1815 | + } |
|
| 1816 | + |
|
| 1817 | + wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
| 1818 | + wp_enqueue_script( 'wl_enabled_blocks' ); |
|
| 1819 | + } |
|
| 1820 | + |
|
| 1821 | + /** |
|
| 1822 | + * Register screens based on the filter. |
|
| 1823 | + */ |
|
| 1824 | + public function register_screens() { |
|
| 1825 | + // Hook the menu to the Download Your Data page. |
|
| 1826 | + if ( apply_filters( 'wl_feature__enable__settings-download', true ) ) { |
|
| 1827 | + Assertions::is_set( $this->download_your_data_page, "`download_your_data_page` can't be null" ); |
|
| 1828 | + add_action( 'admin_menu', array( $this->download_your_data_page, 'admin_menu' ), 100, 0 ); |
|
| 1829 | + } |
|
| 1830 | + |
|
| 1831 | + Assertions::is_set( $this->entity_type_settings_admin_page, "`entity_type_settings_admin_page` can't be null" ); |
|
| 1832 | + add_action( 'admin_menu', array( $this->entity_type_settings_admin_page, 'admin_menu' ), 100, 0 ); |
|
| 1833 | + |
|
| 1834 | + } |
|
| 1835 | 1835 | |
| 1836 | 1836 | } |
@@ -12,179 +12,179 @@ |
||
| 12 | 12 | use Wordlift\Videoobject\Data\Video_Storage\Storage; |
| 13 | 13 | |
| 14 | 14 | class Jsonld { |
| 15 | - /** |
|
| 16 | - * @var Storage |
|
| 17 | - */ |
|
| 18 | - private $video_storage; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Jsonld constructor. |
|
| 22 | - * |
|
| 23 | - * @param $video_storage Storage |
|
| 24 | - */ |
|
| 25 | - public function __construct( $video_storage ) { |
|
| 26 | - add_action( 'wl_post_jsonld', array( $this, 'wl_post_jsonld' ), 10, 3 ); |
|
| 27 | - add_action( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10, 3 ); |
|
| 28 | - $this->video_storage = $video_storage; |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - public function wl_after_get_jsonld( $jsonld, $post_id, $context ) { |
|
| 33 | - if ( 0 === count( $jsonld ) ) { |
|
| 34 | - return $jsonld; |
|
| 35 | - } |
|
| 36 | - $current_item = $jsonld[0]; |
|
| 37 | - |
|
| 38 | - if ( ! is_array( $current_item ) || ! array_key_exists( '@type', $current_item ) ) { |
|
| 39 | - // Cant determine type return early. |
|
| 40 | - return $jsonld; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - $type = $current_item['@type']; |
|
| 44 | - if ( is_string( $type ) ) { |
|
| 45 | - $type = array( $type ); |
|
| 46 | - } |
|
| 47 | - // If its a article or descendant of article, then dont add the |
|
| 48 | - // videoobject in this hook, they will be already added to video property. |
|
| 49 | - if ( array_intersect( Jsonld_Article_Wrapper::$article_types, $type ) ) { |
|
| 50 | - return $jsonld; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - $videos_jsonld = $this->get_videos_jsonld( $post_id ); |
|
| 54 | - if ( 0 === count( $videos_jsonld ) ) { |
|
| 55 | - return $jsonld; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - // check if we have @id in jsonld for first item. |
|
| 59 | - $id = array_key_exists( '@id', $current_item ) ? $current_item['@id'] : ''; |
|
| 60 | - |
|
| 61 | - foreach ( $videos_jsonld as &$video_jsonld ) { |
|
| 62 | - if ( ! $id ) { |
|
| 63 | - continue; |
|
| 64 | - } |
|
| 65 | - if ( ! array_key_exists( 'mentions', $video_jsonld ) ) { |
|
| 66 | - $video_jsonld['mentions'] = array( '@id' => $id ); |
|
| 67 | - } else { |
|
| 68 | - $video_jsonld['mentions'] = array_merge( $video_jsonld['mentions'], array( '@id' => $id ) ); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - return array_merge( $jsonld, $videos_jsonld ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @param $existing_video_data string | array associative or sequential array. |
|
| 77 | - * @param $new_video_data array Sequential array. |
|
| 78 | - * |
|
| 79 | - * @return array |
|
| 80 | - */ |
|
| 81 | - private function merge_video_data( $existing_video_data, $new_video_data ) { |
|
| 82 | - if ( ! is_array( $existing_video_data ) ) { |
|
| 83 | - $new_video_data[] = $existing_video_data; |
|
| 84 | - |
|
| 85 | - return $new_video_data; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - if ( $this->is_associative_array( $existing_video_data ) ) { |
|
| 89 | - $new_video_data[] = $existing_video_data; |
|
| 90 | - |
|
| 91 | - return $new_video_data; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - return array_merge( $existing_video_data, $new_video_data ); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - public function wl_post_jsonld( $jsonld, $post_id, $references ) { |
|
| 98 | - |
|
| 99 | - $video_jsonld = $this->get_videos_jsonld( $post_id ); |
|
| 100 | - if ( count( $video_jsonld ) === 0 ) { |
|
| 101 | - return $jsonld; |
|
| 102 | - } |
|
| 103 | - // Before adding the video jsonld check if the key |
|
| 104 | - // is present and additional data might be present, |
|
| 105 | - // if not present just add the data and return early. |
|
| 106 | - if ( ! array_key_exists( 'video', $jsonld ) ) { |
|
| 107 | - $jsonld['video'] = $video_jsonld; |
|
| 108 | - |
|
| 109 | - return $jsonld; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - // since key exists, we need to merge the data based on type. |
|
| 113 | - $previous_video_data = $jsonld['video']; |
|
| 114 | - $jsonld['video'] = $this->merge_video_data( $previous_video_data, $video_jsonld ); |
|
| 115 | - |
|
| 116 | - return $jsonld; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @param $post_id int Post id. |
|
| 122 | - * |
|
| 123 | - * @return array |
|
| 124 | - */ |
|
| 125 | - public function get_videos_jsonld( $post_id ) { |
|
| 126 | - |
|
| 127 | - $videos = $this->video_storage->get_all_videos( $post_id ); |
|
| 128 | - |
|
| 129 | - $jsonld = array(); |
|
| 130 | - |
|
| 131 | - foreach ( $videos as $video ) { |
|
| 132 | - /** |
|
| 133 | - * @var $video Video |
|
| 134 | - */ |
|
| 135 | - $description = $video->description; |
|
| 136 | - if ( ! $video->description ) { |
|
| 137 | - // If description is empty then use the video title as description |
|
| 138 | - $description = $video->name; |
|
| 139 | - } |
|
| 140 | - $single_jsonld = array( |
|
| 141 | - '@context' => 'http://schema.org', |
|
| 142 | - '@type' => 'VideoObject', |
|
| 143 | - 'name' => $video->name, |
|
| 144 | - 'description' => $description, |
|
| 145 | - 'contentUrl' => $video->content_url, |
|
| 146 | - 'uploadDate' => $video->upload_date, |
|
| 147 | - 'thumbnailUrl' => $video->thumbnail_urls, |
|
| 148 | - 'duration' => $video->duration, |
|
| 149 | - ); |
|
| 150 | - |
|
| 151 | - if ( $video->embed_url ) { |
|
| 152 | - $single_jsonld['embedUrl'] = $video->embed_url; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - if ( $video->views ) { |
|
| 156 | - $single_jsonld['interactionStatistic'] = array( |
|
| 157 | - '@type' => 'InteractionCounter', |
|
| 158 | - 'interactionType' => array( |
|
| 159 | - '@type' => 'http://schema.org/WatchAction' |
|
| 160 | - ), |
|
| 161 | - 'userInteractionCount' => $video->views |
|
| 162 | - ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - if ( $video->is_live_video ) { |
|
| 166 | - $single_jsonld['publication'] = array( |
|
| 167 | - '@type' => 'BroadcastEvent', |
|
| 168 | - 'isLiveBroadcast' => true, |
|
| 169 | - 'startDate' => $video->live_video_start_date, |
|
| 170 | - 'endDate' => $video->live_video_end_date |
|
| 171 | - ); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - $jsonld[] = $single_jsonld; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - return $jsonld; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - private function is_associative_array( $arr ) { |
|
| 182 | - if ( array() === $arr ) { |
|
| 183 | - return false; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - return array_keys( $arr ) !== range( 0, count( $arr ) - 1 ); |
|
| 187 | - } |
|
| 15 | + /** |
|
| 16 | + * @var Storage |
|
| 17 | + */ |
|
| 18 | + private $video_storage; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Jsonld constructor. |
|
| 22 | + * |
|
| 23 | + * @param $video_storage Storage |
|
| 24 | + */ |
|
| 25 | + public function __construct( $video_storage ) { |
|
| 26 | + add_action( 'wl_post_jsonld', array( $this, 'wl_post_jsonld' ), 10, 3 ); |
|
| 27 | + add_action( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10, 3 ); |
|
| 28 | + $this->video_storage = $video_storage; |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + public function wl_after_get_jsonld( $jsonld, $post_id, $context ) { |
|
| 33 | + if ( 0 === count( $jsonld ) ) { |
|
| 34 | + return $jsonld; |
|
| 35 | + } |
|
| 36 | + $current_item = $jsonld[0]; |
|
| 37 | + |
|
| 38 | + if ( ! is_array( $current_item ) || ! array_key_exists( '@type', $current_item ) ) { |
|
| 39 | + // Cant determine type return early. |
|
| 40 | + return $jsonld; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + $type = $current_item['@type']; |
|
| 44 | + if ( is_string( $type ) ) { |
|
| 45 | + $type = array( $type ); |
|
| 46 | + } |
|
| 47 | + // If its a article or descendant of article, then dont add the |
|
| 48 | + // videoobject in this hook, they will be already added to video property. |
|
| 49 | + if ( array_intersect( Jsonld_Article_Wrapper::$article_types, $type ) ) { |
|
| 50 | + return $jsonld; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + $videos_jsonld = $this->get_videos_jsonld( $post_id ); |
|
| 54 | + if ( 0 === count( $videos_jsonld ) ) { |
|
| 55 | + return $jsonld; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + // check if we have @id in jsonld for first item. |
|
| 59 | + $id = array_key_exists( '@id', $current_item ) ? $current_item['@id'] : ''; |
|
| 60 | + |
|
| 61 | + foreach ( $videos_jsonld as &$video_jsonld ) { |
|
| 62 | + if ( ! $id ) { |
|
| 63 | + continue; |
|
| 64 | + } |
|
| 65 | + if ( ! array_key_exists( 'mentions', $video_jsonld ) ) { |
|
| 66 | + $video_jsonld['mentions'] = array( '@id' => $id ); |
|
| 67 | + } else { |
|
| 68 | + $video_jsonld['mentions'] = array_merge( $video_jsonld['mentions'], array( '@id' => $id ) ); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + return array_merge( $jsonld, $videos_jsonld ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @param $existing_video_data string | array associative or sequential array. |
|
| 77 | + * @param $new_video_data array Sequential array. |
|
| 78 | + * |
|
| 79 | + * @return array |
|
| 80 | + */ |
|
| 81 | + private function merge_video_data( $existing_video_data, $new_video_data ) { |
|
| 82 | + if ( ! is_array( $existing_video_data ) ) { |
|
| 83 | + $new_video_data[] = $existing_video_data; |
|
| 84 | + |
|
| 85 | + return $new_video_data; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + if ( $this->is_associative_array( $existing_video_data ) ) { |
|
| 89 | + $new_video_data[] = $existing_video_data; |
|
| 90 | + |
|
| 91 | + return $new_video_data; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + return array_merge( $existing_video_data, $new_video_data ); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + public function wl_post_jsonld( $jsonld, $post_id, $references ) { |
|
| 98 | + |
|
| 99 | + $video_jsonld = $this->get_videos_jsonld( $post_id ); |
|
| 100 | + if ( count( $video_jsonld ) === 0 ) { |
|
| 101 | + return $jsonld; |
|
| 102 | + } |
|
| 103 | + // Before adding the video jsonld check if the key |
|
| 104 | + // is present and additional data might be present, |
|
| 105 | + // if not present just add the data and return early. |
|
| 106 | + if ( ! array_key_exists( 'video', $jsonld ) ) { |
|
| 107 | + $jsonld['video'] = $video_jsonld; |
|
| 108 | + |
|
| 109 | + return $jsonld; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + // since key exists, we need to merge the data based on type. |
|
| 113 | + $previous_video_data = $jsonld['video']; |
|
| 114 | + $jsonld['video'] = $this->merge_video_data( $previous_video_data, $video_jsonld ); |
|
| 115 | + |
|
| 116 | + return $jsonld; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @param $post_id int Post id. |
|
| 122 | + * |
|
| 123 | + * @return array |
|
| 124 | + */ |
|
| 125 | + public function get_videos_jsonld( $post_id ) { |
|
| 126 | + |
|
| 127 | + $videos = $this->video_storage->get_all_videos( $post_id ); |
|
| 128 | + |
|
| 129 | + $jsonld = array(); |
|
| 130 | + |
|
| 131 | + foreach ( $videos as $video ) { |
|
| 132 | + /** |
|
| 133 | + * @var $video Video |
|
| 134 | + */ |
|
| 135 | + $description = $video->description; |
|
| 136 | + if ( ! $video->description ) { |
|
| 137 | + // If description is empty then use the video title as description |
|
| 138 | + $description = $video->name; |
|
| 139 | + } |
|
| 140 | + $single_jsonld = array( |
|
| 141 | + '@context' => 'http://schema.org', |
|
| 142 | + '@type' => 'VideoObject', |
|
| 143 | + 'name' => $video->name, |
|
| 144 | + 'description' => $description, |
|
| 145 | + 'contentUrl' => $video->content_url, |
|
| 146 | + 'uploadDate' => $video->upload_date, |
|
| 147 | + 'thumbnailUrl' => $video->thumbnail_urls, |
|
| 148 | + 'duration' => $video->duration, |
|
| 149 | + ); |
|
| 150 | + |
|
| 151 | + if ( $video->embed_url ) { |
|
| 152 | + $single_jsonld['embedUrl'] = $video->embed_url; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + if ( $video->views ) { |
|
| 156 | + $single_jsonld['interactionStatistic'] = array( |
|
| 157 | + '@type' => 'InteractionCounter', |
|
| 158 | + 'interactionType' => array( |
|
| 159 | + '@type' => 'http://schema.org/WatchAction' |
|
| 160 | + ), |
|
| 161 | + 'userInteractionCount' => $video->views |
|
| 162 | + ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + if ( $video->is_live_video ) { |
|
| 166 | + $single_jsonld['publication'] = array( |
|
| 167 | + '@type' => 'BroadcastEvent', |
|
| 168 | + 'isLiveBroadcast' => true, |
|
| 169 | + 'startDate' => $video->live_video_start_date, |
|
| 170 | + 'endDate' => $video->live_video_end_date |
|
| 171 | + ); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + $jsonld[] = $single_jsonld; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + return $jsonld; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + private function is_associative_array( $arr ) { |
|
| 182 | + if ( array() === $arr ) { |
|
| 183 | + return false; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + return array_keys( $arr ) !== range( 0, count( $arr ) - 1 ); |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | |
| 190 | 190 | } |
@@ -22,54 +22,54 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @param $video_storage Storage |
| 24 | 24 | */ |
| 25 | - public function __construct( $video_storage ) { |
|
| 26 | - add_action( 'wl_post_jsonld', array( $this, 'wl_post_jsonld' ), 10, 3 ); |
|
| 27 | - add_action( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10, 3 ); |
|
| 25 | + public function __construct($video_storage) { |
|
| 26 | + add_action('wl_post_jsonld', array($this, 'wl_post_jsonld'), 10, 3); |
|
| 27 | + add_action('wl_after_get_jsonld', array($this, 'wl_after_get_jsonld'), 10, 3); |
|
| 28 | 28 | $this->video_storage = $video_storage; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | - public function wl_after_get_jsonld( $jsonld, $post_id, $context ) { |
|
| 33 | - if ( 0 === count( $jsonld ) ) { |
|
| 32 | + public function wl_after_get_jsonld($jsonld, $post_id, $context) { |
|
| 33 | + if (0 === count($jsonld)) { |
|
| 34 | 34 | return $jsonld; |
| 35 | 35 | } |
| 36 | 36 | $current_item = $jsonld[0]; |
| 37 | 37 | |
| 38 | - if ( ! is_array( $current_item ) || ! array_key_exists( '@type', $current_item ) ) { |
|
| 38 | + if ( ! is_array($current_item) || ! array_key_exists('@type', $current_item)) { |
|
| 39 | 39 | // Cant determine type return early. |
| 40 | 40 | return $jsonld; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $type = $current_item['@type']; |
| 44 | - if ( is_string( $type ) ) { |
|
| 45 | - $type = array( $type ); |
|
| 44 | + if (is_string($type)) { |
|
| 45 | + $type = array($type); |
|
| 46 | 46 | } |
| 47 | 47 | // If its a article or descendant of article, then dont add the |
| 48 | 48 | // videoobject in this hook, they will be already added to video property. |
| 49 | - if ( array_intersect( Jsonld_Article_Wrapper::$article_types, $type ) ) { |
|
| 49 | + if (array_intersect(Jsonld_Article_Wrapper::$article_types, $type)) { |
|
| 50 | 50 | return $jsonld; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $videos_jsonld = $this->get_videos_jsonld( $post_id ); |
|
| 54 | - if ( 0 === count( $videos_jsonld ) ) { |
|
| 53 | + $videos_jsonld = $this->get_videos_jsonld($post_id); |
|
| 54 | + if (0 === count($videos_jsonld)) { |
|
| 55 | 55 | return $jsonld; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // check if we have @id in jsonld for first item. |
| 59 | - $id = array_key_exists( '@id', $current_item ) ? $current_item['@id'] : ''; |
|
| 59 | + $id = array_key_exists('@id', $current_item) ? $current_item['@id'] : ''; |
|
| 60 | 60 | |
| 61 | - foreach ( $videos_jsonld as &$video_jsonld ) { |
|
| 62 | - if ( ! $id ) { |
|
| 61 | + foreach ($videos_jsonld as &$video_jsonld) { |
|
| 62 | + if ( ! $id) { |
|
| 63 | 63 | continue; |
| 64 | 64 | } |
| 65 | - if ( ! array_key_exists( 'mentions', $video_jsonld ) ) { |
|
| 66 | - $video_jsonld['mentions'] = array( '@id' => $id ); |
|
| 65 | + if ( ! array_key_exists('mentions', $video_jsonld)) { |
|
| 66 | + $video_jsonld['mentions'] = array('@id' => $id); |
|
| 67 | 67 | } else { |
| 68 | - $video_jsonld['mentions'] = array_merge( $video_jsonld['mentions'], array( '@id' => $id ) ); |
|
| 68 | + $video_jsonld['mentions'] = array_merge($video_jsonld['mentions'], array('@id' => $id)); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - return array_merge( $jsonld, $videos_jsonld ); |
|
| 72 | + return array_merge($jsonld, $videos_jsonld); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,32 +78,32 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @return array |
| 80 | 80 | */ |
| 81 | - private function merge_video_data( $existing_video_data, $new_video_data ) { |
|
| 82 | - if ( ! is_array( $existing_video_data ) ) { |
|
| 81 | + private function merge_video_data($existing_video_data, $new_video_data) { |
|
| 82 | + if ( ! is_array($existing_video_data)) { |
|
| 83 | 83 | $new_video_data[] = $existing_video_data; |
| 84 | 84 | |
| 85 | 85 | return $new_video_data; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ( $this->is_associative_array( $existing_video_data ) ) { |
|
| 88 | + if ($this->is_associative_array($existing_video_data)) { |
|
| 89 | 89 | $new_video_data[] = $existing_video_data; |
| 90 | 90 | |
| 91 | 91 | return $new_video_data; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return array_merge( $existing_video_data, $new_video_data ); |
|
| 94 | + return array_merge($existing_video_data, $new_video_data); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function wl_post_jsonld( $jsonld, $post_id, $references ) { |
|
| 97 | + public function wl_post_jsonld($jsonld, $post_id, $references) { |
|
| 98 | 98 | |
| 99 | - $video_jsonld = $this->get_videos_jsonld( $post_id ); |
|
| 100 | - if ( count( $video_jsonld ) === 0 ) { |
|
| 99 | + $video_jsonld = $this->get_videos_jsonld($post_id); |
|
| 100 | + if (count($video_jsonld) === 0) { |
|
| 101 | 101 | return $jsonld; |
| 102 | 102 | } |
| 103 | 103 | // Before adding the video jsonld check if the key |
| 104 | 104 | // is present and additional data might be present, |
| 105 | 105 | // if not present just add the data and return early. |
| 106 | - if ( ! array_key_exists( 'video', $jsonld ) ) { |
|
| 106 | + if ( ! array_key_exists('video', $jsonld)) { |
|
| 107 | 107 | $jsonld['video'] = $video_jsonld; |
| 108 | 108 | |
| 109 | 109 | return $jsonld; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | // since key exists, we need to merge the data based on type. |
| 113 | 113 | $previous_video_data = $jsonld['video']; |
| 114 | - $jsonld['video'] = $this->merge_video_data( $previous_video_data, $video_jsonld ); |
|
| 114 | + $jsonld['video'] = $this->merge_video_data($previous_video_data, $video_jsonld); |
|
| 115 | 115 | |
| 116 | 116 | return $jsonld; |
| 117 | 117 | } |
@@ -122,18 +122,18 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @return array |
| 124 | 124 | */ |
| 125 | - public function get_videos_jsonld( $post_id ) { |
|
| 125 | + public function get_videos_jsonld($post_id) { |
|
| 126 | 126 | |
| 127 | - $videos = $this->video_storage->get_all_videos( $post_id ); |
|
| 127 | + $videos = $this->video_storage->get_all_videos($post_id); |
|
| 128 | 128 | |
| 129 | 129 | $jsonld = array(); |
| 130 | 130 | |
| 131 | - foreach ( $videos as $video ) { |
|
| 131 | + foreach ($videos as $video) { |
|
| 132 | 132 | /** |
| 133 | 133 | * @var $video Video |
| 134 | 134 | */ |
| 135 | 135 | $description = $video->description; |
| 136 | - if ( ! $video->description ) { |
|
| 136 | + if ( ! $video->description) { |
|
| 137 | 137 | // If description is empty then use the video title as description |
| 138 | 138 | $description = $video->name; |
| 139 | 139 | } |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | 'duration' => $video->duration, |
| 149 | 149 | ); |
| 150 | 150 | |
| 151 | - if ( $video->embed_url ) { |
|
| 151 | + if ($video->embed_url) { |
|
| 152 | 152 | $single_jsonld['embedUrl'] = $video->embed_url; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if ( $video->views ) { |
|
| 155 | + if ($video->views) { |
|
| 156 | 156 | $single_jsonld['interactionStatistic'] = array( |
| 157 | 157 | '@type' => 'InteractionCounter', |
| 158 | 158 | 'interactionType' => array( |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | ); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( $video->is_live_video ) { |
|
| 165 | + if ($video->is_live_video) { |
|
| 166 | 166 | $single_jsonld['publication'] = array( |
| 167 | 167 | '@type' => 'BroadcastEvent', |
| 168 | 168 | 'isLiveBroadcast' => true, |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | |
| 181 | - private function is_associative_array( $arr ) { |
|
| 182 | - if ( array() === $arr ) { |
|
| 181 | + private function is_associative_array($arr) { |
|
| 182 | + if (array() === $arr) { |
|
| 183 | 183 | return false; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - return array_keys( $arr ) !== range( 0, count( $arr ) - 1 ); |
|
| 186 | + return array_keys($arr) !== range(0, count($arr) - 1); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <!-- Pane 4 content --> |
| 2 | 2 | <script type="text/html" id="page-3"> |
| 3 | 3 | <h2 class="page-title"> |
| 4 | - <?php esc_html_e( 'Vocabulary', 'wordlift' ); ?> |
|
| 4 | + <?php esc_html_e('Vocabulary', 'wordlift'); ?> |
|
| 5 | 5 | </h2> |
| 6 | 6 | |
| 7 | 7 | <p class="page-txt"> |
| 8 | - <?php esc_html_e( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field below. Check our FAQs if you need more info.', 'wordlift' ); ?> |
|
| 8 | + <?php esc_html_e('All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field below. Check our FAQs if you need more info.', 'wordlift'); ?> |
|
| 9 | 9 | </p> |
| 10 | 10 | |
| 11 | 11 | <input |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | > |
| 20 | 20 | |
| 21 | 21 | <p class="page-det"> |
| 22 | - <?php esc_html_e( 'Leave it empty to place your entities in the root folder of your website', 'wordlift' ); ?> |
|
| 23 | - <?php esc_html_e( ' (requires the permalink settings to be set to Post name)', 'wordlift' ); ?> |
|
| 22 | + <?php esc_html_e('Leave it empty to place your entities in the root folder of your website', 'wordlift'); ?> |
|
| 23 | + <?php esc_html_e(' (requires the permalink settings to be set to Post name)', 'wordlift'); ?> |
|
| 24 | 24 | </p> |
| 25 | 25 | |
| 26 | 26 | <div class="btn-wrapper"> |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | type="button" |
| 29 | 29 | data-wl-next="wl-next" |
| 30 | 30 | class="wl-default-action" |
| 31 | - value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>" |
|
| 31 | + value="<?php esc_attr_e('Next', 'wordlift'); ?>" |
|
| 32 | 32 | > |
| 33 | 33 | </div> |
| 34 | 34 | </script> |
@@ -6,22 +6,22 @@ |
||
| 6 | 6 | |
| 7 | 7 | <p class="page-txt"> |
| 8 | 8 | <?php |
| 9 | - $grab_a_key_link_html = sprintf( |
|
| 10 | - '<a target="_blank" href="%s">%s</a>', |
|
| 11 | - esc_attr__( 'https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift' ), |
|
| 12 | - esc_html__( 'grab a key', 'wordlift' ) |
|
| 13 | - ); |
|
| 9 | + $grab_a_key_link_html = sprintf( |
|
| 10 | + '<a target="_blank" href="%s">%s</a>', |
|
| 11 | + esc_attr__( 'https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift' ), |
|
| 12 | + esc_html__( 'grab a key', 'wordlift' ) |
|
| 13 | + ); |
|
| 14 | 14 | |
| 15 | - echo sprintf( |
|
| 16 | - esc_html__( |
|
| 17 | - 'If you already purchased a plan, check your email, get the' |
|
| 18 | - . ' activation key from your inbox and insert it in the' |
|
| 19 | - . ' field below. Otherwise %s!', |
|
| 20 | - 'wordlift' |
|
| 21 | - ), |
|
| 22 | - $grab_a_key_link_html |
|
| 23 | - ); |
|
| 24 | - ?> |
|
| 15 | + echo sprintf( |
|
| 16 | + esc_html__( |
|
| 17 | + 'If you already purchased a plan, check your email, get the' |
|
| 18 | + . ' activation key from your inbox and insert it in the' |
|
| 19 | + . ' field below. Otherwise %s!', |
|
| 20 | + 'wordlift' |
|
| 21 | + ), |
|
| 22 | + $grab_a_key_link_html |
|
| 23 | + ); |
|
| 24 | + ?> |
|
| 25 | 25 | </p> |
| 26 | 26 | <input |
| 27 | 27 | type="text" |
@@ -1,15 +1,15 @@ discard block |
||
| 1 | 1 | <!-- Pane 3 content --> |
| 2 | 2 | <script type="text/html" id="page-2"> |
| 3 | 3 | <h2 class="page-title"> |
| 4 | - <?php esc_html_e( 'License Key', 'wordlift' ); ?> |
|
| 4 | + <?php esc_html_e('License Key', 'wordlift'); ?> |
|
| 5 | 5 | </h2> |
| 6 | 6 | |
| 7 | 7 | <p class="page-txt"> |
| 8 | 8 | <?php |
| 9 | 9 | $grab_a_key_link_html = sprintf( |
| 10 | 10 | '<a target="_blank" href="%s">%s</a>', |
| 11 | - esc_attr__( 'https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift' ), |
|
| 12 | - esc_html__( 'grab a key', 'wordlift' ) |
|
| 11 | + esc_attr__('https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift'), |
|
| 12 | + esc_html__('grab a key', 'wordlift') |
|
| 13 | 13 | ); |
| 14 | 14 | |
| 15 | 15 | echo sprintf( |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | name="key" |
| 32 | 32 | value="" |
| 33 | 33 | autocomplete="off" |
| 34 | - placeholder="<?php echo esc_attr_x( 'License Key', 'Input text placeholder', 'wordlift' ); ?>" |
|
| 34 | + placeholder="<?php echo esc_attr_x('License Key', 'Input text placeholder', 'wordlift'); ?>" |
|
| 35 | 35 | > |
| 36 | 36 | <div> |
| 37 | 37 | <p class="wl-val-key-error"> |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | target="_tab" |
| 45 | 45 | class="button wl-default-action" |
| 46 | 46 | > |
| 47 | - <?php esc_html_e( 'Grab a Key!', 'wordlift' ); ?> |
|
| 47 | + <?php esc_html_e('Grab a Key!', 'wordlift'); ?> |
|
| 48 | 48 | </a> |
| 49 | 49 | |
| 50 | 50 | <input |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | type="button" |
| 53 | 53 | data-wl-next="wl-next" |
| 54 | 54 | class="button" |
| 55 | - value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>" |
|
| 55 | + value="<?php esc_attr_e('Next', 'wordlift'); ?>" |
|
| 56 | 56 | > |
| 57 | 57 | </div> |
| 58 | 58 | </script> |
@@ -1,42 +1,42 @@ discard block |
||
| 1 | 1 | <!-- Pane 1 content --> |
| 2 | 2 | <script type="text/html" id="page-0"> |
| 3 | 3 | <h2 class="page-title"> |
| 4 | - <?php esc_html_e( 'Welcome', 'wordlift' ); ?> |
|
| 4 | + <?php esc_html_e('Welcome', 'wordlift'); ?> |
|
| 5 | 5 | </h2> |
| 6 | 6 | |
| 7 | 7 | <p class="page-txt"> |
| 8 | - <?php esc_html_e( 'Thank you for downloading WordLift. Now you can boost your website with a double-digit growth. WordLift helps you with:', 'wordlift' ); ?> |
|
| 8 | + <?php esc_html_e('Thank you for downloading WordLift. Now you can boost your website with a double-digit growth. WordLift helps you with:', 'wordlift'); ?> |
|
| 9 | 9 | </p> |
| 10 | 10 | |
| 11 | 11 | <ul class="page-list"> |
| 12 | 12 | <li> |
| 13 | 13 | <span class="fa fa-university"></span> |
| 14 | - <?php esc_html_e( 'Trustworthiness', 'wordlift' ); ?> |
|
| 14 | + <?php esc_html_e('Trustworthiness', 'wordlift'); ?> |
|
| 15 | 15 | </li> |
| 16 | 16 | |
| 17 | 17 | <li> |
| 18 | 18 | <span class="fa fa-map-marker"></span> |
| 19 | - <?php esc_html_e( 'Enrichment', 'wordlift' ); ?> |
|
| 19 | + <?php esc_html_e('Enrichment', 'wordlift'); ?> |
|
| 20 | 20 | </li> |
| 21 | 21 | |
| 22 | 22 | <li> |
| 23 | 23 | <span class="fa fa-heart"></span> |
| 24 | - <?php esc_html_e( 'Engagement', 'wordlift' ); ?> |
|
| 24 | + <?php esc_html_e('Engagement', 'wordlift'); ?> |
|
| 25 | 25 | </li> |
| 26 | 26 | |
| 27 | 27 | <li> |
| 28 | 28 | <span class="fa fa-hand-o-right"></span> |
| 29 | - <?php esc_html_e( 'Smart Navigation', 'wordlift' ); ?> |
|
| 29 | + <?php esc_html_e('Smart Navigation', 'wordlift'); ?> |
|
| 30 | 30 | </li> |
| 31 | 31 | |
| 32 | 32 | <li> |
| 33 | 33 | <span class="fa fa-google"></span> |
| 34 | - <?php esc_html_e( 'SEO Optimization', 'wordlift' ); ?> |
|
| 34 | + <?php esc_html_e('SEO Optimization', 'wordlift'); ?> |
|
| 35 | 35 | </li> |
| 36 | 36 | |
| 37 | 37 | <li> |
| 38 | 38 | <span class="fa fa-group"></span> |
| 39 | - <?php esc_html_e( 'Content Marketing', 'wordlift' ); ?> |
|
| 39 | + <?php esc_html_e('Content Marketing', 'wordlift'); ?> |
|
| 40 | 40 | </li> |
| 41 | 41 | </ul> |
| 42 | 42 | |
@@ -46,13 +46,13 @@ discard block |
||
| 46 | 46 | target="_tab" |
| 47 | 47 | class="button" |
| 48 | 48 | > |
| 49 | - <?php esc_html_e( 'Learn More', 'wordlift' ); ?> |
|
| 49 | + <?php esc_html_e('Learn More', 'wordlift'); ?> |
|
| 50 | 50 | </a> |
| 51 | 51 | <input |
| 52 | 52 | type="button" |
| 53 | 53 | data-wl-next="wl-next" |
| 54 | 54 | class="wl-default-action" |
| 55 | - value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>" |
|
| 55 | + value="<?php esc_attr_e('Next', 'wordlift'); ?>" |
|
| 56 | 56 | > |
| 57 | 57 | </div> |
| 58 | 58 | </script> |
| 59 | 59 | \ No newline at end of file |