Skip to content

Commit

Permalink
Fixing the fail nonce verification warning
Browse files Browse the repository at this point in the history
  • Loading branch information
krugazul committed Dec 11, 2024
1 parent 5b25d2e commit 736f34a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
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
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
2 changes: 1 addition & 1 deletion includes/classes/blocks/class-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}

Expand Down

0 comments on commit 736f34a

Please sign in to comment.