Update php code in function.php
-
Hi, a have php scripts. In updates it is not working. How I updates script to working in newest plugin?
if (!function_exists('get_most_viewedDen')) { function get_most_viewedDen($mode = '', $limit = 16, $chars = 0, $display = true) { $start_date = mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 3, date("Y")); $cil_date = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")); echo "<small><strong>"; echo date_i18n("j.n.y G:i",time()-(60*60*24*3)); echo " - "; echo date_i18n("j.n.y G:i"); echo "</strong></small><br>"; echo "<ul>"; // echo "Aktualizace: " . date_i18n("d.m.Y G:i:s"); global $wpdb, $post; $views_options = get_option('views_options'); $where = ''; $temp = ''; $output = ''; if (!empty($mode) && $mode != 'both') { $where = "post_type = '$mode'"; } else { $where = '1=1'; } $date_limit = "post_date BETWEEN '" . date("Y-m-d H:i:s", $start_date) . "' AND '" . date("Y-m-d H:i:s", $cil_date) . "'"; $most_viewed = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE $date_limit AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit"); if ($most_viewed) { foreach ($most_viewed as $post) { $post_views = intval($post->views); $post_title = get_the_title(); if ($chars > 0) { $post_title = snippet_text($post_title, $chars); } $post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password, $chars); $post_content = get_the_content(); $temp = stripslashes($views_options['most_viewed_template']); $temp = str_replace("%VIEW_COUNT%", number_format_i18n($post_views), $temp); $temp = str_replace("%POST_TITLE%", $post_title, $temp); $temp = str_replace("%POST_EXCERPT%", $post_excerpt, $temp); $temp = str_replace("%POST_CONTENT%", $post_content, $temp); $temp = str_replace("%POST_URL%", get_permalink(), $temp); $output .= $temp; } } else { $output = '<li>' . __('N/A', 'wp-postviews') . '</li>' . "\n"; } if ($display) { echo $output; } else { return $output; } echo "</ul>"; } }
Thanks..
- The topic ‘Update php code in function.php’ is closed to new replies.