PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
← All changes | views/view-options.php +75 -56 2.1.8 → 3.4 View file →
@@ -7,8 +7,10 @@
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 /**
@@ -25,20 +27,19 @@
25 27 * Set up the view with data and do things that are specific for this view.
26 28 *
27 29 * @since 1.0.0
28 30 *
29 - * @param string $action Action for this view.
30 - * @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.
31 33 */
32 - public function setup( $action, array $data ) {
33 - if ( current_user_can( 'tablepress_edit_options' ) ) {
34 - // Register the feature pointer "Custom CSS" textarea, before running `parent::setup();`. This is done here as the target HTML element does not exist for all users.
35 - $this->wp_pointers[] = 'tp20_options_custom_css_css_variables';
36 - }
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 37
38 38 parent::setup( $action, $data );
39 39
40 - $this->admin_page->enqueue_script( 'options' );
40 + TablePress::enqueue_script( 'common', array( 'jquery-core', 'postbox' ) );
41 + TablePress::enqueue_script( 'options' );
41 42
42 43 $this->process_action_messages( array(
43 44 'success_save' => __( 'Options saved successfully.', 'tablepress' ),
44 45 'success_save_error_custom_css' => __( 'Options saved successfully, but &#8220;Custom CSS&#8221; was not saved to file.', 'tablepress' ),
@@ -50,13 +51,17 @@
50 51 // Enqueue WordPress copy of CodeMirror, with CSS linting, etc., for the "Custom CSS" textarea, which is only shown to admins.
51 52 $codemirror_settings = wp_enqueue_code_editor( array( 'type' => 'text/css' ) );
52 53 if ( ! empty( $codemirror_settings ) ) {
53 54 // Load CSS adjustments for CodeMirror and the added vertical resizing.
54 - $this->admin_page->enqueue_style( 'codemirror', array( 'code-editor' ) );
55 - $this->admin_page->enqueue_script( 'codemirror' );
55 + TablePress::enqueue_style( 'codemirror', array( 'code-editor' ) );
56 + TablePress::enqueue_script( 'codemirror' );
56 57 }
57 58
58 - $this->add_meta_box( 'frontend-options', __( 'Frontend Options and Styling', 'tablepress' ), array( $this, 'postbox_frontend_options' ), 'normal' );
59 + if ( ! TABLEPRESS_IS_PLAYGROUND_PREVIEW ) {
60 + /* translators: %s: Premium badge HTML or empty string */
61 + $this->add_meta_box( 'default-style', sprintf( __( 'Default Styling %s', 'tablepress' ), tb_tp_fs()->is_free_plan() ? '<span class="pill-label">' . __( 'Premium', 'tablepress' ) . '</span>' : '' ), array( $this, 'postbox_default_style_customizer_screen' ), 'normal' );
62 + }
63 + $this->add_meta_box( 'frontend-options', __( 'Custom Styling', 'tablepress' ), array( $this, 'postbox_frontend_options' ), 'normal' );
59 64 }
60 65 $this->add_meta_box( 'user-options', __( 'User Options', 'tablepress' ), array( $this, 'postbox_user_options' ), 'normal' );
61 66 $this->add_text_box( 'submit', array( $this, 'textbox_submit_button' ), 'submit' );
62 67 if ( current_user_can( 'deactivate_plugin', TABLEPRESS_BASENAME ) && current_user_can( 'tablepress_edit_options' ) && current_user_can( 'tablepress_delete_tables' ) && ! is_plugin_active_for_network( TABLEPRESS_BASENAME ) ) {
@@ -64,16 +69,16 @@
64 69 }
65 70 }
66 71
67 72 /**
68 - * Print the screen head text.
73 + * Prints the screen head text.
69 74 *
70 75 * @since 1.0.0
71 76 *
72 - * @param array $data Data for this screen.
73 - * @param array $box Information about the text box.
77 + * @param array<string, mixed> $data Data for this screen.
78 + * @param array<string, mixed> $box Information about the text box.
74 79 */
75 - public function textbox_head( array $data, array $box ) {
80 + public function textbox_head( array $data, array $box ): void {
76 81 ?>
77 82 <p>
78 83 <?php _e( 'TablePress has some options which affect the plugin&#8217;s behavior in different areas.', 'tablepress' ); ?>
79 84 </p>
@@ -80,21 +85,53 @@
80 85 <?php
81 86 }
82 87
83 88 /**
84 - * Print the content of the "Frontend Options" post meta box.
89 + * Prints the content of the "Default Style Customizer Screen" post meta box.
85 90 *
91 + * @since 2.2.0
92 + *
93 + * @param array<string, mixed> $data Data for this screen.
94 + * @param array<string, mixed> $box Information about the meta box.
95 + */
96 + public function postbox_default_style_customizer_screen( array $data, array $box ): void {
97 + if ( tb_tp_fs()->is_free_plan() ) :
98 + ?>
99 + <div style="display:flex;max-width:800px;gap:20px;font-size:14px;">
100 + <div>
101 + <p style="font-size:14px;">
102 + <strong><?php _e( 'Did you know?', 'tablepress' ); ?></strong>
103 + <?php _e( 'The TablePress premium versions come with a table default style customizer!', 'tablepress' ); ?>
104 + <?php _e( 'Choose from multiple style variations or define your own color scheme in an easy-to-use visual tool!', 'tablepress' ); ?>
105 + <strong><?php _e( 'Change your tables’ default style without touching CSS code!', 'tablepress' ); ?></strong>
106 + </p>
107 + <div class="buttons" style="text-align:center;">
108 + <a href="https://tablepress.org/modules/default-style-customizer/?utm_source=plugin&utm_medium=textlink&utm_content=options-screen" class="tablepress-button">
109 + <span><?php _e( 'Find out more', 'tablepress' ); ?></span>
110 + <span class="dashicons dashicons-arrow-right-alt"></span>
111 + </a>
112 + </div>
113 + </div>
114 + <a href="https://tablepress.org/modules/default-style-customizer/?utm_source=plugin&utm_medium=textlink&utm_content=options-screen"><img src="<?php echo esc_url( plugins_url( 'admin/img/default-style-customizer.png', TABLEPRESS__FILE__ ) ); ?>" width="305" height="172" alt="<?php esc_attr_e( 'Screenshot of the Default Style Customizer that is part of the TablePress premium versions.', 'tablepress' ); ?>"></a>
115 + </div>
116 + <?php
117 + endif;
118 + }
119 +
120 + /**
121 + * Prints the content of the "Frontend Options" post meta box.
122 + *
86 123 * @since 1.0.0
87 124 *
88 - * @param array $data Data for this screen.
89 - * @param array $box Information about the meta box.
125 + * @param array<string, mixed> $data Data for this screen.
126 + * @param array<string, mixed> $box Information about the meta box.
90 127 */
91 - public function postbox_frontend_options( array $data, array $box ) {
128 + public function postbox_frontend_options( array $data, array $box ): void {
92 129 ?>
93 130 <table class="tablepress-postbox-table fixed">
94 131 <tr>
95 132 <th class="column-1" scope="row"><label for="option-custom-css"><?php _e( 'Custom CSS', 'tablepress' ); ?></label>:</th>
96 - <td class="column-2"><label for="option-use-custom-css"><input type="checkbox" id="option-use-custom-css" name="options[use_custom_css]" value="true"<?php checked( $data['frontend_options']['use_custom_css'] ); ?> /> <?php _e( 'Load this &#8220;Custom CSS&#8221; code to change the table styling:', 'tablepress' ); ?></label>
133 + <td class="column-2"><label><input type="checkbox" id="option-use-custom-css" name="options[use_custom_css]" value="true"<?php checked( $data['frontend_options']['use_custom_css'] ); ?>> <?php _e( 'Load this &#8220;Custom CSS&#8221; code to change the table styling:', 'tablepress' ); ?></label>
97 134 </td>
98 135 </tr>
99 136 <tr>
100 137 <td class="column-1"></td>
@@ -117,20 +154,20 @@
117 154 <?php
118 155 }
119 156
120 157 /**
121 - * Print the content of the "User Options" post meta box.
158 + * Prints the content of the "User Options" post meta box.
122 159 *
123 160 * @since 1.0.0
124 161 *
125 - * @param array $data Data for this screen.
126 - * @param array $box Information about the meta box.
162 + * @param array<string, mixed> $data Data for this screen.
163 + * @param array<string, mixed> $box Information about the meta box.
127 164 */
128 - public function postbox_user_options( array $data, array $box ) {
165 + public function postbox_user_options( array $data, array $box ): void {
129 166 // Get list of current admin menu entries.
130 167 $entries = array();
131 168 foreach ( $GLOBALS['menu'] as $entry ) {
132 - if ( false !== strpos( $entry[2], '.php' ) ) {
169 + if ( str_contains( $entry[2], '.php' ) ) {
133 170 $entries[ $entry[2] ] = $entry[0];
134 171 }
135 172 }
136 173
@@ -167,58 +204,40 @@
167 204 * Prints "Save Changes" button.
168 205 *
169 206 * @since 2.2.0
170 207 *
171 - * @param array $data Data for this screen.
172 - * @param array $box Information about the text box.
208 + * @param array<string, mixed> $data Data for this screen.
209 + * @param array<string, mixed> $box Information about the text box.
173 210 */
174 - public function textbox_submit_button( array $data, array $box ) {
211 + #[\Override]
212 + public function textbox_submit_button( array $data, array $box ): void {
175 213 ?>
176 214 <p class="submit">
177 - <input type="submit" id="tablepress-options-save-changes" class="button button-primary button-large button-save-changes" value="<?php esc_attr_e( 'Save Changes', 'tablepress' ); ?>" data-shortcut="<?php echo esc_attr( _x( '%1$sS', 'keyboard shortcut for Save Changes', 'tablepress' ) ); ?>" />
215 + <input type="submit" id="tablepress-options-save-changes" class="components-button is-primary button-save-changes" value="<?php esc_attr_e( 'Save Changes', 'tablepress' ); ?>" data-shortcut="<?php echo esc_attr( _x( '%1$sS', 'keyboard shortcut for Save Changes', 'tablepress' ) ); ?>">
178 216 </p>
179 217 <?php
180 218 }
181 219
182 220 /**
183 - * Print the content of the "Admin Options" post meta box.
221 + * Prints the content of the "Admin Options" post meta box.
184 222 *
185 223 * @since 1.0.0
186 224 *
187 - * @param array $data Data for this screen.
188 - * @param array $box Information about the text box.
225 + * @param array<string, mixed> $data Data for this screen.
226 + * @param array<string, mixed> $box Information about the text box.
189 227 */
190 - public function textbox_uninstall_tablepress( array $data, array $box ) {
228 + public function textbox_uninstall_tablepress( array $data, array $box ): void {
191 229 ?>
192 230 <h1 style="margin-top:40px;"><?php _e( 'Uninstall TablePress', 'tablepress' ); ?></h1>
193 231 <p>
194 232 <?php
195 - echo __( 'Uninstalling <strong>will permanently delete</strong> all TablePress tables and options from the database.', 'tablepress' ) . '<br />'
196 - . __( 'It is recommended that you create a backup of the tables (by exporting the tables in the JSON format), in case you later change your mind.', 'tablepress' ) . '<br />'
197 - . __( 'You will manually need to remove the plugin&#8217;s files from the plugin folder afterwards.', 'tablepress' ) . '<br />'
233 + echo __( 'Uninstalling <strong>will permanently delete</strong> all TablePress tables and options from the database.', 'tablepress' ) . '<br>'
234 + . __( 'It is recommended that you create a backup of the tables (by exporting the tables in the JSON format), in case you later change your mind.', 'tablepress' ) . '<br>'
235 + . __( 'You will manually need to remove the plugin&#8217;s files from the plugin folder afterwards.', 'tablepress' ) . '<br>'
198 236 . __( 'Be very careful with this and only click the button if you know what you are doing!', 'tablepress' );
199 237 ?>
200 238 </p>
201 - <p><a href="<?php echo TablePress::url( array( 'action' => 'uninstall_tablepress' ), true, 'admin-post.php' ); ?>" id="uninstall-tablepress" class="button"><?php _e( 'Uninstall TablePress', 'tablepress' ); ?></a></p>
239 + <p><a href="<?php echo TablePress::url( array( 'action' => 'uninstall_tablepress' ), true, 'admin-post.php' ); ?>" id="uninstall-tablepress" class="components-button is-secondary is-destructive"><?php _e( 'Uninstall TablePress', 'tablepress' ); ?></a></p>
202 240 <?php
203 - }
204 -
205 - /**
206 - * Sets the content for the WP feature pointer about the CSS Custom Variables on the "Options" screen.
207 - *
208 - * @since 2.0.0
209 - */
210 - public function wp_pointer_tp20_options_custom_css_css_variables() {
211 - $content = '<h3>' . __( 'TablePress feature: Styling tables with CSS Custom Properties', 'tablepress' ) . '</h3>';
212 - $content .= '<p>' . __( 'Did you know?', 'tablepress' ) . ' ' . __( 'To change the table colors, you can easily set new ones with CSS variables.', 'tablepress' ) . ' ' . sprintf( __( '<a href="%s">Read more in the TablePress FAQ.</a>', 'tablepress' ), 'https://tablepress.org/faq/' ) . '</p>';
213 -
214 - $this->admin_page->print_wp_pointer_js(
215 - 'tp20_options_custom_css_css_variables',
216 - '#option-custom-css + .CodeMirror',
217 - array(
218 - 'content' => $content,
219 - 'position' => array( 'edge' => 'top', 'align' => 'center' ),
220 - )
221 - );
222 241 }
223 242
224 243 } // class TablePress_Options_View