@@ -8,89 +8,89 @@ |
||
| 8 | 8 | |
| 9 | 9 | function wl_shortcode_navigator_ajax( $http_raw_data = NULL ) { |
| 10 | 10 | |
| 11 | - // Post ID must be defined |
|
| 12 | - if ( ! isset( $_GET['post_id'] ) ) { |
|
| 13 | - wp_die( 'No post_id given' ); |
|
| 14 | - |
|
| 15 | - return; |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - $current_post_id = $_GET['post_id']; |
|
| 19 | - $current_post = get_post( $current_post_id ); |
|
| 20 | - |
|
| 21 | - // Post ID has to match an existing item |
|
| 22 | - if ( NULL === $current_post ) { |
|
| 23 | - wp_die( 'No valid post_id given' ); |
|
| 24 | - |
|
| 25 | - return; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - // prepare structures to memorize other related posts |
|
| 29 | - $results = array(); |
|
| 30 | - $blacklist_ids = array( $current_post_id ); |
|
| 31 | - $related_entities = array(); |
|
| 32 | - |
|
| 33 | - // Get the related entities, ordering them by WHO, WHAT, WHERE, WHEN |
|
| 34 | - // TODO Replace with a single query if it is possible |
|
| 35 | - // We select in inverse order to give priority to less used entities |
|
| 36 | - foreach ( |
|
| 37 | - array( |
|
| 38 | - WL_WHEN_RELATION, |
|
| 39 | - WL_WHERE_RELATION, |
|
| 40 | - WL_WHAT_RELATION, |
|
| 41 | - WL_WHO_RELATION |
|
| 42 | - ) as $predicate |
|
| 43 | - ) { |
|
| 44 | - |
|
| 45 | - $related_entities = array_merge( $related_entities, wl_core_get_related_entities( $current_post_id, array( |
|
| 46 | - 'predicate' => $predicate, |
|
| 47 | - 'status' => 'publish' |
|
| 48 | - ) ) ); |
|
| 49 | - |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - foreach ( $related_entities as $related_entity ) { |
|
| 53 | - |
|
| 54 | - // take the id of posts referencing the entity |
|
| 55 | - $referencing_posts = wl_core_get_related_posts( $related_entity->ID, array( |
|
| 56 | - 'status' => 'publish' |
|
| 57 | - ) ); |
|
| 58 | - |
|
| 59 | - // loop over them and take the first one which is not already in the $related_posts |
|
| 60 | - foreach ( $referencing_posts as $referencing_post ) { |
|
| 61 | - |
|
| 62 | - if ( ! in_array( $referencing_post->ID, $blacklist_ids ) ) { |
|
| 63 | - |
|
| 64 | - $blacklist_ids[] = $referencing_post->ID; |
|
| 65 | - $serialized_entity = wl_serialize_entity( $related_entity ); |
|
| 66 | - $thumbnail = wp_get_attachment_url( get_post_thumbnail_id( $referencing_post->ID, 'thumbnail' ) ); |
|
| 67 | - |
|
| 68 | - if ( $thumbnail ) { |
|
| 69 | - |
|
| 70 | - $results[] = array( |
|
| 71 | - 'post' => array( |
|
| 72 | - 'permalink' => get_post_permalink( $referencing_post->ID ), |
|
| 73 | - 'title' => $referencing_post->post_title, |
|
| 74 | - 'thumbnail' => $thumbnail |
|
| 75 | - ), |
|
| 76 | - 'entity' => array( |
|
| 77 | - 'label' => $serialized_entity['label'], |
|
| 78 | - 'mainType' => $serialized_entity['mainType'], |
|
| 79 | - 'permalink' => get_post_permalink( $related_entity->ID ) |
|
| 80 | - ) |
|
| 81 | - ); |
|
| 82 | - |
|
| 83 | - // Be sure no more than 1 post for entity is returned |
|
| 84 | - break; |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - // Return first 4 results in json accordingly to 4 columns layout |
|
| 91 | - wl_core_send_json( |
|
| 92 | - array_slice( array_reverse( $results ), 0, 4 ) |
|
| 93 | - ); |
|
| 11 | + // Post ID must be defined |
|
| 12 | + if ( ! isset( $_GET['post_id'] ) ) { |
|
| 13 | + wp_die( 'No post_id given' ); |
|
| 14 | + |
|
| 15 | + return; |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + $current_post_id = $_GET['post_id']; |
|
| 19 | + $current_post = get_post( $current_post_id ); |
|
| 20 | + |
|
| 21 | + // Post ID has to match an existing item |
|
| 22 | + if ( NULL === $current_post ) { |
|
| 23 | + wp_die( 'No valid post_id given' ); |
|
| 24 | + |
|
| 25 | + return; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + // prepare structures to memorize other related posts |
|
| 29 | + $results = array(); |
|
| 30 | + $blacklist_ids = array( $current_post_id ); |
|
| 31 | + $related_entities = array(); |
|
| 32 | + |
|
| 33 | + // Get the related entities, ordering them by WHO, WHAT, WHERE, WHEN |
|
| 34 | + // TODO Replace with a single query if it is possible |
|
| 35 | + // We select in inverse order to give priority to less used entities |
|
| 36 | + foreach ( |
|
| 37 | + array( |
|
| 38 | + WL_WHEN_RELATION, |
|
| 39 | + WL_WHERE_RELATION, |
|
| 40 | + WL_WHAT_RELATION, |
|
| 41 | + WL_WHO_RELATION |
|
| 42 | + ) as $predicate |
|
| 43 | + ) { |
|
| 44 | + |
|
| 45 | + $related_entities = array_merge( $related_entities, wl_core_get_related_entities( $current_post_id, array( |
|
| 46 | + 'predicate' => $predicate, |
|
| 47 | + 'status' => 'publish' |
|
| 48 | + ) ) ); |
|
| 49 | + |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + foreach ( $related_entities as $related_entity ) { |
|
| 53 | + |
|
| 54 | + // take the id of posts referencing the entity |
|
| 55 | + $referencing_posts = wl_core_get_related_posts( $related_entity->ID, array( |
|
| 56 | + 'status' => 'publish' |
|
| 57 | + ) ); |
|
| 58 | + |
|
| 59 | + // loop over them and take the first one which is not already in the $related_posts |
|
| 60 | + foreach ( $referencing_posts as $referencing_post ) { |
|
| 61 | + |
|
| 62 | + if ( ! in_array( $referencing_post->ID, $blacklist_ids ) ) { |
|
| 63 | + |
|
| 64 | + $blacklist_ids[] = $referencing_post->ID; |
|
| 65 | + $serialized_entity = wl_serialize_entity( $related_entity ); |
|
| 66 | + $thumbnail = wp_get_attachment_url( get_post_thumbnail_id( $referencing_post->ID, 'thumbnail' ) ); |
|
| 67 | + |
|
| 68 | + if ( $thumbnail ) { |
|
| 69 | + |
|
| 70 | + $results[] = array( |
|
| 71 | + 'post' => array( |
|
| 72 | + 'permalink' => get_post_permalink( $referencing_post->ID ), |
|
| 73 | + 'title' => $referencing_post->post_title, |
|
| 74 | + 'thumbnail' => $thumbnail |
|
| 75 | + ), |
|
| 76 | + 'entity' => array( |
|
| 77 | + 'label' => $serialized_entity['label'], |
|
| 78 | + 'mainType' => $serialized_entity['mainType'], |
|
| 79 | + 'permalink' => get_post_permalink( $related_entity->ID ) |
|
| 80 | + ) |
|
| 81 | + ); |
|
| 82 | + |
|
| 83 | + // Be sure no more than 1 post for entity is returned |
|
| 84 | + break; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + // Return first 4 results in json accordingly to 4 columns layout |
|
| 91 | + wl_core_send_json( |
|
| 92 | + array_slice( array_reverse( $results ), 0, 4 ) |
|
| 93 | + ); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | ///** |
@@ -6,28 +6,28 @@ discard block |
||
| 6 | 6 | // add_shortcode( 'wl_navigator', 'wordlift_shortcode_navigator' ); |
| 7 | 7 | //} |
| 8 | 8 | |
| 9 | -function wl_shortcode_navigator_ajax( $http_raw_data = NULL ) { |
|
| 9 | +function wl_shortcode_navigator_ajax($http_raw_data = NULL) { |
|
| 10 | 10 | |
| 11 | 11 | // Post ID must be defined |
| 12 | - if ( ! isset( $_GET['post_id'] ) ) { |
|
| 13 | - wp_die( 'No post_id given' ); |
|
| 12 | + if ( ! isset($_GET['post_id'])) { |
|
| 13 | + wp_die('No post_id given'); |
|
| 14 | 14 | |
| 15 | 15 | return; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | $current_post_id = $_GET['post_id']; |
| 19 | - $current_post = get_post( $current_post_id ); |
|
| 19 | + $current_post = get_post($current_post_id); |
|
| 20 | 20 | |
| 21 | 21 | // Post ID has to match an existing item |
| 22 | - if ( NULL === $current_post ) { |
|
| 23 | - wp_die( 'No valid post_id given' ); |
|
| 22 | + if (NULL === $current_post) { |
|
| 23 | + wp_die('No valid post_id given'); |
|
| 24 | 24 | |
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | // prepare structures to memorize other related posts |
| 29 | 29 | $results = array(); |
| 30 | - $blacklist_ids = array( $current_post_id ); |
|
| 30 | + $blacklist_ids = array($current_post_id); |
|
| 31 | 31 | $related_entities = array(); |
| 32 | 32 | |
| 33 | 33 | // Get the related entities, ordering them by WHO, WHAT, WHERE, WHEN |
@@ -42,41 +42,41 @@ discard block |
||
| 42 | 42 | ) as $predicate |
| 43 | 43 | ) { |
| 44 | 44 | |
| 45 | - $related_entities = array_merge( $related_entities, wl_core_get_related_entities( $current_post_id, array( |
|
| 45 | + $related_entities = array_merge($related_entities, wl_core_get_related_entities($current_post_id, array( |
|
| 46 | 46 | 'predicate' => $predicate, |
| 47 | 47 | 'status' => 'publish' |
| 48 | - ) ) ); |
|
| 48 | + ))); |
|
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - foreach ( $related_entities as $related_entity ) { |
|
| 52 | + foreach ($related_entities as $related_entity) { |
|
| 53 | 53 | |
| 54 | 54 | // take the id of posts referencing the entity |
| 55 | - $referencing_posts = wl_core_get_related_posts( $related_entity->ID, array( |
|
| 55 | + $referencing_posts = wl_core_get_related_posts($related_entity->ID, array( |
|
| 56 | 56 | 'status' => 'publish' |
| 57 | - ) ); |
|
| 57 | + )); |
|
| 58 | 58 | |
| 59 | 59 | // loop over them and take the first one which is not already in the $related_posts |
| 60 | - foreach ( $referencing_posts as $referencing_post ) { |
|
| 60 | + foreach ($referencing_posts as $referencing_post) { |
|
| 61 | 61 | |
| 62 | - if ( ! in_array( $referencing_post->ID, $blacklist_ids ) ) { |
|
| 62 | + if ( ! in_array($referencing_post->ID, $blacklist_ids)) { |
|
| 63 | 63 | |
| 64 | 64 | $blacklist_ids[] = $referencing_post->ID; |
| 65 | - $serialized_entity = wl_serialize_entity( $related_entity ); |
|
| 66 | - $thumbnail = wp_get_attachment_url( get_post_thumbnail_id( $referencing_post->ID, 'thumbnail' ) ); |
|
| 65 | + $serialized_entity = wl_serialize_entity($related_entity); |
|
| 66 | + $thumbnail = wp_get_attachment_url(get_post_thumbnail_id($referencing_post->ID, 'thumbnail')); |
|
| 67 | 67 | |
| 68 | - if ( $thumbnail ) { |
|
| 68 | + if ($thumbnail) { |
|
| 69 | 69 | |
| 70 | 70 | $results[] = array( |
| 71 | 71 | 'post' => array( |
| 72 | - 'permalink' => get_post_permalink( $referencing_post->ID ), |
|
| 72 | + 'permalink' => get_post_permalink($referencing_post->ID), |
|
| 73 | 73 | 'title' => $referencing_post->post_title, |
| 74 | 74 | 'thumbnail' => $thumbnail |
| 75 | 75 | ), |
| 76 | 76 | 'entity' => array( |
| 77 | 77 | 'label' => $serialized_entity['label'], |
| 78 | 78 | 'mainType' => $serialized_entity['mainType'], |
| 79 | - 'permalink' => get_post_permalink( $related_entity->ID ) |
|
| 79 | + 'permalink' => get_post_permalink($related_entity->ID) |
|
| 80 | 80 | ) |
| 81 | 81 | ); |
| 82 | 82 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | // Return first 4 results in json accordingly to 4 columns layout |
| 91 | 91 | wl_core_send_json( |
| 92 | - array_slice( array_reverse( $results ), 0, 4 ) |
|
| 92 | + array_slice(array_reverse($results), 0, 4) |
|
| 93 | 93 | ); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -145,6 +145,6 @@ discard block |
||
| 145 | 145 | //} |
| 146 | 146 | |
| 147 | 147 | //add_action( 'init', 'wordlift_register_shortcode_navigator' ); |
| 148 | -add_action( 'wp_ajax_wl_navigator', 'wl_shortcode_navigator_ajax' ); |
|
| 149 | -add_action( 'wp_ajax_nopriv_wl_navigator', 'wl_shortcode_navigator_ajax' ); |
|
| 148 | +add_action('wp_ajax_wl_navigator', 'wl_shortcode_navigator_ajax'); |
|
| 149 | +add_action('wp_ajax_nopriv_wl_navigator', 'wl_shortcode_navigator_ajax'); |
|
| 150 | 150 | |
@@ -8,33 +8,33 @@ discard block |
||
| 8 | 8 | * @return mixed |
| 9 | 9 | */ |
| 10 | 10 | function wl_shortcode_chord_most_referenced_entity_id() { |
| 11 | - // Get the last 20 posts by post date. |
|
| 12 | - // For each post get the entities they reference. |
|
| 13 | - $post_ids = get_posts( array( |
|
| 14 | - 'numberposts' => 20, |
|
| 15 | - 'post_type' => 'post', |
|
| 16 | - 'fields' => 'ids', //only get post IDs |
|
| 17 | - 'post_status' => 'published', |
|
| 18 | - 'orderby' => 'post_date', |
|
| 19 | - 'order' => 'DESC', |
|
| 20 | - ) ); |
|
| 21 | - |
|
| 22 | - if ( empty( $post_ids ) ) { |
|
| 23 | - return NULL; |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - $entities = array(); |
|
| 27 | - foreach ( $post_ids as $id ) { |
|
| 28 | - $entities = array_merge( $entities, wl_core_get_related_entity_ids( $id ) ); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - $famous_entities = array_count_values( $entities ); |
|
| 32 | - arsort( $famous_entities ); |
|
| 33 | - if ( sizeof( $famous_entities ) >= 1 ) { |
|
| 34 | - return key( $famous_entities ); |
|
| 35 | - } else { |
|
| 36 | - return $post_ids[0]; |
|
| 37 | - } |
|
| 11 | + // Get the last 20 posts by post date. |
|
| 12 | + // For each post get the entities they reference. |
|
| 13 | + $post_ids = get_posts( array( |
|
| 14 | + 'numberposts' => 20, |
|
| 15 | + 'post_type' => 'post', |
|
| 16 | + 'fields' => 'ids', //only get post IDs |
|
| 17 | + 'post_status' => 'published', |
|
| 18 | + 'orderby' => 'post_date', |
|
| 19 | + 'order' => 'DESC', |
|
| 20 | + ) ); |
|
| 21 | + |
|
| 22 | + if ( empty( $post_ids ) ) { |
|
| 23 | + return NULL; |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + $entities = array(); |
|
| 27 | + foreach ( $post_ids as $id ) { |
|
| 28 | + $entities = array_merge( $entities, wl_core_get_related_entity_ids( $id ) ); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + $famous_entities = array_count_values( $entities ); |
|
| 32 | + arsort( $famous_entities ); |
|
| 33 | + if ( sizeof( $famous_entities ) >= 1 ) { |
|
| 34 | + return key( $famous_entities ); |
|
| 35 | + } else { |
|
| 36 | + return $post_ids[0]; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
@@ -52,60 +52,60 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | function wl_shortcode_chord_get_relations( $entity_id, $depth = 2, $related = NULL, $max_size = 9 ) { |
| 54 | 54 | |
| 55 | - if ( ! is_null( $related ) ) { |
|
| 56 | - if ( 0 === $depth ) { |
|
| 57 | - return $related; |
|
| 58 | - } |
|
| 59 | - } |
|
| 55 | + if ( ! is_null( $related ) ) { |
|
| 56 | + if ( 0 === $depth ) { |
|
| 57 | + return $related; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - wl_write_log( "wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: " . ( is_null( $related ) ? 'yes' : 'no' ) . " ]" ); |
|
| 61 | + wl_write_log( "wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: " . ( is_null( $related ) ? 'yes' : 'no' ) . " ]" ); |
|
| 62 | 62 | |
| 63 | - // Create a related array which will hold entities and relations. |
|
| 64 | - if ( is_null( $related ) ) { |
|
| 65 | - $related = array( |
|
| 66 | - 'entities' => array( $entity_id ), |
|
| 67 | - 'relations' => array() |
|
| 68 | - ); |
|
| 69 | - } |
|
| 63 | + // Create a related array which will hold entities and relations. |
|
| 64 | + if ( is_null( $related ) ) { |
|
| 65 | + $related = array( |
|
| 66 | + 'entities' => array( $entity_id ), |
|
| 67 | + 'relations' => array() |
|
| 68 | + ); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - // Get related entities |
|
| 72 | - $related_entity_ids = wl_core_get_related_entity_ids( $entity_id, array( |
|
| 73 | - 'status' => 'publish' |
|
| 74 | - ) ); |
|
| 71 | + // Get related entities |
|
| 72 | + $related_entity_ids = wl_core_get_related_entity_ids( $entity_id, array( |
|
| 73 | + 'status' => 'publish' |
|
| 74 | + ) ); |
|
| 75 | 75 | |
| 76 | - // If the current node is an entity, add related posts too |
|
| 77 | - $related_post_ids = ( Wordlift_Entity_Service::get_instance() |
|
| 78 | - ->is_entity( $entity_id ) ) ? |
|
| 79 | - wl_core_get_related_post_ids( $entity_id, array( |
|
| 80 | - 'status' => 'publish' |
|
| 81 | - ) ) : |
|
| 82 | - array(); |
|
| 76 | + // If the current node is an entity, add related posts too |
|
| 77 | + $related_post_ids = ( Wordlift_Entity_Service::get_instance() |
|
| 78 | + ->is_entity( $entity_id ) ) ? |
|
| 79 | + wl_core_get_related_post_ids( $entity_id, array( |
|
| 80 | + 'status' => 'publish' |
|
| 81 | + ) ) : |
|
| 82 | + array(); |
|
| 83 | 83 | |
| 84 | - // Merge results and remove duplicated entries |
|
| 85 | - $related_ids = array_unique( array_merge( $related_post_ids, $related_entity_ids ) ); |
|
| 84 | + // Merge results and remove duplicated entries |
|
| 85 | + $related_ids = array_unique( array_merge( $related_post_ids, $related_entity_ids ) ); |
|
| 86 | 86 | |
| 87 | - // TODO: List of entities ($rel) should be ordered by interest factors. |
|
| 88 | - shuffle( $related_ids ); |
|
| 87 | + // TODO: List of entities ($rel) should be ordered by interest factors. |
|
| 88 | + shuffle( $related_ids ); |
|
| 89 | 89 | |
| 90 | - // Now we have all the related IDs. |
|
| 91 | - foreach ( $related_ids as $related_id ) { |
|
| 90 | + // Now we have all the related IDs. |
|
| 91 | + foreach ( $related_ids as $related_id ) { |
|
| 92 | 92 | |
| 93 | - if ( count( $related['entities'] ) >= $max_size ) { |
|
| 94 | - return $related; |
|
| 95 | - } |
|
| 93 | + if ( count( $related['entities'] ) >= $max_size ) { |
|
| 94 | + return $related; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - $related['relations'][] = array( $entity_id, $related_id ); |
|
| 97 | + $related['relations'][] = array( $entity_id, $related_id ); |
|
| 98 | 98 | |
| 99 | - if ( ! in_array( $related_id, $related['entities'] ) ) { |
|
| 100 | - // Found new related entity! |
|
| 101 | - $related['entities'][] = $related_id; |
|
| 99 | + if ( ! in_array( $related_id, $related['entities'] ) ) { |
|
| 100 | + // Found new related entity! |
|
| 101 | + $related['entities'][] = $related_id; |
|
| 102 | 102 | |
| 103 | - $related = wl_shortcode_chord_get_relations( $related_id, ( $depth - 1 ), $related, $max_size ); |
|
| 104 | - } |
|
| 105 | - } |
|
| 103 | + $related = wl_shortcode_chord_get_relations( $related_id, ( $depth - 1 ), $related, $max_size ); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - // End condition 2: no more entities to search for. |
|
| 108 | - return $related; |
|
| 107 | + // End condition 2: no more entities to search for. |
|
| 108 | + return $related; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -119,56 +119,56 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function wl_shortcode_chord_get_graph( $data ) { |
| 121 | 121 | |
| 122 | - // Refactor the entities array in order to provide entities relevant data (uri, url, label, type, css_class). |
|
| 123 | - array_walk( $data['entities'], function ( &$item ) { |
|
| 124 | - $post = get_post( $item ); |
|
| 125 | - |
|
| 126 | - // Skip non-existing posts. |
|
| 127 | - if ( is_null( $post ) ) { |
|
| 128 | - wl_write_log( "wl_shortcode_chord_get_graph : post not found [ post id :: $item ]" ); |
|
| 129 | - |
|
| 130 | - return $item; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // Get the entity taxonomy bound to this post (if there's no taxonomy, no stylesheet will be set). |
|
| 134 | - $term = wl_entity_type_taxonomy_get_type( $item ); |
|
| 135 | - |
|
| 136 | - wl_write_log( "wl_shortcode_chord_get_graph [ post id :: $post->ID ][ term :: " . var_export( $term, TRUE ) . " ]" ); |
|
| 137 | - |
|
| 138 | - // TODO: get all images |
|
| 139 | - $thumbnail = NULL; |
|
| 140 | - $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
| 141 | - if ( '' !== $thumbnail_id ) { |
|
| 142 | - $attachment = wp_get_attachment_image_src( $thumbnail_id ); |
|
| 143 | - if ( FALSE !== $attachment ) { |
|
| 144 | - $thumbnail = esc_attr( $attachment[0] ); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - $entity = array( |
|
| 149 | - 'uri' => wl_get_entity_uri( $item ), |
|
| 150 | - 'url' => get_permalink( $item ), |
|
| 151 | - 'label' => $post->post_title, |
|
| 152 | - 'type' => $post->post_type, |
|
| 153 | - 'thumbnails' => array( $thumbnail ), |
|
| 154 | - 'css_class' => ( isset( $term['css_class'] ) ? $term['css_class'] : '' ) |
|
| 155 | - ); |
|
| 156 | - |
|
| 157 | - $item = $entity; |
|
| 158 | - } ); |
|
| 159 | - |
|
| 160 | - // Refactor the relations. |
|
| 161 | - array_walk( $data['relations'], function ( &$item ) { |
|
| 162 | - $relation = array( |
|
| 163 | - 's' => wl_get_entity_uri( $item[0] ), |
|
| 164 | - 'o' => wl_get_entity_uri( $item[1] ) |
|
| 165 | - ); |
|
| 166 | - |
|
| 167 | - $item = $relation; |
|
| 168 | - } ); |
|
| 169 | - |
|
| 170 | - // Return the JSON representation. |
|
| 171 | - return $data; |
|
| 122 | + // Refactor the entities array in order to provide entities relevant data (uri, url, label, type, css_class). |
|
| 123 | + array_walk( $data['entities'], function ( &$item ) { |
|
| 124 | + $post = get_post( $item ); |
|
| 125 | + |
|
| 126 | + // Skip non-existing posts. |
|
| 127 | + if ( is_null( $post ) ) { |
|
| 128 | + wl_write_log( "wl_shortcode_chord_get_graph : post not found [ post id :: $item ]" ); |
|
| 129 | + |
|
| 130 | + return $item; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // Get the entity taxonomy bound to this post (if there's no taxonomy, no stylesheet will be set). |
|
| 134 | + $term = wl_entity_type_taxonomy_get_type( $item ); |
|
| 135 | + |
|
| 136 | + wl_write_log( "wl_shortcode_chord_get_graph [ post id :: $post->ID ][ term :: " . var_export( $term, TRUE ) . " ]" ); |
|
| 137 | + |
|
| 138 | + // TODO: get all images |
|
| 139 | + $thumbnail = NULL; |
|
| 140 | + $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
| 141 | + if ( '' !== $thumbnail_id ) { |
|
| 142 | + $attachment = wp_get_attachment_image_src( $thumbnail_id ); |
|
| 143 | + if ( FALSE !== $attachment ) { |
|
| 144 | + $thumbnail = esc_attr( $attachment[0] ); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + $entity = array( |
|
| 149 | + 'uri' => wl_get_entity_uri( $item ), |
|
| 150 | + 'url' => get_permalink( $item ), |
|
| 151 | + 'label' => $post->post_title, |
|
| 152 | + 'type' => $post->post_type, |
|
| 153 | + 'thumbnails' => array( $thumbnail ), |
|
| 154 | + 'css_class' => ( isset( $term['css_class'] ) ? $term['css_class'] : '' ) |
|
| 155 | + ); |
|
| 156 | + |
|
| 157 | + $item = $entity; |
|
| 158 | + } ); |
|
| 159 | + |
|
| 160 | + // Refactor the relations. |
|
| 161 | + array_walk( $data['relations'], function ( &$item ) { |
|
| 162 | + $relation = array( |
|
| 163 | + 's' => wl_get_entity_uri( $item[0] ), |
|
| 164 | + 'o' => wl_get_entity_uri( $item[1] ) |
|
| 165 | + ); |
|
| 166 | + |
|
| 167 | + $item = $relation; |
|
| 168 | + } ); |
|
| 169 | + |
|
| 170 | + // Return the JSON representation. |
|
| 171 | + return $data; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | function wl_shortcode_chord_ajax() { |
| 181 | 181 | |
| 182 | - $post_id = $_REQUEST['post_id']; |
|
| 183 | - $depth = $_REQUEST['depth']; |
|
| 182 | + $post_id = $_REQUEST['post_id']; |
|
| 183 | + $depth = $_REQUEST['depth']; |
|
| 184 | 184 | |
| 185 | - $relations = wl_shortcode_chord_get_relations( $post_id, $depth ); |
|
| 186 | - $graph = wl_shortcode_chord_get_graph( $relations ); |
|
| 185 | + $relations = wl_shortcode_chord_get_relations( $post_id, $depth ); |
|
| 186 | + $graph = wl_shortcode_chord_get_graph( $relations ); |
|
| 187 | 187 | |
| 188 | - wl_core_send_json( $graph ); |
|
| 188 | + wl_core_send_json( $graph ); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | add_action( 'wp_ajax_wl_chord', 'wl_shortcode_chord_ajax' ); |
@@ -10,28 +10,28 @@ discard block |
||
| 10 | 10 | function wl_shortcode_chord_most_referenced_entity_id() { |
| 11 | 11 | // Get the last 20 posts by post date. |
| 12 | 12 | // For each post get the entities they reference. |
| 13 | - $post_ids = get_posts( array( |
|
| 13 | + $post_ids = get_posts(array( |
|
| 14 | 14 | 'numberposts' => 20, |
| 15 | 15 | 'post_type' => 'post', |
| 16 | 16 | 'fields' => 'ids', //only get post IDs |
| 17 | 17 | 'post_status' => 'published', |
| 18 | 18 | 'orderby' => 'post_date', |
| 19 | 19 | 'order' => 'DESC', |
| 20 | - ) ); |
|
| 20 | + )); |
|
| 21 | 21 | |
| 22 | - if ( empty( $post_ids ) ) { |
|
| 22 | + if (empty($post_ids)) { |
|
| 23 | 23 | return NULL; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $entities = array(); |
| 27 | - foreach ( $post_ids as $id ) { |
|
| 28 | - $entities = array_merge( $entities, wl_core_get_related_entity_ids( $id ) ); |
|
| 27 | + foreach ($post_ids as $id) { |
|
| 28 | + $entities = array_merge($entities, wl_core_get_related_entity_ids($id)); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $famous_entities = array_count_values( $entities ); |
|
| 32 | - arsort( $famous_entities ); |
|
| 33 | - if ( sizeof( $famous_entities ) >= 1 ) { |
|
| 34 | - return key( $famous_entities ); |
|
| 31 | + $famous_entities = array_count_values($entities); |
|
| 32 | + arsort($famous_entities); |
|
| 33 | + if (sizeof($famous_entities) >= 1) { |
|
| 34 | + return key($famous_entities); |
|
| 35 | 35 | } else { |
| 36 | 36 | return $post_ids[0]; |
| 37 | 37 | } |
@@ -50,57 +50,56 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return array |
| 52 | 52 | */ |
| 53 | -function wl_shortcode_chord_get_relations( $entity_id, $depth = 2, $related = NULL, $max_size = 9 ) { |
|
| 53 | +function wl_shortcode_chord_get_relations($entity_id, $depth = 2, $related = NULL, $max_size = 9) { |
|
| 54 | 54 | |
| 55 | - if ( ! is_null( $related ) ) { |
|
| 56 | - if ( 0 === $depth ) { |
|
| 55 | + if ( ! is_null($related)) { |
|
| 56 | + if (0 === $depth) { |
|
| 57 | 57 | return $related; |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - wl_write_log( "wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: " . ( is_null( $related ) ? 'yes' : 'no' ) . " ]" ); |
|
| 61 | + wl_write_log("wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: ".(is_null($related) ? 'yes' : 'no')." ]"); |
|
| 62 | 62 | |
| 63 | 63 | // Create a related array which will hold entities and relations. |
| 64 | - if ( is_null( $related ) ) { |
|
| 64 | + if (is_null($related)) { |
|
| 65 | 65 | $related = array( |
| 66 | - 'entities' => array( $entity_id ), |
|
| 66 | + 'entities' => array($entity_id), |
|
| 67 | 67 | 'relations' => array() |
| 68 | 68 | ); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Get related entities |
| 72 | - $related_entity_ids = wl_core_get_related_entity_ids( $entity_id, array( |
|
| 72 | + $related_entity_ids = wl_core_get_related_entity_ids($entity_id, array( |
|
| 73 | 73 | 'status' => 'publish' |
| 74 | - ) ); |
|
| 74 | + )); |
|
| 75 | 75 | |
| 76 | 76 | // If the current node is an entity, add related posts too |
| 77 | - $related_post_ids = ( Wordlift_Entity_Service::get_instance() |
|
| 78 | - ->is_entity( $entity_id ) ) ? |
|
| 79 | - wl_core_get_related_post_ids( $entity_id, array( |
|
| 77 | + $related_post_ids = (Wordlift_Entity_Service::get_instance() |
|
| 78 | + ->is_entity($entity_id)) ? |
|
| 79 | + wl_core_get_related_post_ids($entity_id, array( |
|
| 80 | 80 | 'status' => 'publish' |
| 81 | - ) ) : |
|
| 82 | - array(); |
|
| 81 | + )) : array(); |
|
| 83 | 82 | |
| 84 | 83 | // Merge results and remove duplicated entries |
| 85 | - $related_ids = array_unique( array_merge( $related_post_ids, $related_entity_ids ) ); |
|
| 84 | + $related_ids = array_unique(array_merge($related_post_ids, $related_entity_ids)); |
|
| 86 | 85 | |
| 87 | 86 | // TODO: List of entities ($rel) should be ordered by interest factors. |
| 88 | - shuffle( $related_ids ); |
|
| 87 | + shuffle($related_ids); |
|
| 89 | 88 | |
| 90 | 89 | // Now we have all the related IDs. |
| 91 | - foreach ( $related_ids as $related_id ) { |
|
| 90 | + foreach ($related_ids as $related_id) { |
|
| 92 | 91 | |
| 93 | - if ( count( $related['entities'] ) >= $max_size ) { |
|
| 92 | + if (count($related['entities']) >= $max_size) { |
|
| 94 | 93 | return $related; |
| 95 | 94 | } |
| 96 | 95 | |
| 97 | - $related['relations'][] = array( $entity_id, $related_id ); |
|
| 96 | + $related['relations'][] = array($entity_id, $related_id); |
|
| 98 | 97 | |
| 99 | - if ( ! in_array( $related_id, $related['entities'] ) ) { |
|
| 98 | + if ( ! in_array($related_id, $related['entities'])) { |
|
| 100 | 99 | // Found new related entity! |
| 101 | 100 | $related['entities'][] = $related_id; |
| 102 | 101 | |
| 103 | - $related = wl_shortcode_chord_get_relations( $related_id, ( $depth - 1 ), $related, $max_size ); |
|
| 102 | + $related = wl_shortcode_chord_get_relations($related_id, ($depth - 1), $related, $max_size); |
|
| 104 | 103 | } |
| 105 | 104 | } |
| 106 | 105 | |
@@ -117,51 +116,51 @@ discard block |
||
| 117 | 116 | * |
| 118 | 117 | * @return mixed|string|void |
| 119 | 118 | */ |
| 120 | -function wl_shortcode_chord_get_graph( $data ) { |
|
| 119 | +function wl_shortcode_chord_get_graph($data) { |
|
| 121 | 120 | |
| 122 | 121 | // Refactor the entities array in order to provide entities relevant data (uri, url, label, type, css_class). |
| 123 | - array_walk( $data['entities'], function ( &$item ) { |
|
| 124 | - $post = get_post( $item ); |
|
| 122 | + array_walk($data['entities'], function(&$item) { |
|
| 123 | + $post = get_post($item); |
|
| 125 | 124 | |
| 126 | 125 | // Skip non-existing posts. |
| 127 | - if ( is_null( $post ) ) { |
|
| 128 | - wl_write_log( "wl_shortcode_chord_get_graph : post not found [ post id :: $item ]" ); |
|
| 126 | + if (is_null($post)) { |
|
| 127 | + wl_write_log("wl_shortcode_chord_get_graph : post not found [ post id :: $item ]"); |
|
| 129 | 128 | |
| 130 | 129 | return $item; |
| 131 | 130 | } |
| 132 | 131 | |
| 133 | 132 | // Get the entity taxonomy bound to this post (if there's no taxonomy, no stylesheet will be set). |
| 134 | - $term = wl_entity_type_taxonomy_get_type( $item ); |
|
| 133 | + $term = wl_entity_type_taxonomy_get_type($item); |
|
| 135 | 134 | |
| 136 | - wl_write_log( "wl_shortcode_chord_get_graph [ post id :: $post->ID ][ term :: " . var_export( $term, TRUE ) . " ]" ); |
|
| 135 | + wl_write_log("wl_shortcode_chord_get_graph [ post id :: $post->ID ][ term :: ".var_export($term, TRUE)." ]"); |
|
| 137 | 136 | |
| 138 | 137 | // TODO: get all images |
| 139 | 138 | $thumbnail = NULL; |
| 140 | - $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
| 141 | - if ( '' !== $thumbnail_id ) { |
|
| 142 | - $attachment = wp_get_attachment_image_src( $thumbnail_id ); |
|
| 143 | - if ( FALSE !== $attachment ) { |
|
| 144 | - $thumbnail = esc_attr( $attachment[0] ); |
|
| 139 | + $thumbnail_id = get_post_thumbnail_id($post->ID); |
|
| 140 | + if ('' !== $thumbnail_id) { |
|
| 141 | + $attachment = wp_get_attachment_image_src($thumbnail_id); |
|
| 142 | + if (FALSE !== $attachment) { |
|
| 143 | + $thumbnail = esc_attr($attachment[0]); |
|
| 145 | 144 | } |
| 146 | 145 | } |
| 147 | 146 | |
| 148 | 147 | $entity = array( |
| 149 | - 'uri' => wl_get_entity_uri( $item ), |
|
| 150 | - 'url' => get_permalink( $item ), |
|
| 148 | + 'uri' => wl_get_entity_uri($item), |
|
| 149 | + 'url' => get_permalink($item), |
|
| 151 | 150 | 'label' => $post->post_title, |
| 152 | 151 | 'type' => $post->post_type, |
| 153 | - 'thumbnails' => array( $thumbnail ), |
|
| 154 | - 'css_class' => ( isset( $term['css_class'] ) ? $term['css_class'] : '' ) |
|
| 152 | + 'thumbnails' => array($thumbnail), |
|
| 153 | + 'css_class' => (isset($term['css_class']) ? $term['css_class'] : '') |
|
| 155 | 154 | ); |
| 156 | 155 | |
| 157 | 156 | $item = $entity; |
| 158 | 157 | } ); |
| 159 | 158 | |
| 160 | 159 | // Refactor the relations. |
| 161 | - array_walk( $data['relations'], function ( &$item ) { |
|
| 160 | + array_walk($data['relations'], function(&$item) { |
|
| 162 | 161 | $relation = array( |
| 163 | - 's' => wl_get_entity_uri( $item[0] ), |
|
| 164 | - 'o' => wl_get_entity_uri( $item[1] ) |
|
| 162 | + 's' => wl_get_entity_uri($item[0]), |
|
| 163 | + 'o' => wl_get_entity_uri($item[1]) |
|
| 165 | 164 | ); |
| 166 | 165 | |
| 167 | 166 | $item = $relation; |
@@ -182,14 +181,14 @@ discard block |
||
| 182 | 181 | $post_id = $_REQUEST['post_id']; |
| 183 | 182 | $depth = $_REQUEST['depth']; |
| 184 | 183 | |
| 185 | - $relations = wl_shortcode_chord_get_relations( $post_id, $depth ); |
|
| 186 | - $graph = wl_shortcode_chord_get_graph( $relations ); |
|
| 184 | + $relations = wl_shortcode_chord_get_relations($post_id, $depth); |
|
| 185 | + $graph = wl_shortcode_chord_get_graph($relations); |
|
| 187 | 186 | |
| 188 | - wl_core_send_json( $graph ); |
|
| 187 | + wl_core_send_json($graph); |
|
| 189 | 188 | } |
| 190 | 189 | |
| 191 | -add_action( 'wp_ajax_wl_chord', 'wl_shortcode_chord_ajax' ); |
|
| 192 | -add_action( 'wp_ajax_nopriv_wl_chord', 'wl_shortcode_chord_ajax' ); |
|
| 190 | +add_action('wp_ajax_wl_chord', 'wl_shortcode_chord_ajax'); |
|
| 191 | +add_action('wp_ajax_nopriv_wl_chord', 'wl_shortcode_chord_ajax'); |
|
| 193 | 192 | |
| 194 | 193 | // |
| 195 | 194 | ///** |
@@ -14,56 +14,56 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function wl_shortcode_geomap_get_places( $post_id = null ) { |
| 16 | 16 | |
| 17 | - // If $post_id is null or is not numeric it means this is a global geomap |
|
| 18 | - $is_global = is_null( $post_id ) || ! is_numeric( $post_id ); |
|
| 17 | + // If $post_id is null or is not numeric it means this is a global geomap |
|
| 18 | + $is_global = is_null( $post_id ) || ! is_numeric( $post_id ); |
|
| 19 | 19 | |
| 20 | - // If the current one is not a global geomap, retrieve related entities ids |
|
| 21 | - if ( $is_global ) { |
|
| 22 | - $related_ids = array(); |
|
| 23 | - } else { |
|
| 24 | - $related_ids = wl_core_get_related_entity_ids( $post_id, array( |
|
| 25 | - 'status' => 'publish' |
|
| 26 | - ) ); |
|
| 20 | + // If the current one is not a global geomap, retrieve related entities ids |
|
| 21 | + if ( $is_global ) { |
|
| 22 | + $related_ids = array(); |
|
| 23 | + } else { |
|
| 24 | + $related_ids = wl_core_get_related_entity_ids( $post_id, array( |
|
| 25 | + 'status' => 'publish' |
|
| 26 | + ) ); |
|
| 27 | 27 | |
| 28 | - // Also include current entity |
|
| 29 | - if ( Wordlift_Entity_Service::get_instance()->is_entity( $post_id ) ) { |
|
| 30 | - $related_ids[] = $post_id; |
|
| 31 | - } |
|
| 32 | - } |
|
| 28 | + // Also include current entity |
|
| 29 | + if ( Wordlift_Entity_Service::get_instance()->is_entity( $post_id ) ) { |
|
| 30 | + $related_ids[] = $post_id; |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - // If is not a global geomap, an empty $related_ids means that no entities are related to the post |
|
| 35 | - // An empty array can be returned in this case |
|
| 36 | - if ( ! $is_global && empty( $related_ids ) ) { |
|
| 37 | - return array(); |
|
| 38 | - } |
|
| 34 | + // If is not a global geomap, an empty $related_ids means that no entities are related to the post |
|
| 35 | + // An empty array can be returned in this case |
|
| 36 | + if ( ! $is_global && empty( $related_ids ) ) { |
|
| 37 | + return array(); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - // Retrieve all 'published' places with geo coordinates defined |
|
| 41 | - // If $related_ids is not empty, it's used to limit query results to the current post related places |
|
| 42 | - // Please note that when $place_ids is an empty array, the 'post__in' parameter is not considered in the query |
|
| 43 | - return get_posts( array( |
|
| 44 | - 'post__in' => $related_ids, |
|
| 45 | - 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 46 | - 'nopaging' => true, |
|
| 47 | - 'post_status' => 'publish', |
|
| 48 | - 'meta_query' => array( |
|
| 49 | - 'relation' => 'AND', |
|
| 50 | - array( |
|
| 51 | - 'key' => Wordlift_Schema_Service::FIELD_GEO_LATITUDE, |
|
| 52 | - 'value' => null, |
|
| 53 | - 'compare' => '!=', |
|
| 54 | - ), |
|
| 55 | - array( |
|
| 56 | - 'key' => Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, |
|
| 57 | - 'value' => null, |
|
| 58 | - 'compare' => '!=', |
|
| 59 | - ) |
|
| 60 | - ), |
|
| 61 | - 'tax_query' => array( |
|
| 62 | - 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 63 | - 'field' => 'slug', |
|
| 64 | - 'terms' => 'place' |
|
| 65 | - ) |
|
| 66 | - ) ); |
|
| 40 | + // Retrieve all 'published' places with geo coordinates defined |
|
| 41 | + // If $related_ids is not empty, it's used to limit query results to the current post related places |
|
| 42 | + // Please note that when $place_ids is an empty array, the 'post__in' parameter is not considered in the query |
|
| 43 | + return get_posts( array( |
|
| 44 | + 'post__in' => $related_ids, |
|
| 45 | + 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 46 | + 'nopaging' => true, |
|
| 47 | + 'post_status' => 'publish', |
|
| 48 | + 'meta_query' => array( |
|
| 49 | + 'relation' => 'AND', |
|
| 50 | + array( |
|
| 51 | + 'key' => Wordlift_Schema_Service::FIELD_GEO_LATITUDE, |
|
| 52 | + 'value' => null, |
|
| 53 | + 'compare' => '!=', |
|
| 54 | + ), |
|
| 55 | + array( |
|
| 56 | + 'key' => Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, |
|
| 57 | + 'value' => null, |
|
| 58 | + 'compare' => '!=', |
|
| 59 | + ) |
|
| 60 | + ), |
|
| 61 | + 'tax_query' => array( |
|
| 62 | + 'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, |
|
| 63 | + 'field' => 'slug', |
|
| 64 | + 'terms' => 'place' |
|
| 65 | + ) |
|
| 66 | + ) ); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -78,88 +78,88 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | function wl_shortcode_geomap_prepare_map( $places ) { |
| 80 | 80 | |
| 81 | - // Prepare for min/max lat/long in case we need to define a view boundary for the client JavaScript. |
|
| 82 | - $min_latitude = PHP_INT_MAX; |
|
| 83 | - $min_longitude = PHP_INT_MAX; |
|
| 84 | - $max_latitude = ~PHP_INT_MAX; |
|
| 85 | - $max_longitude = ~PHP_INT_MAX; |
|
| 81 | + // Prepare for min/max lat/long in case we need to define a view boundary for the client JavaScript. |
|
| 82 | + $min_latitude = PHP_INT_MAX; |
|
| 83 | + $min_longitude = PHP_INT_MAX; |
|
| 84 | + $max_latitude = ~PHP_INT_MAX; |
|
| 85 | + $max_longitude = ~PHP_INT_MAX; |
|
| 86 | 86 | |
| 87 | - // Prepare an empty array of POIs in geoJSON format. |
|
| 88 | - $pois = array(); |
|
| 89 | - // And store list of points to allow Leaflet compute the optimal bounding box. |
|
| 90 | - // The main reason for this is that geoJSON has swapped coordinates (lon. lat) |
|
| 91 | - $boundaries = array(); |
|
| 87 | + // Prepare an empty array of POIs in geoJSON format. |
|
| 88 | + $pois = array(); |
|
| 89 | + // And store list of points to allow Leaflet compute the optimal bounding box. |
|
| 90 | + // The main reason for this is that geoJSON has swapped coordinates (lon. lat) |
|
| 91 | + $boundaries = array(); |
|
| 92 | 92 | |
| 93 | - // Add a POI for each entity that has coordinates. |
|
| 94 | - foreach ( $places as $entity ) { |
|
| 93 | + // Add a POI for each entity that has coordinates. |
|
| 94 | + foreach ( $places as $entity ) { |
|
| 95 | 95 | |
| 96 | - // Get the coordinates. |
|
| 97 | - $coordinates = wl_get_coordinates( $entity->ID ); |
|
| 96 | + // Get the coordinates. |
|
| 97 | + $coordinates = wl_get_coordinates( $entity->ID ); |
|
| 98 | 98 | |
| 99 | - // Don't show the widget if the coordinates aren't set. |
|
| 100 | - if ( $coordinates['latitude'] == 0 || $coordinates['longitude'] == 0 ) { |
|
| 101 | - continue; |
|
| 102 | - } |
|
| 99 | + // Don't show the widget if the coordinates aren't set. |
|
| 100 | + if ( $coordinates['latitude'] == 0 || $coordinates['longitude'] == 0 ) { |
|
| 101 | + continue; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - // TODO Map html rendering should be delegated to the wordlift js ui layer |
|
| 105 | - // This function should be focused on returning pure data instead |
|
| 104 | + // TODO Map html rendering should be delegated to the wordlift js ui layer |
|
| 105 | + // This function should be focused on returning pure data instead |
|
| 106 | 106 | |
| 107 | - // Get the title, URL and thumb of the entity. |
|
| 108 | - $title = esc_attr( $entity->post_title ); |
|
| 109 | - $link = esc_attr( get_permalink( $entity->ID ) ); |
|
| 110 | - if ( '' !== ( $thumbnail_id = get_post_thumbnail_id( $entity->ID ) ) && |
|
| 111 | - false !== ( $attachment = wp_get_attachment_image_src( $thumbnail_id ) ) |
|
| 112 | - ) { |
|
| 113 | - $img_src = esc_attr( $attachment[0] ); |
|
| 114 | - } |
|
| 107 | + // Get the title, URL and thumb of the entity. |
|
| 108 | + $title = esc_attr( $entity->post_title ); |
|
| 109 | + $link = esc_attr( get_permalink( $entity->ID ) ); |
|
| 110 | + if ( '' !== ( $thumbnail_id = get_post_thumbnail_id( $entity->ID ) ) && |
|
| 111 | + false !== ( $attachment = wp_get_attachment_image_src( $thumbnail_id ) ) |
|
| 112 | + ) { |
|
| 113 | + $img_src = esc_attr( $attachment[0] ); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - // Build HTML popup. TODO: move thumb width in css |
|
| 117 | - $content = "<a href=$link><h6>$title</h6>"; |
|
| 118 | - if ( isset( $img_src ) ) { |
|
| 119 | - $content = $content . "<img src=$img_src style='width:100%'/>"; |
|
| 120 | - } |
|
| 121 | - $content = $content . "</a><ul>"; |
|
| 122 | - // Get the related posts (published) and print them in the popup. |
|
| 123 | - $related_posts = wl_core_get_related_post_ids( $entity->ID, array( |
|
| 124 | - 'status' => 'publish' |
|
| 125 | - ) ); |
|
| 126 | - foreach ( $related_posts as $rp_id ) { |
|
| 116 | + // Build HTML popup. TODO: move thumb width in css |
|
| 117 | + $content = "<a href=$link><h6>$title</h6>"; |
|
| 118 | + if ( isset( $img_src ) ) { |
|
| 119 | + $content = $content . "<img src=$img_src style='width:100%'/>"; |
|
| 120 | + } |
|
| 121 | + $content = $content . "</a><ul>"; |
|
| 122 | + // Get the related posts (published) and print them in the popup. |
|
| 123 | + $related_posts = wl_core_get_related_post_ids( $entity->ID, array( |
|
| 124 | + 'status' => 'publish' |
|
| 125 | + ) ); |
|
| 126 | + foreach ( $related_posts as $rp_id ) { |
|
| 127 | 127 | |
| 128 | - $rp = get_post( $rp_id ); |
|
| 129 | - $title = esc_attr( $rp->post_title ); |
|
| 130 | - $link = esc_attr( get_permalink( $rp->ID ) ); |
|
| 131 | - $content = $content . "<li><a href=$link>$title</a></li>"; |
|
| 132 | - } |
|
| 133 | - $content = $content . "</ul>"; |
|
| 128 | + $rp = get_post( $rp_id ); |
|
| 129 | + $title = esc_attr( $rp->post_title ); |
|
| 130 | + $link = esc_attr( get_permalink( $rp->ID ) ); |
|
| 131 | + $content = $content . "<li><a href=$link>$title</a></li>"; |
|
| 132 | + } |
|
| 133 | + $content = $content . "</ul>"; |
|
| 134 | 134 | |
| 135 | - // Formatting POI in geoJSON. |
|
| 136 | - // http://leafletjs.com/examples/geojson.html |
|
| 137 | - $poi = array( |
|
| 138 | - 'type' => 'Feature', |
|
| 139 | - 'properties' => array( 'popupContent' => $content ), |
|
| 140 | - 'geometry' => array( |
|
| 141 | - 'type' => 'Point', |
|
| 142 | - 'coordinates' => array( |
|
| 143 | - // Leaflet geoJSON wants them swapped |
|
| 144 | - $coordinates['longitude'], |
|
| 145 | - $coordinates['latitude'] |
|
| 146 | - ) |
|
| 147 | - ) |
|
| 148 | - ); |
|
| 135 | + // Formatting POI in geoJSON. |
|
| 136 | + // http://leafletjs.com/examples/geojson.html |
|
| 137 | + $poi = array( |
|
| 138 | + 'type' => 'Feature', |
|
| 139 | + 'properties' => array( 'popupContent' => $content ), |
|
| 140 | + 'geometry' => array( |
|
| 141 | + 'type' => 'Point', |
|
| 142 | + 'coordinates' => array( |
|
| 143 | + // Leaflet geoJSON wants them swapped |
|
| 144 | + $coordinates['longitude'], |
|
| 145 | + $coordinates['latitude'] |
|
| 146 | + ) |
|
| 147 | + ) |
|
| 148 | + ); |
|
| 149 | 149 | |
| 150 | - $pois[] = $poi; |
|
| 150 | + $pois[] = $poi; |
|
| 151 | 151 | |
| 152 | - // Formatting boundaries in a Leaflet-like format (see LatLngBounds). |
|
| 153 | - // http://leafletjs.com/reference.html#latlngbounds |
|
| 154 | - $boundaries[] = array( $coordinates['latitude'], $coordinates['longitude'] ); |
|
| 152 | + // Formatting boundaries in a Leaflet-like format (see LatLngBounds). |
|
| 153 | + // http://leafletjs.com/reference.html#latlngbounds |
|
| 154 | + $boundaries[] = array( $coordinates['latitude'], $coordinates['longitude'] ); |
|
| 155 | 155 | |
| 156 | - } |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - $map_data = array(); |
|
| 159 | - $map_data['features'] = $pois; |
|
| 160 | - $map_data['boundaries'] = $boundaries; |
|
| 158 | + $map_data = array(); |
|
| 159 | + $map_data['features'] = $pois; |
|
| 160 | + $map_data['boundaries'] = $boundaries; |
|
| 161 | 161 | |
| 162 | - return $map_data; |
|
| 162 | + return $map_data; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -173,13 +173,13 @@ discard block |
||
| 173 | 173 | * @return array An array of place posts. |
| 174 | 174 | */ |
| 175 | 175 | function wl_shortcode_geomap_ajax() { |
| 176 | - // Get the post Id. |
|
| 177 | - $post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null ); |
|
| 176 | + // Get the post Id. |
|
| 177 | + $post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null ); |
|
| 178 | 178 | |
| 179 | - $places = wl_shortcode_geomap_get_places( $post_id ); |
|
| 180 | - $map_data = wl_shortcode_geomap_prepare_map( $places ); |
|
| 179 | + $places = wl_shortcode_geomap_get_places( $post_id ); |
|
| 180 | + $map_data = wl_shortcode_geomap_prepare_map( $places ); |
|
| 181 | 181 | |
| 182 | - wl_core_send_json( $map_data ); |
|
| 182 | + wl_core_send_json( $map_data ); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | add_action( 'wp_ajax_wl_geomap', 'wl_shortcode_geomap_ajax' ); |
@@ -12,35 +12,35 @@ discard block |
||
| 12 | 12 | * |
| 13 | 13 | * @return array An array of place posts. |
| 14 | 14 | */ |
| 15 | -function wl_shortcode_geomap_get_places( $post_id = null ) { |
|
| 15 | +function wl_shortcode_geomap_get_places($post_id = null) { |
|
| 16 | 16 | |
| 17 | 17 | // If $post_id is null or is not numeric it means this is a global geomap |
| 18 | - $is_global = is_null( $post_id ) || ! is_numeric( $post_id ); |
|
| 18 | + $is_global = is_null($post_id) || ! is_numeric($post_id); |
|
| 19 | 19 | |
| 20 | 20 | // If the current one is not a global geomap, retrieve related entities ids |
| 21 | - if ( $is_global ) { |
|
| 21 | + if ($is_global) { |
|
| 22 | 22 | $related_ids = array(); |
| 23 | 23 | } else { |
| 24 | - $related_ids = wl_core_get_related_entity_ids( $post_id, array( |
|
| 24 | + $related_ids = wl_core_get_related_entity_ids($post_id, array( |
|
| 25 | 25 | 'status' => 'publish' |
| 26 | - ) ); |
|
| 26 | + )); |
|
| 27 | 27 | |
| 28 | 28 | // Also include current entity |
| 29 | - if ( Wordlift_Entity_Service::get_instance()->is_entity( $post_id ) ) { |
|
| 29 | + if (Wordlift_Entity_Service::get_instance()->is_entity($post_id)) { |
|
| 30 | 30 | $related_ids[] = $post_id; |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // If is not a global geomap, an empty $related_ids means that no entities are related to the post |
| 35 | 35 | // An empty array can be returned in this case |
| 36 | - if ( ! $is_global && empty( $related_ids ) ) { |
|
| 36 | + if ( ! $is_global && empty($related_ids)) { |
|
| 37 | 37 | return array(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // Retrieve all 'published' places with geo coordinates defined |
| 41 | 41 | // If $related_ids is not empty, it's used to limit query results to the current post related places |
| 42 | 42 | // Please note that when $place_ids is an empty array, the 'post__in' parameter is not considered in the query |
| 43 | - return get_posts( array( |
|
| 43 | + return get_posts(array( |
|
| 44 | 44 | 'post__in' => $related_ids, |
| 45 | 45 | 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
| 46 | 46 | 'nopaging' => true, |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | 'field' => 'slug', |
| 64 | 64 | 'terms' => 'place' |
| 65 | 65 | ) |
| 66 | - ) ); |
|
| 66 | + )); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return array An array of markers and boundaries for Leaflet. |
| 78 | 78 | */ |
| 79 | -function wl_shortcode_geomap_prepare_map( $places ) { |
|
| 79 | +function wl_shortcode_geomap_prepare_map($places) { |
|
| 80 | 80 | |
| 81 | 81 | // Prepare for min/max lat/long in case we need to define a view boundary for the client JavaScript. |
| 82 | 82 | $min_latitude = PHP_INT_MAX; |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | $boundaries = array(); |
| 92 | 92 | |
| 93 | 93 | // Add a POI for each entity that has coordinates. |
| 94 | - foreach ( $places as $entity ) { |
|
| 94 | + foreach ($places as $entity) { |
|
| 95 | 95 | |
| 96 | 96 | // Get the coordinates. |
| 97 | - $coordinates = wl_get_coordinates( $entity->ID ); |
|
| 97 | + $coordinates = wl_get_coordinates($entity->ID); |
|
| 98 | 98 | |
| 99 | 99 | // Don't show the widget if the coordinates aren't set. |
| 100 | - if ( $coordinates['latitude'] == 0 || $coordinates['longitude'] == 0 ) { |
|
| 100 | + if ($coordinates['latitude'] == 0 || $coordinates['longitude'] == 0) { |
|
| 101 | 101 | continue; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -105,38 +105,38 @@ discard block |
||
| 105 | 105 | // This function should be focused on returning pure data instead |
| 106 | 106 | |
| 107 | 107 | // Get the title, URL and thumb of the entity. |
| 108 | - $title = esc_attr( $entity->post_title ); |
|
| 109 | - $link = esc_attr( get_permalink( $entity->ID ) ); |
|
| 110 | - if ( '' !== ( $thumbnail_id = get_post_thumbnail_id( $entity->ID ) ) && |
|
| 111 | - false !== ( $attachment = wp_get_attachment_image_src( $thumbnail_id ) ) |
|
| 108 | + $title = esc_attr($entity->post_title); |
|
| 109 | + $link = esc_attr(get_permalink($entity->ID)); |
|
| 110 | + if ('' !== ($thumbnail_id = get_post_thumbnail_id($entity->ID)) && |
|
| 111 | + false !== ($attachment = wp_get_attachment_image_src($thumbnail_id)) |
|
| 112 | 112 | ) { |
| 113 | - $img_src = esc_attr( $attachment[0] ); |
|
| 113 | + $img_src = esc_attr($attachment[0]); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // Build HTML popup. TODO: move thumb width in css |
| 117 | 117 | $content = "<a href=$link><h6>$title</h6>"; |
| 118 | - if ( isset( $img_src ) ) { |
|
| 119 | - $content = $content . "<img src=$img_src style='width:100%'/>"; |
|
| 118 | + if (isset($img_src)) { |
|
| 119 | + $content = $content."<img src=$img_src style='width:100%'/>"; |
|
| 120 | 120 | } |
| 121 | - $content = $content . "</a><ul>"; |
|
| 121 | + $content = $content."</a><ul>"; |
|
| 122 | 122 | // Get the related posts (published) and print them in the popup. |
| 123 | - $related_posts = wl_core_get_related_post_ids( $entity->ID, array( |
|
| 123 | + $related_posts = wl_core_get_related_post_ids($entity->ID, array( |
|
| 124 | 124 | 'status' => 'publish' |
| 125 | - ) ); |
|
| 126 | - foreach ( $related_posts as $rp_id ) { |
|
| 125 | + )); |
|
| 126 | + foreach ($related_posts as $rp_id) { |
|
| 127 | 127 | |
| 128 | - $rp = get_post( $rp_id ); |
|
| 129 | - $title = esc_attr( $rp->post_title ); |
|
| 130 | - $link = esc_attr( get_permalink( $rp->ID ) ); |
|
| 131 | - $content = $content . "<li><a href=$link>$title</a></li>"; |
|
| 128 | + $rp = get_post($rp_id); |
|
| 129 | + $title = esc_attr($rp->post_title); |
|
| 130 | + $link = esc_attr(get_permalink($rp->ID)); |
|
| 131 | + $content = $content."<li><a href=$link>$title</a></li>"; |
|
| 132 | 132 | } |
| 133 | - $content = $content . "</ul>"; |
|
| 133 | + $content = $content."</ul>"; |
|
| 134 | 134 | |
| 135 | 135 | // Formatting POI in geoJSON. |
| 136 | 136 | // http://leafletjs.com/examples/geojson.html |
| 137 | 137 | $poi = array( |
| 138 | 138 | 'type' => 'Feature', |
| 139 | - 'properties' => array( 'popupContent' => $content ), |
|
| 139 | + 'properties' => array('popupContent' => $content), |
|
| 140 | 140 | 'geometry' => array( |
| 141 | 141 | 'type' => 'Point', |
| 142 | 142 | 'coordinates' => array( |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | // Formatting boundaries in a Leaflet-like format (see LatLngBounds). |
| 153 | 153 | // http://leafletjs.com/reference.html#latlngbounds |
| 154 | - $boundaries[] = array( $coordinates['latitude'], $coordinates['longitude'] ); |
|
| 154 | + $boundaries[] = array($coordinates['latitude'], $coordinates['longitude']); |
|
| 155 | 155 | |
| 156 | 156 | } |
| 157 | 157 | |
@@ -174,16 +174,16 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | function wl_shortcode_geomap_ajax() { |
| 176 | 176 | // Get the post Id. |
| 177 | - $post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null ); |
|
| 177 | + $post_id = (isset($_REQUEST['post_id']) ? $_REQUEST['post_id'] : null); |
|
| 178 | 178 | |
| 179 | - $places = wl_shortcode_geomap_get_places( $post_id ); |
|
| 180 | - $map_data = wl_shortcode_geomap_prepare_map( $places ); |
|
| 179 | + $places = wl_shortcode_geomap_get_places($post_id); |
|
| 180 | + $map_data = wl_shortcode_geomap_prepare_map($places); |
|
| 181 | 181 | |
| 182 | - wl_core_send_json( $map_data ); |
|
| 182 | + wl_core_send_json($map_data); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | -add_action( 'wp_ajax_wl_geomap', 'wl_shortcode_geomap_ajax' ); |
|
| 186 | -add_action( 'wp_ajax_nopriv_wl_geomap', 'wl_shortcode_geomap_ajax' ); |
|
| 185 | +add_action('wp_ajax_wl_geomap', 'wl_shortcode_geomap_ajax'); |
|
| 186 | +add_action('wp_ajax_nopriv_wl_geomap', 'wl_shortcode_geomap_ajax'); |
|
| 187 | 187 | |
| 188 | 188 | ///** |
| 189 | 189 | // * Print geomap shortcode |
@@ -7,64 +7,64 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_Chord_Shortcode extends Wordlift_Shortcode { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * {@inheritdoc} |
|
| 12 | - */ |
|
| 13 | - const SHORTCODE = 'wl_chord'; |
|
| 10 | + /** |
|
| 11 | + * {@inheritdoc} |
|
| 12 | + */ |
|
| 13 | + const SHORTCODE = 'wl_chord'; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * {@inheritdoc} |
|
| 17 | - */ |
|
| 18 | - public function render( $atts ) { |
|
| 15 | + /** |
|
| 16 | + * {@inheritdoc} |
|
| 17 | + */ |
|
| 18 | + public function render( $atts ) { |
|
| 19 | 19 | |
| 20 | - //extract attributes and set default values |
|
| 21 | - $chord_atts = shortcode_atts( array( |
|
| 22 | - 'width' => '100%', |
|
| 23 | - 'height' => '500px', |
|
| 24 | - 'main_color' => '000', |
|
| 25 | - 'depth' => 2, |
|
| 26 | - 'global' => FALSE |
|
| 27 | - ), $atts ); |
|
| 20 | + //extract attributes and set default values |
|
| 21 | + $chord_atts = shortcode_atts( array( |
|
| 22 | + 'width' => '100%', |
|
| 23 | + 'height' => '500px', |
|
| 24 | + 'main_color' => '000', |
|
| 25 | + 'depth' => 2, |
|
| 26 | + 'global' => FALSE |
|
| 27 | + ), $atts ); |
|
| 28 | 28 | |
| 29 | - if ( $chord_atts['global'] ) { |
|
| 30 | - $post_id = wl_shortcode_chord_most_referenced_entity_id(); |
|
| 31 | - if ( $post_id == NULL ) { |
|
| 32 | - return "WordLift Chord: no entities found."; |
|
| 33 | - } |
|
| 34 | - $widget_id = 'wl_chord_global'; |
|
| 35 | - $chord_atts['height'] = '200px'; |
|
| 36 | - } else { |
|
| 37 | - $post_id = get_the_ID(); |
|
| 38 | - $widget_id = 'wl_chord_' . $post_id; |
|
| 39 | - } |
|
| 29 | + if ( $chord_atts['global'] ) { |
|
| 30 | + $post_id = wl_shortcode_chord_most_referenced_entity_id(); |
|
| 31 | + if ( $post_id == NULL ) { |
|
| 32 | + return "WordLift Chord: no entities found."; |
|
| 33 | + } |
|
| 34 | + $widget_id = 'wl_chord_global'; |
|
| 35 | + $chord_atts['height'] = '200px'; |
|
| 36 | + } else { |
|
| 37 | + $post_id = get_the_ID(); |
|
| 38 | + $widget_id = 'wl_chord_' . $post_id; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - // Adding css |
|
| 42 | - wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' ); |
|
| 41 | + // Adding css |
|
| 42 | + wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' ); |
|
| 43 | 43 | |
| 44 | - // Adding javascript code |
|
| 45 | - wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' ); |
|
| 44 | + // Adding javascript code |
|
| 45 | + wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' ); |
|
| 46 | 46 | |
| 47 | - $this->enqueue_scripts(); |
|
| 47 | + $this->enqueue_scripts(); |
|
| 48 | 48 | |
| 49 | - wp_localize_script( 'wordlift-ui', 'wl_chord_params', array( |
|
| 50 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 51 | - 'action' => 'wl_chord' |
|
| 52 | - ) |
|
| 53 | - ); |
|
| 49 | + wp_localize_script( 'wordlift-ui', 'wl_chord_params', array( |
|
| 50 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 51 | + 'action' => 'wl_chord' |
|
| 52 | + ) |
|
| 53 | + ); |
|
| 54 | 54 | |
| 55 | - // Escaping atts. |
|
| 56 | - $esc_class = esc_attr( 'wl-chord' ); |
|
| 57 | - $esc_id = esc_attr( $widget_id ); |
|
| 58 | - $esc_width = esc_attr( $chord_atts['width'] ); |
|
| 59 | - $esc_height = esc_attr( $chord_atts['height'] ); |
|
| 55 | + // Escaping atts. |
|
| 56 | + $esc_class = esc_attr( 'wl-chord' ); |
|
| 57 | + $esc_id = esc_attr( $widget_id ); |
|
| 58 | + $esc_width = esc_attr( $chord_atts['width'] ); |
|
| 59 | + $esc_height = esc_attr( $chord_atts['height'] ); |
|
| 60 | 60 | |
| 61 | - $esc_post_id = esc_attr( $post_id ); |
|
| 62 | - $esc_depth = esc_attr( $chord_atts['depth'] ); |
|
| 63 | - $esc_main_color = esc_attr( $chord_atts['main_color'] ); |
|
| 61 | + $esc_post_id = esc_attr( $post_id ); |
|
| 62 | + $esc_depth = esc_attr( $chord_atts['depth'] ); |
|
| 63 | + $esc_main_color = esc_attr( $chord_atts['main_color'] ); |
|
| 64 | 64 | |
| 65 | - // Building template. |
|
| 66 | - // TODO: in the HTML code there are static CSS rules. Move them to the CSS file. |
|
| 67 | - return <<<EOF |
|
| 65 | + // Building template. |
|
| 66 | + // TODO: in the HTML code there are static CSS rules. Move them to the CSS file. |
|
| 67 | + return <<<EOF |
|
| 68 | 68 | <div class="$esc_class" |
| 69 | 69 | id="$esc_id" |
| 70 | 70 | data-post-id="$esc_post_id" |
@@ -77,6 +77,6 @@ discard block |
||
| 77 | 77 | margin-bottom:10px"> |
| 78 | 78 | </div> |
| 79 | 79 | EOF; |
| 80 | - } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | } |
| 83 | 83 | \ No newline at end of file |
@@ -15,52 +15,52 @@ |
||
| 15 | 15 | /** |
| 16 | 16 | * {@inheritdoc} |
| 17 | 17 | */ |
| 18 | - public function render( $atts ) { |
|
| 18 | + public function render($atts) { |
|
| 19 | 19 | |
| 20 | 20 | //extract attributes and set default values |
| 21 | - $chord_atts = shortcode_atts( array( |
|
| 21 | + $chord_atts = shortcode_atts(array( |
|
| 22 | 22 | 'width' => '100%', |
| 23 | 23 | 'height' => '500px', |
| 24 | 24 | 'main_color' => '000', |
| 25 | 25 | 'depth' => 2, |
| 26 | 26 | 'global' => FALSE |
| 27 | - ), $atts ); |
|
| 27 | + ), $atts); |
|
| 28 | 28 | |
| 29 | - if ( $chord_atts['global'] ) { |
|
| 29 | + if ($chord_atts['global']) { |
|
| 30 | 30 | $post_id = wl_shortcode_chord_most_referenced_entity_id(); |
| 31 | - if ( $post_id == NULL ) { |
|
| 31 | + if ($post_id == NULL) { |
|
| 32 | 32 | return "WordLift Chord: no entities found."; |
| 33 | 33 | } |
| 34 | 34 | $widget_id = 'wl_chord_global'; |
| 35 | 35 | $chord_atts['height'] = '200px'; |
| 36 | 36 | } else { |
| 37 | 37 | $post_id = get_the_ID(); |
| 38 | - $widget_id = 'wl_chord_' . $post_id; |
|
| 38 | + $widget_id = 'wl_chord_'.$post_id; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // Adding css |
| 42 | - wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' ); |
|
| 42 | + wp_enqueue_style('wordlift-ui', dirname(plugin_dir_url(__FILE__)).'/css/wordlift-ui.min.css'); |
|
| 43 | 43 | |
| 44 | 44 | // Adding javascript code |
| 45 | - wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' ); |
|
| 45 | + wp_enqueue_script('d3', dirname(plugin_dir_url(__FILE__)).'/bower_components/d3/d3.min.js'); |
|
| 46 | 46 | |
| 47 | 47 | $this->enqueue_scripts(); |
| 48 | 48 | |
| 49 | - wp_localize_script( 'wordlift-ui', 'wl_chord_params', array( |
|
| 50 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 49 | + wp_localize_script('wordlift-ui', 'wl_chord_params', array( |
|
| 50 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 51 | 51 | 'action' => 'wl_chord' |
| 52 | 52 | ) |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | 55 | // Escaping atts. |
| 56 | - $esc_class = esc_attr( 'wl-chord' ); |
|
| 57 | - $esc_id = esc_attr( $widget_id ); |
|
| 58 | - $esc_width = esc_attr( $chord_atts['width'] ); |
|
| 59 | - $esc_height = esc_attr( $chord_atts['height'] ); |
|
| 56 | + $esc_class = esc_attr('wl-chord'); |
|
| 57 | + $esc_id = esc_attr($widget_id); |
|
| 58 | + $esc_width = esc_attr($chord_atts['width']); |
|
| 59 | + $esc_height = esc_attr($chord_atts['height']); |
|
| 60 | 60 | |
| 61 | - $esc_post_id = esc_attr( $post_id ); |
|
| 62 | - $esc_depth = esc_attr( $chord_atts['depth'] ); |
|
| 63 | - $esc_main_color = esc_attr( $chord_atts['main_color'] ); |
|
| 61 | + $esc_post_id = esc_attr($post_id); |
|
| 62 | + $esc_depth = esc_attr($chord_atts['depth']); |
|
| 63 | + $esc_main_color = esc_attr($chord_atts['main_color']); |
|
| 64 | 64 | |
| 65 | 65 | // Building template. |
| 66 | 66 | // TODO: in the HTML code there are static CSS rules. Move them to the CSS file. |
@@ -7,79 +7,79 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_Timeline_Shortcode extends Wordlift_Shortcode { |
| 9 | 9 | |
| 10 | - const SHORTCODE = 'wl_timeline'; |
|
| 11 | - |
|
| 12 | - /** |
|
| 13 | - * The Log service. |
|
| 14 | - * |
|
| 15 | - * @since 3.1.0 |
|
| 16 | - * @access private |
|
| 17 | - * @var \Wordlift_Log_Service $log_service The Log service. |
|
| 18 | - */ |
|
| 19 | - private $log_service; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Create a Wordlift_Timeline_Shortcode instance. |
|
| 23 | - * |
|
| 24 | - * @since 3.1.0 |
|
| 25 | - */ |
|
| 26 | - public function __construct() { |
|
| 27 | - parent::__construct(); |
|
| 28 | - |
|
| 29 | - $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Timeline_Shortcode' ); |
|
| 30 | - |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Renders the Timeline. |
|
| 35 | - * |
|
| 36 | - * @since 3.1.0 |
|
| 37 | - * @return string The rendered HTML. |
|
| 38 | - */ |
|
| 39 | - public function render( $atts ) { |
|
| 40 | - |
|
| 41 | - //extract attributes and set default values |
|
| 42 | - $timeline_atts = shortcode_atts( array( |
|
| 43 | - 'width' => '100%', |
|
| 44 | - 'height' => '600px', |
|
| 45 | - 'global' => false |
|
| 46 | - ), $atts ); |
|
| 47 | - |
|
| 48 | - // Add timeline library. |
|
| 49 | - wp_enqueue_script( 'timelinejs-storyjs-embed', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/TimelineJS.build/build/js/storyjs-embed.js' ); |
|
| 50 | - wp_enqueue_script( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/TimelineJS.build/build/js/timeline-min.js' ); |
|
| 51 | - |
|
| 52 | - // Enqueue the scripts for the timeline. |
|
| 53 | - $this->enqueue_scripts(); |
|
| 54 | - |
|
| 55 | - wp_localize_script( 'wordlift-ui', 'wl_timeline_params', array( |
|
| 56 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), // TODO: this parameter is already provided by WP |
|
| 57 | - 'action' => 'wl_timeline' |
|
| 58 | - ) ); |
|
| 59 | - |
|
| 60 | - // Get the current post id or set null if global is set to true. |
|
| 61 | - $post_id = ( $timeline_atts['global'] ? null : get_the_ID() ); |
|
| 62 | - |
|
| 63 | - // Generate a unique ID for this timeline. |
|
| 64 | - $element_id = uniqid( 'wl-timeline-' ); |
|
| 65 | - |
|
| 66 | - // Escaping atts. |
|
| 67 | - $esc_width = esc_attr( $timeline_atts['width'] ); |
|
| 68 | - $esc_height = esc_attr( $timeline_atts['height'] ); |
|
| 69 | - $data_post_id = ( isset( $post_id ) ? "data-post-id='$post_id'" : '' ); |
|
| 70 | - |
|
| 71 | - if ( WP_DEBUG ) { |
|
| 72 | - $this->log_service->trace( "Creating a timeline widget [ element id :: $element_id ][ post id :: $post_id ]" ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - // Building template. |
|
| 76 | - // TODO: in the HTML code there are static CSS rules. Move them to the CSS file. |
|
| 77 | - return <<<EOF |
|
| 10 | + const SHORTCODE = 'wl_timeline'; |
|
| 11 | + |
|
| 12 | + /** |
|
| 13 | + * The Log service. |
|
| 14 | + * |
|
| 15 | + * @since 3.1.0 |
|
| 16 | + * @access private |
|
| 17 | + * @var \Wordlift_Log_Service $log_service The Log service. |
|
| 18 | + */ |
|
| 19 | + private $log_service; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Create a Wordlift_Timeline_Shortcode instance. |
|
| 23 | + * |
|
| 24 | + * @since 3.1.0 |
|
| 25 | + */ |
|
| 26 | + public function __construct() { |
|
| 27 | + parent::__construct(); |
|
| 28 | + |
|
| 29 | + $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Timeline_Shortcode' ); |
|
| 30 | + |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Renders the Timeline. |
|
| 35 | + * |
|
| 36 | + * @since 3.1.0 |
|
| 37 | + * @return string The rendered HTML. |
|
| 38 | + */ |
|
| 39 | + public function render( $atts ) { |
|
| 40 | + |
|
| 41 | + //extract attributes and set default values |
|
| 42 | + $timeline_atts = shortcode_atts( array( |
|
| 43 | + 'width' => '100%', |
|
| 44 | + 'height' => '600px', |
|
| 45 | + 'global' => false |
|
| 46 | + ), $atts ); |
|
| 47 | + |
|
| 48 | + // Add timeline library. |
|
| 49 | + wp_enqueue_script( 'timelinejs-storyjs-embed', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/TimelineJS.build/build/js/storyjs-embed.js' ); |
|
| 50 | + wp_enqueue_script( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/TimelineJS.build/build/js/timeline-min.js' ); |
|
| 51 | + |
|
| 52 | + // Enqueue the scripts for the timeline. |
|
| 53 | + $this->enqueue_scripts(); |
|
| 54 | + |
|
| 55 | + wp_localize_script( 'wordlift-ui', 'wl_timeline_params', array( |
|
| 56 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), // TODO: this parameter is already provided by WP |
|
| 57 | + 'action' => 'wl_timeline' |
|
| 58 | + ) ); |
|
| 59 | + |
|
| 60 | + // Get the current post id or set null if global is set to true. |
|
| 61 | + $post_id = ( $timeline_atts['global'] ? null : get_the_ID() ); |
|
| 62 | + |
|
| 63 | + // Generate a unique ID for this timeline. |
|
| 64 | + $element_id = uniqid( 'wl-timeline-' ); |
|
| 65 | + |
|
| 66 | + // Escaping atts. |
|
| 67 | + $esc_width = esc_attr( $timeline_atts['width'] ); |
|
| 68 | + $esc_height = esc_attr( $timeline_atts['height'] ); |
|
| 69 | + $data_post_id = ( isset( $post_id ) ? "data-post-id='$post_id'" : '' ); |
|
| 70 | + |
|
| 71 | + if ( WP_DEBUG ) { |
|
| 72 | + $this->log_service->trace( "Creating a timeline widget [ element id :: $element_id ][ post id :: $post_id ]" ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + // Building template. |
|
| 76 | + // TODO: in the HTML code there are static CSS rules. Move them to the CSS file. |
|
| 77 | + return <<<EOF |
|
| 78 | 78 | <div class="wl-timeline" id="$element_id" $data_post_id |
| 79 | 79 | style="width:$esc_width; height:$esc_height; margin-top:10px; margin-bottom:10px"> |
| 80 | 80 | </div> |
| 81 | 81 | EOF; |
| 82 | 82 | |
| 83 | - } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | public function __construct() { |
| 27 | 27 | parent::__construct(); |
| 28 | 28 | |
| 29 | - $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Timeline_Shortcode' ); |
|
| 29 | + $this->log_service = Wordlift_Log_Service::get_logger('Wordlift_Timeline_Shortcode'); |
|
| 30 | 30 | |
| 31 | 31 | } |
| 32 | 32 | |
@@ -36,40 +36,40 @@ discard block |
||
| 36 | 36 | * @since 3.1.0 |
| 37 | 37 | * @return string The rendered HTML. |
| 38 | 38 | */ |
| 39 | - public function render( $atts ) { |
|
| 39 | + public function render($atts) { |
|
| 40 | 40 | |
| 41 | 41 | //extract attributes and set default values |
| 42 | - $timeline_atts = shortcode_atts( array( |
|
| 42 | + $timeline_atts = shortcode_atts(array( |
|
| 43 | 43 | 'width' => '100%', |
| 44 | 44 | 'height' => '600px', |
| 45 | 45 | 'global' => false |
| 46 | - ), $atts ); |
|
| 46 | + ), $atts); |
|
| 47 | 47 | |
| 48 | 48 | // Add timeline library. |
| 49 | - wp_enqueue_script( 'timelinejs-storyjs-embed', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/TimelineJS.build/build/js/storyjs-embed.js' ); |
|
| 50 | - wp_enqueue_script( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/TimelineJS.build/build/js/timeline-min.js' ); |
|
| 49 | + wp_enqueue_script('timelinejs-storyjs-embed', dirname(plugin_dir_url(__FILE__)).'/bower_components/TimelineJS.build/build/js/storyjs-embed.js'); |
|
| 50 | + wp_enqueue_script('timelinejs', dirname(plugin_dir_url(__FILE__)).'/bower_components/TimelineJS.build/build/js/timeline-min.js'); |
|
| 51 | 51 | |
| 52 | 52 | // Enqueue the scripts for the timeline. |
| 53 | 53 | $this->enqueue_scripts(); |
| 54 | 54 | |
| 55 | - wp_localize_script( 'wordlift-ui', 'wl_timeline_params', array( |
|
| 56 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), // TODO: this parameter is already provided by WP |
|
| 55 | + wp_localize_script('wordlift-ui', 'wl_timeline_params', array( |
|
| 56 | + 'ajax_url' => admin_url('admin-ajax.php'), // TODO: this parameter is already provided by WP |
|
| 57 | 57 | 'action' => 'wl_timeline' |
| 58 | - ) ); |
|
| 58 | + )); |
|
| 59 | 59 | |
| 60 | 60 | // Get the current post id or set null if global is set to true. |
| 61 | - $post_id = ( $timeline_atts['global'] ? null : get_the_ID() ); |
|
| 61 | + $post_id = ($timeline_atts['global'] ? null : get_the_ID()); |
|
| 62 | 62 | |
| 63 | 63 | // Generate a unique ID for this timeline. |
| 64 | - $element_id = uniqid( 'wl-timeline-' ); |
|
| 64 | + $element_id = uniqid('wl-timeline-'); |
|
| 65 | 65 | |
| 66 | 66 | // Escaping atts. |
| 67 | - $esc_width = esc_attr( $timeline_atts['width'] ); |
|
| 68 | - $esc_height = esc_attr( $timeline_atts['height'] ); |
|
| 69 | - $data_post_id = ( isset( $post_id ) ? "data-post-id='$post_id'" : '' ); |
|
| 67 | + $esc_width = esc_attr($timeline_atts['width']); |
|
| 68 | + $esc_height = esc_attr($timeline_atts['height']); |
|
| 69 | + $data_post_id = (isset($post_id) ? "data-post-id='$post_id'" : ''); |
|
| 70 | 70 | |
| 71 | - if ( WP_DEBUG ) { |
|
| 72 | - $this->log_service->trace( "Creating a timeline widget [ element id :: $element_id ][ post id :: $post_id ]" ); |
|
| 71 | + if (WP_DEBUG) { |
|
| 72 | + $this->log_service->trace("Creating a timeline widget [ element id :: $element_id ][ post id :: $post_id ]"); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Building template. |
@@ -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.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.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.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.min.js', array( |
|
| 50 | 50 | 'jquery', |
| 51 | 51 | 'angularjs', |
| 52 | 52 | 'angularjs-touch' |
| 53 | - ) ); |
|
| 53 | + )); |
|
| 54 | 54 | |
| 55 | 55 | } |
| 56 | 56 | |
@@ -7,67 +7,67 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_Geomap_Shortcode extends Wordlift_Shortcode { |
| 9 | 9 | |
| 10 | - const SHORTCODE = 'wl_geomap'; |
|
| 10 | + const SHORTCODE = 'wl_geomap'; |
|
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Render the shortcode. |
|
| 14 | - * |
|
| 15 | - * @since 3.5.4 |
|
| 16 | - * |
|
| 17 | - * @param array $atts An array of shortcode attributes as set by the editor. |
|
| 18 | - * |
|
| 19 | - * @return string The output html code. |
|
| 20 | - */ |
|
| 21 | - public function render( $atts ) { |
|
| 12 | + /** |
|
| 13 | + * Render the shortcode. |
|
| 14 | + * |
|
| 15 | + * @since 3.5.4 |
|
| 16 | + * |
|
| 17 | + * @param array $atts An array of shortcode attributes as set by the editor. |
|
| 18 | + * |
|
| 19 | + * @return string The output html code. |
|
| 20 | + */ |
|
| 21 | + public function render( $atts ) { |
|
| 22 | 22 | |
| 23 | - // Extract attributes and set default values. |
|
| 24 | - $geomap_atts = shortcode_atts( array( |
|
| 25 | - 'width' => '100%', |
|
| 26 | - 'height' => '300px', |
|
| 27 | - 'global' => FALSE |
|
| 28 | - ), $atts ); |
|
| 23 | + // Extract attributes and set default values. |
|
| 24 | + $geomap_atts = shortcode_atts( array( |
|
| 25 | + 'width' => '100%', |
|
| 26 | + 'height' => '300px', |
|
| 27 | + 'global' => FALSE |
|
| 28 | + ), $atts ); |
|
| 29 | 29 | |
| 30 | - // Get id of the post |
|
| 31 | - $post_id = get_the_ID(); |
|
| 30 | + // Get id of the post |
|
| 31 | + $post_id = get_the_ID(); |
|
| 32 | 32 | |
| 33 | - if ( $geomap_atts['global'] || is_null( $post_id ) ) { |
|
| 34 | - // Global geomap |
|
| 35 | - $geomap_id = 'wl_geomap_global'; |
|
| 36 | - $post_id = NULL; |
|
| 37 | - } else { |
|
| 38 | - // Post-specific geomap |
|
| 39 | - $geomap_id = 'wl_geomap_' . $post_id; |
|
| 40 | - } |
|
| 33 | + if ( $geomap_atts['global'] || is_null( $post_id ) ) { |
|
| 34 | + // Global geomap |
|
| 35 | + $geomap_id = 'wl_geomap_global'; |
|
| 36 | + $post_id = NULL; |
|
| 37 | + } else { |
|
| 38 | + // Post-specific geomap |
|
| 39 | + $geomap_id = 'wl_geomap_' . $post_id; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - // Add leaflet css and library. |
|
| 43 | - wp_enqueue_style( |
|
| 44 | - 'leaflet', |
|
| 45 | - dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/leaflet/dist/leaflet.css' |
|
| 46 | - ); |
|
| 47 | - wp_enqueue_script( |
|
| 48 | - 'leaflet', |
|
| 49 | - dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/leaflet/dist/leaflet.js' |
|
| 50 | - ); |
|
| 42 | + // Add leaflet css and library. |
|
| 43 | + wp_enqueue_style( |
|
| 44 | + 'leaflet', |
|
| 45 | + dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/leaflet/dist/leaflet.css' |
|
| 46 | + ); |
|
| 47 | + wp_enqueue_script( |
|
| 48 | + 'leaflet', |
|
| 49 | + dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/leaflet/dist/leaflet.js' |
|
| 50 | + ); |
|
| 51 | 51 | |
| 52 | - // Add wordlift-ui css and library. |
|
| 53 | - wp_enqueue_style( 'wordlift-ui-css', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' ); |
|
| 52 | + // Add wordlift-ui css and library. |
|
| 53 | + wp_enqueue_style( 'wordlift-ui-css', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' ); |
|
| 54 | 54 | |
| 55 | - $this->enqueue_scripts(); |
|
| 55 | + $this->enqueue_scripts(); |
|
| 56 | 56 | |
| 57 | - wp_localize_script( 'wordlift-ui', 'wl_geomap_params', array( |
|
| 58 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), // Global param |
|
| 59 | - 'action' => 'wl_geomap' // Global param |
|
| 60 | - ) ); |
|
| 57 | + wp_localize_script( 'wordlift-ui', 'wl_geomap_params', array( |
|
| 58 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), // Global param |
|
| 59 | + 'action' => 'wl_geomap' // Global param |
|
| 60 | + ) ); |
|
| 61 | 61 | |
| 62 | - // Escaping atts. |
|
| 63 | - $esc_class = esc_attr( 'wl-geomap' ); |
|
| 64 | - $esc_id = esc_attr( $geomap_id ); |
|
| 65 | - $esc_width = esc_attr( $geomap_atts['width'] ); |
|
| 66 | - $esc_height = esc_attr( $geomap_atts['height'] ); |
|
| 67 | - $esc_post_id = esc_attr( $post_id ); |
|
| 62 | + // Escaping atts. |
|
| 63 | + $esc_class = esc_attr( 'wl-geomap' ); |
|
| 64 | + $esc_id = esc_attr( $geomap_id ); |
|
| 65 | + $esc_width = esc_attr( $geomap_atts['width'] ); |
|
| 66 | + $esc_height = esc_attr( $geomap_atts['height'] ); |
|
| 67 | + $esc_post_id = esc_attr( $post_id ); |
|
| 68 | 68 | |
| 69 | - // Return HTML template. |
|
| 70 | - return <<<EOF |
|
| 69 | + // Return HTML template. |
|
| 70 | + return <<<EOF |
|
| 71 | 71 | <div class="$esc_class" |
| 72 | 72 | id="$esc_id" |
| 73 | 73 | data-post-id="$esc_post_id" |
@@ -77,6 +77,6 @@ discard block |
||
| 77 | 77 | "> |
| 78 | 78 | </div> |
| 79 | 79 | EOF; |
| 80 | - } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | } |
@@ -18,53 +18,53 @@ |
||
| 18 | 18 | * |
| 19 | 19 | * @return string The output html code. |
| 20 | 20 | */ |
| 21 | - public function render( $atts ) { |
|
| 21 | + public function render($atts) { |
|
| 22 | 22 | |
| 23 | 23 | // Extract attributes and set default values. |
| 24 | - $geomap_atts = shortcode_atts( array( |
|
| 24 | + $geomap_atts = shortcode_atts(array( |
|
| 25 | 25 | 'width' => '100%', |
| 26 | 26 | 'height' => '300px', |
| 27 | 27 | 'global' => FALSE |
| 28 | - ), $atts ); |
|
| 28 | + ), $atts); |
|
| 29 | 29 | |
| 30 | 30 | // Get id of the post |
| 31 | 31 | $post_id = get_the_ID(); |
| 32 | 32 | |
| 33 | - if ( $geomap_atts['global'] || is_null( $post_id ) ) { |
|
| 33 | + if ($geomap_atts['global'] || is_null($post_id)) { |
|
| 34 | 34 | // Global geomap |
| 35 | 35 | $geomap_id = 'wl_geomap_global'; |
| 36 | 36 | $post_id = NULL; |
| 37 | 37 | } else { |
| 38 | 38 | // Post-specific geomap |
| 39 | - $geomap_id = 'wl_geomap_' . $post_id; |
|
| 39 | + $geomap_id = 'wl_geomap_'.$post_id; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // Add leaflet css and library. |
| 43 | 43 | wp_enqueue_style( |
| 44 | 44 | 'leaflet', |
| 45 | - dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/leaflet/dist/leaflet.css' |
|
| 45 | + dirname(plugin_dir_url(__FILE__)).'/bower_components/leaflet/dist/leaflet.css' |
|
| 46 | 46 | ); |
| 47 | 47 | wp_enqueue_script( |
| 48 | 48 | 'leaflet', |
| 49 | - dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/leaflet/dist/leaflet.js' |
|
| 49 | + dirname(plugin_dir_url(__FILE__)).'/bower_components/leaflet/dist/leaflet.js' |
|
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | 52 | // Add wordlift-ui css and library. |
| 53 | - wp_enqueue_style( 'wordlift-ui-css', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' ); |
|
| 53 | + wp_enqueue_style('wordlift-ui-css', dirname(plugin_dir_url(__FILE__)).'/css/wordlift-ui.min.css'); |
|
| 54 | 54 | |
| 55 | 55 | $this->enqueue_scripts(); |
| 56 | 56 | |
| 57 | - wp_localize_script( 'wordlift-ui', 'wl_geomap_params', array( |
|
| 58 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), // Global param |
|
| 57 | + wp_localize_script('wordlift-ui', 'wl_geomap_params', array( |
|
| 58 | + 'ajax_url' => admin_url('admin-ajax.php'), // Global param |
|
| 59 | 59 | 'action' => 'wl_geomap' // Global param |
| 60 | - ) ); |
|
| 60 | + )); |
|
| 61 | 61 | |
| 62 | 62 | // Escaping atts. |
| 63 | - $esc_class = esc_attr( 'wl-geomap' ); |
|
| 64 | - $esc_id = esc_attr( $geomap_id ); |
|
| 65 | - $esc_width = esc_attr( $geomap_atts['width'] ); |
|
| 66 | - $esc_height = esc_attr( $geomap_atts['height'] ); |
|
| 67 | - $esc_post_id = esc_attr( $post_id ); |
|
| 63 | + $esc_class = esc_attr('wl-geomap'); |
|
| 64 | + $esc_id = esc_attr($geomap_id); |
|
| 65 | + $esc_width = esc_attr($geomap_atts['width']); |
|
| 66 | + $esc_height = esc_attr($geomap_atts['height']); |
|
| 67 | + $esc_post_id = esc_attr($post_id); |
|
| 68 | 68 | |
| 69 | 69 | // Return HTML template. |
| 70 | 70 | return <<<EOF |
@@ -7,59 +7,59 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_Navigator_Shortcode extends Wordlift_Shortcode { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * {@inheritdoc} |
|
| 12 | - */ |
|
| 13 | - const SHORTCODE = 'wl_navigator'; |
|
| 10 | + /** |
|
| 11 | + * {@inheritdoc} |
|
| 12 | + */ |
|
| 13 | + const SHORTCODE = 'wl_navigator'; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * {@inheritdoc} |
|
| 17 | - */ |
|
| 18 | - public function render( $atts ) { |
|
| 15 | + /** |
|
| 16 | + * {@inheritdoc} |
|
| 17 | + */ |
|
| 18 | + public function render( $atts ) { |
|
| 19 | 19 | |
| 20 | - // Extract attributes and set default values. |
|
| 21 | - $shortcode_atts = shortcode_atts( array( |
|
| 22 | - 'title' => __( 'Related articles', 'wordlift' ), |
|
| 23 | - 'with_carousel' => TRUE, |
|
| 24 | - 'squared_thumbs' => FALSE |
|
| 25 | - ), $atts ); |
|
| 20 | + // Extract attributes and set default values. |
|
| 21 | + $shortcode_atts = shortcode_atts( array( |
|
| 22 | + 'title' => __( 'Related articles', 'wordlift' ), |
|
| 23 | + 'with_carousel' => TRUE, |
|
| 24 | + 'squared_thumbs' => FALSE |
|
| 25 | + ), $atts ); |
|
| 26 | 26 | |
| 27 | - foreach ( |
|
| 28 | - array( |
|
| 29 | - 'with_carousel', |
|
| 30 | - 'squared_thumbs' |
|
| 31 | - ) as $att |
|
| 32 | - ) { |
|
| 27 | + foreach ( |
|
| 28 | + array( |
|
| 29 | + 'with_carousel', |
|
| 30 | + 'squared_thumbs' |
|
| 31 | + ) as $att |
|
| 32 | + ) { |
|
| 33 | 33 | |
| 34 | - // See http://wordpress.stackexchange.com/questions/119294/pass-boolean-value-in-shortcode |
|
| 35 | - $shortcode_atts[ $att ] = filter_var( |
|
| 36 | - $shortcode_atts[ $att ], FILTER_VALIDATE_BOOLEAN |
|
| 37 | - ); |
|
| 38 | - } |
|
| 34 | + // See http://wordpress.stackexchange.com/questions/119294/pass-boolean-value-in-shortcode |
|
| 35 | + $shortcode_atts[ $att ] = filter_var( |
|
| 36 | + $shortcode_atts[ $att ], FILTER_VALIDATE_BOOLEAN |
|
| 37 | + ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - // avoid building the widget when there is a list of posts. |
|
| 41 | - if ( ! is_single() ) { |
|
| 42 | - return ''; |
|
| 43 | - } |
|
| 40 | + // avoid building the widget when there is a list of posts. |
|
| 41 | + if ( ! is_single() ) { |
|
| 42 | + return ''; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - $current_post = get_post(); |
|
| 45 | + $current_post = get_post(); |
|
| 46 | 46 | |
| 47 | - // Enqueue common shortcode scripts. |
|
| 48 | - $this->enqueue_scripts(); |
|
| 47 | + // Enqueue common shortcode scripts. |
|
| 48 | + $this->enqueue_scripts(); |
|
| 49 | 49 | |
| 50 | - wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' ); |
|
| 50 | + wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' ); |
|
| 51 | 51 | |
| 52 | - $navigator_id = uniqid( 'wl-navigator-widget-' ); |
|
| 52 | + $navigator_id = uniqid( 'wl-navigator-widget-' ); |
|
| 53 | 53 | |
| 54 | - wp_localize_script( 'wordlift-ui', 'wl_navigator_params', array( |
|
| 55 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 56 | - 'action' => 'wl_navigator', |
|
| 57 | - 'post_id' => $current_post->ID, |
|
| 58 | - 'attrs' => $shortcode_atts |
|
| 59 | - ) |
|
| 60 | - ); |
|
| 54 | + wp_localize_script( 'wordlift-ui', 'wl_navigator_params', array( |
|
| 55 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 56 | + 'action' => 'wl_navigator', |
|
| 57 | + 'post_id' => $current_post->ID, |
|
| 58 | + 'attrs' => $shortcode_atts |
|
| 59 | + ) |
|
| 60 | + ); |
|
| 61 | 61 | |
| 62 | - return "<div id='$navigator_id' class='wl-navigator-widget'></div>"; |
|
| 63 | - } |
|
| 62 | + return "<div id='$navigator_id' class='wl-navigator-widget'></div>"; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | } |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * {@inheritdoc} |
| 17 | 17 | */ |
| 18 | - public function render( $atts ) { |
|
| 18 | + public function render($atts) { |
|
| 19 | 19 | |
| 20 | 20 | // Extract attributes and set default values. |
| 21 | - $shortcode_atts = shortcode_atts( array( |
|
| 22 | - 'title' => __( 'Related articles', 'wordlift' ), |
|
| 21 | + $shortcode_atts = shortcode_atts(array( |
|
| 22 | + 'title' => __('Related articles', 'wordlift'), |
|
| 23 | 23 | 'with_carousel' => TRUE, |
| 24 | 24 | 'squared_thumbs' => FALSE |
| 25 | - ), $atts ); |
|
| 25 | + ), $atts); |
|
| 26 | 26 | |
| 27 | 27 | foreach ( |
| 28 | 28 | array( |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | ) { |
| 33 | 33 | |
| 34 | 34 | // See http://wordpress.stackexchange.com/questions/119294/pass-boolean-value-in-shortcode |
| 35 | - $shortcode_atts[ $att ] = filter_var( |
|
| 36 | - $shortcode_atts[ $att ], FILTER_VALIDATE_BOOLEAN |
|
| 35 | + $shortcode_atts[$att] = filter_var( |
|
| 36 | + $shortcode_atts[$att], FILTER_VALIDATE_BOOLEAN |
|
| 37 | 37 | ); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // avoid building the widget when there is a list of posts. |
| 41 | - if ( ! is_single() ) { |
|
| 41 | + if ( ! is_single()) { |
|
| 42 | 42 | return ''; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | // Enqueue common shortcode scripts. |
| 48 | 48 | $this->enqueue_scripts(); |
| 49 | 49 | |
| 50 | - wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' ); |
|
| 50 | + wp_enqueue_style('wordlift-ui', dirname(plugin_dir_url(__FILE__)).'/css/wordlift-ui.min.css'); |
|
| 51 | 51 | |
| 52 | - $navigator_id = uniqid( 'wl-navigator-widget-' ); |
|
| 52 | + $navigator_id = uniqid('wl-navigator-widget-'); |
|
| 53 | 53 | |
| 54 | - wp_localize_script( 'wordlift-ui', 'wl_navigator_params', array( |
|
| 55 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 54 | + wp_localize_script('wordlift-ui', 'wl_navigator_params', array( |
|
| 55 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 56 | 56 | 'action' => 'wl_navigator', |
| 57 | 57 | 'post_id' => $current_post->ID, |
| 58 | 58 | 'attrs' => $shortcode_atts |
@@ -29,594 +29,594 @@ |
||
| 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 | - /** |
|
| 216 | - * Define the core functionality of the plugin. |
|
| 217 | - * |
|
| 218 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 219 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 220 | - * the public-facing side of the site. |
|
| 221 | - * |
|
| 222 | - * @since 1.0.0 |
|
| 223 | - */ |
|
| 224 | - public function __construct() { |
|
| 225 | - |
|
| 226 | - $this->plugin_name = 'wordlift'; |
|
| 227 | - $this->version = '3.6.0-dev'; |
|
| 228 | - $this->load_dependencies(); |
|
| 229 | - $this->set_locale(); |
|
| 230 | - $this->define_admin_hooks(); |
|
| 231 | - $this->define_public_hooks(); |
|
| 232 | - |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * Load the required dependencies for this plugin. |
|
| 237 | - * |
|
| 238 | - * Include the following files that make up the plugin: |
|
| 239 | - * |
|
| 240 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 241 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 242 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 243 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 244 | - * |
|
| 245 | - * Create an instance of the loader which will be used to register the hooks |
|
| 246 | - * with WordPress. |
|
| 247 | - * |
|
| 248 | - * @since 1.0.0 |
|
| 249 | - * @access private |
|
| 250 | - */ |
|
| 251 | - private function load_dependencies() { |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * The class responsible for orchestrating the actions and filters of the |
|
| 255 | - * core plugin. |
|
| 256 | - */ |
|
| 257 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * The class responsible for defining internationalization functionality |
|
| 261 | - * of the plugin. |
|
| 262 | - */ |
|
| 263 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * Provide support functions to sanitize data. |
|
| 267 | - */ |
|
| 268 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * The Redirect service. |
|
| 272 | - */ |
|
| 273 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * The Log service. |
|
| 277 | - */ |
|
| 278 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * The entity post type service. |
|
| 282 | - */ |
|
| 283 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * The entity link service. |
|
| 287 | - */ |
|
| 288 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * The Query builder. |
|
| 292 | - */ |
|
| 293 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * The Schema service. |
|
| 297 | - */ |
|
| 298 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * The UI service. |
|
| 302 | - */ |
|
| 303 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * The Thumbnail service. |
|
| 307 | - */ |
|
| 308 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * The Entity Types Taxonomy service. |
|
| 312 | - */ |
|
| 313 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * The Entity service. |
|
| 317 | - */ |
|
| 318 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 319 | - |
|
| 320 | - /** |
|
| 321 | - * The User service. |
|
| 322 | - */ |
|
| 323 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * The Timeline service. |
|
| 327 | - */ |
|
| 328 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * The Topic Taxonomy service. |
|
| 332 | - */ |
|
| 333 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 334 | - |
|
| 335 | - |
|
| 336 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 340 | - */ |
|
| 341 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * The class to customize the entity list admin page. |
|
| 345 | - */ |
|
| 346 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 350 | - */ |
|
| 351 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * The Notice service. |
|
| 355 | - */ |
|
| 356 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * The PrimaShop adapter. |
|
| 360 | - */ |
|
| 361 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 362 | - |
|
| 363 | - /** |
|
| 364 | - * The WordLift Dashboard service. |
|
| 365 | - */ |
|
| 366 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 370 | - * side of the site. |
|
| 371 | - */ |
|
| 372 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 373 | - |
|
| 374 | - /** |
|
| 375 | - * The shortcode abstract class. |
|
| 376 | - */ |
|
| 377 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * The Timeline shortcode. |
|
| 381 | - */ |
|
| 382 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.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 | + /** |
|
| 216 | + * Define the core functionality of the plugin. |
|
| 217 | + * |
|
| 218 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 219 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 220 | + * the public-facing side of the site. |
|
| 221 | + * |
|
| 222 | + * @since 1.0.0 |
|
| 223 | + */ |
|
| 224 | + public function __construct() { |
|
| 225 | + |
|
| 226 | + $this->plugin_name = 'wordlift'; |
|
| 227 | + $this->version = '3.6.0-dev'; |
|
| 228 | + $this->load_dependencies(); |
|
| 229 | + $this->set_locale(); |
|
| 230 | + $this->define_admin_hooks(); |
|
| 231 | + $this->define_public_hooks(); |
|
| 232 | + |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * Load the required dependencies for this plugin. |
|
| 237 | + * |
|
| 238 | + * Include the following files that make up the plugin: |
|
| 239 | + * |
|
| 240 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 241 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 242 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 243 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 244 | + * |
|
| 245 | + * Create an instance of the loader which will be used to register the hooks |
|
| 246 | + * with WordPress. |
|
| 247 | + * |
|
| 248 | + * @since 1.0.0 |
|
| 249 | + * @access private |
|
| 250 | + */ |
|
| 251 | + private function load_dependencies() { |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * The class responsible for orchestrating the actions and filters of the |
|
| 255 | + * core plugin. |
|
| 256 | + */ |
|
| 257 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * The class responsible for defining internationalization functionality |
|
| 261 | + * of the plugin. |
|
| 262 | + */ |
|
| 263 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * Provide support functions to sanitize data. |
|
| 267 | + */ |
|
| 268 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * The Redirect service. |
|
| 272 | + */ |
|
| 273 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * The Log service. |
|
| 277 | + */ |
|
| 278 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * The entity post type service. |
|
| 282 | + */ |
|
| 283 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * The entity link service. |
|
| 287 | + */ |
|
| 288 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * The Query builder. |
|
| 292 | + */ |
|
| 293 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * The Schema service. |
|
| 297 | + */ |
|
| 298 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * The UI service. |
|
| 302 | + */ |
|
| 303 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * The Thumbnail service. |
|
| 307 | + */ |
|
| 308 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 309 | + |
|
| 310 | + /** |
|
| 311 | + * The Entity Types Taxonomy service. |
|
| 312 | + */ |
|
| 313 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * The Entity service. |
|
| 317 | + */ |
|
| 318 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 319 | + |
|
| 320 | + /** |
|
| 321 | + * The User service. |
|
| 322 | + */ |
|
| 323 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * The Timeline service. |
|
| 327 | + */ |
|
| 328 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * The Topic Taxonomy service. |
|
| 332 | + */ |
|
| 333 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 334 | + |
|
| 335 | + |
|
| 336 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 340 | + */ |
|
| 341 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * The class to customize the entity list admin page. |
|
| 345 | + */ |
|
| 346 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 350 | + */ |
|
| 351 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * The Notice service. |
|
| 355 | + */ |
|
| 356 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * The PrimaShop adapter. |
|
| 360 | + */ |
|
| 361 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 362 | + |
|
| 363 | + /** |
|
| 364 | + * The WordLift Dashboard service. |
|
| 365 | + */ |
|
| 366 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 367 | + |
|
| 368 | + /** |
|
| 369 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 370 | + * side of the site. |
|
| 371 | + */ |
|
| 372 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 373 | + |
|
| 374 | + /** |
|
| 375 | + * The shortcode abstract class. |
|
| 376 | + */ |
|
| 377 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * The Timeline shortcode. |
|
| 381 | + */ |
|
| 382 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 383 | 383 | |
| 384 | - /** |
|
| 385 | - * The Navigator shortcode. |
|
| 386 | - */ |
|
| 387 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * The chord shortcode. |
|
| 391 | - */ |
|
| 392 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 384 | + /** |
|
| 385 | + * The Navigator shortcode. |
|
| 386 | + */ |
|
| 387 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * The chord shortcode. |
|
| 391 | + */ |
|
| 392 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 393 | 393 | |
| 394 | - /** |
|
| 395 | - * The geomap shortcode. |
|
| 396 | - */ |
|
| 397 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 394 | + /** |
|
| 395 | + * The geomap shortcode. |
|
| 396 | + */ |
|
| 397 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 398 | 398 | |
| 399 | - /** |
|
| 400 | - * The ShareThis service. |
|
| 401 | - */ |
|
| 402 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 399 | + /** |
|
| 400 | + * The ShareThis service. |
|
| 401 | + */ |
|
| 402 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 403 | 403 | |
| 404 | - $this->loader = new Wordlift_Loader(); |
|
| 404 | + $this->loader = new Wordlift_Loader(); |
|
| 405 | 405 | |
| 406 | - // Instantiate a global logger. |
|
| 407 | - global $wl_logger; |
|
| 408 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 406 | + // Instantiate a global logger. |
|
| 407 | + global $wl_logger; |
|
| 408 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 409 | 409 | |
| 410 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 411 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( Wordlift_Entity_Service::TYPE_NAME, WL_ENTITY_TYPE_SLUG ); |
|
| 410 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 411 | + $this->entity_type_service = new Wordlift_Entity_Type_Service( Wordlift_Entity_Service::TYPE_NAME, WL_ENTITY_TYPE_SLUG ); |
|
| 412 | 412 | |
| 413 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 414 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_type_service, WL_ENTITY_TYPE_SLUG ); |
|
| 413 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 414 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_type_service, WL_ENTITY_TYPE_SLUG ); |
|
| 415 | 415 | |
| 416 | - // Create an instance of the UI service. |
|
| 417 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 416 | + // Create an instance of the UI service. |
|
| 417 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 418 | 418 | |
| 419 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 420 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 419 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 420 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 421 | 421 | |
| 422 | - // Create an instance of the Schema service. |
|
| 423 | - $this->schema_service = new Wordlift_Schema_Service(); |
|
| 422 | + // Create an instance of the Schema service. |
|
| 423 | + $this->schema_service = new Wordlift_Schema_Service(); |
|
| 424 | 424 | |
| 425 | - // Create an instance of the Notice service. |
|
| 426 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 425 | + // Create an instance of the Notice service. |
|
| 426 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 427 | 427 | |
| 428 | - // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 429 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 428 | + // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 429 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 430 | 430 | |
| 431 | - // Create an instance of the User service. |
|
| 432 | - $this->user_service = new Wordlift_User_Service(); |
|
| 431 | + // Create an instance of the User service. |
|
| 432 | + $this->user_service = new Wordlift_User_Service(); |
|
| 433 | 433 | |
| 434 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 435 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 434 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 435 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 436 | 436 | |
| 437 | - // Create a new instance of the Redirect service. |
|
| 438 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 437 | + // Create a new instance of the Redirect service. |
|
| 438 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 439 | 439 | |
| 440 | - // Create a new instance of the Redirect service. |
|
| 441 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 440 | + // Create a new instance of the Redirect service. |
|
| 441 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 442 | 442 | |
| 443 | - // Initialize the shortcodes. |
|
| 444 | - new Wordlift_Navigator_Shortcode(); |
|
| 445 | - new Wordlift_Chord_Shortcode(); |
|
| 446 | - new Wordlift_Geomap_Shortcode(); |
|
| 447 | - new Wordlift_Timeline_Shortcode(); |
|
| 443 | + // Initialize the shortcodes. |
|
| 444 | + new Wordlift_Navigator_Shortcode(); |
|
| 445 | + new Wordlift_Chord_Shortcode(); |
|
| 446 | + new Wordlift_Geomap_Shortcode(); |
|
| 447 | + new Wordlift_Timeline_Shortcode(); |
|
| 448 | 448 | |
| 449 | - // Create entity list customization (wp-admin/edit.php) |
|
| 450 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 449 | + // Create entity list customization (wp-admin/edit.php) |
|
| 450 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 451 | 451 | |
| 452 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 453 | - |
|
| 454 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 452 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 453 | + |
|
| 454 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 455 | 455 | |
| 456 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 457 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 456 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 457 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 458 | 458 | |
| 459 | - // Create an instance of the PrimaShop adapter. |
|
| 460 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 459 | + // Create an instance of the PrimaShop adapter. |
|
| 460 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 461 | 461 | |
| 462 | - $this->page_service = new Wordlift_Page_Service(); |
|
| 463 | - } |
|
| 462 | + $this->page_service = new Wordlift_Page_Service(); |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | - /** |
|
| 466 | - * Define the locale for this plugin for internationalization. |
|
| 467 | - * |
|
| 468 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 469 | - * with WordPress. |
|
| 470 | - * |
|
| 471 | - * @since 1.0.0 |
|
| 472 | - * @access private |
|
| 473 | - */ |
|
| 474 | - private function set_locale() { |
|
| 465 | + /** |
|
| 466 | + * Define the locale for this plugin for internationalization. |
|
| 467 | + * |
|
| 468 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 469 | + * with WordPress. |
|
| 470 | + * |
|
| 471 | + * @since 1.0.0 |
|
| 472 | + * @access private |
|
| 473 | + */ |
|
| 474 | + private function set_locale() { |
|
| 475 | 475 | |
| 476 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 477 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 476 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 477 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 478 | 478 | |
| 479 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 479 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 480 | 480 | |
| 481 | - } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - /** |
|
| 484 | - * Register all of the hooks related to the admin area functionality |
|
| 485 | - * of the plugin. |
|
| 486 | - * |
|
| 487 | - * @since 1.0.0 |
|
| 488 | - * @access private |
|
| 489 | - */ |
|
| 490 | - private function define_admin_hooks() { |
|
| 483 | + /** |
|
| 484 | + * Register all of the hooks related to the admin area functionality |
|
| 485 | + * of the plugin. |
|
| 486 | + * |
|
| 487 | + * @since 1.0.0 |
|
| 488 | + * @access private |
|
| 489 | + */ |
|
| 490 | + private function define_admin_hooks() { |
|
| 491 | 491 | |
| 492 | - $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 492 | + $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 493 | 493 | |
| 494 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 495 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 494 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 495 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 496 | 496 | |
| 497 | - // Hook the init action to the Topic Taxonomy service. |
|
| 498 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 497 | + // Hook the init action to the Topic Taxonomy service. |
|
| 498 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 499 | 499 | |
| 500 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 501 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 500 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 501 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 502 | 502 | |
| 503 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 504 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 503 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 504 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 505 | 505 | |
| 506 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 507 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 508 | - |
|
| 509 | - // Hook posts inserts (or updates) to the user service. |
|
| 510 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 511 | - |
|
| 512 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 513 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 514 | - |
|
| 515 | - // Register custom allowed redirect hosts. |
|
| 516 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 517 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 518 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 519 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 520 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 521 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 522 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 523 | - |
|
| 524 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 525 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 526 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 527 | - $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 528 | - |
|
| 529 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 530 | - $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 531 | - |
|
| 532 | - // Entity listing customization (wp-admin/edit.php) |
|
| 533 | - // Add custom columns |
|
| 534 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 535 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 536 | - // Add 4W selection |
|
| 537 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 538 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 539 | - |
|
| 540 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 541 | - |
|
| 542 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 543 | - // entities. |
|
| 544 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - /** |
|
| 548 | - * Register all of the hooks related to the public-facing functionality |
|
| 549 | - * of the plugin. |
|
| 550 | - * |
|
| 551 | - * @since 1.0.0 |
|
| 552 | - * @access private |
|
| 553 | - */ |
|
| 554 | - private function define_public_hooks() { |
|
| 555 | - |
|
| 556 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 557 | - |
|
| 558 | - // Register the entity post type. |
|
| 559 | - $this->loader->add_action( 'init', $this->entity_type_service, 'register' ); |
|
| 560 | - |
|
| 561 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 562 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 563 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 564 | - $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 ); |
|
| 565 | - $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 ); |
|
| 566 | - |
|
| 567 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 568 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 569 | - |
|
| 570 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 571 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 572 | - |
|
| 573 | - // Hook the ShareThis service. |
|
| 574 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 575 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 576 | - |
|
| 577 | - $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 578 | - $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 579 | - |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - /** |
|
| 583 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 584 | - * |
|
| 585 | - * @since 1.0.0 |
|
| 586 | - */ |
|
| 587 | - public function run() { |
|
| 588 | - $this->loader->run(); |
|
| 589 | - } |
|
| 590 | - |
|
| 591 | - /** |
|
| 592 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 593 | - * WordPress and to define internationalization functionality. |
|
| 594 | - * |
|
| 595 | - * @since 1.0.0 |
|
| 596 | - * @return string The name of the plugin. |
|
| 597 | - */ |
|
| 598 | - public function get_plugin_name() { |
|
| 599 | - return $this->plugin_name; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - /** |
|
| 603 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 604 | - * |
|
| 605 | - * @since 1.0.0 |
|
| 606 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 607 | - */ |
|
| 608 | - public function get_loader() { |
|
| 609 | - return $this->loader; |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - /** |
|
| 613 | - * Retrieve the version number of the plugin. |
|
| 614 | - * |
|
| 615 | - * @since 1.0.0 |
|
| 616 | - * @return string The version number of the plugin. |
|
| 617 | - */ |
|
| 618 | - public function get_version() { |
|
| 619 | - return $this->version; |
|
| 620 | - } |
|
| 506 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 507 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 508 | + |
|
| 509 | + // Hook posts inserts (or updates) to the user service. |
|
| 510 | + $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 511 | + |
|
| 512 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 513 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 514 | + |
|
| 515 | + // Register custom allowed redirect hosts. |
|
| 516 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 517 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 518 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 519 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 520 | + $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 521 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 522 | + $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 523 | + |
|
| 524 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 525 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 526 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 527 | + $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 528 | + |
|
| 529 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 530 | + $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 531 | + |
|
| 532 | + // Entity listing customization (wp-admin/edit.php) |
|
| 533 | + // Add custom columns |
|
| 534 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 535 | + $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 536 | + // Add 4W selection |
|
| 537 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 538 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 539 | + |
|
| 540 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 541 | + |
|
| 542 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 543 | + // entities. |
|
| 544 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + /** |
|
| 548 | + * Register all of the hooks related to the public-facing functionality |
|
| 549 | + * of the plugin. |
|
| 550 | + * |
|
| 551 | + * @since 1.0.0 |
|
| 552 | + * @access private |
|
| 553 | + */ |
|
| 554 | + private function define_public_hooks() { |
|
| 555 | + |
|
| 556 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 557 | + |
|
| 558 | + // Register the entity post type. |
|
| 559 | + $this->loader->add_action( 'init', $this->entity_type_service, 'register' ); |
|
| 560 | + |
|
| 561 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 562 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 563 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 564 | + $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 ); |
|
| 565 | + $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 ); |
|
| 566 | + |
|
| 567 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 568 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 569 | + |
|
| 570 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 571 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 572 | + |
|
| 573 | + // Hook the ShareThis service. |
|
| 574 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 575 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 576 | + |
|
| 577 | + $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 578 | + $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 579 | + |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + /** |
|
| 583 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 584 | + * |
|
| 585 | + * @since 1.0.0 |
|
| 586 | + */ |
|
| 587 | + public function run() { |
|
| 588 | + $this->loader->run(); |
|
| 589 | + } |
|
| 590 | + |
|
| 591 | + /** |
|
| 592 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 593 | + * WordPress and to define internationalization functionality. |
|
| 594 | + * |
|
| 595 | + * @since 1.0.0 |
|
| 596 | + * @return string The name of the plugin. |
|
| 597 | + */ |
|
| 598 | + public function get_plugin_name() { |
|
| 599 | + return $this->plugin_name; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + /** |
|
| 603 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 604 | + * |
|
| 605 | + * @since 1.0.0 |
|
| 606 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 607 | + */ |
|
| 608 | + public function get_loader() { |
|
| 609 | + return $this->loader; |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + /** |
|
| 613 | + * Retrieve the version number of the plugin. |
|
| 614 | + * |
|
| 615 | + * @since 1.0.0 |
|
| 616 | + * @return string The version number of the plugin. |
|
| 617 | + */ |
|
| 618 | + public function get_version() { |
|
| 619 | + return $this->version; |
|
| 620 | + } |
|
| 621 | 621 | |
| 622 | 622 | } |
@@ -254,164 +254,164 @@ discard block |
||
| 254 | 254 | * The class responsible for orchestrating the actions and filters of the |
| 255 | 255 | * core plugin. |
| 256 | 256 | */ |
| 257 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 257 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php'; |
|
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | 260 | * The class responsible for defining internationalization functionality |
| 261 | 261 | * of the plugin. |
| 262 | 262 | */ |
| 263 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 263 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php'; |
|
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | 266 | * Provide support functions to sanitize data. |
| 267 | 267 | */ |
| 268 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 268 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php'; |
|
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * The Redirect service. |
| 272 | 272 | */ |
| 273 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 273 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php'; |
|
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | 276 | * The Log service. |
| 277 | 277 | */ |
| 278 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 278 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php'; |
|
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | 281 | * The entity post type service. |
| 282 | 282 | */ |
| 283 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 283 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php'; |
|
| 284 | 284 | |
| 285 | 285 | /** |
| 286 | 286 | * The entity link service. |
| 287 | 287 | */ |
| 288 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 288 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php'; |
|
| 289 | 289 | |
| 290 | 290 | /** |
| 291 | 291 | * The Query builder. |
| 292 | 292 | */ |
| 293 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 293 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php'; |
|
| 294 | 294 | |
| 295 | 295 | /** |
| 296 | 296 | * The Schema service. |
| 297 | 297 | */ |
| 298 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 298 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php'; |
|
| 299 | 299 | |
| 300 | 300 | /** |
| 301 | 301 | * The UI service. |
| 302 | 302 | */ |
| 303 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 303 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php'; |
|
| 304 | 304 | |
| 305 | 305 | /** |
| 306 | 306 | * The Thumbnail service. |
| 307 | 307 | */ |
| 308 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 308 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php'; |
|
| 309 | 309 | |
| 310 | 310 | /** |
| 311 | 311 | * The Entity Types Taxonomy service. |
| 312 | 312 | */ |
| 313 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 313 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 314 | 314 | |
| 315 | 315 | /** |
| 316 | 316 | * The Entity service. |
| 317 | 317 | */ |
| 318 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 318 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php'; |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * The User service. |
| 322 | 322 | */ |
| 323 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 323 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php'; |
|
| 324 | 324 | |
| 325 | 325 | /** |
| 326 | 326 | * The Timeline service. |
| 327 | 327 | */ |
| 328 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 328 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php'; |
|
| 329 | 329 | |
| 330 | 330 | /** |
| 331 | 331 | * The Topic Taxonomy service. |
| 332 | 332 | */ |
| 333 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 333 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 334 | 334 | |
| 335 | 335 | |
| 336 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 336 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-page-service.php'; |
|
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | 339 | * The class responsible for defining all actions that occur in the admin area. |
| 340 | 340 | */ |
| 341 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 341 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php'; |
|
| 342 | 342 | |
| 343 | 343 | /** |
| 344 | 344 | * The class to customize the entity list admin page. |
| 345 | 345 | */ |
| 346 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 346 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php'; |
|
| 347 | 347 | |
| 348 | 348 | /** |
| 349 | 349 | * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
| 350 | 350 | */ |
| 351 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 351 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 352 | 352 | |
| 353 | 353 | /** |
| 354 | 354 | * The Notice service. |
| 355 | 355 | */ |
| 356 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 356 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php'; |
|
| 357 | 357 | |
| 358 | 358 | /** |
| 359 | 359 | * The PrimaShop adapter. |
| 360 | 360 | */ |
| 361 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 361 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php'; |
|
| 362 | 362 | |
| 363 | 363 | /** |
| 364 | 364 | * The WordLift Dashboard service. |
| 365 | 365 | */ |
| 366 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 366 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php'; |
|
| 367 | 367 | |
| 368 | 368 | /** |
| 369 | 369 | * The class responsible for defining all actions that occur in the public-facing |
| 370 | 370 | * side of the site. |
| 371 | 371 | */ |
| 372 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 372 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php'; |
|
| 373 | 373 | |
| 374 | 374 | /** |
| 375 | 375 | * The shortcode abstract class. |
| 376 | 376 | */ |
| 377 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 377 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php'; |
|
| 378 | 378 | |
| 379 | 379 | /** |
| 380 | 380 | * The Timeline shortcode. |
| 381 | 381 | */ |
| 382 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 382 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php'; |
|
| 383 | 383 | |
| 384 | 384 | /** |
| 385 | 385 | * The Navigator shortcode. |
| 386 | 386 | */ |
| 387 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 387 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php'; |
|
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | 390 | * The chord shortcode. |
| 391 | 391 | */ |
| 392 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 392 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php'; |
|
| 393 | 393 | |
| 394 | 394 | /** |
| 395 | 395 | * The geomap shortcode. |
| 396 | 396 | */ |
| 397 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 397 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php'; |
|
| 398 | 398 | |
| 399 | 399 | /** |
| 400 | 400 | * The ShareThis service. |
| 401 | 401 | */ |
| 402 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 402 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php'; |
|
| 403 | 403 | |
| 404 | 404 | $this->loader = new Wordlift_Loader(); |
| 405 | 405 | |
| 406 | 406 | // Instantiate a global logger. |
| 407 | 407 | global $wl_logger; |
| 408 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 408 | + $wl_logger = Wordlift_Log_Service::get_logger('WordLift'); |
|
| 409 | 409 | |
| 410 | 410 | // Create an entity type service instance. It'll be later bound to the init action. |
| 411 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( Wordlift_Entity_Service::TYPE_NAME, WL_ENTITY_TYPE_SLUG ); |
|
| 411 | + $this->entity_type_service = new Wordlift_Entity_Type_Service(Wordlift_Entity_Service::TYPE_NAME, WL_ENTITY_TYPE_SLUG); |
|
| 412 | 412 | |
| 413 | 413 | // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
| 414 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_type_service, WL_ENTITY_TYPE_SLUG ); |
|
| 414 | + $this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_type_service, WL_ENTITY_TYPE_SLUG); |
|
| 415 | 415 | |
| 416 | 416 | // Create an instance of the UI service. |
| 417 | 417 | $this->ui_service = new Wordlift_UI_Service(); |
@@ -426,19 +426,19 @@ discard block |
||
| 426 | 426 | $this->notice_service = new Wordlift_Notice_Service(); |
| 427 | 427 | |
| 428 | 428 | // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
| 429 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 429 | + $this->entity_service = new Wordlift_Entity_Service($this->ui_service, $this->schema_service, $this->notice_service); |
|
| 430 | 430 | |
| 431 | 431 | // Create an instance of the User service. |
| 432 | 432 | $this->user_service = new Wordlift_User_Service(); |
| 433 | 433 | |
| 434 | 434 | // Create a new instance of the Timeline service and Timeline shortcode. |
| 435 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 435 | + $this->timeline_service = new Wordlift_Timeline_Service($this->entity_service); |
|
| 436 | 436 | |
| 437 | 437 | // Create a new instance of the Redirect service. |
| 438 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 438 | + $this->redirect_service = new Wordlift_Redirect_Service($this->entity_service); |
|
| 439 | 439 | |
| 440 | 440 | // Create a new instance of the Redirect service. |
| 441 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 441 | + $this->dashboard_service = new Wordlift_Dashboard_Service($this->entity_service); |
|
| 442 | 442 | |
| 443 | 443 | // Initialize the shortcodes. |
| 444 | 444 | new Wordlift_Navigator_Shortcode(); |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | new Wordlift_Timeline_Shortcode(); |
| 448 | 448 | |
| 449 | 449 | // Create entity list customization (wp-admin/edit.php) |
| 450 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 450 | + $this->entity_list_service = new Wordlift_Entity_List_Service($this->entity_service); |
|
| 451 | 451 | |
| 452 | 452 | $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
| 453 | 453 | |
@@ -474,9 +474,9 @@ discard block |
||
| 474 | 474 | private function set_locale() { |
| 475 | 475 | |
| 476 | 476 | $plugin_i18n = new Wordlift_i18n(); |
| 477 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 477 | + $plugin_i18n->set_domain($this->get_plugin_name()); |
|
| 478 | 478 | |
| 479 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 479 | + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
| 480 | 480 | |
| 481 | 481 | } |
| 482 | 482 | |
@@ -489,59 +489,59 @@ discard block |
||
| 489 | 489 | */ |
| 490 | 490 | private function define_admin_hooks() { |
| 491 | 491 | |
| 492 | - $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 492 | + $plugin_admin = new Wordlift_Admin($this->get_plugin_name(), $this->get_version()); |
|
| 493 | 493 | |
| 494 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 495 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 494 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
| 495 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); |
|
| 496 | 496 | |
| 497 | 497 | // Hook the init action to the Topic Taxonomy service. |
| 498 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 498 | + $this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0); |
|
| 499 | 499 | |
| 500 | 500 | // Hook the deleted_post_meta action to the Thumbnail service. |
| 501 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 501 | + $this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4); |
|
| 502 | 502 | |
| 503 | 503 | // Hook the added_post_meta action to the Thumbnail service. |
| 504 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 504 | + $this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 505 | 505 | |
| 506 | 506 | // Hook the updated_post_meta action to the Thumbnail service. |
| 507 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 507 | + $this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 508 | 508 | |
| 509 | 509 | // Hook posts inserts (or updates) to the user service. |
| 510 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 510 | + $this->loader->add_action('wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3); |
|
| 511 | 511 | |
| 512 | 512 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 513 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 513 | + $this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 514 | 514 | |
| 515 | 515 | // Register custom allowed redirect hosts. |
| 516 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 516 | + $this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts'); |
|
| 517 | 517 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 518 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 518 | + $this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect'); |
|
| 519 | 519 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 520 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 520 | + $this->loader->add_action('wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats'); |
|
| 521 | 521 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 522 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 522 | + $this->loader->add_action('wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets'); |
|
| 523 | 523 | |
| 524 | 524 | // Hook save_post to the entity service to update custom fields (such as alternate labels). |
| 525 | 525 | // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
| 526 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 527 | - $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 526 | + $this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3); |
|
| 527 | + $this->loader->add_action('save_post_entity', $this->entity_service, 'set_rating_for', 10, 1); |
|
| 528 | 528 | |
| 529 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 530 | - $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 529 | + $this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1); |
|
| 530 | + $this->loader->add_action('in_admin_header', $this->entity_service, 'in_admin_header'); |
|
| 531 | 531 | |
| 532 | 532 | // Entity listing customization (wp-admin/edit.php) |
| 533 | 533 | // Add custom columns |
| 534 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 535 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 534 | + $this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns'); |
|
| 535 | + $this->loader->add_filter('manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2); |
|
| 536 | 536 | // Add 4W selection |
| 537 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 538 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 537 | + $this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope'); |
|
| 538 | + $this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope'); |
|
| 539 | 539 | |
| 540 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 540 | + $this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args'); |
|
| 541 | 541 | |
| 542 | 542 | // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
| 543 | 543 | // entities. |
| 544 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 544 | + $this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -553,29 +553,29 @@ discard block |
||
| 553 | 553 | */ |
| 554 | 554 | private function define_public_hooks() { |
| 555 | 555 | |
| 556 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 556 | + $plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version()); |
|
| 557 | 557 | |
| 558 | 558 | // Register the entity post type. |
| 559 | - $this->loader->add_action( 'init', $this->entity_type_service, 'register' ); |
|
| 559 | + $this->loader->add_action('init', $this->entity_type_service, 'register'); |
|
| 560 | 560 | |
| 561 | 561 | // Bind the link generation and handling hooks to the entity link service. |
| 562 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 563 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 564 | - $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 ); |
|
| 565 | - $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 ); |
|
| 562 | + $this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4); |
|
| 563 | + $this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1); |
|
| 564 | + $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); |
|
| 565 | + $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); |
|
| 566 | 566 | |
| 567 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 568 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 567 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
| 568 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
| 569 | 569 | |
| 570 | 570 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 571 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 571 | + $this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 572 | 572 | |
| 573 | 573 | // Hook the ShareThis service. |
| 574 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 575 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 574 | + $this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99); |
|
| 575 | + $this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99); |
|
| 576 | 576 | |
| 577 | - $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 578 | - $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 577 | + $this->loader->add_action('wp_head', $this->page_service, 'wp_head', PHP_INT_MAX); |
|
| 578 | + $this->loader->add_action('wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX); |
|
| 579 | 579 | |
| 580 | 580 | } |
| 581 | 581 | |