public function form($instance) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; $episode_id = isset($instance['episode_id']) ? $instance['episode_id'] : 0; $show_title = isset($instance['show_title']) ? (bool) $instance['show_title'] : false; $show_excerpt = isset($instance['show_excerpt']) ? (bool) $instance['show_excerpt'] : false; $show_content = isset($instance['show_content']) ? (bool) $instance['show_content'] : false; $show_player = isset($instance['show_player']) ? (bool) $instance['show_player'] : false; $show_details = isset($instance['show_details']) ? (bool) $instance['show_details'] : false; // Get all podcast episodes $episode_ids = (array) ssp_episode_ids(); ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'ss-podcasting'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" placeholder="<?php _e('Use episode title', 'ss-podcasting'); ?> " value="<?php echo $title; ?> " /></p> <p><label for="<?php echo $this->get_field_id('episode_id'); ?> "><?php _e('Episode:', 'ss-podcasting'); ?> </label> <select id="<?php echo $this->get_field_id('episode_id'); ?> " name="<?php echo $this->get_field_name('episode_id'); ?> "> <option value="0"><?php _e('- Latest episode -', 'ss-podcasting'); ?> </option> <?php foreach ($episode_ids as $id) { echo '<option value="' . esc_attr($id) . '" ' . selected($episode_id, $id, false) . '>' . get_the_title($id) . '</option>' . "\n"; } ?> </select> </p> <p><input class="checkbox" type="checkbox" <?php checked($show_title); ?> id="<?php echo $this->get_field_id('show_title'); ?> " name="<?php echo $this->get_field_name('show_title'); ?> " /> <label for="<?php echo $this->get_field_id('show_title'); ?> "><?php _e('Display episode title inside widget?', 'ss-podcasting'); ?> </label></p> <p><input class="checkbox" type="checkbox" <?php checked($show_excerpt); ?> id="<?php echo $this->get_field_id('show_excerpt'); ?> " name="<?php echo $this->get_field_name('show_excerpt'); ?> " /> <label for="<?php echo $this->get_field_id('show_excerpt'); ?> "><?php _e('Display episode excerpt?', 'ss-podcasting'); ?> </label></p> <p><input class="checkbox" type="checkbox" <?php checked($show_content); ?> id="<?php echo $this->get_field_id('show_content'); ?> " name="<?php echo $this->get_field_name('show_content'); ?> " /> <label for="<?php echo $this->get_field_id('show_content'); ?> "><?php _e('Display full episode content?', 'ss-podcasting'); ?> </label></p> <p><input class="checkbox" type="checkbox" <?php checked($show_player); ?> id="<?php echo $this->get_field_id('show_player'); ?> " name="<?php echo $this->get_field_name('show_player'); ?> " /> <label for="<?php echo $this->get_field_id('show_player'); ?> "><?php _e('Display episode audio player?', 'ss-podcasting'); ?> </label></p> <p><input class="checkbox" type="checkbox" <?php checked($show_details); ?> id="<?php echo $this->get_field_id('show_details'); ?> " name="<?php echo $this->get_field_name('show_details'); ?> " /> <label for="<?php echo $this->get_field_id('show_details'); ?> "><?php _e('Display episode details?', 'ss-podcasting'); ?> </label></p> <?php }
/** * Fetch all podcast episodes * @param integer $n Number of episodes to fetch * @param string $series Slug of series to fetch * @param boolean $return_args True to return query args, false to return posts * @param string $context Context of query * @since 1.8.2 * @return array Array of posts or array of query args */ function ssp_episodes($n = 10, $series = '', $return_args = false, $context = '') { // Get all podcast episodes IDs $episode_ids = (array) ssp_episode_ids(); if ($context === 'glance') { return $episode_ids; } if (empty($episode_ids)) { return array(); } // Get all valid podcast post types $podcast_post_types = ssp_post_types(true); if (empty($podcast_post_types)) { return array(); } // Fetch podcast episodes $args = array('post_type' => $podcast_post_types, 'post_status' => 'publish', 'posts_per_page' => $n, 'ignore_sticky_posts' => true, 'post__in' => $episode_ids); if ($series) { $args['series'] = esc_attr($series); } $args = apply_filters('ssp_episode_query_args', $args, $context); if ($return_args) { return $args; } // Do we have anything in the cache here? $key = 'episodes'; $group = 'ssp'; $posts = wp_cache_get($key, $group); // If nothing in cache then fetch episodes again and store in cache if ($posts === false) { $posts = get_posts($args); wp_cache_add($key, $posts, $group, HOUR_IN_SECONDS * 12); } return $posts; }
public function add_all_post_types($query) { if (is_admin()) { return; } if (!$query->is_main_query()) { return; } if (is_post_type_archive('podcast') || is_tax('series')) { $podcast_post_types = get_option('ss_podcasting_use_post_types', array()); if (0 == count($podcast_post_types)) { return; } $episode_ids = ssp_episode_ids(); if (0 < count($episode_ids)) { $query->set('post__in', $episode_ids); $podcast_post_types[] = 'podcast'; $query->set('post_type', $podcast_post_types); } } }
public function add_all_post_types($query) { if (is_admin()) { return; } if (!$query->is_main_query()) { return; } if (is_post_type_archive('podcast') || is_tax('series')) { $podcast_post_types = ssp_post_types(false); if (empty($podcast_post_types)) { return; } $episode_ids = ssp_episode_ids(); if (!empty($episode_ids)) { $query->set('post__in', $episode_ids); $podcast_post_types[] = 'podcast'; $query->set('post_type', $podcast_post_types); } } }
/** * Fetch podcast episodes * @param integer $n Number of episodes to fetch * @param string $series Slug of series to fetch * @param boolean $return_args True to return query args, false to return posts * @param string $context Context of query * @since 1.8.2 * @return array Array of posts or array of query args */ function ssp_episodes($n = 10, $series = '', $return_args = false, $context = '') { // Get all podcast episodes IDs $episode_ids = (array) ssp_episode_ids(); if (0 == count($episode_ids)) { return array(); } $podcast_post_types = get_option('ss_podcasting_use_post_types', array()); $podcast_post_types[] = 'podcast'; // Fetch podcast episodes $args = array('post_type' => $podcast_post_types, 'post_status' => 'publish', 'posts_per_page' => $n, 'ignore_sticky_posts' => true, 'post__in' => $episode_ids); if ($series) { $args['series'] = esc_attr($series); } $args = apply_filters('ssp_episode_query_args', $args, $context); if ($return_args) { return $args; } return get_posts($args); }
/** * Fetch all podcast episodes * @param integer $n Number of episodes to fetch * @param string $series Slug of series to fetch * @param boolean $return_args True to return query args, false to return posts * @param string $context Context of query * @since 1.8.2 * @return array Array of posts or array of query args */ function ssp_episodes($n = 10, $series = '', $return_args = false, $context = '') { // Get all podcast episodes IDs $episode_ids = (array) ssp_episode_ids(); if (empty($episode_ids)) { return array(); } // Get all valid podcast post types $podcast_post_types = ssp_post_types(true); if (empty($podcast_post_types)) { return array(); } // Fetch podcast episodes $args = array('post_type' => $podcast_post_types, 'post_status' => 'publish', 'posts_per_page' => $n, 'ignore_sticky_posts' => true, 'post__in' => $episode_ids); if ($series) { $args['series'] = esc_attr($series); } $args = apply_filters('ssp_episode_query_args', $args, $context); if ($return_args) { return $args; } return get_posts($args); }