| @@ -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 | /** |
| @@ -407,17 +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> | |
| 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> | |
| 414 | 415 | <?php if ( ! TABLEPRESS_IS_PLAYGROUND_PREVIEW && tb_tp_fs()->is_free_plan() ) : ?> |
| 415 | 416 | <div class="buttons"> |
| 416 | - <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"> | |
| 417 | 427 | <span><?php _e( 'Upgrade to Premium', 'tablepress' ); ?></span> |
| 418 | 428 | <span class="dashicons dashicons-arrow-right-alt"></span> |
| 419 | 429 | </a> |
| 430 | + <?php endif; ?> | |
| 420 | 431 | </div> |
| 421 | 432 | <?php endif; ?> |
| 422 | 433 | </div> |
| 423 | 434 | <nav id="tablepress-nav"> |
| @@ -467,10 +478,12 @@ | ||
| 467 | 478 | <?php |
| 468 | 479 | } |
| 469 | 480 | |
| 470 | 481 | /** |
| 471 | - * 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). | |
| 472 | 483 | * |
| 484 | + * This method is soft-deprecated. It's no longer used in TablePress, but e.g. in the "TablePress Debug Extension". | |
| 485 | + * | |
| 473 | 486 | * @since 1.0.0 |
| 474 | 487 | * |
| 475 | 488 | * @param array<string, mixed> $data Data for this screen. |
| 476 | 489 | * @param array<string, mixed> $box Information about the text box. |
| @@ -475,11 +488,10 @@ | ||
| 475 | 488 | * @param array<string, mixed> $data Data for this screen. |
| 476 | 489 | * @param array<string, mixed> $box Information about the text box. |
| 477 | 490 | */ |
| 478 | 491 | protected function textbox_submit_button( array $data, array $box ): void { |
| 479 | - $caption = $data['submit_button_caption'] ?? __( 'Save Changes', 'tablepress' ); | |
| 480 | 492 | ?> |
| 481 | - <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> | |
| 482 | 494 | <?php |
| 483 | 495 | } |
| 484 | 496 | |
| 485 | 497 | /** |
| @@ -512,9 +524,9 @@ | ||
| 512 | 524 | |
| 513 | 525 | $pointers_on_page = false; |
| 514 | 526 | foreach ( array_diff( $this->wp_pointers, $dismissed ) as $pointer ) { |
| 515 | 527 | // Bind pointer print function. |
| 516 | - 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 | |
| 517 | 529 | $pointers_on_page = true; |
| 518 | 530 | } |
| 519 | 531 | |
| 520 | 532 | if ( $pointers_on_page ) { |