Skip to content

Commit

Permalink
Merge pull request #456 from lightspeedwp/2.0-code-cleanup
Browse files Browse the repository at this point in the history
2.0 code cleanup
  • Loading branch information
Justinabes007 authored Dec 11, 2024
2 parents 0351ad9 + 736f34a commit b19e63e
Show file tree
Hide file tree
Showing 30 changed files with 157 additions and 2,876 deletions.
Binary file not shown.
1 change: 1 addition & 0 deletions includes/classes/admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
9 changes: 7 additions & 2 deletions includes/classes/admin/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 : '';
}
Expand Down Expand Up @@ -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'];
}
Expand All @@ -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'];
}
Expand All @@ -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;
}
Expand Down
14 changes: 7 additions & 7 deletions includes/classes/blocks/class-bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,47 +77,47 @@ 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' )
)
);

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' )
)
);

register_block_bindings_source(
'lsx/tour-itinerary',
array(
'label' => __( 'Itinerary', 'lsx-wetu-importer' ),
'label' => __( 'Itinerary', 'tour-operator' ),
'get_value_callback' => array( $this, 'empty_callback' )
)
);

register_block_bindings_source(
'lsx/accommodation-units',
array(
'label' => __( 'Units', 'lsx-wetu-importer' ),
'label' => __( 'Units', 'tour-operator' ),
'get_value_callback' => array( $this, 'empty_callback' )
)
);

register_block_bindings_source(
'lsx/gallery',
array(
'label' => __( 'Gallery', 'lsx-wetu-importer' ),
'label' => __( 'Gallery', 'tour-operator' ),
'get_value_callback' => array( $this, 'empty_callback' )
)
);

register_block_bindings_source(
'lsx/map',
array(
'label' => __( 'Map', 'lsx-wetu-importer' ),
'label' => __( 'Map', 'tour-operator' ),
'get_value_callback' => array( $this, 'empty_callback' )
)
);
Expand Down Expand Up @@ -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 = '/(<h[1-6]\s+[^>]*\bclass="[^"]*\bunit-title\b[^"]*"[^>]*>).*?(<\/h[1-6]>)/is';
break;

Expand Down
4 changes: 2 additions & 2 deletions includes/classes/blocks/class-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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' ) )
);
}

Expand Down
1 change: 1 addition & 0 deletions includes/classes/blocks/class-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
return (int) $wpdb->get_var( $wpdb->prepare( $query, $ids ) );
}

Expand Down
79 changes: 0 additions & 79 deletions includes/classes/class-metaboxes.php

This file was deleted.

100 changes: 0 additions & 100 deletions includes/classes/class-share.php

This file was deleted.

18 changes: 0 additions & 18 deletions includes/classes/legacy/class-accommodation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}

/**
Expand All @@ -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
*/
Expand Down
Loading

0 comments on commit b19e63e

Please sign in to comment.