public function widget($args, $instance) { $number_of_episodes = is_numeric($instance['number_of_episodes']) ? $instance['number_of_episodes'] : 10; // Fallback for old browsers that allow a non-numeric string to be entered in the "number_of_episodes" field $episodes = array_slice(Episode::find_all_by_time(['post_status' => ['private', 'publish']]), 0, $number_of_episodes); echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; } echo "<ul style='list-style-type: none;'>"; foreach ($episodes as $episode) { $post = get_post($episode->post_id); $episode_duration = new \Podlove\Duration($episode->duration); ?> <li> <?php if ($instance['show_image']) { ?> <img src="<?php echo $episode->cover_art_with_fallback()->setWidth(400)->url(); ?> " alt="<?php echo $post->post_title; ?> " style="width: 20%; vertical-align: top; margin-right: 2%;"/> <div style="display: inline-block; width: 75%;"> <?php } ?> <p> <a href="<?php echo post_permalink($episode->post_id); ?> "><?php echo $post->post_title; ?> </a><br /> <i class="podlove-icon-calendar"></i> <?php echo get_the_date(get_option('date_format'), $episode->post_id); ?> <?php if ($instance['show_duration']) { echo "<br /><i class='podlove-icon-time'></i> " . $episode_duration->get('human-readable'); } ?> </p> <?php if ($instance['show_image']) { ?> </div> <?php } ?> </li> <?php } echo "</ul>"; echo $args['after_widget']; }
function featured_image_archive() { if (has_post_thumbnail()) { echo '<div id = "featured-post-archive-image">'; echo '<a href = "' . post_permalink($post->{$ID}) . '">'; the_post_thumbnail($post->ID, 'feature-post-archive'); echo '</a>'; echo '</div>'; } }
/** * Filter to added content to the bottom of rss feeds * * @param string $content The content of the page/post in the rrs feed. * * @author Matt Rude <*****@*****.**> * @package Gus Theme * @subpackage Feed Footer * @since 0.2 */ function mdr_postrss($content) { if (is_feed()) { $site_name = get_bloginfo_rss('name'); $post_title = get_the_title_rss(); $home_url = home_url('/'); $post_url = post_permalink(); $content = $content . '<a href="' . $post_url . '">' . $post_title . '</a> is a post from; <a href="' . $home_url . '">' . $site_name . '</a> which is not allowed to be copied on other sites.'; } return $content; }
function update_recipes_request() { if (!empty($_POST["id"])) { $post_id = $_POST["id"]; $post = get_post($post_id); $url = post_permalink($post_id); $ingredients = get_post_meta($post_id, 'RECIPE_META_ingredients', true); $nutrition_facts = process_request($ingredients); if (isValid($nutrition_facts)) { if (!add_post_meta($post_id, META_KEY, $nutrition_facts, true)) { update_post_meta($post_id, META_KEY, $nutrition_facts); } echo json_encode(array('ID' => $post->ID, 'post_title' => $post->post_title, 'url' => $url, 'success' => true, 'error' => false, 'message' => 'Update successful.')); } else { echo json_encode(array('ID' => $post->ID, 'post_title' => $post->post_title, 'url' => $url, 'success' => false, 'error' => true, 'message' => 'Update unsuccessful.')); } } die; }
/** * Output Social Sharing Links * ----------------------------------------------------------------------------- * @category PHP Script * @package Kaitain * @author Mark Grealish <*****@*****.**> * @copyright Copyright (c) 2014-2015, Tuairisc Bheo Teo * @license https://www.gnu.org/copyleft/gpl.html The GNU GPL v3.0 * @version 2.0 * @link https://github.com/bhalash/kaitain-theme * @link http://www.tuairisc.ie */ function kaitain_share_links() { global $post; if (!($post = get_post($post))) { return false; } $post_info = array('blog' => urlencode(get_bloginfo('name')), 'url' => urlencode(post_permalink($post->ID)), 'title' => urlencode($post->post_title), 'tuser' => 'tuairiscnuacht'); $services = array('print' => array('title' => 'Print %s', 'href' => 'javascript:window.print()', 'target' => '', 'reqires' => null), 'twitter' => array('title' => 'Tweet %s', 'href' => sprintf('//twitter.com/share?via=%s&text=%s&url=%s&related=@%s', $post_info['tuser'], $post_info['title'], $post_info['url'], $post_info['tuser']), 'target' => '_blank'), 'facebook' => array('title' => 'Share %s', 'href' => sprintf('//facebook.com/sharer.php?u=%s', $post_info['url']), 'target' => '_blank'), 'email' => array('title' => 'Email %s', 'href' => sprintf('mailto:?subject=%s&body=%s', $post_info['title'], $post_info['url']), 'target' => '_blank'), 'discuss' => array('href' => '#comments', 'title' => 'Read comments on %s', 'target' => '')); printf('<nav class="%s">', 'article__sharing'); printf('<ul class="%s">', 'article__sharemenu'); foreach ($services as $service => $service_info) { if ($service === 'discuss' && !is_singular('post') && comments_open($post->ID)) { // Skip comment if it isn't a single post and comments are open. continue; } kaitain_social_link($post_info, $service, $service_info); } printf('</ul>'); printf('</nav>'); }
function load() { global $multipage, $page, $pings; if ($page == 1) { comments_template('', true); } else { ?> <div id="comments"> <div class="page"> <h3><?php _e('Comments', 'guangzhou'); ?> </h3> <p><?php printf(__('Comments are shown on the <a href="%s">first page</a>.', 'guangzhou'), post_permalink()); ?> </p> </div> </div> <?php } }
function vc_service_function($atts, $content = null) { $output = ''; extract(shortcode_atts(array('title' => '', 'head_icon' => '', 'count_word' => '', 'count_items' => '', 'select_categories' => '', 'button_title' => '', 'style' => 2, 'size' => ''), $atts)); $array_size = ['thumbnail', 'medium', 'large', 'full ']; if (!in_array(trim($size), $array_size)) { $size = 'medium'; } $output .= '<section id="service-section" class="service-section ow-section">'; $output .= '<div class="container"><div class="section-header">'; $output .= '<h3><img src="' . wp_get_attachment_url($head_icon) . '" alt="sep-icon" /> ' . $title . '</h3></div> '; $output .= '<div id="make-clean-service" class="owl-carousel owl-theme services-style' . $style . '">'; if (is_numeric($select_categories) && $select_categories >= 0) { if (!is_numeric($count_items)) { $count_items = 0; } $list_post = get_posts(['category' => $select_categories, 'posts_per_page' => $count_items]); foreach ($list_post as $post) { setup_postdata($post); $content = get_the_content(); $output .= '<div class="item">'; $output .= '<div class="service-box">'; $output .= get_the_post_thumbnail($post->ID, $size); $output .= '<div class="service-box-inner">'; $output .= '<h4>' . get_the_title($post->ID) . '</h4>'; if ($style == 2) { $output .= '<p>' . the_excerpt_max_charlength($content, $count_word) . '</p>'; } $output .= '<a title="xx' . $button_title . '" href="' . post_permalink($post->ID) . '">' . $button_title . '</a>'; $output .= '</div></div></div>'; } } $output .= '</div></div> </div> '; $output .= '</section>'; return $output; }
function mw_getRecentPosts($args) { $this->escape($args); $blog_ID = $args[0]; $user_login = $args[1]; $user_pass = $args[2]; $num_posts = $args[3]; if (!$this->login_pass_ok($user_login, $user_pass)) { return $this->error; } $posts_list = wp_get_recent_posts($num_posts); if (!$posts_list) { $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.'); return $this->error; } foreach ($posts_list as $entry) { $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); $categories = array(); $catids = wp_get_post_categories($entry['ID']); foreach($catids as $catid) { $categories[] = get_cat_name($catid); } $post = get_extended($entry['post_content']); $link = post_permalink($entry['ID']); $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0; $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0; $struct[] = array( 'dateCreated' => new IXR_Date($post_date), 'userid' => $entry['post_author'], 'postid' => $entry['ID'], 'description' => $post['main'], 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, // commented out because no other tool seems to use this // 'content' => $entry['post_content'], 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], 'mt_text_more' => $post['extended'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings ); } $recent_posts = array(); for ($j=0; $j<count($struct); $j++) { array_push($recent_posts, $struct[$j]); } return $recent_posts; }
<div class="box_list_post"> <?php the_content(); ?> <?php global $wpdb; $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, date_format(post_date,'%M') AS `month_text` FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC"; $archive = $wpdb->get_results($query); echo '<ul class="list_archive">'; foreach ($archive as $ar) { echo '<li> <h3>' . $ar->month_text . ' ' . $ar->year . '</h3>'; $query = "SELECT DISTINCT ID, post_title,DAY(post_date) AS post_date FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' AND YEAR(post_date)='" . $ar->year . "' AND MONTH(post_date)='" . $ar->month . "' ORDER BY DAY(post_date) DESC"; $post_archive = $wpdb->get_results($query); echo '<ul>'; foreach ($post_archive as $pa) { echo '<li><a href="' . post_permalink($pa->ID) . '" title="' . $pa->post_title . '">' . $pa->post_date . ' : ' . $pa->post_title . '</a></li>'; } echo '</ul>'; echo '</li>'; } echo '</ul>'; ?> </div> <?php } ?> </div><!-- end main --> <?php get_template_part('sidebar');
function iron_breadcrumbs($id = 'breadcrumbs', $class = 'breadcrumbs') { global $post_type; echo '<nav id="' . $id . '" class="' . $class . '"><ul>'; if (is_paged() || is_singular() || is_author() || is_tax() || is_category() || is_tag() || is_date()) { echo '<li><a href="' . home_url('/') . '">' . __('Home', IRON_TEXT_DOMAIN) . '</a></li>'; } if ((is_paged() || is_singular() || is_tax() || is_category() || is_tag() || is_date()) && (!is_page() || !is_attachment())) { global $iron_post_types; # Post Type if (empty($post_type)) { $post_type = get_post_type(); } $url = ''; if (in_array($post_type, $iron_post_types)) { $archive_page = get_iron_option('page_for_' . $post_type . 's'); } else { $archive_page = get_option('page_for_' . $post_type . 's'); } if ($archive_page > 0) { $url = post_permalink($archive_page); if (!empty($url)) { echo '<li><a href="' . $url . '">' . get_the_title($archive_page) . '</a></li>'; } } } if (is_archive()) { # Term if (is_tax()) { $taxonomy = get_query_var('taxonomy'); $term = get_term_by('slug', get_query_var('term'), $taxonomy); } elseif (is_category()) { $taxonomy = 'category'; $term = get_category(get_query_var('cat')); } elseif (is_tag()) { $taxonomy = 'post_tag'; $term = get_term_by('slug', get_query_var('tag'), $taxonomy); } if (!empty($term) && !is_wp_error($term)) { echo '<li><a href="' . get_term_link($term->slug, $taxonomy) . '">' . $term->name . '</a></li>'; } # A Date/Time Page if (is_day()) { echo '<li>' . sprintf(__('Archive for %s', IRON_TEXT_DOMAIN), get_the_date()) . '</li>'; } elseif (is_month()) { echo '<li>' . sprintf(__('Archive for %s', IRON_TEXT_DOMAIN), get_the_date(_x('F Y', 'monthly archives date format', IRON_TEXT_DOMAIN))) . '</li>'; } elseif (is_year()) { echo '<li>' . sprintf(__('Archive for %s', IRON_TEXT_DOMAIN), get_the_date(_x('Y', 'yearly archives date format', IRON_TEXT_DOMAIN))) . '</li>'; } elseif (is_author()) { $author = get_userdata(get_query_var('author')); echo '<li>' . sprintf(__('Archive for %s', IRON_TEXT_DOMAIN), $author->display_name) . '</li>'; } } elseif (is_search()) { echo '<li>' . __('Results', IRON_TEXT_DOMAIN) . '</li>'; } // Index Pagination if (is_paged()) { echo '<li>' . sprintf(__('Page %s', IRON_TEXT_DOMAIN), get_query_var('paged')) . '</li>'; } # A Single Page, Single Post or Attachment if (is_singular()) { echo '<li>' . get_the_title() . '</li>'; // Post Pagination $paged = get_query_var('page'); if (is_single() && $paged > 1) { echo '<li>' . sprintf(__('Page %s', IRON_TEXT_DOMAIN), $paged) . '</li>'; } } echo '</ul></nav>'; }
function mw_getRecentPosts($args) { $this->escape($args); $blog_ID = (int) $args[0]; $user_login = $args[1]; $user_pass = $args[2]; $num_posts = (int) $args[3]; if (!$this->login_pass_ok($user_login, $user_pass)) { return $this->error; } $posts_list = wp_get_recent_posts($num_posts); if (!$posts_list) { $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); return $this->error; } set_current_user(0, $user_login); foreach ($posts_list as $entry) { if (!current_user_can('edit_post', $entry['ID'])) { continue; } $post_date = mysql2date('Ymd\\TH:i:s', $entry['post_date']); $post_date_gmt = mysql2date('Ymd\\TH:i:s', $entry['post_date_gmt']); $categories = array(); $catids = wp_get_post_categories($entry['ID']); foreach ($catids as $catid) { $categories[] = get_cat_name($catid); } $tagnames = array(); $tags = wp_get_post_tags($entry['ID']); if (!empty($tags)) { foreach ($tags as $tag) { $tagnames[] = $tag->name; } $tagnames = implode(', ', $tagnames); } else { $tagnames = ''; } $post = get_extended($entry['post_content']); $link = post_permalink($entry['ID']); // Get the post author info. $author = get_userdata($entry['post_author']); $allow_comments = 'open' == $entry['comment_status'] ? 1 : 0; $allow_pings = 'open' == $entry['ping_status'] ? 1 : 0; $struct[] = array('dateCreated' => new IXR_Date($post_date), 'userid' => $entry['post_author'], 'postid' => $entry['ID'], 'description' => $post['main'], 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], 'mt_text_more' => $post['extended'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'mt_keywords' => $tagnames, 'wp_slug' => $entry['post_name'], 'wp_password' => $entry['post_password'], 'wp_author_id' => $author->ID, 'wp_author_display_name' => $author->display_name, 'date_created_gmt' => new IXR_Date($post_date_gmt)); } $recent_posts = array(); for ($j = 0; $j < count($struct); $j++) { array_push($recent_posts, $struct[$j]); } return $recent_posts; }
function widget($args, $instance) { global $wpdb, $comments, $comment; extract($args, EXTR_SKIP); $title = apply_filters('widget_title', empty($instance['title']) ? theme_locals("recent_comments_decs") : $instance['title']); $comments_count = apply_filters('widget_title', empty($instance['comments_count']) ? 5 : $instance['comments_count']); $display_avatar = apply_filters('widget_display_avatar', empty($instance['display_avatar']) ? 'off' : 'on'); $avatar_size = apply_filters('widget_avatar_size', empty($instance['avatar_size']) ? '48' : $instance['avatar_size']); $display_author_name = apply_filters('widget_display_author_name', empty($instance['display_author_name']) ? 'off' : 'on'); $display_date = apply_filters('widget_display_date', empty($instance['display_date']) ? 'off' : 'on'); $display_post_title = apply_filters('widget_display_post_title', empty($instance['display_post_title']) ? 'off' : 'on'); $meta_format = apply_filters('widget_meta_format', empty($instance['meta_format']) ? 'none' : $instance['meta_format']); if ($comments_count < 1) { $comments_count = 1; } else { if ($comments_count > 15) { $comments_count = 15; } } $comment_len = 100; if (function_exists('wpml_get_language_information')) { global $sitepress; $sql = "\r\r\n\t\t\t\tSELECT * FROM {$wpdb->comments}\r\r\n\t\t\t\tJOIN {$wpdb->prefix}icl_translations \r\r\n\t\t\t\tON {$wpdb->comments}.comment_post_id = {$wpdb->prefix}icl_translations.element_id \r\r\n\t\t\t\tAND {$wpdb->prefix}icl_translations.element_type='post_post' \r\r\n\t\t\t\tWHERE comment_approved = '1' \r\r\n\t\t\t\tAND language_code = '" . $sitepress->get_current_language() . "' \r\r\n\t\t\t\tORDER BY comment_date_gmt DESC LIMIT {$comments_count}"; } else { $sql = "\r\r\n\t\t\t\tSELECT * FROM {$wpdb->comments} \r\r\n\t\t\t\tWHERE comment_approved = '1' \r\r\n\t\t\t\tAND comment_type not in ('pingback','trackback') \r\r\n\t\t\t\tORDER BY comment_date_gmt \r\r\n\t\t\t\tDESC LIMIT {$comments_count}"; } if (!($comments = wp_cache_get('recent_comments', 'widget'))) { $comments = $wpdb->get_results($sql); wp_cache_add('recent_comments', $comments, 'widget'); } $comments = array_slice((array) $comments, 0, $comments_count); ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <ul class="comments-custom unstyled"><?php if ($comments) { foreach ((array) $comments as $comment) { ?> <li class="comments-custom_li"> <?php if (function_exists('get_avatar') && $display_avatar != 'off') { echo '<figure class="thumbnail featured-thumbnail">'; echo get_avatar(get_the_author_meta('email', $id = get_comment(get_comment_ID())->user_id), $avatar_size); /* This avatar is the user's gravatar (http://gravatar.com) based on their administrative email address */ echo '</figure>'; } ?> <?php if ($display_post_title != 'off') { $post_ID = $comment->comment_post_ID; $title_format = ""; if ($meta_format == "icons") { $title_format = '<i class="icon-link"></i>'; } else { if ($meta_format == "labels") { $title_format = '<span class="ladle">' . theme_locals("comment_in") . ':</span> '; } } echo '<div class="meta_format">' . $title_format . '<h4 class="comments-custom_h_title"><a href="' . post_permalink($post_ID) . '" title="' . get_post($post_ID)->post_title . '">' . get_post($post_ID)->post_title . '</a></h4></div>'; } ?> <?php if ($display_author_name != 'off') { $title_author_name = ""; if ($meta_format == "icons") { $title_author_name = '<i class="icon-user"></i>'; } else { if ($meta_format == "labels") { $title_author_name = '<span class="ladle">' . theme_locals("comment_author") . ':</span> '; } } echo '<div class="meta_format">' . $title_author_name . '<h4 class="comments-custom_h_author">' . $comment->comment_author . '</h4></div>'; } ?> <?php if ($display_date != 'off') { $title_date = ""; if ($meta_format == "icons") { $title_date = '<i class="icon-calendar"></i>'; } else { if ($meta_format == "labels") { $title_date = '<span class="ladle">' . theme_locals("comment_date") . ':</span> '; } } $comment_date = get_comment_date(); $comment_time = get_comment_time(); echo '<div class="meta_format">' . $title_date . '<time datetime="' . date('Y-m-d\\TH:i:s', strtotime($comment_date . $comment_time)) . '">' . $comment_date . ' ' . $comment_time . '</time></div>'; } ?> <div class="clear"></div> <div class="comments-custom_txt"> <a href="<?php echo get_comment_link($comment->comment_ID); ?> " title="<?php echo theme_locals("go_to_c"); ?> "><?php echo strip_tags(substr(apply_filters('get_comment_text', $comment->comment_content), 0, $comment_len)); if (strlen($comment->comment_content) > $comment_len) { echo '...'; } ?> </a> </div> </li> <?php } } ?> </ul> <?php echo $after_widget; ?> <?php }
/** * Flushes post cache * * @param integer $post_id * @return boolean */ function flush_post($post_id = null) { if (!$post_id) { $post_id = $this->_detect_post_id(); } if ($post_id) { $uris = array(); $domain_url = w3_get_domain_url(); $feeds = $this->_config->get_array('pgcache.purge.feed.types'); if ($this->_config->get_boolean('pgcache.purge.terms') || $this->_config->get_boolean('pgcache.purge.feed.terms')) { $taxonomies = get_post_taxonomies($post_id); $terms = nxt_get_post_terms($post_id, $taxonomies); } switch (true) { case $this->_config->get_boolean('pgcache.purge.author'): case $this->_config->get_boolean('pgcache.purge.archive.daily'): case $this->_config->get_boolean('pgcache.purge.archive.monthly'): case $this->_config->get_boolean('pgcache.purge.archive.yearly'): case $this->_config->get_boolean('pgcache.purge.feed.author'): $post = get_post($post_id); } /** * Home URL */ if ($this->_config->get_boolean('pgcache.purge.home')) { $home_path = w3_get_home_path(); $site_path = w3_get_site_path(); $uris[] = $home_path; if ($site_path != $home_path) { $uris[] = $site_path; } } /** * Post URL */ if ($this->_config->get_boolean('pgcache.purge.post')) { $post_link = post_permalink($post_id); $post_uri = str_replace($domain_url, '', $post_link); $uris[] = $post_uri; } /** * Post comments URLs */ if ($this->_config->get_boolean('pgcache.purge.comments') && function_exists('get_comments_pagenum_link')) { $comments_number = get_comments_number($post_id); $comments_per_page = get_option('comments_per_page'); $comments_pages_number = @ceil($comments_number / $comments_per_page); for ($pagenum = 1; $pagenum <= $comments_pages_number; $pagenum++) { $comments_pagenum_link = $this->_get_comments_pagenum_link($post_id, $pagenum); $comments_pagenum_uri = str_replace($domain_url, '', $comments_pagenum_link); $uris[] = $comments_pagenum_uri; } } /** * Post author URLs */ if ($this->_config->get_boolean('pgcache.purge.author') && $post) { $posts_number = count_user_posts($post->post_author); $posts_per_page = get_option('posts_per_page'); $posts_pages_number = @ceil($posts_number / $posts_per_page); $author_link = get_author_link(false, $post->post_author); $author_uri = str_replace($domain_url, '', $author_link); for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) { $author_pagenum_link = $this->_get_pagenum_link($author_uri, $pagenum); $author_pagenum_uri = str_replace($domain_url, '', $author_pagenum_link); $uris[] = $author_pagenum_uri; } } /** * Post terms URLs */ if ($this->_config->get_boolean('pgcache.purge.terms')) { $posts_per_page = get_option('posts_per_page'); foreach ($terms as $term) { $term_link = get_term_link($term, $term->taxonomy); $term_uri = str_replace($domain_url, '', $term_link); $posts_pages_number = @ceil($term->count / $posts_per_page); for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) { $term_pagenum_link = $this->_get_pagenum_link($term_uri, $pagenum); $term_pagenum_uri = str_replace($domain_url, '', $term_pagenum_link); $uris[] = $term_pagenum_uri; } } } /** * Daily archive URLs */ if ($this->_config->get_boolean('pgcache.purge.archive.daily') && $post) { $post_date = strtotime($post->post_date); $post_year = gmdate('Y', $post_date); $post_month = gmdate('m', $post_date); $post_day = gmdate('d', $post_date); $posts_per_page = get_option('posts_per_page'); $posts_number = $this->_get_archive_posts_count($post_year, $post_month, $post_day); $posts_pages_number = @ceil($posts_number / $posts_per_page); $day_link = get_day_link($post_year, $post_month, $post_day); $day_uri = str_replace($domain_url, '', $day_link); for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) { $day_pagenum_link = $this->_get_pagenum_link($day_uri, $pagenum); $day_pagenum_uri = str_replace($domain_url, '', $day_pagenum_link); $uris[] = $day_pagenum_uri; } } /** * Monthly archive URLs */ if ($this->_config->get_boolean('pgcache.purge.archive.monthly') && $post) { $post_date = strtotime($post->post_date); $post_year = gmdate('Y', $post_date); $post_month = gmdate('m', $post_date); $posts_per_page = get_option('posts_per_page'); $posts_number = $this->_get_archive_posts_count($post_year, $post_month); $posts_pages_number = @ceil($posts_number / $posts_per_page); $month_link = get_month_link($post_year, $post_month); $month_uri = str_replace($domain_url, '', $month_link); for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) { $month_pagenum_link = $this->_get_pagenum_link($month_uri, $pagenum); $month_pagenum_uri = str_replace($domain_url, '', $month_pagenum_link); $uris[] = $month_pagenum_uri; } } /** * Yearly archive URLs */ if ($this->_config->get_boolean('pgcache.purge.archive.yearly') && $post) { $post_date = strtotime($post->post_date); $post_year = gmdate('Y', $post_date); $posts_per_page = get_option('posts_per_page'); $posts_number = $this->_get_archive_posts_count($post_year); $posts_pages_number = @ceil($posts_number / $posts_per_page); $year_link = get_year_link($post_year); $year_uri = str_replace($domain_url, '', $year_link); for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) { $year_pagenum_link = $this->_get_pagenum_link($year_uri, $pagenum); $year_pagenum_uri = str_replace($domain_url, '', $year_pagenum_link); $uris[] = $year_pagenum_uri; } } /** * Feed URLs */ if ($this->_config->get_boolean('pgcache.purge.feed.blog')) { foreach ($feeds as $feed) { $feed_link = get_feed_link($feed); $feed_uri = str_replace($domain_url, '', $feed_link); $uris[] = $feed_uri; } } if ($this->_config->get_boolean('pgcache.purge.feed.comments')) { foreach ($feeds as $feed) { $post_comments_feed_link = get_post_comments_feed_link($post_id, $feed); $post_comments_feed_uri = str_replace($domain_url, '', $post_comments_feed_link); $uris[] = $post_comments_feed_uri; } } if ($this->_config->get_boolean('pgcache.purge.feed.author') && $post) { foreach ($feeds as $feed) { $author_feed_link = get_author_feed_link($post->post_author, $feed); $author_feed_uri = str_replace($domain_url, '', $author_feed_link); $uris[] = $author_feed_uri; } } if ($this->_config->get_boolean('pgcache.purge.feed.terms')) { foreach ($terms as $term) { foreach ($feeds as $feed) { $term_feed_link = get_term_feed_link($term->term_id, $term->taxonomy, $feed); $term_feed_uri = str_replace($domain_url, '', $term_feed_link); $uris[] = $term_feed_uri; } } } /** * Flush cache */ if (count($uris)) { $cache =& $this->_get_cache(); $mobile_groups = $this->_get_mobile_groups(); $referrer_groups = $this->_get_referrer_groups(); $encryptions = $this->_get_encryptions(); $compressions = $this->_get_compressions(); foreach ($uris as $uri) { foreach ($mobile_groups as $mobile_group) { foreach ($referrer_groups as $referrer_group) { foreach ($encryptions as $encryption) { foreach ($compressions as $compression) { $page_key = $this->_get_page_key($uri, $mobile_group, $referrer_group, $encryption, $compression); $cache->delete($page_key); } } } } } /** * Purge varnish servers */ if ($this->_config->get_boolean('varnish.enabled')) { $varnish =& w3_instance('W3_Varnish'); foreach ($uris as $uri) { $varnish->purge($uri); } } } return true; } return false; }
<?php if (is_home()) { query_posts('posts_per_page=1'); if (have_posts()) { the_post(); header('Location: ' . post_permalink()); } } ?> <html> <head> <title><?php bloginfo('name'); ?> </title> <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?> " type="text/css" media="screen, print"> </head> <body> <div class="bd"> <div class="entries"> <?php if (have_posts()) { ?> <?php while (have_posts()) { the_post(); ?>
template name: Deprecated - Trending old style * The template for displaying our "in focus" view. * In this version we just show the most recent 'in focus' post * @package Independent Publisher * @since Independent Publisher 1.0 */ $pageBodyID = "trending"; $trendingCatID = get_cat_id('Trending'); /**** GET A SPECIAL PERMALINK FOR THE TWITTER AND FB SHARE BUTTONS *****/ $qParams = array('post_type' => array('post'), 'posts_per_page' => 1, 'orderby' => 'post_date', 'order' => 'desc', 'cat' => $trendingCatID); //echo "catid " . $cat_id . "<BR>"; query_posts($qParams); if (have_posts()) { while (have_posts()) { the_post(); $trendingPostPermalink = post_permalink(get_the_id()); $ogUrl = $trendingPostPermalink; } } rewind_posts(); /***** DONE GETTING SPECIAL PERMALINK ******/ get_header(); ?> <!-- temporary fix --> <div id="logoOnPostPages"> <a class="site-logo" href="https://africa.rizing.org/" title="Africa Rizing" rel="home"> <img class="no-grav" src="https://africa.rizing.org/wp-content/uploads/2015/10/cropped-Rize-socialprofiles_500.png" height="501" width="501" alt="Africa Rizing"> </a> <h1 class="site-title"> <a href="https://africa.rizing.org/" title="Africa Rizing" rel="home">Africa <span class="orangeHighlight">Rizing</span></a>
</div> <h4><a href="<?php echo post_permalink($post->ID); ?> "><?php echo $post->post_title; ?> </a></h4> <div class="description"> <?php $content = self::ya_trim_words($post->post_content, $length, ' '); echo $content; ?> </div> <div class="readmore"><a href="<?php echo post_permalink($post->ID); ?> " title="Read more" ><?php _e('Read more', 'smartaddons'); ?> </a></div> </div> </div> </div> </div> <?php } ?> <?php } ?>
/** * * * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public static function get_schema($testimonial, $atts) { if (!isset($testimonial['post_id'])) { return; } foreach ($testimonial as $key => $value) { if ('testimonial_image' != $key) { $testimonial[$key] = self::clean_string($value); } } extract($testimonial); $do_company = !$atts['hide_company'] && !empty($testimonial_company); $do_content = !empty($testimonial['testimonial_content']); $do_email = !$atts['hide_email'] && !empty($testimonial_email) && is_email($testimonial_email); $do_image = !$atts['hide_image'] && !empty($testimonial_image); $do_location = !$atts['hide_location'] && !empty($testimonial_location); $do_source = !$atts['hide_source'] && !empty($testimonial_source); $do_title = !$atts['hide_title'] && !empty($testimonial_title); $do_url = !$atts['hide_url'] && !empty($testimonial_url); $item_reviewed = self::clean_string($atts['item_reviewed']); $item_reviewed_url = self::clean_string($atts['item_reviewed_url']); $schema = sprintf(self::$schema_div_open, self::$review_schema); $schema .= "\n"; $author_meta = array(); $item_meta = array(); $location_meta = array(); $org_meta = array(); $review_meta = array(); if (!empty($testimonial_author)) { $author_meta[self::$thing_name] = $testimonial_author; } if ($do_source) { if (empty($testimonial_author)) { $author_meta[self::$thing_name] = $testimonial_source; } else { $review_meta[self::$thing_name] = $testimonial_source; } } if ($do_title) { $author_meta[self::$person_job_title] = $testimonial_title; } if ($do_email) { $author_meta[self::$person_email] = $testimonial_email; } if (!$do_company) { if ($do_url) { $author_meta[self::$thing_url] = $testimonial_url; } } else { if ($do_url) { $org_meta[self::$thing_url] = $testimonial_url; } $org_meta[self::$thing_name] = $testimonial_company; } if ($do_location) { $location_meta[self::$thing_name] = $testimonial_location; if (!$do_company) { $author_meta[self::$person_home] = array(self::$place_schema, $location_meta); } else { $org_meta[self::$org_location] = array(self::$place_schema, $location_meta); } } if (!empty($author_meta) && !empty($org_meta)) { $author_meta[self::$person_member] = array(self::$org_schema, $org_meta); } elseif (!empty($org_meta)) { $author_meta[self::$cw_source_org] = array(self::$org_schema, $org_meta); } $author_meta = apply_filters('tw_schema_author', $author_meta, $testimonial, $atts); $author = self::create_schema_div_prop(self::$cw_author, self::$person_schema, $author_meta); $schema .= $author; $schema .= "\n"; $post = get_post($testimonial['post_id']); $the_date = mysql2date('Y-m-d', $post->post_date); $the_date_mod = mysql2date('Y-m-d', $post->post_modified); $review_name_length = apply_filters('tw_review_name_length', 156); if ($do_content) { $review_meta[self::$review_body] = $testimonial['testimonial_content']; } $review_meta[self::$cw_date] = $the_date; $review_meta[self::$cw_date_mod] = $the_date_mod; $review_meta[self::$thing_url] = post_permalink($post->ID); if (empty($review_meta[self::$thing_name])) { $review_meta[self::$thing_name] = self::testimonials_truncate($testimonial_content, $review_name_length); } if ($do_image) { $src = self::get_image_src($testimonial_image); $review_meta[self::$thing_image] = $src; } $aggregate_meta = array(self::$aggregate_review => self::get_review_count($testimonial)); $aggregate_meta[self::$aggregate_count] = $aggregate_meta[self::$aggregate_review]; $review_meta[self::$aggregate_rating] = array(self::$aggregate_schema, $aggregate_meta); $review_meta = apply_filters('tw_schema_review', $review_meta, $testimonial, $atts); $review = self::create_schema_meta($review_meta); $schema .= $review; $schema .= "\n"; $item_meta[self::$thing_name] = $item_reviewed; $item_meta[self::$thing_url] = $item_reviewed_url; $item_meta = apply_filters('tw_schema_item', $item_meta, $testimonial, $atts); $item = self::create_schema_div_prop(self::$review_item, self::$thing_schema, $item_meta); $schema .= $item; $schema .= "\n"; $schema .= '</div>'; $schema .= "\n"; $schema = apply_filters('tw_schema', $schema, $testimonial, $atts); return $schema; }
/** * Returns all urls related to a post * @param $post_id * @return array */ function get_post_urls($post_id) { if (!isset($this->post_urls[$post_id])) { $full_urls = array(); $post_link = post_permalink($post_id); $post_uri = str_replace($this->domain_url, '', $post_link); $full_urls[] = $post_link; $uris[] = $post_uri; $post = isset($post) ? $post : get_post($post_id); $matches = array(); if (($post_pages_number = preg_match_all('/\\<\\!\\-\\-nextpage\\-\\-\\>/', $post->post_content, $matches)) > 0) { global $wp_rewrite; $post_pages_number++; for ($pagenum = 2; $pagenum <= $post_pages_number; $pagenum++) { if ('page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID) { $post_pagenum_link = trailingslashit($post_link) . user_trailingslashit("{$wp_rewrite->pagination_base}/" . $pagenum, 'single_paged'); } else { $post_pagenum_link = trailingslashit($post_link) . user_trailingslashit($pagenum, 'single_paged'); } $full_urls[] = $post_pagenum_link; } } $this->post_urls[$post_id] = $full_urls; } return $this->post_urls[$post_id]; }
/** * Flushes post cache * * @param integer $post_id * @return boolean */ function flush_post($post_id) { if (!$post_id) { $post_id = $this->_detect_post_id(); } if ($post_id) { $home = get_option('home'); $page_keys = array($this->_get_page_key(str_replace($home, '', post_permalink($post_id)), false), $this->_get_page_key(str_replace($home, '', post_permalink($post_id)), 'gzip'), $this->_get_page_key(str_replace($home, '', post_permalink($post_id)), 'deflate'), $this->_get_page_key('/', false), $this->_get_page_key('/', 'gzip'), $this->_get_page_key('/', 'deflate')); $cache =& $this->_get_cache(); foreach ($page_keys as $page_key) { $cache->delete($page_key); } } return false; }
function qppr_frontend_scripts() { global $qppr_setting_links; $qppr_setting_links = true; $turnOff = get_option('ppr_override-active', '0'); $useJQ = get_option('ppr_use-jquery', '0'); if ((int) $useJQ == 0 || (int) $turnOff == 1) { return; } global $wpdb; $rewrite = $this->pproverride_rewrite == '0' || $this->pproverride_rewrite == '' ? false : true; $allNewWin = get_option('ppr_override-newwindow', '0'); $allNoFoll = get_option('ppr_override-nofollow', '0'); $noFollNewWin = get_option('quickppr_redirects_meta', array()); $mainQuick = get_option('quickppr_redirects', array()); $linkData = array(); if (is_array($noFollNewWin) && !empty($noFollNewWin)) { foreach ($noFollNewWin as $key => $val) { if ((int) $allNewWin == 1 && (int) $allNoFoll == 1) { $linkData[$key] = array(1, 1); } elseif ((int) $val['nofollow'] !== 0 || (int) $allNoFoll == 1 || ((int) $val['newwindow'] !== 0 || (int) $allNewWin == 1)) { $newwinval = (int) $allNewWin == 1 ? 1 : (int) $val['newwindow']; $nofollval = (int) $allNoFoll == 1 ? 1 : (int) $val['nofollow']; $rewriteval = $rewrite && isset($mainQuick[$key]) && $mainQuick[$key] != '' ? $mainQuick[$key] : ''; $linkData[$key] = array($newwinval, $nofollval, $rewriteval); } } } $joinSQL = (int) $allNewWin == 1 || (int) $allNoFoll == 1 || $rewrite ? "" : " INNER JOIN {$wpdb->prefix}postmeta AS mt3 ON ( {$wpdb->prefix}posts.ID = mt3.post_id ) "; $whereSQL = (int) $allNewWin == 1 || (int) $allNoFoll == 1 || $rewrite ? "" : " AND ( ( mt3.meta_key = '_pprredirect_relnofollow' AND CAST(mt3.meta_value AS CHAR) = '1' ) OR ( mt3.meta_key = '_pprredirect_newwindow' AND CAST(mt3.meta_value AS CHAR) = '1' ) OR ( mt3.meta_key = '_pprredirect_rewritelink' AND CAST(mt3.meta_value AS CHAR) = '1' ) ) "; $finalSQL = "SELECT {$wpdb->prefix}posts.ID FROM {$wpdb->prefix}posts INNER JOIN {$wpdb->prefix}postmeta ON ( {$wpdb->prefix}posts.ID = {$wpdb->prefix}postmeta.post_id ) INNER JOIN {$wpdb->prefix}postmeta AS mt1 ON ( {$wpdb->prefix}posts.ID = mt1.post_id ) INNER JOIN {$wpdb->prefix}postmeta AS mt2 ON ( {$wpdb->prefix}posts.ID = mt2.post_id ) {$joinSQL} WHERE 1=1 AND ( ( {$wpdb->prefix}postmeta.meta_key = '_pprredirect_active' AND CAST({$wpdb->prefix}postmeta.meta_value AS CHAR) = '1' ) AND ( mt1.meta_key = '_pprredirect_type' AND CAST(mt1.meta_value AS CHAR) != '' ) AND ( mt2.meta_key = '_pprredirect_url' AND CAST(mt2.meta_value AS CHAR) != '' ) {$whereSQL}) AND {$wpdb->prefix}posts.post_type NOT IN ('attachment', 'nav_menu_item', 'revision' ) AND (({$wpdb->prefix}posts.post_status = 'publish')) GROUP BY {$wpdb->prefix}posts.ID ORDER BY {$wpdb->prefix}posts.post_date DESC "; $indReds = $wpdb->get_results($finalSQL); if (is_array($indReds) && !empty($indReds)) { foreach ($indReds as $key => $qpost) { $destURL = get_post_meta($qpost->ID, '_pprredirect_url', true); $rwMeta = (int) get_post_meta($qpost->ID, '_pprredirect_rewritelink', true) == 1 ? true : false; $noFoll = (int) $allNoFoll == 1 ? 1 : (int) get_post_meta($qpost->ID, '_pprredirect_relnofollow', true); $newWin = (int) $allNewWin == 1 ? 1 : (get_post_meta($qpost->ID, '_pprredirect_newwindow', true) != '' ? 1 : 0); $rewriteval = $rewrite || $rwMeta ? $destURL : ''; $redURL = get_permalink($qpost->ID); $redURL1 = post_permalink($qpost->ID); $linkData[$redURL] = array($newWin, $noFoll, $rewriteval); } } $qppr_setting_links = false; //wp_enqueue_script( 'qppr_frontend_scripts', plugins_url( '/js/qppr_frontend_script.js', __FILE__ ) , array('jquery'), $this->ppr_curr_version, true ); wp_enqueue_script('qppr_frontend_scripts', plugins_url('/js/qppr_frontend_script.min.js', __FILE__), array('jquery'), $this->ppr_curr_version, true); wp_localize_script('qppr_frontend_scripts', 'qpprFrontData', array('linkData' => $linkData, 'siteURL' => site_url(), 'siteURLq' => $this->getQAddress())); }
/** * Retrieve list of recent posts. * * @since 1.5.0 * * @param array $args Method parameters. * @return array */ function mw_getRecentPosts($args) { $this->escape($args); $blog_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; if (isset($args[3])) { $query = array('numberposts' => absint($args[3])); } else { $query = array(); } if (!($user = $this->login($username, $password))) { return $this->error; } do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); $posts_list = wp_get_recent_posts($query); if (!$posts_list) { return array(); } $struct = array(); foreach ($posts_list as $entry) { if (!current_user_can('edit_post', $entry['ID'])) { continue; } $post_date = $this->_convert_date($entry['post_date']); $post_date_gmt = $this->_convert_date_gmt($entry['post_date_gmt'], $entry['post_date']); $post_modified = $this->_convert_date($entry['post_modified']); $post_modified_gmt = $this->_convert_date_gmt($entry['post_modified_gmt'], $entry['post_modified']); $categories = array(); $catids = wp_get_post_categories($entry['ID']); foreach ($catids as $catid) { $categories[] = get_cat_name($catid); } $tagnames = array(); $tags = wp_get_post_tags($entry['ID']); if (!empty($tags)) { foreach ($tags as $tag) { $tagnames[] = $tag->name; } $tagnames = implode(', ', $tagnames); } else { $tagnames = ''; } $post = get_extended($entry['post_content']); $link = post_permalink($entry['ID']); // Get the post author info. $author = get_userdata($entry['post_author']); $allow_comments = 'open' == $entry['comment_status'] ? 1 : 0; $allow_pings = 'open' == $entry['ping_status'] ? 1 : 0; // Consider future posts as published if ($entry['post_status'] === 'future') { $entry['post_status'] = 'publish'; } // Get post format $post_format = get_post_format($entry['ID']); if (empty($post_format)) { $post_format = 'standard'; } $struct[] = array('dateCreated' => $post_date, 'userid' => $entry['post_author'], 'postid' => (string) $entry['ID'], 'description' => $post['main'], 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], 'mt_text_more' => $post['extended'], 'wp_more_text' => $post['more_text'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'mt_keywords' => $tagnames, 'wp_slug' => $entry['post_name'], 'wp_password' => $entry['post_password'], 'wp_author_id' => (string) $author->ID, 'wp_author_display_name' => $author->display_name, 'date_created_gmt' => $post_date_gmt, 'post_status' => $entry['post_status'], 'custom_fields' => $this->get_custom_fields($entry['ID']), 'wp_post_format' => $post_format, 'date_modified' => $post_modified, 'date_modified_gmt' => $post_modified_gmt); $entry_index = count($struct) - 1; $struct[$entry_index]['wp_post_thumbnail'] = get_post_thumbnail_id($entry['ID']); } $recent_posts = array(); for ($j = 0; $j < count($struct); $j++) { array_push($recent_posts, $struct[$j]); } return $recent_posts; }
echo post_permalink($article->ID); ?> " class="article-title"><?php echo get_the_title($article->ID); ?> </a> </div> <div class="col-xs-12 article-content"> <?php //echo apply_filters('the_content', $article->post_content); echo the_excerpt(); ?> </div> <div class="col-xs-12"> <a href="<?php echo post_permalink($article->ID); ?> " class="article-link">Learn More ></a> </div> </div> </div> <?php wp_reset_postdata(); } ?> </div> </div> </div> <div class="row">
public function widget($args, $instance) { // outputs the content of the widget extract($args); global $tt_theme; $title = $instance['title']; $number_post = $instance['number_post']; $argus = array('numberposts' => $number_post, 'post_status' => 'publish', 'orderby' => 'post_date', 'order' => 'DESC'); $recent_posts = wp_get_recent_posts($argus); /** This filter is documented in wp-includes/default-widgets.php */ $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo balanceTags($before_widget); if ($title) { echo balanceTags($before_title . $title . $after_title); } ?> <ul class="clean-list recent-posts-loop"> <?php foreach ($recent_posts as $post) { $post = (object) $post; ?> <li class="row row-fit"> <?php if (has_post_thumbnail($post->ID)) { ?> <div class="col-xs-3 col-md-4 col-sm-3"> <figure> <a href="<?php echo post_permalink($post->ID); ?> "> <?php echo balanceTags($tt_theme->lazy_img(wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array(60, 60)), $post->post_title)); ?> </a> </figure> </div> <?php } ?> <div class="col-xs-9 col-sm-8 col-md-<?php echo has_post_thumbnail($post->ID) ? 8 : 12; ?> "> <a href="<?php echo post_permalink($post->ID); ?> " class="font-beta"><?php echo balanceTags($post->post_title); ?> </a> </div> </li> <?php } ?> </ul> <?php echo balanceTags($after_widget); }
function mt_getpost($params) { // ($postid, $user, $pass) global $xmlrpcerruser; $xpostid = $params->getParam(0); $xuser = $params->getParam(1); $xpass = $params->getParam(2); $post_ID = $xpostid->scalarval(); $username = $xuser->scalarval(); $password = $xpass->scalarval(); // Check login if (user_pass_ok($username, $password)) { $postdata = get_postdata($post_ID); if ($postdata["Date"] != "") { // why were we converting to GMT here? spec doesn't call for that. //$post_date = mysql2date("U", $postdata["Date"]); //$post_date = gmdate("Ymd", $post_date)."T".gmdate("H:i:s", $post_date); $post_date = strtotime($postdata['Date']); $post_date = date("Ymd", $post_date) . "T" . date("H:i:s", $post_date); $catids = wp_get_post_cats('1', $post_ID); logIO("O", "CateGory No:" . count($catids)); foreach ($catids as $catid) { $catname = get_cat_name($catid); logIO("O", "CateGory:" . $catname); $catnameenc = new xmlrpcval(mb_conv($catname, "UTF-8", "auto")); $catlist[] = $catnameenc; } $post = get_extended($postdata['Content']); $allow_comments = 'open' == $postdata['comment_status'] ? 1 : 0; $allow_pings = 'open' == $postdata['ping_status'] ? 1 : 0; $resp = array('link' => new xmlrpcval(post_permalink($post_ID)), 'title' => new xmlrpcval(mb_conv($postdata["Title"], "UTF-8", "auto")), 'description' => new xmlrpcval(mb_conv($post['main'], "UTF-8", "auto")), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'userid' => new xmlrpcval($postdata["Author_ID"]), 'postid' => new xmlrpcval($postdata["ID"]), 'content' => new xmlrpcval(mb_conv($postdata["Content"], "UTF-8", "auto")), 'permalink' => new xmlrpcval(post_permalink($post_ID)), 'categories' => new xmlrpcval($catlist, 'array'), 'mt_keywords' => new xmlrpcval("{$catids[0]}"), 'mt_excerpt' => new xmlrpcval(mb_conv($postdata['Excerpt'], "UTF-8", "auto")), 'mt_allow_comments' => new xmlrpcval($allow_comments, 'int'), 'mt_allow_pings' => new xmlrpcval($allow_pings, 'int'), 'mt_convert_breaks' => new xmlrpcval('true'), 'mt_text_more' => new xmlrpcval(mb_conv($post['extended'], "UTF-8", "auto"))); $resp = new xmlrpcval($resp, 'struct'); return new xmlrpcresp($resp); } else { return new xmlrpcresp(0, $xmlrpcerruser + 3, "No such post #{$post_ID}"); } } else { return new xmlrpcresp(0, $xmlrpcerruser + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password)); } }
public static function purge_varnish_cache($post_id = null) { global $wpengine_platform_config; global $wpe_varnish_servers; global $wpdb; $wpe_all_domains = $wpengine_platform_config['all_domains']; if (!$wpe_all_domains) { $wpe_all_domains = array(); } static $purge_counter; // Globally disabled? if (defined('WPE_DISABLE_CACHE_PURGING') && WPE_DISABLE_CACHE_PURGING) { return false; } // Autosaving never updates published content. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return false; } // If we've purged "enough" times, stop already. if (isset($purge_counter) && $purge_counter > 2) { return false; } $blog_url = home_url(); $blog_url_parts = @parse_url($blog_url); $blog_domain = $blog_url_parts['host']; // If purging everything, $paths and $abspaths are empty. $abspaths = array(); // paths to purge exactly; no prefix or suffixes. $paths = array(); // path regular expressions to purge. $purge_thing = false; if ($post_id && $post_id > 1 && !!($post = get_post($post_id))) { // Certain post types aren't cached so we shouldn't purge if ($post->post_type == 'attachment' || $post->post_type == 'revision') { return; } // If the post isn't published, we don't need to purge (draft, scheduled, deleted) if ($post->post_status != 'publish') { //error_log("purgebail: ".$post->post_status); return; } //error_log("micropurge: $post_id"); // Determine the set of paths to purge. If there's no post_id, purge all. Otherwise name the paths. $purge_domains = array($blog_domain); $blog_path = WpeCommon::get_path_trailing_slash(@$blog_url_parts['path']); if ($blog_path == '/') { $blog_path_prefix = ""; } else { $tpath = substr($blog_path, 0, -1); $blog_path_prefix = $tpath . ".*"; } // Always purge the post's own URI, along with anything similar $post_parts = parse_url(post_permalink($post_id)); $post_uri = rtrim($post_parts['path'], '/') . "(.*)"; if (!empty($post_parts['query'])) { $post_uri .= "?" . $post_parts['query']; } $paths[] = $post_uri; // Purge the categories & tags this post belongs to if (defined('WPE_PURGE_CATS_ON_PUB')) { foreach (wp_get_post_categories($post_id) as $cat_id) { $cat = get_category($cat_id); $slug = $cat->slug; $paths[] = "{$blog_path_prefix}/{$slug}/"; } foreach (wp_get_post_tags($post_id) as $tag) { $slug = $tag->slug; $paths[] = "{$blog_path_prefix}/{$slug}/"; } } // Purge main pages if we're there. Can't know for sure, so approximate by saying // if it's more than 7 days old it's either not there or has been there for so // long that it doesn't matter. if (time() - strtotime($post->post_date_gmt) < 60 * 60 * 24 * 7) { if ($post->post_type != 'shop_order') { $paths[] = "^{$blog_path}\$"; $paths[] = "/feed"; } } $purge_thing = $post_id; } else { $paths[] = ".*"; // full blog purge $purge_thing = true; $purge_domains = $wpe_all_domains; if (isset($wpdb->dmtable)) { $rows = $wpdb->get_results("SELECT domain FROM {$wpdb->dmtable}"); foreach ($rows as $row) { $purge_domains[] = strtolower($row->domain); } $purge_domains = array_unique($purge_domains); } } // add on blog domains for this blog // this will ensure we are purging in all proper locations $purge_domains = array_unique(array_merge($purge_domains, self::get_blog_domains())); if (!count($paths)) { return; // short-circuit if there's nothing to do. } // else: $paths = array_unique($paths); // allow the code above to be sloppy // At this point, we know we're going to purge, so let's bump the purge counter. This will prevent us from // over-purging on a given request. // BWD: I'm not sure this is necessary and may actually be harmful, depending on how many updates to a given // post can happen within a single request. if (!isset($purge_counter)) { $purge_counter = 1; } else { $purge_counter++; } // Purge Varnish cache. if (WPE_CLUSTER_TYPE == "pod") { $wpe_varnish_servers = array("localhost"); } else { if (!isset($wpe_varnish_servers)) { if (!defined('WPE_CLUSTER_ID') || !WPE_CLUSTER_ID) { $lbmaster = "lbmaster"; } else { if (WPE_CLUSTER_ID >= 4) { $lbmaster = "localhost"; // so the current user sees the purge } else { $lbmaster = "lbmaster-" . WPE_CLUSTER_ID; } } $wpe_varnish_servers = array($lbmaster); } } // Debugging if (false) { $msg_key = rand(); $msg = "Varnishes # {$msg_key}:\n" . var_export($wpe_varnish_servers, true) . "\nDomains:\n" . var_export($purge_domains, true) . "\nPaths:\n" . var_export($paths, true); //error_log( "PURGE: $msg" ); } if ($paths) { $paths_regex = '(' . join('|', $paths) . ')'; } if ($abspaths) { $abspaths = array_map('preg_quote', $abspaths); $abspaths_regex = '^(' . join('|', $abspaths) . ')$'; } if ($paths && $abspaths) { $path_regex = "(({$abspaths_regex})|({$paths_regex}))"; } else { if ($paths) { $path_regex = $paths_regex; } else { if ($abspaths) { $path_regex = $abspaths_regex; } else { $path_regex = '.*'; } } } // Convert the purge domains to PCRE-escaped strings and join them together in an alternation -- purging in // blocks of 100 domains. Varnish can't handle an unlimited number. Ordinarily, this will still be one chunk, // but for some massive sites, there can be more than 100 domains mapped, unfortunately. $hostname = $purge_domains[0]; $purge_domains = array_map('preg_quote', $purge_domains); $purge_domain_chunks = array_chunk($purge_domains, 100); foreach ($purge_domain_chunks as $chunk) { $purge_domain_regex = '^(' . join('|', $chunk) . ')$'; // Tell Varnish. foreach ($wpe_varnish_servers as $varnish) { $headers = array('X-Purge-Path' => $path_regex, 'X-Purge-Host' => $purge_domain_regex); $ok = WpeCommon::http_request_async('PURGE', $varnish, 9002, $hostname, '/', $headers, 0); if (!$ok) { error_log("purge_varnish_cache() failed for: ({$varnish}) #{$purge_domain_regex}# #{$path_regex}#"); } } } return true; }
function wp_cache_post_change($post_id) { global $file_prefix, $cache_path, $blog_id, $super_cache_enabled, $blog_cache_dir, $blogcacheid; static $last_processed = -1; if ($post_id == $last_processed) { return $post_id; } $last_processed = $post_id; if (!wp_cache_writers_entry()) { return $post_id; } $permalink = trailingslashit(str_replace(get_option('siteurl'), '', post_permalink($post_id))); if ($super_cache_enabled) { $siteurl = trailingslashit(strtolower(preg_replace('/:.*$/', '', str_replace('http://', '', get_option('home'))))); // make sure the front page has a rebuild file if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug("Post change: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4); } prune_super_cache($cache_path . 'supercache/' . $siteurl . 'index.html', true, true); prune_super_cache($cache_path . 'supercache/' . $siteurl . 'index.html.gz', true, true); wp_cache_post_id_gc($siteurl, $post_id); if (get_option('show_on_front') == 'page') { wp_cache_post_id_gc($siteurl, get_option('page_on_front')); wp_cache_post_id_gc($siteurl, get_option('page_for_posts')); } } $matches = array(); if ($handle = @opendir($blog_cache_dir . 'meta/')) { while (false !== ($file = readdir($handle))) { if (preg_match("/^({$file_prefix}{$blogcacheid}.*)\\.meta/", $file, $matches)) { $meta_pathname = $blog_cache_dir . 'meta/' . $file; $content_pathname = $blog_cache_dir . $matches[1] . ".html"; $meta = unserialize(@file_get_contents($meta_pathname)); if (false == is_array($meta)) { @unlink($meta_pathname); @unlink($content_pathname); continue; } if ($post_id > 0 && $meta) { if ($meta['blog_id'] == $blog_id && (!$meta['post'] || $meta['post'] == $post_id)) { @unlink($meta_pathname); @unlink($content_pathname); @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit($meta['uri']) . 'index.html'); @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit($meta['uri']) . 'index.html.gz'); } } elseif ($meta['blog_id'] == $blog_id) { @unlink($meta_pathname); @unlink($content_pathname); @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit($meta['uri']) . 'index.html'); @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit($meta['uri']) . 'index.html.gz'); } } } closedir($handle); } wp_cache_writers_exit(); return $post_id; }
/** * Retrieve list of recent posts. * * @since 1.5.0 * * @param array $args Method parameters. * @return array|IXR_Error */ public function mw_getRecentPosts($args) { $this->escape($args); $username = $args[1]; $password = $args[2]; if (isset($args[3])) { $query = array('numberposts' => absint($args[3])); } else { $query = array(); } if (!($user = $this->login($username, $password))) { return $this->error; } if (!current_user_can('edit_posts')) { return new IXR_Error(401, __('Sorry, you cannot edit posts on this site.')); } /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); $posts_list = wp_get_recent_posts($query); if (!$posts_list) { return array(); } $recent_posts = array(); foreach ($posts_list as $entry) { if (!current_user_can('edit_post', $entry['ID'])) { continue; } $post_date = $this->_convert_date($entry['post_date']); $post_date_gmt = $this->_convert_date_gmt($entry['post_date_gmt'], $entry['post_date']); $post_modified = $this->_convert_date($entry['post_modified']); $post_modified_gmt = $this->_convert_date_gmt($entry['post_modified_gmt'], $entry['post_modified']); $categories = array(); $catids = wp_get_post_categories($entry['ID']); foreach ($catids as $catid) { $categories[] = get_cat_name($catid); } $tagnames = array(); $tags = wp_get_post_tags($entry['ID']); if (!empty($tags)) { foreach ($tags as $tag) { $tagnames[] = $tag->name; } $tagnames = implode(', ', $tagnames); } else { $tagnames = ''; } $post = get_extended($entry['post_content']); $link = post_permalink($entry['ID']); // Get the post author info. $author = get_userdata($entry['post_author']); $allow_comments = 'open' == $entry['comment_status'] ? 1 : 0; $allow_pings = 'open' == $entry['ping_status'] ? 1 : 0; // Consider future posts as published if ($entry['post_status'] === 'future') { $entry['post_status'] = 'publish'; } // Get post format $post_format = get_post_format($entry['ID']); if (empty($post_format)) { $post_format = 'standard'; } $recent_posts[] = array('dateCreated' => $post_date, 'userid' => $entry['post_author'], 'postid' => (string) $entry['ID'], 'description' => $post['main'], 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], 'mt_text_more' => $post['extended'], 'wp_more_text' => $post['more_text'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'mt_keywords' => $tagnames, 'wp_slug' => $entry['post_name'], 'wp_password' => $entry['post_password'], 'wp_author_id' => (string) $author->ID, 'wp_author_display_name' => $author->display_name, 'date_created_gmt' => $post_date_gmt, 'post_status' => $entry['post_status'], 'custom_fields' => $this->get_custom_fields($entry['ID']), 'wp_post_format' => $post_format, 'date_modified' => $post_modified, 'date_modified_gmt' => $post_modified_gmt, 'sticky' => $entry['post_type'] === 'post' && is_sticky($entry['ID']), 'wp_post_thumbnail' => get_post_thumbnail_id($entry['ID'])); } return $recent_posts; }
<?php if (is_single()) { ?> <button id="btVolta" class="ctrl"><span class="volta"></span></button> <div id="sidebarNoticias"> <ul class="maisNoticias"> <?php $attr = array('posts_per_page' => -1); $wp_query = new WP_Query($attr); if ($wp_query->have_posts()) { while ($wp_query->have_posts()) { $wp_query->the_post(); echo '<li class="itemNoticias">' . '<hr />' . '<a href="' . post_permalink() . '">' . '<h3>'; the_title(); echo '</h3>' . '<h4>' . get_field('subtitulo') . '</h4>' . '</a>' . '</li>'; } } ?> </ul> </div> <button id="btVai" class="ctrl"><span class="vai"></span></button> <?php } ?> </aside>
/** * Set opengraph URL to use URL including query vars * * @since 1.1 */ function edd_wl_add_og_url() { if (get_query_var('wl_view')) { $post = get_post(get_query_var('wl_view')); $post_content = $post ? $post->post_content : ''; ?> <meta property="og:title" content="<?php wp_title('|', true, 'right'); ?> " /> <meta property="og:url" content="<?php echo trailingslashit(post_permalink(get_query_var('wl_view'))); ?> " /> <meta property="og:description" content="<?php echo esc_attr($post_content); ?> " /> <link rel="canonical" href="<?php echo trailingslashit(post_permalink(get_query_var('wl_view'))); ?> " /> <?php } }
$c = 0; while ($wp_query->have_posts()) { $wp_query->the_post(); $c++; if ($c == 1) { echo '<li class="noticiaDestaque">' . '<a class="linkNoticiaDestaque" href="' . post_permalink() . '">'; if (has_post_thumbnail()) { the_post_thumbnail('large'); } echo '</a>' . '<div class="conteudoNoticiaDestaque">' . '<a class="linkDoTitulo" href="' . post_permalink() . '">' . '<h3>' . get_the_title() . '</h3>' . '<h4>' . get_field('subtitulo') . '</h4>' . '</a>' . '<p>' . get_the_excerpt() . '</p>' . '</div>' . '</li>'; } else { echo '<li class="outrasNoticias">' . '<a class="linkImagemOutrasNoticias" href="' . post_permalink() . '">'; if (has_post_thumbnail()) { the_post_thumbnail('medium'); } echo '</a>' . '<a class="linkPostOutrasNoticias" href="' . post_permalink() . '">' . '<h3>'; the_title(); echo '</h3>'; if (get_field('subtitulo')) { echo '<h4>' . get_field('subtitulo') . '</h4>'; } echo '</a>' . '</li>'; } } } ?> </ul> </div> </section>