Forum Replies Created

Viewing 10 replies - 1 through 10 (of 10 total)
  • At the end i will just for the moment convert every caracteres before import, i don’t find any “correct” way to do that after export ??
    (or maybe encode html before export in wp reload in HTML mode)

    Thanks anyway

    Hi,
    I use in first the migration tools, but i will need also to import sometimes for x reason ?? ( i’m the dev of a client ?? )
    I don’t have access to the live version, so i can’t test to convert the CSV, sorry ??

    Actually seems work with load string and & instead of &, i’m still testing to fix that.

    I will keep in touch if i find something.

    The imported file contains errors:
    
    Error 68: htmlParseStartTag: invalid element name in line 966, column 14

    Thanks to reply so quick ??

    I’m trying with simplexml load string and/or CDATA

    From wp reload i have some wrong caractere with export csv, only html seems export correctly that’s why i use html

    Hi,
    Finally i switch to Tablepress ??
    I have the same issue, i try to import html with some “extra caracteres” like ‘&’, resulting error.

    I tried your dev version, seems not change anything ??
    Which part/file/line manage this import to try to find a solution ??

    Thanks

    Radyium

    Thread Starter Radyium

    (@radyium)

    Thanks you, i will check later for the last version of your plugin and the new one ??

    Radyium

    Thread Starter Radyium

    (@radyium)

    i coded something in case we don’t have more simple way.
    the code below will output a table filter on special field, this is not just a forced search filter in js.
    If we filter in js, all data are still present and could be display on search or other filter of visitor, that i don’t want.

    For example : [table id=1 c_filter=”hello” c_filter_id=”1″]
    Will output the table id=1 with only column id = “1”, and the filter “hello”
    Of course the code below will have to adapt with your table.
    This code could be heavy of you have a hight number of entries in your table!!
    I also past part of code plug-in to not skip every others filter could be present

    add_filter( 'wp_table_reloaded_shortcode_table_overwrite', 'wp_table_reloaded_overwrite_atts',10,2 );
    add_filter( 'wp_table_reloaded_load_table_overwrite', 'wp_table_custom_load',10,2 );
    
    function wp_table_custom_load($table_id,$atts) {
    	global $WP_Table_Reloaded_Frontend;
    
            $table_loaded = apply_filters( 'wp_table_reloaded_load_table', false, $table_id );
            if ( $table_loaded )
                return $table_loaded;
    
            $table_option = ( $WP_Table_Reloaded_Frontend->table_exists( $table_id ) ) ? $WP_Table_Reloaded_Frontend->tables[ $table_id ] : $WP_Table_Reloaded_Frontend->optionname['table'] . '_' . $table_id;
            $table = get_option( $table_option, $WP_Table_Reloaded_Frontend->default_table);
    
    		//Custom filter
    		$filter_id = $atts['c_filter_id'];
    		$filter = trim($atts['c_filter']);
    
    		$new_table = array();
    		$new_table_v = array();
    
    		foreach($table['data'] as $k => $v) {
    			if(trim($v[$filter_id]) == $filter || $k == 0) {
    				$new_table[] = $v;
    				$new_table_v[] = $table['visibility']['row'][$k];
    			}
    		}
    		$table['data'] = $new_table;
    		$table['visibility']['rows'] = $new_table_v;
    
            $table = apply_filters( 'wp_table_reloaded_post_load_table', $table, $table_id );
            $table = apply_filters( 'wp_table_reloaded_post_load_table_id-' . $table_id, $table );
            return $table;
    }
    
    function wp_table_reloaded_overwrite_atts( $ret = false, $atts ) {
    	global $WP_Table_Reloaded_Frontend;
    
    	if(isset($atts['c_filter_id']) && $atts['c_filter_id'] != '') {
           // check, if a table with the given ID exists
            $table_id = $atts['id'];
            if ( !is_numeric( $table_id ) || 1 > $table_id || !$WP_Table_Reloaded_Frontend->table_exists( $table_id ) ) {
                $message = "[table \"{$table_id}\" not found /]<br />\n";
                $message = apply_filters( 'wp_table_reloaded_table_not_found_message', $message, $table_id );
                return $message;
            }
    
            // $table = $WP_Table_Reloaded_Frontend->load_table( $table_id );
            $table = apply_filters( 'wp_table_reloaded_load_table_overwrite', $table_id, $atts );
    
            // check for table data
            if ( empty( $table['data'] ) ) {
                $message = "[table &quot;{$table_id}&quot; seems to be empty /]<br />\n";
                $message = apply_filters( 'wp_table_reloaded_table_empty_message', $message, $table_id );
                return $message;
            }
    
            $rows = count( $table['data'] );
            $columns = count( $table['data'][0] );
    
            // explode from string to array
            $atts['column_widths'] = ( !empty( $atts['column_widths'] ) ) ? explode( '|', $atts['column_widths'] ) : array();
    
            // add all rows/columns to array if "all" value set for one of the four parameters
            // rows/columns are indexed from 0 internally, but from 1 externally, thus substract 1 from each value
            $actions = array( 'show', 'hide' );
            $elements = array( 'rows', 'columns' );
            foreach ( $actions as $action ) {
                foreach ( $elements as $element ) {
                    if ( !empty( $atts["{$action}_{$element}"] ) ) {
                        if ( 'all' == $atts["{$action}_{$element}"] )
                            $atts["{$action}_{$element}"] = range( 1, ${$element} + 1 ); // because second comment above
                        else
                            $atts["{$action}_{$element}"] = explode( ',', $atts["{$action}_{$element}"] );
                        foreach ( $atts["{$action}_{$element}"] as $key => $value )
                            $atts["{$action}_{$element}"][ $key ] = (string) ( $value - 1 );
                    } else {
                            $atts["{$action}_{$element}"] = array();
                    }
                }
            }
    
            // determine options to use (if set in Shortcode, use those, otherwise use options from DB, i.e. "Edit Table" screen)
            $output_options = array();
            foreach ( $atts as $key => $value ) {
                // have to check this, because strings 'true' or 'false' are not recognized as boolean!
                if ( is_array( $value ) )
                    $output_options[ $key ] = $value;
                elseif ( 'true' == strtolower( $value ) )
                    $output_options[ $key ] = true;
                elseif ( 'false' == strtolower( $value ) )
                    $output_options[ $key ] = false;
                else
                    $output_options[ $key ] = ( -1 !== $value ) ? $value : $table['options'][ $key ] ;
            }
    
            // generate unique HTML ID, depending on how often this table has already been shown on this page
            $count = ( isset( $WP_Table_Reloaded_Frontend->shown_tables[ $table_id ] ) ) ? $WP_Table_Reloaded_Frontend->shown_tables[ $table_id ] : 0;
            $count = $count + 1;
            $WP_Table_Reloaded_Frontend->shown_tables[ $table_id ] = $count;
            $output_options['html_id'] = "wp-table-reloaded-id-{$table_id}-no-{$count}";
            $output_options['html_id'] = apply_filters( 'wp_table_reloaded_html_id', $output_options['html_id'], $table_id );
    
            // get options for the JavaScript library from the table's options
            $js_options = array (
                'alternating_row_colors' => $output_options['alternating_row_colors'],
                'datatables_sort' => $output_options['datatables_sort'],
                'datatables_paginate' => $output_options['datatables_paginate'],
                'datatables_paginate_entries' => $output_options['datatables_paginate_entries'],
                'datatables_lengthchange' => $output_options['datatables_lengthchange'],
                'datatables_filter' => $output_options['datatables_filter'],
                'datatables_info' => $output_options['datatables_info'],
                'datatables_tabletools' => $output_options['datatables_tabletools'],
                'datatables_customcommands' => $output_options['datatables_customcommands']
            );
            $js_options = apply_filters( 'wp_table_reloaded_table_js_options', $js_options, $table_id, $output_options );
    
            // eventually add this table to list of tables which have a JS library enabled and thus are to be included in the script's call in the footer
            if ( $output_options['use_tablesorter'] && $output_options['first_row_th'] && 1 < $rows )
                $WP_Table_Reloaded_Frontend->tablesorter_tables[] = array (
                    'table_id' => $table_id,
                    'html_id' => $output_options['html_id'],
                    'js_options' => $js_options
                );
    
            // generate "Edit Table" link
            $edit_url = '';
            if ( is_user_logged_in() && $WP_Table_Reloaded_Frontend->options['frontend_edit_table_link'] ) {
                $user_group = $WP_Table_Reloaded_Frontend->options['user_access_plugin'];
                $capabilities = array(
                    'admin' => 'manage_options',
                    'editor' => 'publish_pages',
                    'author' => 'publish_posts',
                    'contributor' => 'edit_posts'
                );
                $min_capability = isset( $capabilities[ $user_group ] ) ? $capabilities[ $user_group ] : 'manage_options';
                $min_capability = apply_filters( 'wp_table_reloaded_min_needed_capability', $min_capability );
    
                if ( current_user_can( $min_capability ) ) {
                    $admin_menu_page = $WP_Table_Reloaded_Frontend->options['admin_menu_parent_page'];
                    $admin_menu_page = apply_filters( 'wp_table_reloaded_admin_menu_parent_page', $admin_menu_page );
                    // backward-compatibility for the filter
                    if ( 'top-level' == $admin_menu_page )
                        $admin_menu_page = 'admin.php';
                    // 'edit-pages.php' was renamed to 'edit.php?post_type=page' in WP 3.0
                    if ( 'edit-pages.php' == $admin_menu_page )
                        $admin_menu_page = 'edit.php?post_type=page';
                    if ( !in_array( $admin_menu_page, $WP_Table_Reloaded_Frontend->possible_admin_menu_parent_pages ) )
                        $admin_menu_page = 'tools.php';
                    $url_params = array(
                            'page' => $WP_Table_Reloaded_Frontend->page_slug,
                            'action' => 'edit',
                            'table_id' => $table['id']
                    );
                    $edit_url = add_query_arg( $url_params, admin_url( $admin_menu_page ) );
                    $edit_url = esc_url( $edit_url );
                }
            }
            $output_options['edit_table_url'] = $edit_url;
    
            // check if table output shall and can be loaded from the transient cache, otherwise generate the output
            $cache_name = "wp_table_reloaded_table_output_{$table_id}";
            if ( !$output_options['cache_table_output'] || is_user_logged_in() || ( false === ( $output = get_transient( $cache_name ) ) ) ) {
                // render/generate the table HTML
                $render = $WP_Table_Reloaded_Frontend->create_class_instance( 'WP_Table_Reloaded_Render', 'render.class.php' );
                $render->output_options = apply_filters( 'wp_table_reloaded_frontend_output_options', $output_options, $table['id'], $table );
                $render->table = $table;
                $output = $render->render_table();
    
                if ( $output_options['cache_table_output'] && !is_user_logged_in() )
                    set_transient( $cache_name, $output, 60*60*24 ); // store $output in a transient, set cache timeout to 24 hours
            }
    
            return $output;
    	}
    
    	return false;
    
    }
    
    add_filter( 'wp_table_reloaded_shortcode_table_default_atts', 'wp_table_reloaded_add_atts',10,1 );
    function wp_table_reloaded_add_atts($atts) {
    	$atts['c_filter_id'] = '';
    	$atts['c_filter'] = '';
    	return $atts;
    }

    Radyium

    Thread Starter Radyium

    (@radyium)

    Radyium

    (@radyium)

    aa lol, yesterday i made a code to do that in dashboard lol, but in fact i could simply like that ?? cf : Post support

    so just in case if someone want the code to do a default sort directly in dashboard with shortcode :

    add_filter( 'wp_table_reloaded_post_load_table', 'wp_table_reloaded_execute_shortcode_before_sort',10,2 );
    add_filter( 'wp_table_reloaded_filter_sort_pre', 'wp_table_reloaded_execute_filter_sort_pre' );
    add_filter( 'wp_table_reloaded_pre_save_table', 'wp_table_reloaded_before_save_sort',10,1 );
    
    function wp_table_reloaded_before_save_sort( $table ) {
    	if(isset($table['data']) && isset($table['data_hash'])) {
    		foreach($table['data'] as $k => $v) {
    			$save_v = $v;
    			unset($v[5]);
    			$hash = md5(implode('-',$v));
    			$table['data'][$k][5] = $table['data_hash'][$hash];
    		}
    	}
    
    	return $table;
    }
    
    function wp_table_reloaded_execute_filter_sort_pre( $value ) {
    	return do_shortcode($value);
    }
    
    function wp_table_reloaded_execute_shortcode_before_sort($table,$table_id) {
    	if(isset($_POST['submit']['sort'])) {
    		if(isset($table['data'])){
    			$table['data_hash'] = array();
    			foreach($table['data'] as $k => $v) {
    				$vv = $v;
    				unset($vv[5]);
    				$table['data_hash'][md5(implode('-',$vv))] = $v[5];
    				$v[5] = apply_filters( 'wp_table_reloaded_filter_sort_pre', $v[5] );
    				$table['data'][$k] = $v;
    			}
    		}
    	}
    
    	return $table;
    }

    Thread Starter Radyium

    (@radyium)

    hi, thanks for answer ??
    So, i have A-F column, in F, this is a shortcode
    I want to do a sort by default ( via backoffice ) on it.
    Actually if i do that, the plugin do a sort in the text of short code.

    For exemple : [getcode id=123]
    the plugin will do a sort on the text and not the return value of the shortcode.

    I’m thinking to do like that :
    filter on wp_table_reloaded_post_load_table => i save the current value in $table, then on each row, i do_shortcode to get the return value.
    Then i return the table, in that way, the sort works.

    At the end i filter on wp_table_reloaded_pre_save_table to replace the value by my save of shortcode, in that way the order is already done and i can put again the shortcode instead of value ??
    For the moment, on the filter wp_table_reloaded_pre_save_table, $table is empty, don’t know why, i will check tomorrow.

    Thanks

    Radyium

    Thread Starter Radyium

    (@radyium)

    i can’t edit, but in fact my filter doesn’t work.
    I have a row with shortcode inside, i would like do a sort by default on it.
    The problem, the plugin do a sort on the text of shortcode not the result of the shortcode.

    I already did a filter to execute this sortcode for display on frontend, but i need to keep display shortcode(text) on backoffice and do a sort on it by default.
    Someone have an idea ?

    Radyium

Viewing 10 replies - 1 through 10 (of 10 total)