__( 'ID', 'wp-data-access' ), 'pub_name' => __( 'Name', 'wp-data-access' ), 'pub_schema_name' => __( 'Database', 'wp-data-access' ), 'pub_data_source' => __( 'Data Source', 'wp-data-access' ), 'pub_table_name' => __( 'Table/View Name', 'wp-data-access' ), 'pub_column_names' => __( 'Column Names (* = all)', 'wp-data-access' ), 'pub_format' => __( 'Column Labels', 'wp-data-access' ), 'pub_query' => __( '* Query', 'wp-data-access' ), 'pub_sort_icons' => __( 'Sort Icons', 'wp-data-access' ), 'pub_styles' => __( 'Styling', 'wp-data-access' ), 'pub_style_premium' => __( 'Enable Premium Styling', 'wp-data-access' ), 'pub_style_user' => __( 'Use Custom Style', 'wp-data-access' ), 'pub_style_color' => __( 'Color', 'wp-data-access' ), 'pub_style_space' => __( 'Spacing', 'wp-data-access' ), 'pub_style_corner' => __( 'Border Radius', 'wp-data-access' ), 'pub_style_modal_width' => __( 'Modal Width', 'wp-data-access' ), 'pub_responsive' => __( 'Output', 'wp-data-access' ), 'pub_responsive_popup_title' => __( 'Popup Title', 'wp-data-access' ), 'pub_responsive_cols' => __( 'Number Of Columns', 'wp-data-access' ), 'pub_responsive_type' => __( 'Type', 'wp-data-access' ), 'pub_responsive_modal_hyperlinks' => __( 'Hyperlinks On Modal', 'wp-data-access' ), 'pub_responsive_icon' => __( 'Show Icon', 'wp-data-access' ), 'pub_flat_scrollx' => __( 'Horizontal Scrollbar', 'wp-data-access' ), 'pub_default_where' => __( 'WHERE Clause', 'wp-data-access' ), 'pub_default_orderby' => __( 'Default Order By', 'wp-data-access' ), 'pub_table_options_searching' => __( 'Allow Searching?', 'wp-data-access' ), 'pub_table_options_ordering' => __( 'Allow Ordering?', 'wp-data-access' ), 'pub_table_options_paging' => __( 'Allow Paging?', 'wp-data-access' ), 'pub_table_options_serverside' => __( 'Server Side Processing?', 'wp-data-access' ), 'pub_table_options_nl2br' => __( 'NL > BR', 'wp-data-access' ), 'pub_table_options_advanced' => __( 'Advanced Options', 'wp-data-access' ), 'pub_extentions' => __( 'Extensions', 'wp-data-access' ), 'pub_cpt' => __( 'Post type', 'wp-data-access' ), 'pub_cpt_fields' => __( 'Custom fields', 'wp-data-access' ), 'pub_cpt_query' => __( 'CPT query', 'wp-data-access' ), 'pub_cpt_format' => __( 'Field labels', 'wp-data-access' ), ); $this->check_table_type = false; $this->title = 'Data Tables'; $args['help_url'] = 'https://wpdataaccess.com/docs/data-tables/data-tables-getting-started/'; parent::__construct( $schema_name, $table_name, $wpda_list_columns, $args ); // Get available databases. $schema_names = WPDA_Dictionary_Lists::get_db_schemas(); foreach ( $schema_names as $schema_name ) { array_push( $this->databases, $schema_name['schema_name'] ); //phpcs:ignore - 8.1 proof } // Add scripts and styles. WPDA_Data_Tables::enqueue_styles_and_script(); } /** * Overwrites method add_buttons */ public function add_buttons() { $index = $this->get_item_index( 'pub_id' ); $pub_id_item = $this->form_items[$index]; $pub_id = $pub_id_item->get_item_value(); $disabled = ( 'new' === $this->action ? 'disabled' : '' ); ?> show_shortcode( $pub_id ); } /** * Overwrites method prepare_items * * @param bool $set_back_form_values */ public function prepare_items( $set_back_form_values = false ) { parent::prepare_items( $set_back_form_values ); $i = 0; foreach ( $this->form_items as $form_item ) { // Prepare listbox for column pub_schema_name if ( $form_item->get_item_name() === 'pub_schema_name' ) { if ( '' === $form_item->get_item_value() || null === $form_item->get_item_value() ) { $form_item->set_item_value( WPDA::get_user_default_scheme() ); } $form_item->set_enum( $this->databases ); $this->form_items[$i] = new WPDA_Simple_Form_Item_Enum($form_item); } if ( $form_item->get_item_name() === 'pub_sort_icons' ) { $form_item->set_enum( array('Show', 'Hide') ); $form_item->set_enum_options( array('default', 'none') ); } if ( $form_item->get_item_name() === 'pub_data_source' ) { if ( null !== $form_item->get_item_value() ) { $this->pub_data_source = $form_item->get_item_value(); } } // Prepare listbox for column pub_table_name if ( $form_item->get_item_name() === 'pub_table_name' ) { $this->form_items[$i] = new WPDA_Simple_Form_Item_Enum($form_item); } // Set default value for popup title. if ( $form_item->get_item_name() === 'pub_responsive_popup_title' ) { $form_item->set_item_default_value( __( 'Row details', 'wp-data-access' ) ); } // Prepare listbox for column pub_responsive. if ( $form_item->get_item_name() === 'pub_responsive' ) { $form_item->set_enum( array('Responsive', 'Flat') ); $form_item->set_enum_options( array('Yes', 'No') ); } // Prepare selection for column pub_column_names. if ( $form_item->get_item_name() === 'pub_column_names' ) { $title = __( 'Select columns shown in data table', 'wp-data-access' ); $form_item->set_item_hide_icon( true ); $form_item->set_item_js( 'jQuery("#pub_column_names").parent().parent().find("td.icon").append("' . ' ' . __( 'Select', 'wp-data-access' ) . '");' ); } // Prepare column label settings. if ( $form_item->get_item_name() === 'pub_format' ) { $title = __( 'Define columns for data table (not necessary if already defined in Data Explorer table settings)', 'wp-data-access' ); $form_item->set_item_hide_icon( true ); $form_item->set_item_class( 'hide_item' ); $form_item->set_item_js( 'jQuery("#pub_format").parent().parent().find("td.data").append("' . ' ' . __( 'Click to define column labels', 'wp-data-access' ) . '");' ); } if ( 'pub_responsive_popup_title' === $form_item->get_item_name() || 'pub_responsive_cols' === $form_item->get_item_name() || 'pub_responsive_type' === $form_item->get_item_name() || 'pub_responsive_modal_hyperlinks' === $form_item->get_item_name() || 'pub_responsive_icon' === $form_item->get_item_name() || 'pub_flat_scrollx' === $form_item->get_item_name() ) { $form_item->set_hide_item_init( true ); } if ( 'pub_table_options_advanced' === $form_item->get_item_name() ) { if ( '' === $form_item->get_item_value() || null === $form_item->get_item_value() ) { $form_item->set_item_value( '{}' ); } } if ( 'pub_table_options_searching' === $form_item->get_item_name() || 'pub_table_options_ordering' === $form_item->get_item_name() || 'pub_table_options_paging' === $form_item->get_item_name() || 'pub_table_options_serverside' === $form_item->get_item_name() ) { if ( 'pub_table_options_searching' !== $form_item->get_item_name() ) { $form_item->set_hide_item_init( true ); } $form_item->checkbox_value_on = 'on'; if ( 'new' === $this->action ) { $form_item->set_item_value( 'on' ); } $this->form_items[$i] = new WPDA_Simple_Form_Item_Boolean($form_item); } if ( 'pub_table_options_nl2br' === $form_item->get_item_name() ) { $form_item->set_hide_item_init( true ); $form_item->checkbox_value_on = 'on'; $this->form_items[$i] = new WPDA_Simple_Form_Item_Boolean($form_item); } if ( $form_item->get_item_name() === 'pub_styles' ) { $options = $form_item->get_item_enum(); $option_values = $options; $option_values[0] = 'default = stripe + hover + order-column + row-border'; $form_item->set_enum( $option_values ); $form_item->set_enum_options( $options ); } if ( 'pub_default_orderby' === $form_item->get_item_name() ) { $form_item->set_item_hide_icon( true ); } $i++; } } protected function init_custom_fields() { } protected function add_fieldsets() { $fields = array(); foreach ( $this->form_items as $item ) { $fields[$item->get_item_name()] = true; } $data = array( 'pub_id', 'pub_name', 'pub_schema_name', 'pub_table_name', 'pub_column_names', 'pub_format' ); $styling = array('pub_sort_icons', 'pub_styles'); $this->fieldsets = array( 'Publication Data' => array( 'id' => 'pub_main', 'fields' => $data, ), 'Publication Type' => array( 'id' => 'pub_type', 'fields' => array( 'pub_responsive', 'pub_responsive_popup_title', 'pub_responsive_cols', 'pub_responsive_type', 'pub_responsive_modal_hyperlinks', 'pub_responsive_icon', 'pub_flat_scrollx' ), 'expandable' => true, ), 'Publication Styling' => array( 'id' => 'pub_styling', 'fields' => $styling, 'expandable' => true, ), ); $this->fieldsets['Advanced Settings'] = array( 'id' => 'pub_advanced', 'fields' => array( 'pub_default_where', 'pub_default_orderby', 'pub_table_options_searching', 'pub_table_options_ordering', 'pub_table_options_paging', 'pub_table_options_serverside', 'pub_table_options_nl2br', 'pub_table_options_advanced' ), 'expandable' => true, ); } /** * Overwrites method show * * @param bool $allow_save * @param string $add_param */ public function show( $allow_save = true, $add_param = '' ) { parent::show( $allow_save, $add_param ); $index = $this->get_item_index( 'pub_id' ); $pub_id_item = $this->form_items[$index]; $pub_id = $pub_id_item->get_item_value(); $index = $this->get_item_index( 'pub_schema_name' ); $schema_name_item = $this->form_items[$index]; $schema_name = $schema_name_item->get_item_value(); global $wpdb; $wpdb_name = $wpdb->dbname; $index = $this->get_item_index( 'pub_table_name' ); $table_name_item = $this->form_items[$index]; $table_name = $table_name_item->get_item_value(); $table_columns = WPDA_List_Columns_Cache::get_list_columns( $schema_name, $table_name ); $columns = array(); foreach ( $table_columns->get_table_columns() as $table_column ) { array_push( $columns, $table_column['column_name'] ); //phpcs:ignore - 8.1 proof } $column_labels = $table_columns->get_table_column_headers(); $json_editing = WPDA::get_option( WPDA::OPTION_DP_JSON_EDITING ); $wpda_table_settings_db = WPDA_Table_Settings_Model::query( $table_name, $schema_name ); if ( isset( $wpda_table_settings_db[0]['wpda_table_settings'] ) ) { $wpda_table_settings = json_decode( $wpda_table_settings_db[0]['wpda_table_settings'] ); if ( isset( $wpda_table_settings->hyperlinks ) ) { foreach ( $wpda_table_settings->hyperlinks as $hyperlink ) { $hyperlink_label = ( isset( $hyperlink->hyperlink_label ) ? $hyperlink->hyperlink_label : '' ); $hyperlink_html = ( isset( $hyperlink->hyperlink_html ) ? $hyperlink->hyperlink_html : '' ); if ( $hyperlink_label !== '' && $hyperlink_html !== '' ) { array_push( $this->hyperlinks, $hyperlink_label ); //phpcs:ignore - 8.1 proof } } } } ?> ' . __( 'ERROR: Not authorized', 'wp-data-access' ) . ''; } elseif ( null === $pub_id ) { $publication = '' . __( 'ERROR: Cannot test data table [wrong arguments]', 'wp-data-access' ) . ''; } elseif ( !$datatables_enabled || !$datatables_responsive_enabled ) { $publication = '' . __( 'ERROR: Cannot test data table', 'wp-data-access' ) . '

' . __( 'SOLUTION: Load jQuery DataTables: WP Data Access > Manage Plugin > Back-End Settings', 'wp-data-access' ); } else { $wpda_data_tables = new WPDA_Data_Tables(); $publication = $wpda_data_tables->show( $pub_id, '', '', '', '', '', '', '', '', '' ); // , '', '', '', true ); } ob_start(); ?>
(pub_id= - ) x