Сайт на WP это виджет дополнение темы. Кодировки в норме что может быть?
Нет тут такого места с var_dump. Это код виджета. Поставил стандартный все нормально, а вот с темы все те-же ? знаки.
<?php
class listingpro_TWRecentPostWidget extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'listingpro_TWRecentPostWidget', 'description' => 'listingpro recent posts.');
parent::__construct(false, 'listingpro recent posts', $widget_ops);
}
function widget($args, $instance) {
global $post;
extract(array(
'title' => '',
'number_posts' => 2,
'theme' => 'post_nothumbnailed',
'post_order' => 'latest',
'post_type' => 'post'
));
extract($args);
$title = apply_filters('widget_title', strip_tags($instance['title']));
$post_count = 2;
if (isset($instance['number_posts']))
$post_count = strip_tags($instance['number_posts']);
$q['posts_per_page'] = $post_count;
$cats = (array) $instance['post_category'];
$q['paged'] = 1;
$q['post_type'] = strip_tags($instance['post_type']);
if (count($cats) > 0) {
$typ = 'category';
if ($instance['post_type'] != 'post')
$typ = 'catalog';
$catq = '';
$sp = '';
foreach ($cats as $mycat) {
$catq = $catq . $sp . $mycat;
$sp = ',';
}
$catq = explode(',', $catq);
$q['tax_query'] = Array(Array(
'taxonomy' => $typ,
'terms' => $catq,
'field' => 'id'
)
);
}
if ($instance['post_order'] == 'commented')
$q['orderby'] = 'comment_count';
query_posts($q);
if (isset($before_widget))
echo wp_kses_post($before_widget);
if ($title != '')
echo wp_kses_post($args['before_title'] . $title . $args['after_title']);
echo '<div class="jw-recent-posts-widget">';
echo '<ul>';
while (have_posts ()) : the_post();
echo '<li>';
$class = "with-thumb";
if (isset($instance['theme']) && $instance['theme'] == 'post_thumbnailed') {
if (has_post_thumbnail($post->ID)) {
$lrg_img = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'listingpro-author-thumb');
$feat_img = $lrg_img[0];
$thumb_width = 105;
$thumb_height = 78;
echo '
<div class="recent-thumb image">
<img src="' . $feat_img . '" alt="' . get_the_title() . '"/>
</div>';
} else {
$class = "no-thumb";
}
} else {
$format = get_post_format() == "" ? "standard" : get_post_format();
echo '<div class="recent-thumb"><span class="post-format '.$format.'"></span></div>';
}
echo '<div class="jw-recent-content '.$class.'">';
echo '<h3><a href="'.get_the_permalink().'">'.substr(strip_tags(get_the_title()),0,20).'</a></h3>';
echo '<p>'.substr(strip_tags(get_the_content()),0,45).'.</p>';
echo '<div class="meta">';
esc_html_e("", "listingpro");
echo '<span class="date">'.get_the_date( ' j F' ).'</span>';
esc_html_e("", "listingpro");
echo'<a href="'.get_author_posts_url( get_the_author_meta( 'ID' ) ).'">
'.esc_html_e("By", "listingpro").'<span> '.get_the_author().'</span>
</a>';
echo '</div>';
echo '</div>';
echo '</li>';
endwhile;
echo '</ul>';
echo '</div>';
if (isset($after_widget))
echo wp_kses_post($after_widget);
wp_reset_query();
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
/* Strip tags (if needed) and update the widget settings. */
$instance['title'] = strip_tags($new_instance['title']);
if ($new_instance['post_type'] == 'post') {
$instance['post_category'] = $_REQUEST['post_category'];
} else {
$tax = get_object_taxonomies($new_instance['post_type']);
$instance['post_category'] = $_REQUEST['tax_input'][$tax[0]];
}
$instance['number_posts'] = strip_tags($new_instance['number_posts']);
$instance['post_type'] = strip_tags($new_instance['post_type']);
$instance['post_order'] = strip_tags($new_instance['post_order']);
$instance['theme'] = strip_tags($new_instance['theme']);
return $instance;
}
function form($instance) {
//Output admin widget options form
extract(shortcode_atts(array(
'title' => '',
'theme' => 'post_nothumbnailed',
'number_posts' => 2,
'post_order' => 'latest',
'post_type' => 'post'
), $instance));
$defaultThemes = Array(
Array("name" => 'Thumbnailed posts', 'user_func' => 'post_thumbnailed'),
Array("name" => 'Default posts', 'user_func' => 'post_nonthumbnailed')
);
$themes = apply_filters('jw_recent_posts_widget_theme_list', $defaultThemes);
$defaultPostTypes = Array(Array("name" => 'Post', 'post_type' => 'post')); ?>
<p>
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e("Title:", "listingpro");?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" value="<?php echo esc_attr($title); ?>" />
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('post_order')); ?>"><?php esc_html_e("Post order:", "listingpro");?></label>
<select class="widefat" id="<?php echo esc_attr($this->get_field_id('post_order')); ?>" name="<?php echo esc_attr($this->get_field_name('post_order')); ?>">
<option value="latest" <?php if ($post_order == 'latest') print 'selected="selected"'; ?>><?php esc_html_e("Latest posts", "listingpro");?></option>
<option value="commented" <?php if ($post_order == 'commented') print 'selected="selected"'; ?>><?php esc_html_e("Most commented posts", "listingpro");?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('theme')); ?>"><?php esc_html_e("Post theme:", "listingpro");?></label>
<select class="widefat" id="<?php echo esc_attr($this->get_field_id('theme')); ?>" name="<?php echo esc_attr($this->get_field_name('theme')); ?>">
<option value="post_thumbnailed" <?php if ($theme == 'post_thumbnailed') print 'selected="selected"'; ?>><?php esc_html_e("Thumbnail", "listingpro");?></option>
<option value="post_nothumbnailed" <?php if ($theme == 'post_nothumbnailed') print 'selected="selected"'; ?>><?php esc_html_e("No Thumbnail", "listingpro");?></option>
</select>
</p><?php
$customTypes = apply_filters('jw_recent_posts_widget_type_list', $defaultPostTypes);
if (count($customTypes) > 0) { ?>
<div id="custom-post-display" style="display:none"><p>
<label for="<?php echo esc_attr($this->get_field_id('post_type')); ?>"><?php esc_html_e("Post from:", "listingpro");?></label>
<select rel="<?php echo esc_attr($this->get_field_id('post_cats')); ?>" onChange="jw_get_post_terms(this);" class="widefat" id="<?php echo esc_attr($this->get_field_id('post_type')); ?>" name="<?php echo esc_attr($this->get_field_name('post_type')); ?>"><?php
foreach ($customTypes as $postType) { ?>
<option value="<?php print $postType['post_type'] ?>" <?php echo selected($post_type, $postType['post_type']); ?>><?php print $postType['name'] ?></option><?php
} ?>
</select>
</p></div><?php
} ?>
<p><?php esc_html_e("If you were not selected for cats, it will show all categories.", "listingpro");?></p>
<div id="<?php echo esc_attr($this->get_field_id('post_cats')); ?>" class="recent-post-plugins-style"><?php
$post_type='post';
$tax = get_object_taxonomies($post_type);
$selctedcat = false;
if (isset($instance['post_category']) && $instance['post_category'] != ''){
$selctedcat = $instance['post_category'];
}
wp_terms_checklist(0, array('taxonomy' => $tax[0], 'checked_ontop' => false, 'selected_cats' => $selctedcat)); ?>
</div>
<p>
<label for="<?php echo esc_attr($this->get_field_id('number_posts')); ?>"><?php esc_html_e("Number of posts to show:", "listingpro");?></label>
<input id="<?php echo esc_attr($this->get_field_id('number_posts')); ?>" name="<?php echo esc_attr($this->get_field_name('number_posts')); ?>" value="<?php echo esc_attr($number_posts); ?>" size="3" />
</p><?php
}
}
add_action('widgets_init', create_function('', 'return register_widget("listingpro_TWRecentPostWidget");'));
add_action('wp_ajax_themewave_recent_post_terms', 'get_post_type_terms');
function get_post_type_terms() {
$cat = 'post';
if (isset($_REQUEST['post_format']) && $_REQUEST['post_format'] != '')
$cat = $_REQUEST['post_format'];
$tax = get_object_taxonomies($cat);
wp_terms_checklist(0, array('taxonomy' => $tax[0], 'checked_ontop' => false, 'selected_cats' => false));
die;
} ?>
Тексты у вас в уникоде, а место, где обрезаются названия, не учитывает уникод. Русские символы в уникоде состоят из нескольких байт. Если не учитывать уникод и обрезать строку по байтам, то можно отрезать строку посередине символа. Такие дефектные символы обозначаются символом-заполнителем в виде ромба с вопросом.
Воспроизвести проблему очень просто:
var_dump(substr('Проверка', 0, 7));
Такой код выведет:
string(7) "Про�"
Такой проблемы нет у функции mb_substr, которая работаем с символами (или рунами, как их называют в Go):
var_dump(mb_substr('Проверка', 0, 7));
// выведет string(14) "Проверк"
Поищите по коду где укорачиваются названия постов. Там замените функцию substr на mb_substr.
Сборка персонального компьютера от Artline: умный выбор для современных пользователей