Ejemplo n.º 1
0
 /**
  * Generate conditional fields for the "posts" slideshow type.
  * @since  1.0.0
  * @return array $fields An array of fields.
  */
 public function generate_conditional_fields_posts()
 {
     global $wooslider;
     $images_url = $wooslider->plugin_url . '/assets/images/';
     $fields = array();
     // Categories.
     $terms = get_categories();
     $terms_options = array();
     if (!is_wp_error($terms)) {
         foreach ($terms as $k => $v) {
             $terms_options[$v->slug] = $v->name;
         }
     }
     $categories_args = array('key' => 'category', 'data' => array('options' => $terms_options));
     // Tags.
     $terms = get_tags();
     $terms_options = array();
     if (!is_wp_error($terms)) {
         foreach ($terms as $k => $v) {
             $terms_options[$v->slug] = $v->name;
         }
     }
     $tags_args = array('key' => 'tag', 'data' => array('options' => $terms_options));
     $thumbnails = WooSlider_Utils::get_thumbnail_options();
     $thumbnails_options = array();
     foreach ($thumbnails as $k => $v) {
         $thumbnails_options[$k] = $v['name'];
     }
     $thumbnails_args = array('key' => 'thumbnails', 'data' => array('options' => $thumbnails_options, 'default' => 'Default'));
     $layout_types = WooSlider_Utils::get_posts_layout_types();
     $layout_options = array();
     foreach ((array) $layout_types as $k => $v) {
         $layout_options[$k] = $v['name'];
     }
     $layout_images = array('text-left' => esc_url($images_url . 'text-left.png'), 'text-right' => esc_url($images_url . 'text-right.png'), 'text-top' => esc_url($images_url . 'text-top.png'), 'text-bottom' => esc_url($images_url . 'text-bottom.png'));
     $layouts_args = array('key' => 'layout', 'data' => array('options' => $layout_options, 'images' => $layout_images));
     $overlay_images = array('none' => esc_url($images_url . 'default.png'), 'full' => esc_url($images_url . 'text-bottom.png'), 'natural' => esc_url($images_url . 'overlay-natural.png'));
     $overlay_options = array('none' => __('None', 'wooslider'), 'full' => __('Full', 'wooslider'), 'natural' => __('Natural', 'wooslider'));
     $overlay_args = array('key' => 'overlay', 'data' => array('options' => $overlay_options, 'images' => $overlay_images));
     $limit_options = array();
     for ($i = 1; $i <= 20; $i++) {
         $limit_options[$i] = $i;
     }
     $limit_args = array('key' => 'limit', 'data' => array('options' => $limit_options, 'default' => 5));
     //$thumbnails_args = array( 'key' => 'thumbnails', 'data' => array() );
     $sticky_posts_args = array('key' => 'sticky_posts', 'data' => array());
     $link_title_args = array('key' => 'link_title', 'data' => array());
     $display_excerpt_args = array('key' => 'display_excerpt', 'data' => array('default' => '1'));
     // Create final array.
     $fields['limit'] = array('name' => __('Number of Posts', 'wooslider'), 'type' => 'select', 'args' => $limit_args, 'description' => __('The maximum number of posts to display', 'wooslider'));
     $fields['sticky_posts'] = array('name' => __('Allow for Sticky Posts', 'wooslider'), 'type' => 'checkbox', 'args' => $sticky_posts_args, 'description' => __('Display sticky posts in the slider', 'wooslider'));
     $fields['thumbnails'] = array('name' => __('Use thumbnails for Pagination', 'wooslider'), 'type' => 'select', 'args' => $thumbnails_args, 'description' => __('Use thumbnails for pagination, instead of "dot" indicators (uses featured image)', 'wooslider'));
     $fields['link_title'] = array('name' => __('Link the post title to it\'s post', 'wooslider'), 'type' => 'checkbox', 'args' => $link_title_args, 'description' => __('Link the post title to it\'s single post screen', 'wooslider'));
     $fields['display_excerpt'] = array('name' => __('Display the post\'s excerpt', 'wooslider'), 'type' => 'checkbox', 'args' => $display_excerpt_args, 'description' => __('Display the post\'s excerpt on each slide', 'wooslider'));
     $fields['layout'] = array('name' => __('Layout', 'wooslider'), 'type' => 'images', 'args' => $layouts_args, 'description' => __('The layout to use when displaying posts', 'wooslider'));
     $fields['overlay'] = array('name' => __('Overlay', 'wooslider'), 'type' => 'images', 'args' => $overlay_args, 'description' => __('The type of overlay to use when displaying the post text', 'wooslider'));
     $fields['category'] = array('name' => __('Categories', 'wooslider'), 'type' => 'multicheck', 'args' => $categories_args, 'description' => __('The categories from which to display posts', 'wooslider'));
     $fields['tag'] = array('name' => __('Tags', 'wooslider'), 'type' => 'multicheck', 'args' => $tags_args, 'description' => __('The tags from which to display posts', 'wooslider'));
     return $fields;
 }