@@ -12,62 +12,62 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class LSX_TO_Team_Schema extends LSX_TO_Schema_Graph_Piece { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Constructor. |
|
| 17 | - * |
|
| 18 | - * @param \WPSEO_Schema_Context $context A value object with context variables. |
|
| 19 | - */ |
|
| 20 | - public function __construct( WPSEO_Schema_Context $context ) { |
|
| 21 | - $this->post_type = 'team'; |
|
| 22 | - parent::__construct( $context ); |
|
| 23 | - } |
|
| 15 | + /** |
|
| 16 | + * Constructor. |
|
| 17 | + * |
|
| 18 | + * @param \WPSEO_Schema_Context $context A value object with context variables. |
|
| 19 | + */ |
|
| 20 | + public function __construct( WPSEO_Schema_Context $context ) { |
|
| 21 | + $this->post_type = 'team'; |
|
| 22 | + parent::__construct( $context ); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Returns Review data. |
|
| 27 | - * |
|
| 28 | - * @return array $data Review data. |
|
| 29 | - */ |
|
| 30 | - public function generate() { |
|
| 31 | - $data = array( |
|
| 32 | - '@type' => array( |
|
| 33 | - 'Person', |
|
| 34 | - ), |
|
| 35 | - '@id' => $this->context->canonical . '#person', |
|
| 36 | - 'name' => $this->post->post_title, |
|
| 37 | - 'description' => wp_strip_all_tags( $this->post->post_content ), |
|
| 38 | - 'url' => $this->post_url, |
|
| 39 | - 'mainEntityOfPage' => array( |
|
| 40 | - '@id' => $this->context->canonical . WPSEO_Schema_IDs::WEBPAGE_HASH, |
|
| 41 | - ), |
|
| 42 | - ); |
|
| 25 | + /** |
|
| 26 | + * Returns Review data. |
|
| 27 | + * |
|
| 28 | + * @return array $data Review data. |
|
| 29 | + */ |
|
| 30 | + public function generate() { |
|
| 31 | + $data = array( |
|
| 32 | + '@type' => array( |
|
| 33 | + 'Person', |
|
| 34 | + ), |
|
| 35 | + '@id' => $this->context->canonical . '#person', |
|
| 36 | + 'name' => $this->post->post_title, |
|
| 37 | + 'description' => wp_strip_all_tags( $this->post->post_content ), |
|
| 38 | + 'url' => $this->post_url, |
|
| 39 | + 'mainEntityOfPage' => array( |
|
| 40 | + '@id' => $this->context->canonical . WPSEO_Schema_IDs::WEBPAGE_HASH, |
|
| 41 | + ), |
|
| 42 | + ); |
|
| 43 | 43 | |
| 44 | - if ( $this->context->site_represents_reference ) { |
|
| 45 | - $data['worksFor'] = $this->context->site_represents_reference; |
|
| 46 | - $data['memberOf'] = $this->context->site_represents_reference; |
|
| 47 | - } |
|
| 44 | + if ( $this->context->site_represents_reference ) { |
|
| 45 | + $data['worksFor'] = $this->context->site_represents_reference; |
|
| 46 | + $data['memberOf'] = $this->context->site_represents_reference; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $data = $this->add_taxonomy_terms( $data, 'jobTitle', 'role' ); |
|
| 50 | - $data = $this->add_custom_field( $data, 'email', 'contact_email' ); |
|
| 51 | - $data = $this->add_custom_field( $data, 'telephone', 'contact_number' ); |
|
| 52 | - $data = $this->add_products( $data ); |
|
| 53 | - $data = $this->add_offers( $data, 'makesOffer' ); |
|
| 54 | - $data = \lsx\legacy\Schema_Utils::add_image( $data, $this->context ); |
|
| 55 | - return $data; |
|
| 56 | - } |
|
| 49 | + $data = $this->add_taxonomy_terms( $data, 'jobTitle', 'role' ); |
|
| 50 | + $data = $this->add_custom_field( $data, 'email', 'contact_email' ); |
|
| 51 | + $data = $this->add_custom_field( $data, 'telephone', 'contact_number' ); |
|
| 52 | + $data = $this->add_products( $data ); |
|
| 53 | + $data = $this->add_offers( $data, 'makesOffer' ); |
|
| 54 | + $data = \lsx\legacy\Schema_Utils::add_image( $data, $this->context ); |
|
| 55 | + return $data; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Adds the accommodation and tour products under the 'owns' parameter |
|
| 60 | - * |
|
| 61 | - * @param array $data |
|
| 62 | - * @return array |
|
| 63 | - */ |
|
| 64 | - public function add_products( $data ) { |
|
| 65 | - $places_array = array(); |
|
| 66 | - $places_array = $this->add_accommodation( $places_array ); |
|
| 67 | - $places_array = $this->add_tours( $places_array ); |
|
| 68 | - if ( ! empty( $places_array ) ) { |
|
| 69 | - $data['owns'] = $places_array; |
|
| 70 | - } |
|
| 71 | - return $data; |
|
| 72 | - } |
|
| 58 | + /** |
|
| 59 | + * Adds the accommodation and tour products under the 'owns' parameter |
|
| 60 | + * |
|
| 61 | + * @param array $data |
|
| 62 | + * @return array |
|
| 63 | + */ |
|
| 64 | + public function add_products( $data ) { |
|
| 65 | + $places_array = array(); |
|
| 66 | + $places_array = $this->add_accommodation( $places_array ); |
|
| 67 | + $places_array = $this->add_tours( $places_array ); |
|
| 68 | + if ( ! empty( $places_array ) ) { |
|
| 69 | + $data['owns'] = $places_array; |
|
| 70 | + } |
|
| 71 | + return $data; |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -17,94 +17,94 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | class LSX_TO_Team_Frontend extends LSX_TO_Team { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Holds the $page_links array while its being built on the single team page. |
|
| 22 | - * |
|
| 23 | - * @var array |
|
| 24 | - */ |
|
| 25 | - public $page_links = false; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Holds the array of options. |
|
| 29 | - * |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 32 | - public $options = false; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Constructor |
|
| 36 | - */ |
|
| 37 | - public function __construct() { |
|
| 38 | - $this->options = get_option( '_lsx-to_settings', false ); |
|
| 39 | - |
|
| 40 | - add_action( 'wp_head', array( $this, 'change_single_team_layout' ), 20, 1 ); |
|
| 41 | - |
|
| 42 | - if ( ! is_admin() ) { |
|
| 43 | - add_filter( 'posts_orderby', array( $this, 'enable_role_taxonomy_order' ), 10, 2 ); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - add_filter( 'lsx_to_archive_class', array( $this, 'archive_class' ), 10, 3 ); |
|
| 47 | - add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) ); |
|
| 48 | - add_action( 'lsx_to_settings_current_tab', array( $this, 'set_settings_current_tab' ) ); |
|
| 49 | - |
|
| 50 | - if ( ! class_exists( 'LSX_TO_Template_Redirects' ) ) { |
|
| 51 | - require_once( LSX_TO_TEAM_PATH . 'classes/class-lsx-to-template-redirects.php' ); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - $this->redirects = new LSX_TO_Template_Redirects( LSX_TO_TEAM_PATH, array( 'team' ), array( 'role' ) ); |
|
| 55 | - |
|
| 56 | - add_action( 'lsx_to_team_content', array( $this->redirects, 'content_part' ), 10, 2 ); |
|
| 57 | - |
|
| 58 | - add_filter( 'lsx_to_page_navigation', array( $this, 'page_links' ) ); |
|
| 59 | - |
|
| 60 | - add_action( 'lsx_entry_top', array( $this, 'archive_entry_top' ), 15 ); |
|
| 61 | - add_action( 'lsx_entry_bottom', array( $this, 'archive_entry_bottom' ) ); |
|
| 62 | - add_action( 'lsx_content_bottom', array( $this, 'single_content_bottom' ) ); |
|
| 63 | - |
|
| 64 | - add_filter( 'lsx_to_maps_args', array( $this, 'lsx_to_maps_args' ), 10, 2 ); |
|
| 65 | - add_filter( 'lsx_to_has_maps_location', array( $this, 'lsx_to_has_maps_location' ), 50, 2 ); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Change single team layout. |
|
| 70 | - */ |
|
| 71 | - public function change_single_team_layout() { |
|
| 72 | - global $lsx_to_archive; |
|
| 73 | - |
|
| 74 | - if ( is_singular( 'team' ) && 1 !== $lsx_to_archive ) { |
|
| 75 | - remove_action( 'lsx_entry_bottom', 'lsx_to_single_entry_bottom' ); |
|
| 76 | - add_action( 'lsx_entry_top', array( $this, 'lsx_to_single_entry_bottom' ) ); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Change single team layout. |
|
| 82 | - */ |
|
| 83 | - public function lsx_to_single_entry_bottom() { |
|
| 84 | - if ( is_singular( 'team' ) ) { ?> |
|
| 20 | + /** |
|
| 21 | + * Holds the $page_links array while its being built on the single team page. |
|
| 22 | + * |
|
| 23 | + * @var array |
|
| 24 | + */ |
|
| 25 | + public $page_links = false; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Holds the array of options. |
|
| 29 | + * |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | + public $options = false; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Constructor |
|
| 36 | + */ |
|
| 37 | + public function __construct() { |
|
| 38 | + $this->options = get_option( '_lsx-to_settings', false ); |
|
| 39 | + |
|
| 40 | + add_action( 'wp_head', array( $this, 'change_single_team_layout' ), 20, 1 ); |
|
| 41 | + |
|
| 42 | + if ( ! is_admin() ) { |
|
| 43 | + add_filter( 'posts_orderby', array( $this, 'enable_role_taxonomy_order' ), 10, 2 ); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + add_filter( 'lsx_to_archive_class', array( $this, 'archive_class' ), 10, 3 ); |
|
| 47 | + add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) ); |
|
| 48 | + add_action( 'lsx_to_settings_current_tab', array( $this, 'set_settings_current_tab' ) ); |
|
| 49 | + |
|
| 50 | + if ( ! class_exists( 'LSX_TO_Template_Redirects' ) ) { |
|
| 51 | + require_once( LSX_TO_TEAM_PATH . 'classes/class-lsx-to-template-redirects.php' ); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + $this->redirects = new LSX_TO_Template_Redirects( LSX_TO_TEAM_PATH, array( 'team' ), array( 'role' ) ); |
|
| 55 | + |
|
| 56 | + add_action( 'lsx_to_team_content', array( $this->redirects, 'content_part' ), 10, 2 ); |
|
| 57 | + |
|
| 58 | + add_filter( 'lsx_to_page_navigation', array( $this, 'page_links' ) ); |
|
| 59 | + |
|
| 60 | + add_action( 'lsx_entry_top', array( $this, 'archive_entry_top' ), 15 ); |
|
| 61 | + add_action( 'lsx_entry_bottom', array( $this, 'archive_entry_bottom' ) ); |
|
| 62 | + add_action( 'lsx_content_bottom', array( $this, 'single_content_bottom' ) ); |
|
| 63 | + |
|
| 64 | + add_filter( 'lsx_to_maps_args', array( $this, 'lsx_to_maps_args' ), 10, 2 ); |
|
| 65 | + add_filter( 'lsx_to_has_maps_location', array( $this, 'lsx_to_has_maps_location' ), 50, 2 ); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Change single team layout. |
|
| 70 | + */ |
|
| 71 | + public function change_single_team_layout() { |
|
| 72 | + global $lsx_to_archive; |
|
| 73 | + |
|
| 74 | + if ( is_singular( 'team' ) && 1 !== $lsx_to_archive ) { |
|
| 75 | + remove_action( 'lsx_entry_bottom', 'lsx_to_single_entry_bottom' ); |
|
| 76 | + add_action( 'lsx_entry_top', array( $this, 'lsx_to_single_entry_bottom' ) ); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Change single team layout. |
|
| 82 | + */ |
|
| 83 | + public function lsx_to_single_entry_bottom() { |
|
| 84 | + if ( is_singular( 'team' ) ) { ?> |
|
| 85 | 85 | <div class="col-xs-12 col-sm-5 col-md-4"> |
| 86 | 86 | <figure class="lsx-to-team-thumb"> |
| 87 | 87 | <?php lsx_thumbnail( 'lsx-thumbnail-square' ); ?> |
| 88 | 88 | </figure> |
| 89 | 89 | |
| 90 | 90 | <?php |
| 91 | - lsx_to_team_social_profiles( '<span class="lsx-to-team-socials-header">' . esc_html__( 'Follow', 'to-team' ) . ':</span><div class="lsx-to-team-socials">', '</div>' ); |
|
| 92 | - lsx_to_enquire_modal( esc_html__( 'Get in touch', 'to-team' ) ); |
|
| 93 | - ?> |
|
| 91 | + lsx_to_team_social_profiles( '<span class="lsx-to-team-socials-header">' . esc_html__( 'Follow', 'to-team' ) . ':</span><div class="lsx-to-team-socials">', '</div>' ); |
|
| 92 | + lsx_to_enquire_modal( esc_html__( 'Get in touch', 'to-team' ) ); |
|
| 93 | + ?> |
|
| 94 | 94 | </div> |
| 95 | 95 | <?php |
| 96 | - } |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Enable role taxonomy order. |
|
| 101 | - */ |
|
| 102 | - public function enable_role_taxonomy_order( $orderby, $query ) { |
|
| 103 | - global $wpdb; |
|
| 104 | - |
|
| 105 | - if ( $query->is_main_query() && $query->is_post_type_archive( 'team' ) ) { |
|
| 106 | - if ( isset( $this->options['team'] ) && isset( $this->options['team']['group_items_by_role'] ) ) { |
|
| 107 | - $new_orderby = "( |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Enable role taxonomy order. |
|
| 101 | + */ |
|
| 102 | + public function enable_role_taxonomy_order( $orderby, $query ) { |
|
| 103 | + global $wpdb; |
|
| 104 | + |
|
| 105 | + if ( $query->is_main_query() && $query->is_post_type_archive( 'team' ) ) { |
|
| 106 | + if ( isset( $this->options['team'] ) && isset( $this->options['team']['group_items_by_role'] ) ) { |
|
| 107 | + $new_orderby = "( |
|
| 108 | 108 | SELECT GROUP_CONCAT(lsx_to_term_order ORDER BY lsx_to_term_order ASC) |
| 109 | 109 | FROM $wpdb->term_relationships |
| 110 | 110 | INNER JOIN $wpdb->term_taxonomy USING (term_taxonomy_id) |
@@ -114,333 +114,333 @@ discard block |
||
| 114 | 114 | GROUP BY object_id |
| 115 | 115 | ) "; |
| 116 | 116 | |
| 117 | - $new_orderby .= ( 'ASC' == strtoupper( $query->get( 'order' ) ) ) ? 'ASC' : 'DESC'; |
|
| 118 | - $orderby = $new_orderby . ', ' . $orderby; |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - return $orderby; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * A filter to set the content area to a small column on single |
|
| 127 | - */ |
|
| 128 | - public function archive_class( $new_classes, $classes, $layout ) { |
|
| 129 | - if ( is_post_type_archive( 'team' ) ) { |
|
| 130 | - $new_classes = $classes; |
|
| 131 | - |
|
| 132 | - if ( 'grid' === $layout ) { |
|
| 133 | - $new_classes[] = 'col-xs-12 col-sm-6 col-md-3'; |
|
| 134 | - } else { |
|
| 135 | - $new_classes[] = 'col-xs-12'; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - return $new_classes; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * A filter to set the content area to a small column on single |
|
| 144 | - */ |
|
| 145 | - public function entry_class( $classes ) { |
|
| 146 | - global $lsx_to_archive; |
|
| 147 | - |
|
| 148 | - if ( 1 !== $lsx_to_archive ) { |
|
| 149 | - $lsx_to_archive = false; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if ( is_main_query() && is_singular( 'team' ) && false === $lsx_to_archive ) { |
|
| 153 | - if ( lsx_to_has_enquiry_contact() ) { |
|
| 154 | - $classes[] = 'col-xs-12 col-sm-7 col-md-8'; |
|
| 155 | - } else { |
|
| 156 | - $classes[] = 'col-xs-12'; |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - return $classes; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Sets the current tab selected. |
|
| 165 | - */ |
|
| 166 | - public function set_settings_current_tab( $settings_tab ) { |
|
| 167 | - if ( is_tax( 'role' ) ) { |
|
| 168 | - $taxonomy = get_query_var( 'taxonomy' ); |
|
| 169 | - |
|
| 170 | - if ( 'role' === $taxonomy ) { |
|
| 171 | - $settings_tab = 'team'; |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - return $settings_tab; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Adds our navigation links to the team single post |
|
| 180 | - * |
|
| 181 | - * @param $page_links array |
|
| 182 | - * @return $page_links array |
|
| 183 | - */ |
|
| 184 | - public function page_links( $page_links ) { |
|
| 185 | - if ( is_singular( 'team' ) ) { |
|
| 186 | - $this->page_links = $page_links; |
|
| 187 | - |
|
| 188 | - $this->get_map_link(); |
|
| 189 | - |
|
| 190 | - $this->get_related_posts_link(); |
|
| 191 | - $this->get_related_accommodation_link(); |
|
| 192 | - $this->get_related_destination_link(); |
|
| 193 | - $this->get_related_tours_link(); |
|
| 194 | - $this->get_related_reviews_link(); |
|
| 195 | - |
|
| 196 | - $this->get_gallery_link(); |
|
| 197 | - $this->get_videos_link(); |
|
| 198 | - |
|
| 199 | - $page_links = $this->page_links; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - return $page_links; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * Tests for the Related Posts and returns a link for the section |
|
| 207 | - */ |
|
| 208 | - public function get_related_posts_link() { |
|
| 209 | - $site_user = get_post_meta( get_the_ID(), 'site_user', true ); |
|
| 210 | - |
|
| 211 | - if ( ! empty( $site_user ) ) { |
|
| 212 | - if ( is_user_member_of_blog( $site_user ) ) { |
|
| 213 | - $user_posts = count_user_posts( $site_user, 'post' ); |
|
| 214 | - |
|
| 215 | - if ( $user_posts > 0 ) { |
|
| 216 | - $this->page_links['posts'] = esc_html__( 'Posts', 'to-team' ); |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * Tests for the Google Map and returns a link for the section |
|
| 224 | - */ |
|
| 225 | - public function get_map_link() { |
|
| 226 | - if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) { |
|
| 227 | - $this->page_links['team-map'] = esc_html__( 'Map', 'tour-operator' ); |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Tests for the Related Accommodation and returns a link for the section |
|
| 233 | - */ |
|
| 234 | - public function get_related_accommodation_link() { |
|
| 235 | - $connected_accommodation = get_post_meta( get_the_ID(), 'accommodation_to_team', false ); |
|
| 236 | - |
|
| 237 | - if ( post_type_exists( 'accommodation' ) && is_array( $connected_accommodation ) && ! empty( $connected_accommodation ) ) { |
|
| 238 | - $connected_accommodation = new \WP_Query( array( |
|
| 239 | - 'post_type' => 'accommodation', |
|
| 240 | - 'post__in' => $connected_accommodation, |
|
| 241 | - 'post_status' => 'publish', |
|
| 242 | - 'nopagin' => true, |
|
| 243 | - 'posts_per_page' => '-1', |
|
| 244 | - 'fields' => 'ids', |
|
| 245 | - ) ); |
|
| 246 | - |
|
| 247 | - $connected_accommodation = $connected_accommodation->posts; |
|
| 248 | - |
|
| 249 | - if ( is_array( $connected_accommodation ) && ! empty( $connected_accommodation ) ) { |
|
| 250 | - $this->page_links['accommodation'] = esc_html__( 'Accommodation', 'to-team' ); |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * Tests for the Related Destinations and returns a link for the section |
|
| 257 | - */ |
|
| 258 | - public function get_related_destination_link() { |
|
| 259 | - $connected_destination = get_post_meta( get_the_ID(), 'destination_to_team', false ); |
|
| 260 | - |
|
| 261 | - if ( post_type_exists( 'destination' ) && is_array( $connected_destination ) && ! empty( $connected_destination ) ) { |
|
| 262 | - $connected_destination = new \WP_Query( array( |
|
| 263 | - 'post_type' => 'destination', |
|
| 264 | - 'post__in' => $connected_destination, |
|
| 265 | - 'post_status' => 'publish', |
|
| 266 | - 'nopagin' => true, |
|
| 267 | - 'posts_per_page' => '-1', |
|
| 268 | - 'fields' => 'ids', |
|
| 269 | - ) ); |
|
| 270 | - |
|
| 271 | - $connected_destination = $connected_destination->posts; |
|
| 272 | - |
|
| 273 | - if ( is_array( $connected_destination ) && ! empty( $connected_destination ) ) { |
|
| 274 | - $this->page_links['destination'] = esc_html__( 'Destinations', 'to-team' ); |
|
| 275 | - } |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * Tests for the Related Tours and returns a link for the section |
|
| 281 | - */ |
|
| 282 | - public function get_related_tours_link() { |
|
| 283 | - $connected_tours = get_post_meta( get_the_ID(), 'tour_to_team', false ); |
|
| 284 | - |
|
| 285 | - if ( post_type_exists( 'tour' ) && is_array( $connected_tours ) && ! empty( $connected_tours ) ) { |
|
| 286 | - $connected_tours = new \WP_Query( array( |
|
| 287 | - 'post_type' => 'tour', |
|
| 288 | - 'post__in' => $connected_tours, |
|
| 289 | - 'post_status' => 'publish', |
|
| 290 | - 'nopagin' => true, |
|
| 291 | - 'posts_per_page' => '-1', |
|
| 292 | - 'fields' => 'ids', |
|
| 293 | - ) ); |
|
| 294 | - |
|
| 295 | - $connected_tours = $connected_tours->posts; |
|
| 296 | - |
|
| 297 | - if ( is_array( $connected_tours ) && ! empty( $connected_tours ) ) { |
|
| 298 | - $this->page_links['tours'] = esc_html__( 'Tours', 'to-team' ); |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * Tests for the Related Tours and returns a link for the section |
|
| 305 | - */ |
|
| 306 | - public function get_related_reviews_link() { |
|
| 307 | - $connected_reviews = get_post_meta( get_the_ID(), 'review_to_team', false ); |
|
| 308 | - |
|
| 309 | - if ( post_type_exists( 'review' ) && is_array( $connected_reviews ) && ! empty( $connected_reviews ) ) { |
|
| 310 | - $connected_reviews = new \WP_Query( array( |
|
| 311 | - 'post_type' => 'review', |
|
| 312 | - 'post__in' => $connected_reviews, |
|
| 313 | - 'post_status' => 'publish', |
|
| 314 | - 'nopagin' => true, |
|
| 315 | - 'posts_per_page' => '-1', |
|
| 316 | - 'fields' => 'ids', |
|
| 317 | - ) ); |
|
| 318 | - |
|
| 319 | - $connected_reviews = $connected_reviews->posts; |
|
| 320 | - |
|
| 321 | - if ( is_array( $connected_reviews ) && ! empty( $connected_reviews ) ) { |
|
| 322 | - $this->page_links['reviews'] = esc_html__( 'Reviews', 'to-team' ); |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * Tests for the Gallery and returns a link for the section |
|
| 329 | - */ |
|
| 330 | - public function get_gallery_link() { |
|
| 331 | - $gallery_ids = get_post_meta( get_the_ID(), 'gallery', false ); |
|
| 332 | - $envira_gallery = get_post_meta( get_the_ID(), 'envira_gallery', true ); |
|
| 333 | - |
|
| 334 | - if ( ( ! empty( $gallery_ids ) && is_array( $gallery_ids ) ) || ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) ) { |
|
| 335 | - if ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) { |
|
| 336 | - // Envira Gallery. |
|
| 337 | - $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-team' ); |
|
| 338 | - return; |
|
| 339 | - } else { |
|
| 340 | - if ( function_exists( 'envira_dynamic' ) ) { |
|
| 341 | - // Envira Gallery - Dynamic. |
|
| 342 | - $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-team' ); |
|
| 343 | - return; |
|
| 344 | - } else { |
|
| 345 | - // WordPress Gallery. |
|
| 346 | - $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-team' ); |
|
| 347 | - return; |
|
| 348 | - } |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * Tests for the Videos and returns a link for the section |
|
| 355 | - */ |
|
| 356 | - public function get_videos_link() { |
|
| 357 | - $videos_id = false; |
|
| 358 | - |
|
| 359 | - if ( class_exists( 'Envira_Videos' ) ) { |
|
| 360 | - $videos_id = get_post_meta( get_the_ID(), 'envira_video', true ); |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - if ( empty( $videos_id ) && function_exists( 'lsx_to_videos' ) ) { |
|
| 364 | - $videos_id = get_post_meta( get_the_ID(), 'videos', true ); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - if ( ! empty( $videos_id ) ) { |
|
| 368 | - $this->page_links['videos'] = esc_html__( 'Videos', 'to-team' ); |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * Adds the template tags to the top of the archive team |
|
| 374 | - */ |
|
| 375 | - public function archive_entry_top() { |
|
| 376 | - global $lsx_to_archive; |
|
| 377 | - |
|
| 378 | - if ( 'team' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { |
|
| 379 | - ?> |
|
| 117 | + $new_orderby .= ( 'ASC' == strtoupper( $query->get( 'order' ) ) ) ? 'ASC' : 'DESC'; |
|
| 118 | + $orderby = $new_orderby . ', ' . $orderby; |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + return $orderby; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * A filter to set the content area to a small column on single |
|
| 127 | + */ |
|
| 128 | + public function archive_class( $new_classes, $classes, $layout ) { |
|
| 129 | + if ( is_post_type_archive( 'team' ) ) { |
|
| 130 | + $new_classes = $classes; |
|
| 131 | + |
|
| 132 | + if ( 'grid' === $layout ) { |
|
| 133 | + $new_classes[] = 'col-xs-12 col-sm-6 col-md-3'; |
|
| 134 | + } else { |
|
| 135 | + $new_classes[] = 'col-xs-12'; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + return $new_classes; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * A filter to set the content area to a small column on single |
|
| 144 | + */ |
|
| 145 | + public function entry_class( $classes ) { |
|
| 146 | + global $lsx_to_archive; |
|
| 147 | + |
|
| 148 | + if ( 1 !== $lsx_to_archive ) { |
|
| 149 | + $lsx_to_archive = false; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if ( is_main_query() && is_singular( 'team' ) && false === $lsx_to_archive ) { |
|
| 153 | + if ( lsx_to_has_enquiry_contact() ) { |
|
| 154 | + $classes[] = 'col-xs-12 col-sm-7 col-md-8'; |
|
| 155 | + } else { |
|
| 156 | + $classes[] = 'col-xs-12'; |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + return $classes; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Sets the current tab selected. |
|
| 165 | + */ |
|
| 166 | + public function set_settings_current_tab( $settings_tab ) { |
|
| 167 | + if ( is_tax( 'role' ) ) { |
|
| 168 | + $taxonomy = get_query_var( 'taxonomy' ); |
|
| 169 | + |
|
| 170 | + if ( 'role' === $taxonomy ) { |
|
| 171 | + $settings_tab = 'team'; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + return $settings_tab; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Adds our navigation links to the team single post |
|
| 180 | + * |
|
| 181 | + * @param $page_links array |
|
| 182 | + * @return $page_links array |
|
| 183 | + */ |
|
| 184 | + public function page_links( $page_links ) { |
|
| 185 | + if ( is_singular( 'team' ) ) { |
|
| 186 | + $this->page_links = $page_links; |
|
| 187 | + |
|
| 188 | + $this->get_map_link(); |
|
| 189 | + |
|
| 190 | + $this->get_related_posts_link(); |
|
| 191 | + $this->get_related_accommodation_link(); |
|
| 192 | + $this->get_related_destination_link(); |
|
| 193 | + $this->get_related_tours_link(); |
|
| 194 | + $this->get_related_reviews_link(); |
|
| 195 | + |
|
| 196 | + $this->get_gallery_link(); |
|
| 197 | + $this->get_videos_link(); |
|
| 198 | + |
|
| 199 | + $page_links = $this->page_links; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + return $page_links; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * Tests for the Related Posts and returns a link for the section |
|
| 207 | + */ |
|
| 208 | + public function get_related_posts_link() { |
|
| 209 | + $site_user = get_post_meta( get_the_ID(), 'site_user', true ); |
|
| 210 | + |
|
| 211 | + if ( ! empty( $site_user ) ) { |
|
| 212 | + if ( is_user_member_of_blog( $site_user ) ) { |
|
| 213 | + $user_posts = count_user_posts( $site_user, 'post' ); |
|
| 214 | + |
|
| 215 | + if ( $user_posts > 0 ) { |
|
| 216 | + $this->page_links['posts'] = esc_html__( 'Posts', 'to-team' ); |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * Tests for the Google Map and returns a link for the section |
|
| 224 | + */ |
|
| 225 | + public function get_map_link() { |
|
| 226 | + if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) { |
|
| 227 | + $this->page_links['team-map'] = esc_html__( 'Map', 'tour-operator' ); |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Tests for the Related Accommodation and returns a link for the section |
|
| 233 | + */ |
|
| 234 | + public function get_related_accommodation_link() { |
|
| 235 | + $connected_accommodation = get_post_meta( get_the_ID(), 'accommodation_to_team', false ); |
|
| 236 | + |
|
| 237 | + if ( post_type_exists( 'accommodation' ) && is_array( $connected_accommodation ) && ! empty( $connected_accommodation ) ) { |
|
| 238 | + $connected_accommodation = new \WP_Query( array( |
|
| 239 | + 'post_type' => 'accommodation', |
|
| 240 | + 'post__in' => $connected_accommodation, |
|
| 241 | + 'post_status' => 'publish', |
|
| 242 | + 'nopagin' => true, |
|
| 243 | + 'posts_per_page' => '-1', |
|
| 244 | + 'fields' => 'ids', |
|
| 245 | + ) ); |
|
| 246 | + |
|
| 247 | + $connected_accommodation = $connected_accommodation->posts; |
|
| 248 | + |
|
| 249 | + if ( is_array( $connected_accommodation ) && ! empty( $connected_accommodation ) ) { |
|
| 250 | + $this->page_links['accommodation'] = esc_html__( 'Accommodation', 'to-team' ); |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * Tests for the Related Destinations and returns a link for the section |
|
| 257 | + */ |
|
| 258 | + public function get_related_destination_link() { |
|
| 259 | + $connected_destination = get_post_meta( get_the_ID(), 'destination_to_team', false ); |
|
| 260 | + |
|
| 261 | + if ( post_type_exists( 'destination' ) && is_array( $connected_destination ) && ! empty( $connected_destination ) ) { |
|
| 262 | + $connected_destination = new \WP_Query( array( |
|
| 263 | + 'post_type' => 'destination', |
|
| 264 | + 'post__in' => $connected_destination, |
|
| 265 | + 'post_status' => 'publish', |
|
| 266 | + 'nopagin' => true, |
|
| 267 | + 'posts_per_page' => '-1', |
|
| 268 | + 'fields' => 'ids', |
|
| 269 | + ) ); |
|
| 270 | + |
|
| 271 | + $connected_destination = $connected_destination->posts; |
|
| 272 | + |
|
| 273 | + if ( is_array( $connected_destination ) && ! empty( $connected_destination ) ) { |
|
| 274 | + $this->page_links['destination'] = esc_html__( 'Destinations', 'to-team' ); |
|
| 275 | + } |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * Tests for the Related Tours and returns a link for the section |
|
| 281 | + */ |
|
| 282 | + public function get_related_tours_link() { |
|
| 283 | + $connected_tours = get_post_meta( get_the_ID(), 'tour_to_team', false ); |
|
| 284 | + |
|
| 285 | + if ( post_type_exists( 'tour' ) && is_array( $connected_tours ) && ! empty( $connected_tours ) ) { |
|
| 286 | + $connected_tours = new \WP_Query( array( |
|
| 287 | + 'post_type' => 'tour', |
|
| 288 | + 'post__in' => $connected_tours, |
|
| 289 | + 'post_status' => 'publish', |
|
| 290 | + 'nopagin' => true, |
|
| 291 | + 'posts_per_page' => '-1', |
|
| 292 | + 'fields' => 'ids', |
|
| 293 | + ) ); |
|
| 294 | + |
|
| 295 | + $connected_tours = $connected_tours->posts; |
|
| 296 | + |
|
| 297 | + if ( is_array( $connected_tours ) && ! empty( $connected_tours ) ) { |
|
| 298 | + $this->page_links['tours'] = esc_html__( 'Tours', 'to-team' ); |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Tests for the Related Tours and returns a link for the section |
|
| 305 | + */ |
|
| 306 | + public function get_related_reviews_link() { |
|
| 307 | + $connected_reviews = get_post_meta( get_the_ID(), 'review_to_team', false ); |
|
| 308 | + |
|
| 309 | + if ( post_type_exists( 'review' ) && is_array( $connected_reviews ) && ! empty( $connected_reviews ) ) { |
|
| 310 | + $connected_reviews = new \WP_Query( array( |
|
| 311 | + 'post_type' => 'review', |
|
| 312 | + 'post__in' => $connected_reviews, |
|
| 313 | + 'post_status' => 'publish', |
|
| 314 | + 'nopagin' => true, |
|
| 315 | + 'posts_per_page' => '-1', |
|
| 316 | + 'fields' => 'ids', |
|
| 317 | + ) ); |
|
| 318 | + |
|
| 319 | + $connected_reviews = $connected_reviews->posts; |
|
| 320 | + |
|
| 321 | + if ( is_array( $connected_reviews ) && ! empty( $connected_reviews ) ) { |
|
| 322 | + $this->page_links['reviews'] = esc_html__( 'Reviews', 'to-team' ); |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * Tests for the Gallery and returns a link for the section |
|
| 329 | + */ |
|
| 330 | + public function get_gallery_link() { |
|
| 331 | + $gallery_ids = get_post_meta( get_the_ID(), 'gallery', false ); |
|
| 332 | + $envira_gallery = get_post_meta( get_the_ID(), 'envira_gallery', true ); |
|
| 333 | + |
|
| 334 | + if ( ( ! empty( $gallery_ids ) && is_array( $gallery_ids ) ) || ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) ) { |
|
| 335 | + if ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) { |
|
| 336 | + // Envira Gallery. |
|
| 337 | + $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-team' ); |
|
| 338 | + return; |
|
| 339 | + } else { |
|
| 340 | + if ( function_exists( 'envira_dynamic' ) ) { |
|
| 341 | + // Envira Gallery - Dynamic. |
|
| 342 | + $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-team' ); |
|
| 343 | + return; |
|
| 344 | + } else { |
|
| 345 | + // WordPress Gallery. |
|
| 346 | + $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-team' ); |
|
| 347 | + return; |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * Tests for the Videos and returns a link for the section |
|
| 355 | + */ |
|
| 356 | + public function get_videos_link() { |
|
| 357 | + $videos_id = false; |
|
| 358 | + |
|
| 359 | + if ( class_exists( 'Envira_Videos' ) ) { |
|
| 360 | + $videos_id = get_post_meta( get_the_ID(), 'envira_video', true ); |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + if ( empty( $videos_id ) && function_exists( 'lsx_to_videos' ) ) { |
|
| 364 | + $videos_id = get_post_meta( get_the_ID(), 'videos', true ); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + if ( ! empty( $videos_id ) ) { |
|
| 368 | + $this->page_links['videos'] = esc_html__( 'Videos', 'to-team' ); |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * Adds the template tags to the top of the archive team |
|
| 374 | + */ |
|
| 375 | + public function archive_entry_top() { |
|
| 376 | + global $lsx_to_archive; |
|
| 377 | + |
|
| 378 | + if ( 'team' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { |
|
| 379 | + ?> |
|
| 380 | 380 | <?php if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?> |
| 381 | 381 | <div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-grid-mode"> |
| 382 | 382 | <?php |
| 383 | - $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
|
| 384 | - |
|
| 385 | - lsx_to_team_role( '<span class="' . $meta_class . 'role"><span class="lsx-to-meta-data-key">' . __( 'Role', 'to-team' ) . ':</span> ', '</span>' ); |
|
| 386 | - lsx_to_team_contact_number( '<span class="' . $meta_class . 'phone">', '</span>' ); |
|
| 387 | - lsx_to_team_contact_email( '<span class="' . $meta_class . 'email">', '</span>' ); |
|
| 388 | - lsx_to_team_contact_skype( '<span class="' . $meta_class . 'skype">', '</span>' ); |
|
| 389 | - lsx_to_team_social_profiles( '<div class="' . $meta_class . 'socials">', '</div>' ); |
|
| 390 | - ?> |
|
| 383 | + $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
|
| 384 | + |
|
| 385 | + lsx_to_team_role( '<span class="' . $meta_class . 'role"><span class="lsx-to-meta-data-key">' . __( 'Role', 'to-team' ) . ':</span> ', '</span>' ); |
|
| 386 | + lsx_to_team_contact_number( '<span class="' . $meta_class . 'phone">', '</span>' ); |
|
| 387 | + lsx_to_team_contact_email( '<span class="' . $meta_class . 'email">', '</span>' ); |
|
| 388 | + lsx_to_team_contact_skype( '<span class="' . $meta_class . 'skype">', '</span>' ); |
|
| 389 | + lsx_to_team_social_profiles( '<div class="' . $meta_class . 'socials">', '</div>' ); |
|
| 390 | + ?> |
|
| 391 | 391 | </div> |
| 392 | 392 | <?php } ?> |
| 393 | 393 | <?php |
| 394 | - } |
|
| 395 | - } |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | - /** |
|
| 398 | - * Adds the template tags to the bottom of the archive team |
|
| 399 | - */ |
|
| 400 | - public function archive_entry_bottom() { |
|
| 401 | - global $lsx_to_archive; |
|
| 397 | + /** |
|
| 398 | + * Adds the template tags to the bottom of the archive team |
|
| 399 | + */ |
|
| 400 | + public function archive_entry_bottom() { |
|
| 401 | + global $lsx_to_archive; |
|
| 402 | 402 | |
| 403 | - if ( 'team' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { |
|
| 404 | - ?> |
|
| 403 | + if ( 'team' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { |
|
| 404 | + ?> |
|
| 405 | 405 | </div> |
| 406 | 406 | |
| 407 | 407 | <?php if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?> |
| 408 | 408 | <div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-list-mode"> |
| 409 | 409 | <?php |
| 410 | - $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
|
| 411 | - |
|
| 412 | - lsx_to_team_role( '<span class="' . $meta_class . 'role"><span class="lsx-to-meta-data-key">' . __( 'Role', 'to-team' ) . ':</span> ', '</span>' ); |
|
| 413 | - lsx_to_team_contact_number( '<span class="' . $meta_class . 'phone">', '</span>' ); |
|
| 414 | - lsx_to_team_contact_email( '<span class="' . $meta_class . 'email">', '</span>' ); |
|
| 415 | - lsx_to_team_contact_skype( '<span class="' . $meta_class . 'skype">', '</span>' ); |
|
| 416 | - lsx_to_team_social_profiles( '<div class="' . $meta_class . 'socials">', '</div>' ); |
|
| 417 | - ?> |
|
| 410 | + $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
|
| 411 | + |
|
| 412 | + lsx_to_team_role( '<span class="' . $meta_class . 'role"><span class="lsx-to-meta-data-key">' . __( 'Role', 'to-team' ) . ':</span> ', '</span>' ); |
|
| 413 | + lsx_to_team_contact_number( '<span class="' . $meta_class . 'phone">', '</span>' ); |
|
| 414 | + lsx_to_team_contact_email( '<span class="' . $meta_class . 'email">', '</span>' ); |
|
| 415 | + lsx_to_team_contact_skype( '<span class="' . $meta_class . 'skype">', '</span>' ); |
|
| 416 | + lsx_to_team_social_profiles( '<div class="' . $meta_class . 'socials">', '</div>' ); |
|
| 417 | + ?> |
|
| 418 | 418 | </div> |
| 419 | 419 | <?php } ?> |
| 420 | 420 | |
| 421 | 421 | <?php |
| 422 | - $member_name = get_the_title(); |
|
| 423 | - $has_single = ! lsx_to_is_single_disabled(); |
|
| 424 | - ?> |
|
| 422 | + $member_name = get_the_title(); |
|
| 423 | + $has_single = ! lsx_to_is_single_disabled(); |
|
| 424 | + ?> |
|
| 425 | 425 | |
| 426 | 426 | <?php if ( $has_single && 'grid' === tour_operator()->archive_layout ) : ?> |
| 427 | 427 | <p class="text-center lsx-to-single-link"><a href="<?php the_permalink(); ?>"><?php echo esc_html__( 'More about', 'to-team' ) . ' ' . esc_html( strtok( $member_name, ' ' ) ); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></p> |
| 428 | 428 | <?php endif; ?> |
| 429 | 429 | </div> |
| 430 | 430 | <?php |
| 431 | - } |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * Adds the template tags to the bottom of the single team |
|
| 436 | - */ |
|
| 437 | - public function single_content_bottom() { |
|
| 438 | - if ( is_singular( 'team' ) ) { |
|
| 439 | - if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) : |
|
| 440 | - global $post; |
|
| 441 | - $map_title = $post->post_title; |
|
| 442 | - $map_title = $map_title . __( "'s favourite places", 'to-team' ); |
|
| 443 | - ?> |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * Adds the template tags to the bottom of the single team |
|
| 436 | + */ |
|
| 437 | + public function single_content_bottom() { |
|
| 438 | + if ( is_singular( 'team' ) ) { |
|
| 439 | + if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) : |
|
| 440 | + global $post; |
|
| 441 | + $map_title = $post->post_title; |
|
| 442 | + $map_title = $map_title . __( "'s favourite places", 'to-team' ); |
|
| 443 | + ?> |
|
| 444 | 444 | <section id="team-map" class="lsx-to-section lsx-to-collapse-section"> |
| 445 | 445 | <h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-team-map"><?php echo esc_html( $map_title ); ?></h2> |
| 446 | 446 | |
@@ -451,58 +451,58 @@ discard block |
||
| 451 | 451 | </div> |
| 452 | 452 | </section> |
| 453 | 453 | <?php |
| 454 | - endif; |
|
| 455 | - |
|
| 456 | - lsx_to_team_posts(); |
|
| 457 | - |
|
| 458 | - lsx_to_team_accommodation(); |
|
| 459 | - |
|
| 460 | - lsx_to_team_destination(); |
|
| 461 | - |
|
| 462 | - lsx_to_team_tours(); |
|
| 463 | - |
|
| 464 | - lsx_to_team_reviews(); |
|
| 465 | - |
|
| 466 | - lsx_to_gallery( '<section id="gallery" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-gallery">' . esc_html__( 'Gallery', 'to-team' ) . '</h2><div id="collapse-gallery" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
| 467 | - |
|
| 468 | - if ( function_exists( 'lsx_to_videos' ) ) { |
|
| 469 | - lsx_to_videos( '<section id="videos" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-videos">' . esc_html__( 'Videos', 'to-team' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
| 470 | - } elseif ( class_exists( 'Envira_Videos' ) ) { |
|
| 471 | - lsx_to_envira_videos( '<section id="videos" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-videos">' . esc_html__( 'Videos', 'to-team' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
| 472 | - } |
|
| 473 | - } |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - public function lsx_to_maps_args( $args, $post_id ) { |
|
| 477 | - if ( is_singular( 'team' ) ) { |
|
| 478 | - $accommodation_connected = get_post_meta( get_the_ID(), 'accommodation_to_team' ); |
|
| 479 | - if ( is_array( $accommodation_connected ) && ! empty( $accommodation_connected ) ) { |
|
| 480 | - $args = array( |
|
| 481 | - 'lat' => true, |
|
| 482 | - 'long' => true, |
|
| 483 | - 'connections' => $accommodation_connected, |
|
| 484 | - 'content' => 'excerpt', |
|
| 485 | - 'type' => 'cluster', |
|
| 486 | - 'width' => '100%', |
|
| 487 | - 'height' => '500px', |
|
| 488 | - ); |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - return $args; |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - public function lsx_to_has_maps_location( $location, $id ) { |
|
| 495 | - if ( is_singular( 'team' ) ) { |
|
| 496 | - $accommodation_connected = get_post_meta( $id, 'accommodation_to_team' ); |
|
| 497 | - if ( is_array( $accommodation_connected ) && ! empty( $accommodation_connected ) ) { |
|
| 498 | - $location = array( |
|
| 499 | - 'lat' => true, |
|
| 500 | - 'connections' => $accommodation_connected, |
|
| 501 | - ); |
|
| 502 | - } |
|
| 503 | - } |
|
| 504 | - return $location; |
|
| 505 | - } |
|
| 454 | + endif; |
|
| 455 | + |
|
| 456 | + lsx_to_team_posts(); |
|
| 457 | + |
|
| 458 | + lsx_to_team_accommodation(); |
|
| 459 | + |
|
| 460 | + lsx_to_team_destination(); |
|
| 461 | + |
|
| 462 | + lsx_to_team_tours(); |
|
| 463 | + |
|
| 464 | + lsx_to_team_reviews(); |
|
| 465 | + |
|
| 466 | + lsx_to_gallery( '<section id="gallery" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-gallery">' . esc_html__( 'Gallery', 'to-team' ) . '</h2><div id="collapse-gallery" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
| 467 | + |
|
| 468 | + if ( function_exists( 'lsx_to_videos' ) ) { |
|
| 469 | + lsx_to_videos( '<section id="videos" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-videos">' . esc_html__( 'Videos', 'to-team' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
| 470 | + } elseif ( class_exists( 'Envira_Videos' ) ) { |
|
| 471 | + lsx_to_envira_videos( '<section id="videos" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-videos">' . esc_html__( 'Videos', 'to-team' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
|
| 472 | + } |
|
| 473 | + } |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + public function lsx_to_maps_args( $args, $post_id ) { |
|
| 477 | + if ( is_singular( 'team' ) ) { |
|
| 478 | + $accommodation_connected = get_post_meta( get_the_ID(), 'accommodation_to_team' ); |
|
| 479 | + if ( is_array( $accommodation_connected ) && ! empty( $accommodation_connected ) ) { |
|
| 480 | + $args = array( |
|
| 481 | + 'lat' => true, |
|
| 482 | + 'long' => true, |
|
| 483 | + 'connections' => $accommodation_connected, |
|
| 484 | + 'content' => 'excerpt', |
|
| 485 | + 'type' => 'cluster', |
|
| 486 | + 'width' => '100%', |
|
| 487 | + 'height' => '500px', |
|
| 488 | + ); |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + return $args; |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + public function lsx_to_has_maps_location( $location, $id ) { |
|
| 495 | + if ( is_singular( 'team' ) ) { |
|
| 496 | + $accommodation_connected = get_post_meta( $id, 'accommodation_to_team' ); |
|
| 497 | + if ( is_array( $accommodation_connected ) && ! empty( $accommodation_connected ) ) { |
|
| 498 | + $location = array( |
|
| 499 | + 'lat' => true, |
|
| 500 | + 'connections' => $accommodation_connected, |
|
| 501 | + ); |
|
| 502 | + } |
|
| 503 | + } |
|
| 504 | + return $location; |
|
| 505 | + } |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | global $lsx_to_team_frontend; |
@@ -17,192 +17,192 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | class LSX_TO_Team_Admin extends LSX_TO_Team { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Constructor |
|
| 22 | - */ |
|
| 23 | - public function __construct() { |
|
| 24 | - $this->set_vars(); |
|
| 25 | - |
|
| 26 | - add_action( 'init', array( $this, 'init' ), 20 ); |
|
| 27 | - |
|
| 28 | - add_filter( 'lsx_get_post-types_configs', array( $this, 'post_type_config' ), 10, 1 ); |
|
| 29 | - add_filter( 'lsx_get_metaboxes_configs', array( $this, 'meta_box_config' ), 10, 1 ); |
|
| 30 | - add_filter( 'lsx_get_taxonomies_configs', array( $this, 'taxonomy_config' ), 10, 1 ); |
|
| 31 | - |
|
| 32 | - add_filter( 'lsx_to_destination_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 33 | - add_filter( 'lsx_to_tour_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 34 | - add_filter( 'lsx_to_accommodation_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 35 | - |
|
| 36 | - add_filter( 'lsx_to_special_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 37 | - add_filter( 'lsx_to_review_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 38 | - add_filter( 'lsx_to_activity_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 39 | - |
|
| 40 | - add_filter( 'lsx_to_taxonomies', array( $this, 'to_register_taxonomy' ), 10, 1 ); |
|
| 41 | - add_filter( 'lsx_to_framework_taxonomies', array( $this, 'to_register_taxonomy' ), 10, 1 ); |
|
| 42 | - add_filter( 'lsx_to_framework_taxonomies_plural', array( $this, 'to_register_taxonomy_plural' ), 10, 1 ); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Register the taxonomy with the TO plugin |
|
| 47 | - * |
|
| 48 | - * @since 0.1.0 |
|
| 49 | - */ |
|
| 50 | - public function to_register_taxonomy( $taxonomies ) { |
|
| 51 | - $taxonomies['role'] = esc_attr__( 'Role', 'to-team' ); |
|
| 52 | - return $taxonomies; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Register the taxonomy with the TO plugin |
|
| 57 | - * |
|
| 58 | - * @since 0.1.0 |
|
| 59 | - */ |
|
| 60 | - public function to_register_taxonomy_plural( $taxonomies ) { |
|
| 61 | - $taxonomies['role'] = esc_attr__( 'Roles', 'to-team' ); |
|
| 62 | - return $taxonomies; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Output the form field for this metadata when adding a new term |
|
| 67 | - * |
|
| 68 | - * @since 0.1.0 |
|
| 69 | - */ |
|
| 70 | - public function init() { |
|
| 71 | - if ( function_exists( 'lsx_to_get_taxonomies' ) ) { |
|
| 72 | - $this->taxonomies = array_keys( lsx_to_get_taxonomies() ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - add_filter( 'lsx_to_taxonomy_widget_taxonomies', array( $this, 'widget_taxonomies' ), 10, 1 ); |
|
| 76 | - |
|
| 77 | - if ( false !== $this->taxonomies ) { |
|
| 78 | - add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 ); |
|
| 79 | - add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 ); |
|
| 80 | - |
|
| 81 | - foreach ( $this->taxonomies as $taxonomy ) { |
|
| 82 | - add_action( "{$taxonomy}_edit_form_fields", array( $this, 'add_expert_form_field' ), 3, 1 ); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - add_action( 'lsx_to_framework_team_tab_content', array( $this, 'general_settings' ), 10, 2 ); |
|
| 87 | - add_action( 'lsx_to_framework_team_tab_content', array( $this, 'archive_settings' ), 10, 2 ); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Register the activity post type config |
|
| 92 | - * |
|
| 93 | - * @param $objects |
|
| 94 | - * @return array |
|
| 95 | - */ |
|
| 96 | - public function post_type_config( $objects ) { |
|
| 97 | - foreach ( $this->post_types as $key => $label ) { |
|
| 98 | - if ( file_exists( LSX_TO_TEAM_PATH . 'includes/post-types/config-' . $key . '.php' ) ) { |
|
| 99 | - $objects[ $key ] = include LSX_TO_TEAM_PATH . 'includes/post-types/config-' . $key . '.php'; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - return $objects; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Register the activity metabox config |
|
| 108 | - * |
|
| 109 | - * @param $meta_boxes |
|
| 110 | - * @return array |
|
| 111 | - */ |
|
| 112 | - public function meta_box_config( $meta_boxes ) { |
|
| 113 | - foreach ( $this->post_types as $key => $label ) { |
|
| 114 | - if ( file_exists( LSX_TO_TEAM_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) { |
|
| 115 | - $meta_boxes[ $key ] = include LSX_TO_TEAM_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - return $meta_boxes; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Register the Role taxonomy |
|
| 124 | - * |
|
| 125 | - * |
|
| 126 | - * @return null |
|
| 127 | - */ |
|
| 128 | - public function taxonomy_config( $taxonomies ) { |
|
| 129 | - if ( file_exists( LSX_TO_TEAM_PATH . 'includes/taxonomies/config-role.php' ) ) { |
|
| 130 | - $taxonomies['role'] = include LSX_TO_TEAM_PATH . 'includes/taxonomies/config-role.php'; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - return $taxonomies; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Adds in the fields to the Tour Operators Post Types. |
|
| 138 | - */ |
|
| 139 | - public function custom_fields( $fields ) { |
|
| 140 | - global $post, $typenow, $current_screen; |
|
| 141 | - |
|
| 142 | - if ( $post && $post->post_type ) { |
|
| 143 | - $post_type = $post->post_type; |
|
| 144 | - } elseif ( $typenow ) { |
|
| 145 | - $post_type = $typenow; |
|
| 146 | - } elseif ( $current_screen && $current_screen->post_type ) { |
|
| 147 | - $post_type = $current_screen->post_type; |
|
| 148 | - } elseif ( isset( $_REQUEST['post_type'] ) ) { |
|
| 149 | - $post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
| 150 | - } elseif ( isset( $_REQUEST['post'] ) ) { |
|
| 151 | - $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
| 152 | - } else { |
|
| 153 | - $post_type = false; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - if ( false !== $post_type ) { |
|
| 157 | - $fields[] = array( |
|
| 158 | - 'id' => 'team_title', |
|
| 159 | - 'name' => 'Teams', |
|
| 160 | - 'type' => 'title', |
|
| 161 | - 'cols' => 12, |
|
| 162 | - ); |
|
| 163 | - |
|
| 164 | - $fields[] = array( |
|
| 165 | - 'id' => 'team_to_' . $post_type, |
|
| 166 | - 'name' => 'Specials related with this ' . $post_type, |
|
| 167 | - 'type' => 'post_select', |
|
| 168 | - 'use_ajax' => false, |
|
| 169 | - 'query' => array( |
|
| 170 | - 'post_type' => 'team', |
|
| 171 | - 'nopagin' => true, |
|
| 172 | - 'posts_per_page' => '-1', |
|
| 173 | - 'orderby' => 'title', |
|
| 174 | - 'order' => 'ASC', |
|
| 175 | - ), |
|
| 176 | - 'repeatable' => true, |
|
| 177 | - 'allow_none' => true, |
|
| 178 | - 'cols' => 12, |
|
| 179 | - ); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - return $fields; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Output the form field for this metadata when adding a new term |
|
| 187 | - * |
|
| 188 | - * @since 0.1.0 |
|
| 189 | - */ |
|
| 190 | - public function add_expert_form_field( $term = false ) { |
|
| 191 | - if ( is_object( $term ) ) { |
|
| 192 | - $value = get_term_meta( $term->term_id, 'expert', true ); |
|
| 193 | - } else { |
|
| 194 | - $value = false; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - $experts = get_posts( |
|
| 198 | - array( |
|
| 199 | - 'post_type' => 'team', |
|
| 200 | - 'posts_per_page' => -1, |
|
| 201 | - 'orderby' => 'menu_order', |
|
| 202 | - 'order' => 'ASC', |
|
| 203 | - ) |
|
| 204 | - ); |
|
| 205 | - ?> |
|
| 20 | + /** |
|
| 21 | + * Constructor |
|
| 22 | + */ |
|
| 23 | + public function __construct() { |
|
| 24 | + $this->set_vars(); |
|
| 25 | + |
|
| 26 | + add_action( 'init', array( $this, 'init' ), 20 ); |
|
| 27 | + |
|
| 28 | + add_filter( 'lsx_get_post-types_configs', array( $this, 'post_type_config' ), 10, 1 ); |
|
| 29 | + add_filter( 'lsx_get_metaboxes_configs', array( $this, 'meta_box_config' ), 10, 1 ); |
|
| 30 | + add_filter( 'lsx_get_taxonomies_configs', array( $this, 'taxonomy_config' ), 10, 1 ); |
|
| 31 | + |
|
| 32 | + add_filter( 'lsx_to_destination_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 33 | + add_filter( 'lsx_to_tour_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 34 | + add_filter( 'lsx_to_accommodation_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 35 | + |
|
| 36 | + add_filter( 'lsx_to_special_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 37 | + add_filter( 'lsx_to_review_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 38 | + add_filter( 'lsx_to_activity_custom_fields', array( $this, 'custom_fields' ) ); |
|
| 39 | + |
|
| 40 | + add_filter( 'lsx_to_taxonomies', array( $this, 'to_register_taxonomy' ), 10, 1 ); |
|
| 41 | + add_filter( 'lsx_to_framework_taxonomies', array( $this, 'to_register_taxonomy' ), 10, 1 ); |
|
| 42 | + add_filter( 'lsx_to_framework_taxonomies_plural', array( $this, 'to_register_taxonomy_plural' ), 10, 1 ); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Register the taxonomy with the TO plugin |
|
| 47 | + * |
|
| 48 | + * @since 0.1.0 |
|
| 49 | + */ |
|
| 50 | + public function to_register_taxonomy( $taxonomies ) { |
|
| 51 | + $taxonomies['role'] = esc_attr__( 'Role', 'to-team' ); |
|
| 52 | + return $taxonomies; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Register the taxonomy with the TO plugin |
|
| 57 | + * |
|
| 58 | + * @since 0.1.0 |
|
| 59 | + */ |
|
| 60 | + public function to_register_taxonomy_plural( $taxonomies ) { |
|
| 61 | + $taxonomies['role'] = esc_attr__( 'Roles', 'to-team' ); |
|
| 62 | + return $taxonomies; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Output the form field for this metadata when adding a new term |
|
| 67 | + * |
|
| 68 | + * @since 0.1.0 |
|
| 69 | + */ |
|
| 70 | + public function init() { |
|
| 71 | + if ( function_exists( 'lsx_to_get_taxonomies' ) ) { |
|
| 72 | + $this->taxonomies = array_keys( lsx_to_get_taxonomies() ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + add_filter( 'lsx_to_taxonomy_widget_taxonomies', array( $this, 'widget_taxonomies' ), 10, 1 ); |
|
| 76 | + |
|
| 77 | + if ( false !== $this->taxonomies ) { |
|
| 78 | + add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 ); |
|
| 79 | + add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 ); |
|
| 80 | + |
|
| 81 | + foreach ( $this->taxonomies as $taxonomy ) { |
|
| 82 | + add_action( "{$taxonomy}_edit_form_fields", array( $this, 'add_expert_form_field' ), 3, 1 ); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + add_action( 'lsx_to_framework_team_tab_content', array( $this, 'general_settings' ), 10, 2 ); |
|
| 87 | + add_action( 'lsx_to_framework_team_tab_content', array( $this, 'archive_settings' ), 10, 2 ); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Register the activity post type config |
|
| 92 | + * |
|
| 93 | + * @param $objects |
|
| 94 | + * @return array |
|
| 95 | + */ |
|
| 96 | + public function post_type_config( $objects ) { |
|
| 97 | + foreach ( $this->post_types as $key => $label ) { |
|
| 98 | + if ( file_exists( LSX_TO_TEAM_PATH . 'includes/post-types/config-' . $key . '.php' ) ) { |
|
| 99 | + $objects[ $key ] = include LSX_TO_TEAM_PATH . 'includes/post-types/config-' . $key . '.php'; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + return $objects; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Register the activity metabox config |
|
| 108 | + * |
|
| 109 | + * @param $meta_boxes |
|
| 110 | + * @return array |
|
| 111 | + */ |
|
| 112 | + public function meta_box_config( $meta_boxes ) { |
|
| 113 | + foreach ( $this->post_types as $key => $label ) { |
|
| 114 | + if ( file_exists( LSX_TO_TEAM_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) { |
|
| 115 | + $meta_boxes[ $key ] = include LSX_TO_TEAM_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + return $meta_boxes; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Register the Role taxonomy |
|
| 124 | + * |
|
| 125 | + * |
|
| 126 | + * @return null |
|
| 127 | + */ |
|
| 128 | + public function taxonomy_config( $taxonomies ) { |
|
| 129 | + if ( file_exists( LSX_TO_TEAM_PATH . 'includes/taxonomies/config-role.php' ) ) { |
|
| 130 | + $taxonomies['role'] = include LSX_TO_TEAM_PATH . 'includes/taxonomies/config-role.php'; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + return $taxonomies; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Adds in the fields to the Tour Operators Post Types. |
|
| 138 | + */ |
|
| 139 | + public function custom_fields( $fields ) { |
|
| 140 | + global $post, $typenow, $current_screen; |
|
| 141 | + |
|
| 142 | + if ( $post && $post->post_type ) { |
|
| 143 | + $post_type = $post->post_type; |
|
| 144 | + } elseif ( $typenow ) { |
|
| 145 | + $post_type = $typenow; |
|
| 146 | + } elseif ( $current_screen && $current_screen->post_type ) { |
|
| 147 | + $post_type = $current_screen->post_type; |
|
| 148 | + } elseif ( isset( $_REQUEST['post_type'] ) ) { |
|
| 149 | + $post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
| 150 | + } elseif ( isset( $_REQUEST['post'] ) ) { |
|
| 151 | + $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
| 152 | + } else { |
|
| 153 | + $post_type = false; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + if ( false !== $post_type ) { |
|
| 157 | + $fields[] = array( |
|
| 158 | + 'id' => 'team_title', |
|
| 159 | + 'name' => 'Teams', |
|
| 160 | + 'type' => 'title', |
|
| 161 | + 'cols' => 12, |
|
| 162 | + ); |
|
| 163 | + |
|
| 164 | + $fields[] = array( |
|
| 165 | + 'id' => 'team_to_' . $post_type, |
|
| 166 | + 'name' => 'Specials related with this ' . $post_type, |
|
| 167 | + 'type' => 'post_select', |
|
| 168 | + 'use_ajax' => false, |
|
| 169 | + 'query' => array( |
|
| 170 | + 'post_type' => 'team', |
|
| 171 | + 'nopagin' => true, |
|
| 172 | + 'posts_per_page' => '-1', |
|
| 173 | + 'orderby' => 'title', |
|
| 174 | + 'order' => 'ASC', |
|
| 175 | + ), |
|
| 176 | + 'repeatable' => true, |
|
| 177 | + 'allow_none' => true, |
|
| 178 | + 'cols' => 12, |
|
| 179 | + ); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + return $fields; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Output the form field for this metadata when adding a new term |
|
| 187 | + * |
|
| 188 | + * @since 0.1.0 |
|
| 189 | + */ |
|
| 190 | + public function add_expert_form_field( $term = false ) { |
|
| 191 | + if ( is_object( $term ) ) { |
|
| 192 | + $value = get_term_meta( $term->term_id, 'expert', true ); |
|
| 193 | + } else { |
|
| 194 | + $value = false; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + $experts = get_posts( |
|
| 198 | + array( |
|
| 199 | + 'post_type' => 'team', |
|
| 200 | + 'posts_per_page' => -1, |
|
| 201 | + 'orderby' => 'menu_order', |
|
| 202 | + 'order' => 'ASC', |
|
| 203 | + ) |
|
| 204 | + ); |
|
| 205 | + ?> |
|
| 206 | 206 | <tr class="form-field form-required term-expert-wrap"> |
| 207 | 207 | <th scope="row"> |
| 208 | 208 | <label for="expert"><?php esc_html_e( 'Expert', 'to-team' ); ?></label> |
@@ -212,10 +212,10 @@ discard block |
||
| 212 | 212 | <option value=""><?php esc_html_e( 'None', 'to-team' ); ?></option> |
| 213 | 213 | |
| 214 | 214 | <?php |
| 215 | - foreach ( $experts as $expert ) { |
|
| 216 | - echo '<option value="' . esc_attr( $expert->ID ) . '"' . selected( $value, $expert->ID, false ) . '>' . esc_html( $expert->post_title ) . '</option>'; |
|
| 217 | - } |
|
| 218 | - ?> |
|
| 215 | + foreach ( $experts as $expert ) { |
|
| 216 | + echo '<option value="' . esc_attr( $expert->ID ) . '"' . selected( $value, $expert->ID, false ) . '>' . esc_html( $expert->post_title ) . '</option>'; |
|
| 217 | + } |
|
| 218 | + ?> |
|
| 219 | 219 | </select> |
| 220 | 220 | |
| 221 | 221 | <?php wp_nonce_field( 'lsx_to_team_save_term_expert', 'lsx_to_team_term_expert_nonce' ); ?> |
@@ -223,52 +223,52 @@ discard block |
||
| 223 | 223 | </tr> |
| 224 | 224 | |
| 225 | 225 | <?php |
| 226 | - } |
|
| 227 | - /** |
|
| 228 | - * Saves the Taxnomy term banner image |
|
| 229 | - * |
|
| 230 | - * @since 0.1.0 |
|
| 231 | - * |
|
| 232 | - * @param int $term_id |
|
| 233 | - * @param string $taxonomy |
|
| 234 | - */ |
|
| 235 | - public function save_meta( $term_id = 0, $taxonomy = '' ) { |
|
| 236 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 237 | - return; |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - if ( ! isset( $_POST['expert'] ) ) { |
|
| 241 | - return; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - if ( check_admin_referer( 'lsx_to_team_save_term_expert', 'lsx_to_team_term_expert_nonce' ) ) { |
|
| 245 | - $meta = ! empty( sanitize_text_field( wp_unslash( $_POST['expert'] ) ) ) ? sanitize_text_field( wp_unslash( $_POST['expert'] ) ) : ''; |
|
| 246 | - |
|
| 247 | - if ( empty( $meta ) ) { |
|
| 248 | - delete_term_meta( $term_id, 'expert' ); |
|
| 249 | - } else { |
|
| 250 | - update_term_meta( $term_id, 'expert', $meta ); |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * Adds the team specific options |
|
| 257 | - */ |
|
| 258 | - public function general_settings( $post_type = false, $tab = false ) { |
|
| 259 | - if ( 'general' !== $tab ) { |
|
| 260 | - return false; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - $experts = get_posts( |
|
| 264 | - array( |
|
| 265 | - 'post_type' => 'team', |
|
| 266 | - 'posts_per_page' => -1, |
|
| 267 | - 'orderby' => 'menu_order', |
|
| 268 | - 'order' => 'ASC', |
|
| 269 | - ) |
|
| 270 | - ); |
|
| 271 | - ?> |
|
| 226 | + } |
|
| 227 | + /** |
|
| 228 | + * Saves the Taxnomy term banner image |
|
| 229 | + * |
|
| 230 | + * @since 0.1.0 |
|
| 231 | + * |
|
| 232 | + * @param int $term_id |
|
| 233 | + * @param string $taxonomy |
|
| 234 | + */ |
|
| 235 | + public function save_meta( $term_id = 0, $taxonomy = '' ) { |
|
| 236 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 237 | + return; |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + if ( ! isset( $_POST['expert'] ) ) { |
|
| 241 | + return; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + if ( check_admin_referer( 'lsx_to_team_save_term_expert', 'lsx_to_team_term_expert_nonce' ) ) { |
|
| 245 | + $meta = ! empty( sanitize_text_field( wp_unslash( $_POST['expert'] ) ) ) ? sanitize_text_field( wp_unslash( $_POST['expert'] ) ) : ''; |
|
| 246 | + |
|
| 247 | + if ( empty( $meta ) ) { |
|
| 248 | + delete_term_meta( $term_id, 'expert' ); |
|
| 249 | + } else { |
|
| 250 | + update_term_meta( $term_id, 'expert', $meta ); |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * Adds the team specific options |
|
| 257 | + */ |
|
| 258 | + public function general_settings( $post_type = false, $tab = false ) { |
|
| 259 | + if ( 'general' !== $tab ) { |
|
| 260 | + return false; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + $experts = get_posts( |
|
| 264 | + array( |
|
| 265 | + 'post_type' => 'team', |
|
| 266 | + 'posts_per_page' => -1, |
|
| 267 | + 'orderby' => 'menu_order', |
|
| 268 | + 'order' => 'ASC', |
|
| 269 | + ) |
|
| 270 | + ); |
|
| 271 | + ?> |
|
| 272 | 272 | <tr class="form-field"> |
| 273 | 273 | <th scope="row"> |
| 274 | 274 | <label for="disable_team_panel"><?php esc_html_e( 'Disable Team Panel', 'to-team' ); ?></label> |
@@ -292,16 +292,16 @@ discard block |
||
| 292 | 292 | </td> |
| 293 | 293 | </tr> |
| 294 | 294 | <?php |
| 295 | - } |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * Adds the team specific options |
|
| 299 | - */ |
|
| 300 | - public function archive_settings( $post_type = false, $tab = false ) { |
|
| 301 | - if ( 'archives' !== $tab ) { |
|
| 302 | - return false; |
|
| 303 | - } |
|
| 304 | - ?> |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * Adds the team specific options |
|
| 299 | + */ |
|
| 300 | + public function archive_settings( $post_type = false, $tab = false ) { |
|
| 301 | + if ( 'archives' !== $tab ) { |
|
| 302 | + return false; |
|
| 303 | + } |
|
| 304 | + ?> |
|
| 305 | 305 | <tr class="form-field"> |
| 306 | 306 | <th scope="row"> |
| 307 | 307 | <label for="group_items_by_role"><?php esc_html_e( 'Group by Role', 'to-team' ); ?></label> |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | </td> |
| 313 | 313 | </tr> |
| 314 | 314 | <?php |
| 315 | - } |
|
| 315 | + } |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | new LSX_TO_Team_Admin(); |
@@ -10,173 +10,173 @@ |
||
| 10 | 10 | |
| 11 | 11 | class LSX_TO_Template_Redirects { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * Plugin Path |
|
| 15 | - */ |
|
| 16 | - public $plugin_path = false; |
|
| 13 | + /** |
|
| 14 | + * Plugin Path |
|
| 15 | + */ |
|
| 16 | + public $plugin_path = false; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Post Types |
|
| 20 | - */ |
|
| 21 | - public $post_types = false; |
|
| 18 | + /** |
|
| 19 | + * Post Types |
|
| 20 | + */ |
|
| 21 | + public $post_types = false; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Taxonomies |
|
| 25 | - */ |
|
| 26 | - public $taxonomies = false; |
|
| 23 | + /** |
|
| 24 | + * Taxonomies |
|
| 25 | + */ |
|
| 26 | + public $taxonomies = false; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Initialize the plugin by setting localization, filters, and administration functions. |
|
| 30 | - * |
|
| 31 | - * @param array $post_types an array of the post types to redirect. |
|
| 32 | - * @param array $taxonomies an array of the taxonomies to redirect. |
|
| 33 | - */ |
|
| 34 | - public function __construct( $plugin_path = false, $post_types = false, $taxonomies = false ) { |
|
| 35 | - if ( false !== $plugin_path ) { |
|
| 36 | - $this->plugin_path = $plugin_path; |
|
| 28 | + /** |
|
| 29 | + * Initialize the plugin by setting localization, filters, and administration functions. |
|
| 30 | + * |
|
| 31 | + * @param array $post_types an array of the post types to redirect. |
|
| 32 | + * @param array $taxonomies an array of the taxonomies to redirect. |
|
| 33 | + */ |
|
| 34 | + public function __construct( $plugin_path = false, $post_types = false, $taxonomies = false ) { |
|
| 35 | + if ( false !== $plugin_path ) { |
|
| 36 | + $this->plugin_path = $plugin_path; |
|
| 37 | 37 | |
| 38 | - add_filter( 'lsx_to_widget_path', array( $this, 'widget_path' ), 10, 2 ); |
|
| 39 | - add_filter( 'lsx_to_content_path', array( $this, 'content_path' ), 10, 3 ); |
|
| 38 | + add_filter( 'lsx_to_widget_path', array( $this, 'widget_path' ), 10, 2 ); |
|
| 39 | + add_filter( 'lsx_to_content_path', array( $this, 'content_path' ), 10, 3 ); |
|
| 40 | 40 | |
| 41 | - if ( false !== $post_types ) { |
|
| 42 | - $this->post_types = $post_types; |
|
| 43 | - add_filter( 'template_include', array( $this, 'post_type_archive_template_include' ), 99 ); |
|
| 44 | - add_filter( 'template_include', array( $this, 'post_type_single_template_include' ), 99 ); |
|
| 45 | - add_filter( 'template_include', array( $this, 'search_template_include' ), 99 ); |
|
| 46 | - } |
|
| 47 | - if ( false !== $taxonomies ) { |
|
| 48 | - $this->taxonomies = $taxonomies; |
|
| 49 | - add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 ); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 41 | + if ( false !== $post_types ) { |
|
| 42 | + $this->post_types = $post_types; |
|
| 43 | + add_filter( 'template_include', array( $this, 'post_type_archive_template_include' ), 99 ); |
|
| 44 | + add_filter( 'template_include', array( $this, 'post_type_single_template_include' ), 99 ); |
|
| 45 | + add_filter( 'template_include', array( $this, 'search_template_include' ), 99 ); |
|
| 46 | + } |
|
| 47 | + if ( false !== $taxonomies ) { |
|
| 48 | + $this->taxonomies = $taxonomies; |
|
| 49 | + add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 ); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Redirect wordpress to the archive template located in the plugin |
|
| 56 | - * |
|
| 57 | - * @param $template |
|
| 58 | - * @return $template |
|
| 59 | - */ |
|
| 60 | - public function post_type_archive_template_include( $template ) { |
|
| 61 | - if ( is_main_query() && is_post_type_archive( $this->post_types ) ) { |
|
| 62 | - $current_post_type = get_post_type(); |
|
| 63 | - if ( '' == locate_template( array( 'archive-' . $current_post_type . '.php' ) ) && file_exists( $this->plugin_path . 'templates/archive-' . $current_post_type . '.php' ) ) { |
|
| 64 | - $template = $this->plugin_path . 'templates/archive-' . $current_post_type . '.php'; |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - return $template; |
|
| 68 | - } |
|
| 69 | - /** |
|
| 70 | - * Redirect wordpress to the single template located in the plugin |
|
| 71 | - * |
|
| 72 | - * @param $template |
|
| 73 | - * |
|
| 74 | - * @return $template |
|
| 75 | - */ |
|
| 76 | - public function post_type_single_template_include( $template ) { |
|
| 77 | - if ( is_main_query() && is_singular( $this->post_types ) ) { |
|
| 78 | - $current_post_type = get_post_type(); |
|
| 79 | - if ( '' == locate_template( array( 'single-' . $current_post_type . '.php' ) ) && file_exists( $this->plugin_path . 'templates/single-' . $current_post_type . '.php' ) ) { |
|
| 80 | - $template = $this->plugin_path . 'templates/single-' . $current_post_type . '.php'; |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - return $template; |
|
| 84 | - } |
|
| 85 | - /** |
|
| 86 | - * Redirect wordpress to the taxonomy located in the plugin |
|
| 87 | - * |
|
| 88 | - * @param $template |
|
| 89 | - * |
|
| 90 | - * @return $template |
|
| 91 | - */ |
|
| 92 | - public function taxonomy_template_include( $template ) { |
|
| 54 | + /** |
|
| 55 | + * Redirect wordpress to the archive template located in the plugin |
|
| 56 | + * |
|
| 57 | + * @param $template |
|
| 58 | + * @return $template |
|
| 59 | + */ |
|
| 60 | + public function post_type_archive_template_include( $template ) { |
|
| 61 | + if ( is_main_query() && is_post_type_archive( $this->post_types ) ) { |
|
| 62 | + $current_post_type = get_post_type(); |
|
| 63 | + if ( '' == locate_template( array( 'archive-' . $current_post_type . '.php' ) ) && file_exists( $this->plugin_path . 'templates/archive-' . $current_post_type . '.php' ) ) { |
|
| 64 | + $template = $this->plugin_path . 'templates/archive-' . $current_post_type . '.php'; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + return $template; |
|
| 68 | + } |
|
| 69 | + /** |
|
| 70 | + * Redirect wordpress to the single template located in the plugin |
|
| 71 | + * |
|
| 72 | + * @param $template |
|
| 73 | + * |
|
| 74 | + * @return $template |
|
| 75 | + */ |
|
| 76 | + public function post_type_single_template_include( $template ) { |
|
| 77 | + if ( is_main_query() && is_singular( $this->post_types ) ) { |
|
| 78 | + $current_post_type = get_post_type(); |
|
| 79 | + if ( '' == locate_template( array( 'single-' . $current_post_type . '.php' ) ) && file_exists( $this->plugin_path . 'templates/single-' . $current_post_type . '.php' ) ) { |
|
| 80 | + $template = $this->plugin_path . 'templates/single-' . $current_post_type . '.php'; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + return $template; |
|
| 84 | + } |
|
| 85 | + /** |
|
| 86 | + * Redirect wordpress to the taxonomy located in the plugin |
|
| 87 | + * |
|
| 88 | + * @param $template |
|
| 89 | + * |
|
| 90 | + * @return $template |
|
| 91 | + */ |
|
| 92 | + public function taxonomy_template_include( $template ) { |
|
| 93 | 93 | |
| 94 | - if ( is_main_query() && is_tax( $this->taxonomies ) ) { |
|
| 95 | - $current_taxonomy = get_query_var( 'taxonomy' ); |
|
| 96 | - if ( '' == locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( $this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) { |
|
| 97 | - $template = $this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - return $template; |
|
| 101 | - } |
|
| 94 | + if ( is_main_query() && is_tax( $this->taxonomies ) ) { |
|
| 95 | + $current_taxonomy = get_query_var( 'taxonomy' ); |
|
| 96 | + if ( '' == locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( $this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) { |
|
| 97 | + $template = $this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + return $template; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Redirect wordpress to the search template located in the plugin |
|
| 105 | - * |
|
| 106 | - * @param $template |
|
| 107 | - * |
|
| 108 | - * @return $template |
|
| 109 | - */ |
|
| 110 | - public function search_template_include( $template ) { |
|
| 111 | - if ( is_main_query() && is_search() ) { |
|
| 112 | - if ( file_exists( $this->plugin_path . 'templates/search.php' ) ) { |
|
| 113 | - $template = $this->plugin_path . 'templates/search.php'; |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - return $template; |
|
| 117 | - } |
|
| 103 | + /** |
|
| 104 | + * Redirect wordpress to the search template located in the plugin |
|
| 105 | + * |
|
| 106 | + * @param $template |
|
| 107 | + * |
|
| 108 | + * @return $template |
|
| 109 | + */ |
|
| 110 | + public function search_template_include( $template ) { |
|
| 111 | + if ( is_main_query() && is_search() ) { |
|
| 112 | + if ( file_exists( $this->plugin_path . 'templates/search.php' ) ) { |
|
| 113 | + $template = $this->plugin_path . 'templates/search.php'; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + return $template; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Redirect wordpress to the single template located in the plugin |
|
| 121 | - * |
|
| 122 | - * @param $template |
|
| 123 | - * |
|
| 124 | - * @return $template |
|
| 125 | - */ |
|
| 126 | - public function content_part( $slug, $name = null ) { |
|
| 127 | - $template = array(); |
|
| 128 | - $name = (string) $name; |
|
| 129 | - if ( '' !== $name ) { |
|
| 130 | - $template = "{$slug}-{$name}.php"; |
|
| 131 | - } else { |
|
| 132 | - $template = "{$slug}.php"; |
|
| 133 | - } |
|
| 134 | - $original_name = $template; |
|
| 135 | - $path = apply_filters( 'lsx_to_content_path', '', get_post_type() ); |
|
| 119 | + /** |
|
| 120 | + * Redirect wordpress to the single template located in the plugin |
|
| 121 | + * |
|
| 122 | + * @param $template |
|
| 123 | + * |
|
| 124 | + * @return $template |
|
| 125 | + */ |
|
| 126 | + public function content_part( $slug, $name = null ) { |
|
| 127 | + $template = array(); |
|
| 128 | + $name = (string) $name; |
|
| 129 | + if ( '' !== $name ) { |
|
| 130 | + $template = "{$slug}-{$name}.php"; |
|
| 131 | + } else { |
|
| 132 | + $template = "{$slug}.php"; |
|
| 133 | + } |
|
| 134 | + $original_name = $template; |
|
| 135 | + $path = apply_filters( 'lsx_to_content_path', '', get_post_type() ); |
|
| 136 | 136 | |
| 137 | - if ( '' == locate_template( array( $template ) ) && file_exists( $path . 'templates/' . $template ) ) { |
|
| 138 | - $template = $path . 'templates/' . $template; |
|
| 139 | - } elseif ( file_exists( get_stylesheet_directory() . '/' . $template ) ) { |
|
| 140 | - $template = get_stylesheet_directory() . '/' . $template; |
|
| 141 | - } else { |
|
| 142 | - $template = false; |
|
| 143 | - } |
|
| 144 | - if ( false !== $template ) { |
|
| 145 | - load_template( $template, false ); |
|
| 146 | - } else { |
|
| 147 | - echo wp_kses_post( '<p>No ' . $original_name . ' can be found.</p>' ); |
|
| 148 | - } |
|
| 149 | - } |
|
| 137 | + if ( '' == locate_template( array( $template ) ) && file_exists( $path . 'templates/' . $template ) ) { |
|
| 138 | + $template = $path . 'templates/' . $template; |
|
| 139 | + } elseif ( file_exists( get_stylesheet_directory() . '/' . $template ) ) { |
|
| 140 | + $template = get_stylesheet_directory() . '/' . $template; |
|
| 141 | + } else { |
|
| 142 | + $template = false; |
|
| 143 | + } |
|
| 144 | + if ( false !== $template ) { |
|
| 145 | + load_template( $template, false ); |
|
| 146 | + } else { |
|
| 147 | + echo wp_kses_post( '<p>No ' . $original_name . ' can be found.</p>' ); |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * Redirect wordpress to the widget template located in the plugin |
|
| 153 | - * |
|
| 154 | - * @param $path |
|
| 155 | - * @param $post_type |
|
| 156 | - * |
|
| 157 | - * @return $path |
|
| 158 | - */ |
|
| 159 | - public function widget_path( $path, $slug ) { |
|
| 160 | - if ( ( false !== $this->post_types && in_array( $slug, $this->post_types ) ) |
|
| 161 | - || ( false !== $this->taxonomies && in_array( $slug, $this->taxonomies ) ) || 'post' === $slug ) { |
|
| 162 | - $path = $this->plugin_path; |
|
| 163 | - } |
|
| 164 | - return $path; |
|
| 165 | - } |
|
| 151 | + /** |
|
| 152 | + * Redirect wordpress to the widget template located in the plugin |
|
| 153 | + * |
|
| 154 | + * @param $path |
|
| 155 | + * @param $post_type |
|
| 156 | + * |
|
| 157 | + * @return $path |
|
| 158 | + */ |
|
| 159 | + public function widget_path( $path, $slug ) { |
|
| 160 | + if ( ( false !== $this->post_types && in_array( $slug, $this->post_types ) ) |
|
| 161 | + || ( false !== $this->taxonomies && in_array( $slug, $this->taxonomies ) ) || 'post' === $slug ) { |
|
| 162 | + $path = $this->plugin_path; |
|
| 163 | + } |
|
| 164 | + return $path; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Redirect wordpress to the single template located in the plugin |
|
| 169 | - * |
|
| 170 | - * @param $path |
|
| 171 | - * @param $post_type |
|
| 172 | - * |
|
| 173 | - * @return $path |
|
| 174 | - */ |
|
| 175 | - public function content_path( $path, $slug ) { |
|
| 176 | - if ( ( false !== $this->post_types && in_array( $slug, $this->post_types ) ) |
|
| 177 | - || ( false !== $this->taxonomies && in_array( $slug, $this->taxonomies ) ) || 'post' === $slug ) { |
|
| 178 | - $path = $this->plugin_path; |
|
| 179 | - } |
|
| 180 | - return $path; |
|
| 181 | - } |
|
| 167 | + /** |
|
| 168 | + * Redirect wordpress to the single template located in the plugin |
|
| 169 | + * |
|
| 170 | + * @param $path |
|
| 171 | + * @param $post_type |
|
| 172 | + * |
|
| 173 | + * @return $path |
|
| 174 | + */ |
|
| 175 | + public function content_path( $path, $slug ) { |
|
| 176 | + if ( ( false !== $this->post_types && in_array( $slug, $this->post_types ) ) |
|
| 177 | + || ( false !== $this->taxonomies && in_array( $slug, $this->taxonomies ) ) || 'post' === $slug ) { |
|
| 178 | + $path = $this->plugin_path; |
|
| 179 | + } |
|
| 180 | + return $path; |
|
| 181 | + } |
|
| 182 | 182 | } |