| @@ -7,13 +7,16 @@ | ||
| 7 | 7 | * @author Tobias Bäthge |
| 8 | 8 | * @since 1.0.0 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | +declare(strict_types=1); | |
| 12 | + | |
| 11 | 13 | // Prohibit direct script loading. |
| 12 | 14 | defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); |
| 13 | 15 | |
| 14 | 16 | /** |
| 15 | 17 | * Plugin Options/Save Custom CSS Credentials Form View class |
| 18 | + * | |
| 16 | 19 | * @package TablePress |
| 17 | 20 | * @subpackage Views |
| 18 | 21 | * @author Tobias Bäthge |
| 19 | 22 | * @since 1.0.0 |
| @@ -24,26 +27,28 @@ | ||
| 24 | 27 | * Set up the view with data and do things that are specific for this view. |
| 25 | 28 | * |
| 26 | 29 | * @since 1.0.0 |
| 27 | 30 | * |
| 28 | - * @param string $action Action for this view. | |
| 29 | - * @param array $data Data for this view. | |
| 31 | + * @param string $action Action for this view. | |
| 32 | + * @param array<string, mixed> $data Data for this view. | |
| 30 | 33 | */ |
| 31 | - public function setup( $action, array $data ) { | |
| 34 | + #[\Override] | |
| 35 | + public function setup( /* string */ $action, array $data ) /* : void */ { | |
| 36 | + // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited. | |
| 37 | + | |
| 32 | 38 | // Set action manually here, to get correct page title and nav bar entries. |
| 33 | 39 | $this->action = 'options'; |
| 34 | 40 | $this->data = $data; |
| 35 | 41 | |
| 36 | 42 | // Set page title. |
| 37 | - $GLOBALS['title'] = sprintf( __( '%1$s ‹ %2$s', 'tablepress' ), $this->data['view_actions'][ $this->action ]['page_title'], 'TablePress' ); | |
| 43 | + /* translators: %1$s: Page title, %2$s: Plugin name */ | |
| 44 | + $GLOBALS['title'] = sprintf( __( '%1$s ‹ %2$s', 'tablepress' ), $this->data['view_actions'][ $this->action ]['page_title'], 'TablePress' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited | |
| 38 | 45 | |
| 39 | - $this->add_header_message( '<strong>' . __( 'Attention: Further action is required to save the changes to your “Custom CSS”!', 'tablepress' ) . '</strong>', 'notice-success' ); | |
| 46 | + add_filter( 'admin_footer_text', array( $this, 'add_admin_footer_text' ) ); | |
| 40 | 47 | |
| 41 | - // Admin page helpers, like script/style loading, could be moved to view. | |
| 42 | - $this->admin_page = TablePress::load_class( 'TablePress_Admin_Page', 'class-admin-page-helper.php', 'classes' ); | |
| 43 | - $this->admin_page->enqueue_style( 'common' ); | |
| 48 | + $this->add_header_message( '<strong>' . __( 'Attention: Further action is required to save the changes to your “Custom CSS”!', 'tablepress' ) . '</strong>', 'is-warning notice-warning' ); | |
| 44 | 49 | |
| 45 | - $this->admin_page->add_admin_footer_text(); | |
| 50 | + TablePress::enqueue_style( 'common', array( 'wp-components' ) ); | |
| 46 | 51 | |
| 47 | 52 | $this->add_text_box( 'explanation-text', array( $this, 'textbox_explanation_text' ), 'normal' ); |
| 48 | 53 | $this->add_text_box( 'credentials-form', array( $this, 'textbox_credentials_form' ), 'normal' ); |
| 49 | 54 | $this->add_text_box( 'proceed-no-file-saving', array( $this, 'textbox_proceed_no_file_saving' ), 'submit' ); |
| @@ -53,13 +58,19 @@ | ||
| 53 | 58 | * Render the current view (in this view: without form tag). |
| 54 | 59 | * |
| 55 | 60 | * @since 1.0.0 |
| 56 | 61 | */ |
| 57 | - public function render() { | |
| 62 | + #[\Override] | |
| 63 | + public function render(): void { | |
| 58 | 64 | ?> |
| 59 | 65 | <div id="tablepress-page" class="wrap"> |
| 60 | 66 | <?php |
| 61 | - $this->print_nav_tab_menu(); | |
| 67 | + $this->print_nav_tab_menu(); | |
| 68 | + ?> | |
| 69 | + <div id="tablepress-body"> | |
| 70 | + <hr class="wp-header-end"> | |
| 71 | + <script>document.querySelectorAll('.notice:has(~#tablepress-page)').forEach(e=>document.querySelector('.wp-header-end').after(e));</script> | |
| 72 | + <?php | |
| 62 | 73 | // Print all header messages. |
| 63 | 74 | foreach ( $this->header_messages as $message ) { |
| 64 | 75 | echo $message; |
| 65 | 76 | } |
| @@ -87,11 +98,12 @@ | ||
| 87 | 98 | $this->do_meta_boxes( 'side' ); |
| 88 | 99 | ?> |
| 89 | 100 | </div> |
| 90 | 101 | </div> |
| 91 | - <br class="clear" /> | |
| 102 | + <br class="clear"> | |
| 92 | 103 | </div> |
| 93 | 104 | </div> |
| 105 | + </div> | |
| 94 | 106 | <?php |
| 95 | 107 | } |
| 96 | 108 | |
| 97 | 109 | /** |
| @@ -98,16 +110,19 @@ | ||
| 98 | 110 | * Print the content of the "Explanation" text box. |
| 99 | 111 | * |
| 100 | 112 | * @since 1.0.0 |
| 101 | 113 | * |
| 102 | - * @param array $data Data for this screen. | |
| 103 | - * @param array $box Information about the text box. | |
| 114 | + * @param array<string, mixed> $data Data for this screen. | |
| 115 | + * @param array<string, mixed> $box Information about the text box. | |
| 104 | 116 | */ |
| 105 | - public function textbox_explanation_text( array $data, array $box ) { | |
| 117 | + public function textbox_explanation_text( array $data, array $box ): void { | |
| 106 | 118 | ?> |
| 107 | 119 | <p> |
| 108 | 120 | <?php _e( 'Due to the configuration of your server, TablePress was not able to automatically save your “Custom CSS” to a file.', 'tablepress' ); ?> |
| 109 | - <?php printf( __( 'To try again with the same method that you use for updating plugins or themes, please fill out the “%s” form below.', 'tablepress' ), __( 'Connection Information', 'default' ) ); ?> | |
| 121 | + <?php | |
| 122 | + /* translators: %s: Connection information form label */ | |
| 123 | + printf( __( 'To try again with the same method that you use for updating plugins or themes, please fill out the “%s” form below.', 'tablepress' ), __( 'Connection Information', 'default' ) ); | |
| 124 | + ?> | |
| 110 | 125 | </p> |
| 111 | 126 | <?php |
| 112 | 127 | } |
| 113 | 128 | |
| @@ -115,12 +130,12 @@ | ||
| 115 | 130 | * Print the content of the "Credentials" text box. |
| 116 | 131 | * |
| 117 | 132 | * @since 1.0.0 |
| 118 | 133 | * |
| 119 | - * @param array $data Data for this screen. | |
| 120 | - * @param array $box Information about the text box. | |
| 134 | + * @param array<string, mixed> $data Data for this screen. | |
| 135 | + * @param array<string, mixed> $box Information about the text box. | |
| 121 | 136 | */ |
| 122 | - public function textbox_credentials_form( array $data, array $box ) { | |
| 137 | + public function textbox_credentials_form( array $data, array $box ): void { | |
| 123 | 138 | echo $data['credentials_form']; |
| 124 | 139 | } |
| 125 | 140 | |
| 126 | 141 | /** |
| @@ -127,12 +142,12 @@ | ||
| 127 | 142 | * Print the content of the "Cancel Saving" text box. |
| 128 | 143 | * |
| 129 | 144 | * @since 1.0.0 |
| 130 | 145 | * |
| 131 | - * @param array $data Data for this screen. | |
| 132 | - * @param array $box Information about the text box. | |
| 146 | + * @param array<string, mixed> $data Data for this screen. | |
| 147 | + * @param array<string, mixed> $box Information about the text box. | |
| 133 | 148 | */ |
| 134 | - public function textbox_proceed_no_file_saving( array $data, array $box ) { | |
| 149 | + public function textbox_proceed_no_file_saving( array $data, array $box ): void { | |
| 135 | 150 | ?> |
| 136 | 151 | <h2><?php _e( 'Proceed without saving a file', 'tablepress' ); ?></h2> |
| 137 | 152 | <p> |
| 138 | 153 | <?php _e( 'To proceed without trying to save the “Custom CSS” to a file, click the button below.', 'tablepress' ); ?> |
| @@ -137,9 +152,9 @@ | ||
| 137 | 152 | <p> |
| 138 | 153 | <?php _e( 'To proceed without trying to save the “Custom CSS” to a file, click the button below.', 'tablepress' ); ?> |
| 139 | 154 | <?php _e( 'Your “Custom CSS” will then be loaded inline.', 'tablepress' ); ?> |
| 140 | 155 | </p><p> |
| 141 | - <a href="<?php echo TablePress::url( array( 'action' => 'options', 'message' => 'success_save_error_custom_css' ) ); ?>" class="button button-large"><?php _e( 'Proceed without saving “Custom CSS” to a file', 'tablepress' ); ?></a> | |
| 156 | + <a href="<?php echo TablePress::url( array( 'action' => 'options', 'message' => 'success_save_error_custom_css' ) ); ?>" class="components-button is-secondary"><?php _e( 'Proceed without saving “Custom CSS” to a file', 'tablepress' ); ?></a> | |
| 142 | 157 | </p> |
| 143 | 158 | <?php |
| 144 | 159 | } |
| 145 | 160 | |