← All changes
|
WPDataProjects/Parent_Child/WPDP_Parent_Form.php
+28
-26
5.5.76
→
5.5.85
View file →
| @@ -130,21 +130,21 @@ | ||
| 130 | 130 | ) { |
| 131 | 131 | if ( isset( $args['mode'] ) ) { |
| 132 | 132 | $this->mode = $args['mode']; |
| 133 | 133 | } else { |
| 134 | - wp_die( __( 'ERROR: Wrong arguments [missing mode]', 'wp-data-access' ) ); | |
| 134 | + wp_die( esc_attr__( 'ERROR: Wrong arguments [missing mode]', 'wp-data-access' ) ); | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | if ( isset( $args['child_request'] ) ) { |
| 138 | 138 | $this->child_request = $args['child_request']; |
| 139 | 139 | } else { |
| 140 | - wp_die( __( 'ERROR: Wrong arguments [missing child_request]', 'wp-data-access' ) ); | |
| 140 | + wp_die( esc_attr__( 'ERROR: Wrong arguments [missing child_request]', 'wp-data-access' ) ); | |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $action = null; |
| 144 | - if ( isset( $_REQUEST['action'] ) ) { | |
| 144 | + if ( isset( $_REQUEST['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- already verified | |
| 145 | 145 | // Possible values: "new", "edit" and "view". |
| 146 | - $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); // input var okay. | |
| 146 | + $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- already verified | |
| 147 | 147 | $this->action_posted = $action; |
| 148 | 148 | } elseif ( isset( $args['action'] ) ) { |
| 149 | 149 | $action = $args['action']; |
| 150 | 150 | $this->action_posted = $action; |
| @@ -157,14 +157,15 @@ | ||
| 157 | 157 | parent::__construct( $schema_name, $table_name, $wpda_list_columns, $args ); |
| 158 | 158 | |
| 159 | 159 | if ( 'new' !== $action || $this->child_request ) { |
| 160 | 160 | if ( isset( $this->relations['parent']['key'] ) && is_array( $this->relations['parent']['key'] ) ) { |
| 161 | + // phpcs:disable WordPress.Security.NonceVerification.Recommended -- already verified | |
| 161 | 162 | foreach ( $this->relations['parent']['key'] as $key ) { |
| 162 | 163 | if ( isset( $_REQUEST[ 'WPDA_PARENT_KEY*' . $key ] ) ) { |
| 163 | - array_push( $this->parent_key, $key );//phpcs:ignore - 8.1 proof | |
| 164 | + array_push( $this->parent_key, $key ); // phpcs:ignore -- 8.1 proof | |
| 164 | 165 | $this->parent_key_value[ $key ] = sanitize_text_field( wp_unslash( $_REQUEST[ 'WPDA_PARENT_KEY*' . $key ] ) ); // input var okay. |
| 165 | 166 | } elseif ( isset( $_REQUEST[ $key ] ) ) { |
| 166 | - array_push( $this->parent_key, $key );//phpcs:ignore - 8.1 proof | |
| 167 | + array_push( $this->parent_key, $key ); // phpcs:ignore -- 8.1 proof | |
| 167 | 168 | $this->parent_key_value[ $key ] = sanitize_text_field( wp_unslash( $_REQUEST[ $key ] ) ); // input var okay. |
| 168 | 169 | } |
| 169 | 170 | |
| 170 | 171 | if ( is_array( $this->relations['children'] ) ) { |
| @@ -170,8 +171,9 @@ | ||
| 170 | 171 | if ( is_array( $this->relations['children'] ) ) { |
| 171 | 172 | $this->children = $this->relations['children']; |
| 172 | 173 | } |
| 173 | 174 | } |
| 175 | + // phpcs:enable WordPress.Security.NonceVerification.Recommended | |
| 174 | 176 | } |
| 175 | 177 | } |
| 176 | 178 | |
| 177 | 179 | $this->set_child_action_member(); |
| @@ -199,11 +201,11 @@ | ||
| 199 | 201 | $this->relations[ $child['table_name'] ]['relation_1n'] = $child['relation_1n']; |
| 200 | 202 | } |
| 201 | 203 | } |
| 202 | 204 | |
| 203 | - if ( isset( $_REQUEST['child_tab'] ) ) { | |
| 204 | - if ( isset( $this->tabs[ $_REQUEST['child_tab'] ] ) ) { | |
| 205 | - $this->current_tab = sanitize_text_field( wp_unslash( $_REQUEST['child_tab'] ) ); // input var okay. | |
| 205 | + if ( isset( $_REQUEST['child_tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- verified in parent class | |
| 206 | + if ( isset( $this->tabs[ $_REQUEST['child_tab'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- verified in parent class | |
| 207 | + $this->current_tab = sanitize_text_field( wp_unslash( $_REQUEST['child_tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- verified in parent class | |
| 206 | 208 | } |
| 207 | 209 | } |
| 208 | 210 | |
| 209 | 211 | if ( isset( $args['edit_form_class'] ) ) { |
| @@ -266,9 +268,9 @@ | ||
| 266 | 268 | if ( 'new' === $this->action_posted && 'edit' === parent::get_form_action() ) { |
| 267 | 269 | // Record successfully inserted: reload page to show tabs |
| 268 | 270 | ?> |
| 269 | 271 | <script> |
| 270 | - jQuery("#wpda_simple_form_0 input[name='wpda_message']").val("<?php echo __( 'Succesfully saved changes to database', 'wp-data-access' ); ?>"); | |
| 272 | + jQuery("#wpda_simple_form_0 input[name='wpda_message']").val("<?php esc_html_e( 'Succesfully saved changes to database', 'wp-data-access' ); ?>"); | |
| 271 | 273 | jQuery("#wpda_simple_form_0").submit(); |
| 272 | 274 | </script> |
| 273 | 275 | <?php |
| 274 | 276 | } |
| @@ -293,9 +295,9 @@ | ||
| 293 | 295 | protected function show_child_form( $child_table_name, $child ) { |
| 294 | 296 | if ( |
| 295 | 297 | 'edit' === $this->mode && |
| 296 | 298 | ( 'new' === $this->child_action || 'edit' === $this->child_action ) && |
| 297 | - ( ! ( isset( $_POST['postaction'] ) && 'childlist' === $_POST['postaction'] ) ) | |
| 299 | + ( ! ( isset( $_POST['postaction'] ) && 'childlist' === $_POST['postaction'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing -- verified in parent class | |
| 298 | 300 | ) { |
| 299 | 301 | $this->button_add_new( $child, $child_table_name ); |
| 300 | 302 | echo '<div style="clear:both;"></div>'; |
| 301 | 303 | } |
| @@ -318,9 +320,9 @@ | ||
| 318 | 320 | ); |
| 319 | 321 | |
| 320 | 322 | $wpda_child_form->prepare_form(); |
| 321 | 323 | |
| 322 | - if ( isset( $_POST['postaction'] ) && 'childlist' === $_POST['postaction'] ) { | |
| 324 | + if ( isset( $_POST['postaction'] ) && 'childlist' === $_POST['postaction'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- verified in parent class | |
| 323 | 325 | $this->show_child_list_table( $child_table_name, $child ); |
| 324 | 326 | } else { |
| 325 | 327 | $wpda_child_form->show(); |
| 326 | 328 | } |
| @@ -332,9 +334,9 @@ | ||
| 332 | 334 | * @param string $child_table_name Database table name |
| 333 | 335 | * @param array $child Child info |
| 334 | 336 | */ |
| 335 | 337 | protected function show_child_list_table( $child_table_name, $child ) { |
| 336 | - $is_list_table_selection = isset( $_REQUEST['list_table_selection'] ); | |
| 338 | + $is_list_table_selection = isset( $_REQUEST['list_table_selection'] ); // phpcs:ignore -- verified in parent class | |
| 337 | 339 | if ( 'edit' === $this->mode ) { |
| 338 | 340 | $this->button_add_new( $child, $child_table_name ); |
| 339 | 341 | } |
| 340 | 342 | if ( $is_list_table_selection || 'add' === $this->child_action || 'bulk-add' === $this->child_action ) { |
| @@ -365,15 +367,15 @@ | ||
| 365 | 367 | /** |
| 366 | 368 | * Add a tab for every child |
| 367 | 369 | */ |
| 368 | 370 | protected function add_tabs() { |
| 369 | - if ( count( $this->children ) > 0 ) {//phpcs:ignore - 8.1 proof | |
| 371 | + if ( count( $this->children ) > 0 ) { // phpcs:ignore -- 8.1 proof | |
| 370 | 372 | ?> |
| 371 | 373 | <h2 class="nav-tab-wrapper"> |
| 372 | 374 | <?php |
| 373 | 375 | $requested_page_number = 1; |
| 374 | - if ( isset( $_REQUEST['page_number'] ) ) { | |
| 375 | - $requested_page_number = sanitize_text_field( wp_unslash( $_REQUEST['page_number'] ) ); // input var okay. | |
| 376 | + if ( isset( $_REQUEST['page_number'] ) ) { // phpcs:ignore -- verified in parent class | |
| 377 | + $requested_page_number = sanitize_text_field( wp_unslash( $_REQUEST['page_number'] ) ); // phpcs:ignore -- verified in parent class | |
| 376 | 378 | } |
| 377 | 379 | foreach ( $this->tabs as $tab => $name ) { |
| 378 | 380 | $class = ( $tab === $this->current_tab ) ? ' nav-tab-active' : ''; |
| 379 | 381 | $id_from_name = preg_replace( '/[^a-zA-Z0-9]/', '', $name ); |
| @@ -414,10 +416,10 @@ | ||
| 414 | 416 | * Add parent args to child request |
| 415 | 417 | */ |
| 416 | 418 | protected function add_parent_args() { |
| 417 | 419 | $child_tab = ''; |
| 418 | - if ( isset( $_REQUEST['child_tab'] ) ) { | |
| 419 | - $child_tab = sanitize_text_field( wp_unslash( $_REQUEST['child_tab'] ) ); // input var okay. | |
| 420 | + if ( isset( $_REQUEST['child_tab'] ) ) { // phpcs:ignore -- verified in parent class | |
| 421 | + $child_tab = sanitize_text_field( wp_unslash( $_REQUEST['child_tab'] ) ); // phpcs:ignore -- verified in parent class | |
| 420 | 422 | } |
| 421 | 423 | ?> |
| 422 | 424 | <input type='hidden' name='child_tab' value='<?php echo esc_attr( $child_tab ); ?>'/> |
| 423 | 425 | <?php |
| @@ -432,10 +434,10 @@ | ||
| 432 | 434 | |
| 433 | 435 | // When we are coming from a child we'll need to get our parent key |
| 434 | 436 | if ( isset( $this->relations['parent']['key'] ) && is_array( $this->relations['parent']['key'] ) ) { |
| 435 | 437 | foreach ( $this->relations['parent']['key'] as $key ) { |
| 436 | - if ( isset( $_REQUEST[ 'WPDA_PARENT_KEY*' . $key ] ) ) { | |
| 437 | - $this->form_items_new_values[ $key ] = sanitize_text_field( wp_unslash( $_REQUEST[ 'WPDA_PARENT_KEY*' . $key ] ) ); // input var okay. | |
| 438 | + if ( isset( $_REQUEST[ 'WPDA_PARENT_KEY*' . $key ] ) ) { // phpcs:ignore -- verified in parent class | |
| 439 | + $this->form_items_new_values[ $key ] = sanitize_text_field( wp_unslash( $_REQUEST[ 'WPDA_PARENT_KEY*' . $key ] ) ); // phpcs:ignore -- verified in parent class | |
| 438 | 440 | } |
| 439 | 441 | } |
| 440 | 442 | } |
| 441 | 443 | } |
| @@ -471,9 +473,9 @@ | ||
| 471 | 473 | <input type="hidden" name="child_tab" value="<?php echo esc_attr( $child_table_name ); ?>"> |
| 472 | 474 | <input type="hidden" name="action" value="new"> |
| 473 | 475 | <button type="submit" class="button wpda_tooltip" title="<?php echo esc_attr( $title ); ?>"> |
| 474 | 476 | <i class="fas fa-plus-circle wpda_icon_on_button"></i> |
| 475 | - <?php echo __( 'Add New', 'wp-data-access' ); ?> | |
| 477 | + <?php esc_html_e( 'Add New', 'wp-data-access' ); ?> | |
| 476 | 478 | </button> |
| 477 | 479 | </form> |
| 478 | 480 | <?php |
| 479 | 481 | } |
| @@ -493,9 +495,9 @@ | ||
| 493 | 495 | <button type="submit" class="button wpda_tooltip" |
| 494 | 496 | title="Add existing row" |
| 495 | 497 | > |
| 496 | 498 | <i class="fas fa-plus-circle wpda_icon_on_button"></i> |
| 497 | - <?php echo __( 'Add Existing', 'wp-data-access' ); ?> | |
| 499 | + <?php esc_html_e( 'Add Existing', 'wp-data-access' ); ?> | |
| 498 | 500 | </button> |
| 499 | 501 | </form> |
| 500 | 502 | <?php |
| 501 | 503 | } |
| @@ -522,9 +524,9 @@ | ||
| 522 | 524 | public function add_form_logic() { |
| 523 | 525 | if ( 'new' !== $this->action_posted || $this->child_request ) { |
| 524 | 526 | ?> |
| 525 | 527 | <input type="button" |
| 526 | - value="<?php echo __( 'show more', 'wp-data-access' ); ?> >>>" | |
| 528 | + value="<?php esc_html_e( 'show more', 'wp-data-access' ); ?> >>>" | |
| 527 | 529 | class="button" |
| 528 | 530 | id="show_more_less_button" |
| 529 | 531 | style="float:right;display:none;"> |
| 530 | 532 | <script type='text/javascript'> |
| @@ -529,12 +531,12 @@ | ||
| 529 | 531 | style="float:right;display:none;"> |
| 530 | 532 | <script type='text/javascript'> |
| 531 | 533 | function show_more_less() { |
| 532 | 534 | jQuery('.row-show-less-more').toggle(); |
| 533 | - if (jQuery('#show_more_less_button').val() === '<?php echo __( 'show more', 'wp-data-access' ); ?> >>>') { | |
| 534 | - jQuery('#show_more_less_button').val('<<< <?php echo __( 'show less', 'wp-data-access' ); ?>'); | |
| 535 | + if (jQuery('#show_more_less_button').val() === '<?php esc_html_e( 'show more', 'wp-data-access' ); ?> >>>') { | |
| 536 | + jQuery('#show_more_less_button').val('<<< <?php esc_html_e( 'show less', 'wp-data-access' ); ?>'); | |
| 535 | 537 | } else { |
| 536 | - jQuery('#show_more_less_button').val('<?php echo __( 'show more', 'wp-data-access' ); ?> >>>'); | |
| 538 | + jQuery('#show_more_less_button').val('<?php esc_html_e( 'show more', 'wp-data-access' ); ?> >>>'); | |
| 537 | 539 | } |
| 538 | 540 | } |
| 539 | 541 | |
| 540 | 542 | if (jQuery('.row-show-less-more').length > 0) { |