コード例 #1
0
 function test_largo_is_series_landing_enabled()
 {
     // Series option has not been touched yet (a new install)
     $result = largo_is_series_landing_enabled();
     $this->assertFalse($result);
     // Series option is to not enable series
     of_set_option('custom_landing_enabled', false);
     $result = largo_is_series_landing_enabled();
     $this->assertFalse($result);
     // Series option is to enable series
     of_set_option('custom_landing_enabled', 1);
     $result = largo_is_series_landing_enabled();
     $this->assertTrue($result);
 }
コード例 #2
0
 /**
  * For a series, find a thumbnail in the landing pages or the posts, and create an <li>
  *
  * @private
  * @uses largo_taxonomy_list_widget::render_li
  * @uses largo_featured_thumbnail_in_post_array
  * @uses largo_first_headline_in_post_array
  */
 private function render_series_list($tax_items, $instance)
 {
     foreach ($tax_items as $item) {
         $thumbnail = '';
         $headline = '';
         $posts = array();
         if ($instance['thumbnails'] == '1' || $instance['use_headline'] == '1') {
             $query_args = array('tax_query' => array(array('taxonomy' => $instance['taxonomy'], 'field' => 'term_id', 'terms' => $item->term_id)));
             $posts = get_posts($query_args);
         }
         if ($instance['thumbnails'] == '1' && largo_is_series_landing_enabled()) {
             $landing_array = largo_get_series_landing_page_by_series($item);
             // Thumbnail shall be the one for the landing page post
             foreach ($landing_array as $post) {
                 $thumbnail = get_the_post_thumbnail($post->ID);
             }
         }
         if ($thumbnail == '') {
             $thumbnail = largo_featured_thumbnail_in_post_array($posts);
         }
         if ($instance['use_headline'] == '1') {
             $headline = largo_first_headline_in_post_array($posts);
         }
         $this->render_li($item, $thumbnail, $headline);
     }
 }
コード例 #3
0
    function form($instance)
    {
        //Defaults
        $instance = wp_parse_args((array) $instance, array('title' => '', 'taxonomy' => ''));
        $title = esc_attr($instance['title']);
        $taxonomy = esc_attr($instance['taxonomy']);
        $count = $instance['count'];
        $include = $instance['include'];
        $dropdown = isset($instance['dropdown']) ? (bool) $instance['dropdown'] : false;
        $thumbnails = isset($instance['thumbnails']) ? (bool) $instance['thumbnails'] : false;
        $use_headline = isset($instance['use_headline']) ? (bool) $instance['use_headline'] : false;
        ?>
		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'largo');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo $title;
        ?>
" /></p>

		<p>
			<label for="<?php 
        echo $this->get_field_id('include');
        ?>
"><?php 
        _e('Only display the terms in this comma-separated list of term IDs:', 'largo');
        ?>
</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id('include');
        ?>
" name="<?php 
        echo $this->get_field_name('include');
        ?>
" type="text" value="<?php 
        echo $include;
        ?>
" />
			<small><?php 
        _e('Find term IDs by examining the URL of the taxonomy when you click the "edit" button in the list', 'largo');
        ?>
.</small>
		</p>

		<p>
			<label for"<?php 
        echo $this->get_field_id('count');
        ?>
"><?php 
        _e('Count: (leave blank to receive all items)', 'largo');
        ?>
</label>
			<input id="<?php 
        echo $this->get_field_id('count');
        ?>
" name="<?php 
        echo $this->get_field_name('count');
        ?>
" type="number" value="<?php 
        echo $count;
        ?>
" />
		</p>

		<p>
			<label for="<?php 
        echo $this->get_field_id('taxonomy');
        ?>
"><?php 
        _e('Taxonomy:', 'largo');
        ?>
</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id('taxonomy');
        ?>
" name="<?php 
        echo $this->get_field_name('taxonomy');
        ?>
" type="text" value="<?php 
        echo $taxonomy;
        ?>
" />
		</p>

		<p><input type="checkbox" class="checkbox ltlw-dropdown" id="<?php 
        echo $this->get_field_id('dropdown');
        ?>
" name="<?php 
        echo $this->get_field_name('dropdown');
        ?>
"<?php 
        checked($dropdown);
        ?>
 />
			<label for="<?php 
        echo $this->get_field_id('dropdown');
        ?>
"><?php 
        _e('Display as dropdown', 'largo');
        ?>
</label>
		</p>

		<p><input type="checkbox" class="checkbox ltlw-thumbnails" id="<?php 
        echo $this->get_field_id('thumbnails');
        ?>
" name="<?php 
        echo $this->get_field_name('thumbnails');
        ?>
"<?php 
        checked($thumbnails);
        ?>
 <?php 
        echo largo_is_series_landing_enabled() ? '' : 'disabled';
        ?>
 />
			<label for="<?php 
        echo $this->get_field_id('thumbnails');
        ?>
"><?php 
        _e('Display thumbnails?', 'largo');
        ?>
 <?php 
        echo largo_is_series_landing_enabled() ? '' : __('To use this function, enable Series and Series Landing Pages in Appearance > Theme Options > Advanced.', 'largo');
        ?>
 </label>
		</p>

		<p><input type="checkbox" class="checkbox ltlw-headline" id="<?php 
        echo $this->get_field_id('use_headline');
        ?>
" name="<?php 
        echo $this->get_field_name('use_headline');
        ?>
"<?php 
        checked($use_headline);
        ?>
 />
			<label for="<?php 
        echo $this->get_field_id('use_headline');
        ?>
"><?php 
        _e('Display headline of most-recent post in taxonomy?', 'largo');
        ?>
</label>
		</p>

		<script>
			jQuery(document).ready(function($) {
				$('.ltlw-dropdown').click(function() {
					$(this).parent().parent().find('.ltlw-thumbnails').removeAttr('checked');
					$(this).parent().parent().find('.ltlw-headline').removeAttr('checked');
				});
				$('.ltlw-thumbnails').click(function() {
					$(this).parent().parent().find('.ltlw-dropdown').removeAttr('checked');
				});
				$('.ltlw-headline').click(function() {
					$(this).parent().parent().find('.ltlw-dropdown').removeAttr('checked');
				});
			});
		</script>

	<?php 
    }