@@ -11,25 +11,25 @@ |
||
| 11 | 11 | * Define the {@link Wordlift_Sparql_Tuple_Rendition} interface. |
| 12 | 12 | */ |
| 13 | 13 | interface Wordlift_Sparql_Tuple_Rendition { |
| 14 | - /** |
|
| 15 | - * Get tuple representations for the specified {@link WP_Post}. |
|
| 16 | - * |
|
| 17 | - * @since 3.18.0 |
|
| 18 | - * |
|
| 19 | - * @param int $post_id The {@link WP_Post}'s id. |
|
| 20 | - * |
|
| 21 | - * @return array An array of triples. |
|
| 22 | - */ |
|
| 23 | - public function get_insert_triples( $post_id ); |
|
| 14 | + /** |
|
| 15 | + * Get tuple representations for the specified {@link WP_Post}. |
|
| 16 | + * |
|
| 17 | + * @since 3.18.0 |
|
| 18 | + * |
|
| 19 | + * @param int $post_id The {@link WP_Post}'s id. |
|
| 20 | + * |
|
| 21 | + * @return array An array of triples. |
|
| 22 | + */ |
|
| 23 | + public function get_insert_triples( $post_id ); |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Get delete statement for current post uri. |
|
| 27 | - * |
|
| 28 | - * @since 3.18.0 |
|
| 29 | - * |
|
| 30 | - * @param int $post_id The post id. |
|
| 31 | - * |
|
| 32 | - * @return array An array of delete triples (`<...> <...> ?o` and `?s <...> <...>`). |
|
| 33 | - */ |
|
| 34 | - public function get_delete_triples( $post_id ); |
|
| 25 | + /** |
|
| 26 | + * Get delete statement for current post uri. |
|
| 27 | + * |
|
| 28 | + * @since 3.18.0 |
|
| 29 | + * |
|
| 30 | + * @param int $post_id The post id. |
|
| 31 | + * |
|
| 32 | + * @return array An array of delete triples (`<...> <...> ?o` and `?s <...> <...>`). |
|
| 33 | + */ |
|
| 34 | + public function get_delete_triples( $post_id ); |
|
| 35 | 35 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return array An array of triples. |
| 22 | 22 | */ |
| 23 | - public function get_insert_triples( $post_id ); |
|
| 23 | + public function get_insert_triples($post_id); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Get delete statement for current post uri. |
@@ -31,5 +31,5 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @return array An array of delete triples (`<...> <...> ?o` and `?s <...> <...>`). |
| 33 | 33 | */ |
| 34 | - public function get_delete_triples( $post_id ); |
|
| 34 | + public function get_delete_triples($post_id); |
|
| 35 | 35 | } |
@@ -19,145 +19,145 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Wordlift_Default_Sparql_Tuple_Rendition implements Wordlift_Sparql_Tuple_Rendition { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * A {@link Wordlift_Storage} instance to read a property. |
|
| 24 | - * |
|
| 25 | - * @since 3.15.0 |
|
| 26 | - * @access private |
|
| 27 | - * @var \Wordlift_Storage $storage A {@link Wordlift_Storage} instance to |
|
| 28 | - * read a property. |
|
| 29 | - */ |
|
| 30 | - private $storage; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * The data type (or null if not set). |
|
| 34 | - * |
|
| 35 | - * @since 3.15.0 |
|
| 36 | - * @access private |
|
| 37 | - * @var string|null $data_type The data type (or null if not set). |
|
| 38 | - */ |
|
| 39 | - private $data_type; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * The language (or null if not set). |
|
| 43 | - * |
|
| 44 | - * @since 3.15.0 |
|
| 45 | - * @access private |
|
| 46 | - * @var string|null $language The language (or null if not set). |
|
| 47 | - */ |
|
| 48 | - private $language; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * The {@link Wordlift_Entity_Service} instance. |
|
| 52 | - * |
|
| 53 | - * @since 3.15.0 |
|
| 54 | - * @access private |
|
| 55 | - * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 56 | - */ |
|
| 57 | - private $entity_service; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * The predicate URI. |
|
| 61 | - * |
|
| 62 | - * @since 3.15.0 |
|
| 63 | - * @access private |
|
| 64 | - * @var string $predicate The predicate URI. |
|
| 65 | - */ |
|
| 66 | - private $predicate; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * The URI suffix. |
|
| 70 | - * |
|
| 71 | - * @since 3.18.0 |
|
| 72 | - * @access private |
|
| 73 | - * @var null|string $uri_suffix The URI suffix or null if no suffix is required. |
|
| 74 | - */ |
|
| 75 | - private $uri_suffix; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Create a {@link Wordlift_Sparql_Tuple_Rendition} instance. |
|
| 79 | - * |
|
| 80 | - * @since 3.15.0 |
|
| 81 | - * |
|
| 82 | - * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} |
|
| 83 | - * instance. |
|
| 84 | - * @param \Wordlift_Storage $storage The {@link Wordlift_Storage} |
|
| 85 | - * instance. |
|
| 86 | - * @param string $predicate The predicate URI. |
|
| 87 | - * @param string|null $data_type The data type or null. |
|
| 88 | - * @param string|null $language The language code or null. |
|
| 89 | - * @param string|null $uri_suffix The URI suffix, used for example for 2nd level entities, like location. |
|
| 90 | - */ |
|
| 91 | - public function __construct( $entity_service, $storage, $predicate, $data_type = null, $language = null, $uri_suffix = null ) { |
|
| 92 | - |
|
| 93 | - $this->entity_service = $entity_service; |
|
| 94 | - $this->storage = $storage; |
|
| 95 | - $this->predicate = $predicate; |
|
| 96 | - $this->data_type = $data_type; |
|
| 97 | - $this->language = $language; |
|
| 98 | - $this->uri_suffix = ( ! is_null( $uri_suffix ) ) ? $uri_suffix : ''; |
|
| 99 | - |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Get tuple representations for the specified {@link WP_Post}. |
|
| 104 | - * |
|
| 105 | - * @since 3.15.0 |
|
| 106 | - * |
|
| 107 | - * @param int $post_id The {@link WP_Post}'s id. |
|
| 108 | - * |
|
| 109 | - * @return array An array of tuples. |
|
| 110 | - */ |
|
| 111 | - public function get_insert_triples( $post_id ) { |
|
| 112 | - // Get the entity URI. |
|
| 113 | - $uri = $this->entity_service->get_uri( $post_id ) . $this->uri_suffix; |
|
| 114 | - |
|
| 115 | - // Get the predicate, data type and language. |
|
| 116 | - $predicate = $this->predicate; |
|
| 117 | - $data_type = $this->data_type; |
|
| 118 | - $language = $this->language; |
|
| 119 | - |
|
| 120 | - // Filter out empty values. |
|
| 121 | - $values = array_filter( (array) $this->storage->get( $post_id ), function ( $item ) { |
|
| 122 | - return ! empty( $item ); |
|
| 123 | - } ); |
|
| 124 | - |
|
| 125 | - // Map the values to tuples. |
|
| 126 | - return array_map( function ( $item ) use ( $uri, $predicate, $data_type, $language ) { |
|
| 127 | - |
|
| 128 | - return sprintf( '<%s> <%s> %s . ', |
|
| 129 | - Wordlift_Sparql_Service::escape_uri( $uri ), |
|
| 130 | - Wordlift_Sparql_Service::escape_uri( $predicate ), |
|
| 131 | - Wordlift_Sparql_Service::format( $item, $data_type, $language ) |
|
| 132 | - ); |
|
| 133 | - }, $values ); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Get the delete statement for current post id. |
|
| 138 | - * |
|
| 139 | - * @since 3.18.0 |
|
| 140 | - * |
|
| 141 | - * @param int $post_id The post id. |
|
| 142 | - * |
|
| 143 | - * @return array An array containing delete statements for both |
|
| 144 | - * the uri as subject and object. |
|
| 145 | - */ |
|
| 146 | - public function get_delete_triples( $post_id ) { |
|
| 147 | - // Get the entity URI. |
|
| 148 | - $uri = $this->entity_service->get_uri( $post_id ) . $this->uri_suffix; |
|
| 149 | - |
|
| 150 | - return array( |
|
| 151 | - // As object. |
|
| 152 | - sprintf( '<%s> <%s> ?o', |
|
| 153 | - Wordlift_Sparql_Service::escape_uri( $uri ), |
|
| 154 | - Wordlift_Sparql_Service::escape_uri( $this->predicate ) |
|
| 155 | - ), |
|
| 156 | - // As subject. |
|
| 157 | - sprintf( '?s <%s> <%s>', |
|
| 158 | - Wordlift_Sparql_Service::escape_uri( $this->predicate ), |
|
| 159 | - Wordlift_Sparql_Service::escape_uri( $uri ) |
|
| 160 | - ), |
|
| 161 | - ); |
|
| 162 | - } |
|
| 22 | + /** |
|
| 23 | + * A {@link Wordlift_Storage} instance to read a property. |
|
| 24 | + * |
|
| 25 | + * @since 3.15.0 |
|
| 26 | + * @access private |
|
| 27 | + * @var \Wordlift_Storage $storage A {@link Wordlift_Storage} instance to |
|
| 28 | + * read a property. |
|
| 29 | + */ |
|
| 30 | + private $storage; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * The data type (or null if not set). |
|
| 34 | + * |
|
| 35 | + * @since 3.15.0 |
|
| 36 | + * @access private |
|
| 37 | + * @var string|null $data_type The data type (or null if not set). |
|
| 38 | + */ |
|
| 39 | + private $data_type; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * The language (or null if not set). |
|
| 43 | + * |
|
| 44 | + * @since 3.15.0 |
|
| 45 | + * @access private |
|
| 46 | + * @var string|null $language The language (or null if not set). |
|
| 47 | + */ |
|
| 48 | + private $language; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * The {@link Wordlift_Entity_Service} instance. |
|
| 52 | + * |
|
| 53 | + * @since 3.15.0 |
|
| 54 | + * @access private |
|
| 55 | + * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 56 | + */ |
|
| 57 | + private $entity_service; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * The predicate URI. |
|
| 61 | + * |
|
| 62 | + * @since 3.15.0 |
|
| 63 | + * @access private |
|
| 64 | + * @var string $predicate The predicate URI. |
|
| 65 | + */ |
|
| 66 | + private $predicate; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * The URI suffix. |
|
| 70 | + * |
|
| 71 | + * @since 3.18.0 |
|
| 72 | + * @access private |
|
| 73 | + * @var null|string $uri_suffix The URI suffix or null if no suffix is required. |
|
| 74 | + */ |
|
| 75 | + private $uri_suffix; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Create a {@link Wordlift_Sparql_Tuple_Rendition} instance. |
|
| 79 | + * |
|
| 80 | + * @since 3.15.0 |
|
| 81 | + * |
|
| 82 | + * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} |
|
| 83 | + * instance. |
|
| 84 | + * @param \Wordlift_Storage $storage The {@link Wordlift_Storage} |
|
| 85 | + * instance. |
|
| 86 | + * @param string $predicate The predicate URI. |
|
| 87 | + * @param string|null $data_type The data type or null. |
|
| 88 | + * @param string|null $language The language code or null. |
|
| 89 | + * @param string|null $uri_suffix The URI suffix, used for example for 2nd level entities, like location. |
|
| 90 | + */ |
|
| 91 | + public function __construct( $entity_service, $storage, $predicate, $data_type = null, $language = null, $uri_suffix = null ) { |
|
| 92 | + |
|
| 93 | + $this->entity_service = $entity_service; |
|
| 94 | + $this->storage = $storage; |
|
| 95 | + $this->predicate = $predicate; |
|
| 96 | + $this->data_type = $data_type; |
|
| 97 | + $this->language = $language; |
|
| 98 | + $this->uri_suffix = ( ! is_null( $uri_suffix ) ) ? $uri_suffix : ''; |
|
| 99 | + |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Get tuple representations for the specified {@link WP_Post}. |
|
| 104 | + * |
|
| 105 | + * @since 3.15.0 |
|
| 106 | + * |
|
| 107 | + * @param int $post_id The {@link WP_Post}'s id. |
|
| 108 | + * |
|
| 109 | + * @return array An array of tuples. |
|
| 110 | + */ |
|
| 111 | + public function get_insert_triples( $post_id ) { |
|
| 112 | + // Get the entity URI. |
|
| 113 | + $uri = $this->entity_service->get_uri( $post_id ) . $this->uri_suffix; |
|
| 114 | + |
|
| 115 | + // Get the predicate, data type and language. |
|
| 116 | + $predicate = $this->predicate; |
|
| 117 | + $data_type = $this->data_type; |
|
| 118 | + $language = $this->language; |
|
| 119 | + |
|
| 120 | + // Filter out empty values. |
|
| 121 | + $values = array_filter( (array) $this->storage->get( $post_id ), function ( $item ) { |
|
| 122 | + return ! empty( $item ); |
|
| 123 | + } ); |
|
| 124 | + |
|
| 125 | + // Map the values to tuples. |
|
| 126 | + return array_map( function ( $item ) use ( $uri, $predicate, $data_type, $language ) { |
|
| 127 | + |
|
| 128 | + return sprintf( '<%s> <%s> %s . ', |
|
| 129 | + Wordlift_Sparql_Service::escape_uri( $uri ), |
|
| 130 | + Wordlift_Sparql_Service::escape_uri( $predicate ), |
|
| 131 | + Wordlift_Sparql_Service::format( $item, $data_type, $language ) |
|
| 132 | + ); |
|
| 133 | + }, $values ); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Get the delete statement for current post id. |
|
| 138 | + * |
|
| 139 | + * @since 3.18.0 |
|
| 140 | + * |
|
| 141 | + * @param int $post_id The post id. |
|
| 142 | + * |
|
| 143 | + * @return array An array containing delete statements for both |
|
| 144 | + * the uri as subject and object. |
|
| 145 | + */ |
|
| 146 | + public function get_delete_triples( $post_id ) { |
|
| 147 | + // Get the entity URI. |
|
| 148 | + $uri = $this->entity_service->get_uri( $post_id ) . $this->uri_suffix; |
|
| 149 | + |
|
| 150 | + return array( |
|
| 151 | + // As object. |
|
| 152 | + sprintf( '<%s> <%s> ?o', |
|
| 153 | + Wordlift_Sparql_Service::escape_uri( $uri ), |
|
| 154 | + Wordlift_Sparql_Service::escape_uri( $this->predicate ) |
|
| 155 | + ), |
|
| 156 | + // As subject. |
|
| 157 | + sprintf( '?s <%s> <%s>', |
|
| 158 | + Wordlift_Sparql_Service::escape_uri( $this->predicate ), |
|
| 159 | + Wordlift_Sparql_Service::escape_uri( $uri ) |
|
| 160 | + ), |
|
| 161 | + ); |
|
| 162 | + } |
|
| 163 | 163 | } |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | * @param string|null $language The language code or null. |
| 89 | 89 | * @param string|null $uri_suffix The URI suffix, used for example for 2nd level entities, like location. |
| 90 | 90 | */ |
| 91 | - public function __construct( $entity_service, $storage, $predicate, $data_type = null, $language = null, $uri_suffix = null ) { |
|
| 91 | + public function __construct($entity_service, $storage, $predicate, $data_type = null, $language = null, $uri_suffix = null) { |
|
| 92 | 92 | |
| 93 | 93 | $this->entity_service = $entity_service; |
| 94 | 94 | $this->storage = $storage; |
| 95 | 95 | $this->predicate = $predicate; |
| 96 | 96 | $this->data_type = $data_type; |
| 97 | 97 | $this->language = $language; |
| 98 | - $this->uri_suffix = ( ! is_null( $uri_suffix ) ) ? $uri_suffix : ''; |
|
| 98 | + $this->uri_suffix = ( ! is_null($uri_suffix)) ? $uri_suffix : ''; |
|
| 99 | 99 | |
| 100 | 100 | } |
| 101 | 101 | |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return array An array of tuples. |
| 110 | 110 | */ |
| 111 | - public function get_insert_triples( $post_id ) { |
|
| 111 | + public function get_insert_triples($post_id) { |
|
| 112 | 112 | // Get the entity URI. |
| 113 | - $uri = $this->entity_service->get_uri( $post_id ) . $this->uri_suffix; |
|
| 113 | + $uri = $this->entity_service->get_uri($post_id).$this->uri_suffix; |
|
| 114 | 114 | |
| 115 | 115 | // Get the predicate, data type and language. |
| 116 | 116 | $predicate = $this->predicate; |
@@ -118,19 +118,19 @@ discard block |
||
| 118 | 118 | $language = $this->language; |
| 119 | 119 | |
| 120 | 120 | // Filter out empty values. |
| 121 | - $values = array_filter( (array) $this->storage->get( $post_id ), function ( $item ) { |
|
| 122 | - return ! empty( $item ); |
|
| 121 | + $values = array_filter((array) $this->storage->get($post_id), function($item) { |
|
| 122 | + return ! empty($item); |
|
| 123 | 123 | } ); |
| 124 | 124 | |
| 125 | 125 | // Map the values to tuples. |
| 126 | - return array_map( function ( $item ) use ( $uri, $predicate, $data_type, $language ) { |
|
| 126 | + return array_map(function($item) use ($uri, $predicate, $data_type, $language) { |
|
| 127 | 127 | |
| 128 | - return sprintf( '<%s> <%s> %s . ', |
|
| 129 | - Wordlift_Sparql_Service::escape_uri( $uri ), |
|
| 130 | - Wordlift_Sparql_Service::escape_uri( $predicate ), |
|
| 131 | - Wordlift_Sparql_Service::format( $item, $data_type, $language ) |
|
| 128 | + return sprintf('<%s> <%s> %s . ', |
|
| 129 | + Wordlift_Sparql_Service::escape_uri($uri), |
|
| 130 | + Wordlift_Sparql_Service::escape_uri($predicate), |
|
| 131 | + Wordlift_Sparql_Service::format($item, $data_type, $language) |
|
| 132 | 132 | ); |
| 133 | - }, $values ); |
|
| 133 | + }, $values); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -143,20 +143,20 @@ discard block |
||
| 143 | 143 | * @return array An array containing delete statements for both |
| 144 | 144 | * the uri as subject and object. |
| 145 | 145 | */ |
| 146 | - public function get_delete_triples( $post_id ) { |
|
| 146 | + public function get_delete_triples($post_id) { |
|
| 147 | 147 | // Get the entity URI. |
| 148 | - $uri = $this->entity_service->get_uri( $post_id ) . $this->uri_suffix; |
|
| 148 | + $uri = $this->entity_service->get_uri($post_id).$this->uri_suffix; |
|
| 149 | 149 | |
| 150 | 150 | return array( |
| 151 | 151 | // As object. |
| 152 | - sprintf( '<%s> <%s> ?o', |
|
| 153 | - Wordlift_Sparql_Service::escape_uri( $uri ), |
|
| 154 | - Wordlift_Sparql_Service::escape_uri( $this->predicate ) |
|
| 152 | + sprintf('<%s> <%s> ?o', |
|
| 153 | + Wordlift_Sparql_Service::escape_uri($uri), |
|
| 154 | + Wordlift_Sparql_Service::escape_uri($this->predicate) |
|
| 155 | 155 | ), |
| 156 | 156 | // As subject. |
| 157 | - sprintf( '?s <%s> <%s>', |
|
| 158 | - Wordlift_Sparql_Service::escape_uri( $this->predicate ), |
|
| 159 | - Wordlift_Sparql_Service::escape_uri( $uri ) |
|
| 157 | + sprintf('?s <%s> <%s>', |
|
| 158 | + Wordlift_Sparql_Service::escape_uri($this->predicate), |
|
| 159 | + Wordlift_Sparql_Service::escape_uri($uri) |
|
| 160 | 160 | ), |
| 161 | 161 | ); |
| 162 | 162 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
| 37 | 37 | */ |
| 38 | - public function __construct( $entity_service ) { |
|
| 38 | + public function __construct($entity_service) { |
|
| 39 | 39 | |
| 40 | 40 | $this->entity_service = $entity_service; |
| 41 | 41 | |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @return \Wordlift_Default_Sparql_Tuple_Rendition A {@link Wordlift_Default_Sparql_Tuple_Rendition} instance. |
| 56 | 56 | */ |
| 57 | - public function create( $storage, $predicate, $data_type = null, $language = null, $uri_suffix = null ) { |
|
| 57 | + public function create($storage, $predicate, $data_type = null, $language = null, $uri_suffix = null) { |
|
| 58 | 58 | |
| 59 | - return new Wordlift_Default_Sparql_Tuple_Rendition( $this->entity_service, $storage, $predicate, $data_type, $language, $uri_suffix ); |
|
| 59 | + return new Wordlift_Default_Sparql_Tuple_Rendition($this->entity_service, $storage, $predicate, $data_type, $language, $uri_suffix); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return \Wordlift_Address_Sparql_Tuple_Rendition A {@link Wordlift_Address_Sparql_Tuple_Rendition} instance. |
| 71 | 71 | */ |
| 72 | - public function create_address( $storage, $language = null ) { |
|
| 72 | + public function create_address($storage, $language = null) { |
|
| 73 | 73 | |
| 74 | - return new Wordlift_Address_Sparql_Tuple_Rendition( $this->entity_service, $this, $storage, $language ); |
|
| 74 | + return new Wordlift_Address_Sparql_Tuple_Rendition($this->entity_service, $this, $storage, $language); |
|
| 75 | 75 | } |
| 76 | 76 | } |
@@ -19,81 +19,81 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Wordlift_Sparql_Tuple_Rendition_Factory { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * The {@link Wordlift_Entity_Service} instance. |
|
| 24 | - * |
|
| 25 | - * @since 3.15.0 |
|
| 26 | - * @access private |
|
| 27 | - * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 28 | - */ |
|
| 29 | - private $entity_service; |
|
| 22 | + /** |
|
| 23 | + * The {@link Wordlift_Entity_Service} instance. |
|
| 24 | + * |
|
| 25 | + * @since 3.15.0 |
|
| 26 | + * @access private |
|
| 27 | + * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 28 | + */ |
|
| 29 | + private $entity_service; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} singleton instance. |
|
| 33 | - * |
|
| 34 | - * @since 3.19.1 |
|
| 35 | - * @access private |
|
| 36 | - * @var \Wordlift_Sparql_Tuple_Rendition_Factory $instance The {@link Wordlift_Sparql_Tuple_Rendition_Factory} singleton instance. |
|
| 37 | - */ |
|
| 38 | - private static $instance; |
|
| 31 | + /** |
|
| 32 | + * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} singleton instance. |
|
| 33 | + * |
|
| 34 | + * @since 3.19.1 |
|
| 35 | + * @access private |
|
| 36 | + * @var \Wordlift_Sparql_Tuple_Rendition_Factory $instance The {@link Wordlift_Sparql_Tuple_Rendition_Factory} singleton instance. |
|
| 37 | + */ |
|
| 38 | + private static $instance; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Create a a {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 42 | - * |
|
| 43 | - * @since 3.15.0 |
|
| 44 | - * |
|
| 45 | - * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 46 | - */ |
|
| 47 | - public function __construct( $entity_service ) { |
|
| 40 | + /** |
|
| 41 | + * Create a a {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance. |
|
| 42 | + * |
|
| 43 | + * @since 3.15.0 |
|
| 44 | + * |
|
| 45 | + * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 46 | + */ |
|
| 47 | + public function __construct( $entity_service ) { |
|
| 48 | 48 | |
| 49 | - $this->entity_service = $entity_service; |
|
| 49 | + $this->entity_service = $entity_service; |
|
| 50 | 50 | |
| 51 | - self::$instance = $this; |
|
| 51 | + self::$instance = $this; |
|
| 52 | 52 | |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Get the {@link Wordlift_Sparql_Tuple_Rendition_Factory} singleton instance. |
|
| 57 | - * |
|
| 58 | - * @since 3.19.1 |
|
| 59 | - * |
|
| 60 | - * @return \Wordlift_Sparql_Tuple_Rendition_Factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} singleton instance. |
|
| 61 | - */ |
|
| 62 | - public static function get_instance() { |
|
| 55 | + /** |
|
| 56 | + * Get the {@link Wordlift_Sparql_Tuple_Rendition_Factory} singleton instance. |
|
| 57 | + * |
|
| 58 | + * @since 3.19.1 |
|
| 59 | + * |
|
| 60 | + * @return \Wordlift_Sparql_Tuple_Rendition_Factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} singleton instance. |
|
| 61 | + */ |
|
| 62 | + public static function get_instance() { |
|
| 63 | 63 | |
| 64 | - return self::$instance; |
|
| 65 | - } |
|
| 64 | + return self::$instance; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Create a rendition. |
|
| 69 | - * |
|
| 70 | - * @since 3.15.0 |
|
| 71 | - * |
|
| 72 | - * @param \Wordlift_Storage $storage A {@link Wordlift_Storage} instance. |
|
| 73 | - * @param string $predicate A predicate (e.g. `http://schema.org/name`). |
|
| 74 | - * @param string|null $data_type A data-type. |
|
| 75 | - * @param string|null $language A language code (e.g. `en`). |
|
| 76 | - * @param string|null $uri_suffix The URI suffix. |
|
| 77 | - * |
|
| 78 | - * @return \Wordlift_Default_Sparql_Tuple_Rendition A {@link Wordlift_Default_Sparql_Tuple_Rendition} instance. |
|
| 79 | - */ |
|
| 80 | - public function create( $storage, $predicate, $data_type = null, $language = null, $uri_suffix = null ) { |
|
| 67 | + /** |
|
| 68 | + * Create a rendition. |
|
| 69 | + * |
|
| 70 | + * @since 3.15.0 |
|
| 71 | + * |
|
| 72 | + * @param \Wordlift_Storage $storage A {@link Wordlift_Storage} instance. |
|
| 73 | + * @param string $predicate A predicate (e.g. `http://schema.org/name`). |
|
| 74 | + * @param string|null $data_type A data-type. |
|
| 75 | + * @param string|null $language A language code (e.g. `en`). |
|
| 76 | + * @param string|null $uri_suffix The URI suffix. |
|
| 77 | + * |
|
| 78 | + * @return \Wordlift_Default_Sparql_Tuple_Rendition A {@link Wordlift_Default_Sparql_Tuple_Rendition} instance. |
|
| 79 | + */ |
|
| 80 | + public function create( $storage, $predicate, $data_type = null, $language = null, $uri_suffix = null ) { |
|
| 81 | 81 | |
| 82 | - return new Wordlift_Default_Sparql_Tuple_Rendition( $this->entity_service, $storage, $predicate, $data_type, $language, $uri_suffix ); |
|
| 83 | - } |
|
| 82 | + return new Wordlift_Default_Sparql_Tuple_Rendition( $this->entity_service, $storage, $predicate, $data_type, $language, $uri_suffix ); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Create an address rendition. |
|
| 87 | - * |
|
| 88 | - * @since 3.18.0 |
|
| 89 | - * |
|
| 90 | - * @param \Wordlift_Storage $storage A {@link Wordlift_Storage} instance. |
|
| 91 | - * @param string|null $language A language code (e.g. `en`). |
|
| 92 | - * |
|
| 93 | - * @return \Wordlift_Address_Sparql_Tuple_Rendition A {@link Wordlift_Address_Sparql_Tuple_Rendition} instance. |
|
| 94 | - */ |
|
| 95 | - public function create_address( $storage, $language = null ) { |
|
| 85 | + /** |
|
| 86 | + * Create an address rendition. |
|
| 87 | + * |
|
| 88 | + * @since 3.18.0 |
|
| 89 | + * |
|
| 90 | + * @param \Wordlift_Storage $storage A {@link Wordlift_Storage} instance. |
|
| 91 | + * @param string|null $language A language code (e.g. `en`). |
|
| 92 | + * |
|
| 93 | + * @return \Wordlift_Address_Sparql_Tuple_Rendition A {@link Wordlift_Address_Sparql_Tuple_Rendition} instance. |
|
| 94 | + */ |
|
| 95 | + public function create_address( $storage, $language = null ) { |
|
| 96 | 96 | |
| 97 | - return new Wordlift_Address_Sparql_Tuple_Rendition( $this->entity_service, $this, $storage, $language ); |
|
| 98 | - } |
|
| 97 | + return new Wordlift_Address_Sparql_Tuple_Rendition( $this->entity_service, $this, $storage, $language ); |
|
| 98 | + } |
|
| 99 | 99 | } |
@@ -81,6 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * @inheritdoc |
| 84 | + * @param integer $count |
|
| 84 | 85 | */ |
| 85 | 86 | protected function get_add_button_html( $count ) { |
| 86 | 87 | |
@@ -99,6 +100,7 @@ discard block |
||
| 99 | 100 | |
| 100 | 101 | /** |
| 101 | 102 | * @inheritdoc |
| 103 | + * @param integer $count |
|
| 102 | 104 | */ |
| 103 | 105 | protected function get_stored_values_html( &$count ) { |
| 104 | 106 | |
@@ -16,134 +16,134 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class WL_Metabox_Field_sameas extends WL_Metabox_Field { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @inheritdoc |
|
| 21 | - */ |
|
| 22 | - public function __construct( $args ) { |
|
| 23 | - parent::__construct( $args['sameas'] ); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @inheritdoc |
|
| 28 | - */ |
|
| 29 | - public function save_data( $values ) { |
|
| 30 | - // The autocomplete select may send JSON arrays in input values. |
|
| 31 | - |
|
| 32 | - // Only use mb_* functions when mbstring is available. |
|
| 33 | - // |
|
| 34 | - // See https://github.com/insideout10/wordlift-plugin/issues/693. |
|
| 35 | - if ( extension_loaded( 'mbstring' ) ) { |
|
| 36 | - mb_regex_encoding( 'UTF-8' ); |
|
| 37 | - |
|
| 38 | - $merged = array_reduce( (array) $values, function ( $carry, $item ) { |
|
| 39 | - return array_merge( $carry, mb_split( "\x{2063}", wp_unslash( $item ) ) ); |
|
| 40 | - }, array() ); |
|
| 41 | - } else { |
|
| 42 | - $merged = array_reduce( (array) $values, function ( $carry, $item ) { |
|
| 43 | - return array_merge( $carry, preg_split( "/\x{2063}/u", wp_unslash( $item ) ) ); |
|
| 44 | - }, array() ); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - // Convert all escaped special characters to their original. |
|
| 48 | - $merged = array_map( 'urldecode', $merged ); |
|
| 49 | - |
|
| 50 | - parent::save_data( $merged ); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @inheritdoc |
|
| 55 | - */ |
|
| 56 | - public function sanitize_data_filter( $value ) { |
|
| 57 | - |
|
| 58 | - // Call our sanitizer helper. |
|
| 59 | - return Wordlift_Sanitizer::sanitize_url( $value ); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @inheritdoc |
|
| 64 | - */ |
|
| 65 | - protected function get_heading_html() { |
|
| 66 | - |
|
| 67 | - // Add the select html fragment after the heading. |
|
| 68 | - return parent::get_heading_html() |
|
| 69 | - . $this->get_select_html(); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Get the select html fragment. |
|
| 74 | - * |
|
| 75 | - * @since 3.15.0 |
|
| 76 | - * @return string The html fragment. |
|
| 77 | - */ |
|
| 78 | - private function get_select_html() { |
|
| 79 | - // Return an element where the new Autocomplete Select will attach to. |
|
| 80 | - return '<p>' |
|
| 81 | - . esc_html__( 'Use the search below to link this entity with equivalent entities in the linked data cloud.', 'wordlift' ) |
|
| 82 | - . '<div id="wl-metabox-field-sameas"></div></p>'; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @inheritdoc |
|
| 87 | - */ |
|
| 88 | - protected function get_add_button_html( $count ) { |
|
| 89 | - |
|
| 90 | - $placeholder = esc_attr_x( 'Type here the URL of an equivalent entity from another dataset.', 'sameAs metabox input', 'wordlift' ); |
|
| 91 | - |
|
| 92 | - return |
|
| 93 | - "<label for='$this->meta_name'>" |
|
| 94 | - . esc_html__( 'If you already know the URL of the entity that you would like to link, add it in the field below.', 'wordlift' ) |
|
| 95 | - . '</label>' |
|
| 96 | - . '<div class="wl-input-wrapper">' |
|
| 97 | - . "<input type='text' id='$this->meta_name' name='wl_metaboxes[$this->meta_name][]' placeholder='$placeholder' style='width:88%' />" |
|
| 98 | - . '<button class="button wl-remove-input wl-button" type="button">Remove</button>' |
|
| 99 | - . '</div>' |
|
| 100 | - . parent::get_add_button_html( $count ); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @inheritdoc |
|
| 105 | - */ |
|
| 106 | - protected function get_stored_values_html( &$count ) { |
|
| 107 | - |
|
| 108 | - return '<p>' |
|
| 109 | - . parent::get_stored_values_html( $count ) |
|
| 110 | - . '</p>'; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @inheritdoc |
|
| 115 | - */ |
|
| 116 | - public function html() { |
|
| 117 | - |
|
| 118 | - // Open main <div> for the Field. |
|
| 119 | - $html = $this->html_wrapper_open(); |
|
| 120 | - |
|
| 121 | - // Label. |
|
| 122 | - $html .= $this->get_heading_html(); |
|
| 123 | - |
|
| 124 | - // print nonce. |
|
| 125 | - $html .= $this->html_nonce(); |
|
| 126 | - |
|
| 127 | - // print data loaded from DB. |
|
| 128 | - $count = 0; |
|
| 129 | - |
|
| 130 | - // If cardinality allows it, print button to add new values. |
|
| 131 | - $html .= $this->get_add_button_html( $count ); |
|
| 132 | - |
|
| 133 | - $html .= $this->get_stored_values_html( $count ); |
|
| 134 | - |
|
| 135 | - // Close the HTML wrapper. |
|
| 136 | - $html .= $this->html_wrapper_close(); |
|
| 137 | - |
|
| 138 | - return $html; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @inheritdoc |
|
| 143 | - */ |
|
| 144 | - public function html_input( $value ) { |
|
| 145 | - @ob_start(); |
|
| 146 | - ?> |
|
| 19 | + /** |
|
| 20 | + * @inheritdoc |
|
| 21 | + */ |
|
| 22 | + public function __construct( $args ) { |
|
| 23 | + parent::__construct( $args['sameas'] ); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @inheritdoc |
|
| 28 | + */ |
|
| 29 | + public function save_data( $values ) { |
|
| 30 | + // The autocomplete select may send JSON arrays in input values. |
|
| 31 | + |
|
| 32 | + // Only use mb_* functions when mbstring is available. |
|
| 33 | + // |
|
| 34 | + // See https://github.com/insideout10/wordlift-plugin/issues/693. |
|
| 35 | + if ( extension_loaded( 'mbstring' ) ) { |
|
| 36 | + mb_regex_encoding( 'UTF-8' ); |
|
| 37 | + |
|
| 38 | + $merged = array_reduce( (array) $values, function ( $carry, $item ) { |
|
| 39 | + return array_merge( $carry, mb_split( "\x{2063}", wp_unslash( $item ) ) ); |
|
| 40 | + }, array() ); |
|
| 41 | + } else { |
|
| 42 | + $merged = array_reduce( (array) $values, function ( $carry, $item ) { |
|
| 43 | + return array_merge( $carry, preg_split( "/\x{2063}/u", wp_unslash( $item ) ) ); |
|
| 44 | + }, array() ); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + // Convert all escaped special characters to their original. |
|
| 48 | + $merged = array_map( 'urldecode', $merged ); |
|
| 49 | + |
|
| 50 | + parent::save_data( $merged ); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @inheritdoc |
|
| 55 | + */ |
|
| 56 | + public function sanitize_data_filter( $value ) { |
|
| 57 | + |
|
| 58 | + // Call our sanitizer helper. |
|
| 59 | + return Wordlift_Sanitizer::sanitize_url( $value ); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @inheritdoc |
|
| 64 | + */ |
|
| 65 | + protected function get_heading_html() { |
|
| 66 | + |
|
| 67 | + // Add the select html fragment after the heading. |
|
| 68 | + return parent::get_heading_html() |
|
| 69 | + . $this->get_select_html(); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Get the select html fragment. |
|
| 74 | + * |
|
| 75 | + * @since 3.15.0 |
|
| 76 | + * @return string The html fragment. |
|
| 77 | + */ |
|
| 78 | + private function get_select_html() { |
|
| 79 | + // Return an element where the new Autocomplete Select will attach to. |
|
| 80 | + return '<p>' |
|
| 81 | + . esc_html__( 'Use the search below to link this entity with equivalent entities in the linked data cloud.', 'wordlift' ) |
|
| 82 | + . '<div id="wl-metabox-field-sameas"></div></p>'; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @inheritdoc |
|
| 87 | + */ |
|
| 88 | + protected function get_add_button_html( $count ) { |
|
| 89 | + |
|
| 90 | + $placeholder = esc_attr_x( 'Type here the URL of an equivalent entity from another dataset.', 'sameAs metabox input', 'wordlift' ); |
|
| 91 | + |
|
| 92 | + return |
|
| 93 | + "<label for='$this->meta_name'>" |
|
| 94 | + . esc_html__( 'If you already know the URL of the entity that you would like to link, add it in the field below.', 'wordlift' ) |
|
| 95 | + . '</label>' |
|
| 96 | + . '<div class="wl-input-wrapper">' |
|
| 97 | + . "<input type='text' id='$this->meta_name' name='wl_metaboxes[$this->meta_name][]' placeholder='$placeholder' style='width:88%' />" |
|
| 98 | + . '<button class="button wl-remove-input wl-button" type="button">Remove</button>' |
|
| 99 | + . '</div>' |
|
| 100 | + . parent::get_add_button_html( $count ); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @inheritdoc |
|
| 105 | + */ |
|
| 106 | + protected function get_stored_values_html( &$count ) { |
|
| 107 | + |
|
| 108 | + return '<p>' |
|
| 109 | + . parent::get_stored_values_html( $count ) |
|
| 110 | + . '</p>'; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @inheritdoc |
|
| 115 | + */ |
|
| 116 | + public function html() { |
|
| 117 | + |
|
| 118 | + // Open main <div> for the Field. |
|
| 119 | + $html = $this->html_wrapper_open(); |
|
| 120 | + |
|
| 121 | + // Label. |
|
| 122 | + $html .= $this->get_heading_html(); |
|
| 123 | + |
|
| 124 | + // print nonce. |
|
| 125 | + $html .= $this->html_nonce(); |
|
| 126 | + |
|
| 127 | + // print data loaded from DB. |
|
| 128 | + $count = 0; |
|
| 129 | + |
|
| 130 | + // If cardinality allows it, print button to add new values. |
|
| 131 | + $html .= $this->get_add_button_html( $count ); |
|
| 132 | + |
|
| 133 | + $html .= $this->get_stored_values_html( $count ); |
|
| 134 | + |
|
| 135 | + // Close the HTML wrapper. |
|
| 136 | + $html .= $this->html_wrapper_close(); |
|
| 137 | + |
|
| 138 | + return $html; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * @inheritdoc |
|
| 143 | + */ |
|
| 144 | + public function html_input( $value ) { |
|
| 145 | + @ob_start(); |
|
| 146 | + ?> |
|
| 147 | 147 | <div class="wl-input-wrapper wl-input-wrapper-readonly"> |
| 148 | 148 | <input |
| 149 | 149 | type="text" |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | </div> |
| 161 | 161 | <?php |
| 162 | 162 | |
| 163 | - $html = ob_get_clean(); |
|
| 163 | + $html = ob_get_clean(); |
|
| 164 | 164 | |
| 165 | - return $html; |
|
| 166 | - } |
|
| 165 | + return $html; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | 168 | } |
@@ -19,44 +19,44 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * @inheritdoc |
| 21 | 21 | */ |
| 22 | - public function __construct( $args ) { |
|
| 23 | - parent::__construct( $args['sameas'] ); |
|
| 22 | + public function __construct($args) { |
|
| 23 | + parent::__construct($args['sameas']); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @inheritdoc |
| 28 | 28 | */ |
| 29 | - public function save_data( $values ) { |
|
| 29 | + public function save_data($values) { |
|
| 30 | 30 | // The autocomplete select may send JSON arrays in input values. |
| 31 | 31 | |
| 32 | 32 | // Only use mb_* functions when mbstring is available. |
| 33 | 33 | // |
| 34 | 34 | // See https://github.com/insideout10/wordlift-plugin/issues/693. |
| 35 | - if ( extension_loaded( 'mbstring' ) ) { |
|
| 36 | - mb_regex_encoding( 'UTF-8' ); |
|
| 35 | + if (extension_loaded('mbstring')) { |
|
| 36 | + mb_regex_encoding('UTF-8'); |
|
| 37 | 37 | |
| 38 | - $merged = array_reduce( (array) $values, function ( $carry, $item ) { |
|
| 39 | - return array_merge( $carry, mb_split( "\x{2063}", wp_unslash( $item ) ) ); |
|
| 40 | - }, array() ); |
|
| 38 | + $merged = array_reduce((array) $values, function($carry, $item) { |
|
| 39 | + return array_merge($carry, mb_split("\x{2063}", wp_unslash($item))); |
|
| 40 | + }, array()); |
|
| 41 | 41 | } else { |
| 42 | - $merged = array_reduce( (array) $values, function ( $carry, $item ) { |
|
| 43 | - return array_merge( $carry, preg_split( "/\x{2063}/u", wp_unslash( $item ) ) ); |
|
| 44 | - }, array() ); |
|
| 42 | + $merged = array_reduce((array) $values, function($carry, $item) { |
|
| 43 | + return array_merge($carry, preg_split("/\x{2063}/u", wp_unslash($item))); |
|
| 44 | + }, array()); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Convert all escaped special characters to their original. |
| 48 | - $merged = array_map( 'urldecode', $merged ); |
|
| 48 | + $merged = array_map('urldecode', $merged); |
|
| 49 | 49 | |
| 50 | - parent::save_data( $merged ); |
|
| 50 | + parent::save_data($merged); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * @inheritdoc |
| 55 | 55 | */ |
| 56 | - public function sanitize_data_filter( $value ) { |
|
| 56 | + public function sanitize_data_filter($value) { |
|
| 57 | 57 | |
| 58 | 58 | // Call our sanitizer helper. |
| 59 | - return Wordlift_Sanitizer::sanitize_url( $value ); |
|
| 59 | + return Wordlift_Sanitizer::sanitize_url($value); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -78,35 +78,35 @@ discard block |
||
| 78 | 78 | private function get_select_html() { |
| 79 | 79 | // Return an element where the new Autocomplete Select will attach to. |
| 80 | 80 | return '<p>' |
| 81 | - . esc_html__( 'Use the search below to link this entity with equivalent entities in the linked data cloud.', 'wordlift' ) |
|
| 81 | + . esc_html__('Use the search below to link this entity with equivalent entities in the linked data cloud.', 'wordlift') |
|
| 82 | 82 | . '<div id="wl-metabox-field-sameas"></div></p>'; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * @inheritdoc |
| 87 | 87 | */ |
| 88 | - protected function get_add_button_html( $count ) { |
|
| 88 | + protected function get_add_button_html($count) { |
|
| 89 | 89 | |
| 90 | - $placeholder = esc_attr_x( 'Type here the URL of an equivalent entity from another dataset.', 'sameAs metabox input', 'wordlift' ); |
|
| 90 | + $placeholder = esc_attr_x('Type here the URL of an equivalent entity from another dataset.', 'sameAs metabox input', 'wordlift'); |
|
| 91 | 91 | |
| 92 | 92 | return |
| 93 | 93 | "<label for='$this->meta_name'>" |
| 94 | - . esc_html__( 'If you already know the URL of the entity that you would like to link, add it in the field below.', 'wordlift' ) |
|
| 94 | + . esc_html__('If you already know the URL of the entity that you would like to link, add it in the field below.', 'wordlift') |
|
| 95 | 95 | . '</label>' |
| 96 | 96 | . '<div class="wl-input-wrapper">' |
| 97 | 97 | . "<input type='text' id='$this->meta_name' name='wl_metaboxes[$this->meta_name][]' placeholder='$placeholder' style='width:88%' />" |
| 98 | 98 | . '<button class="button wl-remove-input wl-button" type="button">Remove</button>' |
| 99 | 99 | . '</div>' |
| 100 | - . parent::get_add_button_html( $count ); |
|
| 100 | + . parent::get_add_button_html($count); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * @inheritdoc |
| 105 | 105 | */ |
| 106 | - protected function get_stored_values_html( &$count ) { |
|
| 106 | + protected function get_stored_values_html(&$count) { |
|
| 107 | 107 | |
| 108 | 108 | return '<p>' |
| 109 | - . parent::get_stored_values_html( $count ) |
|
| 109 | + . parent::get_stored_values_html($count) |
|
| 110 | 110 | . '</p>'; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | $count = 0; |
| 129 | 129 | |
| 130 | 130 | // If cardinality allows it, print button to add new values. |
| 131 | - $html .= $this->get_add_button_html( $count ); |
|
| 131 | + $html .= $this->get_add_button_html($count); |
|
| 132 | 132 | |
| 133 | - $html .= $this->get_stored_values_html( $count ); |
|
| 133 | + $html .= $this->get_stored_values_html($count); |
|
| 134 | 134 | |
| 135 | 135 | // Close the HTML wrapper. |
| 136 | 136 | $html .= $this->html_wrapper_close(); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | /** |
| 142 | 142 | * @inheritdoc |
| 143 | 143 | */ |
| 144 | - public function html_input( $value ) { |
|
| 144 | + public function html_input($value) { |
|
| 145 | 145 | @ob_start(); |
| 146 | 146 | ?> |
| 147 | 147 | <div class="wl-input-wrapper wl-input-wrapper-readonly"> |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | /> |
| 156 | 156 | |
| 157 | 157 | <button class="button wl-remove-input wl-button" type="button"> |
| 158 | - <?php esc_html_e( 'Remove', 'wordlift' ); ?> |
|
| 158 | + <?php esc_html_e('Remove', 'wordlift'); ?> |
|
| 159 | 159 | </button> |
| 160 | 160 | </div> |
| 161 | 161 | <?php |
@@ -25,44 +25,44 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class Wordlift_Property_Getter_Factory { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Create a {@link Wordlift_Property_Getter} instance. |
|
| 30 | - * |
|
| 31 | - * @since 3.8.0 |
|
| 32 | - * |
|
| 33 | - * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 34 | - * |
|
| 35 | - * @return \Wordlift_Property_Getter A {@link Wordlift_Property_Getter} instance. |
|
| 36 | - */ |
|
| 37 | - public static function create( $entity_service ) { |
|
| 28 | + /** |
|
| 29 | + * Create a {@link Wordlift_Property_Getter} instance. |
|
| 30 | + * |
|
| 31 | + * @since 3.8.0 |
|
| 32 | + * |
|
| 33 | + * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 34 | + * |
|
| 35 | + * @return \Wordlift_Property_Getter A {@link Wordlift_Property_Getter} instance. |
|
| 36 | + */ |
|
| 37 | + public static function create( $entity_service ) { |
|
| 38 | 38 | |
| 39 | - $property_getter = new Wordlift_Property_Getter( new Wordlift_Simple_Property_Service() ); |
|
| 40 | - $property_getter->register( new Wordlift_Entity_Property_Service( $entity_service ), array( |
|
| 41 | - Wordlift_Schema_Service::FIELD_FOUNDER, |
|
| 42 | - Wordlift_Schema_Service::FIELD_AUTHOR, |
|
| 43 | - Wordlift_Schema_Service::FIELD_KNOWS, |
|
| 44 | - Wordlift_Schema_Service::FIELD_BIRTH_PLACE, |
|
| 45 | - Wordlift_Schema_Service::FIELD_AFFILIATION, |
|
| 46 | - Wordlift_Schema_Service::FIELD_PERFORMER, |
|
| 47 | - Wordlift_Schema_Service::FIELD_OFFERS, |
|
| 48 | - Wordlift_Schema_Service::FIELD_ITEM_OFFERED, |
|
| 49 | - ) ); |
|
| 50 | - $property_getter->register( new Wordlift_Location_Property_Service( $entity_service ), array( |
|
| 51 | - Wordlift_Schema_Service::FIELD_LOCATION, |
|
| 52 | - ) ); |
|
| 53 | - $property_getter->register( new Wordlift_Url_Property_Service(), array( Wordlift_Url_Property_Service::META_KEY ) ); |
|
| 54 | - $property_getter->register( new Wordlift_Double_Property_Service(), array( |
|
| 55 | - Wordlift_Schema_Service::FIELD_GEO_LATITUDE, |
|
| 56 | - Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, |
|
| 57 | - ) ); |
|
| 39 | + $property_getter = new Wordlift_Property_Getter( new Wordlift_Simple_Property_Service() ); |
|
| 40 | + $property_getter->register( new Wordlift_Entity_Property_Service( $entity_service ), array( |
|
| 41 | + Wordlift_Schema_Service::FIELD_FOUNDER, |
|
| 42 | + Wordlift_Schema_Service::FIELD_AUTHOR, |
|
| 43 | + Wordlift_Schema_Service::FIELD_KNOWS, |
|
| 44 | + Wordlift_Schema_Service::FIELD_BIRTH_PLACE, |
|
| 45 | + Wordlift_Schema_Service::FIELD_AFFILIATION, |
|
| 46 | + Wordlift_Schema_Service::FIELD_PERFORMER, |
|
| 47 | + Wordlift_Schema_Service::FIELD_OFFERS, |
|
| 48 | + Wordlift_Schema_Service::FIELD_ITEM_OFFERED, |
|
| 49 | + ) ); |
|
| 50 | + $property_getter->register( new Wordlift_Location_Property_Service( $entity_service ), array( |
|
| 51 | + Wordlift_Schema_Service::FIELD_LOCATION, |
|
| 52 | + ) ); |
|
| 53 | + $property_getter->register( new Wordlift_Url_Property_Service(), array( Wordlift_Url_Property_Service::META_KEY ) ); |
|
| 54 | + $property_getter->register( new Wordlift_Double_Property_Service(), array( |
|
| 55 | + Wordlift_Schema_Service::FIELD_GEO_LATITUDE, |
|
| 56 | + Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, |
|
| 57 | + ) ); |
|
| 58 | 58 | |
| 59 | - $property_getter->register( new Wordlift_Duration_Property_Service(), array( |
|
| 60 | - Wordlift_Schema_Service::FIELD_PREP_TIME, |
|
| 61 | - Wordlift_Schema_Service::FIELD_COOK_TIME, |
|
| 62 | - Wordlift_Schema_Service::FIELD_TOTAL_TIME, |
|
| 63 | - ) ); |
|
| 59 | + $property_getter->register( new Wordlift_Duration_Property_Service(), array( |
|
| 60 | + Wordlift_Schema_Service::FIELD_PREP_TIME, |
|
| 61 | + Wordlift_Schema_Service::FIELD_COOK_TIME, |
|
| 62 | + Wordlift_Schema_Service::FIELD_TOTAL_TIME, |
|
| 63 | + ) ); |
|
| 64 | 64 | |
| 65 | - return $property_getter; |
|
| 66 | - } |
|
| 65 | + return $property_getter; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | } |
@@ -7,13 +7,13 @@ discard block |
||
| 7 | 7 | * @subpackage Wordlift/includes/properties |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -require_once( 'class-wordlift-property-getter.php' ); |
|
| 11 | -require_once( 'class-wordlift-simple-property-service.php' ); |
|
| 12 | -require_once( 'class-wordlift-entity-property-service.php' ); |
|
| 13 | -require_once( 'class-wordlift-location-property-service.php' ); |
|
| 14 | -require_once( 'class-wordlift-url-property-service.php' ); |
|
| 15 | -require_once( 'class-wordlift-double-property-service.php' ); |
|
| 16 | -require_once( 'class-wordlift-duration-property-service.php' ); |
|
| 10 | +require_once('class-wordlift-property-getter.php'); |
|
| 11 | +require_once('class-wordlift-simple-property-service.php'); |
|
| 12 | +require_once('class-wordlift-entity-property-service.php'); |
|
| 13 | +require_once('class-wordlift-location-property-service.php'); |
|
| 14 | +require_once('class-wordlift-url-property-service.php'); |
|
| 15 | +require_once('class-wordlift-double-property-service.php'); |
|
| 16 | +require_once('class-wordlift-duration-property-service.php'); |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * A Wordlift_Property_Getter_Factory, which instantiate a configured |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @return \Wordlift_Property_Getter A {@link Wordlift_Property_Getter} instance. |
| 36 | 36 | */ |
| 37 | - public static function create( $entity_service ) { |
|
| 37 | + public static function create($entity_service) { |
|
| 38 | 38 | |
| 39 | - $property_getter = new Wordlift_Property_Getter( new Wordlift_Simple_Property_Service() ); |
|
| 40 | - $property_getter->register( new Wordlift_Entity_Property_Service( $entity_service ), array( |
|
| 39 | + $property_getter = new Wordlift_Property_Getter(new Wordlift_Simple_Property_Service()); |
|
| 40 | + $property_getter->register(new Wordlift_Entity_Property_Service($entity_service), array( |
|
| 41 | 41 | Wordlift_Schema_Service::FIELD_FOUNDER, |
| 42 | 42 | Wordlift_Schema_Service::FIELD_AUTHOR, |
| 43 | 43 | Wordlift_Schema_Service::FIELD_KNOWS, |
@@ -46,21 +46,21 @@ discard block |
||
| 46 | 46 | Wordlift_Schema_Service::FIELD_PERFORMER, |
| 47 | 47 | Wordlift_Schema_Service::FIELD_OFFERS, |
| 48 | 48 | Wordlift_Schema_Service::FIELD_ITEM_OFFERED, |
| 49 | - ) ); |
|
| 50 | - $property_getter->register( new Wordlift_Location_Property_Service( $entity_service ), array( |
|
| 49 | + )); |
|
| 50 | + $property_getter->register(new Wordlift_Location_Property_Service($entity_service), array( |
|
| 51 | 51 | Wordlift_Schema_Service::FIELD_LOCATION, |
| 52 | - ) ); |
|
| 53 | - $property_getter->register( new Wordlift_Url_Property_Service(), array( Wordlift_Url_Property_Service::META_KEY ) ); |
|
| 54 | - $property_getter->register( new Wordlift_Double_Property_Service(), array( |
|
| 52 | + )); |
|
| 53 | + $property_getter->register(new Wordlift_Url_Property_Service(), array(Wordlift_Url_Property_Service::META_KEY)); |
|
| 54 | + $property_getter->register(new Wordlift_Double_Property_Service(), array( |
|
| 55 | 55 | Wordlift_Schema_Service::FIELD_GEO_LATITUDE, |
| 56 | 56 | Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, |
| 57 | - ) ); |
|
| 57 | + )); |
|
| 58 | 58 | |
| 59 | - $property_getter->register( new Wordlift_Duration_Property_Service(), array( |
|
| 59 | + $property_getter->register(new Wordlift_Duration_Property_Service(), array( |
|
| 60 | 60 | Wordlift_Schema_Service::FIELD_PREP_TIME, |
| 61 | 61 | Wordlift_Schema_Service::FIELD_COOK_TIME, |
| 62 | 62 | Wordlift_Schema_Service::FIELD_TOTAL_TIME, |
| 63 | - ) ); |
|
| 63 | + )); |
|
| 64 | 64 | |
| 65 | 65 | return $property_getter; |
| 66 | 66 | } |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Metabox_Field_Select extends WL_Metabox_Field { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @inheritdoc |
|
| 23 | - */ |
|
| 24 | - public function html_input( $text ) { |
|
| 25 | - @ob_start(); |
|
| 26 | - ?> |
|
| 21 | + /** |
|
| 22 | + * @inheritdoc |
|
| 23 | + */ |
|
| 24 | + public function html_input( $text ) { |
|
| 25 | + @ob_start(); |
|
| 26 | + ?> |
|
| 27 | 27 | <div class="wl-input-wrapper"> |
| 28 | 28 | |
| 29 | 29 | <select name="wl_metaboxes[<?php echo $this->meta_name ?>]" id="<?php echo esc_attr( $this->meta_name ); ?>" style="width:88%;"> |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | </div> |
| 41 | 41 | <?php |
| 42 | 42 | |
| 43 | - $html = ob_get_clean(); |
|
| 44 | - return $html; |
|
| 45 | - } |
|
| 43 | + $html = ob_get_clean(); |
|
| 44 | + return $html; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | } |
@@ -21,15 +21,15 @@ |
||
| 21 | 21 | /** |
| 22 | 22 | * @inheritdoc |
| 23 | 23 | */ |
| 24 | - public function html_input( $text ) { |
|
| 24 | + public function html_input($text) { |
|
| 25 | 25 | @ob_start(); |
| 26 | 26 | ?> |
| 27 | 27 | <div class="wl-input-wrapper"> |
| 28 | 28 | |
| 29 | - <select name="wl_metaboxes[<?php echo $this->meta_name ?>]" id="<?php echo esc_attr( $this->meta_name ); ?>" style="width:88%;"> |
|
| 30 | - <?php foreach ( $this->raw_custom_field['options'] as $option => $label ): ?> |
|
| 29 | + <select name="wl_metaboxes[<?php echo $this->meta_name ?>]" id="<?php echo esc_attr($this->meta_name); ?>" style="width:88%;"> |
|
| 30 | + <?php foreach ($this->raw_custom_field['options'] as $option => $label): ?> |
|
| 31 | 31 | |
| 32 | - <option value="<?php echo esc_attr( $option ); ?>" <?php selected( $text, $option ); ?>> |
|
| 32 | + <option value="<?php echo esc_attr($option); ?>" <?php selected($text, $option); ?>> |
|
| 33 | 33 | <?php echo $label; ?> |
| 34 | 34 | </option> |
| 35 | 35 | |
@@ -18,63 +18,63 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class WL_Metabox_Field_date extends WL_Metabox_Field { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Attribute to distinguish between date formats, inferred from the schema property export type |
|
| 23 | - * |
|
| 24 | - * @since 3.2.0 |
|
| 25 | - * @access protected |
|
| 26 | - * @var string $date_format The date format. |
|
| 27 | - */ |
|
| 28 | - protected $date_format; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * Boolean flag to decide if the calendar should include time or not |
|
| 32 | - * |
|
| 33 | - * @since 3.2.0 |
|
| 34 | - * @access protected |
|
| 35 | - * @var boolean $timepicker A boolean flag. |
|
| 36 | - */ |
|
| 37 | - protected $timepicker; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Whether the calendar should be displayed or not. |
|
| 41 | - * |
|
| 42 | - * @since 3.14.0 |
|
| 43 | - * @access protected |
|
| 44 | - * @var boolean $no_calendar Whether the calendar should be displayed or not. |
|
| 45 | - */ |
|
| 46 | - protected $no_calendar; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * {@inheritdoc} |
|
| 50 | - */ |
|
| 51 | - public function __construct( $args ) { |
|
| 52 | - parent::__construct( $args ); |
|
| 53 | - |
|
| 54 | - $this->no_calendar = false; |
|
| 55 | - |
|
| 56 | - // Distinguish between date and datetime |
|
| 57 | - if ( isset( $this->raw_custom_field['export_type'] ) && 'xsd:dateTime' === $this->raw_custom_field['export_type'] ) { |
|
| 58 | - $this->date_format = 'Y/m/d H:i'; |
|
| 59 | - $this->timepicker = true; |
|
| 60 | - } else { |
|
| 61 | - $this->date_format = 'Y/m/d'; |
|
| 62 | - $this->timepicker = false; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @param mixed $date |
|
| 69 | - * |
|
| 70 | - * @return string |
|
| 71 | - */ |
|
| 72 | - public function html_input( $date ) { |
|
| 73 | - |
|
| 74 | - $this->log->debug("Creating date input with date value $date..."); |
|
| 75 | - |
|
| 76 | - ob_start(); |
|
| 77 | - ?> |
|
| 21 | + /** |
|
| 22 | + * Attribute to distinguish between date formats, inferred from the schema property export type |
|
| 23 | + * |
|
| 24 | + * @since 3.2.0 |
|
| 25 | + * @access protected |
|
| 26 | + * @var string $date_format The date format. |
|
| 27 | + */ |
|
| 28 | + protected $date_format; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * Boolean flag to decide if the calendar should include time or not |
|
| 32 | + * |
|
| 33 | + * @since 3.2.0 |
|
| 34 | + * @access protected |
|
| 35 | + * @var boolean $timepicker A boolean flag. |
|
| 36 | + */ |
|
| 37 | + protected $timepicker; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Whether the calendar should be displayed or not. |
|
| 41 | + * |
|
| 42 | + * @since 3.14.0 |
|
| 43 | + * @access protected |
|
| 44 | + * @var boolean $no_calendar Whether the calendar should be displayed or not. |
|
| 45 | + */ |
|
| 46 | + protected $no_calendar; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * {@inheritdoc} |
|
| 50 | + */ |
|
| 51 | + public function __construct( $args ) { |
|
| 52 | + parent::__construct( $args ); |
|
| 53 | + |
|
| 54 | + $this->no_calendar = false; |
|
| 55 | + |
|
| 56 | + // Distinguish between date and datetime |
|
| 57 | + if ( isset( $this->raw_custom_field['export_type'] ) && 'xsd:dateTime' === $this->raw_custom_field['export_type'] ) { |
|
| 58 | + $this->date_format = 'Y/m/d H:i'; |
|
| 59 | + $this->timepicker = true; |
|
| 60 | + } else { |
|
| 61 | + $this->date_format = 'Y/m/d'; |
|
| 62 | + $this->timepicker = false; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @param mixed $date |
|
| 69 | + * |
|
| 70 | + * @return string |
|
| 71 | + */ |
|
| 72 | + public function html_input( $date ) { |
|
| 73 | + |
|
| 74 | + $this->log->debug("Creating date input with date value $date..."); |
|
| 75 | + |
|
| 76 | + ob_start(); |
|
| 77 | + ?> |
|
| 78 | 78 | <div class="wl-input-wrapper"> |
| 79 | 79 | <input |
| 80 | 80 | type="text" |
@@ -89,24 +89,24 @@ discard block |
||
| 89 | 89 | </button> |
| 90 | 90 | </div> |
| 91 | 91 | <?php |
| 92 | - $html = ob_get_clean(); |
|
| 92 | + $html = ob_get_clean(); |
|
| 93 | 93 | |
| 94 | - return $html; |
|
| 95 | - } |
|
| 94 | + return $html; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - public function html_wrapper_close() { |
|
| 97 | + public function html_wrapper_close() { |
|
| 98 | 98 | |
| 99 | - // Should the widget include time picker? |
|
| 100 | - $timepicker = json_encode( $this->timepicker ); |
|
| 101 | - $date_format = json_encode( $this->date_format ); |
|
| 102 | - $no_calendar = json_encode( $this->no_calendar ); |
|
| 99 | + // Should the widget include time picker? |
|
| 100 | + $timepicker = json_encode( $this->timepicker ); |
|
| 101 | + $date_format = json_encode( $this->date_format ); |
|
| 102 | + $no_calendar = json_encode( $this->no_calendar ); |
|
| 103 | 103 | |
| 104 | - // Set up the datetimepicker. |
|
| 105 | - // |
|
| 106 | - // See https://github.com/trentrichardson/jQuery-Timepicker-Addon |
|
| 107 | - // See in http://trentrichardson.com/examples/timepicker. |
|
| 108 | - @ob_start(); |
|
| 109 | - ?> |
|
| 104 | + // Set up the datetimepicker. |
|
| 105 | + // |
|
| 106 | + // See https://github.com/trentrichardson/jQuery-Timepicker-Addon |
|
| 107 | + // See in http://trentrichardson.com/examples/timepicker. |
|
| 108 | + @ob_start(); |
|
| 109 | + ?> |
|
| 110 | 110 | <script type='text/javascript'> |
| 111 | 111 | ( function( $ ) { |
| 112 | 112 | |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | } ) ( jQuery ); |
| 123 | 123 | </script> |
| 124 | 124 | <?php |
| 125 | - $html = ob_get_clean(); |
|
| 125 | + $html = ob_get_clean(); |
|
| 126 | 126 | |
| 127 | - $html .= parent::html_wrapper_close(); |
|
| 127 | + $html .= parent::html_wrapper_close(); |
|
| 128 | 128 | |
| 129 | - return $html; |
|
| 130 | - } |
|
| 129 | + return $html; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | 132 | } |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * {@inheritdoc} |
| 50 | 50 | */ |
| 51 | - public function __construct( $args ) { |
|
| 52 | - parent::__construct( $args ); |
|
| 51 | + public function __construct($args) { |
|
| 52 | + parent::__construct($args); |
|
| 53 | 53 | |
| 54 | 54 | $this->no_calendar = false; |
| 55 | 55 | |
| 56 | 56 | // Distinguish between date and datetime |
| 57 | - if ( isset( $this->raw_custom_field['export_type'] ) && 'xsd:dateTime' === $this->raw_custom_field['export_type'] ) { |
|
| 57 | + if (isset($this->raw_custom_field['export_type']) && 'xsd:dateTime' === $this->raw_custom_field['export_type']) { |
|
| 58 | 58 | $this->date_format = 'Y/m/d H:i'; |
| 59 | 59 | $this->timepicker = true; |
| 60 | 60 | } else { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return string |
| 71 | 71 | */ |
| 72 | - public function html_input( $date ) { |
|
| 72 | + public function html_input($date) { |
|
| 73 | 73 | |
| 74 | 74 | $this->log->debug("Creating date input with date value $date..."); |
| 75 | 75 | |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | <div class="wl-input-wrapper"> |
| 79 | 79 | <input |
| 80 | 80 | type="text" |
| 81 | - class="<?php echo esc_attr( $this->meta_name ); ?>" |
|
| 81 | + class="<?php echo esc_attr($this->meta_name); ?>" |
|
| 82 | 82 | name="wl_metaboxes[<?php echo $this->meta_name ?>][]" |
| 83 | 83 | value="<?php echo $date ?>" |
| 84 | 84 | style="width:88%" |
| 85 | 85 | /> |
| 86 | 86 | |
| 87 | 87 | <button class="button wl-remove-input wl-button" type="button"> |
| 88 | - <?php esc_html_e( 'Remove', 'wordlift' ); ?> |
|
| 88 | + <?php esc_html_e('Remove', 'wordlift'); ?> |
|
| 89 | 89 | </button> |
| 90 | 90 | </div> |
| 91 | 91 | <?php |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | public function html_wrapper_close() { |
| 98 | 98 | |
| 99 | 99 | // Should the widget include time picker? |
| 100 | - $timepicker = json_encode( $this->timepicker ); |
|
| 101 | - $date_format = json_encode( $this->date_format ); |
|
| 102 | - $no_calendar = json_encode( $this->no_calendar ); |
|
| 100 | + $timepicker = json_encode($this->timepicker); |
|
| 101 | + $date_format = json_encode($this->date_format); |
|
| 102 | + $no_calendar = json_encode($this->no_calendar); |
|
| 103 | 103 | |
| 104 | 104 | // Set up the datetimepicker. |
| 105 | 105 | // |
@@ -8,78 +8,78 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | class WL_Metabox_Field_address extends WL_Metabox_Field { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Sub-fields contained in the Field. |
|
| 13 | - * |
|
| 14 | - * @since 3.2.0 |
|
| 15 | - * @access private |
|
| 16 | - * @var $subfields Array of WL_Metabox_Field objects, each dealing with a part of the http://schema.org/PostalAddress structure. |
|
| 17 | - */ |
|
| 18 | - private $subfields; |
|
| 11 | + /** |
|
| 12 | + * Sub-fields contained in the Field. |
|
| 13 | + * |
|
| 14 | + * @since 3.2.0 |
|
| 15 | + * @access private |
|
| 16 | + * @var $subfields Array of WL_Metabox_Field objects, each dealing with a part of the http://schema.org/PostalAddress structure. |
|
| 17 | + */ |
|
| 18 | + private $subfields; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Constructor. |
|
| 22 | - * |
|
| 23 | - * @param array $args Set of fields containing info to build the subfields. |
|
| 24 | - * The structure of $args is: |
|
| 25 | - * array( 'address' => array( ... array of subfields ... ) ) |
|
| 26 | - */ |
|
| 27 | - public function __construct( $args ) { |
|
| 20 | + /** |
|
| 21 | + * Constructor. |
|
| 22 | + * |
|
| 23 | + * @param array $args Set of fields containing info to build the subfields. |
|
| 24 | + * The structure of $args is: |
|
| 25 | + * array( 'address' => array( ... array of subfields ... ) ) |
|
| 26 | + */ |
|
| 27 | + public function __construct( $args ) { |
|
| 28 | 28 | |
| 29 | - $this->label = key( $args ); |
|
| 29 | + $this->label = key( $args ); |
|
| 30 | 30 | |
| 31 | - // leverage the WL_Metabox_Field class to build the subfields |
|
| 32 | - $this->subfields = array(); |
|
| 33 | - // Loop over subfields. Using 'reset' to take the data contained in the first element of $args |
|
| 34 | - foreach ( reset( $args ) as $key => $subfield ) { |
|
| 35 | - $this->subfields[] = new WL_Metabox_Field( array( $key => $subfield ) ); |
|
| 36 | - } |
|
| 31 | + // leverage the WL_Metabox_Field class to build the subfields |
|
| 32 | + $this->subfields = array(); |
|
| 33 | + // Loop over subfields. Using 'reset' to take the data contained in the first element of $args |
|
| 34 | + foreach ( reset( $args ) as $key => $subfield ) { |
|
| 35 | + $this->subfields[] = new WL_Metabox_Field( array( $key => $subfield ) ); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - // $_POST array key in which we will pass the values |
|
| 39 | - $this->meta_name = 'wl_grouped_field_address'; |
|
| 40 | - } |
|
| 38 | + // $_POST array key in which we will pass the values |
|
| 39 | + $this->meta_name = 'wl_grouped_field_address'; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Load data from DB and store the resulting array in $this->data. |
|
| 44 | - */ |
|
| 45 | - public function get_data() { |
|
| 42 | + /** |
|
| 43 | + * Load data from DB and store the resulting array in $this->data. |
|
| 44 | + */ |
|
| 45 | + public function get_data() { |
|
| 46 | 46 | |
| 47 | - foreach ( $this->subfields as $subfield ) { |
|
| 48 | - $subfield->get_data(); |
|
| 49 | - } |
|
| 50 | - } |
|
| 47 | + foreach ( $this->subfields as $subfield ) { |
|
| 48 | + $subfield->get_data(); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Save data to DB. |
|
| 54 | - * |
|
| 55 | - * @param array $values Values coming from $_POST and passed from WL_Metabox. We just send to each subfield its own value. |
|
| 56 | - */ |
|
| 57 | - public function save_data( $values ) { |
|
| 52 | + /** |
|
| 53 | + * Save data to DB. |
|
| 54 | + * |
|
| 55 | + * @param array $values Values coming from $_POST and passed from WL_Metabox. We just send to each subfield its own value. |
|
| 56 | + */ |
|
| 57 | + public function save_data( $values ) { |
|
| 58 | 58 | |
| 59 | - foreach ( $this->subfields as $subfield ) { |
|
| 60 | - $subfield_value = isset( $values[ $subfield->meta_name ] )? $values[ $subfield->meta_name ] : null; |
|
| 61 | - $subfield->save_data( $subfield_value ); |
|
| 62 | - } |
|
| 63 | - } |
|
| 59 | + foreach ( $this->subfields as $subfield ) { |
|
| 60 | + $subfield_value = isset( $values[ $subfield->meta_name ] )? $values[ $subfield->meta_name ] : null; |
|
| 61 | + $subfield->save_data( $subfield_value ); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Returns Field HTML (nonce included). |
|
| 67 | - * |
|
| 68 | - * @return string Field HTML |
|
| 69 | - */ |
|
| 70 | - public function html() { |
|
| 71 | - @ob_start(); |
|
| 72 | - // Open main <div> for the Field, then insert label and nonce |
|
| 73 | - ?> |
|
| 65 | + /** |
|
| 66 | + * Returns Field HTML (nonce included). |
|
| 67 | + * |
|
| 68 | + * @return string Field HTML |
|
| 69 | + */ |
|
| 70 | + public function html() { |
|
| 71 | + @ob_start(); |
|
| 72 | + // Open main <div> for the Field, then insert label and nonce |
|
| 73 | + ?> |
|
| 74 | 74 | <div class='wl-field'> |
| 75 | 75 | <h3><?php echo $this->label ?></h3> |
| 76 | 76 | <?php echo $this->html_nonce() ?> |
| 77 | 77 | |
| 78 | 78 | <?php |
| 79 | - // print data loaded from DB |
|
| 80 | - foreach ( $this->subfields as $subfield ) : |
|
| 81 | - $value = isset( $subfield->data[0] )? $subfield->data[0] : ''; |
|
| 82 | - ?> |
|
| 79 | + // print data loaded from DB |
|
| 80 | + foreach ( $this->subfields as $subfield ) : |
|
| 81 | + $value = isset( $subfield->data[0] )? $subfield->data[0] : ''; |
|
| 82 | + ?> |
|
| 83 | 83 | <div class="wl-input-wrapper"> |
| 84 | 84 | <label |
| 85 | 85 | for="wl_metaboxes[<?php echo $this->meta_name ?>][<?php echo $subfield->meta_name ?>]" |
@@ -96,12 +96,12 @@ discard block |
||
| 96 | 96 | /> |
| 97 | 97 | </div> |
| 98 | 98 | <?php |
| 99 | - endforeach; |
|
| 100 | - $html = ob_get_clean(); |
|
| 99 | + endforeach; |
|
| 100 | + $html = ob_get_clean(); |
|
| 101 | 101 | |
| 102 | - // Close the HTML wrapper |
|
| 103 | - $html .= $this->html_wrapper_close(); |
|
| 102 | + // Close the HTML wrapper |
|
| 103 | + $html .= $this->html_wrapper_close(); |
|
| 104 | 104 | |
| 105 | - return $html; |
|
| 106 | - } |
|
| 105 | + return $html; |
|
| 106 | + } |
|
| 107 | 107 | } |
| 108 | 108 | \ No newline at end of file |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | * The structure of $args is: |
| 25 | 25 | * array( 'address' => array( ... array of subfields ... ) ) |
| 26 | 26 | */ |
| 27 | - public function __construct( $args ) { |
|
| 27 | + public function __construct($args) { |
|
| 28 | 28 | |
| 29 | - $this->label = key( $args ); |
|
| 29 | + $this->label = key($args); |
|
| 30 | 30 | |
| 31 | 31 | // leverage the WL_Metabox_Field class to build the subfields |
| 32 | 32 | $this->subfields = array(); |
| 33 | 33 | // Loop over subfields. Using 'reset' to take the data contained in the first element of $args |
| 34 | - foreach ( reset( $args ) as $key => $subfield ) { |
|
| 35 | - $this->subfields[] = new WL_Metabox_Field( array( $key => $subfield ) ); |
|
| 34 | + foreach (reset($args) as $key => $subfield) { |
|
| 35 | + $this->subfields[] = new WL_Metabox_Field(array($key => $subfield)); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // $_POST array key in which we will pass the values |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function get_data() { |
| 46 | 46 | |
| 47 | - foreach ( $this->subfields as $subfield ) { |
|
| 47 | + foreach ($this->subfields as $subfield) { |
|
| 48 | 48 | $subfield->get_data(); |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @param array $values Values coming from $_POST and passed from WL_Metabox. We just send to each subfield its own value. |
| 56 | 56 | */ |
| 57 | - public function save_data( $values ) { |
|
| 57 | + public function save_data($values) { |
|
| 58 | 58 | |
| 59 | - foreach ( $this->subfields as $subfield ) { |
|
| 60 | - $subfield_value = isset( $values[ $subfield->meta_name ] )? $values[ $subfield->meta_name ] : null; |
|
| 61 | - $subfield->save_data( $subfield_value ); |
|
| 59 | + foreach ($this->subfields as $subfield) { |
|
| 60 | + $subfield_value = isset($values[$subfield->meta_name]) ? $values[$subfield->meta_name] : null; |
|
| 61 | + $subfield->save_data($subfield_value); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | <?php |
| 79 | 79 | // print data loaded from DB |
| 80 | - foreach ( $this->subfields as $subfield ) : |
|
| 81 | - $value = isset( $subfield->data[0] )? $subfield->data[0] : ''; |
|
| 80 | + foreach ($this->subfields as $subfield) : |
|
| 81 | + $value = isset($subfield->data[0]) ? $subfield->data[0] : ''; |
|
| 82 | 82 | ?> |
| 83 | 83 | <div class="wl-input-wrapper"> |
| 84 | 84 | <label |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Metabox_Field_Multiline extends WL_Metabox_Field { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @inheritdoc |
|
| 23 | - */ |
|
| 24 | - public function html_input( $text ) { |
|
| 25 | - @ob_start(); |
|
| 26 | - ?> |
|
| 21 | + /** |
|
| 22 | + * @inheritdoc |
|
| 23 | + */ |
|
| 24 | + public function html_input( $text ) { |
|
| 25 | + @ob_start(); |
|
| 26 | + ?> |
|
| 27 | 27 | <div class="wl-input-wrapper"> |
| 28 | 28 | <textarea |
| 29 | 29 | id="<?php echo esc_attr( $this->meta_name ) ?>" |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | </button> |
| 38 | 38 | </div> |
| 39 | 39 | <?php |
| 40 | - $html = ob_get_clean(); |
|
| 40 | + $html = ob_get_clean(); |
|
| 41 | 41 | |
| 42 | - return $html; |
|
| 43 | - } |
|
| 42 | + return $html; |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -21,19 +21,19 @@ |
||
| 21 | 21 | /** |
| 22 | 22 | * @inheritdoc |
| 23 | 23 | */ |
| 24 | - public function html_input( $text ) { |
|
| 24 | + public function html_input($text) { |
|
| 25 | 25 | @ob_start(); |
| 26 | 26 | ?> |
| 27 | 27 | <div class="wl-input-wrapper"> |
| 28 | 28 | <textarea |
| 29 | - id="<?php echo esc_attr( $this->meta_name ) ?>" |
|
| 30 | - class="<?php echo esc_attr( $this->meta_name ) ?>" |
|
| 29 | + id="<?php echo esc_attr($this->meta_name) ?>" |
|
| 30 | + class="<?php echo esc_attr($this->meta_name) ?>" |
|
| 31 | 31 | name="wl_metaboxes[<?php echo $this->meta_name ?>][]" |
| 32 | 32 | style="width:88%" |
| 33 | - ><?php echo esc_textarea( $text ) ?></textarea> |
|
| 33 | + ><?php echo esc_textarea($text) ?></textarea> |
|
| 34 | 34 | |
| 35 | 35 | <button class="button wl-remove-input wl-button" type="button"> |
| 36 | - <?php esc_html_e( 'Remove', 'wordlift' ); ?> |
|
| 36 | + <?php esc_html_e('Remove', 'wordlift'); ?> |
|
| 37 | 37 | </button> |
| 38 | 38 | </div> |
| 39 | 39 | <?php |