@@ -291,7 +291,7 @@ |
||
| 291 | 291 | * |
| 292 | 292 | * @since 3.7.0 |
| 293 | 293 | * |
| 294 | - * @param $value int A date value. |
|
| 294 | + * @param integer $value int A date value. |
|
| 295 | 295 | * |
| 296 | 296 | * @return array An array containing year, month and day values. |
| 297 | 297 | */ |
@@ -7,302 +7,302 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_Timeline_Service { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * The Log service. |
|
| 12 | - * |
|
| 13 | - * @since 3.1.0 |
|
| 14 | - * @access private |
|
| 15 | - * @var \Wordlift_Log_Service $log_service The Log service. |
|
| 16 | - */ |
|
| 17 | - private $log_service; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * The Entity service. |
|
| 21 | - * |
|
| 22 | - * @since 3.1.0 |
|
| 23 | - * @access private |
|
| 24 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 25 | - */ |
|
| 26 | - private $entity_service; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * The number of words to use for the excerpt, set in the `to_json` function |
|
| 30 | - * and used by a filter. |
|
| 31 | - * |
|
| 32 | - * @since 3.7.0 |
|
| 33 | - * @access private |
|
| 34 | - * @var int $excerpt_length The number of words to use for the excerpt. |
|
| 35 | - */ |
|
| 36 | - private $excerpt_length; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * A singleton instance of the Timeline service (useful for unit tests). |
|
| 40 | - * |
|
| 41 | - * @since 3.1.0 |
|
| 42 | - * @access private |
|
| 43 | - * @var \Wordlift_Timeline_Service $instance The singleton instance. |
|
| 44 | - */ |
|
| 45 | - private static $instance; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Create a Wordlift_Timeline_Service instance. |
|
| 49 | - * |
|
| 50 | - * @since 3.1.0 |
|
| 51 | - * |
|
| 52 | - * @param \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 53 | - */ |
|
| 54 | - public function __construct( $entity_service ) { |
|
| 55 | - |
|
| 56 | - $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Timeline_Service' ); |
|
| 57 | - |
|
| 58 | - $this->entity_service = $entity_service; |
|
| 59 | - |
|
| 60 | - self::$instance = $this; |
|
| 61 | - |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Get the singleton instance of the Wordlift_Timeline_Service |
|
| 66 | - * |
|
| 67 | - * @since 3.1.0 |
|
| 68 | - * |
|
| 69 | - * @return \Wordlift_Timeline_Service The singleton instance of the Wordlift_Timeline_Service. |
|
| 70 | - */ |
|
| 71 | - public static function get_instance() { |
|
| 72 | - |
|
| 73 | - return self::$instance; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Retrieve timeline events and output them in JSON. |
|
| 78 | - * |
|
| 79 | - * @since 3.1.0 |
|
| 80 | - */ |
|
| 81 | - public function ajax_timeline() { |
|
| 82 | - |
|
| 83 | - // Get the ID of the post who requested the timeline. |
|
| 84 | - $post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : NULL ); |
|
| 85 | - |
|
| 86 | - // Get the events and transform them for the JSON response, then send them to the client. |
|
| 87 | - wp_send_json( $this->to_json( $this->get_events( $post_id ) ) ); |
|
| 88 | - |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Retrieve timeline events. |
|
| 93 | - * |
|
| 94 | - * @since 3.1.0 |
|
| 95 | - * |
|
| 96 | - * @uses wl_core_get_related_entity_ids() to retrieve the entities referenced by the specified post. |
|
| 97 | - * |
|
| 98 | - * @param int $post_id The post ID. |
|
| 99 | - * |
|
| 100 | - * @return array An array of event posts. |
|
| 101 | - */ |
|
| 102 | - public function get_events( $post_id = NULL ) { |
|
| 103 | - |
|
| 104 | - // Get the entity IDs either from the entities related to the specified post or from the last 50 published |
|
| 105 | - // posts if no post has been specified. |
|
| 106 | - $ids = ( is_numeric( $post_id ) |
|
| 107 | - ? wl_core_get_related_entity_ids( $post_id ) |
|
| 108 | - : $this->entity_service->get_all_related_to_last_50_published_posts() ); |
|
| 109 | - |
|
| 110 | - // Add the post itself if it's an entity. |
|
| 111 | - if ( is_numeric( $post_id ) && $this->entity_service->is_entity( $post_id ) ) { |
|
| 112 | - $ids[] = $post_id; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - // If there's no entities, return an empty array right away. |
|
| 116 | - if ( 0 === sizeof( $ids ) ) { |
|
| 117 | - $this->log_service->trace( "No events found [ post id :: $post_id ]" ); |
|
| 118 | - |
|
| 119 | - return array(); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - $this->log_service->trace( "Getting events [ entity ids :: " . join( ', ', $ids ) . " ]" ); |
|
| 123 | - |
|
| 124 | - return get_posts( array( |
|
| 125 | - 'post__in' => $ids, |
|
| 126 | - 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 127 | - 'post_status' => 'publish', |
|
| 128 | - 'posts_per_page' => - 1, |
|
| 129 | - 'meta_query' => array( |
|
| 130 | - 'relation' => 'AND', |
|
| 131 | - array( |
|
| 132 | - 'key' => Wordlift_Schema_Service::FIELD_DATE_START, |
|
| 133 | - 'value' => NULL, |
|
| 134 | - 'compare' => '!=' |
|
| 135 | - ), |
|
| 136 | - array( |
|
| 137 | - 'key' => Wordlift_Schema_Service::FIELD_DATE_END, |
|
| 138 | - 'value' => NULL, |
|
| 139 | - 'compare' => '!=' |
|
| 140 | - ) |
|
| 141 | - ), |
|
| 142 | - 'tax_query' => array( |
|
| 143 | - 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 144 | - 'field' => 'slug', |
|
| 145 | - 'terms' => 'event' |
|
| 146 | - ) |
|
| 147 | - ) ); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * Convert timeline events to JSON. This function sets the global post in order |
|
| 152 | - * to get an automatic excerpt. Since we're being called inside an AJAX request, |
|
| 153 | - * we're not taking care of restoring any previous post: there isn't any. |
|
| 154 | - * |
|
| 155 | - * @since 3.1.0 |
|
| 156 | - * |
|
| 157 | - * @param array $posts An array of posts. |
|
| 158 | - * |
|
| 159 | - * @return array|string An array of timeline events or an empty string if no posts are provided. |
|
| 160 | - */ |
|
| 161 | - public function to_json( $posts ) { |
|
| 162 | - |
|
| 163 | - // If there are no events, return empty JSON |
|
| 164 | - if ( empty( $posts ) || is_null( $posts ) ) { |
|
| 165 | - return ''; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // {media|thumbnail}: if set to 'media' the image is attached to the slide, if set to 'background' the image is set as background. |
|
| 169 | - $display_images_as = isset( $_REQUEST['display_images_as'] ) ? $_REQUEST['display_images_as'] : 'media'; |
|
| 170 | - |
|
| 171 | - // The number of words for the excerpt (by default 55, as WordPress). |
|
| 172 | - $this->excerpt_length = $excerpt_length = isset( $_REQUEST['excerpt_length'] ) && is_numeric( $_REQUEST['excerpt_length'] ) ? $_REQUEST['excerpt_length'] : 55; |
|
| 173 | - add_filter( 'excerpt_length', array( $this, 'excerpt_length' ) ); |
|
| 174 | - |
|
| 175 | - // Add a filter to remove the [...] after excerpts, since we're adding |
|
| 176 | - // a link to the post itself. |
|
| 177 | - add_filter( 'excerpt_more', array( $this, 'excerpt_more' ) ); |
|
| 178 | - |
|
| 179 | - // Prepare for the starting slide data. The starting slide will be the one where *now* is between *start/end* dates. |
|
| 180 | - $start_at_slide = 0; |
|
| 181 | - $event_index = - 1; |
|
| 182 | - $now = time(); |
|
| 183 | - |
|
| 184 | - // Prepare the timeline variable. |
|
| 185 | - $timeline = array(); |
|
| 186 | - |
|
| 187 | - // Populate the arrays. |
|
| 188 | - $timeline['events'] = array_map( function ( $item ) use ( &$timeline, &$event_index, &$start_at_slide, &$now, $display_images_as, $excerpt_length ) { |
|
| 189 | - |
|
| 190 | - // Get the start and end dates. |
|
| 191 | - $start_date = strtotime( get_post_meta( $item->ID, Wordlift_Schema_Service::FIELD_DATE_START, TRUE ) ); |
|
| 192 | - $end_date = strtotime( get_post_meta( $item->ID, Wordlift_Schema_Service::FIELD_DATE_END, TRUE ) ); |
|
| 193 | - |
|
| 194 | - // Set the starting slide. |
|
| 195 | - $event_index ++; |
|
| 196 | - if ( 0 === $start_at_slide && $now >= $start_date && $now <= $end_date ) { |
|
| 197 | - $start_at_slide = $event_index; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - // Load thumbnail |
|
| 201 | - if ( '' !== ( $thumbnail_id = get_post_thumbnail_id( $item->ID ) ) |
|
| 202 | - && FALSE !== ( $attachment = wp_get_attachment_image_src( $thumbnail_id ) ) |
|
| 203 | - ) { |
|
| 204 | - |
|
| 205 | - // Set the thumbnail URL. |
|
| 206 | - if ( 'background' === $display_images_as ) { |
|
| 207 | - $date['background'] = array( 'url' => $attachment[0], ); |
|
| 208 | - $date['media'] = array( 'thumbnail' => $attachment[0], ); |
|
| 209 | - } else { |
|
| 210 | - $date['media'] = array( |
|
| 211 | - 'url' => $attachment[0], |
|
| 212 | - 'thumbnail' => $attachment[0], |
|
| 213 | - ); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - // Set the start/end dates by converting them to TimelineJS required format. |
|
| 219 | - $date['start_date'] = Wordlift_Timeline_Service::date( $start_date ); |
|
| 220 | - $date['end_date'] = Wordlift_Timeline_Service::date( $end_date ); |
|
| 221 | - |
|
| 222 | - setup_postdata( $GLOBALS['post'] = &$item ); |
|
| 223 | - |
|
| 224 | - $more_link_text = sprintf( |
|
| 225 | - '<span aria-label="%1$s">%2$s</span>', |
|
| 226 | - sprintf( |
|
| 227 | - /* translators: %s: Name of current post */ |
|
| 228 | - __( 'Continue reading %s' ), |
|
| 229 | - the_title_attribute( array( 'echo' => FALSE ) ) |
|
| 230 | - ), |
|
| 231 | - __( '(more…)' ) |
|
| 232 | - ); |
|
| 233 | - |
|
| 234 | - // Set the event text only with the headline (see https://github.com/insideout10/wordlift-plugin/issues/352). |
|
| 235 | - $date['text'] = array( |
|
| 236 | - 'headline' => '<a href="' . get_permalink( $item->ID ) . '">' . $item->post_title . '</a>', |
|
| 237 | - ); |
|
| 238 | - |
|
| 239 | - // If we have an excerpt, set it. |
|
| 240 | - if ( 0 < $excerpt_length ) { |
|
| 241 | - $date['text']['text'] = sprintf( '%s <a href="%s">%s</a>', get_the_excerpt( $item ), get_permalink(), $more_link_text ); |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - return $date; |
|
| 245 | - |
|
| 246 | - }, $posts ); |
|
| 247 | - |
|
| 248 | - // Finally remove the excerpt filter. |
|
| 249 | - remove_filter( 'excerpt_length', array( $this, 'excerpt_length' ) ); |
|
| 250 | - |
|
| 251 | - // The JSON format is defined here: https://timeline.knightlab.com/docs/json-format.html |
|
| 252 | - return array( |
|
| 253 | - 'timeline' => $timeline, |
|
| 254 | - 'start_at_slide' => $start_at_slide, |
|
| 255 | - ); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * This function filters {@link excerpt_more} by removing it, since we're |
|
| 260 | - * adding the 'read more' link. This filter is set by {@see to_json}. |
|
| 261 | - * |
|
| 262 | - * @since 3.7.0 |
|
| 263 | - * |
|
| 264 | - * @param string $excerpt_more The excerpt more preset. |
|
| 265 | - * |
|
| 266 | - * @return string An empty string. |
|
| 267 | - */ |
|
| 268 | - public function excerpt_more( $excerpt_more ) { |
|
| 269 | - |
|
| 270 | - return ''; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * A filter for the excerpt length, set by the `to_json` function, to tailor |
|
| 275 | - * how many words to return according to the client setting. |
|
| 276 | - * |
|
| 277 | - * @since 3.7.0 |
|
| 278 | - * |
|
| 279 | - * @param int $length The preset number of words. |
|
| 280 | - * |
|
| 281 | - * @return int The number of words for the preset. |
|
| 282 | - */ |
|
| 283 | - public function excerpt_length( $length ) { |
|
| 284 | - |
|
| 285 | - return $this->excerpt_length; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * Convert the date to a date array. |
|
| 291 | - * |
|
| 292 | - * @since 3.7.0 |
|
| 293 | - * |
|
| 294 | - * @param $value int A date value. |
|
| 295 | - * |
|
| 296 | - * @return array An array containing year, month and day values. |
|
| 297 | - */ |
|
| 298 | - public static function date( $value ) { |
|
| 299 | - |
|
| 300 | - return array( |
|
| 301 | - 'year' => (int) date( 'Y', $value ), |
|
| 302 | - 'month' => (int) date( 'm', $value ), |
|
| 303 | - 'day' => (int) date( 'd', $value ), |
|
| 304 | - |
|
| 305 | - ); |
|
| 306 | - } |
|
| 10 | + /** |
|
| 11 | + * The Log service. |
|
| 12 | + * |
|
| 13 | + * @since 3.1.0 |
|
| 14 | + * @access private |
|
| 15 | + * @var \Wordlift_Log_Service $log_service The Log service. |
|
| 16 | + */ |
|
| 17 | + private $log_service; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * The Entity service. |
|
| 21 | + * |
|
| 22 | + * @since 3.1.0 |
|
| 23 | + * @access private |
|
| 24 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 25 | + */ |
|
| 26 | + private $entity_service; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * The number of words to use for the excerpt, set in the `to_json` function |
|
| 30 | + * and used by a filter. |
|
| 31 | + * |
|
| 32 | + * @since 3.7.0 |
|
| 33 | + * @access private |
|
| 34 | + * @var int $excerpt_length The number of words to use for the excerpt. |
|
| 35 | + */ |
|
| 36 | + private $excerpt_length; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * A singleton instance of the Timeline service (useful for unit tests). |
|
| 40 | + * |
|
| 41 | + * @since 3.1.0 |
|
| 42 | + * @access private |
|
| 43 | + * @var \Wordlift_Timeline_Service $instance The singleton instance. |
|
| 44 | + */ |
|
| 45 | + private static $instance; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Create a Wordlift_Timeline_Service instance. |
|
| 49 | + * |
|
| 50 | + * @since 3.1.0 |
|
| 51 | + * |
|
| 52 | + * @param \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 53 | + */ |
|
| 54 | + public function __construct( $entity_service ) { |
|
| 55 | + |
|
| 56 | + $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Timeline_Service' ); |
|
| 57 | + |
|
| 58 | + $this->entity_service = $entity_service; |
|
| 59 | + |
|
| 60 | + self::$instance = $this; |
|
| 61 | + |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Get the singleton instance of the Wordlift_Timeline_Service |
|
| 66 | + * |
|
| 67 | + * @since 3.1.0 |
|
| 68 | + * |
|
| 69 | + * @return \Wordlift_Timeline_Service The singleton instance of the Wordlift_Timeline_Service. |
|
| 70 | + */ |
|
| 71 | + public static function get_instance() { |
|
| 72 | + |
|
| 73 | + return self::$instance; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Retrieve timeline events and output them in JSON. |
|
| 78 | + * |
|
| 79 | + * @since 3.1.0 |
|
| 80 | + */ |
|
| 81 | + public function ajax_timeline() { |
|
| 82 | + |
|
| 83 | + // Get the ID of the post who requested the timeline. |
|
| 84 | + $post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : NULL ); |
|
| 85 | + |
|
| 86 | + // Get the events and transform them for the JSON response, then send them to the client. |
|
| 87 | + wp_send_json( $this->to_json( $this->get_events( $post_id ) ) ); |
|
| 88 | + |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Retrieve timeline events. |
|
| 93 | + * |
|
| 94 | + * @since 3.1.0 |
|
| 95 | + * |
|
| 96 | + * @uses wl_core_get_related_entity_ids() to retrieve the entities referenced by the specified post. |
|
| 97 | + * |
|
| 98 | + * @param int $post_id The post ID. |
|
| 99 | + * |
|
| 100 | + * @return array An array of event posts. |
|
| 101 | + */ |
|
| 102 | + public function get_events( $post_id = NULL ) { |
|
| 103 | + |
|
| 104 | + // Get the entity IDs either from the entities related to the specified post or from the last 50 published |
|
| 105 | + // posts if no post has been specified. |
|
| 106 | + $ids = ( is_numeric( $post_id ) |
|
| 107 | + ? wl_core_get_related_entity_ids( $post_id ) |
|
| 108 | + : $this->entity_service->get_all_related_to_last_50_published_posts() ); |
|
| 109 | + |
|
| 110 | + // Add the post itself if it's an entity. |
|
| 111 | + if ( is_numeric( $post_id ) && $this->entity_service->is_entity( $post_id ) ) { |
|
| 112 | + $ids[] = $post_id; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + // If there's no entities, return an empty array right away. |
|
| 116 | + if ( 0 === sizeof( $ids ) ) { |
|
| 117 | + $this->log_service->trace( "No events found [ post id :: $post_id ]" ); |
|
| 118 | + |
|
| 119 | + return array(); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + $this->log_service->trace( "Getting events [ entity ids :: " . join( ', ', $ids ) . " ]" ); |
|
| 123 | + |
|
| 124 | + return get_posts( array( |
|
| 125 | + 'post__in' => $ids, |
|
| 126 | + 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 127 | + 'post_status' => 'publish', |
|
| 128 | + 'posts_per_page' => - 1, |
|
| 129 | + 'meta_query' => array( |
|
| 130 | + 'relation' => 'AND', |
|
| 131 | + array( |
|
| 132 | + 'key' => Wordlift_Schema_Service::FIELD_DATE_START, |
|
| 133 | + 'value' => NULL, |
|
| 134 | + 'compare' => '!=' |
|
| 135 | + ), |
|
| 136 | + array( |
|
| 137 | + 'key' => Wordlift_Schema_Service::FIELD_DATE_END, |
|
| 138 | + 'value' => NULL, |
|
| 139 | + 'compare' => '!=' |
|
| 140 | + ) |
|
| 141 | + ), |
|
| 142 | + 'tax_query' => array( |
|
| 143 | + 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 144 | + 'field' => 'slug', |
|
| 145 | + 'terms' => 'event' |
|
| 146 | + ) |
|
| 147 | + ) ); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * Convert timeline events to JSON. This function sets the global post in order |
|
| 152 | + * to get an automatic excerpt. Since we're being called inside an AJAX request, |
|
| 153 | + * we're not taking care of restoring any previous post: there isn't any. |
|
| 154 | + * |
|
| 155 | + * @since 3.1.0 |
|
| 156 | + * |
|
| 157 | + * @param array $posts An array of posts. |
|
| 158 | + * |
|
| 159 | + * @return array|string An array of timeline events or an empty string if no posts are provided. |
|
| 160 | + */ |
|
| 161 | + public function to_json( $posts ) { |
|
| 162 | + |
|
| 163 | + // If there are no events, return empty JSON |
|
| 164 | + if ( empty( $posts ) || is_null( $posts ) ) { |
|
| 165 | + return ''; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // {media|thumbnail}: if set to 'media' the image is attached to the slide, if set to 'background' the image is set as background. |
|
| 169 | + $display_images_as = isset( $_REQUEST['display_images_as'] ) ? $_REQUEST['display_images_as'] : 'media'; |
|
| 170 | + |
|
| 171 | + // The number of words for the excerpt (by default 55, as WordPress). |
|
| 172 | + $this->excerpt_length = $excerpt_length = isset( $_REQUEST['excerpt_length'] ) && is_numeric( $_REQUEST['excerpt_length'] ) ? $_REQUEST['excerpt_length'] : 55; |
|
| 173 | + add_filter( 'excerpt_length', array( $this, 'excerpt_length' ) ); |
|
| 174 | + |
|
| 175 | + // Add a filter to remove the [...] after excerpts, since we're adding |
|
| 176 | + // a link to the post itself. |
|
| 177 | + add_filter( 'excerpt_more', array( $this, 'excerpt_more' ) ); |
|
| 178 | + |
|
| 179 | + // Prepare for the starting slide data. The starting slide will be the one where *now* is between *start/end* dates. |
|
| 180 | + $start_at_slide = 0; |
|
| 181 | + $event_index = - 1; |
|
| 182 | + $now = time(); |
|
| 183 | + |
|
| 184 | + // Prepare the timeline variable. |
|
| 185 | + $timeline = array(); |
|
| 186 | + |
|
| 187 | + // Populate the arrays. |
|
| 188 | + $timeline['events'] = array_map( function ( $item ) use ( &$timeline, &$event_index, &$start_at_slide, &$now, $display_images_as, $excerpt_length ) { |
|
| 189 | + |
|
| 190 | + // Get the start and end dates. |
|
| 191 | + $start_date = strtotime( get_post_meta( $item->ID, Wordlift_Schema_Service::FIELD_DATE_START, TRUE ) ); |
|
| 192 | + $end_date = strtotime( get_post_meta( $item->ID, Wordlift_Schema_Service::FIELD_DATE_END, TRUE ) ); |
|
| 193 | + |
|
| 194 | + // Set the starting slide. |
|
| 195 | + $event_index ++; |
|
| 196 | + if ( 0 === $start_at_slide && $now >= $start_date && $now <= $end_date ) { |
|
| 197 | + $start_at_slide = $event_index; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + // Load thumbnail |
|
| 201 | + if ( '' !== ( $thumbnail_id = get_post_thumbnail_id( $item->ID ) ) |
|
| 202 | + && FALSE !== ( $attachment = wp_get_attachment_image_src( $thumbnail_id ) ) |
|
| 203 | + ) { |
|
| 204 | + |
|
| 205 | + // Set the thumbnail URL. |
|
| 206 | + if ( 'background' === $display_images_as ) { |
|
| 207 | + $date['background'] = array( 'url' => $attachment[0], ); |
|
| 208 | + $date['media'] = array( 'thumbnail' => $attachment[0], ); |
|
| 209 | + } else { |
|
| 210 | + $date['media'] = array( |
|
| 211 | + 'url' => $attachment[0], |
|
| 212 | + 'thumbnail' => $attachment[0], |
|
| 213 | + ); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + // Set the start/end dates by converting them to TimelineJS required format. |
|
| 219 | + $date['start_date'] = Wordlift_Timeline_Service::date( $start_date ); |
|
| 220 | + $date['end_date'] = Wordlift_Timeline_Service::date( $end_date ); |
|
| 221 | + |
|
| 222 | + setup_postdata( $GLOBALS['post'] = &$item ); |
|
| 223 | + |
|
| 224 | + $more_link_text = sprintf( |
|
| 225 | + '<span aria-label="%1$s">%2$s</span>', |
|
| 226 | + sprintf( |
|
| 227 | + /* translators: %s: Name of current post */ |
|
| 228 | + __( 'Continue reading %s' ), |
|
| 229 | + the_title_attribute( array( 'echo' => FALSE ) ) |
|
| 230 | + ), |
|
| 231 | + __( '(more…)' ) |
|
| 232 | + ); |
|
| 233 | + |
|
| 234 | + // Set the event text only with the headline (see https://github.com/insideout10/wordlift-plugin/issues/352). |
|
| 235 | + $date['text'] = array( |
|
| 236 | + 'headline' => '<a href="' . get_permalink( $item->ID ) . '">' . $item->post_title . '</a>', |
|
| 237 | + ); |
|
| 238 | + |
|
| 239 | + // If we have an excerpt, set it. |
|
| 240 | + if ( 0 < $excerpt_length ) { |
|
| 241 | + $date['text']['text'] = sprintf( '%s <a href="%s">%s</a>', get_the_excerpt( $item ), get_permalink(), $more_link_text ); |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + return $date; |
|
| 245 | + |
|
| 246 | + }, $posts ); |
|
| 247 | + |
|
| 248 | + // Finally remove the excerpt filter. |
|
| 249 | + remove_filter( 'excerpt_length', array( $this, 'excerpt_length' ) ); |
|
| 250 | + |
|
| 251 | + // The JSON format is defined here: https://timeline.knightlab.com/docs/json-format.html |
|
| 252 | + return array( |
|
| 253 | + 'timeline' => $timeline, |
|
| 254 | + 'start_at_slide' => $start_at_slide, |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * This function filters {@link excerpt_more} by removing it, since we're |
|
| 260 | + * adding the 'read more' link. This filter is set by {@see to_json}. |
|
| 261 | + * |
|
| 262 | + * @since 3.7.0 |
|
| 263 | + * |
|
| 264 | + * @param string $excerpt_more The excerpt more preset. |
|
| 265 | + * |
|
| 266 | + * @return string An empty string. |
|
| 267 | + */ |
|
| 268 | + public function excerpt_more( $excerpt_more ) { |
|
| 269 | + |
|
| 270 | + return ''; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * A filter for the excerpt length, set by the `to_json` function, to tailor |
|
| 275 | + * how many words to return according to the client setting. |
|
| 276 | + * |
|
| 277 | + * @since 3.7.0 |
|
| 278 | + * |
|
| 279 | + * @param int $length The preset number of words. |
|
| 280 | + * |
|
| 281 | + * @return int The number of words for the preset. |
|
| 282 | + */ |
|
| 283 | + public function excerpt_length( $length ) { |
|
| 284 | + |
|
| 285 | + return $this->excerpt_length; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Convert the date to a date array. |
|
| 291 | + * |
|
| 292 | + * @since 3.7.0 |
|
| 293 | + * |
|
| 294 | + * @param $value int A date value. |
|
| 295 | + * |
|
| 296 | + * @return array An array containing year, month and day values. |
|
| 297 | + */ |
|
| 298 | + public static function date( $value ) { |
|
| 299 | + |
|
| 300 | + return array( |
|
| 301 | + 'year' => (int) date( 'Y', $value ), |
|
| 302 | + 'month' => (int) date( 'm', $value ), |
|
| 303 | + 'day' => (int) date( 'd', $value ), |
|
| 304 | + |
|
| 305 | + ); |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | 308 | } |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @param \Wordlift_Entity_Service $entity_service The Entity service. |
| 53 | 53 | */ |
| 54 | - public function __construct( $entity_service ) { |
|
| 54 | + public function __construct($entity_service) { |
|
| 55 | 55 | |
| 56 | - $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Timeline_Service' ); |
|
| 56 | + $this->log_service = Wordlift_Log_Service::get_logger('Wordlift_Timeline_Service'); |
|
| 57 | 57 | |
| 58 | 58 | $this->entity_service = $entity_service; |
| 59 | 59 | |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | public function ajax_timeline() { |
| 82 | 82 | |
| 83 | 83 | // Get the ID of the post who requested the timeline. |
| 84 | - $post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : NULL ); |
|
| 84 | + $post_id = (isset($_REQUEST['post_id']) ? $_REQUEST['post_id'] : NULL); |
|
| 85 | 85 | |
| 86 | 86 | // Get the events and transform them for the JSON response, then send them to the client. |
| 87 | - wp_send_json( $this->to_json( $this->get_events( $post_id ) ) ); |
|
| 87 | + wp_send_json($this->to_json($this->get_events($post_id))); |
|
| 88 | 88 | |
| 89 | 89 | } |
| 90 | 90 | |
@@ -99,33 +99,33 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return array An array of event posts. |
| 101 | 101 | */ |
| 102 | - public function get_events( $post_id = NULL ) { |
|
| 102 | + public function get_events($post_id = NULL) { |
|
| 103 | 103 | |
| 104 | 104 | // Get the entity IDs either from the entities related to the specified post or from the last 50 published |
| 105 | 105 | // posts if no post has been specified. |
| 106 | - $ids = ( is_numeric( $post_id ) |
|
| 107 | - ? wl_core_get_related_entity_ids( $post_id ) |
|
| 108 | - : $this->entity_service->get_all_related_to_last_50_published_posts() ); |
|
| 106 | + $ids = (is_numeric($post_id) |
|
| 107 | + ? wl_core_get_related_entity_ids($post_id) |
|
| 108 | + : $this->entity_service->get_all_related_to_last_50_published_posts()); |
|
| 109 | 109 | |
| 110 | 110 | // Add the post itself if it's an entity. |
| 111 | - if ( is_numeric( $post_id ) && $this->entity_service->is_entity( $post_id ) ) { |
|
| 111 | + if (is_numeric($post_id) && $this->entity_service->is_entity($post_id)) { |
|
| 112 | 112 | $ids[] = $post_id; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // If there's no entities, return an empty array right away. |
| 116 | - if ( 0 === sizeof( $ids ) ) { |
|
| 117 | - $this->log_service->trace( "No events found [ post id :: $post_id ]" ); |
|
| 116 | + if (0 === sizeof($ids)) { |
|
| 117 | + $this->log_service->trace("No events found [ post id :: $post_id ]"); |
|
| 118 | 118 | |
| 119 | 119 | return array(); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $this->log_service->trace( "Getting events [ entity ids :: " . join( ', ', $ids ) . " ]" ); |
|
| 122 | + $this->log_service->trace("Getting events [ entity ids :: ".join(', ', $ids)." ]"); |
|
| 123 | 123 | |
| 124 | - return get_posts( array( |
|
| 124 | + return get_posts(array( |
|
| 125 | 125 | 'post__in' => $ids, |
| 126 | 126 | 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
| 127 | 127 | 'post_status' => 'publish', |
| 128 | - 'posts_per_page' => - 1, |
|
| 128 | + 'posts_per_page' => -1, |
|
| 129 | 129 | 'meta_query' => array( |
| 130 | 130 | 'relation' => 'AND', |
| 131 | 131 | array( |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | 'field' => 'slug', |
| 145 | 145 | 'terms' => 'event' |
| 146 | 146 | ) |
| 147 | - ) ); |
|
| 147 | + )); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -158,23 +158,23 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return array|string An array of timeline events or an empty string if no posts are provided. |
| 160 | 160 | */ |
| 161 | - public function to_json( $posts ) { |
|
| 161 | + public function to_json($posts) { |
|
| 162 | 162 | |
| 163 | 163 | // If there are no events, return empty JSON |
| 164 | - if ( empty( $posts ) || is_null( $posts ) ) { |
|
| 164 | + if (empty($posts) || is_null($posts)) { |
|
| 165 | 165 | return ''; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // {media|thumbnail}: if set to 'media' the image is attached to the slide, if set to 'background' the image is set as background. |
| 169 | - $display_images_as = isset( $_REQUEST['display_images_as'] ) ? $_REQUEST['display_images_as'] : 'media'; |
|
| 169 | + $display_images_as = isset($_REQUEST['display_images_as']) ? $_REQUEST['display_images_as'] : 'media'; |
|
| 170 | 170 | |
| 171 | 171 | // The number of words for the excerpt (by default 55, as WordPress). |
| 172 | - $this->excerpt_length = $excerpt_length = isset( $_REQUEST['excerpt_length'] ) && is_numeric( $_REQUEST['excerpt_length'] ) ? $_REQUEST['excerpt_length'] : 55; |
|
| 173 | - add_filter( 'excerpt_length', array( $this, 'excerpt_length' ) ); |
|
| 172 | + $this->excerpt_length = $excerpt_length = isset($_REQUEST['excerpt_length']) && is_numeric($_REQUEST['excerpt_length']) ? $_REQUEST['excerpt_length'] : 55; |
|
| 173 | + add_filter('excerpt_length', array($this, 'excerpt_length')); |
|
| 174 | 174 | |
| 175 | 175 | // Add a filter to remove the [...] after excerpts, since we're adding |
| 176 | 176 | // a link to the post itself. |
| 177 | - add_filter( 'excerpt_more', array( $this, 'excerpt_more' ) ); |
|
| 177 | + add_filter('excerpt_more', array($this, 'excerpt_more')); |
|
| 178 | 178 | |
| 179 | 179 | // Prepare for the starting slide data. The starting slide will be the one where *now* is between *start/end* dates. |
| 180 | 180 | $start_at_slide = 0; |
@@ -185,27 +185,27 @@ discard block |
||
| 185 | 185 | $timeline = array(); |
| 186 | 186 | |
| 187 | 187 | // Populate the arrays. |
| 188 | - $timeline['events'] = array_map( function ( $item ) use ( &$timeline, &$event_index, &$start_at_slide, &$now, $display_images_as, $excerpt_length ) { |
|
| 188 | + $timeline['events'] = array_map(function($item) use (&$timeline, &$event_index, &$start_at_slide, &$now, $display_images_as, $excerpt_length) { |
|
| 189 | 189 | |
| 190 | 190 | // Get the start and end dates. |
| 191 | - $start_date = strtotime( get_post_meta( $item->ID, Wordlift_Schema_Service::FIELD_DATE_START, TRUE ) ); |
|
| 192 | - $end_date = strtotime( get_post_meta( $item->ID, Wordlift_Schema_Service::FIELD_DATE_END, TRUE ) ); |
|
| 191 | + $start_date = strtotime(get_post_meta($item->ID, Wordlift_Schema_Service::FIELD_DATE_START, TRUE)); |
|
| 192 | + $end_date = strtotime(get_post_meta($item->ID, Wordlift_Schema_Service::FIELD_DATE_END, TRUE)); |
|
| 193 | 193 | |
| 194 | 194 | // Set the starting slide. |
| 195 | - $event_index ++; |
|
| 196 | - if ( 0 === $start_at_slide && $now >= $start_date && $now <= $end_date ) { |
|
| 195 | + $event_index++; |
|
| 196 | + if (0 === $start_at_slide && $now >= $start_date && $now <= $end_date) { |
|
| 197 | 197 | $start_at_slide = $event_index; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // Load thumbnail |
| 201 | - if ( '' !== ( $thumbnail_id = get_post_thumbnail_id( $item->ID ) ) |
|
| 202 | - && FALSE !== ( $attachment = wp_get_attachment_image_src( $thumbnail_id ) ) |
|
| 201 | + if ('' !== ($thumbnail_id = get_post_thumbnail_id($item->ID)) |
|
| 202 | + && FALSE !== ($attachment = wp_get_attachment_image_src($thumbnail_id)) |
|
| 203 | 203 | ) { |
| 204 | 204 | |
| 205 | 205 | // Set the thumbnail URL. |
| 206 | - if ( 'background' === $display_images_as ) { |
|
| 207 | - $date['background'] = array( 'url' => $attachment[0], ); |
|
| 208 | - $date['media'] = array( 'thumbnail' => $attachment[0], ); |
|
| 206 | + if ('background' === $display_images_as) { |
|
| 207 | + $date['background'] = array('url' => $attachment[0],); |
|
| 208 | + $date['media'] = array('thumbnail' => $attachment[0],); |
|
| 209 | 209 | } else { |
| 210 | 210 | $date['media'] = array( |
| 211 | 211 | 'url' => $attachment[0], |
@@ -216,37 +216,37 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Set the start/end dates by converting them to TimelineJS required format. |
| 219 | - $date['start_date'] = Wordlift_Timeline_Service::date( $start_date ); |
|
| 220 | - $date['end_date'] = Wordlift_Timeline_Service::date( $end_date ); |
|
| 219 | + $date['start_date'] = Wordlift_Timeline_Service::date($start_date); |
|
| 220 | + $date['end_date'] = Wordlift_Timeline_Service::date($end_date); |
|
| 221 | 221 | |
| 222 | - setup_postdata( $GLOBALS['post'] = &$item ); |
|
| 222 | + setup_postdata($GLOBALS['post'] = &$item); |
|
| 223 | 223 | |
| 224 | 224 | $more_link_text = sprintf( |
| 225 | 225 | '<span aria-label="%1$s">%2$s</span>', |
| 226 | 226 | sprintf( |
| 227 | 227 | /* translators: %s: Name of current post */ |
| 228 | - __( 'Continue reading %s' ), |
|
| 229 | - the_title_attribute( array( 'echo' => FALSE ) ) |
|
| 228 | + __('Continue reading %s'), |
|
| 229 | + the_title_attribute(array('echo' => FALSE)) |
|
| 230 | 230 | ), |
| 231 | - __( '(more…)' ) |
|
| 231 | + __('(more…)') |
|
| 232 | 232 | ); |
| 233 | 233 | |
| 234 | 234 | // Set the event text only with the headline (see https://github.com/insideout10/wordlift-plugin/issues/352). |
| 235 | 235 | $date['text'] = array( |
| 236 | - 'headline' => '<a href="' . get_permalink( $item->ID ) . '">' . $item->post_title . '</a>', |
|
| 236 | + 'headline' => '<a href="'.get_permalink($item->ID).'">'.$item->post_title.'</a>', |
|
| 237 | 237 | ); |
| 238 | 238 | |
| 239 | 239 | // If we have an excerpt, set it. |
| 240 | - if ( 0 < $excerpt_length ) { |
|
| 241 | - $date['text']['text'] = sprintf( '%s <a href="%s">%s</a>', get_the_excerpt( $item ), get_permalink(), $more_link_text ); |
|
| 240 | + if (0 < $excerpt_length) { |
|
| 241 | + $date['text']['text'] = sprintf('%s <a href="%s">%s</a>', get_the_excerpt($item), get_permalink(), $more_link_text); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | return $date; |
| 245 | 245 | |
| 246 | - }, $posts ); |
|
| 246 | + }, $posts); |
|
| 247 | 247 | |
| 248 | 248 | // Finally remove the excerpt filter. |
| 249 | - remove_filter( 'excerpt_length', array( $this, 'excerpt_length' ) ); |
|
| 249 | + remove_filter('excerpt_length', array($this, 'excerpt_length')); |
|
| 250 | 250 | |
| 251 | 251 | // The JSON format is defined here: https://timeline.knightlab.com/docs/json-format.html |
| 252 | 252 | return array( |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @return string An empty string. |
| 267 | 267 | */ |
| 268 | - public function excerpt_more( $excerpt_more ) { |
|
| 268 | + public function excerpt_more($excerpt_more) { |
|
| 269 | 269 | |
| 270 | 270 | return ''; |
| 271 | 271 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * |
| 281 | 281 | * @return int The number of words for the preset. |
| 282 | 282 | */ |
| 283 | - public function excerpt_length( $length ) { |
|
| 283 | + public function excerpt_length($length) { |
|
| 284 | 284 | |
| 285 | 285 | return $this->excerpt_length; |
| 286 | 286 | } |
@@ -295,12 +295,12 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @return array An array containing year, month and day values. |
| 297 | 297 | */ |
| 298 | - public static function date( $value ) { |
|
| 298 | + public static function date($value) { |
|
| 299 | 299 | |
| 300 | 300 | return array( |
| 301 | - 'year' => (int) date( 'Y', $value ), |
|
| 302 | - 'month' => (int) date( 'm', $value ), |
|
| 303 | - 'day' => (int) date( 'd', $value ), |
|
| 301 | + 'year' => (int) date('Y', $value), |
|
| 302 | + 'month' => (int) date('m', $value), |
|
| 303 | + 'day' => (int) date('d', $value), |
|
| 304 | 304 | |
| 305 | 305 | ); |
| 306 | 306 | } |
@@ -8,50 +8,50 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | abstract class Wordlift_Shortcode { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * The shortcode, set by extending classes. |
|
| 13 | - */ |
|
| 14 | - const SHORTCODE = NULL; |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * Create a shortcode instance by registering the shortcode with the render |
|
| 18 | - * function. |
|
| 19 | - * |
|
| 20 | - * @since 3.5.4 |
|
| 21 | - */ |
|
| 22 | - public function __construct() { |
|
| 23 | - |
|
| 24 | - add_shortcode( static::SHORTCODE, array( $this, 'render' ) ); |
|
| 25 | - |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Render the shortcode. |
|
| 30 | - * |
|
| 31 | - * @since 3.5.4 |
|
| 32 | - * |
|
| 33 | - * @param array $atts An array of shortcode attributes as set by the editor. |
|
| 34 | - * |
|
| 35 | - * @return string The output html code. |
|
| 36 | - */ |
|
| 37 | - public abstract function render( $atts ); |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Enqueue scripts. Called by the shortcode implementations in their render |
|
| 41 | - * method. |
|
| 42 | - * |
|
| 43 | - * @since 3.5.4 |
|
| 44 | - */ |
|
| 45 | - protected function enqueue_scripts() { |
|
| 46 | - |
|
| 47 | - wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 48 | - wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array( 'angularjs' ) ); |
|
| 49 | - wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', array( |
|
| 50 | - 'jquery', |
|
| 51 | - 'angularjs', |
|
| 52 | - 'angularjs-touch' |
|
| 53 | - ) ); |
|
| 54 | - |
|
| 55 | - } |
|
| 11 | + /** |
|
| 12 | + * The shortcode, set by extending classes. |
|
| 13 | + */ |
|
| 14 | + const SHORTCODE = NULL; |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * Create a shortcode instance by registering the shortcode with the render |
|
| 18 | + * function. |
|
| 19 | + * |
|
| 20 | + * @since 3.5.4 |
|
| 21 | + */ |
|
| 22 | + public function __construct() { |
|
| 23 | + |
|
| 24 | + add_shortcode( static::SHORTCODE, array( $this, 'render' ) ); |
|
| 25 | + |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Render the shortcode. |
|
| 30 | + * |
|
| 31 | + * @since 3.5.4 |
|
| 32 | + * |
|
| 33 | + * @param array $atts An array of shortcode attributes as set by the editor. |
|
| 34 | + * |
|
| 35 | + * @return string The output html code. |
|
| 36 | + */ |
|
| 37 | + public abstract function render( $atts ); |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Enqueue scripts. Called by the shortcode implementations in their render |
|
| 41 | + * method. |
|
| 42 | + * |
|
| 43 | + * @since 3.5.4 |
|
| 44 | + */ |
|
| 45 | + protected function enqueue_scripts() { |
|
| 46 | + |
|
| 47 | + wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 48 | + wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array( 'angularjs' ) ); |
|
| 49 | + wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', array( |
|
| 50 | + 'jquery', |
|
| 51 | + 'angularjs', |
|
| 52 | + 'angularjs-touch' |
|
| 53 | + ) ); |
|
| 54 | + |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct() { |
| 23 | 23 | |
| 24 | - add_shortcode( static::SHORTCODE, array( $this, 'render' ) ); |
|
| 24 | + add_shortcode(static::SHORTCODE, array($this, 'render')); |
|
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @return string The output html code. |
| 36 | 36 | */ |
| 37 | - public abstract function render( $atts ); |
|
| 37 | + public abstract function render($atts); |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Enqueue scripts. Called by the shortcode implementations in their render |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | protected function enqueue_scripts() { |
| 46 | 46 | |
| 47 | - wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
| 48 | - wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array( 'angularjs' ) ); |
|
| 49 | - wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', array( |
|
| 47 | + wp_enqueue_script('angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js'); |
|
| 48 | + wp_enqueue_script('angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array('angularjs')); |
|
| 49 | + wp_enqueue_script('wordlift-ui', dirname(plugin_dir_url(__FILE__)).'/js/wordlift-ui'.( ! defined('SCRIPT_DEBUG') || ! SCRIPT_DEBUG ? '.min' : '').'.js', array( |
|
| 50 | 50 | 'jquery', |
| 51 | 51 | 'angularjs', |
| 52 | 52 | 'angularjs-touch' |
| 53 | - ) ); |
|
| 53 | + )); |
|
| 54 | 54 | |
| 55 | 55 | } |
| 56 | 56 | |
@@ -7,198 +7,198 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_Timeline_Shortcode extends Wordlift_Shortcode { |
| 9 | 9 | |
| 10 | - const SHORTCODE = 'wl_timeline'; |
|
| 11 | - |
|
| 12 | - /** |
|
| 13 | - * The list of locales supported by TimelineJS (correspond to the list of |
|
| 14 | - * files in the locale subfolder). |
|
| 15 | - * |
|
| 16 | - * @since 3.7.0 |
|
| 17 | - * @var array An array of two-letters language codes. |
|
| 18 | - */ |
|
| 19 | - private static $supported_locales = array( |
|
| 20 | - 'ur', |
|
| 21 | - 'uk', |
|
| 22 | - 'tr', |
|
| 23 | - 'tl', |
|
| 24 | - 'th', |
|
| 25 | - 'te', |
|
| 26 | - 'ta', |
|
| 27 | - 'sv', |
|
| 28 | - 'sr', |
|
| 29 | - 'sl', |
|
| 30 | - 'sk', |
|
| 31 | - 'si', |
|
| 32 | - 'ru', |
|
| 33 | - 'ro', |
|
| 34 | - 'rm', |
|
| 35 | - 'pt', |
|
| 36 | - 'pl', |
|
| 37 | - 'no', |
|
| 38 | - 'nl', |
|
| 39 | - 'ne', |
|
| 40 | - 'ms', |
|
| 41 | - 'lv', |
|
| 42 | - 'lt', |
|
| 43 | - 'lb', |
|
| 44 | - 'ko', |
|
| 45 | - 'ka', |
|
| 46 | - 'ja', |
|
| 47 | - 'iw', |
|
| 48 | - 'it', |
|
| 49 | - 'is', |
|
| 50 | - 'id', |
|
| 51 | - 'hy', |
|
| 52 | - 'hu', |
|
| 53 | - 'hr', |
|
| 54 | - 'hi', |
|
| 55 | - 'he', |
|
| 56 | - 'gl', |
|
| 57 | - 'ga', |
|
| 58 | - 'fy', |
|
| 59 | - 'fr', |
|
| 60 | - 'fo', |
|
| 61 | - 'fi', |
|
| 62 | - 'fa', |
|
| 63 | - 'eu', |
|
| 64 | - 'et', |
|
| 65 | - 'es', |
|
| 66 | - 'eo', |
|
| 67 | - 'en', |
|
| 68 | - 'el', |
|
| 69 | - 'de', |
|
| 70 | - 'da', |
|
| 71 | - 'cz', |
|
| 72 | - 'ca', |
|
| 73 | - 'bg', |
|
| 74 | - 'be', |
|
| 75 | - 'ar', |
|
| 76 | - 'af' |
|
| 77 | - ); |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * The Log service. |
|
| 81 | - * |
|
| 82 | - * @since 3.1.0 |
|
| 83 | - * @access private |
|
| 84 | - * @var \Wordlift_Log_Service $log_service The Log service. |
|
| 85 | - */ |
|
| 86 | - private $log_service; |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Create a Wordlift_Timeline_Shortcode instance. |
|
| 90 | - * |
|
| 91 | - * @since 3.1.0 |
|
| 92 | - */ |
|
| 93 | - public function __construct() { |
|
| 94 | - parent::__construct(); |
|
| 95 | - |
|
| 96 | - $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Timeline_Shortcode' ); |
|
| 97 | - |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Renders the Timeline. |
|
| 102 | - * |
|
| 103 | - * @since 3.1.0 |
|
| 104 | - * |
|
| 105 | - * @param array $atts An array of shortcode attributes. |
|
| 106 | - * |
|
| 107 | - * @return string The rendered HTML. |
|
| 108 | - */ |
|
| 109 | - public function render( $atts ) { |
|
| 110 | - |
|
| 111 | - //extract attributes and set default values |
|
| 112 | - $settings = shortcode_atts( array( |
|
| 113 | - 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG, |
|
| 114 | - 'height' => NULL, |
|
| 115 | - 'width' => NULL, |
|
| 116 | - 'is_embed' => FALSE, |
|
| 117 | - 'hash_bookmark' => FALSE, |
|
| 118 | - 'default_bg_color' => 'white', |
|
| 119 | - 'scale_factor' => 2, |
|
| 120 | - 'initial_zoom' => NULL, |
|
| 121 | - 'zoom_sequence' => '[0.5, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]', |
|
| 122 | - 'timenav_position' => 'bottom', |
|
| 123 | - 'optimal_tick_width' => 100, |
|
| 124 | - 'base_class' => 'tl-timeline', |
|
| 125 | - 'timenav_height' => 150, |
|
| 126 | - 'timenav_height_percentage' => NULL, |
|
| 127 | - 'timenav_mobile_height_percentage' => 40, |
|
| 128 | - 'timenav_height_min' => 150, |
|
| 129 | - 'marker_height_min' => 30, |
|
| 130 | - 'marker_width_min' => 100, |
|
| 131 | - 'marker_padding' => 5, |
|
| 132 | - 'start_at_slide' => 0, |
|
| 133 | - 'start_at_end' => FALSE, |
|
| 134 | - 'menubar_height' => 0, |
|
| 135 | - 'use_bc' => FALSE, |
|
| 136 | - 'duration' => 1000, |
|
| 137 | - 'ease' => 'TL.Ease.easeInOutQuint', |
|
| 138 | - 'slide_default_fade' => '0%', |
|
| 139 | - 'language' => $this->get_locale(), |
|
| 140 | - 'ga_property_id' => NULL, |
|
| 141 | - 'track_events' => "['back_to_start','nav_next','nav_previous','zoom_in','zoom_out']", |
|
| 142 | - 'global' => FALSE, |
|
| 143 | - // The following settings are unrelated to TimelineJS script. |
|
| 144 | - 'display_images_as' => 'media', |
|
| 145 | - 'excerpt_length' => 55, |
|
| 146 | - ), $atts ); |
|
| 147 | - |
|
| 148 | - // Load the TimelineJS stylesheets and scripts. |
|
| 149 | - wp_enqueue_style( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/timelinejs/css/timeline.css' ); |
|
| 150 | - wp_enqueue_script( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/timelinejs/js/timeline' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '-min' : '' ) . '.js' ); |
|
| 151 | - |
|
| 152 | - // Enqueue the scripts for the timeline. |
|
| 153 | - $this->enqueue_scripts(); |
|
| 154 | - |
|
| 155 | - // Provide the script with options. |
|
| 156 | - wp_localize_script( 'timelinejs', 'wl_timeline_params', array( |
|
| 157 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 158 | - // TODO: this parameter is already provided by WP |
|
| 159 | - 'action' => 'wl_timeline', |
|
| 160 | - // These settings apply to our wl_timeline AJAX endpoint. |
|
| 161 | - 'display_images_as' => $settings['display_images_as'], |
|
| 162 | - 'excerpt_length' => $settings['excerpt_length'], |
|
| 163 | - // These settings apply to the timeline javascript client. |
|
| 164 | - 'settings' => array_filter( $settings, function ( $value ) { |
|
| 165 | - // Do not set NULL values. |
|
| 166 | - return ( NULL !== $value ); |
|
| 167 | - } ) |
|
| 168 | - ) ); |
|
| 169 | - |
|
| 170 | - // Get the current post id or set null if global is set to true. |
|
| 171 | - $post_id = ( $settings['global'] ? NULL : get_the_ID() ); |
|
| 172 | - |
|
| 173 | - // Escaping atts. |
|
| 174 | - $style = sprintf( 'style="%s%s"', isset( $settings['width'] ) ? "width:{$settings['width']};" : '', isset( $settings['height'] ) ? "height:{$settings['height']};" : '' ); |
|
| 175 | - $data_post_id = ( isset( $post_id ) ? "data-post-id='$post_id'" : '' ); |
|
| 176 | - |
|
| 177 | - // Generate a unique ID for this timeline. |
|
| 178 | - $element_id = uniqid( 'wl-timeline-' ); |
|
| 179 | - |
|
| 180 | - if ( WP_DEBUG ) { |
|
| 181 | - $this->log_service->trace( "Creating a timeline widget [ element id :: $element_id ][ post id :: $post_id ]" ); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - // Building template. |
|
| 185 | - return sprintf( '<div class="wl-timeline-container" %s><div class="wl-timeline" id="%s" %s></div></div>', $style, $element_id, $data_post_id ); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Return the locale for the TimelineJS according to WP's configured locale and |
|
| 190 | - * support TimelineJS locales. If WP's locale is not supported, english is used. |
|
| 191 | - * |
|
| 192 | - * @since 3.7.0 |
|
| 193 | - * @return string The locale (2 letters code). |
|
| 194 | - */ |
|
| 195 | - private function get_locale() { |
|
| 196 | - |
|
| 197 | - // Get the first 2 letters. |
|
| 198 | - $locale = substr( get_locale(), 0, 2 ); |
|
| 199 | - |
|
| 200 | - // Check that the specified locale is supported otherwise use English. |
|
| 201 | - return in_array( $locale, self::$supported_locales ) ? $locale : 'en'; |
|
| 202 | - } |
|
| 10 | + const SHORTCODE = 'wl_timeline'; |
|
| 11 | + |
|
| 12 | + /** |
|
| 13 | + * The list of locales supported by TimelineJS (correspond to the list of |
|
| 14 | + * files in the locale subfolder). |
|
| 15 | + * |
|
| 16 | + * @since 3.7.0 |
|
| 17 | + * @var array An array of two-letters language codes. |
|
| 18 | + */ |
|
| 19 | + private static $supported_locales = array( |
|
| 20 | + 'ur', |
|
| 21 | + 'uk', |
|
| 22 | + 'tr', |
|
| 23 | + 'tl', |
|
| 24 | + 'th', |
|
| 25 | + 'te', |
|
| 26 | + 'ta', |
|
| 27 | + 'sv', |
|
| 28 | + 'sr', |
|
| 29 | + 'sl', |
|
| 30 | + 'sk', |
|
| 31 | + 'si', |
|
| 32 | + 'ru', |
|
| 33 | + 'ro', |
|
| 34 | + 'rm', |
|
| 35 | + 'pt', |
|
| 36 | + 'pl', |
|
| 37 | + 'no', |
|
| 38 | + 'nl', |
|
| 39 | + 'ne', |
|
| 40 | + 'ms', |
|
| 41 | + 'lv', |
|
| 42 | + 'lt', |
|
| 43 | + 'lb', |
|
| 44 | + 'ko', |
|
| 45 | + 'ka', |
|
| 46 | + 'ja', |
|
| 47 | + 'iw', |
|
| 48 | + 'it', |
|
| 49 | + 'is', |
|
| 50 | + 'id', |
|
| 51 | + 'hy', |
|
| 52 | + 'hu', |
|
| 53 | + 'hr', |
|
| 54 | + 'hi', |
|
| 55 | + 'he', |
|
| 56 | + 'gl', |
|
| 57 | + 'ga', |
|
| 58 | + 'fy', |
|
| 59 | + 'fr', |
|
| 60 | + 'fo', |
|
| 61 | + 'fi', |
|
| 62 | + 'fa', |
|
| 63 | + 'eu', |
|
| 64 | + 'et', |
|
| 65 | + 'es', |
|
| 66 | + 'eo', |
|
| 67 | + 'en', |
|
| 68 | + 'el', |
|
| 69 | + 'de', |
|
| 70 | + 'da', |
|
| 71 | + 'cz', |
|
| 72 | + 'ca', |
|
| 73 | + 'bg', |
|
| 74 | + 'be', |
|
| 75 | + 'ar', |
|
| 76 | + 'af' |
|
| 77 | + ); |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * The Log service. |
|
| 81 | + * |
|
| 82 | + * @since 3.1.0 |
|
| 83 | + * @access private |
|
| 84 | + * @var \Wordlift_Log_Service $log_service The Log service. |
|
| 85 | + */ |
|
| 86 | + private $log_service; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Create a Wordlift_Timeline_Shortcode instance. |
|
| 90 | + * |
|
| 91 | + * @since 3.1.0 |
|
| 92 | + */ |
|
| 93 | + public function __construct() { |
|
| 94 | + parent::__construct(); |
|
| 95 | + |
|
| 96 | + $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Timeline_Shortcode' ); |
|
| 97 | + |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Renders the Timeline. |
|
| 102 | + * |
|
| 103 | + * @since 3.1.0 |
|
| 104 | + * |
|
| 105 | + * @param array $atts An array of shortcode attributes. |
|
| 106 | + * |
|
| 107 | + * @return string The rendered HTML. |
|
| 108 | + */ |
|
| 109 | + public function render( $atts ) { |
|
| 110 | + |
|
| 111 | + //extract attributes and set default values |
|
| 112 | + $settings = shortcode_atts( array( |
|
| 113 | + 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG, |
|
| 114 | + 'height' => NULL, |
|
| 115 | + 'width' => NULL, |
|
| 116 | + 'is_embed' => FALSE, |
|
| 117 | + 'hash_bookmark' => FALSE, |
|
| 118 | + 'default_bg_color' => 'white', |
|
| 119 | + 'scale_factor' => 2, |
|
| 120 | + 'initial_zoom' => NULL, |
|
| 121 | + 'zoom_sequence' => '[0.5, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]', |
|
| 122 | + 'timenav_position' => 'bottom', |
|
| 123 | + 'optimal_tick_width' => 100, |
|
| 124 | + 'base_class' => 'tl-timeline', |
|
| 125 | + 'timenav_height' => 150, |
|
| 126 | + 'timenav_height_percentage' => NULL, |
|
| 127 | + 'timenav_mobile_height_percentage' => 40, |
|
| 128 | + 'timenav_height_min' => 150, |
|
| 129 | + 'marker_height_min' => 30, |
|
| 130 | + 'marker_width_min' => 100, |
|
| 131 | + 'marker_padding' => 5, |
|
| 132 | + 'start_at_slide' => 0, |
|
| 133 | + 'start_at_end' => FALSE, |
|
| 134 | + 'menubar_height' => 0, |
|
| 135 | + 'use_bc' => FALSE, |
|
| 136 | + 'duration' => 1000, |
|
| 137 | + 'ease' => 'TL.Ease.easeInOutQuint', |
|
| 138 | + 'slide_default_fade' => '0%', |
|
| 139 | + 'language' => $this->get_locale(), |
|
| 140 | + 'ga_property_id' => NULL, |
|
| 141 | + 'track_events' => "['back_to_start','nav_next','nav_previous','zoom_in','zoom_out']", |
|
| 142 | + 'global' => FALSE, |
|
| 143 | + // The following settings are unrelated to TimelineJS script. |
|
| 144 | + 'display_images_as' => 'media', |
|
| 145 | + 'excerpt_length' => 55, |
|
| 146 | + ), $atts ); |
|
| 147 | + |
|
| 148 | + // Load the TimelineJS stylesheets and scripts. |
|
| 149 | + wp_enqueue_style( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/timelinejs/css/timeline.css' ); |
|
| 150 | + wp_enqueue_script( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/timelinejs/js/timeline' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '-min' : '' ) . '.js' ); |
|
| 151 | + |
|
| 152 | + // Enqueue the scripts for the timeline. |
|
| 153 | + $this->enqueue_scripts(); |
|
| 154 | + |
|
| 155 | + // Provide the script with options. |
|
| 156 | + wp_localize_script( 'timelinejs', 'wl_timeline_params', array( |
|
| 157 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 158 | + // TODO: this parameter is already provided by WP |
|
| 159 | + 'action' => 'wl_timeline', |
|
| 160 | + // These settings apply to our wl_timeline AJAX endpoint. |
|
| 161 | + 'display_images_as' => $settings['display_images_as'], |
|
| 162 | + 'excerpt_length' => $settings['excerpt_length'], |
|
| 163 | + // These settings apply to the timeline javascript client. |
|
| 164 | + 'settings' => array_filter( $settings, function ( $value ) { |
|
| 165 | + // Do not set NULL values. |
|
| 166 | + return ( NULL !== $value ); |
|
| 167 | + } ) |
|
| 168 | + ) ); |
|
| 169 | + |
|
| 170 | + // Get the current post id or set null if global is set to true. |
|
| 171 | + $post_id = ( $settings['global'] ? NULL : get_the_ID() ); |
|
| 172 | + |
|
| 173 | + // Escaping atts. |
|
| 174 | + $style = sprintf( 'style="%s%s"', isset( $settings['width'] ) ? "width:{$settings['width']};" : '', isset( $settings['height'] ) ? "height:{$settings['height']};" : '' ); |
|
| 175 | + $data_post_id = ( isset( $post_id ) ? "data-post-id='$post_id'" : '' ); |
|
| 176 | + |
|
| 177 | + // Generate a unique ID for this timeline. |
|
| 178 | + $element_id = uniqid( 'wl-timeline-' ); |
|
| 179 | + |
|
| 180 | + if ( WP_DEBUG ) { |
|
| 181 | + $this->log_service->trace( "Creating a timeline widget [ element id :: $element_id ][ post id :: $post_id ]" ); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + // Building template. |
|
| 185 | + return sprintf( '<div class="wl-timeline-container" %s><div class="wl-timeline" id="%s" %s></div></div>', $style, $element_id, $data_post_id ); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Return the locale for the TimelineJS according to WP's configured locale and |
|
| 190 | + * support TimelineJS locales. If WP's locale is not supported, english is used. |
|
| 191 | + * |
|
| 192 | + * @since 3.7.0 |
|
| 193 | + * @return string The locale (2 letters code). |
|
| 194 | + */ |
|
| 195 | + private function get_locale() { |
|
| 196 | + |
|
| 197 | + // Get the first 2 letters. |
|
| 198 | + $locale = substr( get_locale(), 0, 2 ); |
|
| 199 | + |
|
| 200 | + // Check that the specified locale is supported otherwise use English. |
|
| 201 | + return in_array( $locale, self::$supported_locales ) ? $locale : 'en'; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | public function __construct() { |
| 94 | 94 | parent::__construct(); |
| 95 | 95 | |
| 96 | - $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Timeline_Shortcode' ); |
|
| 96 | + $this->log_service = Wordlift_Log_Service::get_logger('Wordlift_Timeline_Shortcode'); |
|
| 97 | 97 | |
| 98 | 98 | } |
| 99 | 99 | |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return string The rendered HTML. |
| 108 | 108 | */ |
| 109 | - public function render( $atts ) { |
|
| 109 | + public function render($atts) { |
|
| 110 | 110 | |
| 111 | 111 | //extract attributes and set default values |
| 112 | - $settings = shortcode_atts( array( |
|
| 113 | - 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG, |
|
| 112 | + $settings = shortcode_atts(array( |
|
| 113 | + 'debug' => defined('WP_DEBUG') && WP_DEBUG, |
|
| 114 | 114 | 'height' => NULL, |
| 115 | 115 | 'width' => NULL, |
| 116 | 116 | 'is_embed' => FALSE, |
@@ -143,46 +143,46 @@ discard block |
||
| 143 | 143 | // The following settings are unrelated to TimelineJS script. |
| 144 | 144 | 'display_images_as' => 'media', |
| 145 | 145 | 'excerpt_length' => 55, |
| 146 | - ), $atts ); |
|
| 146 | + ), $atts); |
|
| 147 | 147 | |
| 148 | 148 | // Load the TimelineJS stylesheets and scripts. |
| 149 | - wp_enqueue_style( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/timelinejs/css/timeline.css' ); |
|
| 150 | - wp_enqueue_script( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/timelinejs/js/timeline' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '-min' : '' ) . '.js' ); |
|
| 149 | + wp_enqueue_style('timelinejs', dirname(plugin_dir_url(__FILE__)).'/timelinejs/css/timeline.css'); |
|
| 150 | + wp_enqueue_script('timelinejs', dirname(plugin_dir_url(__FILE__)).'/timelinejs/js/timeline'.( ! defined('SCRIPT_DEBUG') || ! SCRIPT_DEBUG ? '-min' : '').'.js'); |
|
| 151 | 151 | |
| 152 | 152 | // Enqueue the scripts for the timeline. |
| 153 | 153 | $this->enqueue_scripts(); |
| 154 | 154 | |
| 155 | 155 | // Provide the script with options. |
| 156 | - wp_localize_script( 'timelinejs', 'wl_timeline_params', array( |
|
| 157 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 156 | + wp_localize_script('timelinejs', 'wl_timeline_params', array( |
|
| 157 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 158 | 158 | // TODO: this parameter is already provided by WP |
| 159 | 159 | 'action' => 'wl_timeline', |
| 160 | 160 | // These settings apply to our wl_timeline AJAX endpoint. |
| 161 | 161 | 'display_images_as' => $settings['display_images_as'], |
| 162 | 162 | 'excerpt_length' => $settings['excerpt_length'], |
| 163 | 163 | // These settings apply to the timeline javascript client. |
| 164 | - 'settings' => array_filter( $settings, function ( $value ) { |
|
| 164 | + 'settings' => array_filter($settings, function($value) { |
|
| 165 | 165 | // Do not set NULL values. |
| 166 | - return ( NULL !== $value ); |
|
| 166 | + return (NULL !== $value); |
|
| 167 | 167 | } ) |
| 168 | - ) ); |
|
| 168 | + )); |
|
| 169 | 169 | |
| 170 | 170 | // Get the current post id or set null if global is set to true. |
| 171 | - $post_id = ( $settings['global'] ? NULL : get_the_ID() ); |
|
| 171 | + $post_id = ($settings['global'] ? NULL : get_the_ID()); |
|
| 172 | 172 | |
| 173 | 173 | // Escaping atts. |
| 174 | - $style = sprintf( 'style="%s%s"', isset( $settings['width'] ) ? "width:{$settings['width']};" : '', isset( $settings['height'] ) ? "height:{$settings['height']};" : '' ); |
|
| 175 | - $data_post_id = ( isset( $post_id ) ? "data-post-id='$post_id'" : '' ); |
|
| 174 | + $style = sprintf('style="%s%s"', isset($settings['width']) ? "width:{$settings['width']};" : '', isset($settings['height']) ? "height:{$settings['height']};" : ''); |
|
| 175 | + $data_post_id = (isset($post_id) ? "data-post-id='$post_id'" : ''); |
|
| 176 | 176 | |
| 177 | 177 | // Generate a unique ID for this timeline. |
| 178 | - $element_id = uniqid( 'wl-timeline-' ); |
|
| 178 | + $element_id = uniqid('wl-timeline-'); |
|
| 179 | 179 | |
| 180 | - if ( WP_DEBUG ) { |
|
| 181 | - $this->log_service->trace( "Creating a timeline widget [ element id :: $element_id ][ post id :: $post_id ]" ); |
|
| 180 | + if (WP_DEBUG) { |
|
| 181 | + $this->log_service->trace("Creating a timeline widget [ element id :: $element_id ][ post id :: $post_id ]"); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // Building template. |
| 185 | - return sprintf( '<div class="wl-timeline-container" %s><div class="wl-timeline" id="%s" %s></div></div>', $style, $element_id, $data_post_id ); |
|
| 185 | + return sprintf('<div class="wl-timeline-container" %s><div class="wl-timeline" id="%s" %s></div></div>', $style, $element_id, $data_post_id); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -195,10 +195,10 @@ discard block |
||
| 195 | 195 | private function get_locale() { |
| 196 | 196 | |
| 197 | 197 | // Get the first 2 letters. |
| 198 | - $locale = substr( get_locale(), 0, 2 ); |
|
| 198 | + $locale = substr(get_locale(), 0, 2); |
|
| 199 | 199 | |
| 200 | 200 | // Check that the specified locale is supported otherwise use English. |
| 201 | - return in_array( $locale, self::$supported_locales ) ? $locale : 'en'; |
|
| 201 | + return in_array($locale, self::$supported_locales) ? $locale : 'en'; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | } |
@@ -29,702 +29,702 @@ |
||
| 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_Type_Service |
|
| 192 | - */ |
|
| 193 | - private $entity_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 | - * The 'Download Your Data' page. |
|
| 243 | - * |
|
| 244 | - * @since 3.6.0 |
|
| 245 | - * @access private |
|
| 246 | - * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 247 | - */ |
|
| 248 | - private $download_your_data_page; |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * Define the core functionality of the plugin. |
|
| 252 | - * |
|
| 253 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 254 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 255 | - * the public-facing side of the site. |
|
| 256 | - * |
|
| 257 | - * @since 1.0.0 |
|
| 258 | - */ |
|
| 259 | - public function __construct() { |
|
| 260 | - |
|
| 261 | - $this->plugin_name = 'wordlift'; |
|
| 262 | - $this->version = '3.7.0'; |
|
| 263 | - $this->load_dependencies(); |
|
| 264 | - $this->set_locale(); |
|
| 265 | - $this->define_admin_hooks(); |
|
| 266 | - $this->define_public_hooks(); |
|
| 267 | - |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * Load the required dependencies for this plugin. |
|
| 272 | - * |
|
| 273 | - * Include the following files that make up the plugin: |
|
| 274 | - * |
|
| 275 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 276 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 277 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 278 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 279 | - * |
|
| 280 | - * Create an instance of the loader which will be used to register the hooks |
|
| 281 | - * with WordPress. |
|
| 282 | - * |
|
| 283 | - * @since 1.0.0 |
|
| 284 | - * @access private |
|
| 285 | - */ |
|
| 286 | - private function load_dependencies() { |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * The class responsible for orchestrating the actions and filters of the |
|
| 290 | - * core plugin. |
|
| 291 | - */ |
|
| 292 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * The class responsible for defining internationalization functionality |
|
| 296 | - * of the plugin. |
|
| 297 | - */ |
|
| 298 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * Provide support functions to sanitize data. |
|
| 302 | - */ |
|
| 303 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * The Redirect service. |
|
| 307 | - */ |
|
| 308 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * The Log service. |
|
| 312 | - */ |
|
| 313 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * The configuration service. |
|
| 317 | - */ |
|
| 318 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 319 | - |
|
| 320 | - /** |
|
| 321 | - * The entity post type service. |
|
| 322 | - */ |
|
| 323 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * The entity link service. |
|
| 327 | - */ |
|
| 328 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * The Query builder. |
|
| 332 | - */ |
|
| 333 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * The Schema service. |
|
| 337 | - */ |
|
| 338 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * The schema:url property service. |
|
| 342 | - */ |
|
| 343 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 344 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * The UI service. |
|
| 348 | - */ |
|
| 349 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * The Thumbnail service. |
|
| 353 | - */ |
|
| 354 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * The Entity Types Taxonomy service. |
|
| 358 | - */ |
|
| 359 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 360 | - |
|
| 361 | - /** |
|
| 362 | - * The Entity service. |
|
| 363 | - */ |
|
| 364 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * The User service. |
|
| 368 | - */ |
|
| 369 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * The Timeline service. |
|
| 373 | - */ |
|
| 374 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * The Topic Taxonomy service. |
|
| 378 | - */ |
|
| 379 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 380 | - |
|
| 381 | - |
|
| 382 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * The SPARQL service. |
|
| 386 | - */ |
|
| 387 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * The WordLift import service. |
|
| 391 | - */ |
|
| 392 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * The WordLift URI service. |
|
| 396 | - */ |
|
| 397 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 398 | - |
|
| 399 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 400 | - |
|
| 401 | - /** |
|
| 402 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 403 | - */ |
|
| 404 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 405 | - |
|
| 406 | - /** |
|
| 407 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 408 | - */ |
|
| 409 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * The class to customize the entity list admin page. |
|
| 413 | - */ |
|
| 414 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 415 | - |
|
| 416 | - /** |
|
| 417 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 418 | - */ |
|
| 419 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * The Notice service. |
|
| 423 | - */ |
|
| 424 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 425 | - |
|
| 426 | - /** |
|
| 427 | - * The PrimaShop adapter. |
|
| 428 | - */ |
|
| 429 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * The WordLift Dashboard service. |
|
| 433 | - */ |
|
| 434 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 435 | - |
|
| 436 | - /** |
|
| 437 | - * The admin 'Download Your Data' page. |
|
| 438 | - */ |
|
| 439 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.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_Type_Service |
|
| 192 | + */ |
|
| 193 | + private $entity_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 | + * The 'Download Your Data' page. |
|
| 243 | + * |
|
| 244 | + * @since 3.6.0 |
|
| 245 | + * @access private |
|
| 246 | + * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page. |
|
| 247 | + */ |
|
| 248 | + private $download_your_data_page; |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * Define the core functionality of the plugin. |
|
| 252 | + * |
|
| 253 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 254 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 255 | + * the public-facing side of the site. |
|
| 256 | + * |
|
| 257 | + * @since 1.0.0 |
|
| 258 | + */ |
|
| 259 | + public function __construct() { |
|
| 260 | + |
|
| 261 | + $this->plugin_name = 'wordlift'; |
|
| 262 | + $this->version = '3.7.0'; |
|
| 263 | + $this->load_dependencies(); |
|
| 264 | + $this->set_locale(); |
|
| 265 | + $this->define_admin_hooks(); |
|
| 266 | + $this->define_public_hooks(); |
|
| 267 | + |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * Load the required dependencies for this plugin. |
|
| 272 | + * |
|
| 273 | + * Include the following files that make up the plugin: |
|
| 274 | + * |
|
| 275 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 276 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 277 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 278 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 279 | + * |
|
| 280 | + * Create an instance of the loader which will be used to register the hooks |
|
| 281 | + * with WordPress. |
|
| 282 | + * |
|
| 283 | + * @since 1.0.0 |
|
| 284 | + * @access private |
|
| 285 | + */ |
|
| 286 | + private function load_dependencies() { |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * The class responsible for orchestrating the actions and filters of the |
|
| 290 | + * core plugin. |
|
| 291 | + */ |
|
| 292 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * The class responsible for defining internationalization functionality |
|
| 296 | + * of the plugin. |
|
| 297 | + */ |
|
| 298 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * Provide support functions to sanitize data. |
|
| 302 | + */ |
|
| 303 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * The Redirect service. |
|
| 307 | + */ |
|
| 308 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 309 | + |
|
| 310 | + /** |
|
| 311 | + * The Log service. |
|
| 312 | + */ |
|
| 313 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * The configuration service. |
|
| 317 | + */ |
|
| 318 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 319 | + |
|
| 320 | + /** |
|
| 321 | + * The entity post type service. |
|
| 322 | + */ |
|
| 323 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * The entity link service. |
|
| 327 | + */ |
|
| 328 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * The Query builder. |
|
| 332 | + */ |
|
| 333 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * The Schema service. |
|
| 337 | + */ |
|
| 338 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * The schema:url property service. |
|
| 342 | + */ |
|
| 343 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php'; |
|
| 344 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * The UI service. |
|
| 348 | + */ |
|
| 349 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * The Thumbnail service. |
|
| 353 | + */ |
|
| 354 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * The Entity Types Taxonomy service. |
|
| 358 | + */ |
|
| 359 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 360 | + |
|
| 361 | + /** |
|
| 362 | + * The Entity service. |
|
| 363 | + */ |
|
| 364 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * The User service. |
|
| 368 | + */ |
|
| 369 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * The Timeline service. |
|
| 373 | + */ |
|
| 374 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * The Topic Taxonomy service. |
|
| 378 | + */ |
|
| 379 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 380 | + |
|
| 381 | + |
|
| 382 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * The SPARQL service. |
|
| 386 | + */ |
|
| 387 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * The WordLift import service. |
|
| 391 | + */ |
|
| 392 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * The WordLift URI service. |
|
| 396 | + */ |
|
| 397 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 398 | + |
|
| 399 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 400 | + |
|
| 401 | + /** |
|
| 402 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 403 | + */ |
|
| 404 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 408 | + */ |
|
| 409 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * The class to customize the entity list admin page. |
|
| 413 | + */ |
|
| 414 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 415 | + |
|
| 416 | + /** |
|
| 417 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 418 | + */ |
|
| 419 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * The Notice service. |
|
| 423 | + */ |
|
| 424 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 425 | + |
|
| 426 | + /** |
|
| 427 | + * The PrimaShop adapter. |
|
| 428 | + */ |
|
| 429 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * The WordLift Dashboard service. |
|
| 433 | + */ |
|
| 434 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 435 | + |
|
| 436 | + /** |
|
| 437 | + * The admin 'Download Your Data' page. |
|
| 438 | + */ |
|
| 439 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php'; |
|
| 440 | 440 | |
| 441 | - /** |
|
| 442 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 443 | - * side of the site. |
|
| 444 | - */ |
|
| 445 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 441 | + /** |
|
| 442 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 443 | + * side of the site. |
|
| 444 | + */ |
|
| 445 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 446 | 446 | |
| 447 | - /** |
|
| 448 | - * The shortcode abstract class. |
|
| 449 | - */ |
|
| 450 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 447 | + /** |
|
| 448 | + * The shortcode abstract class. |
|
| 449 | + */ |
|
| 450 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 451 | 451 | |
| 452 | - /** |
|
| 453 | - * The Timeline shortcode. |
|
| 454 | - */ |
|
| 455 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 452 | + /** |
|
| 453 | + * The Timeline shortcode. |
|
| 454 | + */ |
|
| 455 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 456 | 456 | |
| 457 | - /** |
|
| 458 | - * The Navigator shortcode. |
|
| 459 | - */ |
|
| 460 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 457 | + /** |
|
| 458 | + * The Navigator shortcode. |
|
| 459 | + */ |
|
| 460 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 461 | 461 | |
| 462 | - /** |
|
| 463 | - * The chord shortcode. |
|
| 464 | - */ |
|
| 465 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 462 | + /** |
|
| 463 | + * The chord shortcode. |
|
| 464 | + */ |
|
| 465 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 466 | 466 | |
| 467 | - /** |
|
| 468 | - * The geomap shortcode. |
|
| 469 | - */ |
|
| 470 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 467 | + /** |
|
| 468 | + * The geomap shortcode. |
|
| 469 | + */ |
|
| 470 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 471 | 471 | |
| 472 | - /** |
|
| 473 | - * The ShareThis service. |
|
| 474 | - */ |
|
| 475 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 472 | + /** |
|
| 473 | + * The ShareThis service. |
|
| 474 | + */ |
|
| 475 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 476 | 476 | |
| 477 | - $this->loader = new Wordlift_Loader(); |
|
| 477 | + $this->loader = new Wordlift_Loader(); |
|
| 478 | 478 | |
| 479 | - // Instantiate a global logger. |
|
| 480 | - global $wl_logger; |
|
| 481 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 479 | + // Instantiate a global logger. |
|
| 480 | + global $wl_logger; |
|
| 481 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 482 | 482 | |
| 483 | - // Create the configuration service. |
|
| 484 | - $configuration_service = new Wordlift_Configuration_Service(); |
|
| 483 | + // Create the configuration service. |
|
| 484 | + $configuration_service = new Wordlift_Configuration_Service(); |
|
| 485 | 485 | |
| 486 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 487 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() ); |
|
| 486 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 487 | + $this->entity_type_service = new Wordlift_Entity_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() ); |
|
| 488 | 488 | |
| 489 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 490 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_type_service, $configuration_service->get_entity_base_path() ); |
|
| 489 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 490 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_type_service, $configuration_service->get_entity_base_path() ); |
|
| 491 | 491 | |
| 492 | - // Create an instance of the UI service. |
|
| 493 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 492 | + // Create an instance of the UI service. |
|
| 493 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 494 | 494 | |
| 495 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 496 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 495 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 496 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 497 | 497 | |
| 498 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 498 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 499 | 499 | |
| 500 | - // Create an instance of the Schema service. |
|
| 501 | - new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 502 | - $this->schema_service = new Wordlift_Schema_Service(); |
|
| 500 | + // Create an instance of the Schema service. |
|
| 501 | + new Wordlift_Schema_Url_Property_Service( $this->sparql_service ); |
|
| 502 | + $this->schema_service = new Wordlift_Schema_Service(); |
|
| 503 | 503 | |
| 504 | - // Create an instance of the Notice service. |
|
| 505 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 504 | + // Create an instance of the Notice service. |
|
| 505 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 506 | 506 | |
| 507 | - // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 508 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 507 | + // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 508 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 509 | 509 | |
| 510 | - // Create an instance of the User service. |
|
| 511 | - $this->user_service = new Wordlift_User_Service(); |
|
| 510 | + // Create an instance of the User service. |
|
| 511 | + $this->user_service = new Wordlift_User_Service(); |
|
| 512 | 512 | |
| 513 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 514 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 513 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 514 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 515 | 515 | |
| 516 | - // Create a new instance of the Redirect service. |
|
| 517 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 516 | + // Create a new instance of the Redirect service. |
|
| 517 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 518 | 518 | |
| 519 | - // Create a new instance of the Redirect service. |
|
| 520 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 519 | + // Create a new instance of the Redirect service. |
|
| 520 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 521 | 521 | |
| 522 | - // Initialize the shortcodes. |
|
| 523 | - new Wordlift_Navigator_Shortcode(); |
|
| 524 | - new Wordlift_Chord_Shortcode(); |
|
| 525 | - new Wordlift_Geomap_Shortcode(); |
|
| 526 | - new Wordlift_Timeline_Shortcode(); |
|
| 522 | + // Initialize the shortcodes. |
|
| 523 | + new Wordlift_Navigator_Shortcode(); |
|
| 524 | + new Wordlift_Chord_Shortcode(); |
|
| 525 | + new Wordlift_Geomap_Shortcode(); |
|
| 526 | + new Wordlift_Timeline_Shortcode(); |
|
| 527 | 527 | |
| 528 | - // Create entity list customization (wp-admin/edit.php) |
|
| 529 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 528 | + // Create entity list customization (wp-admin/edit.php) |
|
| 529 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 530 | 530 | |
| 531 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 531 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 532 | 532 | |
| 533 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 533 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 534 | 534 | |
| 535 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 536 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 535 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 536 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 537 | 537 | |
| 538 | - // Create an instance of the PrimaShop adapter. |
|
| 539 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 538 | + // Create an instance of the PrimaShop adapter. |
|
| 539 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 540 | 540 | |
| 541 | - $this->page_service = new Wordlift_Page_Service(); |
|
| 541 | + $this->page_service = new Wordlift_Page_Service(); |
|
| 542 | 542 | |
| 543 | - // Create an import service instance to hook later to WP's import function. |
|
| 544 | - $this->import_service = new Wordlift_Import_Service( $this->entity_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() ); |
|
| 543 | + // Create an import service instance to hook later to WP's import function. |
|
| 544 | + $this->import_service = new Wordlift_Import_Service( $this->entity_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() ); |
|
| 545 | 545 | |
| 546 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 546 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 547 | 547 | |
| 548 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 549 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 548 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 549 | + $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 550 | 550 | |
| 551 | - //** WordPress Admin */ |
|
| 552 | - $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page(); |
|
| 551 | + //** WordPress Admin */ |
|
| 552 | + $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page(); |
|
| 553 | 553 | |
| 554 | - } |
|
| 554 | + } |
|
| 555 | 555 | |
| 556 | - /** |
|
| 557 | - * Define the locale for this plugin for internationalization. |
|
| 558 | - * |
|
| 559 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 560 | - * with WordPress. |
|
| 561 | - * |
|
| 562 | - * @since 1.0.0 |
|
| 563 | - * @access private |
|
| 564 | - */ |
|
| 565 | - private function set_locale() { |
|
| 556 | + /** |
|
| 557 | + * Define the locale for this plugin for internationalization. |
|
| 558 | + * |
|
| 559 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 560 | + * with WordPress. |
|
| 561 | + * |
|
| 562 | + * @since 1.0.0 |
|
| 563 | + * @access private |
|
| 564 | + */ |
|
| 565 | + private function set_locale() { |
|
| 566 | 566 | |
| 567 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 568 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 567 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 568 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 569 | 569 | |
| 570 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 570 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 571 | 571 | |
| 572 | - } |
|
| 572 | + } |
|
| 573 | 573 | |
| 574 | - /** |
|
| 575 | - * Register all of the hooks related to the admin area functionality |
|
| 576 | - * of the plugin. |
|
| 577 | - * |
|
| 578 | - * @since 1.0.0 |
|
| 579 | - * @access private |
|
| 580 | - */ |
|
| 581 | - private function define_admin_hooks() { |
|
| 574 | + /** |
|
| 575 | + * Register all of the hooks related to the admin area functionality |
|
| 576 | + * of the plugin. |
|
| 577 | + * |
|
| 578 | + * @since 1.0.0 |
|
| 579 | + * @access private |
|
| 580 | + */ |
|
| 581 | + private function define_admin_hooks() { |
|
| 582 | 582 | |
| 583 | - $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 583 | + $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 584 | 584 | |
| 585 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 586 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 585 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 586 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 587 | 587 | |
| 588 | - // Hook the init action to the Topic Taxonomy service. |
|
| 589 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 588 | + // Hook the init action to the Topic Taxonomy service. |
|
| 589 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 590 | 590 | |
| 591 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 592 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 591 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 592 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 593 | 593 | |
| 594 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 595 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 594 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 595 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 596 | 596 | |
| 597 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 598 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 597 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 598 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 599 | 599 | |
| 600 | - // Hook posts inserts (or updates) to the user service. |
|
| 601 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 600 | + // Hook posts inserts (or updates) to the user service. |
|
| 601 | + $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 602 | 602 | |
| 603 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 604 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 603 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 604 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 605 | 605 | |
| 606 | - // Register custom allowed redirect hosts. |
|
| 607 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 608 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 609 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 610 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 611 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 612 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 613 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 606 | + // Register custom allowed redirect hosts. |
|
| 607 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 608 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 609 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 610 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 611 | + $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 612 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 613 | + $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 614 | 614 | |
| 615 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 616 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 617 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 618 | - $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 615 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 616 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 617 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 618 | + $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 619 | 619 | |
| 620 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 621 | - $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 622 | - |
|
| 623 | - // Entity listing customization (wp-admin/edit.php) |
|
| 624 | - // Add custom columns |
|
| 625 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 626 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 627 | - // Add 4W selection |
|
| 628 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 629 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 630 | - |
|
| 631 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 632 | - |
|
| 633 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 634 | - // entities. |
|
| 635 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 636 | - |
|
| 637 | - // Filter imported post meta. |
|
| 638 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 639 | - |
|
| 640 | - // Notify the import service when an import starts and ends. |
|
| 641 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 642 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 643 | - |
|
| 644 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 645 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 646 | - |
|
| 647 | - // Hook the menu to the Download Your Data page. |
|
| 648 | - $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 649 | - |
|
| 650 | - // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 651 | - $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 652 | - |
|
| 653 | - } |
|
| 654 | - |
|
| 655 | - /** |
|
| 656 | - * Register all of the hooks related to the public-facing functionality |
|
| 657 | - * of the plugin. |
|
| 658 | - * |
|
| 659 | - * @since 1.0.0 |
|
| 660 | - * @access private |
|
| 661 | - */ |
|
| 662 | - private function define_public_hooks() { |
|
| 663 | - |
|
| 664 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 665 | - |
|
| 666 | - // Register the entity post type. |
|
| 667 | - $this->loader->add_action( 'init', $this->entity_type_service, 'register' ); |
|
| 668 | - |
|
| 669 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 670 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 671 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 672 | - $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 ); |
|
| 673 | - $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 ); |
|
| 674 | - |
|
| 675 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 676 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 677 | - |
|
| 678 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 679 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 680 | - |
|
| 681 | - // Hook the ShareThis service. |
|
| 682 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 683 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 684 | - |
|
| 685 | - $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 686 | - $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 687 | - |
|
| 688 | - } |
|
| 689 | - |
|
| 690 | - /** |
|
| 691 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 692 | - * |
|
| 693 | - * @since 1.0.0 |
|
| 694 | - */ |
|
| 695 | - public function run() { |
|
| 696 | - $this->loader->run(); |
|
| 697 | - } |
|
| 698 | - |
|
| 699 | - /** |
|
| 700 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 701 | - * WordPress and to define internationalization functionality. |
|
| 702 | - * |
|
| 703 | - * @since 1.0.0 |
|
| 704 | - * @return string The name of the plugin. |
|
| 705 | - */ |
|
| 706 | - public function get_plugin_name() { |
|
| 707 | - return $this->plugin_name; |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - /** |
|
| 711 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 712 | - * |
|
| 713 | - * @since 1.0.0 |
|
| 714 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 715 | - */ |
|
| 716 | - public function get_loader() { |
|
| 717 | - return $this->loader; |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - /** |
|
| 721 | - * Retrieve the version number of the plugin. |
|
| 722 | - * |
|
| 723 | - * @since 1.0.0 |
|
| 724 | - * @return string The version number of the plugin. |
|
| 725 | - */ |
|
| 726 | - public function get_version() { |
|
| 727 | - return $this->version; |
|
| 728 | - } |
|
| 620 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 621 | + $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 622 | + |
|
| 623 | + // Entity listing customization (wp-admin/edit.php) |
|
| 624 | + // Add custom columns |
|
| 625 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 626 | + $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 627 | + // Add 4W selection |
|
| 628 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 629 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 630 | + |
|
| 631 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 632 | + |
|
| 633 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 634 | + // entities. |
|
| 635 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 636 | + |
|
| 637 | + // Filter imported post meta. |
|
| 638 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 639 | + |
|
| 640 | + // Notify the import service when an import starts and ends. |
|
| 641 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 642 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 643 | + |
|
| 644 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 645 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 646 | + |
|
| 647 | + // Hook the menu to the Download Your Data page. |
|
| 648 | + $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 ); |
|
| 649 | + |
|
| 650 | + // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
|
| 651 | + $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 ); |
|
| 652 | + |
|
| 653 | + } |
|
| 654 | + |
|
| 655 | + /** |
|
| 656 | + * Register all of the hooks related to the public-facing functionality |
|
| 657 | + * of the plugin. |
|
| 658 | + * |
|
| 659 | + * @since 1.0.0 |
|
| 660 | + * @access private |
|
| 661 | + */ |
|
| 662 | + private function define_public_hooks() { |
|
| 663 | + |
|
| 664 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 665 | + |
|
| 666 | + // Register the entity post type. |
|
| 667 | + $this->loader->add_action( 'init', $this->entity_type_service, 'register' ); |
|
| 668 | + |
|
| 669 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 670 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 671 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 672 | + $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 ); |
|
| 673 | + $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 ); |
|
| 674 | + |
|
| 675 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 676 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 677 | + |
|
| 678 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 679 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 680 | + |
|
| 681 | + // Hook the ShareThis service. |
|
| 682 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 683 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 684 | + |
|
| 685 | + $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 686 | + $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 687 | + |
|
| 688 | + } |
|
| 689 | + |
|
| 690 | + /** |
|
| 691 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 692 | + * |
|
| 693 | + * @since 1.0.0 |
|
| 694 | + */ |
|
| 695 | + public function run() { |
|
| 696 | + $this->loader->run(); |
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + /** |
|
| 700 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 701 | + * WordPress and to define internationalization functionality. |
|
| 702 | + * |
|
| 703 | + * @since 1.0.0 |
|
| 704 | + * @return string The name of the plugin. |
|
| 705 | + */ |
|
| 706 | + public function get_plugin_name() { |
|
| 707 | + return $this->plugin_name; |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + /** |
|
| 711 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 712 | + * |
|
| 713 | + * @since 1.0.0 |
|
| 714 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 715 | + */ |
|
| 716 | + public function get_loader() { |
|
| 717 | + return $this->loader; |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + /** |
|
| 721 | + * Retrieve the version number of the plugin. |
|
| 722 | + * |
|
| 723 | + * @since 1.0.0 |
|
| 724 | + * @return string The version number of the plugin. |
|
| 725 | + */ |
|
| 726 | + public function get_version() { |
|
| 727 | + return $this->version; |
|
| 728 | + } |
|
| 729 | 729 | |
| 730 | 730 | } |