| @@ -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 | /** |
| @@ -34,12 +36,15 @@ | ||
| 34 | 36 | * Set up the view with data and do things that are specific for this view. |
| 35 | 37 | * |
| 36 | 38 | * @since 1.0.0 |
| 37 | 39 | * |
| 38 | - * @param string $action Action for this view. | |
| 39 | - * @param array $data Data for this view. | |
| 40 | + * @param string $action Action for this view. | |
| 41 | + * @param array<string, mixed> $data Data for this view. | |
| 40 | 42 | */ |
| 41 | - public function setup( $action, array $data ) { | |
| 43 | + #[\Override] | |
| 44 | + public function setup( /* string */ $action, array $data ) /* : void */ { | |
| 45 | + // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited. | |
| 46 | + | |
| 42 | 47 | $this->action = $action; |
| 43 | 48 | $this->data = $data; |
| 44 | 49 | } |
| 45 | 50 | |
| @@ -47,22 +52,32 @@ | ||
| 47 | 52 | * Render the current view. |
| 48 | 53 | * |
| 49 | 54 | * @since 1.0.0 |
| 50 | 55 | */ |
| 51 | - public function render() { | |
| 56 | + #[\Override] | |
| 57 | + public function render(): void { | |
| 52 | 58 | _wp_admin_html_begin(); |
| 53 | 59 | ?> |
| 54 | -<title><?php printf( __( '%1$s ‹ %2$s', 'tablepress' ), __( 'Preview', 'tablepress' ), 'TablePress' ); ?></title> | |
| 60 | + <title> | |
| 61 | + <?php | |
| 62 | + /* translators: %1$s: Page title (Preview), %2$s: Plugin name (TablePress) */ | |
| 63 | + printf( __( '%1$s ‹ %2$s', 'tablepress' ), __( 'Preview', 'tablepress' ), 'TablePress' ); | |
| 64 | + ?> | |
| 65 | + </title> | |
| 55 | 66 | <?php echo $this->data['head_html']; ?> |
| 56 | 67 | </head> |
| 57 | 68 | <body> |
| 58 | 69 | <div id="tablepress-page"> |
| 59 | 70 | <p> |
| 60 | - <?php _e( 'This is a preview of your table.', 'tablepress' ); ?> <?php _e( 'Because of CSS styling in your theme, the table might look different on your page!', 'tablepress' ); ?> <?php _e( 'The Table Features for Site Visitors, like sorting, filtering, and pagination, are also not available in this preview!', 'tablepress' ); ?><br /> | |
| 71 | + <?php _e( 'This is a preview of your table.', 'tablepress' ); ?> <?php _e( 'Because of CSS styling in your theme, the table might look different on your page!', 'tablepress' ); ?> <?php _e( 'The Table Features for Site Visitors, like sorting, filtering, and pagination, are also not available in this preview!', 'tablepress' ); ?><br> | |
| 61 | 72 | <?php |
| 62 | 73 | // Show the instructions string depending on whether the Block Editor is used on the site or not. |
| 63 | - if ( $this->data['site_uses_block_editor'] ) { | |
| 74 | + if ( 'block' === $this->data['site_used_editor'] ) { | |
| 75 | + /* translators: %1$s: Block name (TablePress table) */ | |
| 64 | 76 | 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' ) ); |
| 77 | + } elseif ( 'elementor' === $this->data['site_used_editor'] ) { | |
| 78 | + /* translators: %1$s: Widget name (TablePress table) */ | |
| 79 | + 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' ) ); | |
| 65 | 80 | } else { |
| 66 | 81 | _e( 'To insert a table into a post or page, paste its Shortcode at the desired place in the editor.', 'tablepress' ); |
| 67 | 82 | echo ' '; |
| 68 | 83 | _e( 'Each table has a unique ID that needs to be adjusted in that Shortcode.', 'tablepress' ); |
| @@ -68,9 +83,11 @@ | ||
| 68 | 83 | _e( 'Each table has a unique ID that needs to be adjusted in that Shortcode.', 'tablepress' ); |
| 69 | 84 | } |
| 70 | 85 | ?> |
| 71 | 86 | </p> |
| 87 | +<div class="preview"> | |
| 72 | 88 | <?php echo $this->data['body_html']; ?> |
| 89 | +</div> | |
| 73 | 90 | </div> |
| 74 | 91 | </body> |
| 75 | 92 | </html> |
| 76 | 93 | <?php |