| @@ -26,33 +26,30 @@ | ||
| 26 | 26 | * |
| 27 | 27 | * @since 1.0.0 |
| 28 | 28 | * @var array<string, mixed> |
| 29 | 29 | */ |
| 30 | - protected $data = array(); | |
| 30 | + protected array $data = array(); | |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Number of screen columns for post boxes. |
| 34 | 34 | * |
| 35 | 35 | * @since 1.0.0 |
| 36 | - * @var int | |
| 37 | 36 | */ |
| 38 | - protected $screen_columns = 0; | |
| 37 | + protected int $screen_columns = 0; | |
| 39 | 38 | |
| 40 | 39 | /** |
| 41 | 40 | * User action for this screen. |
| 42 | 41 | * |
| 43 | 42 | * @since 1.0.0 |
| 44 | - * @var string | |
| 45 | 43 | */ |
| 46 | - protected $action = ''; | |
| 44 | + protected string $action = ''; | |
| 47 | 45 | |
| 48 | 46 | /** |
| 49 | 47 | * Instance of the Admin Page Helper Class, with necessary functions. |
| 50 | 48 | * |
| 51 | 49 | * @since 1.0.0 |
| 52 | - * @var TablePress_Admin_Page | |
| 53 | 50 | */ |
| 54 | - protected $admin_page; | |
| 51 | + protected \TablePress_Admin_Page $admin_page; | |
| 55 | 52 | |
| 56 | 53 | /** |
| 57 | 54 | * List of text boxes (similar to post boxes, but just with text and without extra functionality). |
| 58 | 55 | * |
| @@ -58,9 +55,9 @@ | ||
| 58 | 55 | * |
| 59 | 56 | * @since 1.0.0 |
| 60 | 57 | * @var array<string, array<string, array<string, mixed>>> |
| 61 | 58 | */ |
| 62 | - protected $textboxes = array(); | |
| 59 | + protected array $textboxes = array(); | |
| 63 | 60 | |
| 64 | 61 | /** |
| 65 | 62 | * List of messages that are to be displayed as boxes below the page title. |
| 66 | 63 | * |
| @@ -66,9 +63,9 @@ | ||
| 66 | 63 | * |
| 67 | 64 | * @since 1.0.0 |
| 68 | 65 | * @var string[] |
| 69 | 66 | */ |
| 70 | - protected $header_messages = array(); | |
| 67 | + protected array $header_messages = array(); | |
| 71 | 68 | |
| 72 | 69 | /** |
| 73 | 70 | * Whether there are post boxes registered for this screen, |
| 74 | 71 | * is automatically set to true, when a meta box is added. |
| @@ -73,11 +70,10 @@ | ||
| 73 | 70 | * Whether there are post boxes registered for this screen, |
| 74 | 71 | * is automatically set to true, when a meta box is added. |
| 75 | 72 | * |
| 76 | 73 | * @since 1.0.0 |
| 77 | - * @var bool | |
| 78 | 74 | */ |
| 79 | - protected $has_meta_boxes = false; | |
| 75 | + protected bool $has_meta_boxes = false; | |
| 80 | 76 | |
| 81 | 77 | /** |
| 82 | 78 | * List of WP feature pointers for this view. |
| 83 | 79 | * |
| @@ -83,9 +79,9 @@ | ||
| 83 | 79 | * |
| 84 | 80 | * @since 1.0.0 |
| 85 | 81 | * @var string[] |
| 86 | 82 | */ |
| 87 | - protected $wp_pointers = array(); | |
| 83 | + protected array $wp_pointers = array(); | |
| 88 | 84 | |
| 89 | 85 | /** |
| 90 | 86 | * Initialize the View class, by setting the correct screen columns and adding help texts. |
| 91 | 87 | * |
| @@ -93,12 +89,12 @@ | ||
| 93 | 89 | */ |
| 94 | 90 | public function __construct() { |
| 95 | 91 | $screen = get_current_screen(); |
| 96 | 92 | if ( 0 !== $this->screen_columns ) { |
| 97 | - $screen->add_option( 'layout_columns', array( 'max' => $this->screen_columns ) ); | |
| 93 | + $screen->add_option( 'layout_columns', array( 'max' => $this->screen_columns ) ); // @phpstan-ignore method.nonObject | |
| 98 | 94 | } |
| 99 | 95 | // Enable two column layout. |
| 100 | - add_filter( "get_user_option_screen_layout_{$screen->id}", array( $this, 'set_current_screen_layout_columns' ) ); | |
| 96 | + add_filter( "get_user_option_screen_layout_{$screen->id}", array( $this, 'set_current_screen_layout_columns' ) ); // @phpstan-ignore property.nonObject | |
| 101 | 97 | |
| 102 | 98 | $common_content = '<p>' . sprintf( __( 'More information about TablePress can be found on the <a href="%1$s">plugin website</a> or on its page in the <a href="%2$s">WordPress Plugin Directory</a>.', 'tablepress' ), 'https://tablepress.org/', 'https://wordpress.org/plugins/tablepress/' ) . '</p>'; |
| 103 | 99 | $common_content .= '<p>' . sprintf( __( 'For technical information, please see the <a href="%s">Documentation</a>.', 'tablepress' ), 'https://tablepress.org/documentation/' ) . ' ' . sprintf( __( 'Common questions are answered in the <a href="%s">FAQ</a>.', 'tablepress' ), 'https://tablepress.org/faq/' ) . '</p>'; |
| 104 | 100 | |
| @@ -110,15 +106,15 @@ | ||
| 110 | 106 | . '</p>'; |
| 111 | 107 | $common_content .= '<p><strong>' . sprintf( __( 'More great features for you and your site’s visitors and priority email support are available with a Premium license plan of TablePress. <a href="%s">Go check them out!</a>', 'tablepress' ), 'https://tablepress.org/premium/?utm_source=plugin&utm_medium=textlink&utm_content=help-tab' ) . '</strong></p>'; |
| 112 | 108 | } |
| 113 | 109 | |
| 114 | - $screen->add_help_tab( array( | |
| 110 | + $screen->add_help_tab( array( // @phpstan-ignore method.nonObject | |
| 115 | 111 | 'id' => 'tablepress-help', // This should be unique for the screen. |
| 116 | 112 | 'title' => __( 'TablePress Help', 'tablepress' ), |
| 117 | 113 | 'content' => '<p>' . $this->help_tab_content() . '</p>' . $common_content, |
| 118 | 114 | ) ); |
| 119 | 115 | // "Sidebar" in the help tab. |
| 120 | - $screen->set_help_sidebar( | |
| 116 | + $screen->set_help_sidebar( // @phpstan-ignore method.nonObject | |
| 121 | 117 | '<p><strong>' . __( 'For more information:', 'tablepress' ) . '</strong></p>' |
| 122 | 118 | . '<p><a href="https://tablepress.org/">TablePress Website</a></p>' |
| 123 | 119 | . '<p><a href="https://tablepress.org/faq/">TablePress FAQ</a></p>' |
| 124 | 120 | . '<p><a href="https://tablepress.org/documentation/">TablePress Documentation</a></p>' |
| @@ -163,9 +159,9 @@ | ||
| 163 | 159 | $GLOBALS['title'] = sprintf( __( '%1$s ‹ %2$s', 'tablepress' ), $this->data['view_actions'][ $this->action ]['page_title'], 'TablePress' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 164 | 160 | |
| 165 | 161 | // Admin page helpers, like script/style loading, could be moved to view. |
| 166 | 162 | $this->admin_page = TablePress::load_class( 'TablePress_Admin_Page', 'class-admin-page-helper.php', 'classes' ); |
| 167 | - $this->admin_page->enqueue_style( 'common' ); | |
| 163 | + $this->admin_page->enqueue_style( 'common', array( 'wp-components' ) ); | |
| 168 | 164 | // RTL styles for the admin interface. |
| 169 | 165 | if ( is_rtl() ) { |
| 170 | 166 | $this->admin_page->enqueue_style( 'common-rtl', array( 'tablepress-common' ) ); |
| 171 | 167 | } |
| @@ -296,9 +292,9 @@ | ||
| 296 | 292 | * @param string $context Context (normal, side, additional) for which registered post meta boxes shall be rendered. |
| 297 | 293 | */ |
| 298 | 294 | protected function do_meta_boxes( string $context ): void { |
| 299 | 295 | if ( $this->has_meta_boxes ) { |
| 300 | - do_meta_boxes( get_current_screen(), $context, $this->data ); // @phpstan-ignore-line | |
| 296 | + do_meta_boxes( get_current_screen(), $context, $this->data ); // @phpstan-ignore argument.type | |
| 301 | 297 | } |
| 302 | 298 | } |
| 303 | 299 | |
| 304 | 300 | /** |
| @@ -342,9 +338,9 @@ | ||
| 342 | 338 | * @param array<string, mixed> $data Data for this screen. |
| 343 | 339 | * @param array<string, mixed> $box Information about the text box. |
| 344 | 340 | */ |
| 345 | 341 | protected function action_field( array $data, array $box ): void { |
| 346 | - echo "<input type=\"hidden\" name=\"action\" value=\"tablepress_{$this->action}\" />\n"; | |
| 342 | + echo "<input type=\"hidden\" name=\"action\" value=\"tablepress_{$this->action}\">\n"; | |
| 347 | 343 | } |
| 348 | 344 | |
| 349 | 345 | /** |
| 350 | 346 | * Render the current view. |
| @@ -357,9 +353,9 @@ | ||
| 357 | 353 | <?php |
| 358 | 354 | $this->print_nav_tab_menu(); |
| 359 | 355 | ?> |
| 360 | 356 | <div id="tablepress-body"> |
| 361 | - <hr class="wp-header-end" /> | |
| 357 | + <hr class="wp-header-end"> | |
| 362 | 358 | <?php |
| 363 | 359 | // Print all header messages. |
| 364 | 360 | foreach ( $this->header_messages as $message ) { |
| 365 | 361 | echo $message; |
| @@ -366,9 +362,9 @@ | ||
| 366 | 362 | } |
| 367 | 363 | // "Import" screen has file upload. |
| 368 | 364 | $enctype = ( 'import' === $this->action ) ? ' enctype="multipart/form-data"' : ''; |
| 369 | 365 | ?> |
| 370 | - <form action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post"<?php echo $enctype; ?>> | |
| 366 | + <form action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post"<?php echo $enctype; ?> id="tablepress-page-form"> | |
| 371 | 367 | <?php |
| 372 | 368 | $this->do_text_boxes( 'header' ); |
| 373 | 369 | $hide_if_no_js = ( in_array( $this->action, array( 'export', 'import' ), true ) ) ? ' class="hide-if-no-js"' : ''; |
| 374 | 370 | ?> |
| @@ -393,9 +389,9 @@ | ||
| 393 | 389 | $this->do_meta_boxes( 'side' ); |
| 394 | 390 | ?> |
| 395 | 391 | </div> |
| 396 | 392 | </div> |
| 397 | - <br class="clear" /> | |
| 393 | + <br class="clear"> | |
| 398 | 394 | </div> |
| 399 | 395 | </form> |
| 400 | 396 | </div> |
| 401 | 397 | </div> |
| @@ -407,27 +403,32 @@ | ||
| 407 | 403 | * |
| 408 | 404 | * @since 1.0.0 |
| 409 | 405 | */ |
| 410 | 406 | protected function print_nav_tab_menu(): void { |
| 407 | + $name = __( 'TablePress', 'tablepress' ); | |
| 408 | + $filename = 'admin/img/tablepress.svg'; | |
| 411 | 409 | ?> |
| 412 | 410 | <div id="tablepress-header" class="header"> |
| 413 | - <h1 class="name"><img src="<?php echo plugins_url( 'admin/img/tablepress-icon.png', TABLEPRESS__FILE__ ); ?>" class="tablepress-icon" alt="<?php esc_attr_e( 'TablePress plugin logo', 'tablepress' ); ?>" /><?php _e( 'TablePress', 'tablepress' ); ?></h1> | |
| 414 | - <?php if ( tb_tp_fs()->is_free_plan() ) : ?> | |
| 411 | + <h1 class="name"> | |
| 412 | + <img src="<?php echo plugins_url( $filename, TABLEPRESS__FILE__ ); ?>" alt="<?php esc_attr_e( 'TablePress plugin logo', 'tablepress' ); ?>"> | |
| 413 | + <span class="screen-reader-text"><?php echo $name; ?></span> | |
| 414 | + </h1> | |
| 415 | + <?php if ( ! TABLEPRESS_IS_PLAYGROUND_PREVIEW && tb_tp_fs()->is_free_plan() ) : ?> | |
| 415 | 416 | <div class="buttons"> |
| 416 | - <?php | |
| 417 | - $timestamp_today = strtotime( 'today' ); | |
| 418 | - if ( strtotime( '2023-11-19' ) < $timestamp_today && $timestamp_today < strtotime( '2023-11-28' ) ) : | |
| 419 | - ?> | |
| 420 | - <a href="https://tablepress.org/premium/?utm_campaign=black-week-2023&utm_source=plugin&utm_medium=button&utm_content=upgrade-button" class="tablepress-button" style="background:linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%);border-color:#ffffff;font-weight:bold;font-size:20px;border-radius:6px;"> | |
| 421 | - <span>Premium: 20% off during Black Week 2023!</span> | |
| 422 | - <span class="dashicons dashicons-arrow-right-alt" /> | |
| 423 | - </a> | |
| 424 | - <?php else : ?> | |
| 425 | - <a href="https://tablepress.org/premium/?utm_source=plugin&utm_medium=button&utm_content=upgrade-button" class="tablepress-button"> | |
| 417 | + <?php | |
| 418 | + $timestamp_today = strtotime( 'today' ); | |
| 419 | + if ( strtotime( '2024-11-24' ) < $timestamp_today && $timestamp_today < strtotime( '2024-12-03' ) ) : | |
| 420 | + ?> | |
| 421 | + <a href="https://tablepress.org/premium/?utm_campaign=black-week-2024&utm_source=plugin&utm_medium=button&utm_content=upgrade-button" class="tablepress-button" style="background:linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%);border-color:#ffffff;font-weight:bold;font-size:20px;border-radius:6px;"> | |
| 422 | + <span>Premium: 20% off during Black Week 2024!</span> | |
| 423 | + <span class="dashicons dashicons-arrow-right-alt" /> | |
| 424 | + </a> | |
| 425 | + <?php else : ?> | |
| 426 | + <a href="<?php echo esc_url( tb_tp_fs()->pricing_url( WP_FS__PERIOD_ANNUALLY, false ) ); ?>" class="tablepress-button"> | |
| 426 | 427 | <span><?php _e( 'Upgrade to Premium', 'tablepress' ); ?></span> |
| 427 | - <span class="dashicons dashicons-arrow-right-alt" /> | |
| 428 | + <span class="dashicons dashicons-arrow-right-alt"></span> | |
| 428 | 429 | </a> |
| 429 | - <?php endif;?> | |
| 430 | + <?php endif; ?> | |
| 430 | 431 | </div> |
| 431 | 432 | <?php endif; ?> |
| 432 | 433 | </div> |
| 433 | 434 | <nav id="tablepress-nav"> |
| @@ -466,13 +467,13 @@ | ||
| 466 | 467 | <h3><em> |
| 467 | 468 | <?php _e( 'Attention: Unfortunately, there is a problem!', 'tablepress' ); ?> |
| 468 | 469 | </em></h3> |
| 469 | 470 | <p style="font-size:14px"> |
| 470 | - <strong><?php _e( 'This screen requires JavaScript. Please enable JavaScript in your browser settings.', 'tablepress' ); ?></strong><br /> | |
| 471 | + <strong><?php _e( 'This screen requires JavaScript. Please enable JavaScript in your browser settings.', 'tablepress' ); ?></strong><br> | |
| 471 | 472 | <?php _e( 'For help, please follow <a href="https://www.enable-javascript.com/">the instructions on how to enable JavaScript in your browser</a>.', 'tablepress' ); ?> |
| 472 | 473 | </p> |
| 473 | 474 | <p> |
| 474 | - <?php echo '<a href="' . TablePress::url( array( 'action' => 'list' ) ) . '">' . __( 'Back to the List of Tables', 'tablepress' ) . '</a>'; ?> | |
| 475 | + <?php echo '<a href="' . esc_url( TablePress::url( array( 'action' => 'list' ) ) ) . '">' . __( 'Back to the List of Tables', 'tablepress' ) . '</a>'; ?> | |
| 475 | 476 | </p> |
| 476 | 477 | </div> |
| 477 | 478 | <?php |
| 478 | 479 | } |
| @@ -477,10 +478,12 @@ | ||
| 477 | 478 | <?php |
| 478 | 479 | } |
| 479 | 480 | |
| 480 | 481 | /** |
| 481 | - * Print a submit button (only done when function is used as a callback for a text box). | |
| 482 | + * Prints a submit button (only done when function is used as a callback for a text box). | |
| 482 | 483 | * |
| 484 | + * This method is soft-deprecated. It's no longer used in TablePress, but e.g. in the "TablePress Debug Extension". | |
| 485 | + * | |
| 483 | 486 | * @since 1.0.0 |
| 484 | 487 | * |
| 485 | 488 | * @param array<string, mixed> $data Data for this screen. |
| 486 | 489 | * @param array<string, mixed> $box Information about the text box. |
| @@ -485,11 +488,10 @@ | ||
| 485 | 488 | * @param array<string, mixed> $data Data for this screen. |
| 486 | 489 | * @param array<string, mixed> $box Information about the text box. |
| 487 | 490 | */ |
| 488 | 491 | protected function textbox_submit_button( array $data, array $box ): void { |
| 489 | - $caption = $data['submit_button_caption'] ?? __( 'Save Changes', 'tablepress' ); | |
| 490 | 492 | ?> |
| 491 | - <p class="submit"><input type="submit" value="<?php echo esc_attr( $caption ); ?>" class="button button-primary button-large" /></p> | |
| 493 | + <p class="submit"><input type="submit" class="components-button is-primary button-save-changes" value="<?php esc_attr_e( 'Save Changes', 'tablepress' ); ?>"></p> | |
| 492 | 494 | <?php |
| 493 | 495 | } |
| 494 | 496 | |
| 495 | 497 | /** |
| @@ -522,9 +524,9 @@ | ||
| 522 | 524 | |
| 523 | 525 | $pointers_on_page = false; |
| 524 | 526 | foreach ( array_diff( $this->wp_pointers, $dismissed ) as $pointer ) { |
| 525 | 527 | // Bind pointer print function. |
| 526 | - add_action( "admin_footer-{$GLOBALS['hook_suffix']}", array( $this, 'wp_pointer_' . $pointer ) ); // @phpstan-ignore-line | |
| 528 | + add_action( "admin_footer-{$GLOBALS['hook_suffix']}", array( $this, 'wp_pointer_' . $pointer ) ); // @phpstan-ignore argument.type | |
| 527 | 529 | $pointers_on_page = true; |
| 528 | 530 | } |
| 529 | 531 | |
| 530 | 532 | if ( $pointers_on_page ) { |