From 899f94451968a38b4097cda490aceeb0bf9eb2e7 Mon Sep 17 00:00:00 2001 From: Warwick Date: Wed, 11 Dec 2024 12:38:12 +0200 Subject: [PATCH 1/7] Removing the destinations uneeded functions. --- .../classes/legacy/class-accommodation.php | 18 - includes/classes/legacy/class-tour.php | 24 -- includes/template-tags/accommodation.php | 44 --- includes/template-tags/destination.php | 314 ------------------ includes/template-tags/general.php | 117 +++---- includes/template-tags/tour.php | 241 -------------- tour-operator-bootstrap.php | 1 - 7 files changed, 55 insertions(+), 704 deletions(-) delete mode 100644 includes/template-tags/destination.php diff --git a/includes/classes/legacy/class-accommodation.php b/includes/classes/legacy/class-accommodation.php index b52874f2..803d2a07 100644 --- a/includes/classes/legacy/class-accommodation.php +++ b/includes/classes/legacy/class-accommodation.php @@ -73,16 +73,11 @@ private function __construct() { 'villa' => esc_html__( 'Villa', 'tour-operator' ), ); - add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) ); - add_filter( 'lsx_to_custom_field_query', array( $this, 'price_filter' ), 5, 10 ); add_filter( 'lsx_to_custom_field_query', array( $this, 'rating' ), 5, 10 ); include( 'class-unit-query.php' ); - - add_action( 'lsx_to_map_meta', 'lsx_to_accommodation_meta' ); - add_action( 'lsx_to_modal_meta', 'lsx_to_accommodation_meta' ); } /** @@ -101,19 +96,6 @@ public static function get_instance() { return self::$instance; } - /** - * A filter to set the content area to a small column on single - */ - function entry_class( $classes ) { - global $post; - - if ( is_main_query() && is_singular( $this->slug ) ) { - $classes[] = 'col-xs-12 col-sm-12 col-md-7'; - } - - return $classes; - } - /** * Adds in additional info for the price custom field */ diff --git a/includes/classes/legacy/class-tour.php b/includes/classes/legacy/class-tour.php index bc527179..28bdb48f 100644 --- a/includes/classes/legacy/class-tour.php +++ b/includes/classes/legacy/class-tour.php @@ -73,8 +73,6 @@ private function __construct() { add_filter( 'lsx_to_custom_field_query', array( $this, 'rating' ), 10, 5 ); - add_action( 'lsx_to_modal_meta', array( $this, 'content_meta' ) ); - add_filter( 'body_class', array( $this, 'tour_classes' ), 10, 1 ); } @@ -207,28 +205,6 @@ public function rating( $html = '', $meta_key = false, $value = false, $before = return $html; } - /** - * Outputs the tour meta on the modal - */ - public function content_meta() { - if ( 'tour' === get_post_type() ) { - ?> - ' . esc_html__( 'From price', 'tour-operator' ) . ': ', '' ); - lsx_to_duration( ' ', '' ); - the_terms( get_the_ID(), 'travel-style', ' ', ', ', '' ); - lsx_to_connected_countries( ' ', '', true ); - - if ( function_exists( 'lsx_to_connected_activities' ) ) { - lsx_to_connected_activities( ' ', '' ); - } - ?> - 'post', - 'to' => 'accommodation', - 'column' => '3', - 'before' => '

' . esc_html__( 'Featured Posts', 'tour-operator' ) . '

', - 'after' => '
', - ); - - lsx_to_connected_panel_query( $args ); -} /** * Outputs the current accommodations room total @@ -293,30 +273,6 @@ function lsx_to_accommodation_activity_friendly( $before = '', $after = '', $ech } } -/** - * Outputs the accommodation meta - * - * @package tour-operator - * @subpackage template-tags - * @category accommodation - */ -function lsx_to_accommodation_meta() { - if ( 'accommodation' === get_post_type() ) { - $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; - - lsx_to_price( ' ', '' ); - lsx_to_accommodation_room_total( ' ', '' ); - lsx_to_accommodation_rating( ' ', '' ); - the_terms( get_the_ID(), 'travel-style', ' ', ', ', '' ); - the_terms( get_the_ID(), 'accommodation-brand', ' ', ', ', '' ); - the_terms( get_the_ID(), 'accommodation-type', ' ', ', ', '' ); - lsx_to_accommodation_spoken_languages( ' ', '' ); - lsx_to_accommodation_activity_friendly( ' ', '' ); - lsx_to_accommodation_special_interests( ' ', '' ); - lsx_to_connected_countries( ' ', '' ); - } -} - /** * Gets the current specials connected accommodation * diff --git a/includes/template-tags/destination.php b/includes/template-tags/destination.php deleted file mode 100644 index 57449a30..00000000 --- a/includes/template-tags/destination.php +++ /dev/null @@ -1,314 +0,0 @@ - 'post', - 'to' => 'destination', - 'column' => '3', - 'before' => '

' . esc_html__( 'Featured Posts', 'tour-operator' ) . '

', - 'after' => '
', - ); - - lsx_to_connected_panel_query( $args ); -} - -/** - * Outputs the connected accommodation only on a "region" - * - * @package tour-operator - * @subpackage template-tags - * @category destination - */ -function lsx_to_region_accommodation() { - global $lsx_to_archive; - - if ( post_type_exists( 'accommodation' ) && is_singular( 'destination' ) && ! lsx_to_item_has_children( get_the_ID(), 'destination' ) ) { - $args = array( - 'from' => 'accommodation', - 'to' => 'destination', - 'column' => '3', - 'before' => '

' . lsx_to_get_post_type_section_title( 'accommodation', '', esc_html__( 'Featured Accommodation', 'tour-operator' ) ) . '

', - 'after' => '
', - ); - - lsx_to_connected_panel_query( $args ); - } -} - -/** - * Outputs the destinations attached tours - * - * @package tour-operator - * @subpackage template-tags - * @category destination - */ -function lsx_to_destination_tours() { - global $lsx_to_archive, $wp_query; - - if ( post_type_exists( 'tour' ) && is_singular( 'destination' ) ) { - $args = array( - 'from' => 'tour', - 'to' => 'destination', - 'column' => '3', - 'before' => '

' . lsx_to_get_post_type_section_title( 'tour', '', esc_html__( 'Featured Tours', 'tour-operator' ) ) . '

', - 'after' => '
', - ); - - lsx_to_connected_panel_query( $args ); - } -} - -/** - * Outputs the destinations attached activites - * - * @package tour-operator - * @subpackage template-tags - * @category destination - */ -function lsx_to_destination_activities() { - global $lsx_to_archive; - - if ( post_type_exists( 'activity' ) && is_singular( 'destination' ) && ! lsx_to_item_has_children( get_the_ID(), 'destination' ) ) { - $args = array( - 'from' => 'activity', - 'to' => 'destination', - // 'content_part' => 'widget-activity', - 'column' => '3', - 'before' => '

' . lsx_to_get_post_type_section_title( 'activity', '', esc_html__( 'Featured Activities', 'tour-operator' ) ) . '

', - 'after' => '
', - ); - - lsx_to_connected_panel_query( $args ); - } -} - -/** - * Outputs the destination travel info - * - * @package tour-operator - * @subpackage template-tags - * @category destination - */ -function lsx_to_destination_travel_info() { - $electricity = get_post_meta( get_the_ID(), 'electricity', true ); - $banking = get_post_meta( get_the_ID(), 'banking', true ); - $cuisine = get_post_meta( get_the_ID(), 'cuisine', true ); - $climate = get_post_meta( get_the_ID(), 'climate', true ); - $transport = get_post_meta( get_the_ID(), 'transport', true ); - $dress = get_post_meta( get_the_ID(), 'dress', true ); - $health = get_post_meta( get_the_ID(), 'health', true ); - $safety = get_post_meta( get_the_ID(), 'safety', true ); - $visa = get_post_meta( get_the_ID(), 'visa', true ); - $general = get_post_meta( get_the_ID(), 'additional_info', true ); - - if ( ! empty( $electricity ) || ! empty( $banking ) || ! empty( $cuisine ) || ! empty( $climate ) || ! empty( $transport ) || ! empty( $dress ) || ! empty( $health ) || ! empty( $safety ) || ! empty( $visa ) || ! empty( $general ) ) : - $limit_words = 20; - $limit_chars = 150; - $more_button = "\n\n" . 'Read More' . "\n\n"; - - $items = array( - esc_html__( 'Electricity', 'tour-operator' ) => $electricity, - esc_html__( 'Banking', 'tour-operator' ) => $banking, - esc_html__( 'Cuisine', 'tour-operator' ) => $cuisine, - esc_html__( 'Climate', 'tour-operator' ) => $climate, - esc_html__( 'Transport', 'tour-operator' ) => $transport, - esc_html__( 'Dress', 'tour-operator' ) => $dress, - esc_html__( 'Health', 'tour-operator' ) => $health, - esc_html__( 'Safety', 'tour-operator' ) => $safety, - esc_html__( 'Visa', 'tour-operator' ) => $visa, - esc_html__( 'General', 'tour-operator' ) => $general, - ); - ?> -
-

>

- -
-
-
-
-
-
- $value ) : ?> - -
-
> - - -
-

- -

', ' - ', $value ); - $value = str_replace( array( '

', '

' ), '', $value ); - $value = str_replace( '
', ' - ', $value ); - - // if ( str_word_count( $value, 0 ) > $limit_chars ) { - // $tokens = array(); - // $value_output = ''; - // $has_more = false; - // $count = 0; - - // preg_match_all( '/(<[^>]+>|[^<>\s]+)\s*/u', $value, $tokens ); - - // foreach ( $tokens[0] as $token ) { - // if ( $count >= $limit_words ) { - // $value_output .= trim( $token ); - // $has_more = true; - // break; - // } - - // $count++; - // $value_output .= $token; - // } - - // $value = trim( force_balance_tags( $value_output . '...' ) ); - // } - - if ( strlen( $value ) > $limit_chars ) { - $position = strpos( $value, ' ', $limit_chars ); - $value_output = substr( $value, 0, $position ); - - $value = trim( force_balance_tags( $value_output . '...' ) ); - } - - $value = trim( force_balance_tags( $value . $more_button ) ); - - echo wp_kses_post( apply_filters( 'the_content', $value ) ); - ?> -

-
-
- - -
-
-
-
-
-
-
- $theid, - 'post_type' => 'destination', - ) ); - $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; - if ( $child->have_posts() ) { - $list_destinations = array(); - $final_list_destinations = ''; - echo ''; - while ( $child->have_posts() ) { - $child->the_post(); - $childtitle = get_the_title(); - $childlink = get_the_permalink(); - $list_destinations[] = ' ' . esc_attr( $childtitle ) . ''; - } - $final_list_destinations = implode( ', ', $list_destinations ); - echo wp_kses_post( $final_list_destinations ); - } else { - echo ''; - $parent_title = get_the_title( wp_get_post_parent_id( $theid ) ); - $parent_link = get_the_permalink( wp_get_post_parent_id( $theid ) ); - echo ' ' . esc_attr( $parent_title ) . ''; - } - echo ''; - wp_reset_postdata(); -} - -/** - * Gets the current best months to visit - * - * - * @package tour-operator - * @subpackage template-tags - * @category connections - */ - -function months_to_visit() { - $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; - $months = get_post_meta( get_the_ID(), 'best_time_to_visit', true ); - $month_list = array(); - - foreach ( (array) $months as $single_month ) { - $single_month = str_split( $single_month, 3 ); - $month_list[] = '' . $single_month[0] . - ''; - } - - if ( ! empty( $months ) ) { - echo ''; - echo ( implode( ', ', $month_list ) ); - echo ''; - } - -} diff --git a/includes/template-tags/general.php b/includes/template-tags/general.php index aeb27d07..d9773973 100644 --- a/includes/template-tags/general.php +++ b/includes/template-tags/general.php @@ -8,94 +8,87 @@ * @license GPL3 */ -/* ================== LAYOUT ================== */ +/** + * Used Functions + */ /** - * Returns the CSS class for the archive panels + * Outputs The current Itinerary connected destinations, can only be used in + * the itinerary loop. * - * @package tour-operator - * @subpackage template-tags - * @category class + * @package tour-operator + * @subpackage template-tags + * @category itinerary */ -function lsx_to_archive_class( $classes = array() ) { - $layout = tour_operator()->archive_layout; - - if ( ! is_array( $classes ) ) { - $classes = explode( ' ', $classes ); - } - - $new_classes = $classes; - - if ( 'grid' === $layout ) { - $new_classes[] = 'col-xs-12 col-sm-6 col-md-4'; - } else { - $new_classes[] = 'col-xs-12'; +function lsx_to_itinerary_room_basis( $before = '', $after = '', $echo = true ) { + global $tour_itinerary; + if ( $tour_itinerary && $tour_itinerary->has_itinerary && ! empty( $tour_itinerary->itinerary ) ) { + if ( ! empty( $tour_itinerary->itinerary['room_basis'] ) && 'None' !== $tour_itinerary->itinerary['room_basis'] ) { + $label = lsx_to_room_basis_label( $tour_itinerary->itinerary['room_basis'] ); + if ( $echo ) { + echo wp_kses_post( $before . $label . $after ); + } else { + return $before . $label . $after; + } + } } - - $new_classes = apply_filters( 'lsx_to_archive_class', $new_classes, $classes, $layout ); - - return implode( ' ', $new_classes ); + return ''; } /** - * Outputs the CSS class for the widget panels + * Return the Room basis Label. * - * @package tour-operator - * @subpackage template-tags - * @category class + * @param string $index + * @return string */ -function lsx_to_widget_class( $type = '', $return = false ) { - global $columns; - - $cols = 'col-xs-12 col-sm-'; - $cols .= '5' == $columns ? '15' : 12 / $columns; - - $class = 'lsx-to-widget-item-wrap lsx-' . $type . ' ' . $cols; - - if ( false === $return ) { - echo 'class="' . esc_attr( $class ) . '"'; - } else { - return 'class="' . $class . '"'; +function lsx_to_room_basis_label( $index = '' ) { + $label = $index; + if ( isset( tour_operator()->legacy->tour->room_basis[ $index ] ) ) { + $label = tour_operator()->legacy->tour->room_basis[ $index ]; } + return $label; } /** - * Outputs the 'content' class. + * Return the Drinks basis Label. * - * @param $classes string or array + * @param string $index + * @return string */ -function lsx_to_entry_class( $classes = false ) { - global $post; - - if ( false !== $classes ) { - if ( ! is_array( $classes ) ) { - $classes = explode( ' ', $classes ); - } - - $classes = apply_filters( 'lsx_to_entry_class', $classes, $post->ID ); +function lsx_to_drinks_basis_label( $index = '' ) { + $label = $index; + if ( isset( tour_operator()->legacy->tour->drinks_basis[ $index ] ) ) { + $label = tour_operator()->legacy->tour->drinks_basis[ $index ]; } - - echo wp_kses_post( 'class="' . implode( ' ', $classes ) . '"' ); + return $label; } /** - * Outputs the 'content' class. + * Outputs The current Itinerary connected destinations, can only be used in + * the itinerary loop. * - * @param $classes string or array + * @package tour-operator + * @subpackage template-tags + * @category itinerary */ -function lsx_to_column_class( $classes = false ) { - global $post; - - if ( false !== $classes ) { - if ( ! is_array( $classes ) ) { - $classes = explode( ' ', $classes ); +function lsx_to_itinerary_drinks_basis( $before = '', $after = '', $echo = true ) { + global $tour_itinerary; + if ( $tour_itinerary && $tour_itinerary->has_itinerary && ! empty( $tour_itinerary->itinerary ) ) { + if ( ! empty( $tour_itinerary->itinerary['drinks_basis'] ) && 'None' !== $tour_itinerary->itinerary['drinks_basis'] ) { + $label = lsx_to_drinks_basis_label( $tour_itinerary->itinerary['drinks_basis'] ); + if ( $echo ) { + echo wp_kses_post( $before . $label . $after ); + } else { + return $before . $label . $after; + } } - $classes = apply_filters( 'lsx_to_column_class', $classes, $post->ID ); } - - echo wp_kses_post( 'class="' . implode( ' ', $classes ) . '"' ); + return ''; } + +// ============ OLD Functions ============ + /** * Returns the collapsible class if it is active. * diff --git a/includes/template-tags/tour.php b/includes/template-tags/tour.php index b5082698..9ecb2b3a 100644 --- a/includes/template-tags/tour.php +++ b/includes/template-tags/tour.php @@ -8,27 +8,6 @@ * @license GPL3 */ -/** - * Outputs the posts attached tours - * - * @package tour-operator - * @subpackage template-tags - * @category tour - */ -function lsx_to_tour_posts() { - global $lsx_to_archive; - - $args = array( - 'from' => 'post', - 'to' => 'tour', - 'column' => '3', - 'before' => '

' . esc_html__( 'Featured Posts', 'tour-operator' ) . '

', - 'after' => '
', - ); - - lsx_to_connected_panel_query( $args ); -} - /** * Gets the current tours price * @@ -155,226 +134,6 @@ function lsx_to_end_point( $before = '', $after = '', $echo = true ) { } } -/** - * Outputs the tours included / not included block - * - * @package tour-operator - * @subpackage template-tags - * @category tour - */ -function lsx_to_included_block() { - $tour_included = lsx_to_included( '', '', false ); - $tour_not_included = lsx_to_not_included( '', '', false ); - - if ( null !== $tour_included || null !== $tour_not_included ) { - $class = 'col-xs-12 col-sm-6'; - - if ( ( null === $tour_included && null !== $tour_not_included ) || ( null !== $tour_included && null === $tour_not_included ) ) { - $class = 'col-xs-12'; - } - ?> -
- - -
-
-
- -
-

-
- -
-
- -
-

-
- -
-
- -
-
-
-
- ' . apply_filters( 'the_content', wpautop( $highlights ) ) . '' . $after; - - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } -} - -/** - * Outputs the Best Time to Visit HTML - * - * @param $before | string - * @param $after | string - * @param $echo | boolean - * @return string - * - * @package tour-operator - * @subpackage template-tags - * @category tour - */ -function lsx_to_best_time_to_visit( $before = '', $after = '', $echo = true ) { - $best_time_to_visit = get_post_meta( get_the_ID(), 'best_time_to_visit', true ); - - if ( false !== $best_time_to_visit && '' !== $best_time_to_visit && is_array( $best_time_to_visit ) && ! empty( $best_time_to_visit ) ) { - $this_year = array( - 'january' => esc_html__( 'January', 'tour-operator' ), - 'february' => esc_html__( 'February', 'tour-operator' ), - 'march' => esc_html__( 'March', 'tour-operator' ), - 'april' => esc_html__( 'April', 'tour-operator' ), - 'may' => esc_html__( 'May', 'tour-operator' ), - 'june' => esc_html__( 'June', 'tour-operator' ), - 'july' => esc_html__( 'July', 'tour-operator' ), - 'august' => esc_html__( 'August', 'tour-operator' ), - 'september' => esc_html__( 'September', 'tour-operator' ), - 'october' => esc_html__( 'October', 'tour-operator' ), - 'november' => esc_html__( 'November', 'tour-operator' ), - 'december' => esc_html__( 'December', 'tour-operator ' ), - ); - - foreach ( $this_year as $month => $label ) { - $checked = ''; - $checked_class = ''; - - if ( in_array( $month, $best_time_to_visit ) ) { - $checked = ''; - $checked_class = 'lsx-to-month-check'; - } - - $shortname = str_split( $label, 3 ); - $best_times[] = '
' . $shortname[0] . '' . $checked . '
'; - }; - - $return = $before . implode( $best_times ) . $after; - - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } -} - -/** - * Gets the current specials connected tours - * - * @param $before | string - * @param $after | string - * @param $echo | boolean - * @return string - * - * @package tour-operator - * @subpackage template-tags - * @category connections - */ -function lsx_to_connected_tours( $before = '', $after = '', $echo = true ) { - lsx_to_connected_items_query( 'tour', get_post_type(), $before, $after, $echo ); -} - -/** - * Return the Room basis Label. - * - * @param string $index - * @return string - */ -function lsx_to_room_basis_label( $index = '' ) { - $label = $index; - if ( isset( tour_operator()->legacy->tour->room_basis[ $index ] ) ) { - $label = tour_operator()->legacy->tour->room_basis[ $index ]; - } - return $label; -} - -/** - * Outputs The current Itinerary connected destinations, can only be used in - * the itinerary loop. - * - * @package tour-operator - * @subpackage template-tags - * @category itinerary - */ -function lsx_to_itinerary_room_basis( $before = '', $after = '', $echo = true ) { - global $tour_itinerary; - if ( $tour_itinerary && $tour_itinerary->has_itinerary && ! empty( $tour_itinerary->itinerary ) ) { - if ( ! empty( $tour_itinerary->itinerary['room_basis'] ) && 'None' !== $tour_itinerary->itinerary['room_basis'] ) { - $label = lsx_to_room_basis_label( $tour_itinerary->itinerary['room_basis'] ); - if ( $echo ) { - echo wp_kses_post( $before . $label . $after ); - } else { - return $before . $label . $after; - } - } - } - return ''; -} - -/** - * Return the Drinks basis Label. - * - * @param string $index - * @return string - */ -function lsx_to_drinks_basis_label( $index = '' ) { - $label = $index; - if ( isset( tour_operator()->legacy->tour->drinks_basis[ $index ] ) ) { - $label = tour_operator()->legacy->tour->drinks_basis[ $index ]; - } - return $label; -} - -/** - * Outputs The current Itinerary connected destinations, can only be used in - * the itinerary loop. - * - * @package tour-operator - * @subpackage template-tags - * @category itinerary - */ -function lsx_to_itinerary_drinks_basis( $before = '', $after = '', $echo = true ) { - global $tour_itinerary; - if ( $tour_itinerary && $tour_itinerary->has_itinerary && ! empty( $tour_itinerary->itinerary ) ) { - if ( ! empty( $tour_itinerary->itinerary['drinks_basis'] ) && 'None' !== $tour_itinerary->itinerary['drinks_basis'] ) { - $label = lsx_to_drinks_basis_label( $tour_itinerary->itinerary['drinks_basis'] ); - if ( $echo ) { - echo wp_kses_post( $before . $label . $after ); - } else { - return $before . $label . $after; - } - } - } - return ''; -} - /** * Retrieves the accommodation ids from the itinerary, mostly for use in the map. * the itinerary loop. diff --git a/tour-operator-bootstrap.php b/tour-operator-bootstrap.php index 2a399c4d..508bb1c9 100644 --- a/tour-operator-bootstrap.php +++ b/tour-operator-bootstrap.php @@ -27,7 +27,6 @@ require_once( LSX_TO_PATH . 'includes/template-tags/helpers.php' ); require_once( LSX_TO_PATH . 'includes/template-tags/addons.php' ); require_once( LSX_TO_PATH . 'includes/template-tags/accommodation.php' ); - require_once( LSX_TO_PATH . 'includes/template-tags/destination.php' ); require_once( LSX_TO_PATH . 'includes/template-tags/tour.php' ); require_once( LSX_TO_PATH . 'includes/template-tags/maps.php' ); require_once( LSX_TO_PATH . 'includes/template-tags/videos.php' ); From 6bf43de40998a58067511da538e1b8de51519fcd Mon Sep 17 00:00:00 2001 From: Warwick Date: Wed, 11 Dec 2024 12:41:40 +0200 Subject: [PATCH 2/7] Removing the uneeded general functions --- includes/classes/legacy/class-frontend.php | 1 - .../classes/legacy/class-tour-operator.php | 45 -- includes/template-tags/general.php | 500 ------------------ 3 files changed, 546 deletions(-) diff --git a/includes/classes/legacy/class-frontend.php b/includes/classes/legacy/class-frontend.php index e0ebbe06..7abd75d9 100644 --- a/includes/classes/legacy/class-frontend.php +++ b/includes/classes/legacy/class-frontend.php @@ -63,7 +63,6 @@ public function __construct() { add_filter( 'lsx_to_connected_list_item', array( $this, 'add_modal_attributes' ), 10, 3 ); add_action( 'wp_footer', array( $this, 'output_modals' ), 10 ); - add_filter( 'lsx_to_tagline', array( $this, 'get_tagline' ), 1, 3 ); // add_filter( 'the_terms', array( $this, 'links_new_window' ), 10, 2 ); $this->maps = Maps::get_instance(); diff --git a/includes/classes/legacy/class-tour-operator.php b/includes/classes/legacy/class-tour-operator.php index 07bf4a4b..37a3ea4d 100644 --- a/includes/classes/legacy/class-tour-operator.php +++ b/includes/classes/legacy/class-tour-operator.php @@ -470,51 +470,6 @@ public function taxonomies_filter( $taxonomies ) { return $taxonomies; } - /** - * A filter that outputs the tagline for the current page. - * - * @param string|bool $tagline Tagline to use or false to use internal. - * @param string $before Before code. - * @param string $after After code. - * - * @return string HTML tagline string. - */ - public function get_tagline( $tagline = false, $before = '', $after = '' ) { - $post_id = get_the_ID(); - - if ( ! empty( $post_id ) ) { - $post_id = get_the_ID(); - $tagline_value = get_post_meta( $post_id, 'banner_subtitle', true ); - - if ( false !== $tagline_value ) { - $tagline = $tagline_value; - } else { - $tagline_value = get_post_meta( $post_id, 'tagline', true ); - - if ( false !== $tagline_value ) { - $tagline = $tagline_value; - } - } - } else { - $post_type = get_query_var( 'post_type' ); - - if ( is_post_type_archive( $this->active_post_types ) && isset( $this->options[ $post_type ] ) && isset( $this->options[ $post_type ]['tagline'] ) ) { - $tagline = $this->options[ $post_type ]['tagline']; - } elseif ( is_tax( array_keys( $this->taxonomies ) ) ) { - $taxonomy_tagline = get_term_meta( get_queried_object_id(), 'tagline', true ); - if ( false !== $taxonomy_tagline && '' !== $taxonomy_tagline ) { - $tagline = $taxonomy_tagline; - } - } - } - - if ( false !== $tagline && '' !== $tagline ) { - $tagline = $before . $tagline . $after; - } - - return $tagline; - } - /** * checks which plugin is active, and grabs those forms. */ diff --git a/includes/template-tags/general.php b/includes/template-tags/general.php index d9773973..bb946a53 100644 --- a/includes/template-tags/general.php +++ b/includes/template-tags/general.php @@ -85,503 +85,3 @@ function lsx_to_itinerary_drinks_basis( $before = '', $after = '', $echo = true } return ''; } - - -// ============ OLD Functions ============ - -/** - * Returns the collapsible class if it is active. - * - * @param bool $post_type - * @param bool $return - * @return string - */ -function lsx_to_collapsible_class( $post_type = false, $return = true ) { - if ( false === $post_type ) { - $post_type = get_post_type(); - } - if ( ! lsx_to_is_collapsible( $post_type ) ) { - - $output = 'lsx-to-collapse-section'; - if ( false === $return ) { - echo esc_attr( $output ); - } else { - return $output; - } - } -} - -/** - * Returns the collapsible class if it is active. - * - * @param bool $target - * @param bool $post_type - * @param bool $return - * @return string - */ -function lsx_to_collapsible_attributes( $target = false, $post_type = false, $return = true ) { - if ( false === $post_type ) { - $post_type = get_post_type(); - } - if ( ! lsx_to_is_collapsible( $post_type ) ) { - $output = 'data-toggle="collapse" data-target="#' . $target . '"'; - if ( false === $return ) { - echo esc_attr( $output ); - } else { - return $output; - } - } -} - -function lsx_to_collapsible_attributes_not_post( $target = false, $return = true ) { - //$output = 'data-toggle="collapse" data-target="#' . $target . '"'; - $output = 'data-toggle='; - $output .= 'collapse'; - $output .= ' '; - $output .= 'data-target='; - $output .= '#' . $target; - echo esc_attr( $output ); -} - -/* ================== HEADER ================== */ - -/** - * Global header. - * - * @package tour-operator - * @subpackage template-tag - * @category header - */ -function lsx_to_global_header() { - $default_size = 'sm'; - $size = apply_filters( 'lsx_bootstrap_column_size', $default_size ); - ?> -
-
-

- -

- - ', '

' ); ?> -
- - -
-
', '
' ) ); -} - - -/* ================== SINGLE ================== */ - -/** - * Outputs the Single pages navigation - * - * @param $echo - * @return string - * - * @package tour-operator - * @subpackage template-tag - * @category navigation - */ -function lsx_to_page_navigation( $echo = true ) { - $page_links = array(); - - if ( is_single() ) { - $page_links['summary'] = esc_html__( 'Summary', 'tour-operator' ); - } - - // Allow 3rd party plugins and themes to disable the page links. - if ( apply_filters( 'lsx_to_page_navigation_disable', false, get_post_type() ) ) { - return false; - } - - $page_links = apply_filters( 'lsx_to_page_navigation', $page_links ); - - if ( ! empty( $page_links ) && count( $page_links ) > 1 ) { - $return = '
'; - $return .= ''; - $return .= '
'; - - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } -} - -/** - * outputs the sharing - * - * @package tour-operator - * @subpackage setup - * @category helper - */ -function lsx_to_sharing() { - echo '
'; - - if ( class_exists( 'LSX_Sharing' ) ) { - global $lsx_sharing; - echo wp_kses_post( $lsx_sharing->sharing_buttons() ); - } else { - if ( function_exists( 'sharing_display' ) ) { - sharing_display( '', true ); - } - - if ( class_exists( 'Jetpack_Likes' ) ) { - $custom_likes = new Jetpack_Likes(); - echo wp_kses_post( $custom_likes->post_likes( '' ) ); - } - } - - echo '
'; -} - -/* ================== TAXONOMIES ================== */ - -/** - * Outputs the widget with some styling - * - * @package tour-operator - * @subpackage template-tags - * @category helper - */ -function lsx_to_safari_brands( $before = '', $after = '', $echo = true ) { - $args = array( - 'name' => 'Home', - 'id' => 'sidebar-home', - 'description' => '', - 'class' => '', - 'before_widget' => '', - 'before_title' => '

', - 'after_title' => '

', - 'widget_id' => 'lsx_to_taxonomy_widget-6', - 'widget_name' => 'LSX Taxonomies', - ); - $instance = array( - 'title' => '', - 'title_link' => '', - 'columns' => '4', - 'orderby' => 'menu_order', - 'order' => 'ASC', - 'limit' => '100', - 'include' => '', - 'size' => '100', - 'buttons' => '', - 'button_text' => '', - 'responsive' => '1', - 'carousel' => '1', - 'taxonomy' => 'accommodation-brand', - 'class' => '', - 'interval' => '7000', - 'indicators' => '1', - ); - $safari_brands = new \lsx\legacy\Taxonomy_Widget(); - ob_start(); - $safari_brands->widget( $args, $instance ); - $return = ob_get_clean(); - $return = $before . $return . $after; - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } -} - -/** - * Outputs the travel styles widget with some styling - * - * @package tour-operator - * @subpackage template-tags - * @category helper - */ -function lsx_to_travel_styles( $before = '', $after = '', $echo = true ) { - $args = array( - 'name' => 'Home', - 'id' => 'sidebar-home', - 'description' => '', - 'class' => '', - 'before_widget' => '', - 'before_title' => '

', - 'after_title' => '

', - 'widget_id' => 'lsx_to_taxonomy_widget-6', - 'widget_name' => 'LSX Taxonomies', - ); - $instance = array( - 'title' => '', - 'title_link' => '', - 'columns' => '3', - 'orderby' => 'rand', - 'order' => 'DESC', - 'limit' => '100', - 'include' => '', - 'size' => '100', - 'buttons' => '', - 'button_text' => '', - 'responsive' => '1', - 'carousel' => '1', - 'taxonomy' => 'travel-style', - 'class' => '', - 'interval' => '7000', - 'indicators' => '1', - ); - $travel_styles = new \lsx\legacy\Taxonomy_Widget(); - ob_start(); - $travel_styles->widget( $args, $instance ); - $return = ob_get_clean(); - $return = $before . $return . $after; - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } -} - -/* ================== ENQUIRE ================== */ -/** - * Test if Enquire Contact exists - * - * @return boolean - * @package tour-operator - */ -function lsx_to_has_enquiry_contact() { - $tour_operator = tour_operator(); - - $has_enquiry_contact = false; - - if ( function_exists( 'lsx_to_has_team_member' ) ) { - $has_enquiry_contact = lsx_to_has_team_member(); - } - - if ( false === $has_enquiry_contact && isset( $tour_operator->options['general'] ) ) { - if ( isset( $tour_operator->options['general']['enquiry_contact_name'] ) && '' !== $tour_operator->options['general']['enquiry_contact_name'] ) { - $has_enquiry_contact = true; - } - - // First set the general form - if ( isset( $tour_operator->options['general']['enquiry'] ) && '' !== $tour_operator->options['general']['enquiry'] ) { - $has_enquiry_contact = true; - } - } - - return $has_enquiry_contact; -} -/** - * Display Enquire Contact - * - * @return void - * @package tour-operator - */ -function lsx_to_enquiry_contact( $before = '', $after = '' ) { - $tour_operator = tour_operator(); - - $fields = array( - 'enquiry_contact_name' => '', - 'enquiry_contact_email' => '', - 'enquiry_contact_phone' => '', - 'enquiry_contact_image_id' => '', - 'enquiry_contact_image' => '', - ); - - foreach ( $fields as $key => $field ) { - if ( isset( $tour_operator->options['general'] ) && isset( $tour_operator->options['general'][ $key ] ) ) { - $fields[ $key ] = $tour_operator->options['general'][ $key ]; - } - } - - if ( ! empty( $fields['enquiry_contact_image_id'] ) ) { - $temp_src_array = wp_get_attachment_image_src( $fields['enquiry_contact_image_id'], 'medium' ); - - if ( is_array( $temp_src_array ) && count( $temp_src_array ) > 0 ) { - $fields['enquiry_contact_image'] = $temp_src_array[0]; - } - } - - echo wp_kses_post( $before ); - ?> -
> - -
- ' ); ?> -
- - -
- Your travel expert: -

-
- - -
- options['general'] ) && isset( $tour_operator->options['general']['enquiry'] ) && '' !== $tour_operator->options['general']['enquiry'] ) { - $form_id = $tour_operator->options['general']['enquiry']; - } - - if ( is_singular( $tour_operator->active_post_types ) ) { - if ( isset( $tour_operator->options[ get_post_type() ] ) && isset( $tour_operator->options[ get_post_type() ]['enquiry'] ) && '' !== $tour_operator->options[ get_post_type() ]['enquiry'] ) { - $form_id = $tour_operator->options[ get_post_type() ]['enquiry']; - } - } - if ( is_archive( $tour_operator->active_post_types ) ) { - if ( isset( $tour_operator->options[ get_post_type() ] ) && isset( $tour_operator->options[ get_post_type() ]['enquiry'] ) && '' !== $tour_operator->options[ get_post_type() ]['enquiry'] ) { - $form_id = $tour_operator->options[ get_post_type() ]['enquiry']; - } - } - } - - $link = '#'; - - if ( isset( $tour_operator->options['general'] ) && isset( $tour_operator->options['general']['disable_enquire_modal'] ) && 'on' === $tour_operator->options['general']['disable_enquire_modal'] ) { - if ( isset( $tour_operator->options['general']['enquire_link'] ) && '' !== $tour_operator->options['general']['enquire_link'] ) { - $link = $tour_operator->options['general']['enquire_link']; - } - } - - if ( is_singular( $tour_operator->active_post_types ) ) { - if ( isset( $tour_operator->options[ get_post_type() ] ) && isset( $tour_operator->options[ get_post_type() ]['disable_enquire_modal'] ) && 'on' === $tour_operator->options[ get_post_type() ]['disable_enquire_modal'] ) { - $disable_modal = true; - if ( isset( $tour_operator->options[ get_post_type() ]['enquire_link'] ) && '' !== $tour_operator->options[ get_post_type() ]['enquire_link'] ) { - $link = $tour_operator->options[ get_post_type() ]['enquire_link']; - } - } - } - - if ( false !== $form_id ) { - ?> - - 'post_type', - 'label' => __( 'Destinations', 'lsx' ), - 'heirarchy' => true, - ); - - return $sitemap_loops; - } - add_filter( 'lsx_sitemap_loops_list', 'to_sitemap_loops', 1 ); -} From 2c447b815489e5785a4a8b97674ca37ac0c4a4dd Mon Sep 17 00:00:00 2001 From: Warwick Date: Wed, 11 Dec 2024 12:58:30 +0200 Subject: [PATCH 3/7] Removing the uneeded function --- includes/template-tags/addons.php | 25 ----- includes/template-tags/general.php | 108 ++++++++++++++++++ includes/template-tags/tour.php | 173 ----------------------------- includes/template-tags/videos.php | 115 ------------------- 4 files changed, 108 insertions(+), 313 deletions(-) delete mode 100644 includes/template-tags/addons.php delete mode 100644 includes/template-tags/tour.php delete mode 100644 includes/template-tags/videos.php diff --git a/includes/template-tags/addons.php b/includes/template-tags/addons.php deleted file mode 100644 index ced10d49..00000000 --- a/includes/template-tags/addons.php +++ /dev/null @@ -1,25 +0,0 @@ -has_itinerary() ) { + $itinerary_count = 1; + while ( $tour_itinerary->while_itinerary() ) { + $tour_itinerary->current_itinerary_item(); + + if ( ! empty( $tour_itinerary->itinerary[ $meta_key ] ) && '' !== $tour_itinerary->itinerary[ $meta_key] ) { + if ( ! is_array( $tour_itinerary->itinerary[ $meta_key ] ) ) { + $d_ids = array( $tour_itinerary->itinerary[ $meta_key ] ); + } else { + $d_ids = $tour_itinerary->itinerary[ $meta_key ]; + } + $itinerary_ids = array_merge( $itinerary_ids, array_values( $d_ids ) ); + } + } + } + return $itinerary_ids; +} + +// ============== Accommodation ================ +/** + * Outputs the accommodations facilities + * + * @param $before | string + * @param $after | string + * @param $echo | boolean + * @return string + * + * @package tour-operator + * @subpackage template-tags + * @category accommodation + */ +function lsx_to_accommodation_facilities( $before = '', $after = '', $echo = true ) { + $args = []; + $facilities = wp_get_object_terms( get_the_ID(), 'facility' ); + $main_facilities = []; + $child_facilities = []; + $return = ''; + + if ( ! empty( $facilities ) && ! is_wp_error( $facilities ) ) { + foreach ( $facilities as $facility ) { + if ( 0 === $facility->parent ) { + $main_facilities[] = $facility; + } else { + $child_facilities[ $facility->parent ][] = $facility; + } + } + + //Output in the order we want + if ( count( $main_facilities ) > 0 && count( $child_facilities ) > 0 ) { + $return .= '
'; + foreach ( $main_facilities as $heading ) { + if ( isset( $child_facilities[ $heading->term_id ] ) ) { + $return .= '
+

' . esc_html( $heading->name ) . ''; + $return .= '

'; + $return .= '
'; + } + } + $return .= '
'; + + if ( ! empty( $return ) ) { + $return = $before . $return . $after; + + if ( $echo ) { + echo wp_kses_post( $return ); + } else { + return $return; + } + } + } else { + return false; + } + } else { + return false; + } +} diff --git a/includes/template-tags/tour.php b/includes/template-tags/tour.php deleted file mode 100644 index 9ecb2b3a..00000000 --- a/includes/template-tags/tour.php +++ /dev/null @@ -1,173 +0,0 @@ - 0 ) { - $connected_list = lsx_to_connected_list( $departs_from, 'destination', true, ', ' ); - if ( false !== $options && isset( $options[ 'destination' ] ) && isset( $options[ 'destination' ]['disable_single_region'] ) ) { - $connected_list = strip_tags( $connected_list ); - } - $return = $before . $connected_list . $after; - - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } -} - -/** - * Gets the current tours end points - * - * @param $before | string - * @param $after | string - * @param $echo | boolean - * @return string - * - * @package tour-operator - * @subpackage template-tags - * @category tour - */ -function lsx_to_end_point( $before = '', $after = '', $echo = true ) { - $end_point = get_post_meta( get_the_ID(), 'ends_in', false ); - $options = get_option( '_lsx-to_settings', false ); - - if ( ! empty( $end_point ) && is_array( $end_point ) && count( $end_point ) > 0 ) { - $connected_list = lsx_to_connected_list( $end_point, 'destination', true, ', ' ); - if ( false !== $options && isset( $options[ 'destination' ] ) && isset( $options[ 'destination' ]['disable_single_region'] ) ) { - $connected_list = strip_tags( $connected_list ); - } - $return = $before . $connected_list . $after; - - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } -} - -/** - * Retrieves the accommodation ids from the itinerary, mostly for use in the map. - * the itinerary loop. - * - * @package tour-operator - * @subpackage template-tags - * @category itinerary - * - * @param string $meta_key - * @param string $supress_filters - * @return array - */ -function lsx_to_get_tour_itinerary_ids( $meta_key = 'accommodation_to_tour', $supress_filters = false ) { - $tour_itinerary = new \lsx\legacy\Itinerary_Query(); - $itinerary_ids = array(); - - if ( false === $supress_filters ) { - $meta_key = apply_filters( 'lsx_to_get_itinerary_ids_meta_key', $meta_key ); - } - - if ( $tour_itinerary->has_itinerary() ) { - $itinerary_count = 1; - while ( $tour_itinerary->while_itinerary() ) { - $tour_itinerary->current_itinerary_item(); - - if ( ! empty( $tour_itinerary->itinerary[ $meta_key ] ) && '' !== $tour_itinerary->itinerary[ $meta_key] ) { - if ( ! is_array( $tour_itinerary->itinerary[ $meta_key ] ) ) { - $d_ids = array( $tour_itinerary->itinerary[ $meta_key ] ); - } else { - $d_ids = $tour_itinerary->itinerary[ $meta_key ]; - } - $itinerary_ids = array_merge( $itinerary_ids, array_values( $d_ids ) ); - } - } - } - return $itinerary_ids; -} diff --git a/includes/template-tags/videos.php b/includes/template-tags/videos.php deleted file mode 100644 index 1856639d..00000000 --- a/includes/template-tags/videos.php +++ /dev/null @@ -1,115 +0,0 @@ -'; - $content .= '
'; - $content .= '
'; - $content .= '
'; - - foreach ( $videos as $video ) { - $content .= '
'; - $content .= '
'; - - if ( isset( $video['url'] ) && '' !== $video['url'] ) { - $content .= '
'; - - $embed_key = 'to_videos_embed_' . sanitize_title( $video['url'] ); - $embed = get_transient( $embed_key ); - - if ( false === $embed ) { - $embed = wp_oembed_get( $video['url'], array( - 'class' => 'embed-responsive-item', - ) ); - - if ( ! empty( $embed ) ) { - set_transient( $embed_key, $embed, ( 24 * 60 * 60 ) ); - } - } - - $content .= $embed; - $content .= '
'; - - $has_content = ( isset( $video['title'] ) && '' !== $video['title'] ) || ( isset( $video['description'] ) && '' !== $video['description'] ); - - if ( $has_content ) { - $content .= '
'; - - if ( isset( $video['title'] ) && '' !== $video['title'] ) { - $content .= '

' . $video['title'] . '

'; - } - - if ( isset( $video['description'] ) && '' !== $video['description'] ) { - $content .= apply_filters( 'the_content', $video['description'] ); - } - - $content .= '
'; - } - } - - $content .= '
'; - $content .= '
'; - } - - $content .= '
'; - $content .= '
'; - $content .= '
'; - $content .= ''; - - $return = $content; - } - - $protocol = is_ssl() ? 'https' : 'http'; - $return = preg_replace( '/href="\/\//i', 'href="' . $protocol . '://', $return ); - - $return = $before . $return . $after; - - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } - } -} From 54aea351e6dfbc9edc0b087b904130db051924ec Mon Sep 17 00:00:00 2001 From: Warwick Date: Wed, 11 Dec 2024 14:18:46 +0200 Subject: [PATCH 4/7] Removing the uneeded code. --- includes/classes/legacy/class-frontend.php | 77 ------ includes/template-tags/accommodation.php | 290 --------------------- includes/template-tags/helpers.php | 2 +- tour-operator-bootstrap.php | 4 - 4 files changed, 1 insertion(+), 372 deletions(-) delete mode 100644 includes/template-tags/accommodation.php diff --git a/includes/classes/legacy/class-frontend.php b/includes/classes/legacy/class-frontend.php index 7abd75d9..87b499e3 100644 --- a/includes/classes/legacy/class-frontend.php +++ b/includes/classes/legacy/class-frontend.php @@ -53,7 +53,6 @@ public function __construct() { $this->set_vars(); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_stylescripts' ), 1 ); - add_action( 'wp_head', array( $this, 'wp_head' ), 10 ); add_filter( 'body_class', array( $this, 'body_class' ), 15, 1 ); if ( ! is_admin() ) { @@ -61,9 +60,6 @@ public function __construct() { add_filter( 'posts_orderby', array( $this, 'enable_continent_taxonomy_order' ), 10, 2 ); } - add_filter( 'lsx_to_connected_list_item', array( $this, 'add_modal_attributes' ), 10, 3 ); - add_action( 'wp_footer', array( $this, 'output_modals' ), 10 ); - // add_filter( 'the_terms', array( $this, 'links_new_window' ), 10, 2 ); $this->maps = Maps::get_instance(); @@ -75,78 +71,6 @@ public function __construct() { add_filter( 'wpseo_breadcrumb_links', array( $this, 'wpseo_breadcrumb_links' ), 20 ); } - /** - * Initate some boolean flags - */ - public function wp_head() { - if ( ( is_singular( $this->active_post_types ) || is_post_type_archive( $this->active_post_types ) ) - && false !== $this->options - && isset( $this->options['display']['enable_modals'] ) - && 'on' === $this->options['display']['enable_modals'] - ) { - $this->enable_modals = true; - } - } - - /** - * a filter to overwrite the links with modal tags. - */ - public function add_modal_attributes( $html, $post_id, $link ) { - if ( true === $this->enable_modals && true === $link ) { - $html = '' . get_the_title( $post_id ) . ''; - - if ( ! in_array( $post_id, $this->modal_ids ) ) { - $this->modal_ids[] = $post_id; - } - } - - return $html; - } - - /** - * a filter to overwrite the links with modal tags. - */ - public function output_modals() { - global $lsx_to_archive, $post; - - if ( true === $this->enable_modals && ! empty( $this->modal_ids ) ) { - $temp = $lsx_to_archive; - $lsx_to_archive = 1; - - foreach ( $this->modal_ids as $post_id ) { - $post = get_post( $post_id ); - ?> - - - - post_types && is_singular( array_keys( $this->post_types ) ) ) { $classes[] = 'single-tour-operator'; } elseif ( false !== $this->post_types && is_post_type_archive( array_keys( $this->post_types ) ) ) { diff --git a/includes/template-tags/accommodation.php b/includes/template-tags/accommodation.php deleted file mode 100644 index 83e7bb99..00000000 --- a/includes/template-tags/accommodation.php +++ /dev/null @@ -1,290 +0,0 @@ -parent ) { - $main_facilities[] = $facility; - } else { - $child_facilities[ $facility->parent ][] = $facility; - } - } - - set_transient( get_the_ID() . '_facilities', $location, 30 ); - } - } else { - return false; - } -} - -/** - * Outputs the accommodations facilities - * - * @param $before | string - * @param $after | string - * @param $echo | boolean - * @return string - * - * @package tour-operator - * @subpackage template-tags - * @category accommodation - */ -function lsx_to_accommodation_facilities( $before = '', $after = '', $echo = true ) { - $args = []; - $facilities = wp_get_object_terms( get_the_ID(), 'facility' ); - $main_facilities = []; - $child_facilities = []; - $return = ''; - - if ( ! empty( $facilities ) && ! is_wp_error( $facilities ) ) { - foreach ( $facilities as $facility ) { - if ( 0 === $facility->parent ) { - $main_facilities[] = $facility; - } else { - $child_facilities[ $facility->parent ][] = $facility; - } - } - - //Output in the order we want - if ( count( $main_facilities ) > 0 && count( $child_facilities ) > 0 ) { - $return .= '
'; - foreach ( $main_facilities as $heading ) { - if ( isset( $child_facilities[ $heading->term_id ] ) ) { - $return .= '
-

' . esc_html( $heading->name ) . ''; - $return .= '

'; - $return .= '
'; - } - } - $return .= '
'; - - if ( ! empty( $return ) ) { - $return = $before . $return . $after; - - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } - } else { - return false; - } - } else { - return false; - } -} - -/** - * Outputs the Spoken Languages HTML - * - * @param $before | string - * @param $after | string - * @param $echo | boolean - * @return string - * - * @package tour-operator - * @subpackage template-tags - * @category accommodation - */ -function lsx_to_accommodation_spoken_languages( $before = '', $after = '', $echo = true ) { - $spoken_languages = get_post_meta( get_the_ID(), 'spoken_languages', true ); - - if ( is_string( $spoken_languages ) && ! empty( $spoken_languages ) ) { - $spoken_languages = array( $spoken_languages ); - } - - $return = ''; - - if ( ! empty( $spoken_languages ) && ! is_wp_error( $spoken_languages ) ) { - foreach ( $spoken_languages as $i => $spoken_language ) { - $return .= ucwords( str_replace( '_', ' / ', str_replace( '-', ' ', str_replace( '-and-', ' & ', $spoken_language ) ) ) ); - - if ( ( $i + 1 ) < count( $spoken_languages ) ) { - $return .= ', '; - } - } - $return = $before . $return . $after; - - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } else { - return false; - } -} - -/** - * Outputs the Special Interests HTML - * - * @param $before | string - * @param $after | string - * @param $echo | boolean - * @return string - * - * @package tour-operator - * @subpackage template-tags - * @category accommodation - */ -function lsx_to_accommodation_special_interests( $before = '', $after = '', $echo = true, $post_id = false ) { - if ( false === $post_id ) { - $post_id = get_the_ID(); - } - - $special_interests = get_post_meta( $post_id, 'special_interests', true ); - - if ( is_string( $special_interests ) && ! empty( $special_interests ) ) { - $special_interests = array( $special_interests ); - } - - $return = ''; - - if ( ! empty( $special_interests ) && ! is_wp_error( $special_interests ) ) { - foreach ( $special_interests as $i => $special_interest ) { - $return .= ucwords( str_replace( '_', ' / ', str_replace( '-', ' ', str_replace( '-and-', ' & ', $special_interest ) ) ) ); - - if ( ( $i + 1 ) < count( $special_interests ) ) { - $return .= ', '; - } - } - $return = $before . $return . $after; - - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } else { - return false; - } -} - -/** - * Outputs the Friendly HTML - * - * @param $before | string - * @param $after | string - * @param $echo | boolean - * @return string - * - * @package tour-operator - * @subpackage template-tags - * @category accommodation - * @category activity - */ -function lsx_to_accommodation_activity_friendly( $before = '', $after = '', $echo = true ) { - $friendly = get_post_meta( get_the_ID(), 'suggested_visitor_types', true ); - - if ( is_string( $friendly ) && ! empty( $friendly ) ) { - $friendly = array( $friendly ); - } - - $return = ''; - - if ( ! empty( $friendly ) && ! is_wp_error( $friendly ) ) { - foreach ( $friendly as $i => $friendly_item ) { - $return .= ucwords( str_replace( '_', ' / ', str_replace( '-', ' ', str_replace( '-and-', ' & ', $friendly_item ) ) ) ); - - if ( ( $i + 1 ) < count( $friendly ) ) { - $return .= ', '; - } - } - $return = $before . $return . $after; - - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } else { - return false; - } -} - -/** - * Gets the current specials connected accommodation - * - * @param $before | string - * @param $after | string - * @param $echo | boolean - * @return string - * - * @package tour-operator - * @subpackage template-tags - * @category connections - */ -function lsx_to_connected_accommodation( $before = '', $after = '', $echo = true ) { - lsx_to_connected_items_query( 'accommodation', get_post_type(), $before, $after, $echo ); -} diff --git a/includes/template-tags/helpers.php b/includes/template-tags/helpers.php index af69f52c..50940951 100644 --- a/includes/template-tags/helpers.php +++ b/includes/template-tags/helpers.php @@ -763,7 +763,7 @@ function to_continent_region_label( $country_code = '' ) { * @return string */ function lsx_to_get_price_type_label( $label_index = '' ) { - $label = ''; + $label = ''; switch ( $label_index ) { case '': $label = ''; diff --git a/tour-operator-bootstrap.php b/tour-operator-bootstrap.php index 508bb1c9..2c65349c 100644 --- a/tour-operator-bootstrap.php +++ b/tour-operator-bootstrap.php @@ -25,11 +25,7 @@ // Template Tags. require_once( LSX_TO_PATH . 'includes/template-tags/general.php' ); require_once( LSX_TO_PATH . 'includes/template-tags/helpers.php' ); - require_once( LSX_TO_PATH . 'includes/template-tags/addons.php' ); - require_once( LSX_TO_PATH . 'includes/template-tags/accommodation.php' ); - require_once( LSX_TO_PATH . 'includes/template-tags/tour.php' ); require_once( LSX_TO_PATH . 'includes/template-tags/maps.php' ); - require_once( LSX_TO_PATH . 'includes/template-tags/videos.php' ); // include context helper & autoloader. require_once( LSX_TO_PATH . 'includes/tour-operator.php' ); From 15f831a36281a11eae8745ef5144a42ae78393b8 Mon Sep 17 00:00:00 2001 From: Warwick Date: Wed, 11 Dec 2024 15:07:54 +0200 Subject: [PATCH 5/7] Fixing the code errors and removing functions. --- includes/classes/class-metaboxes.php | 79 --- includes/classes/legacy/class-scpo-engine.php | 486 ------------------ .../classes/legacy/class-tour-operator.php | 3 - includes/partials/help.php | 6 +- includes/patterns/accommodation-card.php | 2 +- includes/patterns/destination-card.php | 2 +- includes/patterns/gallery.php | 2 +- includes/patterns/itinerary-list.php | 2 +- includes/patterns/room-card.php | 2 +- includes/patterns/tour-card.php | 2 +- includes/template-tags/helpers.php | 291 ----------- 11 files changed, 11 insertions(+), 866 deletions(-) delete mode 100644 includes/classes/class-metaboxes.php delete mode 100644 includes/classes/legacy/class-scpo-engine.php diff --git a/includes/classes/class-metaboxes.php b/includes/classes/class-metaboxes.php deleted file mode 100644 index d39d1d09..00000000 --- a/includes/classes/class-metaboxes.php +++ /dev/null @@ -1,79 +0,0 @@ -object ); - } - - /** - * Register a taxonomy for the plugin. - * - * @since 1.1.0 - * - * @param string $slug The taxonomy slug. - * @param array $config The taxonomy config arguments. - */ - protected function register_object( $slug, $config ) { - $this->object[ $slug ] = $config; - } - - /** - * Remove Duplicate IDS from the post select fields. - * - * @param array $values - * @return array - */ - public function unique_arrays( $values ) { - - if ( ! empty( $values ) && is_array( $values ) ) { - $values = array_unique( $values ); - } - - return $values; - } -} diff --git a/includes/classes/legacy/class-scpo-engine.php b/includes/classes/legacy/class-scpo-engine.php deleted file mode 100644 index 1c531c9e..00000000 --- a/includes/classes/legacy/class-scpo-engine.php +++ /dev/null @@ -1,486 +0,0 @@ -lsx_to_scporder_install(); - } - - add_action( 'admin_init', array( $this, 'refresh' ) ); - add_action( 'admin_init', array( $this, 'load_script_css' ) ); - - add_action( 'wp_ajax_update-menu-order', array( - $this, - 'update_menu_order', - ) ); - add_action( 'wp_ajax_update-menu-order-tags', array( - $this, - 'update_menu_order_tags', - ) ); - - add_action( 'pre_get_posts', array( - $this, - 'lsx_to_scporder_pre_get_posts', - ) ); - - add_filter( 'get_previous_post_where', array( - $this, - 'lsx_to_scporder_previous_post_where', - ) ); - add_filter( 'get_previous_post_sort', array( - $this, - 'lsx_to_scporder_previous_post_sort', - ) ); - add_filter( 'get_next_post_where', array( - $this, - 'lsx_to_scporder_next_post_where', - ) ); - add_filter( 'get_next_post_sort', array( - $this, - 'lsx_to_scporder_next_post_sort', - ) ); - - add_filter( 'get_terms_orderby', array( - $this, - 'lsx_to_scporder_get_terms_orderby', - ), 10, 3 ); - add_filter( 'wp_get_object_terms', array( - $this, - 'lsx_to_scporder_get_object_terms', - ), 10, 4 ); - add_filter( 'get_terms', array( - $this, - 'lsx_to_scporder_get_object_terms', - ), 10, 4 ); - } - - function lsx_to_scporder_install() { - global $wpdb; - $result = $wpdb->query( "DESCRIBE $wpdb->terms `lsx_to_term_order`" ); - - if ( ! $result ) { - $result = $wpdb->query( "ALTER TABLE $wpdb->terms ADD `lsx_to_term_order` INT(4) NULL DEFAULT '0'" ); - } - - update_option( 'lsx_to_scporder_install', 1 ); - } - - function _check_load_script_css() { - $active = false; - - $objects = $this->get_to_scporder_options_objects(); - $tags = $this->get_to_scporder_options_tags(); - - if ( empty( $objects ) && empty( $tags ) ) { - return false; - } - - if ( isset( $_GET['orderby'] ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'action=edit' ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/post-new.php' ) ) { - return false; - } - - if ( ! empty( $objects ) ) { - if ( isset( $_GET['post_type'] ) && ! isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['post_type'] ), $objects ) ) { // if page or custom post types - $active = true; - } - if ( ! isset( $_GET['post_type'] ) && strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/edit.php' ) && array_key_exists( 'post', $objects ) ) { // if post - $active = true; - } - } - - if ( ! empty( $tags ) ) { - if ( isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['taxonomy'] ), $tags ) ) { - $active = true; - } - } - - return $active; - } - - function load_script_css() { - if ( $this->_check_load_script_css() ) { - wp_enqueue_script( 'scporderjs', LSX_TO_URL . '/assets/js/scporder.min.js', array( 'jquery', 'jquery-ui-sortable' ), null, true ); - - $scporderjs_params = array( - 'ajax_url' => admin_url( 'admin-ajax.php' ), - 'ajax_nonce' => wp_create_nonce( 'scporder' ), - ); - - wp_localize_script( 'scporderjs', 'scporderjs_params', $scporderjs_params ); - - wp_enqueue_style( 'scporder', LSX_TO_URL . '/assets/css/scporder.css', array(), null ); - wp_style_add_data( 'scporder', 'rtl', 'replace' ); - } - } - - function refresh() { - global $wpdb; - $objects = $this->get_to_scporder_options_objects(); - $tags = $this->get_to_scporder_options_tags(); - - if ( ! empty( $objects ) ) { - foreach ( $objects as $object => $object_data ) { - $result = $wpdb->get_results( $wpdb->prepare( " - SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min - FROM $wpdb->posts - WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') - ", $object ) ); - - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { - continue; - } - - $results = $wpdb->get_results( $wpdb->prepare( " - SELECT ID - FROM $wpdb->posts - WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') - ORDER BY menu_order ASC - ", $object ) ); - - foreach ( $results as $key => $result ) { - $wpdb->update( - $wpdb->posts, - array( - 'menu_order' => $key + 1, - ), - array( - 'ID' => $result->ID, - ) - ); - } - } - } - - if ( ! empty( $tags ) ) { - foreach ( $tags as $taxonomy => $taxonomy_data ) { - $result = $wpdb->get_results( $wpdb->prepare( " - SELECT count(*) as cnt, max(lsx_to_term_order) as max, min(lsx_to_term_order) as min - FROM $wpdb->terms AS terms - INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) - WHERE term_taxonomy.taxonomy = '%s' - ", $taxonomy ) ); - - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { - continue; - } - - $results = $wpdb->get_results( $wpdb->prepare( " - SELECT terms.term_id - FROM $wpdb->terms AS terms - INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) - WHERE term_taxonomy.taxonomy = '%s' - ORDER BY lsx_to_term_order ASC - ", $taxonomy ) ); - - foreach ( $results as $key => $result ) { - $wpdb->update( - $wpdb->terms, - array( - 'lsx_to_term_order' => $key + 1, - ), - array( - 'term_id' => $result->term_id, - ) - ); - } - } - } - } - - function update_menu_order() { - check_ajax_referer( 'scporder', 'security' ); - - global $wpdb; - - parse_str( sanitize_text_field( $_POST['order'] ), $data ); - - if ( ! is_array( $data ) ) { - return false; - } - - /*$id_arr = array(); - - foreach ( $data as $key => $values ) { - foreach ( $values as $position => $id ) { - $id_arr[] = $id; - } - } - - $menu_order_arr = array(); - - foreach ( $id_arr as $key => $id ) { - $results = $wpdb->get_results( "SELECT menu_order FROM $wpdb->posts WHERE ID = " . intval( $id ) ); - foreach ( $results as $result ) { - $menu_order_arr[] = $result->menu_order; - } - } - - sort( $menu_order_arr );*/ - - foreach ( $data as $key => $values ) { - foreach ( $values as $position => $id ) { - $wpdb->update( - $wpdb->posts, - array( - 'menu_order' => $position, - ), - array( - 'ID' => intval( $id ), - ) - ); - } - } - } - - function update_menu_order_tags() { - check_ajax_referer( 'scporder', 'security' ); - - global $wpdb; - - parse_str( sanitize_text_field( $_POST['order'] ), $data ); - - if ( ! is_array( $data ) ) { - return false; - } - - /*$current_user = wp_get_current_user(); - if ( false === $current_user || 'lightspeed' !== $current_user->data->user_login ) { - return false; - }*/ - - /*$id_arr = array(); - - foreach ( $data as $key => $values ) { - foreach ( $values as $position => $id ) { - $id_arr[] = $id; - } - } - - $menu_order_arr = array(); - - foreach ( $id_arr as $key => $id ) { - $results = $wpdb->get_results( "SELECT lsx_to_term_order FROM $wpdb->terms WHERE term_id = " . intval( $id ) ); - foreach ( $results as $result ) { - $menu_order_arr[] = $result->lsx_to_term_order; - } - } - - sort( $menu_order_arr );*/ - - foreach ( $data as $key => $values ) { - $term_ids = array(); - foreach ( $values as $position => $id ) { - $wpdb->update( - $wpdb->terms, - array( - 'lsx_to_term_order' => $position + 1, - ), - array( - 'term_id' => intval( $id ), - ) - ); - $term_ids[] = intval( $id ); - } - clean_term_cache( $term_ids ); - } - } - - function lsx_to_scporder_previous_post_where( $where ) { - global $post; - $objects = $this->get_to_scporder_options_objects(); - - if ( empty( $objects ) ) { - return $where; - } - - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { - $current_menu_order = $post->menu_order; - $where = "WHERE p.menu_order > '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; - } - - return $where; - } - - function lsx_to_scporder_previous_post_sort( $orderby ) { - global $post; - $objects = $this->get_to_scporder_options_objects(); - - if ( empty( $objects ) ) { - return $orderby; - } - - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { - $orderby = 'ORDER BY p.menu_order ASC LIMIT 1'; - } - - return $orderby; - } - - function lsx_to_scporder_next_post_where( $where ) { - global $post; - $objects = $this->get_to_scporder_options_objects(); - - if ( empty( $objects ) ) { - return $where; - } - - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { - $current_menu_order = $post->menu_order; - $where = "WHERE p.menu_order < '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; - } - - return $where; - } - - function lsx_to_scporder_next_post_sort( $orderby ) { - global $post; - $objects = $this->get_to_scporder_options_objects(); - - if ( empty( $objects ) ) { - return $orderby; - } - - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { - $orderby = 'ORDER BY p.menu_order DESC LIMIT 1'; - } - - return $orderby; - } - - function lsx_to_scporder_pre_get_posts( $wp_query ) { - $objects = $this->get_to_scporder_options_objects(); - - if ( empty( $objects ) ) { - return false; - } - - if ( is_admin() ) { - if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) { - if ( ! is_array( $wp_query->query['post_type'] ) ) { - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { - $wp_query->set( 'orderby', 'menu_order' ); - $wp_query->set( 'order', 'ASC' ); - } - } - } - } else { - $active = false; - - if ( isset( $wp_query->query['post_type'] ) ) { - if ( ! is_array( $wp_query->query['post_type'] ) ) { - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { - $active = true; - } - } - } else { - if ( array_key_exists( 'post', $objects ) ) { - $active = true; - } - } - - if ( ! $active ) { - return false; - } - - if ( isset( $wp_query->query['disabled_custom_post_order'] ) ) { - return false; - } - - if ( isset( $wp_query->query['suppress_filters'] ) ) { - if ( $wp_query->get( 'orderby' ) == 'date' ) { - $wp_query->set( 'orderby', 'menu_order' ); - } - if ( $wp_query->get( 'order' ) == 'DESC' ) { - $wp_query->set( 'order', 'ASC' ); - } - } else { - if ( ! $wp_query->get( 'orderby' ) ) { - $wp_query->set( 'orderby', 'menu_order' ); - } - if ( ! $wp_query->get( 'order' ) ) { - $wp_query->set( 'order', 'ASC' ); - } - } - } - } - - function lsx_to_scporder_get_terms_orderby( $orderby, $args ) { - - if ( is_admin() ) { - return $orderby; - } - - if ( isset( $args['disabled_custom_post_order'] ) ) { - return $orderby; - } - - $tags = $this->get_to_scporder_options_tags(); - - if ( ! isset( $args['taxonomy'] ) ) { - return $orderby; - } - - $taxonomy = $args['taxonomy']; - if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 ) { - $taxonomy = $taxonomy[0]; - } - if ( ! is_array( $taxonomy ) && ! array_key_exists( $taxonomy, $tags ) ) { - return $orderby; - } - - $orderby = 't.lsx_to_term_order'; - - return $orderby; - } - - function lsx_to_scporder_get_object_terms( $terms, $not_used, $args_1, $args_2 = null ) { - $tags = $this->get_to_scporder_options_tags(); - - if ( is_admin() && isset( $_GET['orderby'] ) ) { - return $terms; - } - - $args = is_null( $args_2 ) || ! is_array( $args_2 ) ? $args_1 : $args_2; - - if ( isset( $args['disabled_custom_post_order'] ) ) { - return $terms; - } - - foreach ( $terms as $key => $term ) { - if ( is_object( $term ) && isset( $term->taxonomy ) ) { - $taxonomy = $term->taxonomy; - if ( ! array_key_exists( $taxonomy, $tags ) ) { - return $terms; - } - } else { - return $terms; - } - } - usort( $terms, array( $this, 'taxcmp' ) ); - return $terms; - } - - function taxcmp( $a, $b ) { - if ( $a->lsx_to_term_order == $b->lsx_to_term_order ) { - return 0; - } - - return ( $a->lsx_to_term_order < $b->lsx_to_term_order ) ? - 1 : 1; - } - - function get_to_scporder_options_objects() { - $tour_operator = tour_operator()->legacy; - - return apply_filters( 'lsx_to_scpo_engine_objects', $tour_operator->post_types ); - } - - function get_to_scporder_options_tags() { - $tour_operator = tour_operator()->legacy; - - return apply_filters( 'lsx_to_scpo_engine_taxonomies', $tour_operator->taxonomies ); - } - -} diff --git a/includes/classes/legacy/class-tour-operator.php b/includes/classes/legacy/class-tour-operator.php index 37a3ea4d..2fced2cf 100644 --- a/includes/classes/legacy/class-tour-operator.php +++ b/includes/classes/legacy/class-tour-operator.php @@ -166,9 +166,6 @@ private function __construct() { add_action( 'init', array( $this, 'disable_deprecated' ), 0 ); add_action( 'plugins_loaded', array( $this, 'trigger_schema' ), 10 ); - // Start sort engine. - new SCPO_Engine(); - // Set the options. $this->options = get_option( 'lsx_to_settings', array() ); $this->set_vars(); diff --git a/includes/partials/help.php b/includes/partials/help.php index ef312dfd..0fcc463e 100644 --- a/includes/partials/help.php +++ b/includes/partials/help.php @@ -20,7 +20,11 @@
- +

diff --git a/includes/patterns/accommodation-card.php b/includes/patterns/accommodation-card.php index aa842f7c..abf8b699 100644 --- a/includes/patterns/accommodation-card.php +++ b/includes/patterns/accommodation-card.php @@ -2,7 +2,7 @@ return array( 'title' => __( 'Accommodation Card', 'tour-operator' ), - 'description' => __( '', 'tour-operator' ), + 'description' => __( 'A grid display for accommodation.', 'tour-operator' ), 'categories' => array( $this->category ), 'content' => '
diff --git a/includes/patterns/destination-card.php b/includes/patterns/destination-card.php index cedc7e30..b921eddc 100644 --- a/includes/patterns/destination-card.php +++ b/includes/patterns/destination-card.php @@ -1,7 +1,7 @@ __( 'Destination Card', 'tour-operator' ), - 'description' => __( '', 'tour-operator' ), + 'description' => __( 'A grid display for destinations.', 'tour-operator' ), 'categories' => array( $this->category ), 'templateTypes' => array( 'single' ), 'content' => ' diff --git a/includes/patterns/gallery.php b/includes/patterns/gallery.php index 54e5d746..fabe0d10 100644 --- a/includes/patterns/gallery.php +++ b/includes/patterns/gallery.php @@ -2,7 +2,7 @@ return array( 'title' => __( 'TO Gallery', 'tour-operator' ), - 'description' => __( '', 'tour-operator' ), + 'description' => __( 'Display the attached images, with a lightbox gallery.', 'tour-operator' ), 'categories' => array( $this->category ), 'templateTypes' => array( 'single' ), 'content' => ' diff --git a/includes/patterns/itinerary-list.php b/includes/patterns/itinerary-list.php index 9087d91d..72ce2ab2 100644 --- a/includes/patterns/itinerary-list.php +++ b/includes/patterns/itinerary-list.php @@ -1,7 +1,7 @@ __( 'Itinerary (list)', 'tour-operator' ), - 'description' => __( '', 'tour-operator' ), + 'description' => __( 'A list display for the tour itineraries.', 'tour-operator' ), 'categories' => array( $this->category ), 'templateTypes' => array( 'single' ), 'blockTypes' => [ 'Day by day' ], diff --git a/includes/patterns/room-card.php b/includes/patterns/room-card.php index 9f384ceb..b00ea6eb 100644 --- a/includes/patterns/room-card.php +++ b/includes/patterns/room-card.php @@ -1,7 +1,7 @@ __( 'Room Card', 'tour-operator' ), - 'description' => __( '', 'tour-operator' ), + 'description' => __( 'A list display for the accommodation units.', 'tour-operator' ), 'categories' => array( $this->category ), 'templateTypes' => array( 'single' ), 'content' => ' diff --git a/includes/patterns/tour-card.php b/includes/patterns/tour-card.php index 7235cc39..649325d7 100644 --- a/includes/patterns/tour-card.php +++ b/includes/patterns/tour-card.php @@ -2,7 +2,7 @@ return array( 'title' => __( 'Tour Card', 'tour-operator' ), - 'description' => __( 'Display the tours', 'tour-operator' ), + 'description' => __( 'A grid display for tours.', 'tour-operator' ), 'categories' => array( $this->category ), 'content' => '
diff --git a/includes/template-tags/helpers.php b/includes/template-tags/helpers.php index 50940951..72344769 100644 --- a/includes/template-tags/helpers.php +++ b/includes/template-tags/helpers.php @@ -308,297 +308,6 @@ function lsx_to_custom_field_query( $meta_key = false, $before = '', $after = '' } } -/** - * Gets the list of connections requested - * - * @param $from | string - * @param $to | string - * @param $before | string - * @param $after | string - * @param $echo | boolean - * @param $parent | boolean - * @return string - * - * @package tour-operator - * @subpackage template-tags - * @category helper - */ -function lsx_to_connected_items_query( $from = false, $to = false, $before = '', $after = '', $echo = false, $parents = false, $extra = false ) { - if ( post_type_exists( $from ) && post_type_exists( $to ) ) { - $connected_ids = get_post_meta( get_the_ID(), $from . '_to_' . $to, false ); - - if ( $parents ) { - $connected_ids = apply_filters( 'lsx_to_parents_only', $connected_ids, $from . '_to_' . $to ); - } - - if ( false !== $connected_ids && '' !== $connected_ids && ! empty( $connected_ids ) ) { - if ( ! is_array( $connected_ids ) ) { - $connected_ids = array( $connected_ids ); - } - - $return = $before . lsx_to_connected_list( $connected_ids, $from, true, ', ' ) . $after; - - if ( false !== $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } else { - return false; - } - } -} - -/** - * Gets the list of connections items, and displays them using the the specified content part. - * - * @param $args | array - * @return string - * - * @package tour-operator - * @subpackage template-tags - * @category helper - */ -function lsx_to_connected_panel_query( $args = false ) { - global $lsx_to_archive, $columns; - - if ( false !== $args && is_array( $args ) ) { - $defaults = array( - 'from' => false, - 'to' => false, - 'content_part' => false, - 'id' => false, - 'column' => false, - 'before' => '', - 'after' => '', - 'featured' => false, - 'orderby' => false, - 'items' => array(), - ); - - $args = wp_parse_args( $args, $defaults ); - - if ( false === $args['content_part'] ) { - $args['content_part'] = $args['from']; - } - - if ( empty( $args['items'] ) ) { - $items_array = get_post_meta( get_the_ID(), $args['from'] . '_to_' . $args['to'], false ); - } else { - $items_array = $args['items']; - } - - if ( false !== $items_array && is_array( $items_array ) && ! empty( $items_array ) ) { - $items_query_args = array( - 'post_type' => $args['from'], - 'post_status' => 'publish', - 'post__in' => $items_array, - ); - - if ( false !== $args['orderby'] ) { - $items_query_args['orderby'] = $args['orderby']; - } - - if ( true === $args['featured'] || 'true' === $args['featured'] ) { - $items_query_args['meta_query'] = array( - 'relation' => 'OR', - array( - 'key' => 'featured', - 'value' => true, - 'compare' => '=', - ), - ); - - if ( 'accommodation' === $args['from'] ) { - $items_query_args['meta_query'][] = array( - 'key' => 'featured', - 'compare' => 'NOT EXISTS', - ); - $items_query_args['orderby'] = array( - 'meta_value' => 'DESC', - 'title' => 'RAND', - ); - } - } - - $items = new WP_Query( $items_query_args ); - - if ( $items->have_posts() ) : - $lsx_to_archive = 1; - - $carousel_id = rand( 20, 20000 ); - $columns = intval( esc_attr( $args['column'] ) ); - $interval = '6000'; - $post_type = $args['content_part']; - - echo wp_kses_post( $args['before'] ); - - if ( 1 < $items->post_count ) { - echo '
'; - echo '
'; - echo '
'; - echo '
'; - } - - while ( $items->have_posts() ) : - $items->the_post(); - - global $disable_placeholder, $disable_text; - - $disable_placeholder = apply_filters( 'lsx_to_widget_disable_placeholder', false, $args['to'], $post_type ); - $disable_text = apply_filters( 'lsx_to_widget_disable_text', false, $args['to'], $post_type ); - - $class = ''; - if ( 1 === $items->post_count ) { - $class = 'singular-item'; - } else if ( 2 === $items->post_count ) { - $class = 'dual-item'; - } - - echo '
'; - lsx_to_content( 'content-widget', $args['content_part'] ); - echo '
'; - endwhile; - - wp_reset_postdata(); - $lsx_to_archive = 0; - - if ( 1 < $items->post_count ) { - echo '
'; - } - do_action( 'lsx_to_connected_panel_query_bottom', $args ); - - if ( 1 < $items->post_count ) { - echo '
'; - echo '
'; - echo '
'; - } - - echo wp_kses_post( $args['after'] ); - - endif; - } - } -} - -/** - * Returns items tagged in the same terms for the taxonomy you select. - * - * @param $taxonomy | string - * @return string - * - * @package tour-operator - * @subpackage template-tags - * @category helper - */ -function lsx_to_related_items( $taxonomy = false, $before = '', $after = '', $echo = true, $post_type = false ) { - if ( false !== $taxonomy ) { - $return = false; - $filters = array(); - - if ( false === $post_type ) { - $post_type = get_post_type(); - } - - $filters['post_type'] = $post_type; - - if ( is_array( $taxonomy ) ) { - $filters['post__in'] = $taxonomy; - } else { - //Get the settings from the customizer options - $filters['posts_per_page'] = 15; - //Exclude the current post - $filters['post__not_in'] = array( get_the_ID() ); - //if its set to related then we need to check by the type. - $filters['orderby'] = 'rand'; - $terms = wp_get_object_terms( get_the_ID(), $taxonomy ); - - //only allow relation by 1 property type term - if ( is_array( $terms ) && ! empty( $terms ) ) { - $filters['tax_query'] = array( - array( - 'taxonomy' => $taxonomy, - 'field' => 'slug', - 'terms' => array(), - ), - ); - - foreach ( $terms as $term ) { - $filters['tax_query'][0]['terms'][] = $term->slug; - } - } - } - - $related_query = new WP_Query( $filters ); - - if ( $related_query->have_posts() ) : - global $wp_query, $columns; - - $wp_query->is_single = 0; - $wp_query->is_singular = 0; - $wp_query->is_post_type_archive = 1; - - if ( null === $columns || empty( $columns ) || '' === $columns ) { - $columns = 3; - } - - ob_start(); - - //Setting some carousel variables - $carousel_id = rand( 20, 20000 ); - $interval = '6000'; - $post_type = get_post_type(); - - $slider_atts = array( - 'slidesToShow' => esc_attr( $columns ), - 'slidesToScroll' => esc_attr( $columns ), - ); - $slider_atts = apply_filters( 'lsx_to_related_slider_attributes', $slider_atts ); - - echo '
'; - echo '
'; - echo '
'; - - //echo '
'; - echo "
"; - - while ( $related_query->have_posts() ) : - $related_query->the_post(); - - global $disable_placeholder, $disable_text; - - $disable_placeholder = apply_filters( 'lsx_to_widget_disable_placeholder', false, $post_type, false, $taxonomy ); - $disable_text = apply_filters( 'lsx_to_widget_disable_text', false, $post_type, false, $taxonomy ); - - echo '
'; - lsx_to_content( 'content-widget', $post_type ); - echo '
'; - endwhile; - - echo '
'; - echo '
'; - echo '
'; - echo '
'; - - $return = ob_get_clean(); - - $wp_query->is_single = 1; - $wp_query->is_singular = 1; - $wp_query->is_post_type_archive = 0; - - wp_reset_postdata(); - - $return = $before . $return . $after; - endif; - - if ( $echo ) { - echo wp_kses_post( $return ); - } else { - return $return; - } - } -} - /** * Outputs a list of the ids you give it * From 5b25d2eebf07a26e61c1bdc5077e6c0c4ce109c3 Mon Sep 17 00:00:00 2001 From: Warwick Date: Wed, 11 Dec 2024 15:21:12 +0200 Subject: [PATCH 6/7] Fixing the PHPcs errors --- .../placeholder-post-750x350 copy.jpg | Bin 3587 -> 0 bytes includes/classes/blocks/class-bindings.php | 14 +-- .../classes/blocks/class-registration.php | 1 + includes/classes/class-share.php | 100 ------------------ includes/classes/legacy/class-maps.php | 4 +- vendor/cmb2/includes/CMB2.php | 2 +- 6 files changed, 11 insertions(+), 110 deletions(-) delete mode 100644 assets/img/placeholders/placeholder-post-750x350 copy.jpg delete mode 100644 includes/classes/class-share.php diff --git a/assets/img/placeholders/placeholder-post-750x350 copy.jpg b/assets/img/placeholders/placeholder-post-750x350 copy.jpg deleted file mode 100644 index 6001631cd20353545f67a3935688081a2a91a478..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3587 zcmeHGeN>WJ8h;VB?94PVq|Q!$G+LxK<3@ah@9sUj0SE*DKD7_PHUUIO7Nn8^0E-0z003ACK*~}9N4sS|0(@xy z007zq0igCBvgB)W_$}(7Yl8k}Lk=$;v}u8m&r&jTGHEH9pRY#+ZUI7e?7=!NvDvX~ zZ(KIl411oIF@f(LHUDs7&6;kl7Nci85tlf&Mc6Iad&1$~lP9Wu; z`d|Ypc-xNbvqSdmwSOf2g?`Bk`@>bgdPjkGpb)zzC=7@I7L$MRzFpsT;Qy=xf00>4 z)fccx@Yq3-eyVFyiuIV&_vZA5Wv?z*k#rbg9c|*sluF5c-lBEg{}dkB_unYscFE<> zXQ$VFOG$khW({4)lyjMIIU&!7ezwbZ^$Ed1$EohljJ(+S(JLnw`==NM?AqCA^XoM( zI{Lo?&psIel^YLUm&}C`u_N4ymo!&=Sd+p-x-B2Oy|?1YEe|S)imC&J6~;mu$q|?&uPOX z_s=wp|HO^?iCx24rRZbTPNrJ}$PEQ*9|jo|vfJhin@Osp`gby~9=a`N8iIU;KAHnfk+z@k*pl(j$S)m(IuB6b26xODjq@4mW%`TO~-^M3k9>jc1Z#y5eFGyEo~; zs&88PtcEeT*n_6`vNj(+ji4k`zm8D4()W&_8JD=4LvBuk_(ONQD$b-0=4VLO;yla@ z^2tKtC?$S7uAK_Ipt0ya$)5)O*tKA-56Bty2QOAqr!-sddH!|S$hc^-0Vdx<%EQvG ztD9+roCKj;iZI)!hC9zDg|flPMlVt=g@GW)xmibU)SDEo=QyeE#^WFJKbFK{W{c)i zc!79$&;k~{O9~H11Wd6kbL%CltronpmNBcjIzg2pwAuix3ZEcGV|k<0Rz79QV-RU9 zPi=aWzvhE7$ptQPA)~*egvG1WE7>5GK_X=wsHkAp@5}TLY|o*++W#mA6K`aW(03+) zQ^(SsIcOf}W-b}#SA zV`27F8VVa8Zlb9v<>loDRL@R@B>am>y`n^9e1P7}M_gmB9r}}7o33)QQGkLGTqAK_ zp)Hp);qOnTCIV7Z;tmm!un-(GE)s!(xKd=$0gzwJeuBj-ykmSD>*wx$x*Owe1NuJX zy!_Gz?3I^l{;3sq3|~@psC;T&E^Gx1#8*rinj!|^n zK_Ojn$k?cIFo5Z`snNr!LzsIS15KfxxL=HmY(JTHO@b~eU>7h|sGeOX)d!gm>5CDP zhxD%S2Oc({<;5Yx zTQ@WO1sA1qllEF#jrB)@QdYO!27nl1y2;mFMWPC&S)nuC83BU)PCg=_1tb?v@_i5m zx;fpD_w2v}8=woZ0kXR`U|OGxZ!IE%<~Yrx&^bfaBuPZLd^0M%fYs=V7x&YDK3WqC zd*H>3=NOB5&1%txf(or*3}&W_rsUS7uYwQ*8s&YB8g0d#FPjf7L`UZPP9}6KVxwST zkHI#k_ZQSt#wn6aqn4k!nYMMl7@sYW{(0<`iJ0VJ131k3dyDv6Z}P;Kav}BGI%Ou8 zGXfe~d448DqIrqmHB@$PY62UCkDgz^#qNsk5m&a3$y#q6#bhR1YNzA8r(f%bzY7`+ zp6yAh@}lxs7CanHSD}aChSb5b@2@f%v3)-#<}Gik Q_ig^$4*ah=;BAxr8=ULFF8}}l diff --git a/includes/classes/blocks/class-bindings.php b/includes/classes/blocks/class-bindings.php index df1567b8..b8d9526d 100644 --- a/includes/classes/blocks/class-bindings.php +++ b/includes/classes/blocks/class-bindings.php @@ -77,7 +77,7 @@ public function register_block_bindings() { register_block_bindings_source( 'lsx/post-connection', array( - 'label' => __( 'Post Connection', 'lsx-wetu-importer' ), + 'label' => __( 'Post Connection', 'tour-operator' ), 'get_value_callback' => array( $this, 'post_connections_callback' ) ) ); @@ -85,7 +85,7 @@ public function register_block_bindings() { register_block_bindings_source( 'lsx/post-meta', array( - 'label' => __( 'Post Meta', 'lsx-wetu-importer' ), + 'label' => __( 'Post Meta', 'tour-operator' ), 'get_value_callback' => array( $this, 'post_meta_callback' ) ) ); @@ -93,7 +93,7 @@ public function register_block_bindings() { register_block_bindings_source( 'lsx/tour-itinerary', array( - 'label' => __( 'Itinerary', 'lsx-wetu-importer' ), + 'label' => __( 'Itinerary', 'tour-operator' ), 'get_value_callback' => array( $this, 'empty_callback' ) ) ); @@ -101,7 +101,7 @@ public function register_block_bindings() { register_block_bindings_source( 'lsx/accommodation-units', array( - 'label' => __( 'Units', 'lsx-wetu-importer' ), + 'label' => __( 'Units', 'tour-operator' ), 'get_value_callback' => array( $this, 'empty_callback' ) ) ); @@ -109,7 +109,7 @@ public function register_block_bindings() { register_block_bindings_source( 'lsx/gallery', array( - 'label' => __( 'Gallery', 'lsx-wetu-importer' ), + 'label' => __( 'Gallery', 'tour-operator' ), 'get_value_callback' => array( $this, 'empty_callback' ) ) ); @@ -117,7 +117,7 @@ public function register_block_bindings() { register_block_bindings_source( 'lsx/map', array( - 'label' => __( 'Map', 'lsx-wetu-importer' ), + 'label' => __( 'Map', 'tour-operator' ), 'get_value_callback' => array( $this, 'empty_callback' ) ) ); @@ -474,7 +474,7 @@ public function build_unit_field( $build = '', $field = '', $count = 1 ) { switch ( $field ) { case 'title': - $value = strip_tags( $rooms->item_title( '', '', false ) ); + $value = wp_strip_all_tags( $rooms->item_title( '', '', false ) ); $pattern = '/(]*\bclass="[^"]*\bunit-title\b[^"]*"[^>]*>).*?(<\/h[1-6]>)/is'; break; diff --git a/includes/classes/blocks/class-registration.php b/includes/classes/blocks/class-registration.php index 4b168c59..97a0ce78 100644 --- a/includes/classes/blocks/class-registration.php +++ b/includes/classes/blocks/class-registration.php @@ -432,6 +432,7 @@ protected function post_ids_exist( $ids ) { AND ID IN (%s) AND post_status IN ('draft', 'publish')"; + // @phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared (the code is prepared) return (int) $wpdb->get_var( $wpdb->prepare( $query, $ids ) ); } diff --git a/includes/classes/class-share.php b/includes/classes/class-share.php deleted file mode 100644 index 42be9d70..00000000 --- a/includes/classes/class-share.php +++ /dev/null @@ -1,100 +0,0 @@ -active_styles .= $styles; - } - - /** - * Runs after active assets have been set. - * - * @since 1.1.0 - * @access protected - */ - public function render_active_styles() { - - if ( ! empty( $this->active_styles ) ) { - echo ''; - } - } - - /** - * Return an instance of this class. - * - * @codeCoverageIgnore - * @since 1.1.0 - * @return self A single instance of the share class. - */ - public static function init() { - - // If the single instance hasn't been set, set it now. - if ( ! isset( self::$instance ) ) { - self::$instance = new self(); - } - - return self::$instance; - - } - - /** - * Constructor. Sets up action to render styles. - * - * @since 1.1.0 - */ - public function __construct() { - add_action( 'admin_enqueue_scripts', array( - $this, - 'render_active_styles', - ), 100 ); - add_action( 'wp_print_styles', array( - $this, - 'render_active_styles', - ), 100 ); - } -} diff --git a/includes/classes/legacy/class-maps.php b/includes/classes/legacy/class-maps.php index d6ea76bc..b960c481 100644 --- a/includes/classes/legacy/class-maps.php +++ b/includes/classes/legacy/class-maps.php @@ -230,7 +230,7 @@ public function map_output( $post_id = false, $args = array() ) { $tooltip = $args['search']; if ( 'excerpt' === $args['content'] ) { - $tooltip = strip_tags( get_the_excerpt( $post_id ) ); + $tooltip = wp_strip_all_tags( get_the_excerpt( $post_id ) ); } $icon = $this->set_icon( $post_id ); @@ -257,7 +257,7 @@ public function map_output( $post_id = false, $args = array() ) { $tooltip = $location['address']; if ( 'excerpt' === $args['content'] ) { - $tooltip = strip_tags( get_the_excerpt( $connection ) ); + $tooltip = wp_strip_all_tags( get_the_excerpt( $connection ) ); } $icon = $this->set_icon( $connection ); diff --git a/vendor/cmb2/includes/CMB2.php b/vendor/cmb2/includes/CMB2.php index 33fdc180..961fea3a 100644 --- a/vendor/cmb2/includes/CMB2.php +++ b/vendor/cmb2/includes/CMB2.php @@ -382,7 +382,7 @@ public function box_classes() { foreach ( array_filter( $classes ) as $class ) { foreach ( explode( ' ', $class ) as $_class ) { // Clean up & sanitize. - $split[] = sanitize_html_class( strip_tags( $_class ) ); + $split[] = sanitize_html_class( wp_strip_all_tags( $_class ) ); } } $classes = $split; From 736f34addad608841268ec5664fa3908301ec47b Mon Sep 17 00:00:00 2001 From: Warwick Date: Wed, 11 Dec 2024 15:32:20 +0200 Subject: [PATCH 7/7] Fixing the fail nonce verification warning --- includes/classes/admin/class-admin.php | 1 + includes/classes/admin/class-settings.php | 9 +++++++-- includes/classes/blocks/class-patterns.php | 4 ++-- includes/classes/blocks/class-registration.php | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/includes/classes/admin/class-admin.php b/includes/classes/admin/class-admin.php index 526b7249..ca02c079 100644 --- a/includes/classes/admin/class-admin.php +++ b/includes/classes/admin/class-admin.php @@ -42,6 +42,7 @@ public function allow_svgimg_types( $mimes ) { * feature images */ public function change_attachment_field_button( $html ) { + // @phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['feature_image_text_button'] ) ) { $html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'tour-operator' ) ), $html ); } diff --git a/includes/classes/admin/class-settings.php b/includes/classes/admin/class-settings.php index edf28680..00f6cf02 100644 --- a/includes/classes/admin/class-settings.php +++ b/includes/classes/admin/class-settings.php @@ -45,7 +45,9 @@ class Settings { public function __construct() { $this->options = tour_operator()->options; + // @phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['welcome-page'] ) ) { + // @phpcs:ignore WordPress.Security.NonceVerification.Recommended $display_page = sanitize_text_field( $_GET['welcome-page'] ); $display_page = ! empty( $display_page ) ? $display_page : ''; } @@ -530,8 +532,9 @@ public function save_settings() { if ( 'post_types' !== $section ) { foreach ( $fields as $key => $field ) { $save = ''; + // @phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_POST[ $key ] ) ) { - $save = $_POST[ $key ]; + $save = sanitize_text_field( $_POST[ $key ] ); } else if ( isset( $field['default'] ) ) { $save = $field['default']; } @@ -551,8 +554,9 @@ public function save_settings() { //Loop through each of the fields in the section. foreach ( $fields as $key => $field ) { $save = ''; + // @phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_POST[ $tab_index . '_' . $key ] ) ) { - $save = $_POST[ $tab_index . '_' . $key ]; + $save = wp_unslash( $_POST[ $tab_index . '_' . $key ] ); } else if ( isset( $field['default'] ) ) { $save = $field['default']; } @@ -565,6 +569,7 @@ public function save_settings() { if ( ! empty( $settings_values ) ) { update_option( 'lsx_to_settings', $settings_values ); + // @phpcs:ignore WordPress.Security.NonceVerification.Recommended wp_safe_redirect( $_POST[ '_wp_http_referer' ] ); exit; } diff --git a/includes/classes/blocks/class-patterns.php b/includes/classes/blocks/class-patterns.php index 7221591d..909dcc3b 100644 --- a/includes/classes/blocks/class-patterns.php +++ b/includes/classes/blocks/class-patterns.php @@ -35,7 +35,7 @@ public function __construct() { public function register_block_category( $categories ) { $categories[] = array( 'slug' => $this->category, - 'title' => __( 'Tour Operator', 'lsx-tour-operator' ) + 'title' => __( 'Tour Operator', 'tour-operator' ) ); return $categories; } @@ -48,7 +48,7 @@ public function register_block_category( $categories ) { public function register_block_pattern_category() { register_block_pattern_category( $this->category, - array( 'label' => __( 'Tour Operator', 'lsx-tour-operator' ) ) + array( 'label' => __( 'Tour Operator', 'tour-operator' ) ) ); } diff --git a/includes/classes/blocks/class-registration.php b/includes/classes/blocks/class-registration.php index 97a0ce78..628e1cec 100644 --- a/includes/classes/blocks/class-registration.php +++ b/includes/classes/blocks/class-registration.php @@ -432,7 +432,7 @@ protected function post_ids_exist( $ids ) { AND ID IN (%s) AND post_status IN ('draft', 'publish')"; - // @phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared (the code is prepared) + // @phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared return (int) $wpdb->get_var( $wpdb->prepare( $query, $ids ) ); }