Example #1
6
function charity_vc_our_mission($atts, $content = null)
{
    extract(shortcode_atts(array('our_mission' => ''), $atts));
    $page_id = get_page_by_title($our_mission);
    $missionQuery = new WP_Query(array("page_id" => $page_id->ID));
    if ($missionQuery->have_posts()) {
        $missionQuery->the_post();
        $url = wp_get_attachment_image_src(get_post_thumbnail_id($page_id->ID), array(1143, 479));
        ?>
        <!-- Save Lives Section Start Here-->
        <section class="save-lives text-center parallax" style="background-image: url('<?php 
        echo esc_url($url[0]);
        ?>
')">
            <div class="container">
                <div class="row">
                    <div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
                        <header class="page-header">
                            <h2><?php 
        the_title();
        ?>
</h2>
                            <?php 
        the_content();
        ?>
                        </header>
                    </div>
                </div>
            </div>
        </section>
        <!-- Save Lives Section Start Here-->
    <?php 
    }
    wp_reset_postdata();
}
 function widget($args, $instance)
 {
     ob_start();
     extract($args);
     $title = !empty($instance['title']) ? esc_attr($instance['title']) : __('Custom Menu', 'zn_framework');
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $menu = isset($instance['menu']) ? esc_attr($instance['menu']) : '';
     $style = isset($instance['style']) ? esc_attr($instance['style']) : '';
     $columns = isset($instance['columns']) ? esc_attr($instance['columns']) : '';
     if (empty($menu)) {
         echo 'Please edit the widget and select at least one menu';
         return;
     }
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     $menu_items = wp_get_nav_menu_items($menu);
     echo '<ul class="menu-' . $menu . ' ' . $style . ' clearfix ">';
     //row
     foreach ((array) $menu_items as $key => $menu_item) {
         $title = $menu_item->title;
         $url = $menu_item->url;
         echo '<li class="' . $columns . '"><a href="' . $url . '">' . $title . '</a></li>';
     }
     echo '</ul>';
     echo $after_widget;
     // Reset the global $the_post as this query will have stomped on it
     wp_reset_postdata();
 }
function bap_ajaxP_loop($offset = '')
{
    global $wp_query;
    $paged = get_query_var('page') ? get_query_var('page') : 1;
    $do_not_duplicate = array();
    // OFFSET SETTING
    if (!$offset == '' || !$offset == '0') {
        $argshidepost = array('numberposts' => $offset, 'post_type' => 'post', 'post_status' => 'publish');
        $hide_to_array = get_posts($argshidepost);
        // HIDE OFFSETED POSTS
        if ($hide_to_array) {
            foreach ($hide_to_array as $post) {
                $do_not_duplicate[] = $post->ID;
            }
        }
    }
    $argsmain = array('post_type' => 'post', 'post_status' => 'publish', 'paged' => $paged, 'order' => 'DESC', 'post__not_in' => $do_not_duplicate);
    $wp_query = new WP_Query($argsmain);
    if ($wp_query->have_posts()) {
        echo '<section id="' . bap_get_option_text('bap_loopContainer') . '">';
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            get_template_part('partials/listitem');
        }
        echo '</section>';
    }
    wp_reset_postdata();
}
function rec_epl_lu_single_download()
{
    global $post, $epl_settings;
    $unique_id = get_post_meta($post->ID, 'property_unique_id', true);
    $tab_title = isset($epl_settings['epl_lu_group_title']) ? __($epl_settings['epl_lu_group_title'], 'epl') : __('Extra Info', 'epl');
    $query = new WP_Query(array('post_type' => 'listing_unlimited', 'meta_query' => array(array('key' => 'property_unique_id', 'value' => $unique_id, 'compare' => '=='))));
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $link = get_post_meta($post->ID, 'listing_unlimited_pdf', true);
            ?>

			<div style="xxxdisplay:none" class="rec-panel-section-32 xxxfancybox-hidden">
				<div id="xxxfancyboxID-section-32">
					<?php 
            echo do_shortcode('[gravityform id="21" title="false" description="false" tabindex="33"]');
            ?>
				</div>
			</div>
			<!--<h5 class="widget-sub-title download"><a href="#fancyboxID-section-32" class="rec-panel-section-32-popout-fancybox fancybox"><i class="fa fa-file-pdf-o"></i> Download Section 32</a></h5>-->

			<?php 
        }
    }
    wp_reset_postdata();
}
/**
 * The Shortcode
 */
function ebor_testimonial_shortcode($atts)
{
    extract(shortcode_atts(array('pppage' => '999', 'filter' => 'all', 'type' => 'carousel-3col'), $atts));
    /**
     * Initial query args
     */
    $query_args = array('post_type' => 'testimonial', 'posts_per_page' => $pppage);
    if (!($filter == 'all')) {
        if (function_exists('icl_object_id')) {
            $filter = (int) icl_object_id($filter, 'testimonial_category', true);
        }
        $query_args['tax_query'] = array(array('taxonomy' => 'testimonial_category', 'field' => 'id', 'terms' => $filter));
    }
    /**
     * Finally, here's the query.
     */
    global $wp_query;
    $wp_query = new WP_Query($query_args);
    ob_start();
    get_template_part('loop/loop-testimonial', $type);
    wp_reset_postdata();
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Example #6
0
    function widget($args, $instance)
    {
        $cache = wp_cache_get('widget_dt_slider', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('', 'engine') : $instance['title'], $instance, $this->id_base);
        $category = empty($instance['category']) ? '' : $instance['category'];
        $qty = empty($instance['qty']) ? '3' : $instance['qty'];
        $excerpt_length = empty($instance['excerpt_length']) ? '0' : $instance['excerpt_length'];
        $r = new WP_Query(array('posts_per_page' => $qty, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'category__in' => explode(',', $category)));
        if ($r->have_posts()) {
            ?>
		<?php 
            echo $before_widget;
            echo do_shortcode('[engine_slider title="' . $title . '" category="' . $category . '" qty="' . $qty . '" autoplay="0" random="0" thumb_size="small" excerpt_length="' . $excerpt_length . '"]');
            echo $after_widget;
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('widget_dt_slider', $cache, 'widget');
    }
 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;
 }
function load_more_posts_callback()
{
    check_ajax_referer('pan_travel_blog', 'token');
    try {
        $offset = $_POST['offset'];
        $number = $_POST['number'];
        $loop = new WP_Query(array('post_type' => 'travel_blogs', 'post_status' => 'publish', 'order' => 'DESC', 'orderby' => 'meta_value', 'meta_key' => 'travel_blog_start_date', 'offset' => $offset, 'posts_per_page' => $number));
        if ($loop->have_posts()) {
            while ($loop->have_posts()) {
                $loop->the_post();
                ?>
				<?php 
                get_template_part('parts/content', 'travelblog');
                ?>
			<?php 
            }
        } else {
            ?>
			<p><?php 
            _e('Sorry, no posts matched your criteria.');
            ?>
</p>
		<?php 
        }
        wp_reset_postdata();
    } catch (Exception $e) {
        echo 'Errors';
    }
    wp_die();
}
Example #9
0
    public function widget($args, $instance)
    {
        ?>
			<?php 
        echo $args['before_widget'];
        ?>
			<?php 
        echo $args['before_title'];
        echo $instance['title'];
        echo $args['after_title'];
        ?>
            <div class="list-group">
			<?php 
        $arg = array('posts_per_page' => 5, 'post_type' => 'post', 'orderby' => 'date', 'order' => 'DESC');
        $newposts = new WP_Query($arg);
        while ($newposts->have_posts()) {
            $newposts->the_post();
            ?>
			  <a class="list-group-item" href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
			<?php 
        }
        wp_reset_postdata();
        ?>
			</div>
            <?php 
        echo $args['after_widget'];
        ?>
        <?php 
    }
Example #10
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;
 }
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     echo $args['before_widget'];
     $display_title = !empty($instance['display_title']) ? $instance['display_title'] : '';
     $numberofposts = !empty($instance['numberofposts']) ? absint($instance['numberofposts']) : '';
     if ($display_title == 'on') {
         if (!empty($instance['title'])) {
             echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
         }
     }
     $post_query_args = array('post_type' => array('post'), 'pagination' => false, 'posts_per_page' => $numberofposts, 'ignore_sticky_posts' => true, 'cache_results' => true, 'update_post_meta_cache' => true, 'update_post_term_cache' => true);
     $post_query = new WP_Query($post_query_args);
     if ($post_query->have_posts()) {
         while ($post_query->have_posts()) {
             $post_query->the_post();
             global $post;
             $output = '';
             $output .= '<div class="widget-recent-post clearfix">';
             $output .= has_post_thumbnail($post->ID) ? '<div class="recent-post-image">' : '';
             $output .= has_post_thumbnail($post->ID) ? get_the_post_thumbnail($post->ID, 'illdy-widget-recent-posts') : '';
             $output .= has_post_thumbnail($post->ID) ? '</div><!--/.recent-post-image-->' : '';
             $output .= '<a href="' . esc_url(get_the_permalink()) . '" title="' . esc_attr(get_the_title()) . '" class="recent-post-title">' . esc_html(get_the_title()) . '</a>';
             $output .= '<a href="' . esc_url(get_the_permalink()) . '" title="' . __('More...', 'illdy') . '" class="recent-post-button">' . __('More...', 'illdy') . '</a>';
             $output .= '</div><!--/.widget-recent-post.clearfix-->';
             echo $output;
         }
     } else {
         echo __('No posts found.', 'illdy');
     }
     wp_reset_postdata();
     echo $args['after_widget'];
 }
 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 public function widget($args, $instance)
 {
     global $comments, $comment, $woocommerce;
     if ($this->get_cached_widget($args)) {
         return;
     }
     ob_start();
     extract($args);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     $number = absint($instance['number']);
     $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'rand');
     $query_args['meta_query'] = array();
     $query_args['meta_query'][] = WC()->query->stock_status_meta_query();
     $query_args['meta_query'] = array_filter($query_args['meta_query']);
     $r = new WP_Query($query_args);
     if ($r->have_posts()) {
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         echo '<ul class="product_list_widget">';
         while ($r->have_posts()) {
             $r->the_post();
             wc_get_template('content-widget-product.php');
         }
         echo '</ul>';
         echo $after_widget;
     }
     wp_reset_postdata();
     $content = ob_get_clean();
     echo $content;
 }
Example #13
0
function td_events_api()
{
    $events = array();
    $start = isset($_GET['start']) ? $_GET['start'] : '';
    $end = isset($_GET['end']) ? $_GET['end'] : '';
    $args = array('post_type' => 'event');
    $query = new WP_Query($args);
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $parent = get_post(get_post_meta(get_the_ID(), 'tdec_product', true));
            $dates = get_post_meta(get_the_ID(), 'tdec_dates', true);
            $color = get_post_meta(get_the_ID(), 'tdec_color', true);
            if (is_array($dates)) {
                foreach ($dates as $date) {
                    $event = array('title' => $parent->post_title, 'start' => date('c', $date['start']), 'end' => date('c', $date['end']), 'url' => get_permalink($parent->ID), 'backgroundColor' => $color);
                    $events[] = $event;
                }
            }
        }
    }
    wp_reset_postdata();
    echo json_encode($events);
    die;
}
Example #14
0
/**
 * Find duplicates according to settings
 */
function pmxi_findDuplicates($articleData, $custom_duplicate_name = '', $custom_duplicate_value = '', $duplicate_indicator = 'title')
{
    global $wpdb;
    if ('custom field' == $duplicate_indicator) {
        $duplicate_ids = array();
        if (!empty($articleData['post_type'])) {
            $post_types = (class_exists('PMWI_Plugin') and $articleData['post_type'] == 'product') ? array('product', 'product_variation') : array($articleData['post_type']);
            $args = array('post_type' => $post_types, 'post_status' => array('any'), 'meta_query' => array(array('key' => trim($custom_duplicate_name), 'value' => htmlspecialchars(trim($custom_duplicate_value)))), 'order' => 'ASC', 'orderby' => 'ID');
            $query = new WP_Query($args);
            if ($query->have_posts()) {
                $duplicate_ids[] = $query->post->ID;
            }
            wp_reset_postdata();
            if (empty($duplicate_ids)) {
                $query = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS " . $wpdb->posts . ".ID FROM " . $wpdb->posts . " INNER JOIN " . $wpdb->postmeta . " ON (" . $wpdb->posts . ".ID = " . $wpdb->postmeta . ".post_id) WHERE 1=1 AND " . $wpdb->posts . ".post_type IN ('" . implode("','", $post_types) . "') AND (" . $wpdb->posts . ".post_status = 'publish' OR " . $wpdb->posts . ".post_status = 'future' OR " . $wpdb->posts . ".post_status = 'draft' OR " . $wpdb->posts . ".post_status = 'pending' OR " . $wpdb->posts . ".post_status = 'trash' OR " . $wpdb->posts . ".post_status = 'private') AND ( (" . $wpdb->postmeta . ".meta_key = '%s' AND CAST(" . $wpdb->postmeta . ".meta_value AS CHAR) = '%s') ) GROUP BY " . $wpdb->posts . ".ID ORDER BY " . $wpdb->posts . ".ID ASC LIMIT 0, 20", trim($custom_duplicate_name), htmlspecialchars(trim($custom_duplicate_value))));
                if (!empty($query)) {
                    foreach ($query as $p) {
                        $duplicate_ids[] = $p->ID;
                    }
                }
            }
        } else {
            $args = array('meta_query' => array(0 => array('key' => $custom_duplicate_name, 'value' => $custom_duplicate_value, 'compare' => '=')));
            $user_query = new WP_User_Query($args);
            if (!empty($user_query->results)) {
                foreach ($user_query->results as $user) {
                    $duplicate_ids[] = $user->ID;
                }
            } else {
                $query = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS " . $wpdb->users . ".ID FROM " . $wpdb->users . " INNER JOIN " . $wpdb->usermeta . " ON (" . $wpdb->users . ".ID = " . $wpdb->usermeta . ".user_id) WHERE 1=1 AND ( (" . $wpdb->usermeta . ".meta_key = '%s' AND CAST(" . $wpdb->usermeta . ".meta_value AS CHAR) = '%s') ) GROUP BY " . $wpdb->users . ".ID ORDER BY " . $wpdb->users . ".ID ASC LIMIT 0, 20", $custom_duplicate_name, $custom_duplicate_value));
                if (!empty($query)) {
                    foreach ($query as $p) {
                        $duplicate_ids[] = $p->ID;
                    }
                }
            }
        }
        return $duplicate_ids;
    } elseif ('parent' == $duplicate_indicator) {
        $field = 'post_title';
        // post_title or post_content
        return $wpdb->get_col($wpdb->prepare("\n\t\t\tSELECT ID FROM " . $wpdb->posts . "\n\t\t\tWHERE\n\t\t\t\tpost_type = %s\n\t\t\t\tAND ID != %s\n\t\t\t\tAND post_parent = %s\n\t\t\t\tAND REPLACE(REPLACE(REPLACE({$field}, ' ', ''), '\\t', ''), '\\n', '') = %s\n\t\t\t", $articleData['post_type'], isset($articleData['ID']) ? $articleData['ID'] : 0, !empty($articleData['post_parent']) ? $articleData['post_parent'] : 0, preg_replace('%[ \\t\\n]%', '', $articleData[$field])));
    } else {
        if (!empty($articleData['post_type'])) {
            $field = 'post_' . $duplicate_indicator;
            // post_title or post_content
            return $wpdb->get_col($wpdb->prepare("\n\t\t\t\tSELECT ID FROM " . $wpdb->posts . "\n\t\t\t\tWHERE\n\t\t\t\t\tpost_type = %s\n\t\t\t\t\tAND ID != %s\n\t\t\t\t\tAND REPLACE(REPLACE(REPLACE({$field}, ' ', ''), '\\t', ''), '\\n', '') = %s\n\t\t\t\t", $articleData['post_type'], isset($articleData['ID']) ? $articleData['ID'] : 0, preg_replace('%[ \\t\\n]%', '', $articleData[$field])));
        } else {
            if ($duplicate_indicator == 'title') {
                $field = 'user_login';
                $u = get_user_by('login', $articleData[$field]);
                return !empty($u) ? array($u->ID) : false;
            } else {
                $field = 'user_email';
                $u = get_user_by('email', $articleData[$field]);
                return !empty($u) ? array($u->ID) : false;
            }
        }
    }
}
    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;
    }
Example #16
0
 function widget($args, $instance)
 {
     extract($args);
     extract($instance);
     if (empty($hide_if_empty)) {
         $hide_if_empty = false;
     }
     // Get all the upcoming events for this venue.
     $events = tribe_get_events(array('post_type' => TribeEvents::POSTTYPE, 'venue' => $venue_ID, 'posts_per_page' => $count, 'eventDisplay' => 'upcoming'), true);
     // If there are no events, and the user has set to hide if empty, don't display the widget.
     if ($hide_if_empty && !$events->have_posts()) {
         return;
     }
     $ecp = TribeEventsPro::instance();
     $tooltip_status = $ecp->recurring_info_tooltip_status();
     $ecp->disable_recurring_info_tooltip();
     echo $before_widget;
     do_action('tribe_events_venue_widget_before_the_title');
     echo $instance['title'] ? $args['before_title'] . $instance['title'] . $args['after_title'] : '';
     do_action('tribe_events_venue_widget_after_the_title');
     include TribeEventsTemplates::getTemplateHierarchy('pro/widgets/venue-widget.php');
     echo $after_widget;
     if ($tooltip_status) {
         $ecp->enable_recurring_info_tooltip();
     }
     wp_reset_postdata();
 }
Example #17
0
 /**
  * @param array $args
  * @param array $instance
  */
 function widget($args, $instance)
 {
     if (empty($instance['template'])) {
         return;
     }
     if (is_admin()) {
         return;
     }
     echo $args['before_widget'];
     $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     if (!empty($instance['title'])) {
         echo $args['before_title'] . $instance['title'] . $args['after_title'];
     }
     if (strpos('/' . $instance['template'], '/content') !== false) {
         while (have_posts()) {
             the_post();
             locate_template($instance['template'], true, false);
         }
     } else {
         locate_template($instance['template'], true, false);
     }
     echo $args['after_widget'];
     // Reset everything
     rewind_posts();
     wp_reset_postdata();
 }
Example #18
0
 function end_el(&$output, $item, $depth = 0, $args = array())
 {
     if ($depth == 0 && $item->object == 'category') {
         $output .= "<div class='subcat'>";
         for ($i = 0; $i < count($item->children); $i++) {
             $child = $item->children[$i];
             $output .= "<div class='" . ($i === 0 ? 'active' : '') . "' id='mn-latest-" . $child->ID . "'>";
             //$output .="<h5>".$child->title."</h5>";
             $output .= "<ul id='mn-latest-" . $child->ID . "'>";
             if ($child->object == 'category') {
                 $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => 5, 'no_found_rows' => true, 'post_status' => 'publish', 'cat' => $child->object_id)));
                 if ($r->have_posts()) {
                     while ($r->have_posts()) {
                         $r->the_post();
                         $output .= "<li ";
                         if (has_post_thumbnail()) {
                             $output .= "class='has-thumbnail' ";
                         }
                         $output .= "><div class='subcat-thumbnail'><a href='" . get_permalink() . "' title='" . get_the_title() . "'>" . get_the_post_thumbnail(get_the_ID(), array(40, 40)) . "</a></div><div class='subcat-title'><a href='" . get_permalink() . "' title='" . get_the_title() . "'> " . get_the_title() . "</a><span> - " . dw_human_time_diff(get_the_time('U'), current_time('timestamp')) . "</span></div></li>";
                     }
                     // Reset the global $the_post as this query will have stomped on it
                     wp_reset_postdata();
                 }
             }
             $output .= "</ul>";
             $output .= "<a href='" . $child->url . "' title='" . $child->attr_title . "'>View all</a>";
             $output .= "</div>";
         }
         $output .= "</div> \n</div>\n";
     } else {
     }
     $output .= "</li>\n";
 }
 function bl_posttype_shortcodes_showposts($params = array())
 {
     // Pulls the paramater values passed from the shortcode options
     extract(shortcode_atts(array('post_type' => 'post', 'post_status' => 'publish', 'offset' => 0, 'posts_per_page' => ''), $params));
     // Builds the query based on the available params
     $query = new WP_Query(array('post_type' => $post_type, 'post_status' => $post_status, 'offset' => $offset, 'posts_per_page' => $posts_per_page));
     // Looks for the presence of any qualifying posts inside the defined loop
     if ($query->have_posts()) {
         // We open the post container only where specified posts are available
         $shortcodeOutput = '<div>';
         while ($query->have_posts()) {
             $query->the_post();
             // Wraps each qualifying post for output in an <article> tag with Schema data.
             $shortcodeOutput .= '<article itemscope itemtype="http://schema.org/Article">';
             $shortcodeOutput .= '<a href="' . get_the_permalink() . '">';
             $shortcodeOutput .= '<h3 itemprop="name">' . get_the_title() . '</h3>';
             $shortcodeOutput .= '</a>';
             $shortcodeOutput .= '<time itemprop="dateCreated">' . get_the_date() . '</time>';
             $shortcodeOutput .= '<em itemprop="author">' . get_the_author() . '</em>';
             $shortcodeOutput .= '<div itemprop="description">' . get_the_excerpt() . '</div>';
             $shortcodeOutput .= '<article>';
         }
         // Closes off the parent container
         $shortcodeOutput .= '</div>';
     }
     // Resets the wordpress loop
     wp_reset_postdata();
     // Returns the concatenated shortcodeOutput to the page
     return $shortcodeOutput;
 }
Example #20
0
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 
}
Example #21
0
 /**
  * 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;
 }
 /**
  * Shortcode functionality to show posts.
  *
  * @since 1.0.0
  */
 function theme_posts_shortcode($atts)
 {
     $output = false;
     // Pull in shortcode attributes and set defaults
     $defaults = array('category' => '', 'order' => 'DESC', 'orderby' => 'date', 'posts_per_page' => '10', 'tag' => '');
     // Process shortcode attribtues
     $atts = shortcode_atts($defaults, $atts, 'show-posts');
     // Set up initial query for post
     $args = array('category_name' => $atts['category'], 'order' => $atts['order'], 'orderby' => $atts['orderby'], 'posts_per_page' => $atts['posts_per_page'], 'tag' => $atts['tag'], 'ignore_sticky_posts' => 1, 'no_found_rows' => true);
     $query = new WP_Query($args);
     if ($query->have_posts()) {
         global $wp_query;
         // Backup the main query.
         $saved_query = $wp_query;
         // Replace the main query by reference.
         $wp_query = $query;
         // Capture the output so we can return it to the shortcode process.
         ob_start();
         echo '<div class="show-posts-wrapper">';
         while ($wp_query->have_posts()) {
             $wp_query->the_post();
             get_template_part('content', get_post_format());
         }
         echo '</div>';
         $output = ob_get_clean();
         // Clean up after ourselves.
         $wp_query = $saved_query;
         wp_reset_postdata();
     }
     return $output;
 }
Example #23
0
 public function store_commission_data($data, $query_mode, $api_object)
 {
     if ('store-commissions' != $query_mode) {
         return $data;
     }
     $user_id = $api_object->get_user();
     if (!user_can($user_id, 'view_shop_reports')) {
         return $data;
     }
     $data = array('commissions' => array());
     $paged = $api_object->get_paged();
     $status = isset($_REQUEST['status']) ? sanitize_text_field($_REQUEST['status']) : 'unpaid';
     $commission_args = array('post_type' => 'edd_commission', 'post_status' => 'publish', 'posts_per_page' => $api_object->per_page(), 'paged' => $paged);
     if ($status) {
         $commission_args['tax_query'] = array(array('taxonomy' => 'edd_commission_status', 'terms' => $status, 'field' => 'slug'));
     }
     $commissions = get_posts($commission_args);
     if ($commissions) {
         foreach ($commissions as $commission) {
             $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true);
             $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true);
             $renewal = (bool) get_post_meta($commission->ID, '_edd_commission_is_renewal', true);
             $data['commissions'][] = array('amount' => edd_sanitize_amount($commission_meta['amount']), 'rate' => $commission_meta['rate'], 'currency' => $commission_meta['currency'], 'item' => get_the_title($download_id), 'status' => eddc_get_commission_status($commission->ID), 'date' => $commission->post_date, 'renewal' => $renewal ? 1 : 0);
         }
         wp_reset_postdata();
     }
     $data['total_unpaid'] = eddc_get_unpaid_totals();
     return $data;
 }
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
     $sticky = get_option('sticky_posts');
     $number = empty($instance['number']) ? 1 : (int) $instance['number'];
     $cat = empty($instance['category']) ? 0 : (int) $instance['category'];
     if (is_single()) {
         array_push($sticky, get_the_ID());
     }
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     } else {
         echo '<br />';
     }
     $featuredPosts = new WP_Query(array('posts_per_page' => $number, 'cat' => $cat, 'post__not_in' => $sticky, 'no_found_rows' => true));
     while ($featuredPosts->have_posts()) {
         $featuredPosts->the_post();
         global $mb_content_area, $more;
         $mb_content_area = 'sidebar';
         get_template_part('content', get_post_format());
     }
     wp_reset_postdata();
     echo $after_widget;
 }
 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 public function widget($args, $instance)
 {
     if ($this->get_cached_widget($args)) {
         return;
     }
     ob_start();
     extract($args);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     $number = absint($instance['number']);
     add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
     $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product');
     $query_args['meta_query'] = WC()->query->get_meta_query();
     $r = new WP_Query($query_args);
     if ($r->have_posts()) {
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         echo '<ul class="product_list_widget">';
         while ($r->have_posts()) {
             $r->the_post();
             wc_get_template('content-widget-product.php', array('show_rating' => true));
         }
         echo '</ul>';
         echo $after_widget;
     }
     remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
     wp_reset_postdata();
     $content = ob_get_clean();
     echo $content;
     $this->cache_widget($args, $content);
 }
 /**
  * Outputs the HTML for this widget.
  *
  * @param array  An array of standard parameters for widgets in this theme 
  * @param array  An array of settings for this widget instance 
  * @return void Echoes it's output
  **/
 public function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $count = esc_attr($instance['count']);
     $count = 0 < $count && $count < 10 ? $count : 2;
     $loop = new WP_Query(array('post_type' => 'event', 'posts_per_page' => $count, 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_key' => '_event_start', 'meta_query' => array(array('key' => '_event_end', 'value' => time(), 'compare' => '>'))));
     if ($loop->have_posts()) {
         echo $before_widget;
         if ($instance['title']) {
             echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title;
         }
         echo '<ul>';
         while ($loop->have_posts()) {
             $loop->the_post();
             global $post;
             $output = '<span class="meta">' . date(get_option('date_format'), get_post_meta(get_the_ID(), '_event_start', true)) . '</span> <a href="' . get_permalink() . '">' . get_the_title() . '</a>';
             $read_more = apply_filters('em4wp_events_manager_upcoming_widget_output', $output, $post);
             if ($read_more) {
                 echo '<li>' . $read_more . '</li>';
             }
         }
         if ($instance['more_text']) {
             echo '<li><a href="' . get_post_type_archive_link('event') . '">' . esc_attr($instance['more_text']) . '</a></li>';
         }
         echo '</ul>';
         echo $after_widget;
     }
     wp_reset_postdata();
 }
    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;
    }
Example #28
0
function moxie_press_endpoint_data()
{
    global $wp_query;
    // get query vars
    $json = $wp_query->get('json');
    $name = $wp_query->get('name');
    // use this template redirect only if json is requested
    if ($json != 'true') {
        return;
    }
    // build the query
    $movie_data = array();
    // default args
    $args = array('post_type' => 'movie', 'posts_per_page' => 100);
    if ($name != '') {
        $args['name'] = $name;
    }
    // add name if provided in query
    // check if this particular request is cached, if not, perform the query
    if (false === ($moxie_cached_request = get_transient('moxie_cached_request_' . json_encode($args)))) {
        $moxie_cached_request = new WP_Query($args);
        set_transient('moxie_cached_request_' . json_encode($args), $moxie_cached_request);
    }
    // prepare the object we want to send as response
    if ($moxie_cached_request->have_posts()) {
        while ($moxie_cached_request->have_posts()) {
            $moxie_cached_request->the_post();
            $id = get_the_ID();
            $movie_data[] = array('id' => $id, 'title' => get_the_title(), 'poster_url' => get_post_meta($id, 'moxie_press_poster_url', true), 'rating' => get_post_meta($id, 'moxie_press_rating', true), 'year' => get_post_meta($id, 'moxie_press_year', true), 'short_description' => get_post_meta($id, 'moxie_press_description', true), 'mdbid' => get_post_meta($id, 'moxie_press_mdbid', true));
        }
        wp_reset_postdata();
    }
    // send json data using built-in WP function
    wp_send_json(array('data' => $movie_data));
}
    function widget($args, $instance)
    {
        global $post;
        // Preserve global $post
        $preserve = $post;
        extract($args);
        // only useful on post pages
        if (!is_single()) {
            return;
        }
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Read Next', 'largo') : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        $related = new Largo_Related($instance['qty']);
        //get the related posts
        $rel_posts = new WP_Query(array('post__in' => $related->ids(), 'nopaging' => 1, 'posts_per_page' => $instance['qty'], 'ignore_sticky_posts' => 1));
        if ($rel_posts->have_posts()) {
            echo '<ul class="related">';
            while ($rel_posts->have_posts()) {
                $rel_posts->the_post();
                echo '<li>';
                echo '<a href="' . get_permalink() . '"/>' . get_the_post_thumbnail(get_the_ID(), 'thumbnail', array('class' => 'alignleft')) . '</a>';
                ?>
				<h4><a href="<?php 
                the_permalink();
                ?>
" title="Read: <?php 
                esc_attr(the_title('', '', FALSE));
                ?>
"><?php 
                the_title();
                ?>
</a></h4>
				<h5 class="byline">
					<span class="by-author"><?php 
                largo_byline(true, true);
                ?>
</span>
					<time class="entry-date updated dtstamp pubdate" datetime="<?php 
                echo esc_attr(get_the_date('c'));
                ?>
"><?php 
                largo_time();
                ?>
</time>
				</h5>
				<?php 
                // post excerpt/summary
                largo_excerpt(get_the_ID(), 2, false, '', true);
                echo '</li>';
            }
            echo "</ul>";
        }
        echo $after_widget;
        // Restore global $post
        wp_reset_postdata();
        $post = $preserve;
    }
 /**
  * Output widget.
  *
  * @see WP_Widget
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     $viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', $_COOKIE['woocommerce_recently_viewed']) : array();
     $viewed_products = array_reverse(array_filter(array_map('absint', $viewed_products)));
     if (empty($viewed_products)) {
         return;
     }
     ob_start();
     $number = !empty($instance['number']) ? absint($instance['number']) : $this->settings['number']['std'];
     $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'post__in');
     $query_args['meta_query'] = array();
     $query_args['meta_query'][] = WC()->query->stock_status_meta_query();
     $query_args['meta_query'] = array_filter($query_args['meta_query']);
     $r = new WP_Query($query_args);
     if ($r->have_posts()) {
         $this->widget_start($args, $instance);
         echo apply_filters('woocommerce_before_widget_product_list', '<ul class="product_list_widget">');
         while ($r->have_posts()) {
             $r->the_post();
             wc_get_template('content-widget-product.php');
         }
         echo apply_filters('woocommerce_after_widget_product_list', '</ul>');
         $this->widget_end($args);
     }
     wp_reset_postdata();
     $content = ob_get_clean();
     echo $content;
 }