| @@ -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 | /** |
| @@ -24,11 +26,10 @@ | ||
| 24 | 26 | /** |
| 25 | 27 | * Number of screen columns for post boxes on this screen. |
| 26 | 28 | * |
| 27 | 29 | * @since 1.0.0 |
| 28 | - * @var int | |
| 29 | 30 | */ |
| 30 | - protected $screen_columns = 2; | |
| 31 | + protected int $screen_columns = 2; | |
| 31 | 32 | |
| 32 | 33 | /** |
| 33 | 34 | * Set up the view with data and do things that are specific for this view. |
| 34 | 35 | * |
| @@ -33,14 +34,19 @@ | ||
| 33 | 34 | * Set up the view with data and do things that are specific for this view. |
| 34 | 35 | * |
| 35 | 36 | * @since 1.0.0 |
| 36 | 37 | * |
| 37 | - * @param string $action Action for this view. | |
| 38 | - * @param array $data Data for this view. | |
| 38 | + * @param string $action Action for this view. | |
| 39 | + * @param array<string, mixed> $data Data for this view. | |
| 39 | 40 | */ |
| 40 | - public function setup( $action, array $data ) { | |
| 41 | + #[\Override] | |
| 42 | + public function setup( /* string */ $action, array $data ) /* : void */ { | |
| 43 | + // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited. | |
| 44 | + | |
| 41 | 45 | parent::setup( $action, $data ); |
| 42 | 46 | |
| 47 | + TablePress::enqueue_script( 'common', array( 'jquery-core', 'postbox' ) ); | |
| 48 | + | |
| 43 | 49 | $this->add_text_box( 'spacer', array( $this, 'textbox_spacer' ), 'normal' ); |
| 44 | 50 | $this->add_text_box( 'spacer', array( $this, 'textbox_spacer' ), 'side' ); |
| 45 | 51 | $this->add_meta_box( 'plugin-purpose', __( 'Plugin Purpose', 'tablepress' ), array( $this, 'postbox_plugin_purpose' ), 'normal' ); |
| 46 | 52 | $this->add_meta_box( 'usage', __( 'Usage', 'tablepress' ), array( $this, 'postbox_usage' ), 'normal' ); |
| @@ -55,15 +61,13 @@ | ||
| 55 | 61 | * Prints the screen head spacer. |
| 56 | 62 | * |
| 57 | 63 | * @since 2.0.0 |
| 58 | 64 | * |
| 59 | - * @param array $data Data for this screen. | |
| 60 | - * @param array $box Information about the text box. | |
| 65 | + * @param array<string, mixed> $data Data for this screen. | |
| 66 | + * @param array<string, mixed> $box Information about the text box. | |
| 61 | 67 | */ |
| 62 | - public function textbox_spacer( array $data, array $box ) { | |
| 63 | - ?> | |
| 64 | - <p></p> | |
| 65 | - <?php | |
| 68 | + public function textbox_spacer( array $data, array $box ): void { | |
| 69 | + echo '<p></p>'; | |
| 66 | 70 | } |
| 67 | 71 | |
| 68 | 72 | /** |
| 69 | 73 | * Print the content of the "Plugin Purpose" post meta box. |
| @@ -69,17 +73,17 @@ | ||
| 69 | 73 | * Print the content of the "Plugin Purpose" post meta box. |
| 70 | 74 | * |
| 71 | 75 | * @since 1.0.0 |
| 72 | 76 | * |
| 73 | - * @param array $data Data for this screen. | |
| 74 | - * @param array $box Information about the meta box. | |
| 77 | + * @param array<string, mixed> $data Data for this screen. | |
| 78 | + * @param array<string, mixed> $box Information about the meta box. | |
| 75 | 79 | */ |
| 76 | - public function postbox_plugin_purpose( array $data, array $box ) { | |
| 80 | + public function postbox_plugin_purpose( array $data, array $box ): void { | |
| 77 | 81 | ?> |
| 78 | 82 | <p> |
| 79 | 83 | <?php _e( 'TablePress allows you to create and manage tables in the admin area of WordPress.', 'tablepress' ); ?> |
| 80 | 84 | <?php _e( 'Tables may contain text, numbers, formulas, and even HTML code (e.g. to include images or links).', 'tablepress' ); ?> |
| 81 | - <?php _e( 'You can embed the tables into posts, pages, or other site areas using a block in the block editor.', 'tablepress' ); ?> | |
| 85 | + <?php _e( 'You can embed the tables into posts, pages, or other site areas using a block in the block editor, a widget in the Elementor page builder, or a Shortcode.', 'tablepress' ); ?> | |
| 82 | 86 | </p> |
| 83 | 87 | <?php |
| 84 | 88 | } |
| 85 | 89 | |
| @@ -87,12 +91,12 @@ | ||
| 87 | 91 | * Print the content of the "Usage" post meta box. |
| 88 | 92 | * |
| 89 | 93 | * @since 1.0.0 |
| 90 | 94 | * |
| 91 | - * @param array $data Data for this screen. | |
| 92 | - * @param array $box Information about the meta box. | |
| 95 | + * @param array<string, mixed> $data Data for this screen. | |
| 96 | + * @param array<string, mixed> $box Information about the meta box. | |
| 93 | 97 | */ |
| 94 | - public function postbox_usage( array $data, array $box ) { | |
| 98 | + public function postbox_usage( array $data, array $box ): void { | |
| 95 | 99 | ?> |
| 96 | 100 | <p> |
| 97 | 101 | <?php _e( 'At first, you should add or import a table.', 'tablepress' ); ?> |
| 98 | 102 | <?php _e( 'This means that you either let the plugin create an empty table for you or that you load an existing table from either a CSV, HTML, JSON, XLS, or XLSX file.', 'tablepress' ); ?> |
| @@ -104,10 +108,12 @@ | ||
| 104 | 108 | </p> |
| 105 | 109 | <p> |
| 106 | 110 | <?php |
| 107 | 111 | // Show the instructions string depending on whether the Block Editor is used on the site or not. |
| 108 | - if ( $data['site_uses_block_editor'] ) { | |
| 112 | + if ( 'block' === $data['site_used_editor'] ) { | |
| 109 | 113 | printf( __( 'To insert a table into a post or page, add a “%1$s” block in the block editor and select the desired table.', 'tablepress' ), __( 'TablePress table', 'tablepress' ) ); |
| 114 | + } elseif ( 'elementor' === $data['site_used_editor'] ) { | |
| 115 | + printf( __( 'To insert a table into a post or page, add a “%1$s” widget in the Elementor editor and select the desired table.', 'tablepress' ), __( 'TablePress table', 'tablepress' ) ); | |
| 110 | 116 | } else { |
| 111 | 117 | _e( 'To insert a table into a post or page, paste its Shortcode at the desired place in the editor.', 'tablepress' ); |
| 112 | 118 | echo ' '; |
| 113 | 119 | _e( 'Each table has a unique ID that needs to be adjusted in that Shortcode.', 'tablepress' ); |
| @@ -127,12 +133,12 @@ | ||
| 127 | 133 | * Print the content of the "More Information and Documentation" post meta box. |
| 128 | 134 | * |
| 129 | 135 | * @since 1.0.0 |
| 130 | 136 | * |
| 131 | - * @param array $data Data for this screen. | |
| 132 | - * @param array $box Information about the meta box. | |
| 137 | + * @param array<string, mixed> $data Data for this screen. | |
| 138 | + * @param array<string, mixed> $box Information about the meta box. | |
| 133 | 139 | */ |
| 134 | - public function postbox_more_information( array $data, array $box ) { | |
| 140 | + public function postbox_more_information( array $data, array $box ): void { | |
| 135 | 141 | ?> |
| 136 | 142 | <p> |
| 137 | 143 | <?php printf( __( '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/' ); ?> |
| 138 | 144 | <?php printf( __( 'For technical information, please see the <a href="%s">Documentation</a>.', 'tablepress' ), 'https://tablepress.org/documentation/' ); ?> |
| @@ -145,23 +151,30 @@ | ||
| 145 | 151 | * Print the content of the "Author and License" post meta box. |
| 146 | 152 | * |
| 147 | 153 | * @since 1.0.0 |
| 148 | 154 | * |
| 149 | - * @param array $data Data for this screen. | |
| 150 | - * @param array $box Information about the meta box. | |
| 155 | + * @param array<string, mixed> $data Data for this screen. | |
| 156 | + * @param array<string, mixed> $box Information about the meta box. | |
| 151 | 157 | */ |
| 152 | - public function postbox_author_license( array $data, array $box ) { | |
| 158 | + public function postbox_author_license( array $data, array $box ): void { | |
| 153 | 159 | ?> |
| 154 | 160 | <p> |
| 155 | - <?php printf( __( 'This plugin was written and developed by <a href="%s">Tobias Bäthge</a>.', 'tablepress' ), 'https://tobias.baethge.com/' ); ?> | |
| 161 | + <?php | |
| 162 | + /* translators: %s: Author's website URL */ | |
| 163 | + printf( __( 'This plugin was written and developed by <a href="%s">Tobias Bäthge</a>.', 'tablepress' ), 'https://tobias.baethge.com/' ); | |
| 164 | + ?> | |
| 156 | 165 | <?php _e( 'It is licensed as Free Software under GNU General Public License 2 (GPL 2).', 'tablepress' ); ?> |
| 157 | 166 | </p> |
| 158 | 167 | <p> |
| 159 | - <?php printf( __( 'Please rate and review the plugin in the <a href="%s">WordPress Plugin Directory</a>.', 'tablepress' ), 'https://wordpress.org/support/view/plugin-reviews/tablepress' ); ?> | |
| 168 | + <?php | |
| 169 | + /* translators: %s: WordPress Plugin Directory URL */ | |
| 170 | + printf( __( 'Please rate and review the plugin in the <a href="%s">WordPress Plugin Directory</a>.', 'tablepress' ), 'https://wordpress.org/support/view/plugin-reviews/tablepress' ); | |
| 171 | + ?> | |
| 160 | 172 | </p> |
| 161 | 173 | <?php |
| 162 | 174 | if ( tb_tp_fs()->is_free_plan() ) { |
| 163 | - echo '<p><strong>' . sprintf( __( 'I would like to invite you to check out the <a href="%s">Premium versions of TablePress</a>.', 'tablepress' ), 'https://tablepress.org/premium/' ) . ' ' | |
| 175 | + /* translators: %s: TablePress Premium website URL */ | |
| 176 | + echo '<p><strong>' . sprintf( __( 'I would like to invite you to check out the <a href="%s">Premium versions of TablePress</a>.', 'tablepress' ), 'https://tablepress.org/premium/?utm_source=plugin&utm_medium=textlink&utm_content=about-screen' ) . ' ' | |
| 164 | 177 | . __( 'The available Pro and Max plans offer user support and many exciting and helpful features for your tables.', 'tablepress' ) . '</strong></p>'; |
| 165 | 178 | } |
| 166 | 179 | ?> |
| 167 | 180 | <?php |
| @@ -171,18 +184,18 @@ | ||
| 171 | 184 | * Print the content of the "Help and Support" post meta box. |
| 172 | 185 | * |
| 173 | 186 | * @since 1.0.0 |
| 174 | 187 | * |
| 175 | - * @param array $data Data for this screen. | |
| 176 | - * @param array $box Information about the meta box. | |
| 188 | + * @param array<string, mixed> $data Data for this screen. | |
| 189 | + * @param array<string, mixed> $box Information about the meta box. | |
| 177 | 190 | */ |
| 178 | - public function postbox_help_support( array $data, array $box ) { | |
| 191 | + public function postbox_help_support( array $data, array $box ): void { | |
| 179 | 192 | if ( tb_tp_fs()->is_free_plan() ) { |
| 180 | 193 | ?> |
| 181 | 194 | <h4><?php _e( 'Premium Support', 'tablepress' ); ?></h4> |
| 182 | 195 | <p> |
| 183 | 196 | <?php _e( 'Users with a valid TablePress Premium license plan are eligible for Priority Email Support, directly from the plugin developer!', 'tablepress' ); ?> |
| 184 | - <strong><?php printf( __( '<a href="%s">Find out more!</a>', 'tablepress' ), 'https://tablepress.org/premium/' ); ?></strong> | |
| 197 | + <strong><?php printf( __( '<a href="%s">Find out more!</a>', 'tablepress' ), 'https://tablepress.org/premium/?utm_source=plugin&utm_medium=textlink&utm_content=about-screen' ); ?></strong> | |
| 185 | 198 | </p> |
| 186 | 199 | <h4><?php _e( 'Community Support for users of the Free version', 'tablepress' ); ?></h4> |
| 187 | 200 | <p> |
| 188 | 201 | <?php printf( __( '<a href="%1$s">Support</a> is provided through the <a href="%2$s">WordPress Support Forums</a>.', 'tablepress' ), 'https://tablepress.org/support/', 'https://wordpress.org/support/plugin/tablepress' ); ?> |
| @@ -197,37 +210,40 @@ | ||
| 197 | 210 | * Print the content of the "Debug and Version Information" post meta box. |
| 198 | 211 | * |
| 199 | 212 | * @since 1.0.0 |
| 200 | 213 | * |
| 201 | - * @param array $data Data for this screen. | |
| 202 | - * @param array $box Information about the meta box. | |
| 214 | + * @param array<string, mixed> $data Data for this screen. | |
| 215 | + * @param array<string, mixed> $box Information about the meta box. | |
| 203 | 216 | */ |
| 204 | - public function postbox_debug_version_information( array $data, array $box ) { | |
| 205 | - $mysqli = ( isset( $GLOBALS['wpdb']->use_mysqli, $GLOBALS['wpdb']->dbh ) && $GLOBALS['wpdb']->use_mysqli ); | |
| 217 | + public function postbox_debug_version_information( array $data, array $box ): void { | |
| 206 | 218 | ?> |
| 207 | 219 | <p> |
| 208 | 220 | <strong><?php _e( 'Please provide this information in bug reports and support requests.', 'tablepress' ); ?></strong> |
| 209 | 221 | </p> |
| 210 | - <p class="ltr"> | |
| 211 | - · Website: <?php echo site_url(); ?> | |
| 212 | - <br />· TablePress: <?php echo TablePress::version; ?> | |
| 213 | - <br />· TablePress (DB): <?php echo TablePress::db_version; ?> | |
| 214 | - <br />· TablePress table scheme: <?php echo TablePress::table_scheme_version; ?> | |
| 215 | - <br />· Plan: <?php echo tb_tp_fs()->is_plan_or_trial( 'pro', true ) ? 'Pro' : ( tb_tp_fs()->is_plan_or_trial( 'max', true ) ? 'Max' : 'Free' ); ?> | |
| 216 | - <br />· Plugin installed: <?php echo wp_date( 'Y/m/d H:i:s', $data['first_activation'] ); ?> | |
| 217 | - <br />· WordPress: <?php echo $GLOBALS['wp_version']; ?> | |
| 218 | - <br />· Multisite: <?php echo is_multisite() ? 'yes' : 'no'; ?> | |
| 219 | - <br />· PHP: <?php echo PHP_VERSION; ?> | |
| 220 | - <br />· mysqli Extension: <?php echo $mysqli ? 'true' : 'false'; ?> | |
| 221 | - <br />· mySQL (Server): <?php echo $mysqli ? mysqli_get_server_info( $GLOBALS['wpdb']->dbh ) : '<em>no mysqli</em>'; // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_server_info ?> | |
| 222 | - <br />· mySQL (Client): <?php echo $mysqli ? mysqli_get_client_info() : '<em>no mysqli</em>'; // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_info ?> | |
| 223 | - <br />· ZIP support: <?php echo $data['zip_support_available'] ? 'yes' : 'no'; ?> | |
| 224 | - <br />· UTF-8 conversion: <?php echo ( function_exists( 'mb_detect_encoding' ) && function_exists( 'iconv' ) ) ? 'yes' : 'no'; ?> | |
| 225 | - <br />· WP Memory Limit: <?php echo WP_MEMORY_LIMIT; ?> | |
| 226 | - <br />· Server Memory Limit: <?php echo (int) @ini_get( 'memory_limit' ) . 'M'; // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged ?> | |
| 227 | - <br />· WP_DEBUG: <?php echo WP_DEBUG ? 'true' : 'false'; ?> | |
| 228 | - <br />· WP_POST_REVISIONS: <?php echo is_bool( WP_POST_REVISIONS ) ? ( WP_POST_REVISIONS ? 'true' : 'false' ) : WP_POST_REVISIONS; ?> | |
| 229 | - </p> | |
| 222 | + <ul> | |
| 223 | + <li>Website: <?php echo site_url(); ?></li> | |
| 224 | + <li>Block Theme: <?php echo wp_is_block_theme() ? 'yes' : 'no'; ?></li> | |
| 225 | + <li>TablePress: <?php echo TablePress::version; ?></li> | |
| 226 | + <li>TablePress (DB): <?php echo TablePress::db_version; ?></li> | |
| 227 | + <li>TablePress table scheme: <?php echo TablePress::table_scheme_version; ?></li> | |
| 228 | + <li>Plan: Free</li> | |
| 229 | + <li>Plugin installed: <?php echo wp_date( 'Y/m/d H:i:s', $data['first_activation'] ); ?></li> | |
| 230 | + <li>WordPress: <?php echo wp_get_wp_version(); ?></li> | |
| 231 | + <li>Multisite: <?php echo is_multisite() ? 'yes' : 'no'; ?></li> | |
| 232 | + <li>PHP: <?php echo PHP_VERSION; ?></li> | |
| 233 | + <li>mySQL (Server): <?php echo ( isset( $GLOBALS['wpdb']->dbh ) && 'mysqli' === get_class( $GLOBALS['wpdb']->dbh ) && function_exists( 'mysqli_get_server_info' ) ) ? mysqli_get_server_info( $GLOBALS['wpdb']->dbh ) : 'no mySQL server'; // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_server_info ?></li> | |
| 234 | + <li>mySQL (Client): <?php echo function_exists( 'mysqli_get_client_info' ) ? mysqli_get_client_info() : 'no mySQL client'; // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_info ?></li> | |
| 235 | + <li>mbstring: <?php echo extension_loaded( 'mbstring' ) ? 'yes' : '<span style="color:#800000;font-weight:bold;">no</span>'; ?></li> | |
| 236 | + <li>ZipArchive: <?php echo class_exists( 'ZipArchive', false ) ? 'yes' : '<span style="color:#800000;font-weight:bold;">no</span>'; ?></li> | |
| 237 | + <li>DOMDocument: <?php echo class_exists( 'DOMDocument', false ) ? 'yes' : '<span style="color:#800000;font-weight:bold;">no</span>'; ?></li> | |
| 238 | + <li>simplexml_load_string: <?php echo function_exists( 'simplexml_load_string' ) ? 'yes' : '<span style="color:#800000;font-weight:bold;">no</span>'; ?></li> | |
| 239 | + <li>libxml_disable_entity_loader: <?php echo function_exists( 'libxml_disable_entity_loader' ) ? 'yes' : '<span style="color:#800000;font-weight:bold;">no</span>'; ?></li> | |
| 240 | + <li>UTF-8 conversion: <?php echo ( function_exists( 'mb_detect_encoding' ) && function_exists( 'iconv' ) ) ? 'yes' : '<span style="color:#800000;font-weight:bold;">no</span>'; ?></li> | |
| 241 | + <li>WP Memory Limit: <?php echo WP_MEMORY_LIMIT; ?></li> | |
| 242 | + <li>Server Memory Limit: <?php echo esc_html( @ini_get( 'memory_limit' ) ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged ?></li> | |
| 243 | + <li>WP_DEBUG: <?php echo WP_DEBUG ? 'true' : 'false'; ?></li> | |
| 244 | + <li>WP_POST_REVISIONS: <?php echo is_bool( WP_POST_REVISIONS ) ? ( WP_POST_REVISIONS ? 'true' : 'false' ) : WP_POST_REVISIONS; // @phpstan-ignore constant.notFound, phpstanWP.wpConstant.fetch, phpstanWP.wpConstant.fetch, phpstanWP.wpConstant.fetch (The constant is printed for debugging purposes.) ?></li> | |
| 245 | + </ul> | |
| 230 | 246 | <?php |
| 231 | 247 | } |
| 232 | 248 | |
| 233 | 249 | /** |
| @@ -234,19 +250,21 @@ | ||
| 234 | 250 | * Print the content of the "Credits and Thanks" post meta box. |
| 235 | 251 | * |
| 236 | 252 | * @since 1.0.0 |
| 237 | 253 | * |
| 238 | - * @param array $data Data for this screen. | |
| 239 | - * @param array $box Information about the meta box. | |
| 254 | + * @param array<string, mixed> $data Data for this screen. | |
| 255 | + * @param array<string, mixed> $box Information about the meta box. | |
| 240 | 256 | */ |
| 241 | - public function postbox_credits_thanks( array $data, array $box ) { | |
| 257 | + public function postbox_credits_thanks( array $data, array $box ): void { | |
| 242 | 258 | ?> |
| 243 | 259 | <p> |
| 244 | 260 | <?php _e( 'Special Thanks go to:', 'tablepress' ); ?> |
| 245 | - <br />· <?php printf( __( 'Allan Jardine for <a href="%s">DataTables</a>,', 'tablepress' ), 'https://www.datatables.net/' ); ?> | |
| 246 | - <br />· <?php printf( __( 'the translators in the <a href="%s">Plugin Directory</a>,', 'tablepress' ), 'https://translate.wordpress.org/projects/wp-plugins/tablepress/' ); ?> | |
| 247 | - <br />· <?php _e( 'all customers, donors, contributors, supporters, reviewers, and users of the plugin!', 'tablepress' ); ?> | |
| 248 | 261 | </p> |
| 262 | + <ul> | |
| 263 | + <li><?php printf( __( 'Allan Jardine for <a href="%s">DataTables</a>,', 'tablepress' ), 'https://datatables.net/' ); ?></li> | |
| 264 | + <li><?php printf( __( 'the translators in the <a href="%s">Plugin Directory</a>,', 'tablepress' ), 'https://translate.wordpress.org/projects/wp-plugins/tablepress/' ); ?></li> | |
| 265 | + <li><?php _e( 'all customers, donors, contributors, supporters, reviewers, and users of the plugin!', 'tablepress' ); ?></li> | |
| 266 | + </ul> | |
| 249 | 267 | <?php |
| 250 | 268 | } |
| 251 | 269 | |
| 252 | 270 | } // class TablePress_About_View |