Home › Toolset Professional Support › [Resolved] Updating without breaking things
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Hong_Kong (GMT+08:00)
Tagged: Views, Views plugin
This topic contains 25 replies, has 3 voices.
Last updated by rainman 6 years, 5 months ago.
Assisted by: Luo Yang.
This website has such a complicated setup with templates and views and we have had problems when updating Toolset versions in the past, I have not updated to newest version of Types and Views. I am afraid it will break things and would like some assistance with the update.
Hello,
In your case, I suggest you backup your website, then try these:
1) Deactivate other plugins and switch wordpress default theme
2) Update wordpress installation to the latest version:
https://wordpress.org/download/
3) Update the Toolset Types plugin first, you can download it here:
https://toolset.com/account/downloads/
4) Update other Toolset plugins:
https://toolset.com/faq/how-to-install-and-register-toolset/
5) Then activate and update other plugins and theme.
What I am concerned about is that my views and/or custom templates with code like below will not work with new version since it is a big change. I worry about this because I have had problems in past with Toolset making changes that were incompatible and website doesn't work the way it should. It was a big problem.
<div class="entry-body"> <?php // START THE LOOP: // Toolset > WordPress Archive > Practice Areas-taxonomy-archive if (isset($_GET['l']) && is_numeric($_GET['l'])){ while ( have_posts() ) : the_post(); endwhile; ?> </div><!-- .entry-body --> <div class="practice-areas tablet-right"> <h2>Practice Areas</h2> <?php echo do_shortcode( '[menu name="practice"]' ); ?> </div> <div class="award-badges tablet-right"> <?php $term = wp_get_post_terms( $_GET['l'], 'attorney-tax' ); echo do_shortcode( '[wpv-view name="view-for-award-badges-2" wpvattorneytax='.$term[0]->slug.']' ); ?> </div>
Do you think I will have any problems with my old code? Shortcode syntax? Look at this previous support thread as an example of the kind of problems I had https://toolset.com/forums/topic/recent-updates-broke-custom-post-type-setup/
I don't think there is any problem with your old code, the Shortcode syntax is correct.
Is there any problem with this code after you upgrade Toolset plugins?
OK I did the upgrade to Types 3.0.1 and Views 2.6.1 and it broke my pages that use this custom template file:
hidden link
Here's an example of broken page:
hidden link
The loop section doesn't do anything anymore, leaving a blank content area.
<div class="entry-body"> <?php // START THE LOOP: // Toolset > WordPress Archive > Practice Areas-taxonomy-archive if (isset($_GET['l']) && is_numeric($_GET['l'])){ while ( have_posts() ) : the_post(); endwhile; ?> </div><!-- .entry-body -->
Since it is a custom codes problem, please provide the credentials and ftp access of your website in below, or you can provide a copy of your website:
https://toolset.com/faq/provide-supporters-copy-site/
I need to debug it in a live website, thanks
Thanks for the details, the credentials is not valid, I am downloading the duplicator package files, will feedback if there is anything found
Here are what I found, I can not login the website in my localhost too.
I have to fix it like this:
1) Rename the folder "wp-content" to "wp-content-bak"
2) Login
3) Dashboard-> Plugins, refresh the page, this will be able to disable all plugins
4) Then activate Toolset plugins
The original problem of this thread is in your custom shortcodes [if-check-count] and [1-if-check-taxonomy], you can try these:
1) Edit the view "Cases status - menu"
hidden link
in section "Loop Editor", and remove the shortcodes:
[if-check-count]
Same as above edit the view "Practice Areas - tax", remove the shortcode
[1-if-check-taxonomy]
And test again.
I'm sorry about the credentials. I forgot that you would need the password to login to duplicator package. I had supplied the admin login in my previous ticket and it had not been changed. I don't know if you can access that information. Otherwise, you could use PHPmyadmin to edit the toolset user password.
I'm not sure how to edit the view as you are describing. Here is the current view code:
<!-- Views / Cases status menu --> [wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --> <ul class="case-list-menu"> <wpv-loop> [if-check-count view_name="cases-count-for-case-status" practicearea="[wpv-post-taxonomy-practice-area]" l="[wpv-post-slug]"] <li><a href="#[wpv-taxonomy-slug]">[wpv-taxonomy-title]</a></li> [/if-check-count] </wpv-loop> </ul> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end]
The if-check-count is there, I think, to keep it from listing empty practice areas for the lawyer defined for that page. Can you edit the code to show how if should be written? Also, here is the other view code:
<!-- views / Practice Areas – tax --> [wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --> <wpv-loop> [if-check-taxonomy view_name="practice-areas-tax" taxonomy="[wpv-taxonomy-slug]"] [wpv-view name="Cases status"] [/if-check-taxonomy] </wpv-loop> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-taxonomy-found][wpml-string context="wpv-views"]<strong>No taxonomy found</strong>[/wpml-string][/wpv-no-taxonomy-found] [wpv-layout-end]
As I mentioned above, it is the problem of your custom shortcode [if-check-count] and [if-check-taxonomy], you can simply remove them and test again, for example, edit it from:
[if-check-count view_name="cases-count-for-case-status" practicearea="[wpv-post-taxonomy-practice-area]" l="[wpv-post-slug]"] <li><a href="#[wpv-taxonomy-slug]">[wpv-taxonomy-title]</a></li> [/if-check-count]
To:
<li><a href="#[wpv-taxonomy-slug]">[wpv-taxonomy-title]</a></li>
The credentials you provided above is not valid, I can not login your website, the login form of your website does not display any error message, so you will need to test it by yourself.
That did not work. See screenshot (new-wrong.jpg) of this page:
hidden link
In the top part, it generated an unfiltered list of all the Status taxonomies. Some do not apply to this particular Attorney or to this particular Practice Area.
The bottom part still doesn't work at all - just blank.
The top part should have listed just these 5 Status:
- Charges Dismissed Before Warrant Issued
- Charges Dismissed After Warrant Issued
- Charges Dismissed After Indictment Issued
- Charges Reduced After Indictment
- Jury Trials - Not Guilty Verdicts
The bottom part should have listed all the cases for that Attorney and that Practice Area grouped by the different Status.
Are you able to retrieve the login credentials from my previous ticket?
https://toolset.com/forums/topic/incorrect-view-output/
If not, I can reset the password so you can login.
I can get the credentials in that thread, I am checking it in your website, will update this thread if there is anything found
Here are what I found
1) The top part, it should be the view "Cases status - menu":
hidden link
As I mentioned above, the custom shortcode [if-check-count] does not work, it display the blank in the top part,
2) The bottom part, it should be the view "Practice Areas - tax":
hidden link
the custom shortcode if-check-taxonomy] does not work, it display the blank in the bottom part,
both of them are using different custom codes from your post:
https://toolset.com/forums/topic/updating-without-breaking-things/#post-919065
So they are different custom codes problem,
Can you confirm it?
and the custom codes are in your theme file "functions.php", line 338~395:
//workaround for wpv-if statement when evaluating views results add_shortcode( 'if-check-count', 'if_check_count_shortcode' ); ... add_shortcode('if-check-taxonomy','if_check_taxonomy_shortcode'); ...
Can you confirm it?
Yes. Here is the custom functions code created by Anna Couto at Toolset:
// TOOLSET FUNCTIONS //--------------------------------------------------------------------------------------------- // get the post slug add_shortcode('wpv-post-slug', 'wpv_post_slug_shortcode'); function wpv_post_slug_shortcode($atts) { extract( shortcode_atts( array(), $atts ) ); $out = ''; if (!empty($_GET['l']) && is_numeric($_GET['l'])) { $out = get_post_field('post_name', $_GET['l'], 'raw'); } return $out; } //workaround for wpv-if statement when evaluating views results add_shortcode( 'if-check-count', 'if_check_count_shortcode' ); function if_check_count_shortcode( $atts, $content = null ) { if ( ! empty ( $atts['view_name'] ) ) { $args = array( 'name' => $atts['view_name'] ); if ( ! empty ( $atts['current_post'] ) ) { $current_post = $atts['current_post']; $attorney_terms = get_the_terms( $atts['current_post'], 'attorney-tax' ); if ( is_array( $attorney_terms ) ) { foreach ( $attorney_terms as $attorney ) { $args['attorneytax'] = $attorney->slug; break; } } } else { $current_post = ''; } if ( ! empty ( $atts['practicearea'] ) ) { $args['practicearea'] = $atts['practicearea']; } if ( ! empty ( $atts['l'] ) ) { $args['l'] = $atts['l']; } add_filter( 'wpv_filter_' . str_replace( '-', '_', $atts['view_name'] ), 'wpv_filter_' . str_replace( '-', '_', $atts['view_name'] ) . '_func' ); $string = str_replace( array( "\n", "\r", "\t" ), '', render_view( $args ) ); remove_filter( 'wpv_filter_' . str_replace( '-', '_', $atts['view_name'] ), 'wpv_filter_' . str_replace( '-', '_', $atts['view_name'] ) . '_func' ); $result = preg_match( '/<div\sid="wpv-view-.*>(.*?)<\/div>/', $string, $match ); if ( $result && isset( $match[1] ) ) { sscanf( $match[1], '%d', $count ); if ( is_numeric( $count ) && 0 === $count ) { $content = ''; } } } return do_shortcode( $content ); } add_shortcode('if-check-taxonomy','if_check_taxonomy_shortcode'); function if_check_taxonomy_shortcode($atts, $content=null) { extract( shortcode_atts( array( 'view_name' => '', 'taxonomy' => '', ), $atts ) ); if ($view_name == 'practice-areas-tax') { $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); if (isset($term->slug) && $term->slug == $taxonomy) { } else { $content = ''; } } return do_shortcode($content); } add_shortcode('wpv-post-taxonomy-practice-area', 'wpv_post_taxonomy_practice_area_shortcode'); function wpv_post_taxonomy_practice_area_shortcode($atts) { $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); return $term->slug; } //filter hook to allow execution of view filter code function wpv_filter_cases_count_for_case_status_func($filter) { return true; } // filter properly the 'cases-count-for-case-status' view add_action('pre_get_posts', 'filter_cases_count_for_case_status'); function filter_cases_count_for_case_status($query) { if (!isset($query -> query_vars['post_type'])) $query -> query_vars['post_type'] = false; if (!is_admin() && is_array($query->query_vars['post_type']) && in_array('cases', $query->query_vars['post_type'])) { $taxonomies = array( 'attorney-tax'=>array('url_param'=>'l', 'type'=>'post_id'), 'practice-area'=>array('url_param'=>'practice-area', 'type'=>'slug') ); $enter_filter = apply_filters('wpv_filter_cases_count_for_case_status', false); if ($enter_filter) { $tax_query = $query->query_vars['tax_query']; $tax_query_values = array_key_values('taxonomy', $tax_query); foreach ($taxonomies as $taxonomy=>$settings) { if (!in_array($taxonomy, $tax_query_values)) { $terms = array(); switch ($settings['type']) { case 'post_id': if (isset($_GET[$settings['url_param']]) && is_numeric($_GET[$settings['url_param']])) { $post_name = get_post_field('post_name', $_GET[$settings['url_param']], 'raw'); if (!empty($post_name)) { $terms = get_term_by('slug', $post_name, $taxonomy); if ($terms) { $terms = array($terms->term_id); } } } break; case 'slug': $slug = ''; $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); if ($term->taxonomy == $taxonomy) { $slug = $term->slug; } if (!empty($slug)) { $terms = get_term_by('slug', $slug, $taxonomy); if ($terms) { $terms = array($terms->term_id); } } break; } if (!is_array($terms)) { $terms = array(); } $tax_query[] = array( 'taxonomy' => $taxonomy, 'field' => 'id', 'terms' => $terms, 'operator'=> 'IN' ); } } $query->set('tax_query', $tax_query); } } } // recursive get array values by key function array_key_values($needle, $haystack) { $output = array(); foreach($haystack as $key => $value){ if($key === $needle && !is_array($value)){ $output[] = $value; } else if (is_array($value)) { $output = array_merge($output, array_key_values($needle, $value)); } } return $output; } // dequeue wp-types front-end scripts and stylesheets add_action( 'wp_enqueue_scripts', 'prefix_remove_views_assets', 20 ); function prefix_remove_views_assets() { // Scripts // views_front_end_utils.js - used in Views parametric searches wp_deregister_script( 'wpv-front-end-utils' ); // wpv-pagination-embedded.js - used in Views pagination and table sorting wp_deregister_script( 'views-pagination-script' ); // jquery.ui.datepicker.min.js and wpv-date-front-end-control.js - used in Views parametric searches by a date field wp_deregister_script( 'jquery-ui-datepicker' ); wp_deregister_script( 'wpv-date-front-end-script' ); // Styles // wpv-views-sorting.css - used in Views table sorting wp_deregister_style( 'views-table-sorting-style' ); // wpv-pagination.css -used in Views pagination wp_deregister_style( 'views-pagination-style' ); } // NAKED VIEWS OUTPUT WITH NO WRAPPER DIVS add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 ); function prefix_clean_view_output( $out, $id ) { if ( $id == '820' ) { //Please adjust to your Views ID $start = strpos( $out, '<!-- wpv-loop-start -->' ); if ( $start !== false && strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false ) { $start = $start + strlen( '<!-- wpv-loop-start -->' ); $out = substr( $out , $start ); $end = strrpos( $out, '<!-- wpv-loop-end -->' ); $out = substr( $out, 0, $end ); } } return $out; }