$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' ), ) ); wp_enqueue_style( 'wp-jquery-ui-dialog' ); wp_enqueue_style( 'editor-buttons' ); wp_enqueue_script( 'wpdialogs' ); // For the Advanced Editor, Table Preview, and Help Boxes. add_filter( 'media_view_strings', array( $this, 'change_media_view_strings' ) ); wp_enqueue_media(); wp_enqueue_script( 'wplink' ); // JS for the "Insert Link" button. $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-1', 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-2', 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 ); } /** * Change 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 ) ) { $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 = ''; $screen_settings .= sprintf( __( '%s pixels', 'tablepress' ), $input ); $screen_settings .= '
'; $screen_settings .= '
'; $screen_settings .= ' '; $input = ''; $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 { ?>
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 postbox_table_data(). } /** * Print 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 { ?>
/>
" readonly />
: ' . TablePress::format_datetime( $data['table']['last_modified'] ) . '', '' . TablePress::get_user_display_name( $data['table']['options']['last_editor'] ) . '' ); ?>
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 { echo "\n"; $css_variables = '--table-editor-line-clamp:' . absint( TablePress::$model_options->get( 'table_editor_line_clamp' ) ) . ';'; $css_variables = esc_attr( $css_variables ); echo "
"; } /** * Print 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 { ?>
   
$data Data for this screen. * @param array $box Information about the text box. */ public function textbox_buttons( array $data, array $box ): void { $preview_url = TablePress::url( array( 'action' => 'preview_table', 'item' => $data['table']['id'], 'return' => 'edit', 'return_item' => $data['table']['id'] ), true, 'admin-post.php' ); echo '

'; if ( current_user_can( 'tablepress_preview_table', $data['table']['id'] ) ) { echo '' . __( 'Preview', 'tablepress' ) . ''; } ?> '; } /** * Print the "Delete Table" and "Export 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 { $user_can_copy_table = current_user_can( 'tablepress_copy_table', $data['table']['id'] ); $user_can_export_table = current_user_can( 'tablepress_export_table', $data['table']['id'] ); $user_can_delete_table = current_user_can( 'tablepress_delete_table', $data['table']['id'] ); if ( ! $user_can_copy_table && ! $user_can_export_table && ! $user_can_delete_table ) { return; } echo '

'; echo __( 'Other Actions', 'tablepress' ) . ':  '; if ( $user_can_copy_table ) { echo '' . __( 'Copy Table', 'tablepress' ) . ' '; } if ( $user_can_export_table ) { echo '' . __( 'Export Table', 'tablepress' ) . ' '; } if ( $user_can_delete_table ) { echo '' . __( 'Delete Table', 'tablepress' ) . ''; } echo '

'; } /** * Print 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 ); ?>
' . __( 'Table cells can span across more than one column or row.', 'tablepress' ) . '

'; echo '

' . __( 'Combining consecutive cells within the same row is called “colspanning”.', 'tablepress' ) . ' ' . __( 'Combining consecutive cells within the same column is called “rowspanning”.', 'tablepress' ) . '

'; echo '

' . sprintf( __( 'To combine adjacent cells, select the desired cells and click the “%s” button or use the context menu.', 'tablepress' ), __( 'Combine/Merge', 'tablepress' ) ) . ' ' . __( 'The corresponding keywords, #colspan# and #rowspan#, will then be added for you.', 'tablepress' ) . '

'; echo '

' . __( 'Be aware that the Table Features for Site Visitors, like sorting, filtering, and pagination, will not work on tables which have combined cells.', 'tablepress' ) . '

'; ?>
$data Data for this screen. * @param array $box Information about the meta box. */ public function postbox_table_options( array $data, array $box ): void { ?> '; $position_select .= ''; $position_select .= ''; $position_select .= ''; ?> '; $position_select .= ''; $position_select .= ''; $position_select .= ''; ?>
:
:
:
:
:
:
:
$data Data for this screen. * @param array $box Information about the meta box. */ public function postbox_datatables_features( array $data, array $box ): void { ?>

>
:
:
:
:
:
:
:
:
$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="button">' . __( '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 ( $data['site_uses_block_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' ) ); } 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