add_text_box( 'table-corrupted', array( $this, 'textbox_corrupted_table' ), 'normal' ); return; }; $action_messages = array( 'success_save' => __( 'The table was saved successfully.', 'tablepress' ), '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' ), 'success_import_wp_table_reloaded' => __( 'The table was imported successfully from WP-Table Reloaded.', 'tablepress' ), 'error_save' => __( 'Error: The table could not be saved.', 'tablepress' ), 'error_delete' => __( 'Error: The table could not be deleted.', 'tablepress' ), 'success_save_success_id_change' => __( 'The table was saved successfully, and the table ID was changed.', 'tablepress' ), 'success_save_error_id_change' => __( 'The table was saved successfully, but the table ID could not be changed!', 'tablepress' ), ); // Custom handling instead of $this->process_action_messages(). Also, $action_messages is used below. if ( $data['message'] && isset( $action_messages[ $data['message'] ] ) ) { $class = ( 'error' === substr( $data['message'], 0, 5 ) || in_array( $data['message'], array( 'success_save_error_id_change' ), true ) ) ? 'notice-error' : 'notice-success' ; $this->add_header_message( "{$action_messages[ $data['message'] ]}", $class ); } // Load jQuery UI dialog here to get the CSS into the HTML
part. wp_enqueue_style( 'wp-jquery-ui-dialog' ); wp_enqueue_script( 'wpdialogs' ); // for the Advanced Editor // Remove default media-upload.js, in favor of own code. add_action( 'admin_print_footer_scripts', array( $this, 'dequeue_media_upload_js' ), 2 ); add_thickbox(); add_filter( 'media_view_strings', array( $this, 'change_media_view_strings' ) ); wp_enqueue_media(); // Enqueue JS for the "Insert Link" button. wp_enqueue_script( 'wplink' ); $this->admin_page->enqueue_style( 'edit' ); $this->admin_page->enqueue_script( 'edit', array( 'jquery-core', 'jquery-ui-sortable', 'json2' ), array( 'options' => array( /** * Filter whether debug output shall be printed to the page. * * The value before filtering is determined from the GET parameter "debug" or the WP_DEBUG constant. * * @since 1.4.0 * * @param bool $print Whether debug output shall be printed. */ 'print_debug_output' => apply_filters( 'tablepress_print_debug_output', isset( $_GET['debug'] ) ? ( 'true' === $_GET['debug'] ) : WP_DEBUG ), /** * Filter whether the "Advanced Editor" button shall be enabled. * * @since 1.0.0 * * @param bool $enable Whether the "Advanced Editor" shall be enabled. Default true. */ 'cells_advanced_editor' => apply_filters( 'tablepress_edit_cells_advanced_editor', true ), /** * Filter whether the size of the table input textareas shall increase when they are focused. * * @since 1.0.0 * * @param bool $auto_grow Whether the size of the cell textareas shall increase. Default true. */ 'cells_auto_grow' => apply_filters( 'tablepress_edit_cells_auto_grow', true ), 'shortcode' => esc_js( TablePress::$shortcode ), ), 'strings' => array_merge( array( 'no_remove_all_rows' => __( 'You can not delete all table rows!', 'tablepress' ), 'no_remove_all_columns' => __( 'You can not delete all table columns!', 'tablepress' ), 'no_rows_selected' => __( 'You did not select any rows!', 'tablepress' ), 'no_columns_selected' => __( 'You did not select any columns!', 'tablepress' ), 'append_num_rows_invalid' => __( 'The value for the number of rows is invalid!', 'tablepress' ), 'append_num_columns_invalid' => __( 'The value for the number of columns is invalid!', 'tablepress' ), 'ays_remove_rows_singular' => _n( 'Do you really want to delete the selected row?', 'Do you really want to delete the selected rows?', 1, 'tablepress' ), 'ays_remove_rows_plural' => _n( 'Do you really want to delete the selected row?', 'Do you really want to delete the selected rows?', 2, 'tablepress' ), 'ays_remove_columns_singular' => _n( 'Do you really want to delete the selected column?', 'Do you really want to delete the selected columns?', 1, 'tablepress' ), 'ays_remove_columns_plural' => _n( 'Do you really want to delete the selected column?', 'Do you really want to delete the selected columns?', 2, 'tablepress' ), 'advanced_editor_open' => __( 'Please click into the cell that you want to edit using the “Advanced Editor”.', 'tablepress' ), 'rowspan_add' => __( 'To combine cells within a column, click into the cell below the cell that has the content the combined cells shall have.', 'tablepress' ), 'colspan_add' => __( 'To combine cells within a row, click into the cell to the right of the cell that has the content the combined cells shall have.', 'tablepress' ), 'span_add_datatables_warning' => __( 'Attention: You have enabled the usage of the DataTables JavaScript library for features like sorting, search, or pagination.', 'tablepress' ) . "\n" . __( 'Unfortunately, these can not be used in tables with combined cells.', 'tablepress' ) . "\n" . __( 'Do you want to proceed and automatically turn off the usage of DataTables for this table?', 'tablepress' ), 'link_add' => __( 'Please click into the cell that you want to add a link to.', 'tablepress' ) . "\n" . __( 'You can then enter the Link URL and Text or choose an existing page or post.', 'tablepress' ), 'image_add' => __( 'Please click into the cell that you want to add an image to.', 'tablepress' ) . "\n" . __( 'The Media Library will open, where you can select or upload the desired image or enter the image URL.', 'tablepress' ) . "\n" . sprintf( __( 'Click the “%s” button to insert the image.', 'tablepress' ), __( 'Insert into Table', 'tablepress' ) ), 'unsaved_changes_unload' => __( 'The changes to this table were not saved yet and will be lost if you navigate away from this page.', 'tablepress' ), 'preparing_preview' => __( 'The Table Preview is being loaded...', 'tablepress' ), 'preview_error' => __( 'The Table Preview could not be loaded.', 'tablepress' ), 'save_changes_success' => __( 'Saving successful', 'tablepress' ), 'save_changes_error' => __( 'Saving failed', 'tablepress' ), 'saving_changes' => __( 'Changes are being saved...', 'tablepress' ), 'table_id_not_empty' => __( 'The Table ID field can not be empty. Please enter a Table ID!', 'tablepress' ), 'table_id_not_zero' => __( 'The Table ID “0” is not supported. Please enter a different Table ID!', 'tablepress' ), 'ays_change_table_id' => __( 'Do you really want to change the Table ID? All Shortcodes for this table in your pages and posts will have to be adjusted!', 'tablepress' ), 'extra_css_classes_invalid' => __( 'The entered value in the field “Extra CSS classes” is invalid.', 'tablepress' ), 'num_pagination_entries_invalid' => __( 'The entered value in the field “Pagination Entries” is not a number.', 'tablepress' ), 'sort_asc' => __( 'Sort ascending', 'tablepress' ), 'sort_desc' => __( 'Sort descending', 'tablepress' ), 'no_rowspan_first_row' => __( 'You can not add rowspan to the first row!', 'tablepress' ), 'no_colspan_first_col' => __( 'You can not add colspan to the first column!', 'tablepress' ), 'no_rowspan_table_head' => __( 'You can not connect cells into the table head row!', 'tablepress' ), 'no_rowspan_table_foot' => __( 'You can not connect cells out of the table foot row!', 'tablepress' ), ), // Merge this to have messages available for AJAX after save dialog. $action_messages ), ) ); $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', __( 'Features of the DataTables JavaScript library', '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' ); } /** * Dequeue 'media-upload' JavaScript, which gets added by the Media Library, * but is undesired here, as we don't want the tb_position() function for resizing. * * @since 1.0.0 */ public function dequeue_media_upload_js() { wp_dequeue_script( 'media-upload' ); } /** * 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 ) { $strings['insertIntoPost'] = __( 'Insert into Table', 'tablepress' ); return $strings; } /** * Print hidden field with a nonce for the screen's action, to be transmitted in HTTP requests. * * @since 1.0.0 * * @param array $data Data for this screen * @param array $box Information about the text box. */ protected function action_nonce_field( array $data, array $box ) { // use custom nonce field here, that includes the table ID wp_nonce_field( TablePress::nonce( $this->action, $data['table']['id'] ), 'nonce-edit-table' ); echo "\n"; wp_nonce_field( TablePress::nonce( 'preview_table', $data['table']['id'] ), 'nonce-preview-table', false, true ); } /** * 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 ) { ?>
/>
" readonly="readonly" />
|
|
: | ' . TablePress::format_datetime( $data['table']['last_modified'] ) . '', '' . TablePress::get_user_display_name( $data['table']['options']['last_editor'] ) . '' ); ?> |
{$column}\n"; } ?> | |||
---|---|---|---|
{$row} | "; echo ""; foreach ( $row_data as $col_idx => $cell ) { $column = TablePress::number_to_letter( $col_idx + 1 ); $column_class = ''; if ( 0 === $visibility['columns'][ $col_idx ] ) { $column_class = ' class="column-hidden"'; } // Sanitize, so that HTML is possible in table cells. $cell = esc_textarea( $cell ); echo " | "; } echo " | {$row} | \n"; echo "\t\t
"; echo "\n"; } ?> |
'; 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 ) { $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 Advanced Editor and 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 ) { ?>: | |
---|---|
: | |
: | |
: | |
: | '; $position_select .= ''; $position_select .= ''; $position_select .= ''; ?>/> |
: | '; $position_select .= ''; $position_select .= ''; $position_select .= ''; ?>/> |
: |
: | |
---|---|
: | |
: | |
: | |
: | |
: | |
: | |
: |
%s.', 'tablepress' ), 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' ) . ''; ?>
' ); ?>
' . __( 'TablePress Feature: Moving rows and columns', 'tablepress' ) . ''; $content .= '' . __( 'Did you know? You can drag and drop rows and columns via the row number and the column title. And the arrows next to the column title can be used for sorting.', 'tablepress' ) . '
'; $this->admin_page->print_wp_pointer_js( 'tp09_edit_drag_drop_sort', '#edit-form-head', array( 'content' => $content, 'position' => array( 'edge' => 'top', 'align' => 'left', 'offset' => '56 2' ), ) ); } } // class TablePress_Edit_View