Wtyczka WP-PostViews
-
Witam, wie ktoś gdzie w tej wtyczce zamienia się, aby było
„wyświetleń” a nie „views”Jeżeli zamieniam w kodzie „view” na „wyświetleń”
'<strong>'.number_format($count).'</strong> '.plural($count, ' view');to działa tylko, że jest wtedy „wyświetleńs” dodaje s i nie wiem jak z tym mam sobie poradzić.
Cały kod wtyczki:
<?php /******************************************************************** Post Views by Kevin Chard over at WP-Snipp & Parts from Lesterchan ********************************************************************/ // function to display number of posts. function getPostViews_wpt2($postID){ $count_key = 'views'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 views"; } return '<strong>'.number_format($count).'</strong> '.plural($count, ' view'); } // function to count views. function setPostViews_wpt2($postID) { $count_key = 'views'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } // Function: Modify Default WordPress Listing To Make It Sorted By Post Views function views_fields_wpt2($content) { global $wpdb; $content .= ", ($wpdb->postmeta.meta_value+0) AS views"; return $content; } function views_join_wpt2($content) { global $wpdb; $content .= " LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID"; return $content; } function views_where_wpt2($content) { global $wpdb; $content .= " AND $wpdb->postmeta.meta_key = 'odsłon'"; return $content; } function views_orderby_wpt2($content) { $orderby = trim(addslashes(get_query_var('v_orderby'))); if(empty($orderby) || ($orderby != 'asc' && $orderby != 'desc')) { $orderby = 'desc'; } $content = " views $orderby"; return $content; } // Function: Views Public Variables add_filter('query_vars', 'views_variables_wpt2'); function views_variables_wpt2($public_query_vars) { $public_query_vars[] = 'v_sortby'; $public_query_vars[] = 'v_orderby'; return $public_query_vars; } // Function: Sort Views Posts add_action('pre_get_posts', 'views_sorting_wpt2'); function views_sorting_wpt2($local_wp_query) { if($local_wp_query->get('v_sortby') == 'views') { add_filter('posts_fields', 'views_fields_wpt2'); add_filter('posts_join', 'views_join_wpt2'); add_filter('posts_where', 'views_where_wpt2'); add_filter('posts_orderby', 'views_orderby_wpt2'); } else { remove_filter('posts_fields', 'views_fields_wpt2'); remove_filter('posts_join', 'views_join_wpt2'); remove_filter('posts_where', 'views_where_wpt2'); remove_filter('posts_orderby', 'views_orderby_wpt2'); } } // Show Top 5 Most Viewed function top_5_most_viewed_wpt2() { ?> <?php global $post; $args = array( 'meta_key' => 'views', 'posts_per_page'=> 5, 'ignore_sticky_posts' => 1, 'orderby' => 'meta_value_num', 'order' => 'DESC' ); $post_views_query = new WP_Query ($args); while ($post_views_query -> have_posts()) : $post_views_query -> the_post(); ?> <li> <div class="wptube-tabs-list-container"> <div class="tab_list_content"> <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"> <?php the_title(); ?> </a> <?php echo getPostViews_wpt2(get_the_ID()); ?> <?php comments_popup_link(__('Brak Komentarzy', 'wpt'), __('1 Komentarz', 'wpt'), __('% Komentarze', 'wpt')); ?> </div> <?php if ( has_post_thumbnail()) : ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php echo the_post_thumbnail( 'recent-post-thumbnail' ); ?></a> <?php else : ?> <?php print_recent_thumb($post); ?> <?php endif; ?> <div class="clear"></div> </div> </li> <?php endwhile;?> <?php wp_reset_query(); } ?>Pozdrawiam
Zobacz 2 odpowiedzi - od 1 do 2 (z 2 łącznie)
Zobacz 2 odpowiedzi - od 1 do 2 (z 2 łącznie)
Temat ‘Wtyczka WP-PostViews’ jest zamknięty na nowe odpowiedzi.