function ciGetAllStaff($maxNumEmployees = 100, $maxCharLength = -1)
 {
     $query = new WP_Query('showposts=' . $maxNumEmployees . '&post_type=' . CI_STAFF_TYPE);
     $employeeArray = array();
     while ($query->have_posts()) {
         $query->next_post();
         $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($query->post->ID), CI_STAFF_IMG);
         $maybeExcerpt = has_excerpt($query->post->ID) ? $query->post->post_excerpt : $query->post->post_content;
         $employeeArray[] = array('id' => $query->post->ID, 'content' => ciFilterToMaxCharLength($maybeExcerpt, $maxCharLength), 'fullContent' => $query->post->post_content, 'title' => $query->post->post_title, 'imgURL' => $attachment ? $attachment[0] : '', 'imgWidth' => $attachment ? $attachment[1] : -1, 'imgHeight' => $attachment ? $attachment[2] : -1, 'url' => get_permalink($query->post->ID), 'socialURLs' => function_exists('ciGetStaffSocialURLs') ? ciGetStaffSocialURLs($query->post->ID) : array());
     }
     wp_reset_postdata();
     return $employeeArray;
 }
Exemple #2
1
 function ciGetPostsOfType($postType = 'post', $maxCharLength = -1, $featuredImageSize = array(1000, 1000), $maxNumPosts = 100, $orderBy = 'date', $order = ORDER_ASC)
 {
     $query = new WP_Query("showposts={$maxNumPosts}&post_type={$postType}&orderby={$orderBy}&order={$order}");
     $postsArray = array();
     while ($query->have_posts()) {
         $query->next_post();
         $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($query->post->ID), $featuredImageSize);
         $maybeExcerpt = has_excerpt($query->post->ID) ? get_post_field('post_excerpt', $query->post->ID) : $query->post->post_content;
         $postsArray[] = array('id' => $query->post->ID, 'content' => apply_filters('the_content', ciFilterToMaxCharLength($maybeExcerpt, $maxCharLength)), 'fullContent' => apply_filters('the_content', $query->post->post_content), 'title' => $query->post->post_title, 'imgURL' => $attachment ? $attachment[0] : '', 'imgWidth' => $attachment ? $attachment[1] : -1, 'imgHeight' => $attachment ? $attachment[2] : -1, 'url' => get_permalink($query->post->ID));
     }
     wp_reset_postdata();
     return $postsArray;
 }
 private static function _post($term_id, $taxonomy = null)
 {
     // Allow first argument to be term object instead
     if (is_object($term_id)) {
         $taxonomy = $term_id->taxonomy;
         $term_id = $term_id->term_id;
     }
     // Get or create the post whose name is _meta_{$taxonomy}_{$term_id}.
     //
     // This naming format is used to take advantage of the index on post_name
     // so we can quickly pull the meta-containing post object from a known term object.
     //
     // Conversely, if we need to do a search on meta (which is non-optimal,) we can
     // easily extract the correct taxonomy and term from the post_name
     $post_name = sanitize_key('_meta_' . $taxonomy . '_' . $term_id);
     $post_query = new WP_Query(array('post_type' => self::post_type, 'post_status' => self::post_type, 'posts_per_page' => 1, 'name' => $post_name));
     if ($post_query->have_posts()) {
         $post = $post_query->next_post();
     } else {
         if (current_user_can('edit_posts')) {
             $post_id = wp_insert_post(array('post_name' => $post_name, 'post_type' => self::post_type, 'post_status' => self::post_type));
             $post = get_post($post_id);
         }
     }
     return isset($post) ? $post : null;
 }
Exemple #4
0
 /**
  * @param $post_type
  * @return array
  */
 public function get_active_liveblogs($post_type)
 {
     $liveblogs = array();
     $query = new WP_Query(array('meta_key' => '_liveblog', 'meta_value' => '1', 'post_type' => $post_type, 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'DESC'));
     // Get all active live blogs
     while ($query->have_posts()) {
         $query->next_post();
         $liveblogs[strval($query->post->ID)] = esc_attr($query->post->post_title);
     }
     return $liveblogs;
 }
function popmake_preload_popups()
{
    global $popmake_loaded_popups, $popmake_loaded_popup_ids;
    $query = new WP_Query(array('post_type' => 'popup', 'posts_per_page' => -1));
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->next_post();
            if (popmake_popup_is_loadable($query->post->ID)) {
                do_action('popmake_preload_popup', $query->post->ID);
                $popmake_loaded_popups->posts[] = $query->post;
                $popmake_loaded_popups->post_count++;
            }
        }
    }
}
function podlove_get_episodes_deprecations()
{
    $deprecations = [];
    $shortcodes_data = podlove_get_deprecated_shortcodes();
    $shortcode_matcher = array_keys($shortcodes_data);
    $query = new \WP_Query(['post_type' => 'podcast']);
    while ($query->have_posts()) {
        $post = $query->next_post();
        foreach ($shortcode_matcher as $shortcode) {
            if (preg_match("/" . $shortcode . "/", $post->post_content, $matches)) {
                $deprecations[] = ['context' => ['type' => 'post', 'id' => $post->ID], 'deprecated' => ['type' => 'shortcode', 'content' => $matches[0]], 'instead' => $shortcodes_data[$shortcode]];
            }
        }
        // hint: template tags don't need to be checked in episodes because they only work in templates
    }
    return $deprecations;
}
 /**
  * Get information about current website(s) as pillar data
  * suitable for specified minion.
  * TODO: which minion?!
  * @param string $minion_id id of minion to return pillar data for.
  * @return pillar data structure
  */
 function get_pillar($minion_id)
 {
     //debug_halt("here!");
     $qargs = array('post_type' => 'wpss_site', 'post_status' => 'any');
     $query = new WP_Query($qargs);
     $apachesites = array();
     $wpsssites = array();
     while ($query->have_posts()) {
         $post = $query->next_post();
         $id = strval($post->ID);
         // TODO: servername?
         $servername = '127.0.0.1';
         // TODO real port vs external?
         $port = ':8080';
         // TODO: type option?
         $type = 'wordpress';
         $locations = array();
         if (array_key_exists($servername, $apachesites)) {
             $locations = $apachesites[$servername]['locations'];
         }
         $urlpath = '/' . $post->post_name;
         // TODO: duplicates/clashes??
         $directory = '/srv/selfservice/' . $id;
         if ('publish' === $post->post_status) {
             $available = true;
             $defaultMessage = 'Available';
         } else {
             $available = false;
             $defaultMessage = 'Site not available (' . $post->post_status . ')';
         }
         $author = get_userdata($post->post_author);
         if (false === $author) {
             if ($available) {
                 $defaultMessage = 'Site not available (could not find author ' . $post->post_author . ')';
             }
             $available = false;
         }
         $locations[$urlpath] = array('DocumentRoot' => $directory, 'available' => $available, 'defaultMessage' => $defaultMessage, 'id' => $id);
         $apachesites[$servername] = array('locations' => $locations);
         $url = 'http://' . $servername . $port . $urlpath;
         $wpsssites[$directory] = array('id' => $id, 'type' => $type, 'admin_password_hash' => $author->user_pass, 'title' => $post->post_title, 'description' => $post->post_content, 'url' => $url, 'status' => $post->post_status, 'template' => wpss_get_selected_template_for_website($id));
     }
     $pillar = array('apache' => array('sites' => $apachesites), 'selfservice' => array('sites' => $wpsssites));
     return $pillar;
 }
    /**
     * Display this setting
     * @since 1.0
     */
    public function display_setting()
    {
        $posts = new WP_Query($this->args);
        ?>

			<select name="<?php 
        echo $this->get_input_name();
        ?>
" id="<?php 
        echo $this->get_input_name();
        ?>
">

				<?php 
        if ($this->blank_option === true) {
            ?>
					<option></option>
				<?php 
        }
        ?>

				<?php 
        while ($posts->have_posts()) {
            $posts->next_post();
            ?>
					<option value="<?php 
            echo absint($posts->post->ID);
            ?>
" <?php 
            selected($this->value, $posts->post->ID);
            ?>
><?php 
            echo esc_attr($posts->post->post_title);
            ?>
</option>
				<?php 
        }
        ?>

			</select>

		<?php 
        wp_reset_postdata();
        $this->display_description();
    }
/**
 * @param $category string Name of the category to filter. If empty, we'll return slides from all categories.
 * @param $maxNumSlides int Maximum number of slides to return
 * @param $size string One of two constants: SIZE_LG or SIZE_MD (use MD if the image will be in a container div)
 * @return array All the slide data you need. Keys are 'content', 'title', 'imgURL', 'imgWidth', and 'imgHeight'
 */
function ciGetAllSlides($category, $maxNumSlides, $size)
{
    if ($size == CI_SIZE_INPAGE) {
        $size = CI_SIZE_MD;
    }
    $query = null;
    if ($category) {
        $query = new WP_Query(array('category_name' => $category, 'post_type' => CI_SLIDE_TYPE, 'showposts' => $maxNumSlides));
    } else {
        $query = new WP_Query('showposts=' . $maxNumSlides . '&post_type=' . CI_SLIDE_TYPE);
    }
    $slidesArray = array();
    while ($query->have_posts()) {
        $query->next_post();
        $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($query->post->ID), $size);
        if ($attachment) {
            $slidesArray[] = array('id' => $query->post->ID, 'content' => apply_filters('the_content', $query->post->post_content), 'title' => apply_filters('the_title', $query->post->post_title), 'imgURL' => $attachment[0], 'imgWidth' => $attachment[1], 'imgHeight' => $attachment[2], 'contentPosition' => ciGetNormalizedMeta('caption_position', 'center', $query->post->ID), 'bg' => ciGetNormalizedMeta('caption_bg', '', $query->post->ID), 'link' => ciGetNormalizedMeta('link', '', $query->post->ID), 'darken' => ciGetNormalizedMeta('darken_slide', true, $query->post->ID));
        }
    }
    wp_reset_postdata();
    return $slidesArray;
}
 public function next_gallery()
 {
     return parent::next_post();
 }
 /**
  * Function prepare returns the required html and enqueues
  * the scripts and stylesheets necessary for displaying the slideshow
  *
  * Passing this function no parameter or passing it a negative one will
  * result in a random pick of slideshow
  *
  * @since 2.1.0
  * @param int $postId
  * @return String $output
  */
 static function prepare($postId = null)
 {
     $post = null;
     // Get post by its ID, if the ID is not a negative value
     if (is_numeric($postId) && $postId >= 0) {
         $post = get_post($postId);
     }
     // Get slideshow by slug when it's a non-empty string
     if ($post === null && is_string($postId) && !is_numeric($postId) && !empty($postId)) {
         $query = new WP_Query(array('post_type' => SlideshowPluginPostType::$postType, 'name' => $postId, 'orderby' => 'post_date', 'order' => 'DESC', 'suppress_filters' => true));
         if ($query->have_posts()) {
             $post = $query->next_post();
         }
     }
     // When no slideshow is found, get one at random
     if ($post === null) {
         $post = get_posts(array('numberposts' => 1, 'offset' => 0, 'orderby' => 'rand', 'post_type' => SlideshowPluginPostType::$postType, 'suppress_filters' => true));
         if (is_array($post)) {
             $post = $post[0];
         }
     }
     // Exit on error
     if ($post === null) {
         return '<!-- Wordpress Slideshow - No slideshows available -->';
     }
     // Log slideshow's issues to be able to track them on the page.
     $log = array();
     // Get views
     $views = SlideshowPluginSlideshowSettingsHandler::getViews($post->ID);
     if (!is_array($views) || count($views) <= 0) {
         $log[] = 'No views were found';
     }
     // Get settings
     $settings = SlideshowPluginSlideshowSettingsHandler::getSettings($post->ID);
     $styleSettings = SlideshowPluginSlideshowSettingsHandler::getStyleSettings($post->ID);
     // The slideshow's session ID, allows JavaScript and CSS to distinguish between multiple slideshows
     $sessionID = self::$sessionCounter++;
     // Try to get a custom stylesheet
     if (isset($styleSettings['style'])) {
         // Try to get the custom style's version
         $customStyle = get_option($styleSettings['style'], false);
         $customStyleVersion = false;
         if ($customStyle) {
             $customStyleVersion = get_option($styleSettings['style'] . '_version', false);
         }
         // Style name and version
         if ($customStyle && $customStyleVersion) {
             $styleName = $styleSettings['style'];
             $styleVersion = $customStyleVersion;
         } else {
             $styleName = str_replace('.css', '', $styleSettings['style']);
             $styleVersion = SlideshowPluginMain::$version;
         }
     } else {
         $styleName = 'style-light';
         $styleVersion = SlideshowPluginMain::$version;
     }
     // Register function stylesheet
     wp_enqueue_style('slideshow-jquery-image-gallery-stylesheet_functional', SlideshowPluginMain::getPluginUrl() . '/style/' . __CLASS__ . '/functional.css', array(), SlideshowPluginMain::$version);
     // Enqueue stylesheet
     wp_enqueue_style('slideshow-jquery-image-gallery-ajax-stylesheet_' . $styleName, admin_url('admin-ajax.php?action=slideshow_jquery_image_gallery_load_stylesheet&style=' . $styleName), array(), $styleVersion);
     // Include output file to store output in $output.
     $output = '';
     ob_start();
     include SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/slideshow.php';
     $output .= ob_get_clean();
     // Enqueue slideshow script
     wp_enqueue_script('slideshow-jquery-image-gallery-script', SlideshowPluginMain::getPluginUrl() . '/js/' . __CLASS__ . '/slideshow.min.js', array('jquery'), SlideshowPluginMain::$version);
     // Set dimensionWidth and dimensionHeight if dimensions should be preserved
     if (isset($settings['preserveSlideshowDimensions']) && $settings['preserveSlideshowDimensions'] == 'true') {
         $aspectRatio = explode(':', $settings['aspectRatio']);
         // Width
         if (isset($aspectRatio[0]) && is_numeric($aspectRatio[0])) {
             $settings['dimensionWidth'] = $aspectRatio[0];
         } else {
             $settings['dimensionWidth'] = 1;
         }
         // Height
         if (isset($aspectRatio[1]) && is_numeric($aspectRatio[1])) {
             $settings['dimensionHeight'] = $aspectRatio[1];
         } else {
             $settings['dimensionHeight'] = 1;
         }
     }
     // Include slideshow settings by localizing them
     wp_localize_script('slideshow-jquery-image-gallery-script', 'SlideshowPluginSettings_' . $sessionID, $settings);
     // Return output
     return $output;
 }
 /**
  * @see WP_Widget::widget()
  */
 public function widget($args, $instance)
 {
     $data = new stdClass();
     if (isset($instance['title'])) {
         $data->title = $instance['title'];
     } else {
         $data->title = '';
     }
     if (isset($instance['contest_ID']) && is_numeric($instance['contest_ID'])) {
         $contest_ID = intval($instance['contest_ID']);
     } else {
         $contest_ID = $this->latest_entry_ID;
     }
     $latest_entries_query = new WP_Query();
     $latest_entries_query_options = array('post_type' => 'pronamic_photo_entry', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => 1, 'meta_query' => array(array('key' => '_thumbnail_id')));
     // Get the latest entry of a specific contest
     if ($contest_ID != $this->latest_entry_ID) {
         $latest_entries_query = new WP_Query(array_merge_recursive($latest_entries_query_options, array('meta_query' => array(array('key' => '_pronamic_photo_contest_id', 'value' => $contest_ID)))));
     }
     // Get the latest entry of any contest when the contest ID is set to retrieve the latest entry, or no entries have been found for a specific contest
     if ($contest_ID == $this->latest_entry_ID || !$latest_entries_query->have_posts()) {
         $latest_entries_query = new WP_Query($latest_entries_query_options);
     }
     $data->image = $data->message = '';
     if ($latest_entries_query->have_posts()) {
         $latest_entry = $latest_entries_query->next_post();
         $contest_id = get_post_meta($latest_entry->ID, '_pronamic_photo_contest_id', true);
         $width = $height = 0;
         if (isset($instance['width']) && is_numeric($instance['width'])) {
             $width = $instance['width'];
         }
         if (isset($instance['height']) && is_numeric($instance['height'])) {
             $height = $instance['height'];
         }
         $data->image .= '<a href="' . get_permalink($contest_id) . '">';
         if ($width > 0 && $height > 0) {
             $data->image .= get_the_post_thumbnail($latest_entry->ID, array($instance['width'], $instance['height']));
         } else {
             $data->image .= get_the_post_thumbnail($latest_entry->ID);
         }
         $data->image .= '</a>';
     } else {
         $data->message .= __('No entries have been posted yet.', 'pronamic_photo_contest');
     }
     if (isset($instance['content'])) {
         $data->content = $instance['content'];
     } else {
         $data->content = '';
     }
     $data->beforeWidget = $data->afterWidget = $data->beforeTitle = $data->afterTitle = '';
     if (isset($args['before_widget'])) {
         $data->beforeWidget = $args['before_widget'];
     }
     if (isset($args['after_widget'])) {
         $data->afterWidget = $args['after_widget'];
     }
     if (isset($args['before_title'])) {
         $data->beforeTitle = $args['before_title'];
     }
     if (isset($args['after_title'])) {
         $data->afterTitle = $args['after_title'];
     }
     include $this->plugin->path . 'admin' . DIRECTORY_SEPARATOR . 'latest_entries_widget.php';
 }
    /**
     * Print the form to configure this widget in the admin panel
     * @since 1.0
     */
    public function form($instance)
    {
        $id = null;
        if (isset($instance['id'])) {
            $id = $instance['id'];
        }
        ?>

		<p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"> <?php 
        _e('Title');
        ?>
</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text"<?php 
        if (isset($instance['title'])) {
            ?>
 value="<?php 
            echo esc_attr($instance['title']);
            ?>
"<?php 
        }
        ?>
>
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('id');
        ?>
"> <?php 
        _e('Menu Item');
        ?>
</label>
			<select id="<?php 
        echo $this->get_field_id('id');
        ?>
" name="<?php 
        echo $this->get_field_name('id');
        ?>
">

				<?php 
        $items = new WP_Query(array('posts_per_page' => -1, 'post_type' => 'fdm-menu-item'));
        while ($items->have_posts()) {
            $items->next_post();
            ?>

				<option value="<?php 
            echo $items->post->ID;
            ?>
"<?php 
            if ($items->post->ID == $id) {
                ?>
 selected<?php 
            }
            ?>
>
					<?php 
            echo esc_attr($items->post->post_title);
            ?>
				</option>

				<?php 
        }
        // Reset the loop so we don't interfere with normal template functions
        wp_reset_postdata();
        ?>
			</select>
		</p>

		<?php 
    }
Exemple #14
0
 /**
  * Get posts
  *
  * @param array $field
  *
  * @return array
  */
 static function get_options($field)
 {
     $options = array();
     $query = new WP_Query($field['query_args']);
     if ($query->have_posts()) {
         while ($query->have_posts()) {
             $post = $query->next_post();
             $title = apply_filters('rwmb_post_field_title', $post->post_title, $post);
             $title = apply_filters("rwmb_{$field['id']}_field_title", $title, $post);
             $options[$post->ID] = $post_title;
         }
     }
     return $options;
 }
Exemple #15
0
 /**
  * Fetches charts from database.
  *
  * @since 1.0.0
  *
  * @access public
  */
 public function getCharts()
 {
     $query_args = array('post_type' => Visualizer_Plugin::CPT_VISUALIZER, 'posts_per_page' => 9, 'paged' => filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'default' => 1))));
     $filter = filter_input(INPUT_GET, 'filter');
     if ($filter && in_array($filter, Visualizer_Plugin::getChartTypes())) {
         $query_args['meta_query'] = array(array('key' => Visualizer_Plugin::CF_CHART_TYPE, 'value' => $filter, 'compare' => '='));
     }
     $query = new WP_Query($query_args);
     $charts = array();
     while ($query->have_posts()) {
         $chart = $query->next_post();
         $chart_data = $this->_getChartArray($chart);
         $chart_data['id'] = $chart->ID;
         $charts[] = $chart_data;
     }
     $this->_sendResponse(array('success' => true, 'data' => $charts, 'total' => $query->max_num_pages));
 }
			<?php 
if (is_array($search_for)) {
    foreach ($search_for as $post_type) {
        ?>
					<input type="hidden" name="post_type[]" value="<?php 
        echo $post_type;
        ?>
" />
			<?php 
    }
}
$query = new WP_Query(array('s' => $s, 'posts_per_page' => 20));
$html = '';
if ($query->have_posts()) {
    while ($query->have_posts()) {
        $query->next_post();
        $query->post->post_title;
    }
}
wp_reset_query();
?>
			<script type="text/javascript">
				jQuery(document).ready(function($){
					$('html, body').animate({
						 scrollTop: $("#form-ss").offset().top
					 }, 500);
					 <?php 
if ($highlight_results) {
    ?>
						highlight_searchquery('<?php 
    echo $s;
 public static function list_saved_layout($storage_key = '')
 {
     global $wpdb;
     self::set_storage_key($storage_key);
     $storage_key = self::get_storage_key();
     $layouts = $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE ( `option_name` LIKE '{$storage_key}-single%' OR `option_name` LIKE '{$storage_key}-archive%' )");
     $return = array();
     foreach ($layouts as $layout) {
         if (preg_match("/^{$storage_key}-([^-]+)(-([^-]+)|)(-([^-]+)|)\$/", $layout->option_name, $match)) {
             $ids = array();
             if (!empty($match[3]) && !empty($match[5])) {
                 $ids['specificity'] = $match[1] . '-' . $match[3] . '-' . $match[5];
             }
             if ($match[3]) {
                 $ids['item'] = $match[1] . '-' . $match[3];
             }
             $ids['type'] = $match[1];
             $layout_id = !empty($ids['specificity']) ? $ids['specificity'] : ($ids['item'] ? $ids['item'] : $ids['type']);
             $return[$layout_id] = array('layout' => $ids, 'label' => Upfront_EntityResolver::layout_to_name($ids));
             if ($ids['type'] == 'single') {
                 $query = new WP_Query(array('post_type' => $post_type->name, 'post_status' => 'publish'));
                 $query->parse_query();
                 $post = $query->next_post();
                 $return[$layout_id]['latest_post'] = $post->ID;
             }
         }
     }
     return $return;
 }
Exemple #18
0
 public function getPrevNext($query, $base_post_id)
 {
     $lapost = get_post($base_post_id);
     $query['posts_per_page'] = 100;
     $this->queryService->setQuery($query);
     $args = $this->queryService->getArgs();
     $args['post_type'] = 'casawp_property';
     $the_query = new \WP_Query($args);
     $prev = false;
     $next = false;
     while ($the_query->have_posts()) {
         $the_query->next_post();
         if ($the_query->post->post_name == $lapost->post_name) {
             if ($the_query->current_post + 1 < $the_query->post_count) {
                 $next_post = $the_query->next_post();
                 $next = $next_post;
                 break;
             }
         }
         if ($the_query->post_count - 1 != $the_query->current_post) {
             //because nextpost will fail at the end :-)
             $prev = $the_query->post;
         }
     }
     $prevnext = array('nextlink' => $prev ? get_permalink($prev->ID) : 'no', 'prevlink' => $next ? get_permalink($next->ID) : 'no');
     return $prevnext;
 }
        /**
         * Get field HTML
         *
         * @param mixed $meta
         * @param array $field
         *
         * @return string
         */
        static function html($meta, $field)
        {
            $exclude_quiz = array();
            $exclude_lesson = array();
            $current_user = get_current_user_id();
            global $wpdb;
            $used_item = $wpdb->get_col($wpdb->prepare("SELECT         pm.meta_value\r\n\t\t\t\t\tFROM            {$wpdb->posts}        AS p\r\n\t\t\t\t\tINNER JOIN      {$wpdb->postmeta}     AS pm  ON p.ID = pm.post_id\r\n\t\t\t\t\t\tWHERE           p.post_type = %s\r\n\t\t\t\t\t\tAND \t\t\tp.post_author = %d\r\n\t\t\t\t\t\tAND             pm.meta_key = %s", 'lpr_course', $current_user, '_lpr_course_lesson_quiz'));
            for ($i = 0; $i < count($used_item); $i++) {
                $lesson_quiz_array = unserialize($used_item[$i]);
                for ($j = 0; $j < count($lesson_quiz_array); $j++) {
                    if (isset($lesson_quiz_array[$j]['lesson_quiz'])) {
                        foreach ($lesson_quiz_array[$j]['lesson_quiz'] as $key => $value) {
                            array_push($exclude_lesson, $value);
                            array_push($exclude_quiz, $value);
                        }
                    }
                }
            }
            ob_start();
            ?>
<!-- -->
			<div class="lpr-course-curriculum">
                <p class="lpr-course-curriculum-toggle">
					<a href="" class="expand" data-action="expand"><?php 
            _e('Expand All', 'learn_press');
            ?>
</a>
					<a href="" class="close" data-action="close"><?php 
            _e('Collapse All', 'learn_press');
            ?>
</a>
				</p>
                <?php 
            _e('Outline your course and add content with sections, lessons and quizzes.', 'learn_press');
            ?>
				<ul class="lpr-curriculum-sections">
					<?php 
            global $post;
            $course_sections = get_post_meta($post->ID, '_lpr_course_lesson_quiz', true);
            $section_state = get_post_meta($post->ID, '_lpr_course_section_state', true);
            if ($course_sections) {
                foreach ($course_sections as $k => $section) {
                    ?>
						<?php 
                    $is_open = !isset($section_state[$k]) || isset($section_state[$k]) && $section_state[$k];
                    ?>
						<li class="lpr-curriculum-section<?php 
                    echo $is_open ? "" : " closed";
                    ?>
">
							<h3>
								<!-- actions -->
								<span class="lpr-action lpr-toggle" title="<?php 
                    _e('Expand/Close', 'learn_press');
                    ?>
"><i class="dashicons <?php 
                    echo $is_open ? "dashicons-minus" : "dashicons-plus";
                    ?>
"></i></span>
								<span class="lpr-action lpr-sort"><i class="dashicons dashicons-sort"></i></span>
								<span class="lpr-action lpr-remove" title="<?php 
                    _e('Remove', 'learn_press');
                    ?>
"><i class="dashicons dashicons-no"></i></span>
								<!-- // actions -->
								<span class="lpr-section-icon"><i class="dashicons dashicons-pressthis"></i></span>
								<span class="lpr-section-name-wrapper"><input name="_lpr_course_lesson_quiz[__SECTION__][name]" type="text" placeholder="Enter the section name and hit enter" class="lpr-section-name" value="<?php 
                    echo esc_attr($section['name']);
                    ?>
" /></span>
							</h3>
							<div class="lpr-curriculum-section-content">
								<ul class="lpr-section-quiz-less">
									<?php 
                    if (isset($section['lesson_quiz']) && is_array($section['lesson_quiz'])) {
                        global $wpdb;
                        $query = "\r\n                                            SELECT *\r\n                                            FROM {$wpdb->posts} p\r\n                                            WHERE p.ID IN(" . join(',', $section['lesson_quiz']) . ")\r\n                                        ";
                        if ($items = $wpdb->get_results($query, OBJECT_K)) {
                            foreach ($section['lesson_quiz'] as $id) {
                                if (empty($items[$id])) {
                                    continue;
                                }
                                $item = $items[$id];
                                if ('lpr_quiz' == $item->post_type) {
                                    $exclude_quiz[] = $item->ID;
                                }
                                if ('lpr_lesson' == $item->post_type) {
                                    $exclude_lesson[] = $item->ID;
                                }
                                if ('lpr_assignment' == $item->post_type) {
                                    $exclude_lesson[] = $item->ID;
                                }
                                ?>
												<li class="lpr-<?php 
                                echo $item->post_type;
                                ?>
" data-id="<?php 
                                echo $item->ID;
                                ?>
" data-type="<?php 
                                echo $item->post_type;
                                ?>
">
													<?php 
                                if ('lpr_quiz' == $item->post_type) {
                                    ?>
														<span class="handle dashicons dashicons-format-status"></span>
													<?php 
                                } else {
                                    ?>
														<span class="handle dashicons dashicons-media-document"></span>
													<?php 
                                }
                                ?>
													<span class="lpr-title" title="<?php 
                                _e('Click to quick edit', 'learn_press');
                                ?>
"><?php 
                                echo $item->post_title;
                                ?>
</span>
													<a href="" class="lpr-remove"><?php 
                                _e('Remove', 'learn_press');
                                ?>
</a>
													<a href="<?php 
                                echo get_edit_post_link($item->ID);
                                ?>
" target="_blank"><?php 
                                _e('Edit', 'learn_press');
                                ?>
</a>
													<input type="hidden" name="_lpr_course_lesson_quiz[__SECTION__][lesson_quiz][]" value="<?php 
                                echo $item->ID;
                                ?>
" />
												</li>
											<?php 
                            }
                            ?>
										<?php 
                        }
                        ?>
									<?php 
                    }
                    ?>
								</ul>
								<p class="lpr-add-buttons">
									<button class="button button-primary" data-action="add-lesson"><?php 
                    _e('Add Lesson', 'learn_press');
                    ?>
</button>
									<button class="button button-primary" data-action="add-quiz"><?php 
                    _e('Add Quiz', 'learn_press');
                    ?>
</button>
									<button class="button button-primary" data-action="quick-add-lesson"><?php 
                    _e('Quick add <span>L</span>esson', 'learn_press');
                    ?>
</button>
									<button class="button button-primary" data-action="quick-add-quiz"><?php 
                    _e('Quick add <span>Q</span>uiz', 'learn_press');
                    ?>
</button>
								</p>
							</div>

						</li>
					<?php 
                }
            }
            ?>
					<li class="lpr-curriculum-section lpr-empty">
						<h3>
							<!-- actions -->
							<span class="lpr-action lpr-toggle" title="<?php 
            _e('Expand/Close', 'learn_press');
            ?>
"><i class="dashicons dashicons-minus"></i></span>
							<span class="lpr-action lpr-sort"><i class="dashicons dashicons-sort"></i></span>
							<span class="lpr-action lpr-remove" title="<?php 
            _e('Remove', 'learn_press');
            ?>
"><i class="dashicons dashicons-no"></i></span>
							<!-- // actions -->
							<span class="lpr-section-icon"><i class="dashicons dashicons-pressthis"></i></span>
							<span class="lpr-section-name-wrapper"><input name="_lpr_course_lesson_quiz[__SECTION__][name]" type="text" placeholder="Enter the section name and hit enter" class="lpr-section-name" /></span>
						</h3>

						<div class="lpr-curriculum-section-content">
							<ul class="lpr-section-quiz-less">

							</ul>
							<p class="lpr-add-buttons">
								<button class="button button-primary" data-action="add-lesson"><?php 
            _e('Add Lesson', 'learn_press');
            ?>
</button>
								<button class="button button-primary" data-action="add-quiz"><?php 
            _e('Add Quiz', 'learn_press');
            ?>
</button>
								<button class="button button-primary" data-action="quick-add-lesson"><?php 
            _e('Quick add <span>L</span>esson', 'learn_press');
            ?>
</button>
								<button class="button button-primary" data-action="quick-add-quiz"><?php 
            _e('Quick add <span>Q</span>uiz', 'learn_press');
            ?>
</button>
							</p>
						</div>

					</li>
				</ul>
			</div>
			<script type="text/html" id="tmpl-quick-add-lesson">
				<div id="lpr-quick-add-lesson-form" class="lpr-quick-add-form">
					<input type="text" name="" />
					<button type="button" class="button" data-action="cancel"><?php 
            _e('Cancel [ESC]', 'learn_press');
            ?>
</button>
					<button type="button" class="button" data-action="add"><?php 
            _e('Add [Enter]', 'learn_press');
            ?>
</button>
					<span class="lpr-ajaxload">...</span>
				</div>
			</script>
			<script type="text/html" id="tmpl-quick-add-quiz">
				<div id="lpr-quick-add-quiz-form" class="lpr-quick-add-form">
					<input type="text" name="" />
					<button type="button" class="button" data-action="cancel"><?php 
            _e('Cancel [ESC]', 'learn_press');
            ?>
</button>
					<button type="button" class="button" data-action="add"><?php 
            _e('Add [Enter]', 'learn_press');
            ?>
</button>
					<span class="lpr-ajaxload">...</span>
				</div>
			</script>
			<script type="text/html" id="tmpl-curriculum-section">
				<li class="lpr-curriculum-section lpr-empty">
					<h3>
						<!-- actions -->
						<span class="lpr-action lpr-toggle" title="<?php 
            _e('Expand/Close', 'learn_press');
            ?>
"><i class="dashicons dashicons-minus"></i></span>
						<span class="lpr-action lpr-sort"><i class="dashicons dashicons-sort"></i></span>
						<span class="lpr-action lpr-remove" title="<?php 
            _e('Remove', 'learn_press');
            ?>
"><i class="dashicons dashicons-no"></i></span>
						<!-- // actions -->
						<span class="lpr-section-icon"><i class="dashicons dashicons-pressthis"></i></span>
						<span class="lpr-section-name-wrapper"><input name="_lpr_course_lesson_quiz[__SECTION__][name]" type="text" placeholder="Type section's name and hit enter" class="lpr-section-name" /></span>
					</h3>

					<div class="lpr-curriculum-section-content">
						<ul class="lpr-section-quiz-less"></ul>
						<p class="lpr-add-buttons">
							<button class="button button-primary" data-action="add-lesson"><?php 
            _e('Add Lesson', 'learn_press');
            ?>
</button>
							<button class="button button-primary" data-action="add-quiz"><?php 
            _e('Add Quiz', 'learn_press');
            ?>
</button>
							<button class="button button-primary" data-action="quick-add-lesson"><?php 
            _e('Quick add <span>L</span>esson', 'learn_press');
            ?>
</button>
							<button class="button button-primary" data-action="quick-add-quiz"><?php 
            _e('Quick add <span>Q</span>uiz', 'learn_press');
            ?>
</button>
							<?php 
            if (class_exists('LPR_Assignment_Post_Type')) {
                ?>
										<button class="button button-primary" data-action="add-assignment"><?php 
                _e('Add Assignment', 'learn_press');
                ?>
</button>
										<button class="button button-primary" data-action="quick-add-assignment"><?php 
                _e('Quick add Assigment', 'learn_press');
                ?>
</button>
									<?php 
            }
            ?>
						</p>
					</div>
				</li>
			</script>
			<script type="text/html" id="tmpl-section-quiz-lesson">

				<li class="lpr-empty lpr-{{data.type}}" data-id="{{data.id}}" data-type="{{data.type}}">
					<# if( 'quiz' == data.type ){ #>
						<span class="handle dashicons dashicons-format-status"></span>
						<# }else{ #>
							<span class="handle dashicons dashicons-media-document"></span>
							<# } #>
								<span class="lpr-title" title="<?php 
            _e('Click to quick edit', 'learn_press');
            ?>
">{{data.title}}</span><a href="" class="lpr-remove"><?php 
            _e('Remove', 'learn_press');
            ?>
</a><a href="<?php 
            echo admin_url('post.php?post={{data.id}}&action=edit');
            ?>
" target="_blank"><?php 
            _e('Edit', 'learn_press');
            ?>
</a>
								<input type="hidden" name="_lpr_course_lesson_quiz[__SECTION__][lesson_quiz][]" value="{{data.id}}" />
				</li>
			</script>

			<script type="text/html" id="tmpl-lpr-lesson-form">
				<div id="lpr-lesson-form" class="lpr-dynamic-form">
                    <?php 
            $query_args = array('post_type' => 'lpr_lesson', 'post_status' => 'publish', 'author' => $current_user, 'posts_per_page' => -1, 'post__not_in' => $exclude_lesson);
            //print_r( $query_args );
            $query = new WP_Query($query_args);
            ?>
					<select name="">
						<option value=""><?php 
            _e('--Select a Lesson--', 'learn_press');
            ?>
</option>
						<?php 
            if ($query->have_posts()) {
                while ($query->have_posts()) {
                    $p = $query->next_post();
                    echo '<option value="' . $p->ID . '">' . $p->post_title . '</option>';
                }
            }
            ?>
                    </select>
				</div>
			</script>
			<script type="text/html" id="tmpl-lpr-quiz-form">
				<div id="lpr-quiz-form" class="lpr-dynamic-form">
					<select name="">
						<option value=""><?php 
            _e('--Select a Quiz--', 'learn_press');
            ?>
</option>
						<?php 
            $query_args = array('post_type' => 'lpr_quiz', 'post_status' => 'publish', 'author' => $current_user, 'posts_per_page' => -1, 'post__not_in' => $exclude_quiz);
            $query = new WP_Query($query_args);
            if ($query->have_posts()) {
                while ($query->have_posts()) {
                    $p = $query->next_post();
                    echo '<option value="' . $p->ID . '">' . $p->post_title . '</option>';
                }
            }
            ?>
					</select>
				</div>
			</script>
			<?php 
            global $post;
            ?>
			<script type="text/javascript">
				var lpr_course_id =
				<?php 
            echo $post->ID;
            ?>
			</script>
			<?php 
            return ob_get_clean();
        }
Exemple #20
0
      </ul>
      <div class="clr"></div>
    </div>
  </div>

  <? 
  $args = array(
    'post_type' => 'appeals_index',
    'posts_per_page' => -1,
    'order' => 'ASC'
  );
  $query2 = new WP_Query( $args );
  $counter = 0;
  // Цикл
  while ( $query2->have_posts() ) {
    $query2->next_post(); 
    $image_id = get_post_thumbnail_id($query2->post->ID);
    $image_url = wp_get_attachment_image_src($image_id, 'full'); 
    $image_url = $image_url[0];
    $counter++;
    ?>
    <div class="darker">
      <div class="wrap">
        <div id="<? echo "for_man" . $counter; ?>" class="modal">
          <div class="close"></div>
          <div class="content">
            <div class="left-part">
              <img src="<? echo $image_url; ?>" width="100%" alt="">
            </div>
            <div class="right-part">
              <div class="colored"><? echo get_field('first_name_index', $query2->post->ID) . " " . get_field('last_name_index', $query2->post->ID)?></div>
 /**
  * Prepare the items
  */
 public function prepare_items()
 {
     // Set table properties
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     // Vies
     $this->views();
     // Set search
     if ($this->search !== null) {
         add_filter('posts_where', array($this, 'filter_posts_where'));
     }
     // Get Data
     $this->data = array();
     // Get per page
     $screen = get_current_screen();
     $per_page = absint(get_user_meta(get_current_user_id(), $screen->get_option('per_page', 'option'), true));
     $per_page = $per_page > 0 ? $per_page : 20;
     $paged = absint(isset($_GET['paged']) ? $_GET['paged'] : 1);
     $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'title';
     $order = isset($_GET['order']) ? $_GET['order'] : 'asc';
     // Get posts
     $post_query = new WP_Query(array('post_type' => $this->post_type, 'posts_per_page' => $per_page, 'paged' => $paged, 'suppress_filters' => false, 'orderby' => $orderby, 'order' => $order, 'post_status' => apply_filters('pc_manual_link_post_statuses', array('publish', 'private'))));
     // Format data for table
     if ($post_query->have_posts()) {
         while ($post_query->have_posts()) {
             $next_post = $post_query->next_post();
             $this->data[] = array('ID' => $next_post->ID, 'title' => $next_post->post_title);
         }
     }
     // Remove search filter
     remove_filter('posts_where', array($this, 'filter_posts_where'));
     // Pagination
     $this->set_pagination_args(array('total_items' => $post_query->found_posts, 'per_page' => $per_page));
     // Set items
     $this->items = $this->data;
 }
 public function review_collector_export_csv()
 {
     if (!isset($_GET['action']) || $_GET['action'] != 'wc-gzd-trusted-shops-export' || isset($_GET['action']) && $_GET['action'] == 'wc-gzd-trusted-shops-export' && !wp_verify_nonce($_REQUEST['_wpnonce'], 'wc-gzd-trusted-shops-export')) {
         return;
     }
     $interval_d = isset($_GET['interval']) && !empty($_GET['interval']) ? absint($_GET['interval']) : 30;
     header('Content-Description: File Transfer');
     header('Content-Disposition: attachment; filename=review-collector.csv');
     header('Content-Type: text/csv; charset=' . get_option('blog_charset'), true);
     header('Cache-Control: no-cache, no-store, must-revalidate');
     header('Pragma: no-cache');
     header('Expires: 0');
     $date = date('Y-m-d', strtotime('-' . $interval_d . ' days'));
     $order_query = new WP_Query(array('post_type' => 'shop_order', 'post_status' => array('wc-completed'), 'showposts' => -1, 'date_query' => array(array('after' => $date))));
     $data = array();
     while ($order_query->have_posts()) {
         $order_query->next_post();
         $order = wc_get_order($order_query->post->ID);
         array_push($data, array($order->billing_email, $order->id, $order->billing_first_name, $order->billing_last_name));
     }
     $write = $this->prepare_csv_data($data);
     $df = fopen("php://output", 'w');
     foreach ($write as $row) {
         fwrite($df, $row);
     }
     fclose($df);
     exit;
 }
 /**
  * Send Customer Email notifications if necessary (loops through orders and checks day difference after completion)
  */
 public function send_mails()
 {
     $order_query = new WP_Query(array('post_type' => 'shop_order', 'post_status' => 'wc-completed', 'meta_query' => array(array('key' => '_ekomi_review_link', 'compare' => 'EXISTS'), array('key' => '_ekomi_review_mail_sent', 'compare' => 'NOT EXISTS'))));
     while ($order_query->have_posts()) {
         $order_query->next_post();
         $order = wc_get_order($order_query->post->ID);
         $diff = WC_germanized()->get_date_diff($order->completed_date, date('Y-m-d H:i:s'));
         if ($diff['d'] >= (int) get_option('woocommerce_gzd_ekomi_day_diff')) {
             if ($mail = WC_germanized()->emails->get_email_instance_by_id('customer_ekomi')) {
                 $mail->trigger($order->id);
                 update_post_meta($order->id, '_ekomi_review_mail_sent', 1);
                 update_post_meta($order->id, '_ekomi_review_link', '');
             }
         }
     }
 }
 /**
  * Ensure slides are added to the slideshow in the correct order.
  *
  * Find the highest slide menu_order in the slideshow, increment, then
  * update the new slides menu_order.
  */
 public function update_menu_order()
 {
     $menu_order = 0;
     // get the slide with the highest menu_order so far
     $args = array('force_no_custom_order' => true, 'orderby' => 'menu_order', 'order' => 'DESC', 'post_type' => 'attachment', 'post_status' => 'inherit', 'lang' => '', 'suppress_filters' => 1, 'posts_per_page' => 1, 'tax_query' => array(array('taxonomy' => 'ml-slider', 'field' => 'slug', 'terms' => $this->slider->ID)));
     $query = new WP_Query($args);
     while ($query->have_posts()) {
         $query->next_post();
         $menu_order = $query->post->menu_order;
     }
     wp_reset_query();
     // increment
     $menu_order = $menu_order + 1;
     // update the slide
     wp_update_post(array('ID' => $this->slide->ID, 'menu_order' => $menu_order));
 }
    /**
     * render display condition for single post types
     *
     * @param obj $ad ad object
     * @since 1.2.6
     */
    public static function single_posts($ad = false)
    {
        if (is_object($ad)) {
            $_all = isset($ad->conditions['postids']['all']) ? 1 : 0;
            if (!$_all && empty($ad->conditions['postids']['method'])) {
                $_all = 1;
            }
        }
        ?>
<h4><label class="advads-conditions-all"><input type="checkbox" name="advanced_ad[conditions][postids][all]" value="1" <?php 
        checked($_all, 1);
        ?>
><?php 
        _e('Display an all <strong>individual posts, pages</strong> and public post type pages', 'advanced-ads');
        ?>
</label></h4><?php 
        ?>
<div class="advads-conditions-single">
        <p class="description"><?php 
        _e('Choose on which individual posts, pages and public post type pages you want to display or hide ads.', 'advanced-ads');
        ?>
</p><?php 
        // derrive method from previous setup
        // set defaults
        if (is_object($ad)) {
            $_method = isset($ad->conditions['postids']['method']) ? $ad->conditions['postids']['method'] : 0;
            if ($_method === 0) {
                if (empty($ad->conditions['postids']['include']) && !empty($ad->conditions['postids']['exclude'])) {
                    $_method = 'exclude';
                } elseif (!empty($ad->conditions['postids']['include']) && empty($ad->conditions['postids']['exclude'])) {
                    $_method = 'include';
                } else {
                    $_method = '';
                }
            }
        }
        ?>
<p><?php 
        _e('What should happen with ads on the list of individual posts below?', 'advanced-ads');
        ?>
</p>
        <label><input type="radio" name='advanced_ad[conditions][postids][method]' value='' <?php 
        checked('', $_method);
        ?>
><?php 
        _e('ignore the list', 'advanced-ads');
        ?>
</label></li>
        <label><input type="radio" name='advanced_ad[conditions][postids][method]' value='include' <?php 
        checked('include', $_method);
        ?>
><?php 
        _e('display the ad only there', 'advanced-ads');
        ?>
</label></li>
        <label><input type="radio" name='advanced_ad[conditions][postids][method]' value='exclude' <?php 
        checked('exclude', $_method);
        ?>
><?php 
        _e('hide the ad here', 'advanced-ads');
        ?>
</label></li>
        <?php 
        /**
         * Update warning
         * @todo remove on a later version, if no longer needed
         */
        if (!empty($ad->conditions['postids']['include']) && !empty($ad->conditions['postids']['exclude'])) {
            ?>
<div style="color: red;"><p><strong><?php 
            _e('Update warning', 'advanced-ads');
            ?>
</strong></p>
                <p><?php 
            _e('Due to some conflicts before version 1.2.6, it is from now on only possible to choose either individual pages to include or exclude an ad, but not both with mixed settings. It seems you are still using mixed settings on this page. Please consider changing your setup for this ad.', 'advanced-ads');
            ?>
</p>
                <p><?php 
            _e('Your old values are:', 'advanced-ads');
            ?>
</p>
                <p><?php 
            _e('Post IDs the ad is displayed on:', 'advanced-ads');
            echo $ad->conditions['postids']['include'];
            ?>
</p>
                <p><?php 
            _e('Post IDs the ad is hidden from:', 'advanced-ads');
            echo $ad->conditions['postids']['exclude'];
            ?>
</p>
                <p><?php 
            _e('Below you find the pages the ad is displayed on. If this is ok, just save the ad. If not, please update your settings.', 'advanced-ads');
            ?>
</p>

        </div><?php 
        }
        if (!empty($ad->conditions['postids']['include'])) {
            // backward compatibility
            // TODO: remove in a later version; this should already be an array
            if (is_string($ad->conditions['postids']['include'])) {
                $_postids = explode(',', $ad->conditions['postids']['include']);
            } else {
                $_postids = $ad->conditions['postids']['include'];
            }
        } elseif (!empty($ad->conditions['postids']['exclude'])) {
            // backward compatibility
            // TODO: remove in a later version; this should already be an array
            if (is_string($ad->conditions['postids']['exclude'])) {
                $_postids = explode(',', $ad->conditions['postids']['exclude']);
            } else {
                $_postids = $ad->conditions['postids']['exclude'];
            }
        } elseif (isset($ad->conditions['postids']['ids']) && is_array($ad->conditions['postids']['ids'])) {
            $_postids = $ad->conditions['postids']['ids'];
        } else {
            $_postids = array();
        }
        ?>
<ul class='advads-conditions-postids-list'><?php 
        if ($_postids != array()) {
            $args = array('post_type' => 'any', 'post__in' => $_postids, 'posts_per_page' => -1);
            $the_query = new WP_Query($args);
            while ($the_query->have_posts()) {
                $the_query->next_post();
                echo '<li><a class="remove" href="#">remove</a><a href="' . get_permalink($the_query->post->ID) . '">' . get_the_title($the_query->post->ID) . '</a><input type="hidden" name="advanced_ad[conditions][postids][ids][]" value="' . $the_query->post->ID . '"></li>';
            }
        }
        ?>
<li class="show-search"><a href="#"><?php 
        _e('new', 'advanced-ads');
        ?>
</a>
            <input type="text" style="display:none;" id="advads-display-conditions-individual-post" value="" placeholder="<?php 
        _e('type the title', 'advanced-ads');
        ?>
"/>
				<?php 
        wp_nonce_field('internal-linking', '_ajax_linking_nonce', false);
        ?>
			</li>
			</ul>
			</div><?php 
    }
Exemple #26
0
/**
 * Prints the appropriate response to a menu quick search.
 *
 * @since 3.0.0
 *
 * @param array $request The unsanitized request values.
 */
function _wp_ajax_menu_quick_search($request = array())
{
    $args = array();
    $type = isset($request['type']) ? $request['type'] : '';
    $object_type = isset($request['object_type']) ? $request['object_type'] : '';
    $query = isset($request['q']) ? $request['q'] : '';
    $response_format = isset($request['response-format']) && in_array($request['response-format'], array('json', 'markup')) ? $request['response-format'] : 'json';
    if ('markup' == $response_format) {
        $args['walker'] = new Walker_Nav_Menu_Checklist();
    }
    if ('get-post-item' == $type) {
        if (post_type_exists($object_type)) {
            if (isset($request['ID'])) {
                $object_id = (int) $request['ID'];
                if ('markup' == $response_format) {
                    echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($object_id))), 0, (object) $args);
                } elseif ('json' == $response_format) {
                    echo wp_json_encode(array('ID' => $object_id, 'post_title' => get_the_title($object_id), 'post_type' => get_post_type($object_id)));
                    echo "\n";
                }
            }
        } elseif (taxonomy_exists($object_type)) {
            if (isset($request['ID'])) {
                $object_id = (int) $request['ID'];
                if ('markup' == $response_format) {
                    echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_term($object_id, $object_type))), 0, (object) $args);
                } elseif ('json' == $response_format) {
                    $post_obj = get_term($object_id, $object_type);
                    echo wp_json_encode(array('ID' => $object_id, 'post_title' => $post_obj->name, 'post_type' => $object_type));
                    echo "\n";
                }
            }
        }
    } elseif (preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\\b)/', $type, $matches)) {
        if ('posttype' == $matches[1] && get_post_type_object($matches[2])) {
            $search_results_query = new WP_Query(array('no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'posts_per_page' => 10, 'post_type' => $matches[2], 's' => $query));
            if (!$search_results_query->have_posts()) {
                return;
            }
            while ($search_results_query->have_posts()) {
                $post = $search_results_query->next_post();
                if ('markup' == $response_format) {
                    $var_by_ref = $post->ID;
                    echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($var_by_ref))), 0, (object) $args);
                } elseif ('json' == $response_format) {
                    echo wp_json_encode(array('ID' => $post->ID, 'post_title' => get_the_title($post->ID), 'post_type' => $matches[2]));
                    echo "\n";
                }
            }
        } elseif ('taxonomy' == $matches[1]) {
            $terms = get_terms($matches[2], array('name__like' => $query, 'number' => 10));
            if (empty($terms) || is_wp_error($terms)) {
                return;
            }
            foreach ((array) $terms as $term) {
                if ('markup' == $response_format) {
                    echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array($term)), 0, (object) $args);
                } elseif ('json' == $response_format) {
                    echo wp_json_encode(array('ID' => $term->term_id, 'post_title' => $term->name, 'post_type' => $matches[2]));
                    echo "\n";
                }
            }
        }
    }
}
Exemple #27
0
 /**
  * Get posts
  *
  * @param array $field
  *
  * @return array
  */
 static function get_options($field)
 {
     $query = new WP_Query($field['query_args']);
     if ($query->have_posts()) {
         while ($query->have_posts()) {
             $post = $query->next_post();
             $options[$post->ID] = $post->post_title;
         }
     } else {
         $options = array();
     }
     return $options;
 }
 function live_blogging_tweet_to_comment()
 {
     if ('1' == get_option('liveblogging_enable_twitter'))
     {
         $connection = new TwitterOAuth(
                 LIVE_BLOGGING_TWITTER_CONSUMER_KEY,
                 LIVE_BLOGGING_TWITTER_CONSUMER_SECRET,
                 get_option('liveblogging_twitter_token'),
                 get_option('liveblogging_twitter_secret')
             );
         foreach ($connection->get('statuses/mentions') as $tweet) {
             
             // Get the entry this tweet refers to
             $in_reply_to = $tweet->in_reply_to_status_id;
             
             // Check that we've not already inserted this comment
             $comments = get_comments(
                 array('author_email' => $tweet->id . '@twitter.com')
             );
             
             $imported_tweets =
                 get_option('liveblogging_imported_tweets', array());
             
             if (!empty($in_reply_to)
                 && empty($comments)
                 && !in_array($tweet->id, $imported_tweets))
             {
                 $imported_tweets[] = $tweet->id;
                 update_option('liveblogging_imported_tweets', $imported_tweets);
                 $query = new WP_Query(array(
                     'meta_key' => '_liveblogging_tweeted',
                     'meta_value' => $in_reply_to,
                     'post_type' => 'liveblog_entry'
                 ));
                 while ($query->have_posts())
                 {
                     $query->next_post();
                     // Get the post that this entry is in
                     foreach (wp_get_object_terms(array($query->post->ID), 'liveblog') as $b) {
                         // Insert comment
                         wp_insert_comment(array(
                             'comment_post_ID' => intval($b->name),
                             'comment_author' => $tweet->user->name . ' (@' . $tweet->user->screen_name . ')',
                             'comment_author_email' => sprintf('%0.0f', $tweet->id) . '@twitter.com',
                             'comment_author_url' => 'http://twitter.com/' . $tweet->user->screen_name . '/status/' . sprintf('%0.0f', $tweet->id),
                             'comment_content' => $tweet->text,
                             'user_id' => 0,
                             'comment_agent' => 'Live Blogging for WordPress Twitter Importer',
                             'comment_date' => strftime('%Y-%m-%d %H:%M:%S', strtotime($tweet->created_at) + (get_option('gmt_offset') * 3600)),
                             'comment_approved' => (get_option('comment_moderation') == 1) ? 0 : 1
                         ));
                     }
                 }
             }
         }
     }
 }
Exemple #29
0
	}
	?>
	<script type="text/javascript">
		var barcodes = [];
	</script>
	<?
		// переводить страницу?

		$args = array(
          'post_type' => 'test_drive',
          'posts_per_page' => -1,
        );
        $query1 = new WP_Query( $args );
        // Цикл
        while ( $query1->have_posts() ) {
          $query1->next_post(); 
         ?>
			<script type="text/javascript">
				barcodes.push(<? the_field('td_barcode', $query1->post->ID); ?>);
			</script>
		<?
		}
		?>
	<div class="booking">
		<div class="wrap">
			<form action="../test-drive" method="post">
			    <p>Введите номер персонального штрих кода, который указан на билете:</p>
			    <p class="full">Количество записей по данному штрих коду исчерпано</p>
			    <input type="text" style="display: none;" name="ifen" id="ifen">
			    <input type="text" oninput="checker()" name="barcode" id="barcode_input"/>
			    <input type="submit" name="submit" value="Продолжить" class="submit" />
 public function find($params)
 {
     global $post;
     $offset = $params['offset'];
     $limit = $params['limit'];
     $post_args = array('showposts' => $limit + 1, 'offset' => $offset, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish');
     if (isset($params['category_id']) && '-1' != $params['category_id']) {
         //cetogory_id = -1 when fitive category all post is searched
         $post_args['category__in'] = array($params['category_id']);
     }
     if (isset($params['exclude_categories'])) {
         $excluded_categories = explode(',', $params['exclude_categories']);
         $post_args['category__not_in'] = $excluded_categories;
     }
     $query = new WP_Query($post_args);
     $remaped_posts = array();
     $this->attach_external_plugin_integration();
     while ($query->have_posts()) {
         $query->next_post();
         $post = $query->post;
         setup_postdata($post);
         $remaped_posts[] = $this->get_post($post, $params);
     }
     $paged_posts = $this->add_paging_info($remaped_posts, $params);
     return $paged_posts;
 }