@@ -13,216 +13,216 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class Wordlift_Entity_Post_To_Jsonld_Converter { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * The JSON-LD context. |
|
| 18 | - * |
|
| 19 | - * @since 3.8.0 |
|
| 20 | - */ |
|
| 21 | - const CONTEXT = 'http://schema.org'; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 25 | - * |
|
| 26 | - * @since 3.8.0 |
|
| 27 | - * @access protected |
|
| 28 | - * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 29 | - */ |
|
| 30 | - protected $entity_type_service; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * A {@link Wordlift_Entity_Service} instance. |
|
| 34 | - * |
|
| 35 | - * @since 3.8.0 |
|
| 36 | - * @access protected |
|
| 37 | - * @var \Wordlift_Entity_Service $entity_type_service A {@link Wordlift_Entity_Service} instance. |
|
| 38 | - */ |
|
| 39 | - protected $entity_service; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * A {@link Wordlift_Property_Getter} instance. |
|
| 43 | - * |
|
| 44 | - * @since 3.8.0 |
|
| 45 | - * @access private |
|
| 46 | - * @var \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 47 | - */ |
|
| 48 | - private $property_getter; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Wordlift_Entity_To_Jsonld_Converter constructor. |
|
| 52 | - * |
|
| 53 | - * @since 3.8.0 |
|
| 54 | - * |
|
| 55 | - * @param \Wordlift_Entity_Type_Service $entity_type_service |
|
| 56 | - * @param \Wordlift_Entity_Service $entity_service |
|
| 57 | - * @param \Wordlift_Property_Getter $property_getter |
|
| 58 | - */ |
|
| 59 | - public function __construct( $entity_type_service, $entity_service, $property_getter ) { |
|
| 60 | - |
|
| 61 | - $this->entity_type_service = $entity_type_service; |
|
| 62 | - $this->entity_service = $entity_service; |
|
| 63 | - $this->property_getter = $property_getter; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 68 | - * found while processing the post is set in the $references array. |
|
| 69 | - * |
|
| 70 | - * @since 3.8.0 |
|
| 71 | - * |
|
| 72 | - * @param WP_Post $post The {@link WP_Post} to convert. |
|
| 73 | - * |
|
| 74 | - * @param array $references An array of entity references. |
|
| 75 | - * |
|
| 76 | - * @return array A JSON-LD array. |
|
| 77 | - */ |
|
| 78 | - public function convert( $post, &$references = array() ) { |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - // Get the entity @type. |
|
| 82 | - $type = $this->entity_type_service->get( $post->ID ); |
|
| 83 | - |
|
| 84 | - // Get the entity @id. |
|
| 85 | - $id = $this->entity_service->get_uri( $post->ID ); |
|
| 86 | - |
|
| 87 | - // Get the entity name. |
|
| 88 | - $name = $post->post_title; |
|
| 89 | - |
|
| 90 | - // Get the configured type custom fields. |
|
| 91 | - $fields = $type['custom_fields']; |
|
| 92 | - |
|
| 93 | - // Prepare the response. |
|
| 94 | - $jsonld = array( |
|
| 95 | - '@context' => self::CONTEXT, |
|
| 96 | - '@id' => $id, |
|
| 97 | - '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 98 | - 'name' => $name, |
|
| 99 | - 'description' => $this->get_excerpt( $post ), |
|
| 100 | - ); |
|
| 101 | - |
|
| 102 | - // Set a reference to use in closures. |
|
| 103 | - $converter = $this; |
|
| 104 | - |
|
| 105 | - // Try each field on the entity. |
|
| 106 | - foreach ( $fields as $key => $value ) { |
|
| 107 | - |
|
| 108 | - // Get the predicate. |
|
| 109 | - $name = $this->relative_to_context( $value['predicate'] ); |
|
| 110 | - |
|
| 111 | - // Get the value, the property service will get the right extractor |
|
| 112 | - // for that property. |
|
| 113 | - $value = $this->property_getter->get( $post->ID, $key ); |
|
| 114 | - |
|
| 115 | - if ( 0 === count( $value ) ) { |
|
| 116 | - continue; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - // Map the value to the property name. |
|
| 120 | - // If we got an array with just one value, we return that one value. |
|
| 121 | - // If we got a Wordlift_Property_Entity_Reference we get the URL. |
|
| 122 | - $jsonld[ $name ] = $this->make_one( array_map( function ( $item ) use ( $converter, &$references ) { |
|
| 123 | - |
|
| 124 | - if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 125 | - |
|
| 126 | - $url = $item->getURL(); |
|
| 127 | - $references[] = $url; |
|
| 128 | - |
|
| 129 | - return array( "@id" => $url ); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - return $converter->relative_to_context( $item ); |
|
| 133 | - }, $value ) ); |
|
| 134 | - |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - return $this->post_process( $jsonld ); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * If the provided value starts with the schema.org context, we remove the schema.org |
|
| 142 | - * part since it is set with the '@context'. |
|
| 143 | - * |
|
| 144 | - * @since 3.8.0 |
|
| 145 | - * |
|
| 146 | - * @param string $value The property value. |
|
| 147 | - * |
|
| 148 | - * @return string The property value without the context. |
|
| 149 | - */ |
|
| 150 | - public function relative_to_context( $value ) { |
|
| 151 | - |
|
| 152 | - return 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * If the provided array of values contains only one value, then one single |
|
| 157 | - * value is returned, otherwise the original array is returned. |
|
| 158 | - * |
|
| 159 | - * @since 3.8.0 |
|
| 160 | - * @access private |
|
| 161 | - * |
|
| 162 | - * @param array $value An array of values. |
|
| 163 | - * |
|
| 164 | - * @return mixed|array A single value or the original array. |
|
| 165 | - */ |
|
| 166 | - private function make_one( $value ) { |
|
| 167 | - |
|
| 168 | - return 1 === count( $value ) ? $value[0] : $value; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Post process the generated JSON to reorganize values which are stored as 1st |
|
| 173 | - * level in WP but are really 2nd level. |
|
| 174 | - * |
|
| 175 | - * @since 3.8.0 |
|
| 176 | - * |
|
| 177 | - * @param array $jsonld An array of JSON-LD properties and values. |
|
| 178 | - * |
|
| 179 | - * @return array The array remapped. |
|
| 180 | - */ |
|
| 181 | - private function post_process( $jsonld ) { |
|
| 182 | - |
|
| 183 | - foreach ( $jsonld as $key => $value ) { |
|
| 184 | - if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 185 | - $jsonld['address']['@type'] = 'PostalAddress'; |
|
| 186 | - $jsonld['address'][ $key ] = $value; |
|
| 187 | - unset( $jsonld[ $key ] ); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 191 | - $jsonld['geo']['@type'] = 'GeoCoordinates'; |
|
| 192 | - $jsonld['geo'][ $key ] = $value; |
|
| 193 | - unset( $jsonld[ $key ] ); |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - return $jsonld; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Get the excerpt for the provided {@link WP_Post}. |
|
| 202 | - * |
|
| 203 | - * @since 3.8.0 |
|
| 204 | - * |
|
| 205 | - * @param WP_Post $post The {@link WP_Post}. |
|
| 206 | - * |
|
| 207 | - * @return string The excerpt. |
|
| 208 | - */ |
|
| 209 | - private function get_excerpt( $post ) { |
|
| 210 | - |
|
| 211 | - // Temporary pop the previous post. |
|
| 212 | - $original = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : NULL; |
|
| 213 | - |
|
| 214 | - // Setup our own post. |
|
| 215 | - setup_postdata( $GLOBALS['post'] = &$post ); |
|
| 216 | - |
|
| 217 | - $excerpt = get_the_excerpt( $post ); |
|
| 218 | - |
|
| 219 | - // Restore the previous post. |
|
| 220 | - if ( NULL !== $original ) { |
|
| 221 | - setup_postdata( $GLOBALS['post'] = $original ); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - // Finally return the excerpt. |
|
| 225 | - return html_entity_decode( $excerpt ); |
|
| 226 | - } |
|
| 16 | + /** |
|
| 17 | + * The JSON-LD context. |
|
| 18 | + * |
|
| 19 | + * @since 3.8.0 |
|
| 20 | + */ |
|
| 21 | + const CONTEXT = 'http://schema.org'; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * A {@link Wordlift_Entity_Type_Service} instance. |
|
| 25 | + * |
|
| 26 | + * @since 3.8.0 |
|
| 27 | + * @access protected |
|
| 28 | + * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance. |
|
| 29 | + */ |
|
| 30 | + protected $entity_type_service; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * A {@link Wordlift_Entity_Service} instance. |
|
| 34 | + * |
|
| 35 | + * @since 3.8.0 |
|
| 36 | + * @access protected |
|
| 37 | + * @var \Wordlift_Entity_Service $entity_type_service A {@link Wordlift_Entity_Service} instance. |
|
| 38 | + */ |
|
| 39 | + protected $entity_service; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * A {@link Wordlift_Property_Getter} instance. |
|
| 43 | + * |
|
| 44 | + * @since 3.8.0 |
|
| 45 | + * @access private |
|
| 46 | + * @var \Wordlift_Property_Getter $property_getter A {@link Wordlift_Property_Getter} instance. |
|
| 47 | + */ |
|
| 48 | + private $property_getter; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Wordlift_Entity_To_Jsonld_Converter constructor. |
|
| 52 | + * |
|
| 53 | + * @since 3.8.0 |
|
| 54 | + * |
|
| 55 | + * @param \Wordlift_Entity_Type_Service $entity_type_service |
|
| 56 | + * @param \Wordlift_Entity_Service $entity_service |
|
| 57 | + * @param \Wordlift_Property_Getter $property_getter |
|
| 58 | + */ |
|
| 59 | + public function __construct( $entity_type_service, $entity_service, $property_getter ) { |
|
| 60 | + |
|
| 61 | + $this->entity_type_service = $entity_type_service; |
|
| 62 | + $this->entity_service = $entity_service; |
|
| 63 | + $this->property_getter = $property_getter; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Convert the provided {@link WP_Post} to a JSON-LD array. Any entity reference |
|
| 68 | + * found while processing the post is set in the $references array. |
|
| 69 | + * |
|
| 70 | + * @since 3.8.0 |
|
| 71 | + * |
|
| 72 | + * @param WP_Post $post The {@link WP_Post} to convert. |
|
| 73 | + * |
|
| 74 | + * @param array $references An array of entity references. |
|
| 75 | + * |
|
| 76 | + * @return array A JSON-LD array. |
|
| 77 | + */ |
|
| 78 | + public function convert( $post, &$references = array() ) { |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + // Get the entity @type. |
|
| 82 | + $type = $this->entity_type_service->get( $post->ID ); |
|
| 83 | + |
|
| 84 | + // Get the entity @id. |
|
| 85 | + $id = $this->entity_service->get_uri( $post->ID ); |
|
| 86 | + |
|
| 87 | + // Get the entity name. |
|
| 88 | + $name = $post->post_title; |
|
| 89 | + |
|
| 90 | + // Get the configured type custom fields. |
|
| 91 | + $fields = $type['custom_fields']; |
|
| 92 | + |
|
| 93 | + // Prepare the response. |
|
| 94 | + $jsonld = array( |
|
| 95 | + '@context' => self::CONTEXT, |
|
| 96 | + '@id' => $id, |
|
| 97 | + '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 98 | + 'name' => $name, |
|
| 99 | + 'description' => $this->get_excerpt( $post ), |
|
| 100 | + ); |
|
| 101 | + |
|
| 102 | + // Set a reference to use in closures. |
|
| 103 | + $converter = $this; |
|
| 104 | + |
|
| 105 | + // Try each field on the entity. |
|
| 106 | + foreach ( $fields as $key => $value ) { |
|
| 107 | + |
|
| 108 | + // Get the predicate. |
|
| 109 | + $name = $this->relative_to_context( $value['predicate'] ); |
|
| 110 | + |
|
| 111 | + // Get the value, the property service will get the right extractor |
|
| 112 | + // for that property. |
|
| 113 | + $value = $this->property_getter->get( $post->ID, $key ); |
|
| 114 | + |
|
| 115 | + if ( 0 === count( $value ) ) { |
|
| 116 | + continue; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + // Map the value to the property name. |
|
| 120 | + // If we got an array with just one value, we return that one value. |
|
| 121 | + // If we got a Wordlift_Property_Entity_Reference we get the URL. |
|
| 122 | + $jsonld[ $name ] = $this->make_one( array_map( function ( $item ) use ( $converter, &$references ) { |
|
| 123 | + |
|
| 124 | + if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 125 | + |
|
| 126 | + $url = $item->getURL(); |
|
| 127 | + $references[] = $url; |
|
| 128 | + |
|
| 129 | + return array( "@id" => $url ); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + return $converter->relative_to_context( $item ); |
|
| 133 | + }, $value ) ); |
|
| 134 | + |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + return $this->post_process( $jsonld ); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * If the provided value starts with the schema.org context, we remove the schema.org |
|
| 142 | + * part since it is set with the '@context'. |
|
| 143 | + * |
|
| 144 | + * @since 3.8.0 |
|
| 145 | + * |
|
| 146 | + * @param string $value The property value. |
|
| 147 | + * |
|
| 148 | + * @return string The property value without the context. |
|
| 149 | + */ |
|
| 150 | + public function relative_to_context( $value ) { |
|
| 151 | + |
|
| 152 | + return 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * If the provided array of values contains only one value, then one single |
|
| 157 | + * value is returned, otherwise the original array is returned. |
|
| 158 | + * |
|
| 159 | + * @since 3.8.0 |
|
| 160 | + * @access private |
|
| 161 | + * |
|
| 162 | + * @param array $value An array of values. |
|
| 163 | + * |
|
| 164 | + * @return mixed|array A single value or the original array. |
|
| 165 | + */ |
|
| 166 | + private function make_one( $value ) { |
|
| 167 | + |
|
| 168 | + return 1 === count( $value ) ? $value[0] : $value; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Post process the generated JSON to reorganize values which are stored as 1st |
|
| 173 | + * level in WP but are really 2nd level. |
|
| 174 | + * |
|
| 175 | + * @since 3.8.0 |
|
| 176 | + * |
|
| 177 | + * @param array $jsonld An array of JSON-LD properties and values. |
|
| 178 | + * |
|
| 179 | + * @return array The array remapped. |
|
| 180 | + */ |
|
| 181 | + private function post_process( $jsonld ) { |
|
| 182 | + |
|
| 183 | + foreach ( $jsonld as $key => $value ) { |
|
| 184 | + if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 185 | + $jsonld['address']['@type'] = 'PostalAddress'; |
|
| 186 | + $jsonld['address'][ $key ] = $value; |
|
| 187 | + unset( $jsonld[ $key ] ); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 191 | + $jsonld['geo']['@type'] = 'GeoCoordinates'; |
|
| 192 | + $jsonld['geo'][ $key ] = $value; |
|
| 193 | + unset( $jsonld[ $key ] ); |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + return $jsonld; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Get the excerpt for the provided {@link WP_Post}. |
|
| 202 | + * |
|
| 203 | + * @since 3.8.0 |
|
| 204 | + * |
|
| 205 | + * @param WP_Post $post The {@link WP_Post}. |
|
| 206 | + * |
|
| 207 | + * @return string The excerpt. |
|
| 208 | + */ |
|
| 209 | + private function get_excerpt( $post ) { |
|
| 210 | + |
|
| 211 | + // Temporary pop the previous post. |
|
| 212 | + $original = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : NULL; |
|
| 213 | + |
|
| 214 | + // Setup our own post. |
|
| 215 | + setup_postdata( $GLOBALS['post'] = &$post ); |
|
| 216 | + |
|
| 217 | + $excerpt = get_the_excerpt( $post ); |
|
| 218 | + |
|
| 219 | + // Restore the previous post. |
|
| 220 | + if ( NULL !== $original ) { |
|
| 221 | + setup_postdata( $GLOBALS['post'] = $original ); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + // Finally return the excerpt. |
|
| 225 | + return html_entity_decode( $excerpt ); |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | 228 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param \Wordlift_Entity_Service $entity_service |
| 57 | 57 | * @param \Wordlift_Property_Getter $property_getter |
| 58 | 58 | */ |
| 59 | - public function __construct( $entity_type_service, $entity_service, $property_getter ) { |
|
| 59 | + public function __construct($entity_type_service, $entity_service, $property_getter) { |
|
| 60 | 60 | |
| 61 | 61 | $this->entity_type_service = $entity_type_service; |
| 62 | 62 | $this->entity_service = $entity_service; |
@@ -75,14 +75,14 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return array A JSON-LD array. |
| 77 | 77 | */ |
| 78 | - public function convert( $post, &$references = array() ) { |
|
| 78 | + public function convert($post, &$references = array()) { |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | // Get the entity @type. |
| 82 | - $type = $this->entity_type_service->get( $post->ID ); |
|
| 82 | + $type = $this->entity_type_service->get($post->ID); |
|
| 83 | 83 | |
| 84 | 84 | // Get the entity @id. |
| 85 | - $id = $this->entity_service->get_uri( $post->ID ); |
|
| 85 | + $id = $this->entity_service->get_uri($post->ID); |
|
| 86 | 86 | |
| 87 | 87 | // Get the entity name. |
| 88 | 88 | $name = $post->post_title; |
@@ -94,47 +94,47 @@ discard block |
||
| 94 | 94 | $jsonld = array( |
| 95 | 95 | '@context' => self::CONTEXT, |
| 96 | 96 | '@id' => $id, |
| 97 | - '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 97 | + '@type' => $this->relative_to_context($type['uri']), |
|
| 98 | 98 | 'name' => $name, |
| 99 | - 'description' => $this->get_excerpt( $post ), |
|
| 99 | + 'description' => $this->get_excerpt($post), |
|
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | 102 | // Set a reference to use in closures. |
| 103 | 103 | $converter = $this; |
| 104 | 104 | |
| 105 | 105 | // Try each field on the entity. |
| 106 | - foreach ( $fields as $key => $value ) { |
|
| 106 | + foreach ($fields as $key => $value) { |
|
| 107 | 107 | |
| 108 | 108 | // Get the predicate. |
| 109 | - $name = $this->relative_to_context( $value['predicate'] ); |
|
| 109 | + $name = $this->relative_to_context($value['predicate']); |
|
| 110 | 110 | |
| 111 | 111 | // Get the value, the property service will get the right extractor |
| 112 | 112 | // for that property. |
| 113 | - $value = $this->property_getter->get( $post->ID, $key ); |
|
| 113 | + $value = $this->property_getter->get($post->ID, $key); |
|
| 114 | 114 | |
| 115 | - if ( 0 === count( $value ) ) { |
|
| 115 | + if (0 === count($value)) { |
|
| 116 | 116 | continue; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Map the value to the property name. |
| 120 | 120 | // If we got an array with just one value, we return that one value. |
| 121 | 121 | // If we got a Wordlift_Property_Entity_Reference we get the URL. |
| 122 | - $jsonld[ $name ] = $this->make_one( array_map( function ( $item ) use ( $converter, &$references ) { |
|
| 122 | + $jsonld[$name] = $this->make_one(array_map(function($item) use ($converter, &$references) { |
|
| 123 | 123 | |
| 124 | - if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 124 | + if ($item instanceof Wordlift_Property_Entity_Reference) { |
|
| 125 | 125 | |
| 126 | 126 | $url = $item->getURL(); |
| 127 | 127 | $references[] = $url; |
| 128 | 128 | |
| 129 | - return array( "@id" => $url ); |
|
| 129 | + return array("@id" => $url); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - return $converter->relative_to_context( $item ); |
|
| 133 | - }, $value ) ); |
|
| 132 | + return $converter->relative_to_context($item); |
|
| 133 | + }, $value)); |
|
| 134 | 134 | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - return $this->post_process( $jsonld ); |
|
| 137 | + return $this->post_process($jsonld); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return string The property value without the context. |
| 149 | 149 | */ |
| 150 | - public function relative_to_context( $value ) { |
|
| 150 | + public function relative_to_context($value) { |
|
| 151 | 151 | |
| 152 | - return 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value; |
|
| 152 | + return 0 === strpos($value, self::CONTEXT.'/') ? substr($value, strlen(self::CONTEXT) + 1) : $value; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return mixed|array A single value or the original array. |
| 165 | 165 | */ |
| 166 | - private function make_one( $value ) { |
|
| 166 | + private function make_one($value) { |
|
| 167 | 167 | |
| 168 | - return 1 === count( $value ) ? $value[0] : $value; |
|
| 168 | + return 1 === count($value) ? $value[0] : $value; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -178,19 +178,19 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return array The array remapped. |
| 180 | 180 | */ |
| 181 | - private function post_process( $jsonld ) { |
|
| 181 | + private function post_process($jsonld) { |
|
| 182 | 182 | |
| 183 | - foreach ( $jsonld as $key => $value ) { |
|
| 184 | - if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
| 183 | + foreach ($jsonld as $key => $value) { |
|
| 184 | + if ('streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key) { |
|
| 185 | 185 | $jsonld['address']['@type'] = 'PostalAddress'; |
| 186 | - $jsonld['address'][ $key ] = $value; |
|
| 187 | - unset( $jsonld[ $key ] ); |
|
| 186 | + $jsonld['address'][$key] = $value; |
|
| 187 | + unset($jsonld[$key]); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if ( 'latitude' === $key || 'longitude' === $key ) { |
|
| 190 | + if ('latitude' === $key || 'longitude' === $key) { |
|
| 191 | 191 | $jsonld['geo']['@type'] = 'GeoCoordinates'; |
| 192 | - $jsonld['geo'][ $key ] = $value; |
|
| 193 | - unset( $jsonld[ $key ] ); |
|
| 192 | + $jsonld['geo'][$key] = $value; |
|
| 193 | + unset($jsonld[$key]); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
@@ -206,23 +206,23 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return string The excerpt. |
| 208 | 208 | */ |
| 209 | - private function get_excerpt( $post ) { |
|
| 209 | + private function get_excerpt($post) { |
|
| 210 | 210 | |
| 211 | 211 | // Temporary pop the previous post. |
| 212 | - $original = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : NULL; |
|
| 212 | + $original = isset($GLOBALS['post']) ? $GLOBALS['post'] : NULL; |
|
| 213 | 213 | |
| 214 | 214 | // Setup our own post. |
| 215 | - setup_postdata( $GLOBALS['post'] = &$post ); |
|
| 215 | + setup_postdata($GLOBALS['post'] = &$post); |
|
| 216 | 216 | |
| 217 | - $excerpt = get_the_excerpt( $post ); |
|
| 217 | + $excerpt = get_the_excerpt($post); |
|
| 218 | 218 | |
| 219 | 219 | // Restore the previous post. |
| 220 | - if ( NULL !== $original ) { |
|
| 221 | - setup_postdata( $GLOBALS['post'] = $original ); |
|
| 220 | + if (NULL !== $original) { |
|
| 221 | + setup_postdata($GLOBALS['post'] = $original); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // Finally return the excerpt. |
| 225 | - return html_entity_decode( $excerpt ); |
|
| 225 | + return html_entity_decode($excerpt); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | } |
@@ -29,778 +29,778 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class Wordlift { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | - * the plugin. |
|
| 35 | - * |
|
| 36 | - * @since 1.0.0 |
|
| 37 | - * @access protected |
|
| 38 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | - */ |
|
| 40 | - protected $loader; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The unique identifier of this plugin. |
|
| 44 | - * |
|
| 45 | - * @since 1.0.0 |
|
| 46 | - * @access protected |
|
| 47 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | - */ |
|
| 49 | - protected $plugin_name; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * The current version of the plugin. |
|
| 53 | - * |
|
| 54 | - * @since 1.0.0 |
|
| 55 | - * @access protected |
|
| 56 | - * @var string $version The current version of the plugin. |
|
| 57 | - */ |
|
| 58 | - protected $version; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * The Thumbnail service. |
|
| 62 | - * |
|
| 63 | - * @since 3.1.5 |
|
| 64 | - * @access private |
|
| 65 | - * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 66 | - */ |
|
| 67 | - private $thumbnail_service; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * The UI service. |
|
| 71 | - * |
|
| 72 | - * @since 3.2.0 |
|
| 73 | - * @access private |
|
| 74 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 75 | - */ |
|
| 76 | - private $ui_service; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * The Schema service. |
|
| 80 | - * |
|
| 81 | - * @since 3.3.0 |
|
| 82 | - * @access private |
|
| 83 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 84 | - */ |
|
| 85 | - private $schema_service; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * The Entity service. |
|
| 89 | - * |
|
| 90 | - * @since 3.1.0 |
|
| 91 | - * @access private |
|
| 92 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 93 | - */ |
|
| 94 | - private $entity_service; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * The Topic Taxonomy service. |
|
| 98 | - * |
|
| 99 | - * @since 3.5.0 |
|
| 100 | - * @access private |
|
| 101 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 102 | - */ |
|
| 103 | - private $topic_taxonomy_service; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * The User service. |
|
| 107 | - * |
|
| 108 | - * @since 3.1.7 |
|
| 109 | - * @access private |
|
| 110 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 111 | - */ |
|
| 112 | - private $user_service; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * The Timeline service. |
|
| 116 | - * |
|
| 117 | - * @since 3.1.0 |
|
| 118 | - * @access private |
|
| 119 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 120 | - */ |
|
| 121 | - private $timeline_service; |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * The Redirect service. |
|
| 125 | - * |
|
| 126 | - * @since 3.2.0 |
|
| 127 | - * @access private |
|
| 128 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 129 | - */ |
|
| 130 | - private $redirect_service; |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * The Notice service. |
|
| 134 | - * |
|
| 135 | - * @since 3.3.0 |
|
| 136 | - * @access private |
|
| 137 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 138 | - */ |
|
| 139 | - private $notice_service; |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * The Entity list customization. |
|
| 143 | - * |
|
| 144 | - * @since 3.3.0 |
|
| 145 | - * @access private |
|
| 146 | - * @var \Wordlift_List_Service $entity_list_service The Entity list service. |
|
| 147 | - */ |
|
| 148 | - private $entity_list_service; |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * The Entity Types Taxonomy Walker. |
|
| 152 | - * |
|
| 153 | - * @since 3.1.0 |
|
| 154 | - * @access private |
|
| 155 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 156 | - */ |
|
| 157 | - private $entity_types_taxonomy_walker; |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * The ShareThis service. |
|
| 161 | - * |
|
| 162 | - * @since 3.2.0 |
|
| 163 | - * @access private |
|
| 164 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 165 | - */ |
|
| 166 | - private $sharethis_service; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * The PrimaShop adapter. |
|
| 170 | - * |
|
| 171 | - * @since 3.2.3 |
|
| 172 | - * @access private |
|
| 173 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 174 | - */ |
|
| 175 | - private $primashop_adapter; |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * The WordLift Dashboard adapter. |
|
| 179 | - * |
|
| 180 | - * @since 3.4.0 |
|
| 181 | - * @access private |
|
| 182 | - * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 183 | - */ |
|
| 184 | - private $dashboard_service; |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * The entity type service. |
|
| 188 | - * |
|
| 189 | - * @since 3.6.0 |
|
| 190 | - * @access private |
|
| 191 | - * @var \Wordlift_Entity_Post_Type_Service |
|
| 192 | - */ |
|
| 193 | - private $entity_post_type_service; |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 197 | - * |
|
| 198 | - * @since 3.6.0 |
|
| 199 | - * @access private |
|
| 200 | - * @var \Wordlift_Entity_Link_Service |
|
| 201 | - */ |
|
| 202 | - private $entity_link_service; |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * The page service instance which processes the page output in order to insert schema.org microdata to export the |
|
| 206 | - * correct page title to Google+. |
|
| 207 | - * |
|
| 208 | - * @since 3.5.3 |
|
| 209 | - * @access private |
|
| 210 | - * @var \Wordlift_Page_Service |
|
| 211 | - */ |
|
| 212 | - private $page_service; |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 216 | - * |
|
| 217 | - * @var 3.6.0 |
|
| 218 | - * @access private |
|
| 219 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 220 | - */ |
|
| 221 | - private $sparql_service; |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * A {@link Wordlift_Import_Service} instance. |
|
| 225 | - * |
|
| 226 | - * @since 3.6.0 |
|
| 227 | - * @access private |
|
| 228 | - * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 229 | - */ |
|
| 230 | - private $import_service; |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * A {@link Wordlift_Rebuild_Service} instance. |
|
| 234 | - * |
|
| 235 | - * @since 3.6.0 |
|
| 236 | - * @access private |
|
| 237 | - * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 238 | - */ |
|
| 239 | - private $rebuild_service; |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * A {@link Wordlift_Jsonld_Service} instance. |
|
| 243 | - * |
|
| 244 | - * @since 3.7.0 |
|
| 245 | - * @access private |
|
| 246 | - * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 247 | - */ |
|
| 248 | - private $jsonld_service; |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * |
|
| 252 | - * @since 3.7.0 |
|
| 253 | - * @access private |
|
| 254 | - * @var \Wordlift_Property_Factory $property_factory |
|
| 255 | - */ |
|
| 256 | - private $property_factory; |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * The 'Download Your Data' page. |
|
| 260 | - * |
|
| 261 | - * @since 3.6.0 |
|
| 262 | - * @access private |
|
| 263 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 264 | - */ |
|
| 265 | - private $download_your_data_page; |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 269 | - * linking of entities to their pages. |
|
| 270 | - * |
|
| 271 | - * @since 3.8.0 |
|
| 272 | - * @access private |
|
| 273 | - * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 274 | - */ |
|
| 275 | - private $content_filter_service; |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * Define the core functionality of the plugin. |
|
| 279 | - * |
|
| 280 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 281 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 282 | - * the public-facing side of the site. |
|
| 283 | - * |
|
| 284 | - * @since 1.0.0 |
|
| 285 | - */ |
|
| 286 | - public function __construct() { |
|
| 287 | - |
|
| 288 | - $this->plugin_name = 'wordlift'; |
|
| 289 | - $this->version = '3.9.0-dev'; |
|
| 290 | - $this->load_dependencies(); |
|
| 291 | - $this->set_locale(); |
|
| 292 | - $this->define_admin_hooks(); |
|
| 293 | - $this->define_public_hooks(); |
|
| 294 | - |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * Load the required dependencies for this plugin. |
|
| 299 | - * |
|
| 300 | - * Include the following files that make up the plugin: |
|
| 301 | - * |
|
| 302 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 303 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 304 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 305 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 306 | - * |
|
| 307 | - * Create an instance of the loader which will be used to register the hooks |
|
| 308 | - * with WordPress. |
|
| 309 | - * |
|
| 310 | - * @since 1.0.0 |
|
| 311 | - * @access private |
|
| 312 | - */ |
|
| 313 | - private function load_dependencies() { |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * The class responsible for orchestrating the actions and filters of the |
|
| 317 | - * core plugin. |
|
| 318 | - */ |
|
| 319 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * The class responsible for defining internationalization functionality |
|
| 323 | - * of the plugin. |
|
| 324 | - */ |
|
| 325 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * Provide support functions to sanitize data. |
|
| 329 | - */ |
|
| 330 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * The Redirect service. |
|
| 334 | - */ |
|
| 335 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 336 | - |
|
| 337 | - /** |
|
| 338 | - * The Log service. |
|
| 339 | - */ |
|
| 340 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * The configuration service. |
|
| 344 | - */ |
|
| 345 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 346 | - |
|
| 347 | - /** |
|
| 348 | - * The entity post type service (this is the WordPress post type, not the entity schema type). |
|
| 349 | - */ |
|
| 350 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * The entity type service (i.e. the schema type). |
|
| 354 | - */ |
|
| 355 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * The entity link service. |
|
| 359 | - */ |
|
| 360 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * The Query builder. |
|
| 364 | - */ |
|
| 365 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * The Schema service. |
|
| 369 | - */ |
|
| 370 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * The schema:url property service. |
|
| 374 | - */ |
|
| 375 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 376 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * The UI service. |
|
| 380 | - */ |
|
| 381 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 382 | - |
|
| 383 | - /** |
|
| 384 | - * The Thumbnail service. |
|
| 385 | - */ |
|
| 386 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * The Entity Types Taxonomy service. |
|
| 390 | - */ |
|
| 391 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * The Entity service. |
|
| 395 | - */ |
|
| 396 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 397 | - |
|
| 398 | - /** |
|
| 399 | - * The User service. |
|
| 400 | - */ |
|
| 401 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 402 | - |
|
| 403 | - /** |
|
| 404 | - * The Timeline service. |
|
| 405 | - */ |
|
| 406 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * The Topic Taxonomy service. |
|
| 410 | - */ |
|
| 411 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 412 | - |
|
| 413 | - |
|
| 414 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 415 | - |
|
| 416 | - /** |
|
| 417 | - * The SPARQL service. |
|
| 418 | - */ |
|
| 419 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * The WordLift import service. |
|
| 423 | - */ |
|
| 424 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 425 | - |
|
| 426 | - /** |
|
| 427 | - * The WordLift URI service. |
|
| 428 | - */ |
|
| 429 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 430 | - |
|
| 431 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 432 | - |
|
| 433 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 434 | - |
|
| 435 | - /** |
|
| 436 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 437 | - */ |
|
| 438 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 439 | - |
|
| 440 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 441 | - |
|
| 442 | - /** |
|
| 443 | - * Load the converters. |
|
| 444 | - */ |
|
| 445 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 446 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-to-jsonld-converter.php'; |
|
| 447 | - |
|
| 448 | - /** |
|
| 449 | - * Load the content filter. |
|
| 450 | - */ |
|
| 451 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 452 | - |
|
| 453 | - /** |
|
| 454 | - * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 455 | - * |
|
| 456 | - * @since 3.8.0 |
|
| 457 | - */ |
|
| 458 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 459 | - |
|
| 460 | - /** |
|
| 461 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 462 | - */ |
|
| 463 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * The class to customize the entity list admin page. |
|
| 467 | - */ |
|
| 468 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 469 | - |
|
| 470 | - /** |
|
| 471 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 472 | - */ |
|
| 473 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 474 | - |
|
| 475 | - /** |
|
| 476 | - * The Notice service. |
|
| 477 | - */ |
|
| 478 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 479 | - |
|
| 480 | - /** |
|
| 481 | - * The PrimaShop adapter. |
|
| 482 | - */ |
|
| 483 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 484 | - |
|
| 485 | - /** |
|
| 486 | - * The WordLift Dashboard service. |
|
| 487 | - */ |
|
| 488 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 32 | + /** |
|
| 33 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | + * the plugin. |
|
| 35 | + * |
|
| 36 | + * @since 1.0.0 |
|
| 37 | + * @access protected |
|
| 38 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | + */ |
|
| 40 | + protected $loader; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The unique identifier of this plugin. |
|
| 44 | + * |
|
| 45 | + * @since 1.0.0 |
|
| 46 | + * @access protected |
|
| 47 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | + */ |
|
| 49 | + protected $plugin_name; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * The current version of the plugin. |
|
| 53 | + * |
|
| 54 | + * @since 1.0.0 |
|
| 55 | + * @access protected |
|
| 56 | + * @var string $version The current version of the plugin. |
|
| 57 | + */ |
|
| 58 | + protected $version; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * The Thumbnail service. |
|
| 62 | + * |
|
| 63 | + * @since 3.1.5 |
|
| 64 | + * @access private |
|
| 65 | + * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 66 | + */ |
|
| 67 | + private $thumbnail_service; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The UI service. |
|
| 71 | + * |
|
| 72 | + * @since 3.2.0 |
|
| 73 | + * @access private |
|
| 74 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 75 | + */ |
|
| 76 | + private $ui_service; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * The Schema service. |
|
| 80 | + * |
|
| 81 | + * @since 3.3.0 |
|
| 82 | + * @access private |
|
| 83 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 84 | + */ |
|
| 85 | + private $schema_service; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * The Entity service. |
|
| 89 | + * |
|
| 90 | + * @since 3.1.0 |
|
| 91 | + * @access private |
|
| 92 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 93 | + */ |
|
| 94 | + private $entity_service; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * The Topic Taxonomy service. |
|
| 98 | + * |
|
| 99 | + * @since 3.5.0 |
|
| 100 | + * @access private |
|
| 101 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 102 | + */ |
|
| 103 | + private $topic_taxonomy_service; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * The User service. |
|
| 107 | + * |
|
| 108 | + * @since 3.1.7 |
|
| 109 | + * @access private |
|
| 110 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 111 | + */ |
|
| 112 | + private $user_service; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * The Timeline service. |
|
| 116 | + * |
|
| 117 | + * @since 3.1.0 |
|
| 118 | + * @access private |
|
| 119 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 120 | + */ |
|
| 121 | + private $timeline_service; |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * The Redirect service. |
|
| 125 | + * |
|
| 126 | + * @since 3.2.0 |
|
| 127 | + * @access private |
|
| 128 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 129 | + */ |
|
| 130 | + private $redirect_service; |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * The Notice service. |
|
| 134 | + * |
|
| 135 | + * @since 3.3.0 |
|
| 136 | + * @access private |
|
| 137 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 138 | + */ |
|
| 139 | + private $notice_service; |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * The Entity list customization. |
|
| 143 | + * |
|
| 144 | + * @since 3.3.0 |
|
| 145 | + * @access private |
|
| 146 | + * @var \Wordlift_List_Service $entity_list_service The Entity list service. |
|
| 147 | + */ |
|
| 148 | + private $entity_list_service; |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * The Entity Types Taxonomy Walker. |
|
| 152 | + * |
|
| 153 | + * @since 3.1.0 |
|
| 154 | + * @access private |
|
| 155 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 156 | + */ |
|
| 157 | + private $entity_types_taxonomy_walker; |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * The ShareThis service. |
|
| 161 | + * |
|
| 162 | + * @since 3.2.0 |
|
| 163 | + * @access private |
|
| 164 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 165 | + */ |
|
| 166 | + private $sharethis_service; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * The PrimaShop adapter. |
|
| 170 | + * |
|
| 171 | + * @since 3.2.3 |
|
| 172 | + * @access private |
|
| 173 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 174 | + */ |
|
| 175 | + private $primashop_adapter; |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * The WordLift Dashboard adapter. |
|
| 179 | + * |
|
| 180 | + * @since 3.4.0 |
|
| 181 | + * @access private |
|
| 182 | + * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 183 | + */ |
|
| 184 | + private $dashboard_service; |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * The entity type service. |
|
| 188 | + * |
|
| 189 | + * @since 3.6.0 |
|
| 190 | + * @access private |
|
| 191 | + * @var \Wordlift_Entity_Post_Type_Service |
|
| 192 | + */ |
|
| 193 | + private $entity_post_type_service; |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 197 | + * |
|
| 198 | + * @since 3.6.0 |
|
| 199 | + * @access private |
|
| 200 | + * @var \Wordlift_Entity_Link_Service |
|
| 201 | + */ |
|
| 202 | + private $entity_link_service; |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * The page service instance which processes the page output in order to insert schema.org microdata to export the |
|
| 206 | + * correct page title to Google+. |
|
| 207 | + * |
|
| 208 | + * @since 3.5.3 |
|
| 209 | + * @access private |
|
| 210 | + * @var \Wordlift_Page_Service |
|
| 211 | + */ |
|
| 212 | + private $page_service; |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 216 | + * |
|
| 217 | + * @var 3.6.0 |
|
| 218 | + * @access private |
|
| 219 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 220 | + */ |
|
| 221 | + private $sparql_service; |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * A {@link Wordlift_Import_Service} instance. |
|
| 225 | + * |
|
| 226 | + * @since 3.6.0 |
|
| 227 | + * @access private |
|
| 228 | + * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 229 | + */ |
|
| 230 | + private $import_service; |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * A {@link Wordlift_Rebuild_Service} instance. |
|
| 234 | + * |
|
| 235 | + * @since 3.6.0 |
|
| 236 | + * @access private |
|
| 237 | + * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 238 | + */ |
|
| 239 | + private $rebuild_service; |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * A {@link Wordlift_Jsonld_Service} instance. |
|
| 243 | + * |
|
| 244 | + * @since 3.7.0 |
|
| 245 | + * @access private |
|
| 246 | + * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance. |
|
| 247 | + */ |
|
| 248 | + private $jsonld_service; |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * |
|
| 252 | + * @since 3.7.0 |
|
| 253 | + * @access private |
|
| 254 | + * @var \Wordlift_Property_Factory $property_factory |
|
| 255 | + */ |
|
| 256 | + private $property_factory; |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * The 'Download Your Data' page. |
|
| 260 | + * |
|
| 261 | + * @since 3.6.0 |
|
| 262 | + * @access private |
|
| 263 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 264 | + */ |
|
| 265 | + private $download_your_data_page; |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * The Content Filter Service hooks up to the 'the_content' filter and provides |
|
| 269 | + * linking of entities to their pages. |
|
| 270 | + * |
|
| 271 | + * @since 3.8.0 |
|
| 272 | + * @access private |
|
| 273 | + * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance. |
|
| 274 | + */ |
|
| 275 | + private $content_filter_service; |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * Define the core functionality of the plugin. |
|
| 279 | + * |
|
| 280 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 281 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 282 | + * the public-facing side of the site. |
|
| 283 | + * |
|
| 284 | + * @since 1.0.0 |
|
| 285 | + */ |
|
| 286 | + public function __construct() { |
|
| 287 | + |
|
| 288 | + $this->plugin_name = 'wordlift'; |
|
| 289 | + $this->version = '3.9.0-dev'; |
|
| 290 | + $this->load_dependencies(); |
|
| 291 | + $this->set_locale(); |
|
| 292 | + $this->define_admin_hooks(); |
|
| 293 | + $this->define_public_hooks(); |
|
| 294 | + |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * Load the required dependencies for this plugin. |
|
| 299 | + * |
|
| 300 | + * Include the following files that make up the plugin: |
|
| 301 | + * |
|
| 302 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 303 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 304 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 305 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 306 | + * |
|
| 307 | + * Create an instance of the loader which will be used to register the hooks |
|
| 308 | + * with WordPress. |
|
| 309 | + * |
|
| 310 | + * @since 1.0.0 |
|
| 311 | + * @access private |
|
| 312 | + */ |
|
| 313 | + private function load_dependencies() { |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * The class responsible for orchestrating the actions and filters of the |
|
| 317 | + * core plugin. |
|
| 318 | + */ |
|
| 319 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * The class responsible for defining internationalization functionality |
|
| 323 | + * of the plugin. |
|
| 324 | + */ |
|
| 325 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * Provide support functions to sanitize data. |
|
| 329 | + */ |
|
| 330 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * The Redirect service. |
|
| 334 | + */ |
|
| 335 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * The Log service. |
|
| 339 | + */ |
|
| 340 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * The configuration service. |
|
| 344 | + */ |
|
| 345 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 346 | + |
|
| 347 | + /** |
|
| 348 | + * The entity post type service (this is the WordPress post type, not the entity schema type). |
|
| 349 | + */ |
|
| 350 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * The entity type service (i.e. the schema type). |
|
| 354 | + */ |
|
| 355 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * The entity link service. |
|
| 359 | + */ |
|
| 360 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * The Query builder. |
|
| 364 | + */ |
|
| 365 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * The Schema service. |
|
| 369 | + */ |
|
| 370 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * The schema:url property service. |
|
| 374 | + */ |
|
| 375 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 376 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * The UI service. |
|
| 380 | + */ |
|
| 381 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 382 | + |
|
| 383 | + /** |
|
| 384 | + * The Thumbnail service. |
|
| 385 | + */ |
|
| 386 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * The Entity Types Taxonomy service. |
|
| 390 | + */ |
|
| 391 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * The Entity service. |
|
| 395 | + */ |
|
| 396 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 397 | + |
|
| 398 | + /** |
|
| 399 | + * The User service. |
|
| 400 | + */ |
|
| 401 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 402 | + |
|
| 403 | + /** |
|
| 404 | + * The Timeline service. |
|
| 405 | + */ |
|
| 406 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * The Topic Taxonomy service. |
|
| 410 | + */ |
|
| 411 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 412 | + |
|
| 413 | + |
|
| 414 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 415 | + |
|
| 416 | + /** |
|
| 417 | + * The SPARQL service. |
|
| 418 | + */ |
|
| 419 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * The WordLift import service. |
|
| 423 | + */ |
|
| 424 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 425 | + |
|
| 426 | + /** |
|
| 427 | + * The WordLift URI service. |
|
| 428 | + */ |
|
| 429 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 430 | + |
|
| 431 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 432 | + |
|
| 433 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php'; |
|
| 434 | + |
|
| 435 | + /** |
|
| 436 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 437 | + */ |
|
| 438 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 439 | + |
|
| 440 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
| 441 | + |
|
| 442 | + /** |
|
| 443 | + * Load the converters. |
|
| 444 | + */ |
|
| 445 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
| 446 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-to-jsonld-converter.php'; |
|
| 447 | + |
|
| 448 | + /** |
|
| 449 | + * Load the content filter. |
|
| 450 | + */ |
|
| 451 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php'; |
|
| 452 | + |
|
| 453 | + /** |
|
| 454 | + * Load the JSON-LD service to publish entities using JSON-LD.s |
|
| 455 | + * |
|
| 456 | + * @since 3.8.0 |
|
| 457 | + */ |
|
| 458 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php'; |
|
| 459 | + |
|
| 460 | + /** |
|
| 461 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 462 | + */ |
|
| 463 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * The class to customize the entity list admin page. |
|
| 467 | + */ |
|
| 468 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 469 | + |
|
| 470 | + /** |
|
| 471 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 472 | + */ |
|
| 473 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 474 | + |
|
| 475 | + /** |
|
| 476 | + * The Notice service. |
|
| 477 | + */ |
|
| 478 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 479 | + |
|
| 480 | + /** |
|
| 481 | + * The PrimaShop adapter. |
|
| 482 | + */ |
|
| 483 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 484 | + |
|
| 485 | + /** |
|
| 486 | + * The WordLift Dashboard service. |
|
| 487 | + */ |
|
| 488 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 489 | 489 | |
| 490 | - /** |
|
| 491 | - * The admin 'Download Your Data' page. |
|
| 492 | - */ |
|
| 493 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 490 | + /** |
|
| 491 | + * The admin 'Download Your Data' page. |
|
| 492 | + */ |
|
| 493 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 494 | 494 | |
| 495 | - /** |
|
| 496 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 497 | - * side of the site. |
|
| 498 | - */ |
|
| 499 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 495 | + /** |
|
| 496 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 497 | + * side of the site. |
|
| 498 | + */ |
|
| 499 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 500 | 500 | |
| 501 | - /** |
|
| 502 | - * The shortcode abstract class. |
|
| 503 | - */ |
|
| 504 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 501 | + /** |
|
| 502 | + * The shortcode abstract class. |
|
| 503 | + */ |
|
| 504 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 505 | 505 | |
| 506 | - /** |
|
| 507 | - * The Timeline shortcode. |
|
| 508 | - */ |
|
| 509 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 506 | + /** |
|
| 507 | + * The Timeline shortcode. |
|
| 508 | + */ |
|
| 509 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 510 | 510 | |
| 511 | - /** |
|
| 512 | - * The Navigator shortcode. |
|
| 513 | - */ |
|
| 514 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 511 | + /** |
|
| 512 | + * The Navigator shortcode. |
|
| 513 | + */ |
|
| 514 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 515 | 515 | |
| 516 | - /** |
|
| 517 | - * The chord shortcode. |
|
| 518 | - */ |
|
| 519 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 516 | + /** |
|
| 517 | + * The chord shortcode. |
|
| 518 | + */ |
|
| 519 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 520 | 520 | |
| 521 | - /** |
|
| 522 | - * The geomap shortcode. |
|
| 523 | - */ |
|
| 524 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 521 | + /** |
|
| 522 | + * The geomap shortcode. |
|
| 523 | + */ |
|
| 524 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 525 | 525 | |
| 526 | - /** |
|
| 527 | - * The ShareThis service. |
|
| 528 | - */ |
|
| 529 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 526 | + /** |
|
| 527 | + * The ShareThis service. |
|
| 528 | + */ |
|
| 529 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 530 | 530 | |
| 531 | - $this->loader = new Wordlift_Loader(); |
|
| 531 | + $this->loader = new Wordlift_Loader(); |
|
| 532 | 532 | |
| 533 | - // Instantiate a global logger. |
|
| 534 | - global $wl_logger; |
|
| 535 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 533 | + // Instantiate a global logger. |
|
| 534 | + global $wl_logger; |
|
| 535 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 536 | 536 | |
| 537 | - // Create the configuration service. |
|
| 538 | - $configuration_service = new Wordlift_Configuration_Service(); |
|
| 537 | + // Create the configuration service. |
|
| 538 | + $configuration_service = new Wordlift_Configuration_Service(); |
|
| 539 | 539 | |
| 540 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 541 | - $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() ); |
|
| 540 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 541 | + $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() ); |
|
| 542 | 542 | |
| 543 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 544 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $configuration_service->get_entity_base_path() ); |
|
| 543 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 544 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $configuration_service->get_entity_base_path() ); |
|
| 545 | 545 | |
| 546 | - // Create an instance of the UI service. |
|
| 547 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 546 | + // Create an instance of the UI service. |
|
| 547 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 548 | 548 | |
| 549 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 550 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 549 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 550 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 551 | 551 | |
| 552 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 552 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 553 | 553 | |
| 554 | - // Create an instance of the Schema service. |
|
| 555 | - $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 556 | - $this->schema_service = new Wordlift_Schema_Service(); |
|
| 554 | + // Create an instance of the Schema service. |
|
| 555 | + $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 556 | + $this->schema_service = new Wordlift_Schema_Service(); |
|
| 557 | 557 | |
| 558 | - // Create an instance of the Notice service. |
|
| 559 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 558 | + // Create an instance of the Notice service. |
|
| 559 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 560 | 560 | |
| 561 | - // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 562 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 561 | + // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 562 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 563 | 563 | |
| 564 | - // Create an instance of the User service. |
|
| 565 | - $this->user_service = new Wordlift_User_Service(); |
|
| 564 | + // Create an instance of the User service. |
|
| 565 | + $this->user_service = new Wordlift_User_Service(); |
|
| 566 | 566 | |
| 567 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 568 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 567 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 568 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 569 | 569 | |
| 570 | - // Create a new instance of the Redirect service. |
|
| 571 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 570 | + // Create a new instance of the Redirect service. |
|
| 571 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 572 | 572 | |
| 573 | - // Create a new instance of the Redirect service. |
|
| 574 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 573 | + // Create a new instance of the Redirect service. |
|
| 574 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 575 | 575 | |
| 576 | - // Initialize the shortcodes. |
|
| 577 | - new Wordlift_Navigator_Shortcode(); |
|
| 578 | - new Wordlift_Chord_Shortcode(); |
|
| 579 | - new Wordlift_Geomap_Shortcode(); |
|
| 580 | - new Wordlift_Timeline_Shortcode(); |
|
| 576 | + // Initialize the shortcodes. |
|
| 577 | + new Wordlift_Navigator_Shortcode(); |
|
| 578 | + new Wordlift_Chord_Shortcode(); |
|
| 579 | + new Wordlift_Geomap_Shortcode(); |
|
| 580 | + new Wordlift_Timeline_Shortcode(); |
|
| 581 | 581 | |
| 582 | - // Create entity list customization (wp-admin/edit.php) |
|
| 583 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 582 | + // Create entity list customization (wp-admin/edit.php) |
|
| 583 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 584 | 584 | |
| 585 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 585 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 586 | 586 | |
| 587 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 587 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 588 | 588 | |
| 589 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 590 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 589 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 590 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 591 | 591 | |
| 592 | - // Create an instance of the PrimaShop adapter. |
|
| 593 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 592 | + // Create an instance of the PrimaShop adapter. |
|
| 593 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 594 | 594 | |
| 595 | - $this->page_service = new Wordlift_Page_Service(); |
|
| 595 | + $this->page_service = new Wordlift_Page_Service(); |
|
| 596 | 596 | |
| 597 | - // Create an import service instance to hook later to WP's import function. |
|
| 598 | - $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() ); |
|
| 597 | + // Create an import service instance to hook later to WP's import function. |
|
| 598 | + $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() ); |
|
| 599 | 599 | |
| 600 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 600 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 601 | 601 | |
| 602 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 603 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 602 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 603 | + $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 604 | 604 | |
| 605 | - $entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 605 | + $entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service ); |
|
| 606 | 606 | |
| 607 | - $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 608 | - $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 607 | + $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
| 608 | + $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
| 609 | 609 | |
| 610 | - // Instantiate the JSON-LD service. |
|
| 611 | - $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 612 | - $entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter( $entity_type_service, $this->entity_service, $property_getter ); |
|
| 613 | - $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $entity_uri_to_jsonld_converter ); |
|
| 610 | + // Instantiate the JSON-LD service. |
|
| 611 | + $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service ); |
|
| 612 | + $entity_uri_to_jsonld_converter = new Wordlift_Entity_Uri_To_Jsonld_Converter( $entity_type_service, $this->entity_service, $property_getter ); |
|
| 613 | + $this->jsonld_service = new Wordlift_Jsonld_Service( $this->entity_service, $entity_uri_to_jsonld_converter ); |
|
| 614 | 614 | |
| 615 | - //** WordPress Admin */ |
|
| 616 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page(); |
|
| 615 | + //** WordPress Admin */ |
|
| 616 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page(); |
|
| 617 | 617 | |
| 618 | - // Create an instance of the content filter service. |
|
| 619 | - $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service ); |
|
| 618 | + // Create an instance of the content filter service. |
|
| 619 | + $this->content_filter_service = new Wordlift_Content_Filter_Service( $this->entity_service ); |
|
| 620 | 620 | |
| 621 | - } |
|
| 621 | + } |
|
| 622 | 622 | |
| 623 | - /** |
|
| 624 | - * Define the locale for this plugin for internationalization. |
|
| 625 | - * |
|
| 626 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 627 | - * with WordPress. |
|
| 628 | - * |
|
| 629 | - * @since 1.0.0 |
|
| 630 | - * @access private |
|
| 631 | - */ |
|
| 632 | - private function set_locale() { |
|
| 623 | + /** |
|
| 624 | + * Define the locale for this plugin for internationalization. |
|
| 625 | + * |
|
| 626 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 627 | + * with WordPress. |
|
| 628 | + * |
|
| 629 | + * @since 1.0.0 |
|
| 630 | + * @access private |
|
| 631 | + */ |
|
| 632 | + private function set_locale() { |
|
| 633 | 633 | |
| 634 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 635 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 634 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 635 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 636 | 636 | |
| 637 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 637 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 638 | 638 | |
| 639 | - } |
|
| 639 | + } |
|
| 640 | 640 | |
| 641 | - /** |
|
| 642 | - * Register all of the hooks related to the admin area functionality |
|
| 643 | - * of the plugin. |
|
| 644 | - * |
|
| 645 | - * @since 1.0.0 |
|
| 646 | - * @access private |
|
| 647 | - */ |
|
| 648 | - private function define_admin_hooks() { |
|
| 641 | + /** |
|
| 642 | + * Register all of the hooks related to the admin area functionality |
|
| 643 | + * of the plugin. |
|
| 644 | + * |
|
| 645 | + * @since 1.0.0 |
|
| 646 | + * @access private |
|
| 647 | + */ |
|
| 648 | + private function define_admin_hooks() { |
|
| 649 | 649 | |
| 650 | - $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 650 | + $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 651 | 651 | |
| 652 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 653 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 652 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 653 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 654 | 654 | |
| 655 | - // Hook the init action to the Topic Taxonomy service. |
|
| 656 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 655 | + // Hook the init action to the Topic Taxonomy service. |
|
| 656 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 657 | 657 | |
| 658 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 659 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 658 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 659 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 660 | 660 | |
| 661 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 662 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 661 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 662 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 663 | 663 | |
| 664 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 665 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 664 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 665 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 666 | 666 | |
| 667 | - // Hook posts inserts (or updates) to the user service. |
|
| 668 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 667 | + // Hook posts inserts (or updates) to the user service. |
|
| 668 | + $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 669 | 669 | |
| 670 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 671 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 670 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 671 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 672 | 672 | |
| 673 | - // Register custom allowed redirect hosts. |
|
| 674 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 675 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 676 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 677 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 678 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 679 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 680 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 673 | + // Register custom allowed redirect hosts. |
|
| 674 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 675 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 676 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 677 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 678 | + $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 679 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 680 | + $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 681 | 681 | |
| 682 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 683 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 684 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 685 | - $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 682 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 683 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 684 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 685 | + $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 686 | 686 | |
| 687 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 688 | - $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 687 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 688 | + $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 689 | 689 | |
| 690 | - // Entity listing customization (wp-admin/edit.php) |
|
| 691 | - // Add custom columns |
|
| 692 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 693 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 694 | - // Add 4W selection |
|
| 695 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 696 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 697 | - |
|
| 698 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 699 | - |
|
| 700 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 701 | - // entities. |
|
| 702 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 703 | - |
|
| 704 | - // Filter imported post meta. |
|
| 705 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 706 | - |
|
| 707 | - // Notify the import service when an import starts and ends. |
|
| 708 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 709 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 710 | - |
|
| 711 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 712 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 713 | - |
|
| 714 | - // Hook the menu to the Download Your Data page. |
|
| 715 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 716 | - |
|
| 717 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 718 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 719 | - |
|
| 720 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 721 | - $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 722 | - |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - /** |
|
| 726 | - * Register all of the hooks related to the public-facing functionality |
|
| 727 | - * of the plugin. |
|
| 728 | - * |
|
| 729 | - * @since 1.0.0 |
|
| 730 | - * @access private |
|
| 731 | - */ |
|
| 732 | - private function define_public_hooks() { |
|
| 733 | - |
|
| 734 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 735 | - |
|
| 736 | - // Register the entity post type. |
|
| 737 | - $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 738 | - |
|
| 739 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 740 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 741 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 742 | - $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 743 | - $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 744 | - |
|
| 745 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 746 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 747 | - |
|
| 748 | - // Hook the content filter service to add entity links. |
|
| 749 | - $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content'); |
|
| 750 | - |
|
| 751 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 752 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 753 | - |
|
| 754 | - // Hook the ShareThis service. |
|
| 755 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 756 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 757 | - |
|
| 758 | - $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 759 | - $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 760 | - |
|
| 761 | - // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 762 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 763 | - |
|
| 764 | - } |
|
| 765 | - |
|
| 766 | - /** |
|
| 767 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 768 | - * |
|
| 769 | - * @since 1.0.0 |
|
| 770 | - */ |
|
| 771 | - public function run() { |
|
| 772 | - $this->loader->run(); |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - /** |
|
| 776 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 777 | - * WordPress and to define internationalization functionality. |
|
| 778 | - * |
|
| 779 | - * @since 1.0.0 |
|
| 780 | - * @return string The name of the plugin. |
|
| 781 | - */ |
|
| 782 | - public function get_plugin_name() { |
|
| 783 | - return $this->plugin_name; |
|
| 784 | - } |
|
| 785 | - |
|
| 786 | - /** |
|
| 787 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 788 | - * |
|
| 789 | - * @since 1.0.0 |
|
| 790 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 791 | - */ |
|
| 792 | - public function get_loader() { |
|
| 793 | - return $this->loader; |
|
| 794 | - } |
|
| 795 | - |
|
| 796 | - /** |
|
| 797 | - * Retrieve the version number of the plugin. |
|
| 798 | - * |
|
| 799 | - * @since 1.0.0 |
|
| 800 | - * @return string The version number of the plugin. |
|
| 801 | - */ |
|
| 802 | - public function get_version() { |
|
| 803 | - return $this->version; |
|
| 804 | - } |
|
| 690 | + // Entity listing customization (wp-admin/edit.php) |
|
| 691 | + // Add custom columns |
|
| 692 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 693 | + $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 694 | + // Add 4W selection |
|
| 695 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 696 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 697 | + |
|
| 698 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 699 | + |
|
| 700 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 701 | + // entities. |
|
| 702 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 703 | + |
|
| 704 | + // Filter imported post meta. |
|
| 705 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 706 | + |
|
| 707 | + // Notify the import service when an import starts and ends. |
|
| 708 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 709 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 710 | + |
|
| 711 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 712 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 713 | + |
|
| 714 | + // Hook the menu to the Download Your Data page. |
|
| 715 | + $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 716 | + |
|
| 717 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 718 | + $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 719 | + |
|
| 720 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 721 | + $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 722 | + |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + /** |
|
| 726 | + * Register all of the hooks related to the public-facing functionality |
|
| 727 | + * of the plugin. |
|
| 728 | + * |
|
| 729 | + * @since 1.0.0 |
|
| 730 | + * @access private |
|
| 731 | + */ |
|
| 732 | + private function define_public_hooks() { |
|
| 733 | + |
|
| 734 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 735 | + |
|
| 736 | + // Register the entity post type. |
|
| 737 | + $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' ); |
|
| 738 | + |
|
| 739 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 740 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 741 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 742 | + $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 743 | + $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 744 | + |
|
| 745 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 746 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 747 | + |
|
| 748 | + // Hook the content filter service to add entity links. |
|
| 749 | + $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content'); |
|
| 750 | + |
|
| 751 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 752 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 753 | + |
|
| 754 | + // Hook the ShareThis service. |
|
| 755 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 756 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 757 | + |
|
| 758 | + $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 759 | + $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 760 | + |
|
| 761 | + // Hook the AJAX wl_jsonld action to the JSON-LD service. |
|
| 762 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' ); |
|
| 763 | + |
|
| 764 | + } |
|
| 765 | + |
|
| 766 | + /** |
|
| 767 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 768 | + * |
|
| 769 | + * @since 1.0.0 |
|
| 770 | + */ |
|
| 771 | + public function run() { |
|
| 772 | + $this->loader->run(); |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + /** |
|
| 776 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 777 | + * WordPress and to define internationalization functionality. |
|
| 778 | + * |
|
| 779 | + * @since 1.0.0 |
|
| 780 | + * @return string The name of the plugin. |
|
| 781 | + */ |
|
| 782 | + public function get_plugin_name() { |
|
| 783 | + return $this->plugin_name; |
|
| 784 | + } |
|
| 785 | + |
|
| 786 | + /** |
|
| 787 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 788 | + * |
|
| 789 | + * @since 1.0.0 |
|
| 790 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 791 | + */ |
|
| 792 | + public function get_loader() { |
|
| 793 | + return $this->loader; |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + /** |
|
| 797 | + * Retrieve the version number of the plugin. |
|
| 798 | + * |
|
| 799 | + * @since 1.0.0 |
|
| 800 | + * @return string The version number of the plugin. |
|
| 801 | + */ |
|
| 802 | + public function get_version() { |
|
| 803 | + return $this->version; |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | 806 | } |