コード例 #1
0
 public function ajax_handler($data)
 {
     CS_Shortcode_Preserver::init();
     if ($this->sandbox_the_content) {
         CS_Shortcode_Preserver::sandbox('cs_render_the_content');
     }
     add_filter('cs_preserve_shortcodes_no_wrap', '__return_true');
     $this->orchestrator = $this->plugin->component('Element_Orchestrator');
     $this->orchestrator->load_elements();
     $this->mk1 = new Cornerstone_Legacy_Renderer($this->plugin->component('Legacy_Elements'));
     global $post;
     if (!isset($data['post_id']) || !($post = get_post((int) $data['post_id']))) {
         wp_send_json_error(array('message' => 'post_id not set'));
     }
     setup_postdata($post);
     $this->enqueue_extractor = $this->plugin->loadComponent('Enqueue_Extractor');
     $this->enqueue_extractor->start();
     if (isset($data['raw_markup'])) {
         $this->raw_markup = (bool) $data['raw_markup'];
     }
     if (!isset($data['batch'])) {
         wp_send_json_error(array('message' => 'No element data recieved'));
     }
     $jobs = $this->batch($data['batch']);
     $scripts = $this->enqueue_extractor->get_scripts();
     if (is_wp_error($jobs)) {
         wp_send_json_error(array('message' => $jobs->get_error_message()));
     }
     $result = array('jobs' => $jobs, 'scripts' => $scripts);
     //Suppress PHP error output unless debugging
     if (CS()->common()->isDebug()) {
         return wp_send_json_success($result);
     }
     return @wp_send_json_success($result);
 }
コード例 #2
0
function start_wp()
{
    global $wp_query, $post;
    // Since the old style loop is being used, advance the query iterator here.
    $wp_query->next_post();
    setup_postdata($post);
}
コード例 #3
0
ファイル: functions.php プロジェクト: leshuis/testwp
function ipin_head()
{
    //Opengraph
    if (is_single()) {
        global $post;
        setup_postdata($post);
        $output = '<meta property="og:type" content="article" />' . "\n";
        $output .= '<meta property="og:title" content="' . preg_replace('/[\\n\\r]/', ' ', mb_strimwidth(the_title_attribute('echo=0'), 0, 255, ' ...')) . '" />' . "\n";
        $output .= '<meta property="og:url" content="' . get_permalink() . '" />' . "\n";
        if ($post->post_content == '') {
            $meta_categories = get_the_category($post->ID);
            foreach ($meta_categories as $meta_category) {
                $meta_category_name = $meta_category->name;
            }
            if (ipin_get_post_board()) {
                $meta_board_name = ipin_get_post_board()->name;
            } else {
                $meta_board_name = __('Untitled', ipin);
            }
            $output .= '<meta property="og:description" content="' . esc_attr(__('Pinned onto', 'ipin') . ' ' . $meta_board_name . ' ' . __('Board in', 'ipin') . ' ' . $meta_category_name . ' ' . __('Category', 'ipin')) . '" />' . "\n";
        } else {
            $output .= '<meta property="og:description" content="' . esc_attr(get_the_excerpt()) . '" />' . "\n";
        }
        if (has_post_thumbnail()) {
            $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
            $output .= '<meta property="og:image" content="' . $imgsrc[0] . '" />' . "\n";
        }
        if (get_option('wsl_settings_Facebook_app_id')) {
            $output .= '<meta property="fb:app_id" content="' . get_option('wsl_settings_Facebook_app_id') . '" />' . "\n";
        }
        echo $output;
    }
    if (is_tax('board')) {
        global $post, $wp_query, $wp_taxonomies;
        setup_postdata($post);
        $output = '<meta property="og:type" content="article" />' . "\n";
        $output .= '<meta property="og:title" content="' . esc_attr($wp_query->queried_object->name) . '" />' . "\n";
        $output .= '<meta property="og:url" content="' . home_url('/' . $wp_taxonomies["board"]->rewrite['slug'] . '/' . sanitize_title($wp_query->queried_object->name, '_') . '/') . $wp_query->queried_object->term_id . '/" />' . "\n";
        $output .= '<meta property="og:description" content="" />' . "\n";
        if (has_post_thumbnail()) {
            $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
            $output .= '<meta property="og:image" content="' . $imgsrc[0] . '" />' . "\n";
        }
        echo $output;
    }
    if (is_author()) {
        global $wp_query, $wp_rewrite;
        $user_info = get_user_by('id', $wp_query->query_vars['author']);
        $output = '<meta property="og:type" content="article" />' . "\n";
        $output .= '<meta property="og:title" content="' . esc_attr($user_info->display_name) . ' (' . $user_info->user_nicename . ')" />' . "\n";
        $output .= '<meta property="og:url" content="' . home_url('/') . $wp_rewrite->author_base . '/' . $user_info->user_nicename . '/" />' . "\n";
        $output .= '<meta property="og:description" content="' . esc_attr($user_info->description) . '" />' . "\n";
        $avatar_id = get_user_meta($user_info->ID, 'ipin_user_avatar', true);
        if ($avatar_id != '' && $avatar_id != 'deleted') {
            $user_avatar = wp_get_attachment_image_src($avatar_id, 'full');
            $output .= '<meta property="og:image" content="' . $user_avatar[0] . '" />' . "\n";
        }
        echo $output;
    }
}
コード例 #4
0
ファイル: menu-fullwidth.php プロジェクト: tanzoor/wpbss
function wpbss_main_menu_fallback()
{
    global $post;
    $args = array('post_type' => 'page', 'post_status' => 'publish', 'hierarchical' => 0);
    $pages = get_pages($args);
    //var_dump($pages);
    ?>
	<ul class="nav navbar-nav">
		<?php 
    foreach ($pages as $post) {
        setup_postdata($post);
        ?>
			<li>
				<a href="<?php 
        the_permalink();
        ?>
"><?php 
        echo $post->post_title;
        ?>
</a>
			</li>
		<?php 
    }
    wp_reset_postdata();
    ?>
	</ul>
<?php 
}
コード例 #5
0
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $numberposts = isset($instance['numberposts']) ? $instance['numberposts'] : 1;
     $termargs = array('post_type' => 'glossary', 'post_status' => 'publish', 'numberposts' => $numberposts, 'orderby' => 'rand');
     if ($group = $instance['group']) {
         $termargs['tax_query'] = array(array('taxonomy' => 'wpglossarygroup', 'field' => 'slug', 'terms' => $group));
     }
     $terms = get_posts($termargs);
     if ($terms && count($terms)) {
         echo '<ul class="wpglossary widget-list">';
         foreach ($terms as $term) {
             setup_postdata($term);
             $title = '<a href="' . apply_filters('wpg_term_link', get_post_permalink($term->ID)) . '">' . get_the_title($term->ID) . '</a>';
             $desc = '';
             $display = $instance['display'];
             if ($display && $display != 'title') {
                 $desc = $display == 'full' ? apply_filters('the_content', get_the_content(), $main = false) : wpautop(get_the_excerpt());
                 $desc = '<br>' . $desc;
             }
             echo '<li>' . $title . $desc . '</li>';
         }
         wp_reset_postdata();
         echo '</ul>';
     } else {
         echo '<em>' . __('No terms available', 'wp-glossary') . '</em>';
     }
     echo $after_widget;
 }
コード例 #6
0
    /** @see WP_Widget::widget */
    function widget($args, $instance)
    {
        extract($args);
        echo $before_widget;
        $a = array("orderby" => "id", "order" => "asc");
        $categories = get_categories($a);
        foreach ($categories as $category) {
            echo $before_title;
            // var_dump($category);
            echo "<h2>" . $category->name . "</h2><ul>";
            global $post;
            $args = array('category' => $category->term_id, "numberposts" => -1, "orderby" => "title", "order" => "ASC");
            $myposts = get_posts($args);
            foreach ($myposts as $post) {
                setup_postdata($post);
                ?>
<li><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></li><?php 
            }
            echo "</ul>";
            wp_reset_query();
            echo $after_title;
        }
        echo $after_widget;
    }
コード例 #7
0
ファイル: carrington.php プロジェクト: Linuxwang/PIE
function cfct_about_text()
{
    $about_text = get_option('cfct_about_text');
    if (!empty($about_text)) {
        $about_text = cfct_basic_content_formatting($about_text);
    } else {
        global $post, $wp_query;
        $orig_post = $post;
        isset($wp_query->query_vars['page']) ? $page = $wp_query->query_vars['page'] : ($page = null);
        // temporary - resetting below
        $wp_query->query_vars['page'] = null;
        remove_filter('the_excerpt', 'st_add_widget');
        $about_query = new WP_Query('pagename=about');
        while ($about_query->have_posts()) {
            $about_query->the_post();
            $about_text = get_the_excerpt() . sprintf(__('<a class="more" href="%s">more &rarr;</a>', 'carrington'), get_permalink());
        }
        $wp_query->query_vars['page'] = $page;
        $post = $orig_post;
        setup_postdata($post);
    }
    if (function_exists('st_add_widget')) {
        add_filter('the_excerpt', 'st_add_widget');
    }
    return $about_text;
}
コード例 #8
0
 /**
  * Get a post by a specified field and value
  *
  * @param string $field
  * @param string $field_value
  * @param string $context Post use context (e.g. 'display')
  * @return array Post
  **/
 function get_post_by($field, $field_value, $context = 'display')
 {
     // validate input
     if (!in_array($field, array('ID', 'name'))) {
         return new WP_Error('invalid_field', 'Invalid API FIELD', 400);
     }
     if (!in_array($context, array('display', 'edit'))) {
         return new WP_Error('invalid_context', 'Invalid API CONTEXT', 400);
     }
     if ('display' === $context) {
         $args = $this->query_args();
         if (isset($args['content_width']) && $args['content_width']) {
             $GLOBALS['content_width'] = (int) $args['content_width'];
         }
     }
     if (strpos($_SERVER['HTTP_USER_AGENT'], 'wp-windows8')) {
         remove_shortcode('gallery', 'gallery_shortcode');
         add_shortcode('gallery', array(&$this, 'win8_gallery_shortcode'));
     }
     // fetch SAL post
     $post = $this->get_sal_post_by($field, $field_value, $context);
     if (is_wp_error($post)) {
         return $post;
     }
     $GLOBALS['post'] = $post;
     // TODO: not sure where this one should go
     if ('display' === $context) {
         setup_postdata($post);
     }
     $response = $this->render_response_keys($post, $context, array_keys($this->post_object_format));
     unset($GLOBALS['post']);
     return $response;
 }
コード例 #9
0
ファイル: postpicker.php プロジェクト: studio-montana/custom
/**
 * retrieve post
*/
function postpicker_ajax_postpicker_get_post()
{
    if (!check_ajax_referer('postpicker-ajax-nonce', 'ajaxNonce', false)) {
        die('Busted!');
    }
    $response = array('what' => 'postpicker_ajax_postpicker_get_post', 'action' => 'postpicker_ajax_postpicker_get_post', 'id' => '1');
    $results = "";
    $post_id = null;
    if (isset($_POST['post_id']) && !empty($_POST['post_id'])) {
        $post_id = $_POST['post_id'];
    }
    $asked_post = get_post($post_id);
    if ($asked_post) {
        global $post;
        $post = $asked_post;
        setup_postdata($post);
        ob_start();
        $postpick_item_template = locate_ressource(CUSTOM_PLUGIN_COMMONS_FOLDER . '/postpicker/templates/postpicker-item.php');
        if (!empty($postpick_item_template)) {
            include $postpick_item_template;
        }
        $results = ob_get_contents();
        ob_end_clean();
        wp_reset_postdata();
    }
    $response['data'] = $results;
    $xmlResponse = new WP_Ajax_Response($response);
    $xmlResponse->send();
    exit;
}
コード例 #10
0
ファイル: functions.php プロジェクト: alloylabs/PatternPress
function patterns_meta_box($post)
{
    wp_nonce_field(plugin_basename(__FILE__), 'patterns_noncename');
    $html = get_post_meta($post->ID, 'html', true);
    $css = get_post_meta($post->ID, 'css', true);
    $resources = get_post_meta($post->ID, 'resources', true);
    $notes = get_post_meta($post->ID, 'notes', true);
    $height = get_post_meta($post->ID, 'height', true);
    $usepattern = get_post_meta($post->ID, 'usepattern', true);
    echo '<label for="' . $post->post_name . '"><input type="checkbox" name="usepattern" id="usepattern" value="true"' . ($usepattern ? ' checked="true"' : '') . '>Show Pattern Options</input></label><br/>';
    echo '<label class="pattern-label" for="resources">Resources</label>';
    echo '<div class="form-wrap">
  	      <fieldset>';
    $args = array('post_type' => 'resource', 'published' => true, 'meta_key' => 'priority', 'orderby' => 'meta_value_num', 'order' => 'ASC');
    $myposts = get_posts($args);
    foreach ($myposts as $post) {
        setup_postdata($post);
        echo '<label for="' . $post->post_name . '"><input type="checkbox" name="resources[]" id="' . $post->post_name . '" value="' . $post->ID . '"' . ($resources && in_array($post->ID, $resources) ? ' checked="true"' : '') . '>' . $post->post_title . '</input></label>';
    }
    wp_reset_postdata();
    echo '</fieldset>
  	      </div>';
    echo '<label class="pattern-label" for="html">Preview Height (px)</label>';
    echo '<input type="number" id="height" name="height" style="width:120px;float:left;clear:both;" value="' . ($height ? $height : "300") . '"/>';
    echo '<label class="pattern-label" for="html">HTML</label>';
    echo '<textarea id="html" name="html" rows="10" cols="90" style="width:100%">' . $html . '</textarea>';
    echo '<label class="pattern-label" for="css">CSS</label>';
    echo '<textarea id="css" name="css" rows="10" cols="90" style="width:100%">' . $css . '</textarea>';
    echo '<div class="form-wrap"><label class="pattern-label">Notes</label>	';
    wp_editor($notes, 'notes');
    echo "</div>";
}
コード例 #11
0
 /**
  * The shortcode to display the single book layout.
  *
  * [tb_book id="3"]
  *
  * @param $atts
  * @return string
  */
 function book_shortcode($atts)
 {
     global $post;
     extract(shortcode_atts(array('id' => false), $atts));
     if (!$id) {
         return '';
     }
     //Store The Original Post Object.
     $original_post = $post;
     $post = get_post($id);
     //Remove The Shortcode Filter to avoid a repeating loop..
     remove_filter('the_content', 'do_shortcode', 11);
     //Set The Post
     setup_postdata($post);
     ob_start();
     tb_get_template_part(apply_filters('tb_book_shortcode_template_part', 'loops/single_book'));
     echo '<div class="clear"></div>';
     $out = ob_get_contents();
     ob_end_clean();
     //Reinstate The Original Post.
     $post = $original_post;
     setup_postdata($original_post);
     //Re-Add The Filter
     add_filter('the_content', 'do_shortcode', 11);
     return $out;
 }
コード例 #12
0
 public function __construct($thePost = null, $mainQuery = true)
 {
     global $post;
     $this->isMainQuery = (bool) $mainQuery;
     if (is_object($thePost)) {
         $this->wpo = $thePost;
     } else {
         if (is_numeric($thePost)) {
             $this->wpo = get_post($thePost);
         } else {
             if (is_string($thePost)) {
                 $this->wpo = new \WP_Query(array('name' => $thePost));
             } else {
                 $this->wpo = $post;
             }
         }
     }
     /*
     		@link https://codex.wordpress.org/Function_Reference/setup_postdata
     		Sets up global post data. Helps to format custom query results for using Template tags.
     		setup_postdata() fills the global variables $id, $authordata, $currentday, $currentmonth,
     		$page, $pages, $multipage, $more, $numpages, which help many Template Tags work in the
     		current post context. It does not assign the global $post variable, but seems to expect
     		that its argument is a reference to it.
     */
     if ($this->isMainQuery) {
         setup_postdata($this->wpo);
     }
 }
コード例 #13
0
 public static function process()
 {
     theme_features::check_referer();
     $post_id = isset($_GET['post-id']) && is_numeric($_GET['post-id']) ? (int) $_GET['post-id'] : false;
     if (!$post_id) {
         die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_post_id', 'msg' => ___('Sorry, post id is invaild.')]));
     }
     global $post, $page;
     /**
      * post
      */
     $post = theme_cache::get_post($post_id);
     if (!$post) {
         die(theme_features::json_format(['status' => 'error', 'code' => 'post_not_exist', 'msg' => ___('Sorry, the post does not exist.')]));
     }
     /**
      * page
      */
     $page = isset($_GET['page']) && is_numeric($_GET['page']) ? (int) $_GET['page'] : false;
     if (!$page) {
         die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_page_number', 'msg' => ___('Sorry, page number is invaild.')]));
     }
     set_query_var('page', $page);
     setup_postdata($post);
     ob_start();
     if (class_exists('theme_img_lazyload')) {
         remove_filter('the_content', 'theme_img_lazyload::the_content');
     }
     the_content();
     $content = html_minify(ob_get_contents());
     ob_end_clean();
     die(theme_features::json_format(['status' => 'success', 'content' => $content]));
 }
コード例 #14
0
ファイル: functions.php プロジェクト: TheProjecter/mangapress
/**
 * Handles display for the latest comic page.
 *
 * @global object $mp MangaPress bootstrap object
 * @global object $post WordPress Post
 * @global array $_wp_additional_image_sizes Array defining thumbnail names and dimensions.
 *
 * @since 2.7
 * @param string $template
 * @return string
 */
function mpp_filter_latest_comic($content)
{
    global $post, $mp, $_wp_additional_image_sizes;
    $mp_options = $mp->get_options();
    if (!($post->post_name == $mp_options['basic']['latestcomic_page'])) {
        return $content;
    } else {
        global $thumbnail_size, $single_comic_query;
        $single_comic_query = mpp_get_latest_comic();
        if ($single_comic_query instanceof WP_Error) {
            return apply_filters('the_latest_comic_content_error', '<p class="error">No Latest Comic was found.</p>');
        }
        $thumbnail_size = 'comic-page';
        if (!isset($_wp_additional_image_sizes['comic-page'])) {
            $thumbnail_size = 'large';
        }
        if (!isset($single_comic_query->posts[0])) {
            ob_start();
            load_template(MP_ABSPATH . 'templates/content/no-comics.php', true);
            $content = ob_get_contents();
            ob_end_clean();
        } else {
            $post = $single_comic_query->posts[0];
            setup_postdata($post);
            ob_start();
            load_template(MP_ABSPATH . 'templates/content/latest-comic.php', true);
            $content = ob_get_contents();
            ob_end_clean();
        }
        return apply_filters('the_latest_comic_content', $content);
    }
}
コード例 #15
0
 public static function estimate_embed($atts = array())
 {
     do_action('sprout_invoices_estimate_embed');
     $estimate_id = 0;
     // Make sure id given is for an invoice
     if (isset($atts['id'])) {
         $estimate_id = (int) $atts['id'];
     }
     if (isset($_GET['si_id'])) {
         $estimate_id = (int) $_GET['si_id'];
     }
     if (SI_Estimate::POST_TYPE !== get_post_type($estimate_id)) {
         return;
     }
     // enqueue style
     self::frontend_enqueue();
     // Show snippet view or not.
     $embed_view = '';
     if (isset($atts['snippet']) && 'true' === $atts['snippet']) {
         $embed_view = '-snippet';
     }
     self::remove_actions();
     // Setup global post for filters and functions to work
     global $post;
     $post = get_post($estimate_id);
     setup_postdata($post);
     $estimate = SI_Estimate::get_instance($estimate_id);
     $line_items = $estimate->get_line_items();
     $view = self::load_addon_view_to_string('estimates/embed' . $embed_view, array('id' => $estimate_id, 'line_items' => $line_items, 'prev_type' => '', 'totals' => SI_Line_Items::line_item_totals($estimate_id)), false);
     // reset to the original post
     wp_reset_postdata();
     return $view;
 }
コード例 #16
0
 /**
  * Trigger.
  *
  * @version 2.4.0
  */
 function trigger($order_id)
 {
     if ($order_id) {
         $this->object = wc_get_order($order_id);
         if ($this->customer_email) {
             $this->recipient = $this->object->billing_email;
         }
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     if ($order_id) {
         global $post;
         $order = wc_get_order($order_id);
         $post = $order->post;
         setup_postdata($post);
     }
     $this->send($this->get_recipient(), $this->get_subject(), do_shortcode($this->get_content()), $this->get_headers(), $this->get_attachments());
     if ($order_id) {
         wp_reset_postdata();
     }
 }
コード例 #17
0
function most_viewed()
{
    ob_start();
    $posts = wmp_get_popular(array('limit' => 4, 'post_type' => 'paper', 'range' => 'all_time'));
    global $post;
    if (count($posts) > 0) {
        foreach ($posts as $post) {
            setup_postdata($post);
            ?>
		<li><a href="<?php 
            the_permalink();
            ?>
">
			<?php 
            if (get_field('short_title')) {
                the_field('short_title');
            } else {
                the_title();
            }
            ?>
		</a></li>
		<?php 
        }
    }
    wp_reset_query();
    $contents = ob_get_contents();
    ob_end_clean();
    return $contents;
}
コード例 #18
0
ファイル: featured_video.php プロジェクト: annguyenit/getdeal
        function widget($args, $instance)
        {
            // prints the widget
            extract($args, EXTR_SKIP);
            echo $before_widget;
            $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
            $category = empty($instance['category']) ? '' : apply_filters('widget_category', $instance['category']);
            $post_type = empty($instance['post_type']) ? 'post' : apply_filters('widget_post_type', $instance['post_type']);
            $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
            ?>
			<div class="featured_video">		
			<?php 
            if ($title) {
                ?>
<h3 class="clearfix"> <?php 
                echo $title;
                ?>
</h3><?php 
            }
            ?>
            <?php 
            global $post;
            $args = '';
            if ($category) {
                $args .= '&category=' . $category;
            }
            $latest_menus = get_posts('numberposts=' . $post_number . $args . '&post_type=' . $post_type);
            foreach ($latest_menus as $post) {
                setup_postdata($post);
                if (get_post_meta($post->ID, 'video', true) || get_post_meta($post->ID, 'Video', true) || get_post_meta($post->ID, 'VIDEO', true)) {
                    if (get_post_meta($post->ID, 'video', true)) {
                        $video = get_post_meta($post->ID, 'video', true);
                    } elseif (get_post_meta($post->ID, 'Video', true)) {
                        $video = get_post_meta($post->ID, 'Video', true);
                    } elseif (get_post_meta($post->ID, 'VIDEO', true)) {
                        $video = get_post_meta($post->ID, 'VIDEO', true);
                    }
                    ?>
                 <div class="video">
                <?php 
                    echo $video;
                    ?>
                    <h4><a class="widget-title" href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
 </a></h4>
                </div>
                <?php 
                }
                ?>
             <?php 
            }
            ?>
             </div>
            <?php 
            echo $after_widget;
        }
コード例 #19
0
    function form($instance)
    {
        ?>
        <p><label for="<?php 
        echo $this->get_field_id('ewic_shortcode');
        ?>
">Select your Slider name and hit save button.<br />
    <select id="<?php 
        echo $this->get_field_id('ewic_shortcode');
        ?>
" name="<?php 
        echo $this->get_field_name('ewic_shortcode');
        ?>
" >
	<?php 
        global $post;
        $args = array('post_type' => 'easyimageslider', 'order' => 'ASC', 'posts_per_page' => -1, 'post_status' => 'publish');
        $myposts = get_posts($args);
        foreach ($myposts as $post) {
            setup_postdata($post);
            echo '<option value=' . $post->ID . '' . selected($instance["ewic_shortcode"], $post->ID) . '>' . esc_html(esc_js(the_title(NULL, NULL, FALSE))) . '</option>';
        }
        ?>
</select></label></p>
        <?php 
    }
コード例 #20
0
function mdwpbp_related_posts()
{
    global $post;
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
        foreach ($tags as $tag) {
            $tag_arr = $tag->slug . ',';
        }
        $args = array('tag' => $tag_arr, 'numberposts' => 5, 'post__not_in' => array($post->ID));
        $related_posts = get_posts($args);
        if ($related_posts) {
            echo '<p class="related-posts-header">Related Posts</p><ul id="mdwpbp-related-posts">';
            foreach ($related_posts as $post) {
                setup_postdata($post);
                echo '<li class="related-post"><a href="';
                the_permalink();
                echo '">';
                the_title();
                echo '</a></li>';
            }
            echo '</ul>';
        }
    }
    // if ($tags)
    wp_reset_postdata();
}
コード例 #21
0
/**
 * Get the location
 * @return
 */
function the_location()
{
    global $location, $location_list;
    $location_list->in_the_loop = true;
    $location = $location_list->next_post();
    setup_postdata($location);
}
コード例 #22
0
 function test_thematic_link_pages_args()
 {
     $post = $this->factory->post->create_and_get(array('post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3'));
     setup_postdata($post);
     $content = wp_link_pages(array('before' => sprintf('<nav class="page-link">%s', __('Pages:', 'thematic')), 'after' => '</nav>', 'echo' => '0'));
     $this->assertRegexp('/^<nav/', $content);
 }
コード例 #23
0
ファイル: Post.php プロジェクト: silversite/silverwp
 /**
  * Latest blog posts
  *
  * @param int    $limit post display limit
  *
  * @param string $thumbnail_size
  *
  * @return array
  */
 public static function getRecent($limit = 10, $thumbnail_size = 'thumbnail')
 {
     $args = array('numberposts' => $limit, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending', 'suppress_filters' => true);
     $array_out = array();
     $recent_posts = \get_posts(\wp_parse_args($args));
     /*$like_bool    = Option::get_theme_option( 'blog_list_like' );
       if ( $like_bool === '1' ) {
           $PostLike = \SilverWp\Ajax\PostLike::getInstance();
       }*/
     foreach ($recent_posts as $key => $recent) {
         \setup_postdata($recent);
         $post_id = $recent->ID;
         //$array_out[ $key ] = $recent;
         $array_out[$key]['ID'] = $post_id;
         $array_out[$key]['post_title'] = \get_the_title($post_id);
         $array_out[$key]['url'] = \get_the_permalink($post_id);
         $array_out[$key]['post_author'] = \get_the_author();
         $array_out[$key]['post_date'] = \get_the_date('', $post_id);
         $array_out[$key]['post_date_utc'] = \get_the_time('c', $post_id);
         //$array_out[ $key ]['post_like'] = ($like_bool === '1') ? $PostLike->getPostLikeCount($post_id) : '';
         $array_out[$key]['post_comment_count'] = $recent->comment_count;
         if (strpos($recent->post_content, '<!--more-->') || empty($recent->post_excerpt)) {
             $array_out[$key]['post_excerpt'] = \get_the_excerpt();
         } else {
             $array_out[$key]['post_excerpt'] = $recent->post_excerpt;
         }
         $array_out[$key]['image_html'] = \get_the_post_thumbnail($post_id, $thumbnail_size);
         // Thumbnail
         $array_out[$key]['categories'] = self::getTaxonomy($post_id);
     }
     \wp_reset_postdata();
     return $array_out;
 }
コード例 #24
0
/**
 * Render Popup Columns
 *
 * @since 1.0
 *
 * @param string $column_name Column name
 * @param int $post_id Popup (Post) ID
 *
 * @return void
 */
function popmake_render_popup_columns($column_name, $post_id)
{
    if (get_post_type($post_id) == 'popup') {
        global $popmake_options;
        $post = get_post($post_id);
        setup_postdata($post);
        $post_type_object = get_post_type_object($post->post_type);
        $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID);
        switch ($column_name) {
            case 'popup_title':
                echo '<strong>' . esc_html(popmake_get_the_popup_title($post_id)) . '</strong>';
                break;
            case 'popup_category':
                echo get_the_term_list($post_id, 'popup_category', '', ', ', '');
                break;
            case 'popup_tag':
                echo get_the_term_list($post_id, 'popup_tag', '', ', ', '');
                break;
            case 'class':
                echo '<pre style="display:inline-block;margin:0;"><code>popmake-' . absint($post_id) . '</code></pre>';
                if ($post->post_name != $post->ID) {
                    echo '|';
                    echo '<pre style="display:inline-block;margin:0;"><code>popmake-' . $post->post_name . '</code></pre>';
                }
                break;
        }
    }
}
コード例 #25
0
ファイル: totc.php プロジェクト: Ruxton/ToTC
function totc_children($atts)
{
    global $post;
    global $more;
    $more = 0;
    $return = "";
    $oldpost = $post;
    if ($post->ID) {
        $args = array('post_parent' => $post->ID, 'post_type' => 'page', 'orderby' => 'date', 'order' => 'DESC');
        $children = get_posts($args);
        if ($children) {
            foreach ($children as $post) {
                setup_postdata($post);
                $more = 0;
                $content = get_the_content('');
                $content = apply_filters('the_content', $content);
                $content = str_replace(']]>', ']]&gt;', $content);
                $return .= '<h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>
' . $content;
            }
        }
    }
    setup_postdata($oldpost);
    return $return;
}
コード例 #26
0
    function widget($args, $instance)
    {
        extract($args);
        $title_widget = $instance['title_widget'];
        $limit = $instance['limit'];
        echo $before_widget;
        echo '<h3 class="widget-title">' . $title_widget . '</h3>';
        echo '<ul>';
        $args = array('posts_per_page' => $limit, 'post_type' => 'coupons', 'meta_key' => 'clicks', 'orderby' => 'meta_value', 'order' => 'DESC');
        $coupons = get_posts($args);
        foreach ($coupons as $coupon) {
            setup_postdata($coupon);
            ?>
                    
						<li>
							<a href="<?php 
            echo get_permalink($coupon->ID);
            ?>
"><?php 
            echo get_the_title($coupon->ID);
            ?>
 ( <?php 
            echo get_post_meta($coupon->ID, 'coupon_discount', true);
            ?>
 )</a>
						</li>
					
					<?php 
        }
        wp_reset_postdata();
        echo '</ul>';
        echo $after_widget;
    }
コード例 #27
0
ファイル: woo-tabs.php プロジェクト: shramee/test-ppb
    function woo_widget_tabs_latest($posts = 5, $size = 45)
    {
        global $post;
        $latest = get_posts(array('suppress_filters' => false, 'ignore_sticky_posts' => 1, 'orderby' => 'post_date', 'order' => 'desc', 'numberposts' => $posts));
        foreach ($latest as $post) {
            setup_postdata($post);
            ?>
			<li>
				<?php 
            if ($size != 0) {
                woo_image('height=' . $size . '&width=' . $size . '&class=thumbnail&single=true');
            }
            ?>
				<a title="<?php 
            the_title_attribute();
            ?>
" href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
				<span class="meta"><?php 
            the_time(get_option('date_format'));
            ?>
</span>
				<div class="fix"></div>
			</li>
		<?php 
        }
        wp_reset_postdata();
    }
コード例 #28
0
    function column_default($item, $column_name)
    {
        switch ($column_name) {
            case 'author':
                $user_info = get_userdata($item->post_author);
                if (!$user_info) {
                    echo '<strong>Anonymous</strong>';
                } else {
                    echo '<strong>' . get_avatar($item->post_author, $size = '32') . ' ' . $user_info->display_name . '</strong>';
                }
                break;
            case 'detail':
                global $post;
                setup_postdata($item);
                ?>
        		<div class="submitted-on"><?php 
                _e('Answered on ', 'dwqa');
                ?>
<a href="<?php 
                echo get_permalink($item->ID);
                ?>
"><?php 
                echo $item->post_date;
                ?>
</a></div>
        		<?php 
                the_excerpt();
                ?>
        		<?php 
                break;
            default:
                return print_r($item, true);
        }
    }
コード例 #29
0
    function widget($args, $instance)
    {
        extract($args);
        @($title = $instance['title'] ? $instance['title'] : '最热文章');
        @($num = $instance['num'] ? $instance['num'] : 5);
        echo $before_widget;
        ?>
      <div class="panel panel-zan hidden-xs">
        <div class="panel-heading"><?php 
        echo $title;
        ?>
</div>
        <div class="panel-body">
          <ul class="list-group">
            <?php 
        // 设置全局变量,实现post整体赋值
        global $post;
        $posts = zan_get_hotest_posts($num);
        foreach ($posts as $post) {
            setup_postdata($post);
            ?>
              <li class="zan-list clearfix">
                <figure class="thumbnail zan-thumb">
                  <?php 
            the_post_thumbnail(array(75, 75));
            ?>
                </figure>
                <a href="<?php 
            the_permalink();
            ?>
">
                 <h5><?php 
            the_title();
            ?>
</h5>
                </a>
                <div class="sidebar-info">
                  <span><i class="fa fa-calendar"></i> <?php 
            the_time('m月j日, Y');
            ?>
</span>
                  <span><i class="fa fa-comment"></i> <a href="<?php 
            the_permalink();
            ?>
#comments"><?php 
            comments_number('0', '1', '%');
            ?>
</a></span>
                </div>
              </li>
            <?php 
        }
        wp_reset_postdata();
        ?>
          </ul>
        </div>
      </div>
    <?php 
        echo $after_widget;
    }
コード例 #30
0
ファイル: posts_on_page.php プロジェクト: Antario/UkifelaLLC
function short_posts_on_page($atts)
{
    global $more, $id, $post;
    ###
    $pro = true;
    // Set to 'false' for turn off external template
    ###
    $more_s = $more;
    $id_s = $id;
    $post_s = $post;
    $res = '<div id="posts_on_page">' . "\n";
    $lastposts = get_posts($atts);
    foreach ($lastposts as $post) {
        $id = $post->ID;
        setup_postdata($post);
        $more = false;
        if ($pro and $atts['template'] and file_exists(TEMPLATEPATH . '/' . $atts['template'])) {
            ob_start();
            include TEMPLATEPATH . '/' . $atts['template'];
            $res .= ob_get_contents();
            ob_end_clean();
        } else {
            $res .= '<div id="post-' . $id . '"><h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>' . "\n";
            if ($atts['show_content']) {
                $res .= apply_filters('the_content', get_the_content($atts['more_text']));
            }
            $res .= "</div>\n";
        }
    }
    $res .= "</div>\n";
    $more = $more_s;
    $id = $id_s;
    $post = $post_s;
    return $res;
}