/** * Initialize cache */ public function init() { // save defaults - also used by custom-css generator via Bunyad::options()->default $options_tree = (include get_template_directory() . '/admin/options.php'); $this->defaults = Bunyad::factory('admin/options')->get_elements_from_tree($options_tree); $options = get_option($this->configs['theme_prefix'] . '_theme_options'); if (is_array($options) && $options) { $this->cache = $options; } }
public function form($instance) { $defaults = array('type' => '', 'image' => '', 'text' => '', 'email' => '', 'posts' => ''); $instance = array_merge($defaults, (array) $instance); extract($instance); $render = Bunyad::factory('admin/option-renderer'); /* @var $render Bunyad_Admin_OptionRenderer */ ?> <input type="hidden" name="<?php echo $this->get_field_name('no_container'); ?> " value="1" /> <p><strong><?php _e('Important:', 'so-panels'); ?> </strong> <?php _e('This block automatically shows the sub-categories under a parent category. Only a parent category needs to be selected.', 'so-panels'); ?> </p> <p> <label><?php _e('Separator Type:', 'so-panels'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('type')); ?> "> <option value="line"><?php _e('Line', 'so-panels'); ?> </option> <option value="space"><?php _e('Space', 'so-panels'); ?> </option> <option value="half-line"><?php _e('Half Height Line', 'so-panels'); ?> </option> <option value="half-space"><?php _e('Half Height Space', 'so-panels'); ?> </option> </select> </p> <?php }
/** * Render the metabox - used via callback * * @param array $post * @param array $args */ public function render($post = null, $args = null) { if (!$args['id']) { return false; } // add nonce for security if (!isset($this->cache['nonce'])) { wp_nonce_field('meta_save', '_nonce_' . $this->prefix . 'meta', false); } Bunyad::factory('admin/option-renderer'); // load $file = sanitize_file_name(str_replace($this->prefix, '', $args['id'])) . '.php'; $meta = Bunyad::factory('admin/meta-renderer', true); /* @var $meta Bunyad_Admin_MetaRenderer */ // render the template $meta->set_prefix($this->option_prefix)->template(array(), locate_template('admin/meta/' . $file), Bunyad::posts()->meta(null, $post->ID), array('post' => $post, 'box' => $this->get_box($args['id']), 'box_id' => $args['id'])); }
public function get_custom_fields($item, $depth = 0) { $fields = apply_filters('bunyad_custom_menu_fields', array()); $output = ''; foreach ($fields as $key => $field) { // parent menu field only? if (!empty($field['parent_only']) && $depth > 0) { continue; } // only applies to a specific location? if (!empty($field['locations']) && !empty($this->locations[$this->current_menu]) && !in_array($this->locations[$this->current_menu], $field['locations'])) { continue; } // relevant field values $name = 'menu-item-' . esc_attr($key) . '[' . $item->ID . ']'; $value = esc_attr($item->{$key}); // use renderer or a template? if (is_array($field['element'])) { $renderer = Bunyad::factory('admin/option-renderer'); /* @var $renderer Bunyad_Admin_OptionRenderer */ if ($field['element']['type'] == 'select') { $template = $renderer->render_select(array_merge(array('name' => $name, 'value' => $value), $field['element'])); } } else { // string template $template = str_replace(array('%id%', '%name%', '%value%'), array($item->ID, $name, $value), $field['element']); } $output .= ' <p class="field-custom description description-wide"> <label for="edit-menu-item-subtitle-' . esc_attr($item->ID) . '"> ' . $field['label'] . '<br />' . $template . ' </label> </p>'; } return $output; }
<?php $render = Bunyad::factory('admin/option-renderer'); ?> <p><a href="#" id="add-more-groups"><?php _e('Add More Accordions', 'bunyad-shortcodes'); ?> </a></p> <script type="text/html" class="template-group-options"> <div class="divider-or"><span><?php _e('Accordion %number%'); ?> </span></div> <div class="element-control"> <label><?php _e('Title:', 'bunyad-shortcodes'); ?> </label> <?php echo $render->render_text(array('name' => 'title[%number%]')); ?> </div> <div class="element-control"> <label><?php _e('Default:', 'bunyad-shortcodes'); ?>
public function form($instance) { $defaults = array('pagination' => 0, 'heading' => '', 'heading_type' => '', 'posts' => 4, 'type' => '', 'cats' => '', 'post_type' => ''); $instance = array_merge($defaults, (array) $instance); extract($instance); $render = Bunyad::factory('admin/option-renderer'); /* @var $render Bunyad_Admin_OptionRenderer */ ?> <input type="hidden" name="<?php echo $this->get_field_name('no_container'); ?> " value="1" /> <p> <label><?php _e('Number of Posts:', 'bunyad-admin'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('posts')); ?> " type="text" value="<?php echo esc_attr($posts); ?> " /> </p> <p class="description"><?php _e('Configures posts to show for each listing. Leave empty to use theme default number of posts.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Sort By:', 'bunyad-admin'); ?> </label> <select name="<?php echo esc_attr($this->get_field_name('sort_by')); ?> "> <option value=""><?php _e('Published Date', 'bunyad-admin'); ?> </option> <option value="modified"><?php _e('Modified Date', 'bunyad-admin'); ?> </option> <option value="random"><?php _e('Random', 'bunyad-admin'); ?> </option> </select> <select name="<?php echo esc_attr($this->get_field_name('sort_order')); ?> "> <option value="desc"><?php _e('Latest First - Descending', 'bunyad-admin'); ?> </option> <option value="asc"><?php _e('Oldest First - Ascending', 'bunyad-admin'); ?> </option> </select> </p> <p> <label><?php _e('Listing Style:', 'bunyad-admin'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('type')); ?> "> <option value=""><?php _e('Default Style (In Theme Settings)', 'bunyad-admin'); ?> </option> <option value="modern"><?php _e('Modern Style - 2 Column', 'bunyad-admin'); ?> </option> <option value="modern-3"><?php _e('Modern Style - 3 Column', 'bunyad-admin'); ?> </option> <option value="grid-overlay"><?php _e('Grid Overlay - 2 Column', 'bunyad-admin'); ?> </option> <option value="grid-overlay-3"><?php _e('Grid Overlay - 3 Column', 'bunyad-admin'); ?> </option> <option value="tall-overlay"><?php _e('Tall Grid Overlay', 'bunyad-admin'); ?> </option> <option value="alt"><?php _e('Blog Style', 'bunyad-admin'); ?> </option> <option value="classic"><?php _e('Classic - Large Blog Style', 'bunyad-admin'); ?> </option> <option value="timeline"><?php _e('Timeline Style', 'bunyad-admin'); ?> </option> </select> </p> <p class="description"><?php _e('Check docs and demo to choose the right style.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Main Category: (Optional)', 'bunyad-admin'); ?> </label> <?php wp_dropdown_categories(array('show_option_all' => __('-- None --', 'bunyad-admin'), 'hierarchical' => 1, 'hide_empty' => 0, 'order_by' => 'name', 'class' => 'widefat', 'name' => $this->get_field_name('cat'))); ?> </p> <p class="description"><?php _e('Posts will be limited to this category and category color will be used for heading.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Heading: (Optional)', 'bunyad-admin'); ?> </label> <input class="widefat" name="<?php echo esc_attr($this->get_field_name('heading')); ?> " type="text" value="<?php echo esc_attr($heading); ?> " /> </p> <p class="description"><?php _e('Optional heading.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Heading Style:', 'bunyad-admin'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('heading_type')); ?> "> <option value="block"><?php _e('Block Section Heading Style', 'bunyad-admin'); ?> </option> <option value=""><?php _e('Page Heading Style', 'bunyad-admin'); ?> </option> </select> </p> <p class="description"><?php _e('Page heading style is normal heading style used for pages. Block section heading style is what you would see often on homepage with multiple sections.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Show Category Overlays?', 'bunyad-admin'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('cat_labels')); ?> "> <option value="1"><?php _e('Yes', 'bunyad-admin'); ?> </option> <option value="0"><?php _e('No', 'bunyad-admin'); ?> </option> </select> </p> <div> <label><?php _e('Pagination:', 'bunyad-admin'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('pagination')); ?> "> <option value="0"><?php _e('Disabled', 'bunyad-admin'); ?> </option> <option value="1"><?php _e('Enabled', 'bunyad-admin'); ?> </option> </select> </div> <div> <label><?php _e('Pagination Type:', 'bunyad-admin'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('pagination_type')); ?> "> <option value=""><?php _e('Normal', 'bunyad-admin'); ?> </option> <option value="infinite"><?php _e('Infinite Scroll', 'bunyad-admin'); ?> </option> </select> </div> <p class="description"><?php _e('WARNING: Infinite Scroll will only work for the last block on a page. Infinite scroll loads more posts as user scrolls.', 'bunyad-admin'); ?> </p> <div class="taxonomydiv"> <!-- borrow wp taxonomydiv > categorychecklist css rules --> <label><?php _e('Limit Categories:', 'bunyad-admin'); ?> </label> <div class="tabs-panel"> <ul class="categorychecklist"> <?php ob_start(); wp_category_checklist(); echo str_replace('post_category[]', $this->get_field_name('cats') . '[]', ob_get_clean()); ?> </ul> </div> </div> <p class="description"><?php _e('By default, all categories will be used. Tick categories to limit to a specific category or categories.', 'bunyad-admin'); ?> </p> <p class="tag"> <?php _e('or Limit with Tags: (optional)', 'bunyad-admin'); ?> <input type="text" name="<?php echo $this->get_field_name('tags'); ?> " value="" class="widefat" /> </p> <p class="description"><?php _e('Separate tags with comma. e.g. cooking,sports', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Offset: (Advanced)', 'bunyad-admin'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('offset'); ?> " value="0" /> </p> <p class="description"><?php _e('By specifying an offset as 10 (for example), you can ignore 10 posts in the results.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Post Types: (Advanced)', 'bunyad-admin'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('post_type')); ?> " type="text" value="<?php echo esc_attr($post_type); ?> " /> </p> <p class="description"><?php _e('Only for advanced users! You can use a custom post type here - multiples supported when separated by comma. Leave empty to use the default format.', 'bunyad-admin'); ?> </p> <?php }
public function form($instance) { $defaults = array('title' => '', 'number' => 10, 'format' => '', 'cat' => '', 'post_type' => ''); $instance = array_merge($defaults, (array) $instance); extract($instance); $render = Bunyad::factory('admin/option-renderer'); /* @var $render Bunyad_Admin_OptionRenderer */ ?> <input type="hidden" name="<?php echo $this->get_field_name('no_container'); ?> " value="1" /> <p> <label><?php _e('Title:', 'bunyad-admin'); ?> </label> <input class="widefat" name="<?php echo esc_attr($this->get_field_name('title')); ?> " type="text" value="<?php echo esc_attr($title); ?> " /> </p> <p> <label><?php _e('Number of Media:', 'bunyad-admin'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('number')); ?> " type="text" value="<?php echo esc_attr($number); ?> " /> </p> <p class="description"><?php _e(' Leave empty to use theme default number of posts.', 'bunyad-admin'); ?> </p> <div> <label><?php _e('Type of Media:', 'bunyad-admin'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('format')); ?> "> <option value="video"><?php _e('Videos', 'bunyad-admin'); ?> </option> <option value="audio"><?php _e('Audio', 'bunyad-admin'); ?> </option> <option value="gallery"><?php _e('Gallery', 'bunyad-admin'); ?> </option> <option value="all"><?php _e('All Post Formats', 'bunyad-admin'); ?> </option> </select> <p class="description"><?php _e('Corresponds to "post format". e.g. videos would use posts marked as video format.', 'bunyad-admin'); ?> </p> </div> <p> <label><?php _e('Limit to Category:', 'bunyad-admin'); ?> </label> <?php wp_dropdown_categories(array('hierarchical' => 1, 'show_option_all' => __('Not Limited', 'bunyad-admin'), 'order_by' => 'name', 'class' => 'widefat', 'name' => $this->get_field_name('cat'))); ?> </p> <p> <label><?php _e('or Limit by Tags: (optional) ', 'bunyad-admin'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('tax_tag'); ?> " value="" /> </p> <p class="description"><?php _e('You can use a single or multiple tags. Separate tags with comma. e.g. cooking,sports', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Post Types: (Advanced)', 'bunyad-admin'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('post_type')); ?> " type="text" value="<?php echo esc_attr($post_type); ?> " /> </p> <p class="description"><?php _e('Only for advanced users! You can use a custom post type here - multiples supported when separated by comma. Leave empty to use the default format.', 'bunyad-admin'); ?> </p> <?php }
public function form($instance) { // enqueue js to the footer add_action('admin_print_footer_scripts', array($this, 'add_javascript'), 60); $defaults = array('posts' => 4, 'cats' => '', 'sorting' => '', 'post_type' => ''); $instance = array_merge($defaults, (array) $instance); extract($instance); $render = Bunyad::factory('admin/option-renderer'); /* @var $render Bunyad_Admin_OptionRenderer */ ?> <input type="hidden" name="<?php echo $this->get_field_name('no_container'); ?> " value="1" /> <p><strong><?php _e('Important:', 'bunyad-admin'); ?> </strong> <?php _e('Select 2 categories for 2 columns and 3 categories for 3 columns.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Number of Posts:', 'bunyad-admin'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('posts')); ?> " type="text" value="<?php echo esc_attr($posts); ?> " /> </p> <p class="description"><?php _e('Configures posts to show in each column. Leave empty to use theme default number of posts.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Sort By:', 'bunyad-admin'); ?> </label> <select name="<?php echo esc_attr($this->get_field_name('sort_by')); ?> "> <option value=""><?php _e('Published Date', 'bunyad-admin'); ?> </option> <option value="modified"><?php _e('Modified Date', 'bunyad-admin'); ?> </option> <option value="random"><?php _e('Random', 'bunyad-admin'); ?> </option> </select> <select name="<?php echo esc_attr($this->get_field_name('sort_order')); ?> "> <option value="desc"><?php _e('Latest First - Descending', 'bunyad-admin'); ?> </option> <option value="asc"><?php _e('Oldest First - Ascending', 'bunyad-admin'); ?> </option> </select> </p> <div> <label><?php _e('Columns:', 'bunyad-admin'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('columns')); ?> "> <option value="2"><?php _e('2 Columns', 'bunyad-admin'); ?> </option> <option value="3"><?php _e('3 Columns', 'bunyad-admin'); ?> </option> </select> </div> <div> <label><?php _e('Heading Style:', 'bunyad-admin'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('heading_type')); ?> "> <option value="auto"><?php _e('Auto: Overlay for 2 Column - Block Heading for 3 Columns', 'bunyad-admin'); ?> <option value="none"><?php _e('No Heading', 'bunyad-admin'); ?> </option> </select> </div> <hr /> <div> <h3><?php _e('First Column', 'bunyad-admin'); ?> </h3> <label><?php _e('Category', 'bunyad-admin'); ?> </label> <?php wp_dropdown_categories(array('show_option_all' => __('-- None - Use a Tag --', 'bunyad-admin'), 'hierarchical' => 1, 'hide_empty' => 0, 'order_by' => 'name', 'class' => 'widefat', 'name' => $this->get_field_name('cat_1'))); ?> <p class="tag"><label><?php _e('or Enter a Tag:', 'bunyad-admin'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('tag_1'); ?> " value="" /></p> <p> <label><?php _e('Custom Heading (optional)', 'bunyad-admin'); ?> </label> <input type="text" class="widefat" name="<?php echo $this->get_field_name('heading_1'); ?> " value="" /> </p> <p> <label><?php _e('Offset: (Advanced)', 'bunyad-admin'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('offset_1'); ?> " value="0" /> </p> <p class="description"><?php _e('By specifying an offset as 10 (for example), you can ignore 10 posts in the results.', 'bunyad-admin'); ?> </p> </div> <hr /> <div> <h3><?php _e('Second Column', 'bunyad-admin'); ?> </h3> <label><?php _e('Category', 'bunyad-admin'); ?> </label> <?php wp_dropdown_categories(array('show_option_all' => __('-- None - Use a Tag --', 'bunyad-admin'), 'hierarchical' => 1, 'hide_empty' => 0, 'order_by' => 'name', 'class' => 'widefat', 'name' => $this->get_field_name('cat_2'))); ?> <p class="tag"><label><?php _e('or Enter a Tag:', 'bunyad-admin'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('tag_2'); ?> " value="" /></p> <p> <label><?php _e('Custom Heading (optional)', 'bunyad-admin'); ?> </label> <input type="text" class="widefat" name="<?php echo $this->get_field_name('heading_2'); ?> " value="" /> </p> <p> <label><?php _e('Offset: (Advanced)', 'bunyad-admin'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('offset_2'); ?> " value="0" /> </p> <p class="description"><?php _e('By specifying an offset as 10 (for example), you can ignore 10 posts in the results.', 'bunyad-admin'); ?> </p> </div> <div class="cat-3"> <hr /> <h3><?php _e('Third Column', 'bunyad-admin'); ?> </h3> <label><?php _e('Category', 'bunyad-admin'); ?> </label> <?php wp_dropdown_categories(array('show_option_all' => __('-- None - Use a Tag --', 'bunyad-admin'), 'hierarchical' => 1, 'hide_empty' => 0, 'order_by' => 'name', 'class' => 'widefat', 'name' => $this->get_field_name('cat_3'))); ?> <p class="tag"><label><?php _e('or Enter a Tag:', 'bunyad-admin'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('tag_3'); ?> " value="" /></p> <p> <label><?php _e('Custom Heading (optional)', 'bunyad-admin'); ?> </label> <input type="text" class="widefat" name="<?php echo $this->get_field_name('heading_3'); ?> " value="" /> </p> <p> <label><?php _e('Offset: (Advanced)', 'bunyad-admin'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('offset_3'); ?> " value="0" /> </p> <p class="description"><?php _e('By specifying an offset as 10 (for example), you can ignore 10 posts in the results.', 'bunyad-admin'); ?> </p> </div> <p> <label><?php _e('Post Types: (Advanced)', 'bunyad-admin'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('post_type')); ?> " type="text" value="<?php echo esc_attr($post_type); ?> " /> </p> <p class="description"><?php _e('Only for advanced users! You can use a custom post type here - multiples supported when separated by comma. Leave empty to use the default format. .', 'bunyad-admin'); ?> </p> <?php /** <div class="taxonomydiv"> <!-- borrow wp taxonomydiv > categorychecklist css rules --> <label><?php _e('Categories:', 'bunyad-admin'); ?></label> <div class="tabs-panel"> <ul class="categorychecklist"> <?php ob_start(); wp_category_checklist(); echo str_replace('post_category[]', $this->get_field_name('cats') .'[]', ob_get_clean()); ?> </ul> </div> </div>*/ ?> <?php }
/** * Import the main WXR file containing most of the import data */ public function import_xml() { // get the importer plugin if (!class_exists('WP_Import')) { include_once get_template_directory() . '/lib/vendor/importer/wordpress-importer.php'; } // disable all image sizes generation? if (empty($_POST['import_image_gen'])) { add_filter('intermediate_image_sizes_advanced', array($this, 'disable_image_sizes')); } $xml_file = $this->demo_data_path . 'sample.xml'; if (file_exists($xml_file)) { ob_start(); $this->wp_import = Bunyad::factory('admin/importer/wp-import'); $this->wp_import->fetch_attachments = !empty($_POST['import_media']) ? true : false; $this->wp_import->import($xml_file); $xml_result = ob_get_clean(); return $xml_result; } return false; }
public function form($instance) { $defaults = array('posts' => 5, 'cat' => '', 'offset' => 0, 'post_type' => ''); $instance = array_merge($defaults, (array) $instance); extract($instance); $render = Bunyad::factory('admin/option-renderer'); /* @var $render Bunyad_Admin_OptionRenderer */ ?> <input type="hidden" name="<?php echo $this->get_field_name('no_container'); ?> " value="1" /> <p> <label><?php _e('Number of Posts:', 'bunyad-admin'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('posts')); ?> " type="text" value="<?php echo esc_attr($posts); ?> " /> </p> <p class="description"><?php _e('Configures posts to show for each listing. Leave empty to use theme default number of posts.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Sort By:', 'bunyad-admin'); ?> </label> <select name="<?php echo esc_attr($this->get_field_name('sort_by')); ?> "> <option value=""><?php _e('Published Date', 'bunyad-admin'); ?> </option> <option value="modified"><?php _e('Modified Date', 'bunyad-admin'); ?> </option> <option value="random"><?php _e('Random', 'bunyad-admin'); ?> </option> </select> <select name="<?php echo esc_attr($this->get_field_name('sort_order')); ?> "> <option value="desc"><?php _e('Latest First - Descending', 'bunyad-admin'); ?> </option> <option value="asc"><?php _e('Oldest First - Ascending', 'bunyad-admin'); ?> </option> </select> </p> <p> <label><?php _e('Highlighted Post(s):', 'bunyad-admin'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('highlights')); ?> " type="text" value="1" /> </p> <p class="description"><?php _e('Highlighted posts are displayed larger at left. If you have more than 10 posts, we recommend using 2 highlighted posts.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Parent Category:', 'bunyad-admin'); ?> </label> <?php wp_dropdown_categories(array('show_option_all' => __('-- None - Use a Tag --', 'bunyad-admin'), 'hierarchical' => 1, 'hide_empty' => 0, 'order_by' => 'name', 'class' => 'widefat', 'name' => $this->get_field_name('cat'))); ?> </p> <p> <label><?php _e('Show Category Overlays?', 'bunyad-admin'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('cat_labels')); ?> "> <option value="0"><?php _e('No', 'bunyad-admin'); ?> </option> <option value="1"><?php _e('Yes', 'bunyad-admin'); ?> </option> </select> </p> <p> <label><?php _e('or Parent Tag: (optional) ', 'bunyad-admin'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('tax_tag'); ?> " value="" /> </p> <p class="description"><?php _e('You can enter a tag if you wish to show posts from a tag instead. Leave empty if you selected a category.', 'bunyad-admin'); ?> </p> <div class="taxonomydiv"> <!-- borrow wp taxonomydiv > categorychecklist css rules --> <label><?php _e('Sub Categories:', 'bunyad-admin'); ?> </label> <div class="tabs-panel"> <ul class="categorychecklist"> <?php ob_start(); wp_category_checklist(); echo str_replace('post_category[]', $this->get_field_name('sub_cats') . '[]', ob_get_clean()); ?> </ul> </div> </div> <p class="description"><?php _e('News Focus blocks displays sub-categories as tabs. Select any sub-category you wish to display.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('or Sub Tag: (optional) ', 'bunyad-admin'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('sub_tags'); ?> " class="widefat" /> </p> <p class="description"><?php _e('Separate tags with comma. e.g. cooking,sports', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Offset: (Advanced)', 'bunyad-admin'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('offset'); ?> " value="0" /> </p> <p class="description"><?php _e('By specifying an offset as 10 (for example), you can ignore 10 posts in the results.', 'bunyad-admin'); ?> </p> <p> <label><?php _e('Post Types: (Advanced)', 'bunyad-admin'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('post_type')); ?> " type="text" value="<?php echo esc_attr($post_type); ?> " /> </p> <p class="description"><?php _e('Only for advanced users! You can use a custom post type here - multiples supported when separated by comma. Leave empty to use the default format.', 'bunyad-admin'); ?> </p> <?php }
/** * Initialize admin related classes */ private function init_admin($options) { add_action('admin_enqueue_scripts', array($this, '_admin_assets')); Bunyad::factory('admin/options'); Bunyad::factory('admin/meta-boxes'); Bunyad::factory('admin/importer'); }
/** * Add/edit widget form */ public function form($instance) { $defaults = array('title' => '', 'posts' => 4, 'type' => '', 'cats' => '', 'post_type' => '', 'tags' => '', 'offset' => 0, 'sort_by' => '', 'sort_order' => ''); $instance = array_merge($defaults, (array) $instance); extract($instance); $render = Bunyad::factory('admin/option-renderer'); /* @var $render Bunyad_Admin_OptionRenderer */ ?> <p> <label><?php _e('Title:', 'bunyad-widgets'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('title')); ?> " type="text" value="<?php echo esc_attr($title); ?> " /> </p> <p> <label><?php _e('Number of Posts:', 'bunyad-widgets'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('posts')); ?> " type="text" value="<?php echo esc_attr($posts); ?> " /> </p> <p class="description"><?php _e('Configures posts to show for each listing. Leave empty to use theme default number of posts.', 'bunyad-widgets'); ?> </p> <p> <label><?php _e('Sort By:', 'bunyad-widgets'); ?> </label> <select name="<?php echo esc_attr($this->get_field_name('sort_by')); ?> "> <option value=""><?php _e('Published Date', 'bunyad-widgets'); ?> </option> <option value="modified" <?php selected($sort_by, 'modified'); ?> ><?php _e('Modified Date', 'bunyad-widgets'); ?> </option> <option value="random" <?php selected($sort_by, 'random'); ?> ><?php _e('Random', 'bunyad-widgets'); ?> </option> </select> <select name="<?php echo esc_attr($this->get_field_name('sort_order')); ?> "> <option value="desc" <?php selected($sort_order, 'desc'); ?> ><?php _e('Latest First - Descending', 'bunyad-widgets'); ?> </option> <option value="asc" <?php selected($sort_order, 'asc'); ?> ><?php _e('Oldest First - Ascending', 'bunyad-widgets'); ?> </option> </select> </p> <p> <label><?php _e('Block:', 'bunyad-widgets'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('block')); ?> "> <option value="blog-modern" <?php selected($block, 'blog-modern'); ?> ><?php _e('Listing: Modern Style', 'bunyad-widgets'); ?> </option> <option value="blog-grid-overlay" <?php selected($block, 'blog-grid-overlay'); ?> ><?php _e('Listing: Grid Overlay Style', 'bunyad-widgets'); ?> </option> <option value="blog-timeline" <?php selected($block, 'blog-timeline'); ?> ><?php _e('Listing: Timeline Style', 'bunyad-widgets'); ?> </option> </select> </p> <p class="description"><?php _e('Check docs and demo to choose the right style.', 'bunyad-widgets'); ?> </p> <div class="taxonomydiv"> <!-- borrow wp taxonomydiv > categorychecklist css rules --> <label><?php _e('Limit Categories:', 'bunyad-widgets'); ?> </label> <div class="tabs-panel"> <ul class="categorychecklist"> <?php ob_start(); wp_category_checklist(0, 0, $cats, false, null, false); echo str_replace('post_category[]', $this->get_field_name('cats') . '[]', ob_get_clean()); ?> </ul> </div> </div> <p class="description"><?php _e('By default, all categories will be used. Tick categories to limit to a specific category or categories.', 'bunyad-widgets'); ?> </p> <p class="tag"> <?php _e('or Limit with Tags: (optional)', 'bunyad-widgets'); ?> <input type="text" name="<?php echo $this->get_field_name('tags'); ?> " value="<?php echo esc_attr($tags); ?> " class="widefat" /> </p> <p class="description"><?php _e('Separate tags with comma. e.g. cooking,sports', 'bunyad-widgets'); ?> </p> <p> <label><?php _e('Offset: (Advanced)', 'bunyad-widgets'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('offset'); ?> " value="<?php echo esc_attr($offset); ?> " /> </p> <p class="description"><?php _e('By specifying an offset as 10 (for example), you can ignore 10 posts in the results.', 'bunyad-widgets'); ?> </p> <p> <label><?php _e('Post Types: (Advanced)', 'bunyad-widgets'); ?> </label> <input name="<?php echo esc_attr($this->get_field_name('post_type')); ?> " type="text" value="<?php echo esc_attr($post_type); ?> " /> </p> <p class="description"><?php _e('Only for advanced users! You can use a custom post type here - multiples supported when separated by comma. Leave empty to use the default format.', 'bunyad-widgets'); ?> </p> <?php }
/** * Render our options form * @param array $populate an array of default values to use for elements */ public function _render_form($populate = null, $data = array()) { $renderer = Bunyad::factory('admin/option-renderer'); /* @var $renderer Bunyad_Admin_OptionRenderer */ $renderer->template($this->options, locate_template('/admin/template-options.php'), array_merge(Bunyad::options()->get_all(), (array) $populate), array_merge($data, array('option_key' => $this->option_key))); }