$data Data for this view. */ #[\Override] public function setup( /* string */ $action, array $data ) /* : void */ { // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited. parent::setup( $action, $data ); $this->add_text_box( 'no-javascript', array( $this, 'textbox_no_javascript' ), 'header' ); if ( isset( $data['table']['is_corrupted'] ) && $data['table']['is_corrupted'] ) { $this->add_text_box( 'table-corrupted', array( $this, 'textbox_corrupted_table' ), 'header' ); return; } $this->process_action_messages( array( 'success_add' => __( 'The table was added successfully.', 'tablepress' ), 'success_copy' => _n( 'The table was copied successfully.', 'The tables were copied successfully.', 1, 'tablepress' ) . ' ' . sprintf( __( 'You are now seeing the copied table, which has the table ID “%s”.', 'tablepress' ), esc_html( $data['table']['id'] ) ), 'success_import' => __( 'The table was imported successfully.', 'tablepress' ), 'error_delete' => __( 'Error: The table could not be deleted.', 'tablepress' ), ) ); // For the Advanced Editor. wp_enqueue_style( 'wp-jquery-ui-dialog' ); wp_enqueue_style( 'editor-buttons' ); wp_enqueue_script( 'wpdialogs' ); // For the "Insert Image" dialog. add_filter( 'media_view_strings', array( $this, 'change_media_view_strings' ) ); wp_enqueue_media(); // For the "Insert Link" dialog. wp_enqueue_script( 'wplink' ); $this->admin_page->enqueue_style( 'jspreadsheet' ); $this->admin_page->enqueue_style( 'jsuites', array( 'tablepress-jspreadsheet' ) ); $this->admin_page->enqueue_style( 'edit', array( 'tablepress-jspreadsheet', 'tablepress-jsuites' ) ); if ( ! TABLEPRESS_IS_PLAYGROUND_PREVIEW && tb_tp_fs()->is_free_plan() ) { $this->admin_page->enqueue_style( 'edit-features', array( 'tablepress-edit' ) ); } $this->admin_page->enqueue_script( 'jspreadsheet' ); $this->admin_page->enqueue_script( 'jsuites', array( 'tablepress-jspreadsheet' ) ); $this->admin_page->enqueue_script( 'edit', array( 'tablepress-jspreadsheet', 'tablepress-jsuites', 'jquery-core' ) ); $this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' ); $this->add_text_box( 'buttons-top', array( $this, 'textbox_buttons' ), 'normal' ); $this->add_meta_box( 'table-information', __( 'Table Information', 'tablepress' ), array( $this, 'postbox_table_information' ), 'normal' ); $this->add_meta_box( 'table-data', __( 'Table Content', 'tablepress' ), array( $this, 'postbox_table_data' ), 'normal' ); $this->add_meta_box( 'table-manipulation', __( 'Table Manipulation', 'tablepress' ), array( $this, 'postbox_table_manipulation' ), 'normal' ); $this->add_meta_box( 'table-options', __( 'Table Options', 'tablepress' ), array( $this, 'postbox_table_options' ), 'normal' ); $this->add_meta_box( 'datatables-features', __( 'Table Features for Site Visitors', 'tablepress' ), array( $this, 'postbox_datatables_features' ), 'normal' ); $this->add_text_box( 'hidden-containers', array( $this, 'textbox_hidden_containers' ), 'additional' ); $this->add_text_box( 'buttons-bottom', array( $this, 'textbox_buttons' ), 'additional' ); $this->add_text_box( 'other-actions', array( $this, 'textbox_other_actions' ), 'submit' ); add_filter( 'screen_settings', array( $this, 'add_screen_options_output' ), 10, 2 ); } /** * Changes the Media View string "Insert into post" to "Insert into Table". * * @since 1.0.0 * * @param array $strings Current set of Media View strings. * @return array Changed Media View strings. */ public function change_media_view_strings( array $strings ): array { $strings['insertIntoPost'] = __( 'Insert into Table', 'tablepress' ); return $strings; } /** * Adds custom screen options to the screen. * * @since 2.1.0 * * @param string $screen_settings Screen settings. * @param WP_Screen $screen WP_Screen object. * @return string Extended Screen settings. */ public function add_screen_options_output( /* string */ $screen_settings, WP_Screen $screen ): string { // Don't use a type hint for the `$screen_settings` argument as many WordPress plugins seem to be returning `null` in their filter hook handlers. // Protect against other plugins not returning a string for the `$screen_settings` argument. if ( ! is_string( $screen_settings ) ) { // @phpstan-ignore function.alreadyNarrowedType (The `is_string()` check is needed as the input is coming from a filter hook.) $screen_settings = ''; } $screen_settings = '
'; $screen_settings .= '' . __( 'Table editor settings', 'tablepress' ) . ''; $screen_settings .= '

' . __( 'Adjust the default size of the table cells in the table editor below.', 'tablepress' ) . ' ' . __( 'Cells with many lines of text will expand to their full height when they are edited.', 'tablepress' ) . '

'; $screen_settings .= '

' . __( 'Please note: These settings only influence the table editor view on this screen, but not the table that the site visitor sees!', 'tablepress' ) . '

'; $screen_settings .= '
'; $screen_settings .= ' '; $input = ''; /* translators: %s: Input field for the number of pixels */ $screen_settings .= sprintf( __( '%s pixels', 'tablepress' ), $input ); $screen_settings .= '
'; $screen_settings .= '
'; $screen_settings .= ' '; $input = ''; /* translators: %s: Input field for the number of lines */ $screen_settings .= sprintf( __( '%s lines', 'tablepress' ), $input ); $screen_settings .= '
'; $screen_settings .= '
'; return $screen_settings; } /** * Renders the current view. * * In comparison to the parent class method, this contains handling for the no-js case and adjusts the HTML code structure. * * @since 2.0.0 */ #[\Override] public function render(): void { $this->print_javascript_data(); ?>
print_nav_tab_menu(); ?>

header_messages as $message ) { echo $message; } $this->do_text_boxes( 'header' ); ?>
do_text_boxes( 'normal' ); $this->do_meta_boxes( 'normal' ); $this->do_text_boxes( 'additional' ); $this->do_meta_boxes( 'additional' ); $this->do_text_boxes( 'submit' ); $this->do_text_boxes( 'side' ); $this->do_meta_boxes( 'side' ); ?>

$data Data for this screen. * @param array $box Information about the text box. */ #[\Override] protected function action_nonce_field( array $data, array $box ): void { // Intentionally left empty. Nonces for this view are generated in `print_javascript_data()`. } /** * Prints the table data for use in JS code and the main React container. * * @since 3.0.0 */ public function print_javascript_data(): void { echo "\n"; echo '
'; // React container. } /** * Prints the content of the "Table Information" post meta box. * * @since 1.0.0 * * @param array $data Data for this screen. * @param array $box Information about the meta box. */ public function postbox_table_information( array $data, array $box ): void { echo '
'; if ( ! TABLEPRESS_IS_PLAYGROUND_PREVIEW && tb_tp_fs()->is_free_plan() ) : ?>

' . __( 'Supercharge your tables with exceptional features:', 'tablepress' ) . ''; echo '

' . $feature_module['name'] . '

'; echo '' . $feature_module['description'] . ' ' . __( 'Read more!', 'tablepress' ) . ''; ?>
$data Data for this screen. * @param array $box Information about the meta box. */ public function postbox_table_data( array $data, array $box ): void { $css_variables = '--table-editor-line-clamp:' . absint( TablePress::$model_options->get( 'table_editor_line_clamp' ) ) . ';'; $css_variables = esc_attr( $css_variables ); echo "
"; } /** * Prints the content of the "Table Manipulation" post meta box. * * @since 1.0.0 * * @param array $data Data for this screen. * @param array $box Information about the meta box. */ public function postbox_table_manipulation( array $data, array $box ): void { echo '
'; } /** * Prints the container for the "Preview" and "Save Changes" buttons. * * @since 1.0.0 * * @param array $data Data for this screen. * @param array $box Information about the text box. */ public function textbox_buttons( array $data, array $box ): void { echo '
'; echo '
'; } /** * Prints the container for the "Copy Table, "Export Table", and "Delete Table" buttons. * * @since 1.0.0 * * @param array $data Data for this screen. * @param array $box Information about the text box. */ public function textbox_other_actions( array $data, array $box ): void { echo '
'; } /** * Prints the hidden containers for the Preview. * * @since 1.0.0 * * @param array $data Data for this screen. * @param array $box Information about the text box. */ public function textbox_hidden_containers( array $data, array $box ): void { ?>
10, 'tinymce' => false, 'quicktags' => array( 'buttons' => 'strong,em,link,del,ins,img,code,spell,close', ), ); wp_editor( '', 'advanced-editor-content', $wp_editor_options ); ?>
$data Data for this screen. * @param array $box Information about the meta box. */ public function postbox_table_options( array $data, array $box ): void { echo '
'; } /** * Prints the content of the "Table Features for Site Visitors" post meta box. * * @since 1.0.0 * * @param array $data Data for this screen. * @param array $box Information about the meta box. */ public function postbox_datatables_features( array $data, array $box ): void { echo '
'; } /** * Prints a notification about a corrupted table. * * @since 1.4.0 * * @param array $data Data for this screen. * @param array $box Information about the text box. */ public function textbox_corrupted_table( array $data, array $box ): void { ?>

' . esc_html( $data['table']['json_error'] ) . '' ); ?>

TablePress FAQ page for further instructions.', 'tablepress' ), 'https://tablepress.org/faq/corrupted-tables/' ); ?>

'list' ) ) ) . '" class="components-button is-secondary is-compact">' . __( 'Back to the List of Tables', 'tablepress' ) . ''; ?>

$data Data for this screen. * @param array $box Information about the text box. */ public function textbox_head( array $data, array $box ): void { echo '

'; _e( 'To edit the content or modify the structure of this table, use the input fields and buttons below.', 'tablepress' ); echo ' '; // Show the instructions string depending on whether the Block Editor is used on the site or not. if ( 'block' === $data['site_used_editor'] ) { 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' ) ); } elseif ( 'elementor' === $data['site_used_editor'] ) { 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' ) ); } else { _e( 'To insert a table into a post or page, paste its Shortcode at the desired place in the editor.', 'tablepress' ); } echo '

'; } /** * Sets the content for the WP feature pointer about the drag and drop and sort on the "Edit" screen. * * @since 2.0.0 */ public function wp_pointer_tp20_edit_context_menu(): void { $content = '

' . __( 'TablePress feature: Context menu', 'tablepress' ) . '

'; $content .= '

' . __( 'Did you know?', 'tablepress' ) . ' ' . __( 'Right-clicking the table content fields will open a context menu for quick access to common editing tools.', 'tablepress' ) . '

'; $this->admin_page->print_wp_pointer_js( 'tp20_edit_context_menu', '#table-editor', array( 'content' => $content, 'position' => array( 'edge' => 'bottom', 'align' => 'center' ), ), ); } /** * Sets the content for the WP feature pointer about the screen options for changing the cell size. * * @since 2.1.0 */ public function wp_pointer_tp21_edit_screen_options(): void { $content = '

' . __( 'TablePress feature: Column width and row height of the table editor', 'tablepress' ) . '

'; $content .= '

' . __( 'Did you know?', 'tablepress' ) . ' ' . sprintf( __( 'You can change the default cell size for the table editor on this “Edit” screen in the “%s”.', 'tablepress' ), __( 'Screen Options', 'default' ) ) . '

'; $this->admin_page->print_wp_pointer_js( 'tp21_edit_screen_options', '#screen-options-link-wrap', array( 'content' => $content, 'position' => array( 'edge' => 'top', 'align' => 'right' ), 'pointerClass' => 'wp-pointer pointer-tp21_edit_screen_options', ), ); } } // class TablePress_Edit_View