Zadejte hledaný výraz...

Po aktualizaci WordPress přestal fungovat widget

Markussius
verified
rating uzivatele
15. 5. 2016 10:36:14
Zdravím, potřeboval bych poradit s widgetem, který mi přistal fungovat po aktualizaci WP.. Nechce se vůbec zobrazit v sidebaru... Snažil jsem googlovat atd, ale zatím sem na nic nepřišel.. :( Děkuji za každou pomoc
/**
* DP Posts Widget
*
* Display posts in various ways you'd like.
*
* @package deTube
* @subpackage Widgets
* @since deTube 1.0
*/
class DP_Widget_Posts extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget-posts', 'description' => __( "Display posts in various ways you'd like.", 'dp') );
parent::__construct('dp-widget-posts', __('(DeDePress) Query Posts', 'dp'), $widget_ops);
$this->alt_option_name = 'alt_dp_widget_posts';
add_action( 'save_post', array(&$this, 'flush_widget_cache') );
add_action( 'deleted_post', array(&$this, 'flush_widget_cache') );
add_action( 'switch_theme', array(&$this, 'flush_widget_cache') );
}
function widget($args, $instance) {
$cache = wp_cache_get('dp_widget_posts', 'widget');
if ( !is_array($cache) )
$cache = array();
if ( ! isset( $args ) )
$args = $this->id;
if ( isset( $cache ] ) ) {
echo $cache ];
return;
}
$style = isset($instance) ? $instance : 'list';
extract($args);
ob_start();
$title = apply_filters('widget_title', empty($instance) ? __('Recent Posts', 'dp') : $instance, $instance, $this->id_base);
$query_args = $instance;
$query_args = true;
$query_args = dp_parse_query_args($query_args);
$r = new WP_Query( apply_filters( 'dp_widget_posts_args', $query_args ) );
if ($r->have_posts()) : ?>
    have_posts()) : $r->the_post(); $item_format = is_video() ? 'video' : 'post'; ?>
// Reset the global $the_post as this query will have stomped on it
wp_reset_postdata();
endif;
$cache] = ob_get_flush();
wp_cache_set('dp_widget_posts', $cache, 'widget');
}
function update( $new_instance, $old_instance ) {
$new_instance = strip_tags($new_instance);
$new_instance = (int) $new_instance;
$new_instance = isset($new_instance);
$new_instance = isset($new_instance);
$this->flush_widget_cache();
$alloptions = wp_cache_get( 'alloptions', 'options' );
if ( isset($alloptions) )
delete_option('alt_dp_widget_posts');
return $new_instance;
}
function flush_widget_cache() {
wp_cache_delete('dp_widget_posts', 'widget');
}
function form( $instance ) {
$defaults = array(
'title' => __('Recent Posts', 'dp'),
'posts_per_page' => 6,
'orderby' => 'date',
'order' => 'desc',
'style' => 'list',
'cat' => '',
'current_cat' => true,
'current_author' => true,
'post__in' => '',
'views_timing' => '',
'style' => 'list', // list, list-full, grid-2 or grid-3
);
$instance = wp_parse_args( (array) $instance, $defaults );
// Styles
$styles = array(
'list' => __( 'List with Thumbnail', 'dp' ),
'list-full' => __( 'List with Full Width Thumbnail', 'dp' ),
'grid-2' => __( '2 Columns Grid', 'dp' ),
'grid-3' => __( '3 Columns Grid', 'dp' )
);
$views_timings = dp_views_timings();
$dropdown_categories = wp_dropdown_categories(array(
'echo' => 0,
'name' => $this->get_field_name( 'cat' ),
'selected' => $instance,
'show_option_all' => __('All', 'dp'),
'class' => 'widefat'
));
$dropdown_sort_types = dp_dropdown_sort_types(array(
'echo' => 0,
'name' => $this->get_field_name( 'orderby' ),
'selected' => $instance,
'class' => 'widefat'
));
$dropdown_order_types = dp_dropdown_order_types(array(
'echo' => 0,
'name' => $this->get_field_name( 'order' ),
'selected' => $instance,
'class' => 'widefat'
)); ?>

/> 

/> 

if this field is not empty, category will be ignored.
If you want to display posts sort by the order of your enter IDs, set "Sort" field as None.', 'dp'); ?>

}
// Register Widget
add_action('widgets_init', 'register_dp_widget_posts');
function register_dp_widget_posts() {
register_widget('DP_Widget_Posts');
}
15. 5. 2016 10:36:14
https://webtrh.cz/diskuse/po-aktualizaci-wordpress-prestal-fungovat-widget/#reply1195935
kybernaut.cz
verified
rating uzivatele
(12 hodnocení)
22. 5. 2016 16:14:39
Zkoušels WP_DEBUG, píše ti to něco?
22. 5. 2016 16:14:39
https://webtrh.cz/diskuse/po-aktualizaci-wordpress-prestal-fungovat-widget/#reply1195934
Markussius
verified
rating uzivatele
24. 5. 2016 21:57:53
ne e to sem nikdy nezkoušel ani nevím jak se to přesně dělá ...
---------- Příspěvek doplněn 25.05.2016 v 00:34 ----------
Napsal Karolína Vyskočilová;1293814
Zkoušels WP_DEBUG, píše ti to něco?
Už sem něco vypátral v šabloně soubor functions.php
Hlásí to chybu v tomto řádku:
Tuto chybu : Incorrect Use of is_main_query()
In pre_get_posts, use the WP_Query->is_main_query() method, not the is_main_query() function. See https://codex.wordpress.org/Function_Reference/is_main_query.
This message was added in version 3.7.
Zkusil jsem upravit kod na if($query->is_main_query() && !empty($selected_sort_types) && empty($orderby)) {
Žádná změna widget prostě není vidět. Ale chyba se už neobjevuje
24. 5. 2016 21:57:53
https://webtrh.cz/diskuse/po-aktualizaci-wordpress-prestal-fungovat-widget/#reply1195933
Pro odpověď se přihlašte.
Přihlásit