function tptn_daily_lists() { global $wpdb, $id; $is_widget = intval($_GET['is_widget']); if ($is_widget) { $output = tptn_pop_posts('daily=1&is_widget=1'); } else { $output = tptn_pop_posts('daily=1&is_widget=0'); } echo "document.write('" . $output . "')"; }
/** * Creates a shortcode [tptn_list limit="5" heading="1" daily="0"]. * * @since 1.9.9 * @param array $atts Shortcode attributes * @param string $content Content * @return string Formatted list of posts generated by tptn_pop_posts */ function tptn_shortcode($atts, $content = null) { global $tptn_settings; $atts = shortcode_atts(array_merge($tptn_settings, array('heading' => 1, 'daily' => 0, 'is_shortcode' => 1)), $atts, 'top-10'); return tptn_pop_posts($atts); }
<h1>by <?php the_author_posts_link(); ?> </h1> <?php echo get_the_author_meta('description'); ?> </div> </aside> <!--//.relatedInfo--> <?php $top_daily = tptn_pop_posts(array('is_widget' => FALSE, 'daily' => TRUE, 'echo' => FALSE, 'strict_limit' => TRUE, 'posts_only' => TRUE, 'limit' => 6)); ?> <?php if (count($top_daily)) { ?> <section class="recommendList02"> <h1>この記事を読んだ人は、こんな記事も読んでいます</h1> <ul> <?php foreach ($top_daily as $key => $dp) { // if ($key == 6) { // break; // } $item = get_post($dp->ID);
/** * Function to echo popular posts. * * @since 1.0 * * @param mixed $args Arguments list */ function tptn_show_pop_posts($args = NULL) { if (is_array($args)) { $args['manual'] = 1; } else { $args .= '&is_manual=1'; } echo tptn_pop_posts($args); }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ function widget($args, $instance) { global $wpdb, $tptn_url, $tptn_settings, $post; // Get the post meta $tptn_post_meta = get_post_meta($post->ID, 'tptn_post_meta', true); if (isset($tptn_post_meta['disable_here']) && 1 == $tptn_post_meta['disable_here']) { return; } $title = apply_filters('widget_title', empty($instance['title']) ? strip_tags($tptn_settings['title']) : $instance['title']); $limit = isset($instance['limit']) ? $instance['limit'] : $tptn_settings['limit']; if (empty($limit)) { $limit = $tptn_settings['limit']; } $daily_range = empty($instance['daily_range']) ? $tptn_settings['daily_range'] : $instance['daily_range']; $hour_range = empty($instance['hour_range']) ? $tptn_settings['hour_range'] : $instance['hour_range']; $daily = isset($instance['daily']) && "daily" == $instance['daily'] ? true : false; $output = $args['before_widget']; $output .= $args['before_title'] . $title . $args['after_title']; $post_thumb_op = isset($instance['post_thumb_op']) ? esc_attr($instance['post_thumb_op']) : 'text_only'; $thumb_height = isset($instance['thumb_height']) && '' != $instance['thumb_height'] ? intval($instance['thumb_height']) : $tptn_settings['thumb_height']; $thumb_width = isset($instance['thumb_width']) && '' != $instance['thumb_width'] ? intval($instance['thumb_width']) : $tptn_settings['thumb_width']; $disp_list_count = isset($instance['disp_list_count']) ? esc_attr($instance['disp_list_count']) : ''; $show_excerpt = isset($instance['show_excerpt']) ? esc_attr($instance['show_excerpt']) : ''; $show_author = isset($instance['show_author']) ? esc_attr($instance['show_author']) : ''; $show_date = isset($instance['show_date']) ? esc_attr($instance['show_date']) : ''; $post_types = isset($instance['post_types']) ? $instance['post_types'] : $tptn_settings['post_types']; $arguments = array('is_widget' => 1, 'heading' => 0, 'limit' => $limit, 'daily' => $daily, 'daily_range' => $daily_range, 'hour_range' => $hour_range, 'show_excerpt' => $show_excerpt, 'show_author' => $show_author, 'show_date' => $show_date, 'post_thumb_op' => $post_thumb_op, 'thumb_height' => $thumb_height, 'thumb_width' => $thumb_width, 'disp_list_count' => $disp_list_count, 'post_types' => $post_types); /** * Filters arguments passed to tptn_pop_posts for the widget. * * @since 2.0.0 * * @param array $arguments Widget options array */ $arguments = apply_filters('tptn_widget_options', $arguments); $output .= tptn_pop_posts($arguments); $output .= $args['after_widget']; echo $output; }
/** * Create the Dashboard Widget and content of the Popular pages * * @since 1.3 * * @param bool $daily Switch for Daily or Overall popular posts * @param int $page Which page of the lists are we on? * @param int $limit Maximum number of posts per page * @param bool $widget Is this a WordPress widget? * @return Formatted list of popular posts */ function tptn_pop_display($daily = FALSE, $page = 0, $limit = FALSE, $widget = FALSE) { global $wpdb, $siteurl, $tableposts, $id, $tptn_settings; $table_name = $wpdb->base_prefix . "top_ten"; if ($daily) { $table_name .= "_daily"; } // If we're viewing daily posts, set this to true if (!$limit) { $limit = $tptn_settings['limit']; } if (!$page) { $page = 0; } // Default page value. parse_str($tptn_settings['post_types'], $post_types); // Save post types in $post_types variable $results = tptn_pop_posts('posts_only=1&limit=99999&strict_limit=1&is_widget=1&exclude_post_ids=0&daily=' . $daily); $numrows = count($results); $pages = intval($numrows / $limit); // Number of results pages. // $pages now contains int of pages, unless there is a remainder from division. if ($numrows % $limit) { $pages++; } // has remainder so add one page $current = $page / $limit + 1; // Current page number. if ($pages < 1 || 0 == $pages) { $total = 1; // If $pages is less than one or equal to 0, total pages is 1. } else { $total = $pages; // Else total pages is $pages value. } $first = $page + 1; // The first result. if (!(($page + $limit) / $limit >= $pages) && $pages != 1) { $last = $page + $limit; //If not last results page, last result equals $page plus $limit. } else { $last = $numrows; // If last results page, last result equals total number of results. } $results = array_slice($results, $page, $limit); $output = '<div id="tptn_popular_posts">'; $output .= '<table width="100%" border="0"> <tr> <td width="50%" align="left">'; $output .= sprintf(__('Results %1$s to %2$s of %3$s', TPTN_LOCAL_NAME), '<strong>' . $first . '</strong>', '<strong>' . $last . '</strong>', '<strong>' . $numrows . '</strong>'); $output .= ' </td> <td width="50%" align="right">'; $output .= sprintf(__('Page %s of %s', TPTN_LOCAL_NAME), '<strong>' . $current . '</strong>', '<strong>' . $total . '</strong>'); $output .= ' </td> </tr> <tr> <td colspan="2" align="right"> </td> </tr> <tr> <td align="left">'; if ($daily && $widget || !$daily && !$widget) { $output .= '<a href="./admin.php?page=tptn_manage_daily">'; $output .= __('View Daily Popular Posts', TPTN_LOCAL_NAME); $output .= '</a></td>'; $output .= '<td align="right">'; if (!$widget) { $output .= __('Results per-page:', TPTN_LOCAL_NAME); } if (!$widget) { $output .= ' <a href="./admin.php?page=tptn_manage&limit=10">10</a> | <a href="./admin.php?page=tptn_manage&limit=20">20</a> | <a href="./admin.php?page=tptn_manage&limit=50">50</a> | <a href="./admin.php?page=tptn_manage&limit=100">100</a> '; } $output .= ' </td> </tr> <tr> <td colspan="2" align="right"><hr /></td> </tr> </table>'; } else { $output .= '<a href="./admin.php?page=tptn_manage">'; $output .= __('View Overall Popular Posts', TPTN_LOCAL_NAME); $output .= '</a></td>'; $output .= '<td align="right">'; if (!$widget) { $output .= __('Results per-page:', TPTN_LOCAL_NAME); } if (!$widget) { $output .= ' <a href="./admin.php?page=tptn_manage_daily&limit=10">10</a> | <a href="./admin.php?page=tptn_manage_daily&limit=20">20</a> | <a href="./admin.php?page=tptn_manage_daily&limit=50">50</a> | <a href="./admin.php?page=tptn_manage_daily&limit=100">100</a> '; } $output .= ' </td> </tr> <tr> <td colspan="2" align="right"><hr /></td> </tr> </table>'; } $dailytag = $daily ? '_daily' : ''; $output .= '<ul>'; if ($results) { foreach ($results as $result) { $output .= '<li><a href="' . get_permalink($result['postnumber']) . '">' . get_the_title($result['postnumber']) . '</a>'; $output .= ' (' . number_format_i18n($result['sumCount']) . ')'; $output .= '</li>'; } } $output .= '</ul>'; $output .= '<p align="center">'; if (0 != $page) { // Don't show back link if current page is first page. $back_page = $page - $limit; $output .= "<a href=\"./admin.php?page=tptn_manage{$dailytag}&paged={$back_page}&daily={$daily}&limit={$limit}\">« "; $output .= __('Previous', TPTN_LOCAL_NAME); $output .= "</a>\n"; } $pagination_range = 4; for ($i = 1; $i <= $pages; $i++) { // loop through each page and give link to it. if ($i >= $current + $pagination_range && $i < $pages) { if ($i == $current + $pagination_range) { $output .= '… '; } continue; } if ($i < $current - $pagination_range + 1 && $i < $pages) { continue; } $ppage = $limit * ($i - 1); if ($ppage == $page) { $output .= "<span class='current'>{$i}</span>\n"; // If current page don't give link, just text. } else { $output .= "<a href=\"./admin.php?page=tptn_manage{$dailytag}&paged={$ppage}&daily={$daily}&limit={$limit}\">{$i}</a> \n"; } } if (!(($page + $limit) / $limit >= $pages) && $pages != 1) { // If last page don't give next link. $next_page = $page + $limit; $output .= "<a href=\"./admin.php?page=tptn_manage{$dailytag}&paged={$next_page}&daily={$daily}&limit={$limit}\">"; $output .= __('Next', TPTN_LOCAL_NAME); $output .= " »</a>"; } $output .= '</p>'; $output .= '<p style="text-align:center;border-top: #000 1px solid">Popular posts by <a href="http://ajaydsouza.com/wordpress/plugins/top-10/">Top 10 plugin</a></p>'; $output .= '</div>'; return apply_filters('tptn_pop_display', $output); }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ function widget($args, $instance) { global $wpdb, $tptn_url, $tptn_settings; extract($args, EXTR_SKIP); $title = apply_filters('widget_title', empty($instance['title']) ? strip_tags($tptn_settings['title']) : $instance['title']); $limit = isset($instance['limit']) ? $instance['limit'] : $tptn_settings['limit']; if (empty($limit)) { $limit = $tptn_settings['limit']; } $daily_range = empty($instance['daily_range']) ? $tptn_settings['daily_range'] : $instance['daily_range']; $hour_range = empty($instance['hour_range']) ? $tptn_settings['hour_range'] : $instance['hour_range']; $daily = isset($instance['daily']) && "daily" == $instance['daily'] ? true : false; $output = $before_widget; $output .= $before_title . $title . $after_title; $post_thumb_op = isset($instance['post_thumb_op']) ? esc_attr($instance['post_thumb_op']) : 'text_only'; $thumb_height = isset($instance['thumb_height']) ? esc_attr($instance['thumb_height']) : $tptn_settings['thumb_height']; $thumb_width = isset($instance['thumb_width']) ? esc_attr($instance['thumb_width']) : $tptn_settings['thumb_width']; $disp_list_count = isset($instance['disp_list_count']) ? esc_attr($instance['disp_list_count']) : ''; $show_excerpt = isset($instance['show_excerpt']) ? esc_attr($instance['show_excerpt']) : ''; $show_author = isset($instance['show_author']) ? esc_attr($instance['show_author']) : ''; $show_date = isset($instance['show_date']) ? esc_attr($instance['show_date']) : ''; $arguments = array('is_widget' => 1, 'heading' => 0, 'limit' => $limit, 'daily' => $daily, 'daily_range' => $daily_range, 'hour_range' => $hour_range, 'show_excerpt' => $show_excerpt, 'show_author' => $show_author, 'show_date' => $show_date, 'post_thumb_op' => $post_thumb_op, 'thumb_height' => $thumb_height, 'thumb_width' => $thumb_width, 'disp_list_count' => $disp_list_count); /** * Filters arguments passed to tptn_pop_posts for the widget. * * @since 2.0.0 * * @param array $arguments Widget options array */ $arguments = apply_filters('tptn_widget_options', $arguments); if ($daily) { if ($tptn_settings['d_use_js']) { $output .= '<script type="text/javascript" src="' . $tptn_url . '/top-10-daily.js.php?widget=1"></script>'; } else { $output .= tptn_pop_posts($arguments); } } else { $output .= tptn_pop_posts($arguments); } $output .= $after_widget; echo $output; }
function widget($args, $instance) { global $wpdb, $tptn_url; extract($args, EXTR_SKIP); global $tptn_settings; $title = apply_filters('widget_title', empty($instance['title']) ? strip_tags($tptn_settings['title']) : $instance['title']); $limit = $instance['limit']; if (empty($limit)) { $limit = $tptn_settings['limit']; } $daily_range = empty($instance['daily_range']) ? $tptn_settings['daily_range'] : $instance['daily_range']; $daily = $instance['daily'] == "daily" ? true : false; $output = $before_widget; $output .= $before_title . $title . $after_title; if ($daily) { if ($tptn_settings['d_use_js']) { $output .= '<script type="text/javascript" src="' . $tptn_url . '/top-10-daily.js.php?widget=1"></script>'; } else { $output .= tptn_pop_posts(array('is_widget' => 1, 'limit' => $limit, 'daily' => 1, 'daily_range' => $daily_range, 'show_excerpt' => $instance['show_excerpt'], 'show_author' => $instance['show_author'], 'show_date' => $instance['show_date'], 'post_thumb_op' => $instance['post_thumb_op'], 'thumb_height' => $instance['thumb_height'], 'thumb_width' => $instance['thumb_width'])); } } else { $output .= tptn_pop_posts(array('is_widget' => 1, 'limit' => $limit, 'daily' => 0, 'daily_range' => $daily_range, 'show_excerpt' => $instance['show_excerpt'], 'show_author' => $instance['show_author'], 'show_date' => $instance['show_date'], 'post_thumb_op' => $instance['post_thumb_op'], 'thumb_height' => $instance['thumb_height'], 'thumb_width' => $instance['thumb_width'])); } $output .= $after_widget; echo $output; }
/** * generates the featured posts mini-boxes * * @api * * @return string */ function multiloquent_paralax_featured_sliders() { global $wpdb; $output = ''; $total_posts = '4'; if (function_exists('tptn_pop_posts')) { $args = array('is_widget' => false, 'daily' => false, 'echo' => false, 'strict_limit' => $total_posts, 'posts_only' => true); // todo - this needs to be an array of objects.. $top_ten_post_array = tptn_pop_posts($args); foreach ($top_ten_post_array as $post => $val) { $posts_to_get[] = $val['ID']; } // set to 4 items as the strict_limit doesnt appear to work correctly.. $posts_to_get = array_slice($posts_to_get, 0, 4); $args = array('post__in' => $posts_to_get); $recent_posts = get_posts($args); } else { $args = array('numberposts' => $total_posts, 'offset' => 0, 'category' => '', 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'post_type' => 'post', 'post_status' => 'publish'); $recent_posts = get_posts($args); } $count = 1; $output = '<div class="featured-posts">'; $colour = $this->multiloquent_get_random_blue_class(); foreach ($recent_posts as $val) { $slider_image = wp_get_attachment_image_src(get_post_thumbnail_id($val->ID), 'single-post-thumbnail'); if ($slider_image) { $theimg = $slider_image[0]; } else { $theimg = get_header_image(); } if ($count == '1' || $count == '2') { $output .= '<div class="paralax_image_holder halfheight col-sm-6 col-md-3 col-lg-3 alpha omega">'; } else { $output .= '<div class="paralax_image_holder halfheight hidden-xs hidden-sm col-md-3 col-lg-3 alpha omega">'; } $output .= '<span style="background-image:url(' . $theimg . ');" class="grayscale"></span>'; $output .= '<div class="paralax_image_bg halfheight ' . $colour . '"></div>'; $output .= '<div class="paralax_image_text halfheight">'; $output .= '<span class="h1"><a href="' . get_permalink($val->ID) . '">' . $this->multiloquent_post_title($val->ID) . '</a></span>'; $output .= '</div></div>'; $count++; } $output .= '</div>'; return $output; }