@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @since 3.20.0 |
| 52 | 52 | */ |
| 53 | - public function __construct( $entity_uri_service, $post_id_to_jsonld_converter ) { |
|
| 53 | + public function __construct($entity_uri_service, $post_id_to_jsonld_converter) { |
|
| 54 | 54 | |
| 55 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
| 55 | + add_action('wp_head', array($this, 'wp_head')); |
|
| 56 | 56 | |
| 57 | 57 | $this->entity_uri_service = $entity_uri_service; |
| 58 | 58 | $this->post_id_to_jsonld_converter = $post_id_to_jsonld_converter; |
@@ -74,31 +74,31 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return array|boolean |
| 76 | 76 | */ |
| 77 | - public function get_carousel_jsonld( $id = null ) { |
|
| 78 | - $posts = $this->get_posts( $id ); |
|
| 77 | + public function get_carousel_jsonld($id = null) { |
|
| 78 | + $posts = $this->get_posts($id); |
|
| 79 | 79 | $post_jsonld = array(); |
| 80 | - if ( ! is_array( $posts ) || count( $posts ) < 2 ) { |
|
| 80 | + if ( ! is_array($posts) || count($posts) < 2) { |
|
| 81 | 81 | // Bail out if no posts are present. |
| 82 | 82 | return false; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if ( $id !== null ) { |
|
| 86 | - $term = get_term( $id ); |
|
| 87 | - $post_jsonld['description'] = wp_strip_all_tags( strip_shortcodes( $term->description ) ); |
|
| 88 | - $thumbnail_id = get_term_meta( $id, 'thumbnail_id', true ); |
|
| 89 | - if ( ! empty( $thumbnail_id ) ) { |
|
| 90 | - $post_jsonld['image'] = wp_get_attachment_url( $thumbnail_id ); |
|
| 85 | + if ($id !== null) { |
|
| 86 | + $term = get_term($id); |
|
| 87 | + $post_jsonld['description'] = wp_strip_all_tags(strip_shortcodes($term->description)); |
|
| 88 | + $thumbnail_id = get_term_meta($id, 'thumbnail_id', true); |
|
| 89 | + if ( ! empty($thumbnail_id)) { |
|
| 90 | + $post_jsonld['image'] = wp_get_attachment_url($thumbnail_id); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // More than 2 items are present, so construct the post_jsonld data |
| 95 | 95 | $post_jsonld['@context'] = 'https://schema.org'; |
| 96 | 96 | $post_jsonld['@type'] = 'ItemList'; |
| 97 | - $post_jsonld['url'] = $this->get_term_url( $id ); |
|
| 97 | + $post_jsonld['url'] = $this->get_term_url($id); |
|
| 98 | 98 | $post_jsonld['itemListElement'] = array(); |
| 99 | 99 | $position = 1; |
| 100 | 100 | |
| 101 | - foreach ( $posts as $post_id ) { |
|
| 101 | + foreach ($posts as $post_id) { |
|
| 102 | 102 | $result = array( |
| 103 | 103 | '@type' => 'ListItem', |
| 104 | 104 | 'position' => $position, |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * See https://developers.google.com/search/docs/data-types/carousel |
| 109 | 109 | */ |
| 110 | - 'url' => apply_filters( 'wl_carousel_post_list_item_url', get_permalink( $post_id ), $post_id ), |
|
| 110 | + 'url' => apply_filters('wl_carousel_post_list_item_url', get_permalink($post_id), $post_id), |
|
| 111 | 111 | ); |
| 112 | - array_push( $post_jsonld['itemListElement'], $result ); |
|
| 113 | - ++ $position; |
|
| 112 | + array_push($post_jsonld['itemListElement'], $result); |
|
| 113 | + ++$position; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | return $post_jsonld; |
@@ -123,25 +123,25 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return array|int[]|string[]|WP_Error|null |
| 125 | 125 | */ |
| 126 | - private function get_posts( $id ) { |
|
| 126 | + private function get_posts($id) { |
|
| 127 | 127 | global $wp_query; |
| 128 | 128 | |
| 129 | - if ( $wp_query->posts !== null ) { |
|
| 129 | + if ($wp_query->posts !== null) { |
|
| 130 | 130 | return array_map( |
| 131 | - function ( $post ) { |
|
| 131 | + function($post) { |
|
| 132 | 132 | return $post->ID; |
| 133 | 133 | }, |
| 134 | 134 | $wp_query->posts |
| 135 | 135 | ); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - if ( $id === null ) { |
|
| 138 | + if ($id === null) { |
|
| 139 | 139 | return null; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $term = get_term( $id ); |
|
| 142 | + $term = get_term($id); |
|
| 143 | 143 | |
| 144 | - return get_objects_in_term( $id, $term->taxonomy ); |
|
| 144 | + return get_objects_in_term($id, $term->taxonomy); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -153,28 +153,28 @@ discard block |
||
| 153 | 153 | $query_object = get_queried_object(); |
| 154 | 154 | |
| 155 | 155 | // Check if it is a term page. |
| 156 | - if ( ! $query_object instanceof WP_Term ) { |
|
| 156 | + if ( ! $query_object instanceof WP_Term) { |
|
| 157 | 157 | return; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Bail out if `wl_jsonld_enabled` isn't enabled. |
| 161 | - if ( ! apply_filters( 'wl_jsonld_enabled', true ) ) { |
|
| 161 | + if ( ! apply_filters('wl_jsonld_enabled', true)) { |
|
| 162 | 162 | return; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $term_id = $query_object->term_id; |
| 166 | 166 | |
| 167 | - $jsonld = $this->get( $term_id, Jsonld_Context_Enum::PAGE ); |
|
| 167 | + $jsonld = $this->get($term_id, Jsonld_Context_Enum::PAGE); |
|
| 168 | 168 | |
| 169 | 169 | // Bail out if the JSON-LD is empty. |
| 170 | - if ( empty( $jsonld ) ) { |
|
| 170 | + if (empty($jsonld)) { |
|
| 171 | 171 | return; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - $jsonld_string = wp_json_encode( $jsonld ); |
|
| 174 | + $jsonld_string = wp_json_encode($jsonld); |
|
| 175 | 175 | |
| 176 | - $jsonld_term_html_output = '<script type="application/ld+json" id="wl-jsonld-term">' . $jsonld_string . '</script>'; |
|
| 177 | - $jsonld_term_html_output = apply_filters( 'wl_jsonld_term_html_output', $jsonld_term_html_output, $term_id ); |
|
| 176 | + $jsonld_term_html_output = '<script type="application/ld+json" id="wl-jsonld-term">'.$jsonld_string.'</script>'; |
|
| 177 | + $jsonld_term_html_output = apply_filters('wl_jsonld_term_html_output', $jsonld_term_html_output, $term_id); |
|
| 178 | 178 | |
| 179 | 179 | echo $jsonld_term_html_output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- It's an application/ld+json output. |
| 180 | 180 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @return array |
| 191 | 191 | */ |
| 192 | - public function get( $id, $context, $is_recursive_call = false ) { |
|
| 192 | + public function get($id, $context, $is_recursive_call = false) { |
|
| 193 | 193 | /** |
| 194 | 194 | * Support for carousel rich snippet, get jsonld data present |
| 195 | 195 | * for all the posts shown in the term page, and add the jsonld data |
@@ -201,17 +201,17 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | $jsonld_array = array(); |
| 203 | 203 | |
| 204 | - if ( Jsonld_Context_Enum::PAGE === $context ) { |
|
| 205 | - $carousel_data = $this->get_carousel_jsonld( $id ); |
|
| 206 | - if ( $carousel_data ) { |
|
| 204 | + if (Jsonld_Context_Enum::PAGE === $context) { |
|
| 205 | + $carousel_data = $this->get_carousel_jsonld($id); |
|
| 206 | + if ($carousel_data) { |
|
| 207 | 207 | $jsonld_array[] = $carousel_data; |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - $entities_jsonld_array = $this->get_entity_jsonld( $id, $context ); |
|
| 211 | + $entities_jsonld_array = $this->get_entity_jsonld($id, $context); |
|
| 212 | 212 | |
| 213 | 213 | $result = array( |
| 214 | - 'jsonld' => array_merge( $jsonld_array, $entities_jsonld_array ), |
|
| 214 | + 'jsonld' => array_merge($jsonld_array, $entities_jsonld_array), |
|
| 215 | 215 | 'references' => array(), |
| 216 | 216 | ); |
| 217 | 217 | |
@@ -222,20 +222,20 @@ discard block |
||
| 222 | 222 | * @var $jsonld_array array An array containing jsonld for term and entities. |
| 223 | 223 | * @var $context int A context for the JSON-LD generation, valid values in Jsonld_Context_Enum |
| 224 | 224 | */ |
| 225 | - $arr = apply_filters( 'wl_term_jsonld_array', $result, $id, $context ); |
|
| 225 | + $arr = apply_filters('wl_term_jsonld_array', $result, $id, $context); |
|
| 226 | 226 | |
| 227 | 227 | $references = array(); |
| 228 | 228 | |
| 229 | 229 | // Don't expand nested references, it will lead to an infinite loop. |
| 230 | - if ( ! $is_recursive_call ) { |
|
| 230 | + if ( ! $is_recursive_call) { |
|
| 231 | 231 | /** |
| 232 | 232 | * @since 3.32.0 |
| 233 | 233 | * Expand the references returned by this filter. |
| 234 | 234 | */ |
| 235 | - $references = $this->expand_references( $arr['references'] ); |
|
| 235 | + $references = $this->expand_references($arr['references']); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - $jsonld_array = array_merge( $arr['jsonld'], $references ); |
|
| 238 | + $jsonld_array = array_merge($arr['jsonld'], $references); |
|
| 239 | 239 | |
| 240 | 240 | return $jsonld_array; |
| 241 | 241 | } |
@@ -247,17 +247,17 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return array|false|int|mixed|string|WP_Error|WP_Term|null |
| 249 | 249 | */ |
| 250 | - private function get_term_url( $id ) { |
|
| 251 | - if ( null === $id ) { |
|
| 252 | - return isset( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_URL ) : ''; |
|
| 250 | + private function get_term_url($id) { |
|
| 251 | + if (null === $id) { |
|
| 252 | + return isset($_SERVER['REQUEST_URI']) ? filter_var(wp_unslash($_SERVER['REQUEST_URI']), FILTER_SANITIZE_URL) : ''; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - $maybe_url = get_term_meta( $id, Wordlift_Url_Property_Service::META_KEY, true ); |
|
| 256 | - if ( ! empty( $maybe_url ) ) { |
|
| 255 | + $maybe_url = get_term_meta($id, Wordlift_Url_Property_Service::META_KEY, true); |
|
| 256 | + if ( ! empty($maybe_url)) { |
|
| 257 | 257 | return $maybe_url; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - return get_term_link( $id ); |
|
| 260 | + return get_term_link($id); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -269,30 +269,30 @@ discard block |
||
| 269 | 269 | * @return array |
| 270 | 270 | */ |
| 271 | 271 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 272 | - private function get_entity_jsonld( $term_id, $context ) { |
|
| 272 | + private function get_entity_jsonld($term_id, $context) { |
|
| 273 | 273 | |
| 274 | 274 | // The `_wl_entity_id` are URIs. |
| 275 | - $entity_ids = get_term_meta( $term_id, '_wl_entity_id' ); |
|
| 275 | + $entity_ids = get_term_meta($term_id, '_wl_entity_id'); |
|
| 276 | 276 | $entity_uri_service = $this->entity_uri_service; |
| 277 | 277 | |
| 278 | 278 | $wordlift_jsonld_service = Wordlift_Jsonld_Service::get_instance(); |
| 279 | 279 | |
| 280 | 280 | $local_entity_ids = array_filter( |
| 281 | 281 | $entity_ids, |
| 282 | - function ( $uri ) use ( $entity_uri_service ) { |
|
| 283 | - return $entity_uri_service->is_internal( $uri ); |
|
| 282 | + function($uri) use ($entity_uri_service) { |
|
| 283 | + return $entity_uri_service->is_internal($uri); |
|
| 284 | 284 | } |
| 285 | 285 | ); |
| 286 | 286 | |
| 287 | 287 | // Bail out if there are no entities. |
| 288 | - if ( empty( $local_entity_ids ) ) { |
|
| 288 | + if (empty($local_entity_ids)) { |
|
| 289 | 289 | return array(); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - $post = $this->entity_uri_service->get_entity( array_shift( $local_entity_ids ) ); |
|
| 293 | - $entities_jsonld = $wordlift_jsonld_service->get_jsonld( false, $post->ID ); |
|
| 292 | + $post = $this->entity_uri_service->get_entity(array_shift($local_entity_ids)); |
|
| 293 | + $entities_jsonld = $wordlift_jsonld_service->get_jsonld(false, $post->ID); |
|
| 294 | 294 | // Reset the `url` to the term page. |
| 295 | - $entities_jsonld[0]['url'] = get_term_link( $term_id ); |
|
| 295 | + $entities_jsonld[0]['url'] = get_term_link($term_id); |
|
| 296 | 296 | |
| 297 | 297 | return $entities_jsonld; |
| 298 | 298 | } |
@@ -302,24 +302,24 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @return array |
| 304 | 304 | */ |
| 305 | - private function expand_references( $references ) { |
|
| 306 | - if ( ! is_array( $references ) ) { |
|
| 305 | + private function expand_references($references) { |
|
| 306 | + if ( ! is_array($references)) { |
|
| 307 | 307 | return array(); |
| 308 | 308 | } |
| 309 | 309 | $references_jsonld = array(); |
| 310 | 310 | // Expand the references. |
| 311 | - foreach ( $references as $reference ) { |
|
| 312 | - if ( $reference instanceof Term_Reference ) { |
|
| 311 | + foreach ($references as $reference) { |
|
| 312 | + if ($reference instanceof Term_Reference) { |
|
| 313 | 313 | // Second level references won't be expanded. |
| 314 | - $references_jsonld[] = current( $this->get( $reference->get_id(), Jsonld_Context_Enum::UNKNOWN, true ) ); |
|
| 315 | - } elseif ( is_numeric( $reference ) ) { |
|
| 314 | + $references_jsonld[] = current($this->get($reference->get_id(), Jsonld_Context_Enum::UNKNOWN, true)); |
|
| 315 | + } elseif (is_numeric($reference)) { |
|
| 316 | 316 | $ref_2 = array(); |
| 317 | 317 | $ref_info_2 = array(); |
| 318 | - $references_jsonld[] = $this->post_id_to_jsonld_converter->convert( $reference, $ref_2, $ref_info_2, new Relations() ); |
|
| 319 | - } elseif ( $reference instanceof Post_Reference ) { |
|
| 318 | + $references_jsonld[] = $this->post_id_to_jsonld_converter->convert($reference, $ref_2, $ref_info_2, new Relations()); |
|
| 319 | + } elseif ($reference instanceof Post_Reference) { |
|
| 320 | 320 | $ref_2 = array(); |
| 321 | 321 | $ref_info_2 = array(); |
| 322 | - $references_jsonld[] = $this->post_id_to_jsonld_converter->convert( $reference->get_id(), $ref_2, $ref_info_2, new Relations() ); |
|
| 322 | + $references_jsonld[] = $this->post_id_to_jsonld_converter->convert($reference->get_id(), $ref_2, $ref_info_2, new Relations()); |
|
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @since 3.8.0 |
| 259 | 259 | */ |
| 260 | - public function __construct( $entity_service, $converter, $website_converter, $term_jsonld_adapter ) { |
|
| 260 | + public function __construct($entity_service, $converter, $website_converter, $term_jsonld_adapter) { |
|
| 261 | 261 | $this->entity_service = $entity_service; |
| 262 | 262 | $this->converter = $converter; |
| 263 | 263 | $this->website_converter = $website_converter; |
@@ -290,11 +290,11 @@ discard block |
||
| 290 | 290 | @ob_clean(); |
| 291 | 291 | |
| 292 | 292 | // Get the parameter from the request. |
| 293 | - $is_homepage = isset( $_REQUEST['homepage'] ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 294 | - $post_id = isset( $_REQUEST['id'] ) && is_numeric( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : null; //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 293 | + $is_homepage = isset($_REQUEST['homepage']); //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 294 | + $post_id = isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ? intval($_REQUEST['id']) : null; //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 295 | 295 | |
| 296 | 296 | // Send the generated JSON-LD. |
| 297 | - $this->send_jsonld( $this->get_jsonld( $is_homepage, $post_id ) ); |
|
| 297 | + $this->send_jsonld($this->get_jsonld($is_homepage, $post_id)); |
|
| 298 | 298 | |
| 299 | 299 | } |
| 300 | 300 | |
@@ -306,11 +306,11 @@ discard block |
||
| 306 | 306 | * |
| 307 | 307 | * @since 3.18.5 |
| 308 | 308 | */ |
| 309 | - private function send_jsonld( $response ) { |
|
| 309 | + private function send_jsonld($response) { |
|
| 310 | 310 | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
| 311 | - @header( 'Content-Type: application/ld+json; charset=' . get_option( 'blog_charset' ) ); |
|
| 312 | - echo wp_json_encode( $response ); |
|
| 313 | - if ( apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
| 311 | + @header('Content-Type: application/ld+json; charset='.get_option('blog_charset')); |
|
| 312 | + echo wp_json_encode($response); |
|
| 313 | + if (apply_filters('wp_doing_ajax', defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 314 | 314 | wp_die(); |
| 315 | 315 | } else { |
| 316 | 316 | die; |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * @return array A JSON-LD structure. |
| 328 | 328 | * @since 3.15.1 |
| 329 | 329 | */ |
| 330 | - public function get_jsonld( $is_homepage = false, $post_id = null, $context = Jsonld_Context_Enum::UNKNOWN ) { |
|
| 330 | + public function get_jsonld($is_homepage = false, $post_id = null, $context = Jsonld_Context_Enum::UNKNOWN) { |
|
| 331 | 331 | // Tell NewRelic to ignore us, otherwise NewRelic customers might receive |
| 332 | 332 | // e-mails with a low apdex score. |
| 333 | 333 | // |
@@ -335,14 +335,14 @@ discard block |
||
| 335 | 335 | Wordlift_NewRelic_Adapter::ignore_apdex(); |
| 336 | 336 | |
| 337 | 337 | // Switch to Website converter if is home page. |
| 338 | - if ( $is_homepage ) { |
|
| 338 | + if ($is_homepage) { |
|
| 339 | 339 | /** |
| 340 | 340 | * Filter: 'wordlift_disable_website_json_ld' - Allow disabling of the json+ld output. |
| 341 | 341 | * |
| 342 | 342 | * @since 3.14.0 |
| 343 | 343 | * @api bool $display_search Whether or not to display json+ld search on the frontend. |
| 344 | 344 | */ |
| 345 | - if ( apply_filters( 'wordlift_disable_website_json_ld', false ) ) { |
|
| 345 | + if (apply_filters('wordlift_disable_website_json_ld', false)) { |
|
| 346 | 346 | return array(); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | // If no id has been provided return an empty array. |
| 357 | - if ( ! isset( $post_id ) ) { |
|
| 357 | + if ( ! isset($post_id)) { |
|
| 358 | 358 | return array(); |
| 359 | 359 | } |
| 360 | 360 | |
@@ -367,32 +367,32 @@ discard block |
||
| 367 | 367 | $entity_to_jsonld_converter = $this->converter; |
| 368 | 368 | |
| 369 | 369 | $relations = new Relations(); |
| 370 | - $jsonld = $entity_to_jsonld_converter->convert( $post_id, $references, $references_infos, $relations ); |
|
| 370 | + $jsonld = $entity_to_jsonld_converter->convert($post_id, $references, $references_infos, $relations); |
|
| 371 | 371 | |
| 372 | - $graph = new Graph( $jsonld, $entity_to_jsonld_converter, Wordlift_Term_JsonLd_Adapter::get_instance() ); |
|
| 372 | + $graph = new Graph($jsonld, $entity_to_jsonld_converter, Wordlift_Term_JsonLd_Adapter::get_instance()); |
|
| 373 | 373 | |
| 374 | - $schema_type = is_array( $jsonld['@type'] ) ? $jsonld['@type'] : array( $jsonld['@type'] ); |
|
| 374 | + $schema_type = is_array($jsonld['@type']) ? $jsonld['@type'] : array($jsonld['@type']); |
|
| 375 | 375 | |
| 376 | 376 | // Add `about`/`mentions` only for `CreativeWork` and descendants. |
| 377 | - if ( array_intersect( $schema_type, self::$creative_work_types ) ) { |
|
| 377 | + if (array_intersect($schema_type, self::$creative_work_types)) { |
|
| 378 | 378 | |
| 379 | - foreach ( $relations->toArray() as $relation ) { |
|
| 379 | + foreach ($relations->toArray() as $relation) { |
|
| 380 | 380 | |
| 381 | 381 | // Setting about or mentions by label match is currently supported only for posts |
| 382 | - if ( Object_Type_Enum::POST !== $relation->get_object()->get_type() ) { |
|
| 382 | + if (Object_Type_Enum::POST !== $relation->get_object()->get_type()) { |
|
| 383 | 383 | continue; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | // Add the `mentions`/`about` prop. |
| 387 | - $this->add_mention_or_about( $jsonld, $post_id, $relation ); |
|
| 387 | + $this->add_mention_or_about($jsonld, $post_id, $relation); |
|
| 388 | 388 | } |
| 389 | - $graph->set_main_jsonld( $jsonld ); |
|
| 389 | + $graph->set_main_jsonld($jsonld); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - $jsonld_arr = $graph->add_references( $references ) |
|
| 393 | - ->add_relations( $relations ) |
|
| 394 | - ->add_required_reference_infos( $references_infos ) |
|
| 395 | - ->render( $context ); |
|
| 392 | + $jsonld_arr = $graph->add_references($references) |
|
| 393 | + ->add_relations($relations) |
|
| 394 | + ->add_required_reference_infos($references_infos) |
|
| 395 | + ->render($context); |
|
| 396 | 396 | |
| 397 | 397 | /** |
| 398 | 398 | * Filter name: wl_after_get_jsonld |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | * @var $jsonld_arr array The final jsonld before outputting to page. |
| 403 | 403 | * @var $post_id int The post id for which the jsonld is generated. |
| 404 | 404 | */ |
| 405 | - $jsonld_arr = apply_filters( 'wl_after_get_jsonld', $jsonld_arr, $post_id, $context ); |
|
| 405 | + $jsonld_arr = apply_filters('wl_after_get_jsonld', $jsonld_arr, $post_id, $context); |
|
| 406 | 406 | |
| 407 | 407 | return $jsonld_arr; |
| 408 | 408 | } |
@@ -421,9 +421,9 @@ discard block |
||
| 421 | 421 | $is_homepage = is_home() || is_front_page(); |
| 422 | 422 | $post_id = is_singular() ? get_the_ID() : null; |
| 423 | 423 | |
| 424 | - $jsonld = wp_json_encode( $this->get_jsonld( $is_homepage, $post_id, Jsonld_Context_Enum::PAGE ) ); |
|
| 424 | + $jsonld = wp_json_encode($this->get_jsonld($is_homepage, $post_id, Jsonld_Context_Enum::PAGE)); |
|
| 425 | 425 | ?> |
| 426 | - <script type="application/ld+json"><?php echo esc_html( $jsonld ); ?></script> |
|
| 426 | + <script type="application/ld+json"><?php echo esc_html($jsonld); ?></script> |
|
| 427 | 427 | <?php |
| 428 | 428 | } |
| 429 | 429 | |
@@ -433,17 +433,17 @@ discard block |
||
| 433 | 433 | * |
| 434 | 434 | * @return void |
| 435 | 435 | */ |
| 436 | - private function add_mention_or_about( &$jsonld, $post_id, $relation ) { |
|
| 436 | + private function add_mention_or_about(&$jsonld, $post_id, $relation) { |
|
| 437 | 437 | $content_service = Wordpress_Content_Service::get_instance(); |
| 438 | 438 | $entity_service = Wordlift_Entity_Service::get_instance(); |
| 439 | 439 | |
| 440 | 440 | $object = $relation->get_object(); |
| 441 | - $entity_uri = $content_service->get_entity_id( $object ); |
|
| 442 | - $labels = $entity_service->get_labels( $object->get_id(), $object->get_type() ); |
|
| 441 | + $entity_uri = $content_service->get_entity_id($object); |
|
| 442 | + $labels = $entity_service->get_labels($object->get_id(), $object->get_type()); |
|
| 443 | 443 | |
| 444 | 444 | $escaped_labels = array_map( |
| 445 | - function ( $value ) { |
|
| 446 | - return preg_quote( $value, '/' ); |
|
| 445 | + function($value) { |
|
| 446 | + return preg_quote($value, '/'); |
|
| 447 | 447 | }, |
| 448 | 448 | $labels |
| 449 | 449 | ); |
@@ -451,17 +451,17 @@ discard block |
||
| 451 | 451 | $matches = false; |
| 452 | 452 | |
| 453 | 453 | // When the title is empty, then we shouldn't yield a match to about section. |
| 454 | - if ( array_filter( $escaped_labels ) ) { |
|
| 454 | + if (array_filter($escaped_labels)) { |
|
| 455 | 455 | // Check if the labels match any part of the title. |
| 456 | - $post = get_post( $post_id ); |
|
| 457 | - $matches = $this->check_title_match( $escaped_labels, $post->post_title ); |
|
| 456 | + $post = get_post($post_id); |
|
| 457 | + $matches = $this->check_title_match($escaped_labels, $post->post_title); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if ( $entity_uri ) { |
|
| 460 | + if ($entity_uri) { |
|
| 461 | 461 | // If the title matches, assign the entity to the about, otherwise to the mentions. |
| 462 | 462 | $property_name = $matches ? 'about' : 'mentions'; |
| 463 | - $jsonld[ $property_name ] = isset( $jsonld[ $property_name ] ) ? (array) $jsonld[ $property_name ] : array(); |
|
| 464 | - $jsonld[ $property_name ][] = array( '@id' => $entity_uri ); |
|
| 463 | + $jsonld[$property_name] = isset($jsonld[$property_name]) ? (array) $jsonld[$property_name] : array(); |
|
| 464 | + $jsonld[$property_name][] = array('@id' => $entity_uri); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | } |
@@ -474,15 +474,15 @@ discard block |
||
| 474 | 474 | * |
| 475 | 475 | * @return boolean |
| 476 | 476 | */ |
| 477 | - public function check_title_match( $labels, $title ) { |
|
| 477 | + public function check_title_match($labels, $title) { |
|
| 478 | 478 | |
| 479 | 479 | // If the title is empty, then we shouldn't yield a match to about section. |
| 480 | - if ( empty( $title ) ) { |
|
| 480 | + if (empty($title)) { |
|
| 481 | 481 | return false; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | // Check if the labels match any part of the title. |
| 485 | - return 1 === preg_match( '/\b(' . implode( '|', $labels ) . ')\b/iu', $title ); |
|
| 485 | + return 1 === preg_match('/\b('.implode('|', $labels).')\b/iu', $title); |
|
| 486 | 486 | |
| 487 | 487 | } |
| 488 | 488 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * Init. |
| 19 | 19 | */ |
| 20 | 20 | public function init() { |
| 21 | - add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 ); |
|
| 21 | + add_filter('wl_term_jsonld_array', array($this, 'wl_term_jsonld_array'), 10, 2); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -29,23 +29,23 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return array|mixed |
| 31 | 31 | */ |
| 32 | - public function wl_term_jsonld_array( $jsonld_array, $term_id ) { |
|
| 32 | + public function wl_term_jsonld_array($jsonld_array, $term_id) { |
|
| 33 | 33 | |
| 34 | - $entities = Jsonld_Utils::get_matched_entities_for_term( $term_id ); |
|
| 34 | + $entities = Jsonld_Utils::get_matched_entities_for_term($term_id); |
|
| 35 | 35 | |
| 36 | - if ( count( $entities ) > 0 ) { |
|
| 37 | - $entity = array_shift( $entities ); |
|
| 36 | + if (count($entities) > 0) { |
|
| 37 | + $entity = array_shift($entities); |
|
| 38 | 38 | $entity['@context'] = 'http://schema.org'; |
| 39 | 39 | |
| 40 | - $term_link = get_term_link( $term_id ); |
|
| 41 | - if ( is_wp_error( $term_link ) ) { |
|
| 42 | - Wordlift_Log_Service::get_logger( get_class() ) |
|
| 43 | - ->error( "Term $term_id returned an error: " . $term_link->get_error_message() ); |
|
| 40 | + $term_link = get_term_link($term_id); |
|
| 41 | + if (is_wp_error($term_link)) { |
|
| 42 | + Wordlift_Log_Service::get_logger(get_class()) |
|
| 43 | + ->error("Term $term_id returned an error: ".$term_link->get_error_message()); |
|
| 44 | 44 | |
| 45 | 45 | return $jsonld_array; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $entity['@id'] = $term_link . '/#id'; |
|
| 48 | + $entity['@id'] = $term_link.'/#id'; |
|
| 49 | 49 | $entity['url'] = $term_link; |
| 50 | 50 | $entity['mainEntityOfPage'] = $term_link; |
| 51 | 51 | $jsonld_array['jsonld'][] = $entity; |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | * Enhance post jsonld. |
| 20 | 20 | */ |
| 21 | 21 | public function enhance_post_jsonld() { |
| 22 | - add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 11, 2 ); |
|
| 23 | - add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 11 ); |
|
| 22 | + add_filter('wl_post_jsonld_array', array($this, 'wl_post_jsonld_array'), 11, 2); |
|
| 23 | + add_filter('wl_after_get_jsonld', array($this, 'wl_after_get_jsonld'), 11); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @return array |
| 33 | 33 | */ |
| 34 | - public function wl_post_jsonld_array( $arr, $post_id ) { |
|
| 34 | + public function wl_post_jsonld_array($arr, $post_id) { |
|
| 35 | 35 | $jsonld = $arr['jsonld']; |
| 36 | 36 | $references = $arr['references']; |
| 37 | 37 | |
| 38 | - $this->add_mentions( $post_id, $jsonld ); |
|
| 38 | + $this->add_mentions($post_id, $jsonld); |
|
| 39 | 39 | |
| 40 | 40 | return array( |
| 41 | 41 | 'jsonld' => $jsonld, |
@@ -49,44 +49,44 @@ discard block |
||
| 49 | 49 | * @param $post_id |
| 50 | 50 | * @param $jsonld |
| 51 | 51 | */ |
| 52 | - public function add_mentions( $post_id, &$jsonld ) { |
|
| 52 | + public function add_mentions($post_id, &$jsonld) { |
|
| 53 | 53 | |
| 54 | 54 | $taxonomies = Terms_Compat::get_public_taxonomies(); |
| 55 | 55 | $terms = array(); |
| 56 | 56 | |
| 57 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 58 | - $taxonomy_terms = get_the_terms( $post_id, $taxonomy ); |
|
| 59 | - if ( ! $taxonomy_terms ) { |
|
| 57 | + foreach ($taxonomies as $taxonomy) { |
|
| 58 | + $taxonomy_terms = get_the_terms($post_id, $taxonomy); |
|
| 59 | + if ( ! $taxonomy_terms) { |
|
| 60 | 60 | continue; |
| 61 | 61 | } |
| 62 | - $terms = array_merge( $taxonomy_terms, $terms ); |
|
| 62 | + $terms = array_merge($taxonomy_terms, $terms); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if ( ! $terms ) { |
|
| 65 | + if ( ! $terms) { |
|
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if ( ! array_key_exists( 'mentions', $jsonld ) && count( $terms ) > 0 ) { |
|
| 69 | + if ( ! array_key_exists('mentions', $jsonld) && count($terms) > 0) { |
|
| 70 | 70 | $jsonld['mentions'] = array(); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - foreach ( $terms as $term ) { |
|
| 73 | + foreach ($terms as $term) { |
|
| 74 | 74 | |
| 75 | - $is_matched = intval( get_term_meta( $term->term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, true ) ) === 1; |
|
| 75 | + $is_matched = intval(get_term_meta($term->term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, true)) === 1; |
|
| 76 | 76 | |
| 77 | - if ( ! $is_matched ) { |
|
| 77 | + if ( ! $is_matched) { |
|
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $entities = Jsonld_Utils::get_matched_entities_for_term( $term->term_id ); |
|
| 81 | + $entities = Jsonld_Utils::get_matched_entities_for_term($term->term_id); |
|
| 82 | 82 | |
| 83 | - if ( count( $entities ) === 0 ) { |
|
| 83 | + if (count($entities) === 0) { |
|
| 84 | 84 | continue; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $add_additional_attrs = self::add_additional_attrs( $term, $entities ); |
|
| 87 | + $add_additional_attrs = self::add_additional_attrs($term, $entities); |
|
| 88 | 88 | |
| 89 | - $jsonld['mentions'] = array_merge( $jsonld['mentions'], $add_additional_attrs ); |
|
| 89 | + $jsonld['mentions'] = array_merge($jsonld['mentions'], $add_additional_attrs); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | } |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return array |
| 99 | 99 | */ |
| 100 | - public static function add_additional_attrs( $term, $entities ) { |
|
| 100 | + public static function add_additional_attrs($term, $entities) { |
|
| 101 | 101 | |
| 102 | 102 | return array_map( |
| 103 | - function ( $entity ) use ( $term ) { |
|
| 104 | - $entity['@id'] = get_term_link( $term->term_id ) . '#id'; |
|
| 105 | - if ( ! empty( $term->description ) ) { |
|
| 103 | + function($entity) use ($term) { |
|
| 104 | + $entity['@id'] = get_term_link($term->term_id).'#id'; |
|
| 105 | + if ( ! empty($term->description)) { |
|
| 106 | 106 | $entity['description'] = $term->description; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -121,23 +121,23 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @return array|mixed |
| 123 | 123 | */ |
| 124 | - public function wl_after_get_jsonld( $jsonld ) { |
|
| 124 | + public function wl_after_get_jsonld($jsonld) { |
|
| 125 | 125 | |
| 126 | - if ( ! is_array( $jsonld ) || count( $jsonld ) === 0 ) { |
|
| 126 | + if ( ! is_array($jsonld) || count($jsonld) === 0) { |
|
| 127 | 127 | return $jsonld; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - foreach ( $jsonld as $key => $value ) { |
|
| 131 | - if ( 'Article' === $value['@type'] && isset( $value['image'] ) ) { |
|
| 130 | + foreach ($jsonld as $key => $value) { |
|
| 131 | + if ('Article' === $value['@type'] && isset($value['image'])) { |
|
| 132 | 132 | $image = $value['image']; |
| 133 | 133 | } |
| 134 | - if ( 'Recipe' === $value['@type'] && ! isset( $value['image'] ) ) { |
|
| 134 | + if ('Recipe' === $value['@type'] && ! isset($value['image'])) { |
|
| 135 | 135 | $index = $key; |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if ( isset( $index ) && ! empty( $image ) ) { |
|
| 140 | - $jsonld[ $index ]['image'] = $image; |
|
| 139 | + if (isset($index) && ! empty($image)) { |
|
| 140 | + $jsonld[$index]['image'] = $image; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | return $jsonld; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | use Wordlift\Modules\Events\Post_Entity\Events_Post_Entity_Jsonld; |
| 16 | 16 | use Wordlift\Modules\Events\Term_Entity\Events_Term_Entity_Jsonld; |
| 17 | 17 | |
| 18 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 18 | +if ( ! defined('ABSPATH')) { |
|
| 19 | 19 | exit; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -30,32 +30,32 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | function __wl_events__load() { |
| 32 | 32 | // Autoloader for plugin itself. |
| 33 | - if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
| 34 | - require __DIR__ . '/vendor/autoload.php'; |
|
| 33 | + if (file_exists(__DIR__.'/vendor/autoload.php')) { |
|
| 34 | + require __DIR__.'/vendor/autoload.php'; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $container_builder = new ContainerBuilder(); |
| 38 | - $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
| 39 | - $loader->load( 'services.yml' ); |
|
| 38 | + $loader = new YamlFileLoader($container_builder, new FileLocator(__DIR__)); |
|
| 39 | + $loader->load('services.yml'); |
|
| 40 | 40 | $container_builder->compile(); |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @var $post_entity Events_Post_Entity_Jsonld |
| 44 | 44 | */ |
| 45 | - $post_entity = $container_builder->get( Events_Post_Entity_Jsonld::class ); |
|
| 45 | + $post_entity = $container_builder->get(Events_Post_Entity_Jsonld::class); |
|
| 46 | 46 | $post_entity->register_hooks(); |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * @var $term_entity Events_Term_Entity_Jsonld |
| 50 | 50 | */ |
| 51 | - $term_entity = $container_builder->get( Events_Term_Entity_Jsonld::class ); |
|
| 51 | + $term_entity = $container_builder->get(Events_Term_Entity_Jsonld::class); |
|
| 52 | 52 | $term_entity->register_hooks(); |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * @var $include_exclude Events_Options_Entity_Include_Exclude |
| 56 | 56 | */ |
| 57 | - $include_exclude = $container_builder->get( Events_Options_Entity_Include_Exclude::class ); |
|
| 57 | + $include_exclude = $container_builder->get(Events_Options_Entity_Include_Exclude::class); |
|
| 58 | 58 | $include_exclude->register_hooks(); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | -add_action( 'plugins_loaded', '__wl_events__load' ); |
|
| 61 | +add_action('plugins_loaded', '__wl_events__load'); |
|
@@ -3,14 +3,14 @@ discard block |
||
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | 5 | if (PHP_VERSION_ID < 50600) { |
| 6 | - if (!headers_sent()) { |
|
| 6 | + if ( ! headers_sent()) { |
|
| 7 | 7 | header('HTTP/1.1 500 Internal Server Error'); |
| 8 | 8 | } |
| 9 | 9 | $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; |
| 10 | - if (!ini_get('display_errors')) { |
|
| 10 | + if ( ! ini_get('display_errors')) { |
|
| 11 | 11 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
| 12 | 12 | fwrite(STDERR, $err); |
| 13 | - } elseif (!headers_sent()) { |
|
| 13 | + } elseif ( ! headers_sent()) { |
|
| 14 | 14 | echo $err; |
| 15 | 15 | } |
| 16 | 16 | } |
@@ -20,6 +20,6 @@ discard block |
||
| 20 | 20 | ); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 23 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 24 | 24 | |
| 25 | 25 | return ComposerAutoloaderInitca2d76f00d9dc05bb61631fe434b572d::getLoader(); |
@@ -4,23 +4,23 @@ |
||
| 4 | 4 | |
| 5 | 5 | $issues = array(); |
| 6 | 6 | |
| 7 | -if (!(PHP_VERSION_ID >= 50600)) { |
|
| 8 | - $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.'; |
|
| 7 | +if ( ! (PHP_VERSION_ID >= 50600)) { |
|
| 8 | + $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running '.PHP_VERSION.'.'; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | if ($issues) { |
| 12 | - if (!headers_sent()) { |
|
| 12 | + if ( ! headers_sent()) { |
|
| 13 | 13 | header('HTTP/1.1 500 Internal Server Error'); |
| 14 | 14 | } |
| 15 | - if (!ini_get('display_errors')) { |
|
| 15 | + if ( ! ini_get('display_errors')) { |
|
| 16 | 16 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
| 17 | - fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); |
|
| 18 | - } elseif (!headers_sent()) { |
|
| 19 | - echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; |
|
| 17 | + fwrite(STDERR, 'Composer detected issues in your platform:'.PHP_EOL.PHP_EOL.implode(PHP_EOL, $issues).PHP_EOL.PHP_EOL); |
|
| 18 | + } elseif ( ! headers_sent()) { |
|
| 19 | + echo 'Composer detected issues in your platform:'.PHP_EOL.PHP_EOL.str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)).PHP_EOL.PHP_EOL; |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | trigger_error( |
| 23 | - 'Composer detected issues in your platform: ' . implode(' ', $issues), |
|
| 23 | + 'Composer detected issues in your platform: '.implode(' ', $issues), |
|
| 24 | 24 | E_USER_ERROR |
| 25 | 25 | ); |
| 26 | 26 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | public static function loadClassLoader($class) |
| 10 | 10 | { |
| 11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
| 12 | - require __DIR__ . '/ClassLoader.php'; |
|
| 12 | + require __DIR__.'/ClassLoader.php'; |
|
| 13 | 13 | } |
| 14 | 14 | } |
| 15 | 15 | |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | return self::$loader; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - require __DIR__ . '/platform_check.php'; |
|
| 25 | + require __DIR__.'/platform_check.php'; |
|
| 26 | 26 | |
| 27 | 27 | spl_autoload_register(array('ComposerAutoloaderInitca2d76f00d9dc05bb61631fe434b572d', 'loadClassLoader'), true, true); |
| 28 | 28 | self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); |
| 29 | 29 | spl_autoload_unregister(array('ComposerAutoloaderInitca2d76f00d9dc05bb61631fe434b572d', 'loadClassLoader')); |
| 30 | 30 | |
| 31 | - require __DIR__ . '/autoload_static.php'; |
|
| 31 | + require __DIR__.'/autoload_static.php'; |
|
| 32 | 32 | call_user_func(\Composer\Autoload\ComposerStaticInitca2d76f00d9dc05bb61631fe434b572d::getInitializer($loader)); |
| 33 | 33 | |
| 34 | 34 | $loader->register(true); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function getPrefixes() |
| 115 | 115 | { |
| 116 | - if (!empty($this->prefixesPsr0)) { |
|
| 116 | + if ( ! empty($this->prefixesPsr0)) { |
|
| 117 | 117 | return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function add($prefix, $paths, $prepend = false) |
| 185 | 185 | { |
| 186 | - if (!$prefix) { |
|
| 186 | + if ( ! $prefix) { |
|
| 187 | 187 | if ($prepend) { |
| 188 | 188 | $this->fallbackDirsPsr0 = array_merge( |
| 189 | 189 | (array) $paths, |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | $first = $prefix[0]; |
| 203 | - if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
| 203 | + if ( ! isset($this->prefixesPsr0[$first][$prefix])) { |
|
| 204 | 204 | $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
| 205 | 205 | |
| 206 | 206 | return; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function addPsr4($prefix, $paths, $prepend = false) |
| 234 | 234 | { |
| 235 | - if (!$prefix) { |
|
| 235 | + if ( ! $prefix) { |
|
| 236 | 236 | // Register directories for the root namespace. |
| 237 | 237 | if ($prepend) { |
| 238 | 238 | $this->fallbackDirsPsr4 = array_merge( |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | (array) $paths |
| 246 | 246 | ); |
| 247 | 247 | } |
| 248 | - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
| 248 | + } elseif ( ! isset($this->prefixDirsPsr4[$prefix])) { |
|
| 249 | 249 | // Register directories for a new namespace. |
| 250 | 250 | $length = strlen($prefix); |
| 251 | 251 | if ('\\' !== $prefix[$length - 1]) { |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | public function set($prefix, $paths) |
| 281 | 281 | { |
| 282 | - if (!$prefix) { |
|
| 282 | + if ( ! $prefix) { |
|
| 283 | 283 | $this->fallbackDirsPsr0 = (array) $paths; |
| 284 | 284 | } else { |
| 285 | 285 | $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | public function setPsr4($prefix, $paths) |
| 301 | 301 | { |
| 302 | - if (!$prefix) { |
|
| 302 | + if ( ! $prefix) { |
|
| 303 | 303 | $this->fallbackDirsPsr4 = (array) $paths; |
| 304 | 304 | } else { |
| 305 | 305 | $length = strlen($prefix); |
@@ -493,18 +493,18 @@ discard block |
||
| 493 | 493 | private function findFileWithExtension($class, $ext) |
| 494 | 494 | { |
| 495 | 495 | // PSR-4 lookup |
| 496 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 496 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 497 | 497 | |
| 498 | 498 | $first = $class[0]; |
| 499 | 499 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 500 | 500 | $subPath = $class; |
| 501 | 501 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
| 502 | 502 | $subPath = substr($subPath, 0, $lastPos); |
| 503 | - $search = $subPath . '\\'; |
|
| 503 | + $search = $subPath.'\\'; |
|
| 504 | 504 | if (isset($this->prefixDirsPsr4[$search])) { |
| 505 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 505 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
| 506 | 506 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 507 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 507 | + if (file_exists($file = $dir.$pathEnd)) { |
|
| 508 | 508 | return $file; |
| 509 | 509 | } |
| 510 | 510 | } |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | // PSR-4 fallback dirs |
| 516 | 516 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 517 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 517 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 518 | 518 | return $file; |
| 519 | 519 | } |
| 520 | 520 | } |
@@ -526,14 +526,14 @@ discard block |
||
| 526 | 526 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 527 | 527 | } else { |
| 528 | 528 | // PEAR-like class name |
| 529 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 529 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | if (isset($this->prefixesPsr0[$first])) { |
| 533 | 533 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 534 | 534 | if (0 === strpos($class, $prefix)) { |
| 535 | 535 | foreach ($dirs as $dir) { |
| 536 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 536 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 537 | 537 | return $file; |
| 538 | 538 | } |
| 539 | 539 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | // PSR-0 fallback dirs |
| 545 | 545 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 546 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 546 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 547 | 547 | return $file; |
| 548 | 548 | } |
| 549 | 549 | } |