Beispiel #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();
}
 public function load_user()
 {
     if ($this->id > 0) {
         $current_user = get_user_by('ID', $this->id);
     } elseif (function_exists('is_user_logged_in') && is_user_logged_in()) {
         $current_user = wp_get_current_user();
     }
     if (isset($current_user) && $current_user) {
         $this->id = $current_user->ID;
         $this->first_name = $current_user->user_firstname;
         $this->last_name = $current_user->user_lastname;
         $this->email = $current_user->user_email;
         $this->address = get_user_meta($current_user->ID, 'address', TRUE);
         $this->is_on_mailing_list = get_user_meta($current_user->ID, 'mailing_list', TRUE);
         $this->is_on_mailing_list = $this->is_on_mailing_list == 1 ? TRUE : FALSE;
         $neighborhood_id = get_user_meta($current_user->ID, 'neighborhood_id', TRUE);
         if (!empty($neighborhood_id) && $neighborhood_id > 0) {
             $args = array('post_type' => 'wbb_neighborhood', 'post_status' => 'publish');
             $query = new \WP_Query($args);
             while ($query->have_posts()) {
                 $query->the_post();
                 if (get_the_ID() == $neighborhood_id) {
                     $this->neighborhood = new Neighborhood();
                     $this->neighborhood->post_id = get_the_ID();
                     $this->neighborhood->title = get_the_title();
                     break;
                 }
             }
         }
         $this->get_locations();
     }
 }
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 generate_ryuzine_stylesheets()
{
    // verify this came from the our screen and with proper authorization.
    if (!wp_verify_nonce($_POST['ryu_regenstyles_noncename'], 'ryuzine-regenstyles_install')) {
        return;
    }
    // Check permissions
    if (!current_user_can('administrator')) {
        echo "<div class='error'><p>Sorry, you do not have the correct priveledges to install the files.</p></div>";
        return;
    }
    $my_query = null;
    $my_query = new WP_Query(array('post_type' => 'ryuzine'));
    if ($my_query->have_posts()) {
        while ($my_query->have_posts()) {
            $my_query->the_post();
            $stylesheet = "";
            $issuestyles = get_post_meta(get_the_ID(), '_ryustyles', false);
            if (!empty($issuestyles)) {
                foreach ($issuestyles as $appendstyle) {
                    // If there are multiple ryustyles append them //
                    $stylesheet = $stylesheet . $appendstyle;
                }
            }
            if ($stylesheet != "") {
                ryu_create_css($stylesheet, get_the_ID());
            }
        }
    }
    // reset css check //
    //	update_option('ryu_css_admin',0);
    wp_reset_query();
    return;
}
 public function get_Relationships_by_Tag($tag, $_method, $_route, $_path, $_headers)
 {
     if (empty($tag) || !is_string($tag)) {
         return new WP_Error('json_options_invalid_tag', __("Invalid options tag"), ['status' => 404]);
     }
     $site = $_headers['REMOTE'];
     $tags = explode(',', $tag);
     if ($tags) {
         $tags_query['relation'] = 'OR';
         foreach ($tags as $tag) {
             $tags_query[] = array('key' => 'related_tags', 'value' => $tag, 'compare' => 'LIKE');
         }
     }
     $args = array('post_type' => 'relationship', 'meta_query' => array('relation' => 'AND', array('key' => 'site_address', 'value' => $site), $tags_query));
     $relationships = new WP_Query($args);
     if ($relationships->have_posts()) {
         // Get the Target Categories
         $targets = [];
         while ($relationships->have_posts()) {
             $relationships->the_post();
             $targets[] = get_field('target_category');
         }
         $targets = dedupe($targets);
         $related_categories = implode(', ', $targets);
         // Find Matching Relationships
         $args = array('post_type' => 'relationship', 'tax_query' => array(array('taxonomy' => 'related_categories', 'terms' => $related_categories)));
         $relationships = new WP_Query($args);
         // Build Relationships JSON Reponse
         include 'related-json-response.php';
     }
     wp_reset_query();
     return $sites;
 }
Beispiel #6
0
 function ktz_mustread_content()
 {
     global $post;
     if (ot_get_option('ktz_popup_activated') == 'yes') {
         $paged = get_query_var('paged') ? get_query_var('paged') : 1;
         $args = array('post_type' => 'post', 'orderby' => 'rand', 'order' => 'desc', 'showposts' => 3, 'post_status' => 'publish', 'ignore_sticky_posts' => 1);
         $ktz_topfeatquery = new WP_Query($args);
         if ($ktz_topfeatquery->have_posts()) {
             echo '<div id="ktz_slidebox">';
             echo '<strong class="mustread_title">' . __('Must read', ktz_theme_textdomain) . '</strong><a href="#" class="close">&times;</a>';
             echo '<ul class="mustread_list">';
             while ($ktz_topfeatquery->have_posts()) {
                 $ktz_topfeatquery->the_post();
                 echo '<li class="mustread_li clearfix">';
                 echo '<div class="pull-left">';
                 echo ktz_featured_img(50, 50);
                 echo '</div>';
                 echo '<div class="title">';
                 echo ktz_posted_title_a();
                 echo '</div>';
                 echo '</li>';
             }
             echo '</ul>';
             echo '</div>';
         }
         wp_reset_query();
     }
 }
Beispiel #7
0
function blog_summary_shortcode($attr)
{
    // Describes what attributes to parse from shortcode; only 'count'
    extract(shortcode_atts(array('count' => '5', 'grouptag' => 'ul', 'entrytag' => 'li', 'titletag' => 'h4', 'datetag' => 'span', 'commentstag' => 'span', 'summarytag' => 'div'), $attr));
    // Queries to populate our loop based on shortcode count attribute
    $r = new WP_Query("showposts={$count}&what_to_show=posts&nopaging=0&post_status=publish");
    // Only run if we have posts; can't run this through searches
    if ($r->have_posts() && !is_search()) {
        // If we're using a Sandbox-friendly theme . . .
        if (function_exists('sandbox_body_class')) {
            // We can't have double hfeed classes, otherwise it won't parse
            $groupclasses = 'xoxo';
        } else {
            // Otherwise, use hfeed to ensure hAtom compliance
            $groupclasses = 'xoxo hfeed';
        }
        // Begin the output for shortcode and inserts in the group tag what classes we have
        $output = '<' . $grouptag . ' class="' . $groupclasses . '">';
        // Begins our loop for returning posts
        while ($r->have_posts()) {
            // Sets which post from our loop we're at
            $r->the_post();
            // Allows the_date() with multiple posts within a single day
            unset($previousday);
            // If we're using a Sandbox-friendly theme . . .
            if (function_exists('sandbox_post_class')) {
                // Let's use semantic classes with each entry element
                $entryclasses = sandbox_post_class(false);
            } else {
                // Otherwise, use hentry to ensure hAtom compliance
                $entryclasses = 'hentry';
            }
            // Begin entry wrapper and inserts what classes we got from above
            $output .= "\n" . '<' . $entrytag . ' class="' . $entryclasses . '">';
            // Post title
            $output .= "\n" . '<' . $titletag . ' class="entry-title"><a href="' . get_permalink() . '" title="' . sprintf(__('Permalink to %s', 'blog_summary'), the_title_attribute('echo=0')) . '" rel="bookmark">' . get_the_title() . '</a></' . $titletag . '>';
            // Post date with hAtom support
            $output .= "\n" . '<' . $datetag . ' class="entry-date"><abbr class="published" title="' . get_the_time('Y-m-d\\TH:i:sO') . '">' . sprintf(__('%s', 'blog_summary'), the_date('', '', '', false)) . '</abbr></' . $datetag . '>';
            // Comments number
            $output .= "\n" . '<' . $commentstag . ' class="entry-comments"><a href="' . get_permalink() . '#comments" title="' . sprintf(__('Comments to %s', 'blog_summary'), the_title_attribute('echo=0')) . '">' . sprintf(__('Comments (%s)', 'blog_summary'), apply_filters('comments_number', get_comments_number())) . '</a></' . $commentstag . '>';
            // Post excerpt with hAtom support
            $output .= "\n" . '<' . $summarytag . ' class="entry-summary">' . "\n" . apply_filters('the_excerpt', get_the_excerpt()) . '</' . $summarytag . '>';
            // Close each post LI
            $output .= "\n" . '</' . $entrytag . '>';
            // Finish the have_posts() query
        }
        // while ( $r->have_posts() ) :
        // Close the parent UL
        $output .= "\n" . '</' . $grouptag . '>';
        // Rewinds loop from $r->the_post();
        rewind_posts();
        // End the initial IF statement
    }
    // if ( $r->have_posts() ) :
    // Clears our query to put the loop back where it was
    wp_reset_query();
    // $r = new WP_Query()
    // Returns $output to the shortcode
    return $output;
}
 /**
  * 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'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     }
     // The Query
     $query_args = array('post_type' => 'post', 'post_per_page' => 5, 'meta_key' => 'views', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => 'true');
     $the_query = new WP_Query($query_args);
     // The Loop
     if ($the_query->have_posts()) {
         echo '<ul>';
         while ($the_query->have_posts()) {
             $the_query->the_post();
             echo '<li>';
             echo '<a href="' . get_the_permalink() . '" rel="bookmark">';
             echo get_the_title();
             echo '(' . get_post_meta(get_the_ID(), 'views', true) . ')';
             echo '</a>';
             echo '</li>';
         }
         echo '</ul>';
     } else {
         // no posts found
     }
     /* Restore original Post Data */
     wp_reset_postdata();
     echo $args['after_widget'];
 }
 /**
  * Display widget content.
  *
  * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
  * @param array $instance The settings for the particular instance of the widget
  */
 function widget($args, $instance)
 {
     extract($args);
     $instance = wp_parse_args((array) $instance, $this->defaults);
     $featured_page = new WP_Query(array('page_id' => $instance['page_id']));
     echo $before_widget . '<div class="feature-page">';
     if (!empty($instance['title'])) {
         echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
     }
     if ($featured_page->have_posts()) {
         while ($featured_page->have_posts()) {
             $featured_page->the_post();
             echo '<div class="' . implode(' ', get_post_class()) . '">';
             if (!empty($instance['show_title'])) {
                 printf('<h4 class="entry-title"><a href="%s" title="%s">%s</a></h4>', get_permalink(), the_title_attribute('echo=0'), get_the_title());
             }
             //Show image
             if (!empty($instance['show_image'])) {
                 printf('<a href="%s" title="%s" class="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), calibrefx_get_image(array('format' => 'html', 'size' => $instance['image_size'])));
             }
             if (!empty($instance['show_content'])) {
                 if (empty($instance['content_limit'])) {
                     the_content($instance['more_text']);
                 } else {
                     the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text']));
                 }
             }
             echo '</div><!--end post_class()-->' . "\n\n";
         }
     }
     echo '</div>' . $after_widget;
     wp_reset_query();
 }
Beispiel #10
0
/**
 * Ajax function for loading posts by date and category
 */
function wp_ajax_load_posts()
{
    if (!wp_verify_nonce($_GET['_wpnonce'], 'nonce-ajax-dropdown')) {
        die('Go away!');
    }
    $year = isset($_GET['year']) ? $_GET['year'] : '';
    $month = isset($_GET['month']) ? $_GET['month'] : '';
    $args = array('year' => trim($year), 'monthnum' => trim($month), 'posts_per_page' => -1, 'orderby' => 'date', 'cat' => trim($_GET['cat'] != "-1") ? trim($_GET['cat']) : 0);
    $ajaxsort = new WP_Query($args);
    ?>
	    <?php 
    if ($ajaxsort->have_posts()) {
        ?>
	</div>
		<?php 
        while ($ajaxsort->have_posts()) {
            $ajaxsort->the_post();
            ?>
			<?php 
            get_template_part('content', 'archives');
            ?>
	    <?php 
        }
        ?>

		<?php 
    } else {
        echo '<div align="center">Nothing Found!</div></nav>';
    }
    exit;
}
function rum_post_cta_meta_box_list()
{
    global $post;
    // store global post object for later resetting after our query
    // using wp_reset_postdata() doesn't work so we are manually resetting the global
    $post_old = $post;
    // initialize variables
    $options = '';
    // get plugin option array and store in a variable
    $plugin_option_array = get_option('rum_post_cta_plugin_options');
    // fetch values from the plugin option variable array
    $post_cta_post_type = $plugin_option_array['post_type'];
    // retrieve the custom meta box value
    $post_cta_id = get_post_meta($post->ID, 'rum_post_cta_id', true);
    // set query arguments
    $args = array('post_type' => $post_cta_post_type, 'nopaging' => true);
    // execute the query
    $cta_post_query = new WP_Query($args);
    // The Loop
    while ($cta_post_query->have_posts()) {
        $cta_post_query->the_post();
        $post_title = get_the_title();
        $post_ID = get_the_id();
        $options .= '<option value="' . esc_attr($post_ID) . '" ' . selected($post_cta_id, $post_ID) . '>' . $post_title . '</option>';
    }
    // restore the global $post variable of the main query loop
    // wp_reset_postdata(); doesn't work so we are manually resetting it back
    // restore global post object
    $post = $post_old;
    setup_postdata($post);
    return $options;
}
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();
}
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        $number = $instance['number'];
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		<div class="recent-works-items clearfix">
		<?php 
        $args = array('post_type' => 'evolve_portfolio', 'posts_per_page' => $number, 'has_password' => false);
        $portfolio = new WP_Query($args);
        if ($portfolio->have_posts()) {
            ?>
		<?php 
            while ($portfolio->have_posts()) {
                $portfolio->the_post();
                ?>
		<?php 
                if (has_post_thumbnail()) {
                    ?>
		<?php 
                    $link_target = "";
                    $url_check = get_post_meta(get_the_ID(), 'pyre_link_icon_url', true);
                    if (!empty($url_check)) {
                        $new_permalink = get_post_meta(get_the_ID(), 'pyre_link_icon_url', true);
                        if (get_post_meta(get_the_ID(), 'pyre_link_icon_target', true) == "yes") {
                            $link_target = ' target="_blank"';
                        }
                    } else {
                        $new_permalink = get_permalink();
                    }
                    ?>
		<a href="<?php 
                    echo $new_permalink;
                    ?>
"<?php 
                    echo $link_target;
                    ?>
 title="<?php 
                    the_title();
                    ?>
">
			<?php 
                    the_post_thumbnail('recent-works-thumbnail');
                    ?>
		</a>
		<?php 
                }
            }
        }
        wp_reset_query();
        ?>
		</div>

		<?php 
        echo $after_widget;
    }
    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;
    }
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();
}
Beispiel #16
0
 public static function get_pins($args)
 {
     $defaults = array('numberposts' => 5, 'category' => 0, 'orderby' => 'date', 'order' => 'DESC', 'include' => array(), 'exclude' => array(), 'meta_key' => '', 'meta_value' => '', 'post_type' => 'pin', 'suppress_filters' => true);
     $p = wp_parse_args($args, $defaults);
     $get_pins = new WP_Query();
     return $get_pins->query($p);
 }
Beispiel #17
0
 /**
  *
  */
 public static function pricetable($atts, $content = null, $code = null)
 {
     if ($atts == 'generator') {
         global $wpdb;
         $prices_list = array();
         $pricetables = $wpdb->get_results('SELECT ID, post_title FROM ' . $wpdb->posts . ' WHERE post_type = "pricetable"');
         if (is_array($pricetables)) {
             foreach ($pricetables as $key => $value) {
                 $prices_list[$value->ID] = $pricetables[$key]->post_title;
             }
         } else {
             $price_list[0] = __('Please install Price Table plugin...', MISS_ADMIN_TEXTDOMAIN);
         }
         $option = array('name' => __('Blog Grid Layout', MISS_ADMIN_TEXTDOMAIN), 'value' => 'pricetable', 'options' => array(array('name' => __('Select Table', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Choose "Pricing Table" to use.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'id', 'type' => 'select', 'options' => $prices_list), 'shortcode_has_atts' => true));
         return $option;
     }
     extract(shortcode_atts(array('id' => ''), $atts));
     $pricetable = new WP_Query();
     $pricetable->query(array('post_type' => 'pricetable', 'post_id' => $id));
     while ($pricetable->have_posts()) {
         $pricetable->the_post();
         $prices_list[get_the_ID()] = get_the_title();
         $out = '[price_table id="' . $id . '"]';
     }
     return do_shortcode($out);
 }
function wptouch_custom_latest_post_filter($query_vars)
{
    if (wptouch_is_showing_mobile_theme_on_mobile_device()) {
        $settings = foundation_get_settings();
        if (foundation_is_theme_using_module('custom-latest-posts') && $settings->latest_posts_page != 'none') {
            $dummy_query = new WP_Query();
            // the query isn't run if we don't pass any query vars
            $dummy_query->parse_query($query_vars);
            if ($dummy_query->is_page && count($query_vars) == 0) {
                // Front page
                $front_option = get_option('show_on_front', false);
                if ($front_option == 'page') {
                    $front_page = get_option('page_on_front');
                    $dummy_query->queried_object_id = $front_page;
                }
            }
            if (isset($dummy_query->queried_object_id) && apply_filters('foundation_is_custom_latest_posts_page', $settings->latest_posts_page == $dummy_query->queried_object_id)) {
                if (isset($query_vars['paged'])) {
                    $paged = $query_vars['paged'];
                } elseif (isset($query_vars['page'])) {
                    $paged = $query_vars['page'];
                } else {
                    $paged = 1;
                }
                $query_vars = array('paged' => $paged, 'posts_per_page' => $settings->posts_per_page);
                // Since we're modifying the query here, we need to prevent the custom landing page redirect from firing for this request (it'll think it's loading the homepage)
                add_filter('wptouch_redirect_target', 'wptouch_return_false');
            }
        }
    }
    return $query_vars;
}
    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');
    }
 /**
  * Hook into the query parsing to detect oEmbed requests.
  *
  * If an oEmbed request is made, trigger the output.
  *
  * @codeCoverageIgnore
  *
  * @param WP_Query $wp_query The WP_Query instance (passed by reference).
  */
 public function parse_query($wp_query)
 {
     // Check for required params.
     if (false === $wp_query->get('oembed', false)) {
         return;
     }
     if (false === $wp_query->get('url', false)) {
         status_header(400);
         echo 'URL parameter missing';
         exit;
     }
     /**
      * Check for the allowed query vars and set defaults.
      *
      * @see WP_REST_oEmbed_Controller::register_routes()
      */
     $url = esc_url_raw(get_query_var('url'));
     $format = sanitize_text_field(get_query_var('format', 'json'));
     /**
      * Filter the maxwidth oEmbed parameter.
      *
      * @param int $maxwidth Maximum allowed width. Defaults to 600.
      *
      * @return int
      */
     $maxwidth = apply_filters('oembed_default_width', 600);
     $maxwidth = get_query_var('maxwidth', $maxwidth);
     $callback = get_query_var('_jsonp', false);
     $request = array('url' => $url, 'format' => $format, 'maxwidth' => $maxwidth, 'callback' => $callback);
     echo $this->dispatch($request);
     exit;
 }
 /**
  * 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;
 }
 /**
  * Hook into the query parsing to detect oEmbed requests.
  *
  * If an oEmbed request is made, trigger the output.
  *
  * @since 4.4.0
  *
  * @param WP_Query $wp_query The WP_Query instance (passed by reference).
  */
 public function parse_query($wp_query)
 {
     if (false === $wp_query->get('oembed', false)) {
         return;
     }
     if (false === $wp_query->get('url', false)) {
         status_header(400);
         echo 'URL parameter missing';
         exit;
     }
     $url = esc_url_raw(get_query_var('url'));
     $format = wp_oembed_ensure_format(get_query_var('format'));
     /**
      * Filter the maxwidth oEmbed parameter.
      *
      * @since 4.4.0
      *
      * @param int $maxwidth Maximum allowed width. Default 600.
      */
     $maxwidth = apply_filters('oembed_default_width', 600);
     $maxwidth = absint(get_query_var('maxwidth', $maxwidth));
     $callback = get_query_var('_jsonp', false);
     $request = array('url' => $url, 'format' => $format, 'maxwidth' => $maxwidth, 'callback' => $callback);
     echo $this->dispatch($request);
     exit;
 }
Beispiel #23
0
function echo_state_results()
{
    $args = array('post_type' => 'property', 'posts_per_page' => '99999');
    $query = new WP_Query($args);
    $stateCount = array();
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            if (get_post_meta($query->post->ID, 'state', true)) {
                $cur = 0;
                if ($stateCount[get_post_meta($query->post->ID, 'state', true)]) {
                    $cur = $stateCount[get_post_meta($query->post->ID, 'state', true)];
                }
                $stateCount[get_post_meta($query->post->ID, 'state', true)] = $cur + 1;
            }
            //echo '(' . get_post_meta( $query->post->ID, 'state', true ). ') ';
        }
    }
    echo '<script type="text/javascript">';
    //echo 'var stateCount = []; stateCount["Arizona"]=0; stateCount["Colorado"]=0; stateCount["Delaware"]=0; stateCount["Florida"]=0; stateCount["Georgia"]=0; stateCount["Hawaii"]=0; stateCount["Idaho"]=0; stateCount["Illinois"]=0; stateCount["Indiana"]=0; stateCount["Iowa"]=0; stateCount["Kansas"]=0; stateCount["Kentucky"]=0; stateCount["Louisiana"]=0; stateCount["Maryland"]=0; stateCount["Maine"]=0; stateCount["Massachusetts"]=0; stateCount["Minnesota"]=0; stateCount["Michigan"]=0; stateCount["Mississippi"]=0; stateCount["Missouri"]=0; stateCount["Montana"]=0; stateCount["NorthCarolina"]=0; stateCount["Nebraska"]=0; stateCount["Nevada"]=0; stateCount["NewHampshire"]=0; stateCount["NewJersey"]=0; stateCount["NewYork"]=0; stateCount["NorthDakota"]=0; stateCount["NewMexico"]=0; stateCount["Ohio"]=0; stateCount["Oklahoma"]=0; stateCount["Oregon"]=0; stateCount["Pennsylvania"]=0; stateCount["RhodeIsland"]=0; stateCount["SouthCarolina"]=0; stateCount["SouthDakota"]=0; stateCount["Tennessee"]=0; stateCount["Texas"]=0; stateCount["Utah"]=0; stateCount["Wisconsin"]=0; stateCount["Virginia"]=0; stateCount["Vermont"]=0; stateCount["Washington"]=0; stateCount["WestVirginia"]=0; stateCount["Wyoming"]=0; stateCount["California"]=0; stateCount["Connecticut"]=0; stateCount["Alaska"]=0; stateCount["Arkansas"]=0; stateCount["Alabama"]=0;';
    echo 'var stateCount = [];';
    foreach ($stateCount as $key => $value) {
        echo 'stateCount["' . str_replace(' ', '', $key) . '"] = "' . $value . '";';
    }
    echo '</script>';
}
Beispiel #24
0
function _zn_documentation($options)
{
    $categories = get_terms('documentation_category', array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0, 'show_count ' => 1));
    $limit = '6';
    if (!empty($options['doc_num_items'])) {
        $limit = $options['doc_num_items'];
    }
    $count = count($categories);
    $i = 1;
    foreach ($categories as $category) {
        if ($i % 2 == 1) {
            echo '<div class="row-fluid zn_photo_gallery">';
        }
        echo '<div class="span6">';
        echo '<h3><a href="' . get_term_link($category->slug, 'documentation_category') . '">' . $category->name . ' (' . $category->count . ')</a></h3>';
        $args = array('post_type' => 'documentation', 'post_status' => 'publish', 'posts_per_page' => $limit, 'documentation_category' => $category->slug);
        $zn_doc = new WP_Query($args);
        echo '<ol>';
        while ($zn_doc->have_posts()) {
            $zn_doc->the_post();
            global $post;
            echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
        }
        // end loop
        echo "</ol>";
        echo '</div>';
        if ($i % 2 == 0 || $i == $count) {
            echo '</div>';
        }
        $i++;
    }
}
 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;
 }
 /**
  * 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();
 }
 /**
  * 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;
 }
Beispiel #28
-1
function apto_shopp_collection_query($options)
{
    $orderby = shopp_setting('product_image_orderby');
    if ($orderby != "sortorder") {
        return $options;
    }
    //create a csutom query then use the results as order
    $argv = array('post_type' => 'shopp_product', 'posts_per_page' => -1, 'fields' => 'ids');
    if (isset($options['joins']['wp_term_taxonomy'])) {
        preg_match('/.*tt.term_id=([0-9]+)?.*/i', $options['joins']['wp_term_taxonomy'], $matches);
        if (isset($matches[1])) {
            $term_id = $matches[1];
            $argv['tax_query'] = array(array('taxonomy' => 'shopp_category', 'field' => 'term_id', 'terms' => array($term_id)));
        }
    }
    $custom_query = new WP_Query($argv);
    if (!$custom_query->have_posts()) {
        return $options;
    }
    $posts_list = $custom_query->posts;
    if (count($posts_list) > 0) {
        global $wpdb;
        $options['orderby'] = " FIELD(p.ID, " . implode(",", $posts_list) . ") ASC";
    }
    return $options;
}
Beispiel #29
-1
 /**
  * Find the order active number (completed or processing ) for a given user on a course. It will return the latest order.
  *
  * If multiple exist we will return the latest order.
  *
  * @param $user_id
  * @param $course_id
  * @return array $user_course_orders
  */
 public static function get_learner_course_active_order_id($user_id, $course_id)
 {
     $course_product_id = get_post_meta($course_id, '_course_woocommerce_product', true);
     $orders_query = new WP_Query(array('post_type' => 'shop_order', 'posts_per_page' => -1, 'post_status' => array('wc-processing', 'wc-completed'), 'meta_key' => '_customer_user', 'meta_value' => $user_id));
     if ($orders_query->post_count == 0) {
         return false;
     }
     foreach ($orders_query->get_posts() as $order) {
         $order = new WC_Order($order->ID);
         $items = $order->get_items();
         $user_orders = array();
         foreach ($items as $item) {
             // if the product id on the order and the one given to this function
             // this order has been placed by the given user on the given course.
             $product = wc_get_product($item['product_id']);
             if ($product->is_type('variable')) {
                 $item_product_id = $item['variation_id'];
             } else {
                 $item_product_id = $item['product_id'];
             }
             if ($course_product_id == $item_product_id) {
                 return $order->id;
             }
         }
         //end for each order item
     }
     // end for each order
     // if we reach this place we found no order
     return false;
 }
Beispiel #30
-7
 function widget($args, $instance)
 {
     global $post;
     extract($args, EXTR_SKIP);
     echo $before_widget;
     $title = empty($instance['title']) ? __('Recent Posts', 'lan-thinkupthemes') : apply_filters('widget_title', $instance['title']);
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $posts = new WP_Query('orderby=date&posts_per_page=' . $instance['postcount'] . '');
     while ($posts->have_posts()) {
         $posts->the_post();
         // Insert post date if needed.
         if ($instance['postdate'] == 'on') {
             $date_input = '<a href="' . get_permalink() . '" class="date">' . get_the_date('M j, Y') . '</a>';
         }
         // HTML output
         echo '<div class="recent-posts">';
         if (has_post_thumbnail() and $instance['imageswitch'] == 'on') {
             echo '<div class="image">', '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, array(65, 65)) . '<div class="image-overlay"></div></a>', '</div>', '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
         } else {
             echo '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
         }
         echo '</div>';
     }
     wp_reset_query();
     echo $after_widget;
 }