jueves, 7 de julio de 2016

How to fix deTube theme to make it work with Wordpress 4.5.x


If you have an outdated version of WordPress on your site because you can't update deTube theme, then I will show you how to fix it.

There are two fixes to be done, one for the section boxes on the home page and another one for the sidebar.

To fix home page boxes you have to edit the file
wordpress/wp-content/themes/detube/functions.php and add the line $args[‘title’] = ”; below the line $args['posts_per_page'] = $posts_per_page;


/**
* Output a Section Box
*
* @since deTube 1.0
*/

function dp_section_box($args = array()) {
$defaults = array(
'post_type' => 'post',
'cat' => '',
'taxonomies' => array(),
'view' => 'grid-small',
'title' => '',
'link' => '',
'post__in' => '',
'posts_per_page' => '',
'hide_if_empty' => false
);
$args = wp_parse_args($args, $defaults);
extract($args);

$posts_per_page = absint($posts_per_page);

// Set default posts number if no specified
if(empty($posts_per_page)) {
if($view == 'grid-mini')
$posts_per_page = 8;
elseif($view == 'grid-small')
$posts_per_page = 6;
elseif($view == 'grid-medium')
$posts_per_page = 4;
elseif($view == 'list-small')
$posts_per_page = 3;
elseif($view == 'list-medium')
$posts_per_page = 2;
elseif($view == 'list-large')
$posts_per_page = 1;
}

$args['posts_per_page'] = $posts_per_page;
$args['title'] = ''; // fix WP 4.5 compatibility issue

$args = dp_parse_query_args($args);
$query = new WP_Query($args);
...
...
...
Now that we have the section boxe fixed, let's fix the sidebar...

Look for the file wordpress/wp-content/themes/detube/wordpress/wp-content/themes/detube/widgets/widget-posts.php, there go around line 43, below $query_args['no_found_rows'] = true; add the line $query_args['title'] = '';


...
...
...


extract($args);

ob_start();

$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'dp') : $instance['title'], $instance, $this->id_base);

$query_args = $instance;
$query_args['no_found_rows'] = true;
$query_args['title'] = '';
$query_args = dp_parse_query_args($query_args);

$r = new WP_Query( apply_filters( 'dp_widget_posts_args', $query_args ) );

...
...
...

I hope this help some people, if so please let me know in the comments.
PS: I am available for freelance work ;)
Bitcoin donations 1PvQBKRayC7URnwFivrgJS2EVnFptuy9KP




15 comentarios:

  1. Hi,
    I checked the fix and that worked fine on my theme child!
    Thnks man.
    I was wordering if isn't could be useful to upload the full theme upfix to github in order to allow community continue to improving that theme...?

    ResponderEliminar
    Respuestas
    1. Themeforest license does not allow to do that :( otherwise I wouldn't mind to upload it to github

      Eliminar
    2. Hi,
      that will not be true at all because the author has abandoned the theme and the final version he delivered it is not fully compatible anymore. So this could be a good argument to free the theme and make it open source in benefit of actual users...

      Eliminar
  2. thanks you soo much Gustavo !!! you rock ;)

    ResponderEliminar
  3. Thank you SOOOO much! bugs originated by the same reasons caused our author.php page to malfunction, and now it's fixed! I'm so glad I found your blog!

    ResponderEliminar
  4. Thanks so much! Also fixed author.php!

    ResponderEliminar
  5. me i am having problem in widget-comment.php
    there is a function...anyway i guess that how it's called and they say its obsolete and _construct() should be used instead, plz help

    ResponderEliminar
  6. Amazing dear, thank you verrrrrrrrrrrrrrrrrrrry much..its worked

    ResponderEliminar
  7. it is not working .. can you please help check and see?
    websites: love4shares.info

    ResponderEliminar
  8. THANK YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU !!!!!!

    ResponderEliminar
  9. Thank youuuu from Brazil!!!!!!!!!!!!!!

    ResponderEliminar