@@ -17,53 +17,53 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | interface Wordlift_Cache_Service { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Get the cached response for the specified `id`. |
|
| 22 | - * |
|
| 23 | - * @since 3.16.0 |
|
| 24 | - * |
|
| 25 | - * @param string $id The cache `id`. |
|
| 26 | - * |
|
| 27 | - * @return mixed|false The cached contents or false if the cache isn't found. |
|
| 28 | - */ |
|
| 29 | - function get_cache( $id ); |
|
| 20 | + /** |
|
| 21 | + * Get the cached response for the specified `id`. |
|
| 22 | + * |
|
| 23 | + * @since 3.16.0 |
|
| 24 | + * |
|
| 25 | + * @param string $id The cache `id`. |
|
| 26 | + * |
|
| 27 | + * @return mixed|false The cached contents or false if the cache isn't found. |
|
| 28 | + */ |
|
| 29 | + function get_cache( $id ); |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Check whether we have cached results for the provided id. |
|
| 33 | - * |
|
| 34 | - * @since 3.16.3 |
|
| 35 | - * |
|
| 36 | - * @param string $id The cache `id`. |
|
| 37 | - * |
|
| 38 | - * @return bool True if we have cached results otherwise false. |
|
| 39 | - */ |
|
| 40 | - function has_cache( $id ); |
|
| 31 | + /** |
|
| 32 | + * Check whether we have cached results for the provided id. |
|
| 33 | + * |
|
| 34 | + * @since 3.16.3 |
|
| 35 | + * |
|
| 36 | + * @param string $id The cache `id`. |
|
| 37 | + * |
|
| 38 | + * @return bool True if we have cached results otherwise false. |
|
| 39 | + */ |
|
| 40 | + function has_cache( $id ); |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Set the cache contents for the specified `id`. |
|
| 44 | - * |
|
| 45 | - * @since 3.16.0 |
|
| 46 | - * |
|
| 47 | - * @param string $id The cache id. |
|
| 48 | - * @param mixed $contents The cache contents. |
|
| 49 | - */ |
|
| 50 | - function set_cache( $id, $contents ); |
|
| 42 | + /** |
|
| 43 | + * Set the cache contents for the specified `id`. |
|
| 44 | + * |
|
| 45 | + * @since 3.16.0 |
|
| 46 | + * |
|
| 47 | + * @param string $id The cache id. |
|
| 48 | + * @param mixed $contents The cache contents. |
|
| 49 | + */ |
|
| 50 | + function set_cache( $id, $contents ); |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Delete the cache for the specified `id`. |
|
| 55 | - * |
|
| 56 | - * @since 3.16.0 |
|
| 57 | - * |
|
| 58 | - * @param string $id The cache `id`. |
|
| 59 | - */ |
|
| 60 | - function delete_cache( $id ); |
|
| 53 | + /** |
|
| 54 | + * Delete the cache for the specified `id`. |
|
| 55 | + * |
|
| 56 | + * @since 3.16.0 |
|
| 57 | + * |
|
| 58 | + * @param string $id The cache `id`. |
|
| 59 | + */ |
|
| 60 | + function delete_cache( $id ); |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Flush the whole cache. |
|
| 64 | - * |
|
| 65 | - * @since 3.16.0 |
|
| 66 | - */ |
|
| 67 | - function flush(); |
|
| 62 | + /** |
|
| 63 | + * Flush the whole cache. |
|
| 64 | + * |
|
| 65 | + * @since 3.16.0 |
|
| 66 | + */ |
|
| 67 | + function flush(); |
|
| 68 | 68 | |
| 69 | 69 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return mixed|false The cached contents or false if the cache isn't found. |
| 28 | 28 | */ |
| 29 | - function get_cache( $id ); |
|
| 29 | + function get_cache($id); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Check whether we have cached results for the provided id. |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return bool True if we have cached results otherwise false. |
| 39 | 39 | */ |
| 40 | - function has_cache( $id ); |
|
| 40 | + function has_cache($id); |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Set the cache contents for the specified `id`. |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param string $id The cache id. |
| 48 | 48 | * @param mixed $contents The cache contents. |
| 49 | 49 | */ |
| 50 | - function set_cache( $id, $contents ); |
|
| 50 | + function set_cache($id, $contents); |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @param string $id The cache `id`. |
| 59 | 59 | */ |
| 60 | - function delete_cache( $id ); |
|
| 60 | + function delete_cache($id); |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * Flush the whole cache. |
@@ -18,15 +18,15 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | interface Wordlift_Admin_Element { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Render the element. |
|
| 23 | - * |
|
| 24 | - * @since 3.11.0 |
|
| 25 | - * |
|
| 26 | - * @param array $args An array of parameters. |
|
| 27 | - * |
|
| 28 | - * @return \Wordlift_Admin_Element The element instance. |
|
| 29 | - */ |
|
| 30 | - public function render( $args ); |
|
| 21 | + /** |
|
| 22 | + * Render the element. |
|
| 23 | + * |
|
| 24 | + * @since 3.11.0 |
|
| 25 | + * |
|
| 26 | + * @param array $args An array of parameters. |
|
| 27 | + * |
|
| 28 | + * @return \Wordlift_Admin_Element The element instance. |
|
| 29 | + */ |
|
| 30 | + public function render( $args ); |
|
| 31 | 31 | |
| 32 | 32 | } |
@@ -27,6 +27,6 @@ |
||
| 27 | 27 | * |
| 28 | 28 | * @return \Wordlift_Admin_Element The element instance. |
| 29 | 29 | */ |
| 30 | - public function render( $args ); |
|
| 30 | + public function render($args); |
|
| 31 | 31 | |
| 32 | 32 | } |
@@ -17,52 +17,52 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | class Wordlift_Entity_Page_Service { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Set the entity post types as one to be included in archive pages. |
|
| 22 | - * |
|
| 23 | - * In order to have entities show up in standard WP categories (Posts categories) |
|
| 24 | - * we configure the `entity` post type, but we also need to alter the main |
|
| 25 | - * WP query (which by default queries posts only) to include the `entities`. |
|
| 26 | - * |
|
| 27 | - * @since 3.12.0 |
|
| 28 | - * |
|
| 29 | - * @param WP_Query $query WP's {@link WP_Query} instance. |
|
| 30 | - */ |
|
| 31 | - public function pre_get_posts( $query ) { |
|
| 32 | - |
|
| 33 | - // Only for the main query, avoid problems with widgets and what not. |
|
| 34 | - if ( ! $query->is_main_query() ) { |
|
| 35 | - return; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - // We don't want to alter the query if we're in the admin UI, if this is |
|
| 39 | - // not a entity type achieve query, or if the `suppress_filters` is set. |
|
| 40 | - // |
|
| 41 | - // Note that it is unlikely for `suppress_filter` to be set on the front |
|
| 42 | - // end, but let's be safe if it is set the calling code assumes no |
|
| 43 | - // modifications of queries. |
|
| 44 | - |
|
| 45 | - // Ignore admin side request, requests for which filters should be |
|
| 46 | - // suppressed, and when we are not on a entity type archive page. |
|
| 47 | - if ( is_admin() || |
|
| 48 | - ! is_tax( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) || |
|
| 49 | - ! empty( $query->query_vars['suppress_filters'] ) |
|
| 50 | - ) { |
|
| 51 | - return; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // Events should be sorted by start date in descending order. |
|
| 55 | - if ( is_tax( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, 'event' ) ) { |
|
| 56 | - |
|
| 57 | - // Update the query to use the start time meta and desc order. |
|
| 58 | - $meta_query[] = array( |
|
| 59 | - 'key' => Wordlift_Schema_Service::FIELD_DATE_START, |
|
| 60 | - ); |
|
| 61 | - $query->set( 'meta_query', $meta_query ); |
|
| 62 | - $query->set( 'orderby', 'meta_value' ); |
|
| 63 | - $query->set( 'order', 'DESC' ); |
|
| 64 | - } else { |
|
| 65 | - /* |
|
| 20 | + /** |
|
| 21 | + * Set the entity post types as one to be included in archive pages. |
|
| 22 | + * |
|
| 23 | + * In order to have entities show up in standard WP categories (Posts categories) |
|
| 24 | + * we configure the `entity` post type, but we also need to alter the main |
|
| 25 | + * WP query (which by default queries posts only) to include the `entities`. |
|
| 26 | + * |
|
| 27 | + * @since 3.12.0 |
|
| 28 | + * |
|
| 29 | + * @param WP_Query $query WP's {@link WP_Query} instance. |
|
| 30 | + */ |
|
| 31 | + public function pre_get_posts( $query ) { |
|
| 32 | + |
|
| 33 | + // Only for the main query, avoid problems with widgets and what not. |
|
| 34 | + if ( ! $query->is_main_query() ) { |
|
| 35 | + return; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + // We don't want to alter the query if we're in the admin UI, if this is |
|
| 39 | + // not a entity type achieve query, or if the `suppress_filters` is set. |
|
| 40 | + // |
|
| 41 | + // Note that it is unlikely for `suppress_filter` to be set on the front |
|
| 42 | + // end, but let's be safe if it is set the calling code assumes no |
|
| 43 | + // modifications of queries. |
|
| 44 | + |
|
| 45 | + // Ignore admin side request, requests for which filters should be |
|
| 46 | + // suppressed, and when we are not on a entity type archive page. |
|
| 47 | + if ( is_admin() || |
|
| 48 | + ! is_tax( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) || |
|
| 49 | + ! empty( $query->query_vars['suppress_filters'] ) |
|
| 50 | + ) { |
|
| 51 | + return; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // Events should be sorted by start date in descending order. |
|
| 55 | + if ( is_tax( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, 'event' ) ) { |
|
| 56 | + |
|
| 57 | + // Update the query to use the start time meta and desc order. |
|
| 58 | + $meta_query[] = array( |
|
| 59 | + 'key' => Wordlift_Schema_Service::FIELD_DATE_START, |
|
| 60 | + ); |
|
| 61 | + $query->set( 'meta_query', $meta_query ); |
|
| 62 | + $query->set( 'orderby', 'meta_value' ); |
|
| 63 | + $query->set( 'order', 'DESC' ); |
|
| 64 | + } else { |
|
| 65 | + /* |
|
| 66 | 66 | * All other entity types should be sorted by their connectivity. |
| 67 | 67 | * For this we need to query the relationship table which has |
| 68 | 68 | * to be done by manipulating the SQL generated for the query. |
@@ -70,73 +70,73 @@ discard block |
||
| 70 | 70 | * additional filters to handle it. |
| 71 | 71 | */ |
| 72 | 72 | |
| 73 | - add_filter( 'posts_join', array( $this, 'posts_join' ) ); |
|
| 74 | - add_filter( 'posts_groupby', array( $this, 'posts_groupby' ) ); |
|
| 75 | - add_filter( 'posts_orderby', array( $this, 'posts_orderby' ) ); |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Filter handler that sets the join part of a query to include the |
|
| 81 | - * relationship table to be able to use it in the sorting. |
|
| 82 | - * |
|
| 83 | - * @since 3.15.0 |
|
| 84 | - * |
|
| 85 | - * @param string $join_statement The join part of the SQL statement which is used for the query. |
|
| 86 | - * |
|
| 87 | - * @return string An join SQL which add the relationships table to the join. |
|
| 88 | - */ |
|
| 89 | - public function posts_join( $join_statement ) { |
|
| 90 | - |
|
| 91 | - global $wpdb; |
|
| 92 | - |
|
| 93 | - $join_statement .= " LEFT JOIN {$wpdb->prefix}wl_relation_instances ri " |
|
| 94 | - . " ON (ri.object_id = {$wpdb->posts}.ID)"; |
|
| 95 | - |
|
| 96 | - // Remove to make sure it will not run agan in other context. |
|
| 97 | - remove_filter( 'posts_join', array( $this, 'posts_join' ) ); |
|
| 98 | - |
|
| 99 | - return $join_statement; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Filter handler that sets the groupby part of a query to include the |
|
| 104 | - * relationship table to be able to use it in the sorting. |
|
| 105 | - * |
|
| 106 | - * @since 3.15.0 |
|
| 107 | - * |
|
| 108 | - * @param string $groupby_statement The groupby part of the SQL statement which is used for the query. |
|
| 109 | - * |
|
| 110 | - * @return string A groupby SQL which add the relationships table to the join. |
|
| 111 | - */ |
|
| 112 | - public function posts_groupby( $groupby_statement ) { |
|
| 113 | - |
|
| 114 | - $groupby_statement = 'ri.object_id, ' . $groupby_statement; |
|
| 115 | - |
|
| 116 | - // Remove to make sure it will not run agan in other context. |
|
| 117 | - remove_filter( 'posts_groupby', array( $this, 'posts_groupby' ) ); |
|
| 118 | - |
|
| 119 | - return $groupby_statement; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Filter handler that sets the orderby part of a query to sort by number of |
|
| 124 | - * relationships. |
|
| 125 | - * |
|
| 126 | - * @since 3.15.0 |
|
| 127 | - * |
|
| 128 | - * @param string $orderby_statement The orderby part of the SQL statement which is used for the query. |
|
| 129 | - * |
|
| 130 | - * @return string An orderby SQL which sorts by the number of relationships |
|
| 131 | - */ |
|
| 132 | - public function posts_orderby( $orderby_statement ) { |
|
| 133 | - |
|
| 134 | - $orderby_statement = 'COUNT( ri.object_id ) DESC, ' . $orderby_statement; |
|
| 135 | - |
|
| 136 | - // Remove to make sure it will not run agan in other context. |
|
| 137 | - remove_filter( 'posts_orderby', array( $this, 'posts_orderby' ) ); |
|
| 138 | - |
|
| 139 | - return $orderby_statement; |
|
| 140 | - } |
|
| 73 | + add_filter( 'posts_join', array( $this, 'posts_join' ) ); |
|
| 74 | + add_filter( 'posts_groupby', array( $this, 'posts_groupby' ) ); |
|
| 75 | + add_filter( 'posts_orderby', array( $this, 'posts_orderby' ) ); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Filter handler that sets the join part of a query to include the |
|
| 81 | + * relationship table to be able to use it in the sorting. |
|
| 82 | + * |
|
| 83 | + * @since 3.15.0 |
|
| 84 | + * |
|
| 85 | + * @param string $join_statement The join part of the SQL statement which is used for the query. |
|
| 86 | + * |
|
| 87 | + * @return string An join SQL which add the relationships table to the join. |
|
| 88 | + */ |
|
| 89 | + public function posts_join( $join_statement ) { |
|
| 90 | + |
|
| 91 | + global $wpdb; |
|
| 92 | + |
|
| 93 | + $join_statement .= " LEFT JOIN {$wpdb->prefix}wl_relation_instances ri " |
|
| 94 | + . " ON (ri.object_id = {$wpdb->posts}.ID)"; |
|
| 95 | + |
|
| 96 | + // Remove to make sure it will not run agan in other context. |
|
| 97 | + remove_filter( 'posts_join', array( $this, 'posts_join' ) ); |
|
| 98 | + |
|
| 99 | + return $join_statement; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Filter handler that sets the groupby part of a query to include the |
|
| 104 | + * relationship table to be able to use it in the sorting. |
|
| 105 | + * |
|
| 106 | + * @since 3.15.0 |
|
| 107 | + * |
|
| 108 | + * @param string $groupby_statement The groupby part of the SQL statement which is used for the query. |
|
| 109 | + * |
|
| 110 | + * @return string A groupby SQL which add the relationships table to the join. |
|
| 111 | + */ |
|
| 112 | + public function posts_groupby( $groupby_statement ) { |
|
| 113 | + |
|
| 114 | + $groupby_statement = 'ri.object_id, ' . $groupby_statement; |
|
| 115 | + |
|
| 116 | + // Remove to make sure it will not run agan in other context. |
|
| 117 | + remove_filter( 'posts_groupby', array( $this, 'posts_groupby' ) ); |
|
| 118 | + |
|
| 119 | + return $groupby_statement; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Filter handler that sets the orderby part of a query to sort by number of |
|
| 124 | + * relationships. |
|
| 125 | + * |
|
| 126 | + * @since 3.15.0 |
|
| 127 | + * |
|
| 128 | + * @param string $orderby_statement The orderby part of the SQL statement which is used for the query. |
|
| 129 | + * |
|
| 130 | + * @return string An orderby SQL which sorts by the number of relationships |
|
| 131 | + */ |
|
| 132 | + public function posts_orderby( $orderby_statement ) { |
|
| 133 | + |
|
| 134 | + $orderby_statement = 'COUNT( ri.object_id ) DESC, ' . $orderby_statement; |
|
| 135 | + |
|
| 136 | + // Remove to make sure it will not run agan in other context. |
|
| 137 | + remove_filter( 'posts_orderby', array( $this, 'posts_orderby' ) ); |
|
| 138 | + |
|
| 139 | + return $orderby_statement; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | 142 | } |
@@ -28,10 +28,10 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @param WP_Query $query WP's {@link WP_Query} instance. |
| 30 | 30 | */ |
| 31 | - public function pre_get_posts( $query ) { |
|
| 31 | + public function pre_get_posts($query) { |
|
| 32 | 32 | |
| 33 | 33 | // Only for the main query, avoid problems with widgets and what not. |
| 34 | - if ( ! $query->is_main_query() ) { |
|
| 34 | + if ( ! $query->is_main_query()) { |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -44,23 +44,23 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | // Ignore admin side request, requests for which filters should be |
| 46 | 46 | // suppressed, and when we are not on a entity type archive page. |
| 47 | - if ( is_admin() || |
|
| 48 | - ! is_tax( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) || |
|
| 49 | - ! empty( $query->query_vars['suppress_filters'] ) |
|
| 47 | + if (is_admin() || |
|
| 48 | + ! is_tax(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME) || |
|
| 49 | + ! empty($query->query_vars['suppress_filters']) |
|
| 50 | 50 | ) { |
| 51 | 51 | return; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Events should be sorted by start date in descending order. |
| 55 | - if ( is_tax( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, 'event' ) ) { |
|
| 55 | + if (is_tax(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, 'event')) { |
|
| 56 | 56 | |
| 57 | 57 | // Update the query to use the start time meta and desc order. |
| 58 | 58 | $meta_query[] = array( |
| 59 | 59 | 'key' => Wordlift_Schema_Service::FIELD_DATE_START, |
| 60 | 60 | ); |
| 61 | - $query->set( 'meta_query', $meta_query ); |
|
| 62 | - $query->set( 'orderby', 'meta_value' ); |
|
| 63 | - $query->set( 'order', 'DESC' ); |
|
| 61 | + $query->set('meta_query', $meta_query); |
|
| 62 | + $query->set('orderby', 'meta_value'); |
|
| 63 | + $query->set('order', 'DESC'); |
|
| 64 | 64 | } else { |
| 65 | 65 | /* |
| 66 | 66 | * All other entity types should be sorted by their connectivity. |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | * additional filters to handle it. |
| 71 | 71 | */ |
| 72 | 72 | |
| 73 | - add_filter( 'posts_join', array( $this, 'posts_join' ) ); |
|
| 74 | - add_filter( 'posts_groupby', array( $this, 'posts_groupby' ) ); |
|
| 75 | - add_filter( 'posts_orderby', array( $this, 'posts_orderby' ) ); |
|
| 73 | + add_filter('posts_join', array($this, 'posts_join')); |
|
| 74 | + add_filter('posts_groupby', array($this, 'posts_groupby')); |
|
| 75 | + add_filter('posts_orderby', array($this, 'posts_orderby')); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return string An join SQL which add the relationships table to the join. |
| 88 | 88 | */ |
| 89 | - public function posts_join( $join_statement ) { |
|
| 89 | + public function posts_join($join_statement) { |
|
| 90 | 90 | |
| 91 | 91 | global $wpdb; |
| 92 | 92 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | . " ON (ri.object_id = {$wpdb->posts}.ID)"; |
| 95 | 95 | |
| 96 | 96 | // Remove to make sure it will not run agan in other context. |
| 97 | - remove_filter( 'posts_join', array( $this, 'posts_join' ) ); |
|
| 97 | + remove_filter('posts_join', array($this, 'posts_join')); |
|
| 98 | 98 | |
| 99 | 99 | return $join_statement; |
| 100 | 100 | } |
@@ -109,12 +109,12 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return string A groupby SQL which add the relationships table to the join. |
| 111 | 111 | */ |
| 112 | - public function posts_groupby( $groupby_statement ) { |
|
| 112 | + public function posts_groupby($groupby_statement) { |
|
| 113 | 113 | |
| 114 | - $groupby_statement = 'ri.object_id, ' . $groupby_statement; |
|
| 114 | + $groupby_statement = 'ri.object_id, '.$groupby_statement; |
|
| 115 | 115 | |
| 116 | 116 | // Remove to make sure it will not run agan in other context. |
| 117 | - remove_filter( 'posts_groupby', array( $this, 'posts_groupby' ) ); |
|
| 117 | + remove_filter('posts_groupby', array($this, 'posts_groupby')); |
|
| 118 | 118 | |
| 119 | 119 | return $groupby_statement; |
| 120 | 120 | } |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return string An orderby SQL which sorts by the number of relationships |
| 131 | 131 | */ |
| 132 | - public function posts_orderby( $orderby_statement ) { |
|
| 132 | + public function posts_orderby($orderby_statement) { |
|
| 133 | 133 | |
| 134 | - $orderby_statement = 'COUNT( ri.object_id ) DESC, ' . $orderby_statement; |
|
| 134 | + $orderby_statement = 'COUNT( ri.object_id ) DESC, '.$orderby_statement; |
|
| 135 | 135 | |
| 136 | 136 | // Remove to make sure it will not run agan in other context. |
| 137 | - remove_filter( 'posts_orderby', array( $this, 'posts_orderby' ) ); |
|
| 137 | + remove_filter('posts_orderby', array($this, 'posts_orderby')); |
|
| 138 | 138 | |
| 139 | 139 | return $orderby_statement; |
| 140 | 140 | } |
@@ -26,10 +26,10 @@ |
||
| 26 | 26 | public function install() { |
| 27 | 27 | |
| 28 | 28 | // Check whether the `article` term exists. |
| 29 | - $article = get_term_by( 'slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 29 | + $article = get_term_by('slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
| 30 | 30 | |
| 31 | 31 | // The `article` term doesn't exists, so create it. |
| 32 | - if ( empty( $article ) ) { |
|
| 32 | + if (empty($article)) { |
|
| 33 | 33 | wp_insert_term( |
| 34 | 34 | 'Article', |
| 35 | 35 | Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
@@ -16,30 +16,30 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Wordlift_Install_3_15_0 extends Wordlift_Install { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @inheritdoc |
|
| 21 | - */ |
|
| 22 | - protected static $version = '3.15.0'; |
|
| 19 | + /** |
|
| 20 | + * @inheritdoc |
|
| 21 | + */ |
|
| 22 | + protected static $version = '3.15.0'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @inheritdoc |
|
| 26 | - */ |
|
| 27 | - public function install() { |
|
| 24 | + /** |
|
| 25 | + * @inheritdoc |
|
| 26 | + */ |
|
| 27 | + public function install() { |
|
| 28 | 28 | |
| 29 | - // Check whether the `article` term exists. |
|
| 30 | - $article = get_term_by( 'slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 29 | + // Check whether the `article` term exists. |
|
| 30 | + $article = get_term_by( 'slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 31 | 31 | |
| 32 | - // The `article` term doesn't exists, so create it. |
|
| 33 | - if ( empty( $article ) ) { |
|
| 34 | - wp_insert_term( |
|
| 35 | - 'Article', |
|
| 36 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 37 | - array( |
|
| 38 | - 'slug' => 'article', |
|
| 39 | - 'description' => 'An Article.', |
|
| 40 | - ) |
|
| 41 | - ); |
|
| 42 | - } |
|
| 43 | - } |
|
| 32 | + // The `article` term doesn't exists, so create it. |
|
| 33 | + if ( empty( $article ) ) { |
|
| 34 | + wp_insert_term( |
|
| 35 | + 'Article', |
|
| 36 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 37 | + array( |
|
| 38 | + 'slug' => 'article', |
|
| 39 | + 'description' => 'An Article.', |
|
| 40 | + ) |
|
| 41 | + ); |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | } |
@@ -15,41 +15,41 @@ |
||
| 15 | 15 | * @subpackage Wordlift/install |
| 16 | 16 | */ |
| 17 | 17 | class Wordlift_Install_3_10_0 extends Wordlift_Install { |
| 18 | - /** |
|
| 19 | - * @inheritdoc |
|
| 20 | - */ |
|
| 21 | - protected static $version = '3.10.0'; |
|
| 18 | + /** |
|
| 19 | + * @inheritdoc |
|
| 20 | + */ |
|
| 21 | + protected static $version = '3.10.0'; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @inheritdoc |
|
| 25 | - */ |
|
| 26 | - public function install() { |
|
| 23 | + /** |
|
| 24 | + * @inheritdoc |
|
| 25 | + */ |
|
| 26 | + public function install() { |
|
| 27 | 27 | |
| 28 | - $term_slugs = array( |
|
| 29 | - 'thing', |
|
| 30 | - 'creative-work', |
|
| 31 | - 'event', |
|
| 32 | - 'organization', |
|
| 33 | - 'person', |
|
| 34 | - 'place', |
|
| 35 | - 'localbusiness', |
|
| 36 | - ); |
|
| 28 | + $term_slugs = array( |
|
| 29 | + 'thing', |
|
| 30 | + 'creative-work', |
|
| 31 | + 'event', |
|
| 32 | + 'organization', |
|
| 33 | + 'person', |
|
| 34 | + 'place', |
|
| 35 | + 'localbusiness', |
|
| 36 | + ); |
|
| 37 | 37 | |
| 38 | - foreach ( $term_slugs as $slug ) { |
|
| 38 | + foreach ( $term_slugs as $slug ) { |
|
| 39 | 39 | |
| 40 | - $term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 40 | + $term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 41 | 41 | |
| 42 | - // Set the term's parent to 0. |
|
| 43 | - if ( $term ) { |
|
| 44 | - wp_update_term( |
|
| 45 | - $term->term_id, |
|
| 46 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 47 | - array( |
|
| 48 | - 'parent' => 0, |
|
| 49 | - ) |
|
| 50 | - ); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - } |
|
| 42 | + // Set the term's parent to 0. |
|
| 43 | + if ( $term ) { |
|
| 44 | + wp_update_term( |
|
| 45 | + $term->term_id, |
|
| 46 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 47 | + array( |
|
| 48 | + 'parent' => 0, |
|
| 49 | + ) |
|
| 50 | + ); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | } |
@@ -35,12 +35,12 @@ |
||
| 35 | 35 | 'localbusiness', |
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | - foreach ( $term_slugs as $slug ) { |
|
| 38 | + foreach ($term_slugs as $slug) { |
|
| 39 | 39 | |
| 40 | - $term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 40 | + $term = get_term_by('slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
| 41 | 41 | |
| 42 | 42 | // Set the term's parent to 0. |
| 43 | - if ( $term ) { |
|
| 43 | + if ($term) { |
|
| 44 | 44 | wp_update_term( |
| 45 | 45 | $term->term_id, |
| 46 | 46 | Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
@@ -15,23 +15,23 @@ |
||
| 15 | 15 | * @subpackage Wordlift/install |
| 16 | 16 | */ |
| 17 | 17 | class Wordlift_Install_3_12_0 extends Wordlift_Install { |
| 18 | - /** |
|
| 19 | - * @inheritdoc |
|
| 20 | - */ |
|
| 21 | - protected static $version = '3.12.0'; |
|
| 18 | + /** |
|
| 19 | + * @inheritdoc |
|
| 20 | + */ |
|
| 21 | + protected static $version = '3.12.0'; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @inheritdoc |
|
| 25 | - */ |
|
| 26 | - public function install() { |
|
| 27 | - /* |
|
| 23 | + /** |
|
| 24 | + * @inheritdoc |
|
| 25 | + */ |
|
| 26 | + public function install() { |
|
| 27 | + /* |
|
| 28 | 28 | * As this upgrade functionality runs on the init hook, and the AMP plugin |
| 29 | 29 | * initialization does the same, avoid possible race conditions by |
| 30 | 30 | * deferring the actual flush to a later hook. |
| 31 | 31 | */ |
| 32 | - add_action( 'wp_loaded', function () { |
|
| 33 | - flush_rewrite_rules(); |
|
| 34 | - } ); |
|
| 35 | - } |
|
| 32 | + add_action( 'wp_loaded', function () { |
|
| 33 | + flush_rewrite_rules(); |
|
| 34 | + } ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | } |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | * initialization does the same, avoid possible race conditions by |
| 30 | 30 | * deferring the actual flush to a later hook. |
| 31 | 31 | */ |
| 32 | - add_action( 'wp_loaded', function () { |
|
| 32 | + add_action('wp_loaded', function() { |
|
| 33 | 33 | flush_rewrite_rules(); |
| 34 | 34 | } ); |
| 35 | 35 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | // If uninstall not called from WordPress, then exit. |
| 29 | 29 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 30 | - exit; |
|
| 30 | + exit; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // Get a reference to WP and the Wordlift plugin |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | // Do a db search for posts of type entity |
| 42 | 42 | $args = array( |
| 43 | - 'posts_per_page' => - 1, |
|
| 44 | - 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 45 | - 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ), |
|
| 46 | - 'fields' => 'ids' |
|
| 43 | + 'posts_per_page' => - 1, |
|
| 44 | + 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 45 | + 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ), |
|
| 46 | + 'fields' => 'ids' |
|
| 47 | 47 | ); |
| 48 | 48 | $entities_array = get_posts( $args ); |
| 49 | 49 | |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | wl_write_log( 'Deleting entities and their meta... ' ); |
| 53 | 53 | wl_write_log( $entities_array ); |
| 54 | 54 | foreach ( $entities_array as $entity_id ) { |
| 55 | - // Delete the whole entity and its metas. |
|
| 56 | - wp_delete_post( $entity_id, true ); |
|
| 55 | + // Delete the whole entity and its metas. |
|
| 56 | + wp_delete_post( $entity_id, true ); |
|
| 57 | 57 | } |
| 58 | 58 | wl_write_log( 'Done.' ); |
| 59 | 59 | |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | // We loop over terms in this rude way because in the uninstall script |
| 75 | 75 | // is not possible to call WP custom taxonomy functions. |
| 76 | 76 | foreach ( range( 0, 100 ) as $index ) { |
| 77 | - delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_' . $index ); |
|
| 78 | - wp_delete_term( $index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 77 | + delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_' . $index ); |
|
| 78 | + wp_delete_term( $index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 79 | 79 | } |
| 80 | 80 | delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_children' ); // it's a hierarchical taxonomy |
| 81 | 81 | wl_write_log( 'Done.' ); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | 28 | // If uninstall not called from WordPress, then exit. |
| 29 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 29 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
| 30 | 30 | exit; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -39,53 +39,53 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | |
| 41 | 41 | // Do a db search for posts of type entity |
| 42 | -$args = array( |
|
| 43 | - 'posts_per_page' => - 1, |
|
| 42 | +$args = array( |
|
| 43 | + 'posts_per_page' => -1, |
|
| 44 | 44 | 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
| 45 | - 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ), |
|
| 45 | + 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'), |
|
| 46 | 46 | 'fields' => 'ids' |
| 47 | 47 | ); |
| 48 | -$entities_array = get_posts( $args ); |
|
| 48 | +$entities_array = get_posts($args); |
|
| 49 | 49 | |
| 50 | 50 | // Loop over entities and delete them. |
| 51 | 51 | // TODO: thumbnails? |
| 52 | -wl_write_log( 'Deleting entities and their meta... ' ); |
|
| 53 | -wl_write_log( $entities_array ); |
|
| 54 | -foreach ( $entities_array as $entity_id ) { |
|
| 52 | +wl_write_log('Deleting entities and their meta... '); |
|
| 53 | +wl_write_log($entities_array); |
|
| 54 | +foreach ($entities_array as $entity_id) { |
|
| 55 | 55 | // Delete the whole entity and its metas. |
| 56 | - wp_delete_post( $entity_id, true ); |
|
| 56 | + wp_delete_post($entity_id, true); |
|
| 57 | 57 | } |
| 58 | -wl_write_log( 'Done.' ); |
|
| 58 | +wl_write_log('Done.'); |
|
| 59 | 59 | |
| 60 | 60 | /* |
| 61 | 61 | * Delete post-entity relationships |
| 62 | 62 | */ |
| 63 | -wl_write_log( 'Deleting post-entity relationships... ' ); |
|
| 64 | -$sql = 'DROP TABLE IF EXISTS ' . wl_core_get_relation_instances_table_name() . ';'; |
|
| 65 | -$wpdb->query( $sql ); |
|
| 66 | -delete_option( 'wl_db_version' ); |
|
| 67 | -wl_write_log( 'Done.' ); |
|
| 63 | +wl_write_log('Deleting post-entity relationships... '); |
|
| 64 | +$sql = 'DROP TABLE IF EXISTS '.wl_core_get_relation_instances_table_name().';'; |
|
| 65 | +$wpdb->query($sql); |
|
| 66 | +delete_option('wl_db_version'); |
|
| 67 | +wl_write_log('Done.'); |
|
| 68 | 68 | |
| 69 | 69 | /* |
| 70 | 70 | * Delete taxonomy |
| 71 | 71 | */ |
| 72 | -wl_write_log( 'Cleaning entities taxonomy... ' ); |
|
| 72 | +wl_write_log('Cleaning entities taxonomy... '); |
|
| 73 | 73 | // Delte custom taxonomy terms. |
| 74 | 74 | // We loop over terms in this rude way because in the uninstall script |
| 75 | 75 | // is not possible to call WP custom taxonomy functions. |
| 76 | -foreach ( range( 0, 100 ) as $index ) { |
|
| 77 | - delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_' . $index ); |
|
| 78 | - wp_delete_term( $index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 76 | +foreach (range(0, 100) as $index) { |
|
| 77 | + delete_option(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME.'_'.$index); |
|
| 78 | + wp_delete_term($index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
| 79 | 79 | } |
| 80 | -delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_children' ); // it's a hierarchical taxonomy |
|
| 81 | -wl_write_log( 'Done.' ); |
|
| 80 | +delete_option(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME.'_children'); // it's a hierarchical taxonomy |
|
| 81 | +wl_write_log('Done.'); |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * Delete options |
| 85 | 85 | */ |
| 86 | -wl_write_log( 'Cleaning WordLift options... ' ); |
|
| 86 | +wl_write_log('Cleaning WordLift options... '); |
|
| 87 | 87 | // delete_option( WL_OPTIONS_NAME ); |
| 88 | -delete_option( 'wl_option_prefixes' ); |
|
| 89 | -delete_option( 'wl_general_settings' ); |
|
| 90 | -delete_option( 'wl_advanced_settings' ); |
|
| 91 | -wl_write_log( 'Done. WordLift successfully uninstalled.' ); |
|
| 88 | +delete_option('wl_option_prefixes'); |
|
| 89 | +delete_option('wl_general_settings'); |
|
| 90 | +delete_option('wl_advanced_settings'); |
|
| 91 | +wl_write_log('Done. WordLift successfully uninstalled.'); |
|
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Include constants |
| 4 | -require_once( 'wordlift_core_constants.php' ); |
|
| 4 | +require_once('wordlift_core_constants.php'); |
|
| 5 | 5 | |
| 6 | 6 | // Include methods that deal with post/entity relations |
| 7 | -require_once( 'wordlift_core_post_entity_relations.php' ); |
|
| 7 | +require_once('wordlift_core_post_entity_relations.php'); |
|
| 8 | 8 | |
| 9 | 9 | // Include wl_schema api |
| 10 | -require_once( 'wordlift_core_schema_api.php' ); |
|
| 10 | +require_once('wordlift_core_schema_api.php'); |
|
| 11 | 11 | |
| 12 | 12 | // Include the Entity API which allow to query for entity posts. |
| 13 | -require_once( 'wordlift_core_entity_api.php' ); |
|
| 13 | +require_once('wordlift_core_entity_api.php'); |
|
| 14 | 14 | |
| 15 | 15 | // Include utility global functions |
| 16 | -require_once( 'wordlift_core_functions.php' ); |
|
| 17 | 16 | \ No newline at end of file |
| 17 | +require_once('wordlift_core_functions.php'); |
|
| 18 | 18 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @subpackage Wordlift/includes |
| 11 | 11 | */ |
| 12 | 12 | if ( ! class_exists( 'Walker_Category_Checklist' ) ) { |
| 13 | - require_once( ABSPATH . 'wp-admin/includes/template.php' ); |
|
| 13 | + require_once( ABSPATH . 'wp-admin/includes/template.php' ); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -23,113 +23,113 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class Wordlift_Entity_Types_Taxonomy_Walker extends Walker_Category_Checklist { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Entity taxonomy metabox must show exclusive options, no checkboxes. |
|
| 28 | - * |
|
| 29 | - * @since 3.1.0 |
|
| 30 | - * |
|
| 31 | - * @param $args { |
|
| 32 | - * An array of arguments. |
|
| 33 | - * |
|
| 34 | - * @type string $taxonomy The taxonomy name. |
|
| 35 | - * } |
|
| 36 | - * |
|
| 37 | - * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy. |
|
| 38 | - */ |
|
| 39 | - function terms_checklist_args( $args ) { |
|
| 40 | - |
|
| 41 | - if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
| 42 | - return $args; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - // We override the way WP prints the taxonomy metabox HTML. |
|
| 46 | - $args['walker'] = $this; |
|
| 47 | - $args['checked_ontop'] = false; |
|
| 48 | - |
|
| 49 | - return $args; |
|
| 50 | - |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Change checkboxes to radios. |
|
| 55 | - * |
|
| 56 | - * $max_depth = -1 means flatly display every element. |
|
| 57 | - * $max_depth = 0 means display all levels. |
|
| 58 | - * $max_depth > 0 specifies the number of display levels. |
|
| 59 | - * |
|
| 60 | - * @since 3.1.0 |
|
| 61 | - * |
|
| 62 | - * @param array $elements An array of elements. |
|
| 63 | - * @param int $max_depth The maximum hierarchical depth. |
|
| 64 | - * |
|
| 65 | - * @param array $args Additional arguments. |
|
| 66 | - * |
|
| 67 | - * @return string The hierarchical item output. |
|
| 68 | - */ |
|
| 69 | - public function walk( $elements, $max_depth, $args = array() ) { |
|
| 70 | - |
|
| 71 | - // `max_depth` force to -1 to display a flat taxonomy. |
|
| 72 | - // |
|
| 73 | - // See https://github.com/insideout10/wordlift-plugin/issues/305 |
|
| 74 | - $output = parent::walk( $elements, - 1, $args ); |
|
| 75 | - |
|
| 76 | - $output = str_replace( |
|
| 77 | - array( "type=\"checkbox\"", "type='checkbox'" ), |
|
| 78 | - array( "type=\"radio\"", "type='radio'" ), |
|
| 79 | - $output |
|
| 80 | - ); |
|
| 81 | - |
|
| 82 | - return $output; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Start the element output, output nothing in case of article term. |
|
| 87 | - * |
|
| 88 | - * @since 3.15.0 |
|
| 89 | - * |
|
| 90 | - * @param string $output Passed by reference. Used to append additional content. |
|
| 91 | - * @param object $category The current term object. |
|
| 92 | - * @param int $depth Depth of the term in reference to parents. Default 0. |
|
| 93 | - * @param array $args An array of arguments. @see wp_terms_checklist() |
|
| 94 | - * @param int $id ID of the current term. |
|
| 95 | - */ |
|
| 96 | - public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
|
| 97 | - global $post; |
|
| 98 | - |
|
| 99 | - if ( ! isset( $post ) ) { |
|
| 100 | - return; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
| 104 | - || 'article' !== $category->slug |
|
| 105 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
| 106 | - parent::start_el( $output, $category, $depth, $args, $id ); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * End the element output, output nothing in case of article term. |
|
| 112 | - * |
|
| 113 | - * @since 3.15.0 |
|
| 114 | - * |
|
| 115 | - * @param string $output Passed by reference. Used to append additional content. |
|
| 116 | - * @param object $category The current term object. |
|
| 117 | - * @param int $depth Depth of the term in reference to parents. Default 0. |
|
| 118 | - * @param array $args An array of arguments. @see wp_terms_checklist() |
|
| 119 | - */ |
|
| 120 | - public function end_el( &$output, $category, $depth = 0, $args = array() ) { |
|
| 121 | - global $post; |
|
| 122 | - |
|
| 123 | - if ( ! isset( $post ) ) { |
|
| 124 | - return; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
| 128 | - || 'article' !== $category->slug |
|
| 129 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
| 130 | - parent::end_el( $output, $category, $depth, $args ); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - } |
|
| 26 | + /** |
|
| 27 | + * Entity taxonomy metabox must show exclusive options, no checkboxes. |
|
| 28 | + * |
|
| 29 | + * @since 3.1.0 |
|
| 30 | + * |
|
| 31 | + * @param $args { |
|
| 32 | + * An array of arguments. |
|
| 33 | + * |
|
| 34 | + * @type string $taxonomy The taxonomy name. |
|
| 35 | + * } |
|
| 36 | + * |
|
| 37 | + * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy. |
|
| 38 | + */ |
|
| 39 | + function terms_checklist_args( $args ) { |
|
| 40 | + |
|
| 41 | + if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
| 42 | + return $args; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + // We override the way WP prints the taxonomy metabox HTML. |
|
| 46 | + $args['walker'] = $this; |
|
| 47 | + $args['checked_ontop'] = false; |
|
| 48 | + |
|
| 49 | + return $args; |
|
| 50 | + |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Change checkboxes to radios. |
|
| 55 | + * |
|
| 56 | + * $max_depth = -1 means flatly display every element. |
|
| 57 | + * $max_depth = 0 means display all levels. |
|
| 58 | + * $max_depth > 0 specifies the number of display levels. |
|
| 59 | + * |
|
| 60 | + * @since 3.1.0 |
|
| 61 | + * |
|
| 62 | + * @param array $elements An array of elements. |
|
| 63 | + * @param int $max_depth The maximum hierarchical depth. |
|
| 64 | + * |
|
| 65 | + * @param array $args Additional arguments. |
|
| 66 | + * |
|
| 67 | + * @return string The hierarchical item output. |
|
| 68 | + */ |
|
| 69 | + public function walk( $elements, $max_depth, $args = array() ) { |
|
| 70 | + |
|
| 71 | + // `max_depth` force to -1 to display a flat taxonomy. |
|
| 72 | + // |
|
| 73 | + // See https://github.com/insideout10/wordlift-plugin/issues/305 |
|
| 74 | + $output = parent::walk( $elements, - 1, $args ); |
|
| 75 | + |
|
| 76 | + $output = str_replace( |
|
| 77 | + array( "type=\"checkbox\"", "type='checkbox'" ), |
|
| 78 | + array( "type=\"radio\"", "type='radio'" ), |
|
| 79 | + $output |
|
| 80 | + ); |
|
| 81 | + |
|
| 82 | + return $output; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Start the element output, output nothing in case of article term. |
|
| 87 | + * |
|
| 88 | + * @since 3.15.0 |
|
| 89 | + * |
|
| 90 | + * @param string $output Passed by reference. Used to append additional content. |
|
| 91 | + * @param object $category The current term object. |
|
| 92 | + * @param int $depth Depth of the term in reference to parents. Default 0. |
|
| 93 | + * @param array $args An array of arguments. @see wp_terms_checklist() |
|
| 94 | + * @param int $id ID of the current term. |
|
| 95 | + */ |
|
| 96 | + public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
|
| 97 | + global $post; |
|
| 98 | + |
|
| 99 | + if ( ! isset( $post ) ) { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
| 104 | + || 'article' !== $category->slug |
|
| 105 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
| 106 | + parent::start_el( $output, $category, $depth, $args, $id ); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * End the element output, output nothing in case of article term. |
|
| 112 | + * |
|
| 113 | + * @since 3.15.0 |
|
| 114 | + * |
|
| 115 | + * @param string $output Passed by reference. Used to append additional content. |
|
| 116 | + * @param object $category The current term object. |
|
| 117 | + * @param int $depth Depth of the term in reference to parents. Default 0. |
|
| 118 | + * @param array $args An array of arguments. @see wp_terms_checklist() |
|
| 119 | + */ |
|
| 120 | + public function end_el( &$output, $category, $depth = 0, $args = array() ) { |
|
| 121 | + global $post; |
|
| 122 | + |
|
| 123 | + if ( ! isset( $post ) ) { |
|
| 124 | + return; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
| 128 | + || 'article' !== $category->slug |
|
| 129 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
| 130 | + parent::end_el( $output, $category, $depth, $args ); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | 135 | } |
@@ -9,8 +9,8 @@ discard block |
||
| 9 | 9 | * @package Wordlift |
| 10 | 10 | * @subpackage Wordlift/includes |
| 11 | 11 | */ |
| 12 | -if ( ! class_exists( 'Walker_Category_Checklist' ) ) { |
|
| 13 | - require_once( ABSPATH . 'wp-admin/includes/template.php' ); |
|
| 12 | +if ( ! class_exists('Walker_Category_Checklist')) { |
|
| 13 | + require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy. |
| 38 | 38 | */ |
| 39 | - function terms_checklist_args( $args ) { |
|
| 39 | + function terms_checklist_args($args) { |
|
| 40 | 40 | |
| 41 | - if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
| 41 | + if ( ! isset($args['taxonomy']) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) { |
|
| 42 | 42 | return $args; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -66,16 +66,16 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return string The hierarchical item output. |
| 68 | 68 | */ |
| 69 | - public function walk( $elements, $max_depth, $args = array() ) { |
|
| 69 | + public function walk($elements, $max_depth, $args = array()) { |
|
| 70 | 70 | |
| 71 | 71 | // `max_depth` force to -1 to display a flat taxonomy. |
| 72 | 72 | // |
| 73 | 73 | // See https://github.com/insideout10/wordlift-plugin/issues/305 |
| 74 | - $output = parent::walk( $elements, - 1, $args ); |
|
| 74 | + $output = parent::walk($elements, - 1, $args); |
|
| 75 | 75 | |
| 76 | 76 | $output = str_replace( |
| 77 | - array( "type=\"checkbox\"", "type='checkbox'" ), |
|
| 78 | - array( "type=\"radio\"", "type='radio'" ), |
|
| 77 | + array("type=\"checkbox\"", "type='checkbox'"), |
|
| 78 | + array("type=\"radio\"", "type='radio'"), |
|
| 79 | 79 | $output |
| 80 | 80 | ); |
| 81 | 81 | |
@@ -93,17 +93,17 @@ discard block |
||
| 93 | 93 | * @param array $args An array of arguments. @see wp_terms_checklist() |
| 94 | 94 | * @param int $id ID of the current term. |
| 95 | 95 | */ |
| 96 | - public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
|
| 96 | + public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) { |
|
| 97 | 97 | global $post; |
| 98 | 98 | |
| 99 | - if ( ! isset( $post ) ) { |
|
| 99 | + if ( ! isset($post)) { |
|
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
| 103 | + if (Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
| 104 | 104 | || 'article' !== $category->slug |
| 105 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
| 106 | - parent::start_el( $output, $category, $depth, $args, $id ); |
|
| 105 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) { |
|
| 106 | + parent::start_el($output, $category, $depth, $args, $id); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -117,17 +117,17 @@ discard block |
||
| 117 | 117 | * @param int $depth Depth of the term in reference to parents. Default 0. |
| 118 | 118 | * @param array $args An array of arguments. @see wp_terms_checklist() |
| 119 | 119 | */ |
| 120 | - public function end_el( &$output, $category, $depth = 0, $args = array() ) { |
|
| 120 | + public function end_el(&$output, $category, $depth = 0, $args = array()) { |
|
| 121 | 121 | global $post; |
| 122 | 122 | |
| 123 | - if ( ! isset( $post ) ) { |
|
| 123 | + if ( ! isset($post)) { |
|
| 124 | 124 | return; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
| 127 | + if (Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
| 128 | 128 | || 'article' !== $category->slug |
| 129 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
| 130 | - parent::end_el( $output, $category, $depth, $args ); |
|
| 129 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) { |
|
| 130 | + parent::end_el($output, $category, $depth, $args); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | } |