protected function get_sermon()
 {
     $sermon_id = $this->att('sermon_id');
     if (!$sermon_id || 'recent' === $sermon_id || '0' === $sermon_id || 0 === $sermon_id) {
         $this->shortcode_object->set_att('sermon', $this->most_recent_sermon());
     } elseif ('this' === $sermon_id) {
         $this->shortcode_object->set_att('sermon', gc_get_sermon_post(get_queried_object_id()));
     } elseif (is_numeric($sermon_id)) {
         $this->shortcode_object->set_att('sermon', gc_get_sermon_post($sermon_id));
     }
     return $this->att('sermon');
 }
Exemplo n.º 2
0
/**
 * Get's audio player for the sermon.
 *
 * @since  0.1.3
 *
 * @param  mixed $sermon Post object or ID or (GCS_Sermon_Post object).
 * @param  mixed $args   Arguments passed to GCS_Sermon_Post::get_audio_player().
 *
 * @return string Sermon audio player output.
 */
function gc_get_sermon_audio_player($sermon = 0, $args = array())
{
    $sermon = gc_get_sermon_post($sermon);
    // If no sermon or no related links, bail.
    if (!$sermon || !($audio_player = $sermon->get_audio_player($args))) {
        return '';
    }
    return $audio_player;
}
Exemplo n.º 3
0
 protected function map_related_term_args($args)
 {
     $required = false;
     $passes = false;
     $keys = array('series' => 'related_series', 'speaker' => 'related_speaker');
     foreach ($keys as $key => $param) {
         if ($term_id = absint($this->att($param))) {
             $args['tax_query'][] = array('taxonomy' => $this->taxonomies->{$key}->taxonomy(), 'field' => 'id', 'terms' => $term_id);
             continue;
         }
         if ('this' !== $this->att($param)) {
             continue;
         }
         $required = true;
         try {
             $sermon = gc_get_sermon_post(get_queried_object(), true);
             $args['post__not_in'] = array($sermon->ID);
             $method = 'get_' . $key;
             $term = $sermon->{$method}();
             if (!$term) {
                 throw new Exception('No ' . $key . ' term.');
             }
         } catch (Exception $e) {
             continue;
         }
         $passes = true;
         $args['tax_query'][] = array('taxonomy' => $this->taxonomies->{$key}->taxonomy(), 'field' => 'id', 'terms' => $term->term_id);
     }
     if ($required && !$passes) {
         // They wanted sermons associated to 'this', but that's not possible.
         return false;
     }
     return $args;
 }