function enlightenment_project_types_filter($args = null) { $args = array('container' => 'ul', 'container_class' => 'project-types-filter', 'term_tag' => 'li', 'term_class' => 'project-type', 'current_term_class' => 'current-project-type', 'sep' => '', 'echo' => true); $args = apply_filters('enlightenment_project_types_filter_args', $args); $terms = get_terms('jetpack-portfolio-type'); $output = ''; if (!empty($terms)) { $output .= enlightenment_open_tag($args['container'], $args['container_class']); if (is_tax('jetpack-portfolio-type')) { $output .= enlightenment_open_tag($args['term_tag'], $args['term_class']); $output .= sprintf('<a href="%1$s" rel="%2$s">%3$s</a>', get_post_type_archive_link('jetpack-portfolio'), 'jetpack-portfolio-type', __('All', 'enlightenment')); $output .= enlightenment_close_tag($args['term_tag']); } foreach ($terms as $term) { $class = $args['term_class']; $link = get_term_link($term, $term->taxonomy); $current_url = sprintf('%1$s%2$s%3$s', is_ssl() ? 'https://' : 'http://', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']); if ($link == $current_url) { $class .= ' ' . $args['current_term_class']; } $output .= enlightenment_open_tag($args['term_tag'], $class); $output .= sprintf('<a href="%1$s" rel="%2$s">%3$s</a>', $link, $term->taxonomy, $term->name); $output .= enlightenment_close_tag($args['term_tag']); } $output .= enlightenment_close_tag($args['container']); } $output = apply_filters('enlightenment_project_types_filter', $output); if (!$args['echo']) { return $output; } echo $output; }
function enlightenment_google_fonts_list($args, $echo = true) { $fonts = enlightenment_web_fonts(); $output = enlightenment_open_tag('fieldset', 'google-fonts'); foreach ($fonts as $font) { if (current_theme_supports('enlightenment-web-fonts', 'filter_by_subsets')) { $continue = false; foreach (current_theme_supports('enlightenment-web-fonts', 'subsets') as $subset) { if (!in_array($subset, $font['subsets'])) { $continue = true; } } if ($continue) { continue; } } $output .= enlightenment_checkbox(array('name' => 'web_fonts[' . $font['family'] . '][family]', 'value' => $font['family'], 'checked' => true, 'label' => $font['family']), false); $output .= enlightenment_hidden_input(array('name' => 'web_fonts[' . $font['family'] . '][category]', 'value' => $font['category']), false); $output .= enlightenment_hidden_input(array('name' => 'web_fonts[' . $font['family'] . '][variants]', 'value' => join(',', $font['variants'])), false); $output .= enlightenment_hidden_input(array('name' => 'web_fonts[' . $font['family'] . '][subsets]', 'value' => join(',', $font['subsets'])), false); $output .= '<br />'; } if ('' == current_theme_supports('enlightenment-web-fonts', 'google_api_key')) { $output .= sprintf('<h3>%s</h3>', __('Obtain a Google Developer API key to see all fonts in the Google Directory.', 'enlightenment')); } else { $output .= sprintf('<h3>%s</h3>', __('Please wait while the fonts list is being populated.', 'enlightenment')); } $output .= enlightenment_close_tag('fieldset'); $output = apply_filters('enlightenment_google_fonts_list', $output, $args); if (!$echo) { return $output; } echo $output; }
function enlightenment_page_design_form($post) { wp_nonce_field('enlightenment_page_design_form', 'enlightenment_page_design_form_nonce'); echo enlightenment_open_tag('p'); global $wp_post_types; enlightenment_select_box(array('name' => 'enlightenment_page_design', 'value' => '' != get_post_meta($post->ID, '_enlightenment_page_design', true) ? get_post_meta($post->ID, '_enlightenment_page_design', true) : enlightenment_theme_option('page_design'), 'options' => array('boxed' => 'Boxed', 'full-screen' => 'Full Screen'))); echo enlightenment_close_tag('p'); }
function enlightenment_entry_header_background() { if (is_singular() && current_theme_supports('enlightenment-post-thumbnail-header')) { echo enlightenment_open_tag('div', 'archive-header page-header'); echo enlightenment_open_tag('div', 'background-parallax') . enlightenment_close_tag('div'); echo enlightenment_close_tag('div'); } }
function enlightenment_post_thumbnail_wrap($html, $args = null) { $defaults = array('container' => 'figure', 'container_class' => 'entry-media'); $defaults = apply_filters('enlightenment_post_thumbnail_wrap_args', $defaults); $args = wp_parse_args($args, $defaults); if ('' != $html) { $output = enlightenment_open_tag($args['container'], $args['container_class']); $output .= $html . "\n"; $output .= enlightenment_close_tag($args['container']); return $output; } }
function enlightenment_nav_menu_title($args = null) { $defaults = array('container' => 'h3', 'container_class' => 'navbar-text screen-reader-text', 'text' => __('Menu', 'enlightenment'), 'echo' => true); $defaults = apply_filters('enlightenment_nav_menu_title_args', $defaults); $args = wp_parse_args($args, $defaults); $output = enlightenment_open_tag($args['container'], $args['container_class']); $output .= esc_attr($args['text']); $output .= enlightenment_close_tag($args['container']); $output = apply_filters('enlightenment_nav_menu_title', $output, $args); if (!$args['echo']) { return $output; } echo $output; }
function enlightenment_register_dynamic_sidebars() { $sidebars = (array) enlightenment_theme_option('sidebars'); foreach ($sidebars as $sidebar => $atts) { $before = ''; $after = ''; if (current_theme_supports('enlightenment-grid-loop') && isset($atts['grid'])) { $grid = enlightenment_get_grid($atts['grid']); $before = enlightenment_open_tag('div', $grid['entry_class']); $after = enlightenment_close_tag('div'); } register_sidebar(array('name' => $atts['name'], 'id' => $sidebar, 'before_widget' => $before . '<aside id="%1$s" class="widget %2$s">' . "\n", 'after_widget' => '</aside>' . $after . "\n", 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' . "\n")); } }
function enlightenment_page_builder_form($post) { if (!isset($_GET['post'])) { _e('Please save this post as Draft to use the Page Builder.', 'enlightenment'); return; } wp_nonce_field('enlightenment_page_builder_form', 'enlightenment_page_builder_form_nonce'); echo enlightenment_open_tag('p'); enlightenment_checkbox(array('name' => 'enlightenment_default_template_hooks', 'checked' => '' == get_post_meta($post->ID, '_enlightenment_page_builder', true), 'label' => sprintf(__('Use default template hooks for %1$s', 'enlightenment'), $post->post_type))); echo enlightenment_close_tag('p'); $template = enlightenment_get_template(get_post_type()); $template['hooks'] = array_keys(enlightenment_template_hooks()); do_action('enlightenment_before_page_builder'); echo enlightenment_open_tag('div', 'template-hooks'); foreach ($template['hooks'] as $hook) { $atts = enlightenment_get_template_hook($hook); $available_functions = $atts['functions']; $template_hooks = get_post_meta($post->ID, '_enlightenment_page_builder', true); if ('' == $template_hooks) { $template_hooks = enlightenment_theme_option('template_hooks'); } if (isset($template_hooks[enlightenment_current_template()][$hook])) { $hooked_functions = $template_hooks[enlightenment_current_template()][$hook]; } else { $hooked_functions = array(); global $wp_filter; if (isset($wp_filter[$hook]) && isset($wp_filter[$hook][10])) { foreach ($wp_filter[$hook][10] as $function) { $hooked_functions[] = $function['function']; } } } $available_functions = array_diff($available_functions, $hooked_functions); if (!empty($available_functions) || !empty($hooked_functions)) { echo '<h2>' . esc_attr($atts['name']) . '</h2>'; enlightenment_template_hook_actions(array('hook' => $hook, 'name' => 'enlightenment_page_builder[' . $hook . ']', 'class' => 'template-hooks')); } } echo enlightenment_close_tag(); do_action('enlightenment_after_page_builder'); }
function enlightenment_bootstrap_archive_location_args($args) { $args['container_class'] .= ' page-header'; $args['before'] = enlightenment_open_tag('div', 'container') . $args['before']; $args['after'] .= enlightenment_close_tag('div'); $args['title_class'] .= ' page-title'; $args['prefix_format'] = '%1$s'; $args['format'] = __('%2$s%3$s %1$s', 'enlightenment'); return $args; }
function enlightenment_credit_links($args = null) { $defaults = array('container' => 'div', 'container_class' => 'credits', 'wrap' => 'p', 'text' => sprintf(__('Built with <a href="%1$s" rel="designer">Enlightenment Framework</a> and <a href="%2$s" rel="generator">WordPress</a>', 'enlightenment'), esc_url('http://enlightenmentcore.com/'), esc_url('http://wordpress.org/')) . "\n", 'echo' => true); $defaults = apply_filters('enlightenment_credit_links_args', $defaults); $args = wp_parse_args($args, $defaults); $output = enlightenment_open_tag($args['container'], $args['container_class']); $output .= enlightenment_open_tag($args['wrap']); $output .= strip_tags($args['text'], '<a><abbr>'); $output .= enlightenment_close_tag($args['wrap']); $output .= enlightenment_close_tag($args['container']); $output = apply_filters('enlightenment_credit_links', $output, $args); if (!$args['echo']) { return $output; } echo $output; }
function enlightenment_font_options($args, $echo = true) { $defaults = array('class' => '', 'id' => '', 'description' => ''); $args = wp_parse_args($args, $defaults); if (!isset($args['name']) || empty($args['name'])) { _doing_it_wrong(__FUNCTION__, __('Please specify a name attribute for your font options.', 'enlightenment'), ''); return; } $fonts = enlightenment_available_fonts(); $font_family_args = array('name' => $args['name'] . '_font_family', 'class' => 'font_family' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_family' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_family' : '', 'options' => array()); foreach ($fonts as $name => $font) { // $font_family_args['options'][$name] = ( isset( $font['family'] ) ? str_replace( '"', '', $font['family'] ) : $name ) . ', ' . $font['category']; $font_family_args['options'][$name] = str_replace('"', '', $font['family']) . ', ' . $font['category']; } $font_size_args = array('name' => $args['name'] . '_font_size', 'class' => 'font_size' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_size' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_size' : '', 'options' => array()); $min_font_size = apply_filters('enlightenment_min_font_size', 10); $max_font_size = apply_filters('enlightenment_max_font_size', 48); $font_size_inc = apply_filters('enlightenment_font_size_inc', 1); $font_size_unit = apply_filters('enlightenment_font_size_unit', 'px'); for ($i = $min_font_size; $i <= $max_font_size; $i = $i + $font_size_inc) { $font_size_args['options'][$i] = intval($i) . ' ' . esc_attr($font_size_unit); } $font_style_args = array('name' => $args['name'] . '_font_style', 'class' => 'font_style' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_style' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_style' : '', 'options' => enlightenment_font_styles()); $color_picker_args = array('name' => $args['name'] . '_font_color', 'class' => 'font_color' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_color' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_color' : ''); $output = enlightenment_open_tag('fieldset', 'font-options'); $output .= enlightenment_select_box($font_family_args, false); $output .= enlightenment_select_box($font_size_args, false); $output .= enlightenment_select_box($font_style_args, false); $output .= enlightenment_color_picker($color_picker_args, false); $output .= enlightenment_close_tag('fieldset'); $output .= empty($args['description']) ? '' : '<p class="description">' . strip_tags($args['description'], '<a><abbr><img>') . '</p>'; $output = apply_filters('enlightenment_font_options', $output, $args); if (!$echo) { return $output; } echo $output; }
function enlightenment_comments_nav($args = null) { $defaults = array('container' => 'nav', 'container_id' => 'comments-nav', 'container_class' => 'comments-nav navigation', 'before' => '', 'after' => '', 'link_container' => 'div', 'prev_class' => 'previous', 'next_class' => 'next', 'pointer_tag' => 'span', 'prev_label' => __('Older Comments', 'enlightenment'), 'next_label' => __('Newer Comments', 'enlightenment'), 'pointer_class' => 'pointer', 'prev_pointer' => '←', 'next_pointer' => '→', 'paged' => true, 'type' => 'plain', 'custom_cb' => '', 'custom_cb_args' => array(), 'echo' => true); $defaults['all_pointer'] = $defaults['next_pointer']; $defaults = apply_filters('enlightenment_comments_nav_args', $defaults); $args = wp_parse_args($args, $defaults); if (is_callable($args['custom_cb'])) { call_user_func_array($args['custom_cb'], $args['custom_cb_args']); return; } if (get_comment_pages_count() > 1 && get_option('page_comments')) { $prev_label = enlightenment_open_tag($args['pointer_tag'], $args['pointer_class']) . $args['prev_pointer'] . enlightenment_close_tag($args['pointer_tag']) . $args['prev_label']; $next_label = $args['next_label'] . enlightenment_open_tag($args['pointer_tag'], $args['pointer_class']) . $args['next_pointer'] . enlightenment_close_tag($args['pointer_tag']); $output = enlightenment_open_tag($args['container'], $args['container_class'], $args['container_id'], 'role="navigation"'); $output .= $args['before']; if ($args['paged']) { $big = 999999999; // need an unlikely integer $paginate_comments_links_args = apply_filters('enlightenment_paginate_comments_links_args', array('prev_text' => $prev_label, 'next_text' => $next_label, 'type' => $args['type'], 'echo' => false)); $links = paginate_comments_links($paginate_comments_links_args); $output .= $links; } else { if (1 < intval(get_query_var('cpage'))) { $output .= enlightenment_open_tag($args['link_container'], $args['prev_class']); $output .= get_previous_comments_link($prev_label) . "\n"; $output .= enlightenment_close_tag($args['link_container']); } global $wp_query; if (get_comment_pages_count() > intval(get_query_var('cpage'))) { $output .= enlightenment_open_tag($args['link_container'], $args['next_class']); $output .= get_next_comments_link($next_label) . "\n"; $output .= enlightenment_close_tag($args['link_container']); } } $output .= $args['after']; $output .= enlightenment_close_tag($args['container']); $output = apply_filters('enlightenment_comments_nav', $output, $args); if (!$args['echo']) { return $output; } echo $output; } }
function enlightenment_comments_closed_notice($args = null) { $defaults = array('container' => 'aside', 'container_id' => 'respond', 'container_class' => 'comment-respond', 'notice_tag' => 'p', 'notice_class' => 'comments-closed', 'notice_text' => __('Comments are closed.', 'enlightenment'), 'only_on_entries_with_comments' => true, 'echo' => true); $defaults = apply_filters('enlightenment_comments_closed_notice_args', $defaults); $args = wp_parse_args($args, $defaults); if ($args['only_on_entries_with_comments'] && !have_comments()) { return false; } $output = enlightenment_open_tag($args['container'], $args['container_class'], $args['container_id']); $output .= enlightenment_open_tag($args['notice_tag'], $args['notice_class']); $output .= strip_tags($args['notice_text']); $output .= enlightenment_close_tag($args['notice_tag']); $output .= enlightenment_close_tag($args['container']); $output = apply_filters('enlightenment_comments_closed_notice', $output); if (!$args['echo']) { return $output; } echo $output; }
/** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form($instance) { $defaults = array('title' => '', 'tagline' => '', 'type' => 'list', 'grid' => 'onecol', 'query' => 'sticky_posts', 'post_type' => 'post', 'p' => null, 'page_id' => null, 'pages' => array(), 'images' => array(), 'author' => null, 'taxonomy' => 'category', 'term' => null, 'posts_per_page' => 5, 'leading_posts' => 1, 'link_to_archive' => false, 'link_to_archive_label' => __('See all posts →', 'enlightenment')); $instance = wp_parse_args($instance, $defaults); echo enlightenment_open_tag('p'); enlightenment_text_input(array('label' => __('Title:', 'enlightenment'), 'name' => $this->get_field_name('title'), 'class' => 'widefat', 'id' => $this->get_field_id('title'), 'value' => $instance['title'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p'); enlightenment_textarea(array('label' => __('Tagline:', 'enlightenment'), 'name' => $this->get_field_name('tagline'), 'class' => 'widefat', 'id' => $this->get_field_id('tagline'), 'value' => $instance['tagline'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'type'); $options = array('list' => __('List', 'enlightenment'), 'gallery' => __('Gallery', 'enlightenment'), 'slider' => __('Slider', 'enlightenment'), 'carousel' => __('Carousel', 'enlightenment')); enlightenment_select_box(array('label' => __('Type:', 'enlightenment'), 'name' => $this->get_field_name('type'), 'class' => 'widefat', 'id' => $this->get_field_id('type'), 'options' => $options, 'value' => $instance['type'])); echo enlightenment_close_tag('p'); if (current_theme_supports('enlightenment-grid-loop')) { echo enlightenment_open_tag('p', 'grid'); $options = array(); foreach (enlightenment_grid_columns() as $grid => $atts) { $options[$grid] = $atts['name']; } enlightenment_select_box(array('label' => __('Grid:', 'enlightenment'), 'name' => $this->get_field_name('grid'), 'class' => 'widefat', 'id' => $this->get_field_id('grid'), 'options' => $options, 'value' => $instance['grid'])); echo enlightenment_close_tag('p'); } echo enlightenment_open_tag('p', 'query'); $queries = enlightenment_custom_queries(); $options = array(); foreach ($queries as $query => $atts) { $options[$query] = $atts['name']; } enlightenment_select_box(array('label' => __('Query:', 'enlightenment'), 'name' => $this->get_field_name('query'), 'class' => 'widefat', 'id' => $this->get_field_id('query'), 'options' => $options, 'value' => $instance['query'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'post-types' . ('post_type_archive' == $instance['query'] || 'post_type' == $instance['query'] ? ' show' : '')); $options = array(); $post_types = enlightenment_custom_post_types(); foreach ($post_types as $post_type => $atts) { $options[$post_type] = $atts['name']; } enlightenment_select_box(array('label' => __('Post Type:', 'enlightenment'), 'name' => $this->get_field_name('post_type'), 'class' => 'widefat', 'id' => $this->get_field_id('post_type'), 'options' => $options, 'value' => $instance['post_type'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'post-type' . ('post_type' == $instance['query'] ? ' show' : '')); $posts = get_posts(array('post_type' => esc_attr($instance['post_type']), 'posts_per_page' => -1)); $options = array(); foreach ($posts as $post) { $options[$post->ID] = get_the_title($post->ID); } enlightenment_select_box(array('label' => __('Post:', 'enlightenment'), 'name' => $this->get_field_name('p'), 'class' => 'widefat', 'id' => $this->get_field_id('p'), 'options' => $options, 'value' => $instance['p'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'page' . ('page' == $instance['query'] ? ' show' : '')); $posts = get_posts(array('posts_per_page' => -1, 'post_type' => 'page')); $options = array(); foreach ($posts as $post) { $options[$post->ID] = get_the_title($post->ID); } enlightenment_select_box(array('label' => __('Page:', 'enlightenment'), 'name' => $this->get_field_name('page_id'), 'class' => 'widefat', 'id' => $this->get_field_id('page_id'), 'options' => $options, 'value' => $instance['page_id'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('div', 'pages' . ('pages' == $instance['query'] ? ' show' : '')); $posts = get_posts(array('posts_per_page' => -1, 'post_type' => 'page')); $boxes = array(); $i = 0; foreach ($posts as $post) { $boxes[$i] = array(); $boxes[$i]['label'] = get_the_title($post->ID); $boxes[$i]['name'] = $this->get_field_name('pages') . '[' . $post->ID . ']'; $boxes[$i]['checked'] = in_array($post->ID, $instance['pages']); $i++; } echo '<label>' . __('Select Pages:', 'enlightenment') . '</label><br />'; echo enlightenment_open_tag('div', 'pages-inner'); enlightenment_checkboxes(array('boxes' => $boxes, 'value' => $instance['p'])); echo enlightenment_close_tag('div'); echo enlightenment_close_tag('div'); echo enlightenment_open_tag('p', 'image-gallery' . ('gallery' == $instance['query'] ? ' show' : '')); enlightenment_upload_media(array('name' => $this->get_field_name('images'), 'upload_button_text' => __('Choose Images', 'enlightenment'), 'uploader_title' => __('Insert Images', 'enlightenment'), 'uploader_button_text' => __('Select', 'enlightenment'), 'remove_button_text' => '', 'mime_type' => 'image', 'multiple' => true, 'thumbnail' => null, 'value' => implode(',', $instance['images']))); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'author' . ('author' == $instance['query'] ? ' show' : '')); $authors = get_users(array('who' => 'authors')); $options = array(); foreach ($authors as $author) { $options[$author->ID] = $author->display_name; } enlightenment_select_box(array('label' => __('Select Author:', 'enlightenment'), 'name' => $this->get_field_name('author'), 'class' => 'widefat', 'id' => $this->get_field_id('author'), 'options' => $options, 'value' => $instance['author'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'taxonomy' . ('taxonomy' == $instance['query'] ? ' show' : '')); $taxonomies = get_taxonomies(array('public' => true), 'objects'); $options = array(); foreach ($taxonomies as $name => $taxonomy) { if ('post_format' == $name) { $taxonomy->labels->singular_name = __('Post Format', 'enlightenment'); } $options[$name] = $taxonomy->labels->singular_name; } enlightenment_select_box(array('label' => __('Taxonomy:', 'enlightenment'), 'name' => $this->get_field_name('taxonomy'), 'class' => 'widefat', 'id' => $this->get_field_id('taxonomy'), 'options' => $options, 'value' => $instance['taxonomy'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'term' . ('taxonomy' == $instance['query'] ? ' show' : '')); $terms = get_terms($instance['taxonomy']); $options = array(); foreach ($terms as $term) { $options[$term->slug] = $term->name; } enlightenment_select_box(array('label' => __('Term:', 'enlightenment'), 'name' => $this->get_field_name('term'), 'class' => 'widefat', 'id' => $this->get_field_id('term'), 'options' => $options, 'value' => $instance['term'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'posts-count' . ('post_type_archive' == $instance['query'] || 'author' == $instance['query'] || 'taxonomy' == $instance['query'] ? ' show' : '')); enlightenment_text_input(array('label' => __('Total number of entries:', 'enlightenment'), 'name' => $this->get_field_name('posts_per_page'), 'id' => $this->get_field_id('posts_per_page'), 'value' => $instance['posts_per_page'], 'size' => 3)); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'lead-posts' . ('slider' != $instance['type'] && 'carousel' != $instance['type'] && ('sticky_posts' == $instance['query'] || 'post_type_archive' == $instance['query'] || 'pages' == $instance['query'] || 'gallery' == $instance['query'] || 'author' == $instance['query'] || 'taxonomy' == $instance['query']) ? ' show' : '')); enlightenment_text_input(array('label' => __('Number of leading entries:', 'enlightenment'), 'name' => $this->get_field_name('leading_posts'), 'id' => $this->get_field_id('leading_posts'), 'value' => $instance['leading_posts'], 'size' => 3)); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'archive-link' . ('post_type_archive' == $instance['query'] || 'author' == $instance['query'] || 'taxonomy' == $instance['query'] ? ' show' : '')); enlightenment_checkbox(array('label' => __('Show Link to Archive', 'enlightenment'), 'name' => $this->get_field_name('link_to_archive'), 'id' => $this->get_field_id('link_to_archive'), 'checked' => $instance['link_to_archive'])); echo enlightenment_close_tag('p'); echo enlightenment_open_tag('p', 'archive-link-label' . (('post_type_archive' == $instance['query'] || 'author' == $instance['query'] || 'taxonomy' == $instance['query']) && $instance['link_to_archive'] ? ' show' : '')); enlightenment_text_input(array('label' => __('Link to Archive Label:', 'enlightenment'), 'name' => $this->get_field_name('link_to_archive_label'), 'class' => 'widefat', 'id' => $this->get_field_id('link_to_archive_label'), 'value' => $instance['link_to_archive_label'])); echo enlightenment_close_tag('p'); ?> <script> jQuery(document).ready(function($) { $('.type select').change(function() { var container = $(this).closest('.widget-content'); var val = $(this).val(); if(val == 'slider' || val == 'carousel') $('.lead-posts', container).hide(); else { var query = $('.query select', container).val(); if(query == 'post_type' || query == 'page') $('.lead-posts', container).hide(); else $('.lead-posts', container).show(); } }); $('.query select').change(function() { var container = $(this).closest('.widget-content'); var val = $(this).val(); var type = $('.type select', container).val(); if(val == 'sticky_posts') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).hide(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).hide(); $('.archive-link-label', container).hide(); } else if(val == 'post_type_archive') { $('.post-types', container).show(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).show(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).show(); if($('.archive-link', container).is(':checked')) $('.archive-link-label', container).show(); } else if(val == 'post_type') { $('.post-types', container).show(); $('.post-type', container).show(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).hide(); $('.lead-posts', container).hide(); $('.archive-link', container).hide(); $('.archive-link-label', container).hide(); } else if(val == 'page') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).show(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).hide(); $('.lead-posts', container).hide(); $('.archive-link', container).hide(); $('.archive-link-label', container).hide(); } else if(val == 'pages') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).show(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).hide(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).hide(); $('.archive-link-label', container).hide(); } else if(val == 'gallery') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).show(); $('.author', container).hide(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).hide(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).hide(); $('.archive-link-label', container).hide(); } else if(val == 'author') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).show(); $('.taxonomy', container).hide(); $('.term', container).hide(); $('.posts-count', container).show(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).show(); if($('.archive-link', container).is(':checked')) $('.archive-link-label', container).show(); } else if(val == 'taxonomy') { $('.post-types', container).hide(); $('.post-type', container).hide(); $('.page', container).hide(); $('.pages', container).hide(); $('.image-gallery', container).hide(); $('.author', container).hide(); $('.taxonomy', container).show(); $('.term', container).show(); $('.posts-count', container).show(); if(type != 'slider' && type != 'carousel') $('.lead-posts', container).show(); $('.archive-link', container).show(); if($('.archive-link', container).is(':checked')) $('.archive-link-label', container).show(); } }); $('.post-types select').change(function() { var container = $(this).closest('.widget-content'); var data = { action: 'enlightenment_ajax_get_post_types', post_type: $('.post-types select', container).val(), name: '<?php echo $this->get_field_name('p'); ?> ', id: '<?php echo $this->get_field_id('p'); ?> ', value: '<?php echo $instance['p']; ?> ', } $.post(ajaxurl, data, function(r) { var html = document.createElement( 'div' ); $(html).html(r); $('.post-type select', container).html($('select', $(html)).html()); }); }); $('.taxonomy select').change(function() { var container = $(this).closest('.widget-content'); var data = { action: 'enlightenment_ajax_get_terms', taxonomy: $('.taxonomy select', container).val(), name: '<?php echo $this->get_field_name('term'); ?> ', id: '<?php echo $this->get_field_id('term'); ?> ', value: '<?php echo $instance['term']; ?> ', } $.post(ajaxurl, data, function(r) { var html = document.createElement( 'div' ); $(html).html(r); $('.term', container).remove(); $('.taxonomy', container).after($(html).html()); }); }); $('.archive-link input').each(function() { var container = $(this).closest('.widget-content'); var query = $('.query select', container).val(); if( query == 'post_type_archive' || query == 'author' || query == 'taxonomy' ) { if($(this).is(':checked')) $('.archive-link-label', container).show(); else $('.archive-link-label', container).hide(); } }); $('.archive-link input').change(function() { var container = $(this).closest('.widget-content'); if($(this).is(':checked')) $('.archive-link-label', container).show(); else $('.archive-link-label', container).hide(); }); }); </script> <?php }
function enlightenment_autor_hcard($args = null) { $defaults = array('container' => 'aside', 'container_class' => 'entry-author', 'title_container' => 'h4', 'avatar_size' => 96, 'title_class' => 'author vcard', 'title_prefix' => __('Written by', 'enlightenment'), 'author_name_container' => 'span', 'author_name_class' => 'fn', 'bio_container' => 'div', 'bio_class' => 'author-bio', 'echo' => true); $defaults = apply_filters('enlightenment_autor_hcard_args', $defaults); $args = wp_parse_args($args, $defaults); global $authordata; if (!is_object($authordata)) { return false; } $output = enlightenment_open_tag($args['container'], $args['container_class']); if ($args['avatar_size']) { $avatar = get_avatar(get_the_author_meta('user_email'), $args['avatar_size']); $output .= apply_filters('enlightenment_autor_hcard_avatar', $avatar, $args); } $output .= enlightenment_open_tag($args['title_container'], $args['title_class']); if ('' != $args['title_prefix']) { $output .= esc_attr($args['title_prefix']) . ' '; } $output .= enlightenment_open_tag($args['author_name_container'], $args['author_name_class']); $output .= sprintf('<a href="%1$s" title="%2$s" rel="author">%3$s</a>', esc_url(get_author_posts_url($authordata->ID, $authordata->user_nicename)), esc_attr(sprintf(__('Posts by %s', 'enlightenment'), get_the_author())), get_the_author()); $output .= enlightenment_close_tag($args['author_name_container']); $output .= enlightenment_close_tag($args['title_container']); $description = enlightenment_open_tag($args['bio_container'], $args['bio_class']); $description .= apply_filters('the_author_description', get_the_author_meta('description'), false); $description .= enlightenment_close_tag($args['bio_container']); $output .= apply_filters('enlightenment_author_bio', $description, $args); $output .= enlightenment_clearfix(array('echo' => false)); $output .= enlightenment_close_tag($args['container']); $output = apply_filters('enlightenment_autor_hcard', $output, $args); if (!$args['echo']) { return $output; } echo $output; }
function enlightenment_sidebar_heading($args = null) { $defaults = array('container' => 'header', 'container_class' => 'sidebar-heading', 'container_id' => '', 'container_extra_atts' => '', 'sidebar_title_tag' => 'h2', 'sidebar_title_class' => 'sidebar-title', 'sidebar_title_id' => '', 'sidebar_title_extra_atts' => '', 'sidebar_description_tag' => 'div', 'sidebar_description_class' => 'sidebar-description', 'sidebar_description_id' => '', 'sidebar_description_extra_atts' => '', 'echo' => true); $defaults = apply_filters('enlightenment_sidebar_header_args', $defaults); $args = wp_parse_args($args, $defaults); $locations = enlightenment_sidebar_locations(); $template = enlightenment_current_sidebars_template(); $location = enlightenment_current_sidebar_name(); $sidebars = enlightenment_registered_sidebars(); $sidebar = $sidebars[$locations[$template][$location]['sidebar']]; $sidebar_title = apply_filters('enlightenment_sidebar_title', $sidebar['name']); $sidebar_description = apply_filters('enlightenment_sidebar_description', $sidebar['description']); if (!$sidebar['display_title'] && !$sidebar['display_description']) { return; } $output = enlightenment_open_tag($args['container'], $args['container_class'], $args['container_id'], $args['container_extra_atts']); if ($sidebar['display_title']) { $output .= enlightenment_open_tag($args['sidebar_title_tag'], $args['sidebar_title_class'], $args['sidebar_title_id'], $args['sidebar_title_extra_atts']); $output .= $sidebar_title; $output .= enlightenment_close_tag($args['sidebar_title_tag']); } if ($sidebar['display_description'] && !empty($sidebar_description)) { $output .= enlightenment_open_tag($args['sidebar_description_tag'], $args['sidebar_description_class'], $args['sidebar_description_id'], $args['sidebar_description_extra_atts']); $output .= $sidebar_description . "\n"; $output .= enlightenment_close_tag($args['sidebar_description_tag']); } $output .= enlightenment_close_tag($args['container']); $output = apply_filters('enlightenment_sidebar_header', $output, $args); if (!$args['echo']) { return $output; } echo $output; }
function enlightenment_unlimited_sidebars_form($post) { if (!isset($_GET['post'])) { _e('Please save this post as Draft to use Unlimited Sidebars.', 'enlightenment'); return; } wp_nonce_field('enlightenment_unlimited_sidebars_form', 'enlightenment_unlimited_sidebars_form_nonce'); echo '<p>'; enlightenment_checkbox(array('name' => 'enlightenment_default_sidebar_locations', 'checked' => '' == get_post_meta($post->ID, '_enlightenment_sidebar_locations', true), 'label' => sprintf(__('Use default sidebar locations for %1$s', 'enlightenment'), $post->post_type))); echo '</p>'; echo enlightenment_open_tag('div', 'sidebar-locations'); $sidebar_locations = enlightenment_sidebar_locations(); $post_type = get_post_type($_GET['post']); $post_meta = get_post_meta($post->ID, '_enlightenment_sidebar_locations', true); $locations = $sidebar_locations[$post_type]; foreach ($locations as $location => $sidebar) { if (isset($post_meta[$location])) { $sidebar['sidebar'] = $post_meta[$location]; } $args = array('name' => 'enlightenment_sidebar_locations[' . $location . ']', 'value' => $sidebar['sidebar'], 'description' => ''); echo enlightenment_open_tag('div', 'sidebar-location'); echo enlightenment_open_tag('h3'); echo $sidebar['name']; echo enlightenment_close_tag('h3'); enlightenment_edit_sidebar_location($args); echo enlightenment_close_tag(); } echo enlightenment_close_tag(); }
function enlightenment_custom_header_archive_location($output, $args) { $title_tag = enlightenment_open_tag($args['title_tag'], $args['title_class']); $overlay = enlightenment_open_tag('div', 'slide-overlay') . enlightenment_close_tag('div'); $output = str_replace($title_tag, $overlay . $title_tag, $output); return $output; }
function enlightenment_slide_overlay() { echo enlightenment_open_tag('div', 'slide-overlay'); echo enlightenment_close_tag(); }
function enlightenment_template_hook_actions($args, $echo = true) { global $wp_filter, $pagenow; $hook = enlightenment_get_template_hook($args['hook']); $available_functions = apply_filters($args['hook'] . '_available_functions', $hook['functions']); $template = enlightenment_get_template(enlightenment_current_template()); if (current_theme_supports('enlightenment-page-builder') && 'post_type' == $template['type'] && ('post.php' == $pagenow || 'post-new.php' == $pagenow) && isset($_GET['action']) && 'edit' == $_GET['action']) { global $post; $template_hooks = array(); $template_hooks[enlightenment_current_template()] = get_post_meta($post->ID, '_enlightenment_page_builder', true); if ('' == $template_hooks) { $template_hooks = enlightenment_theme_option('template_hooks'); } } else { $template_hooks = enlightenment_theme_option('template_hooks'); } if (isset($template_hooks[enlightenment_current_template()][$args['hook']])) { $hooked_functions = $template_hooks[enlightenment_current_template()][$args['hook']]; } else { $hooked_functions = array(); if (isset($wp_filter[$args['hook']]) && isset($wp_filter[$args['hook']][10])) { foreach ($wp_filter[$args['hook']][10] as $function) { $hooked_functions[] = $function['function']; } } } $available_functions = array_diff($available_functions, $hooked_functions); $output = ''; $output .= '<div class="widget-liquid-left">'; $output .= '<div id="widgets-left">'; $output .= '<div id="available-widgets" class="widgets-holder-wrap available-functions-' . esc_attr($args['hook']) . '">'; $output .= '<div class="sidebar-name">'; $output .= '<h3>Available Functions <span id="removing-widget">Deactivate <span></span></span></h3>'; $output .= '</div>'; $output .= '<div class="widget-holder">'; $output .= '<div id="widget-list" class="widget-list">'; foreach ($available_functions as $function) { $output .= enlightenment_open_tag('div', 'widget', '', 'data-function="' . $function . '"'); // ui-draggable' ); $output .= '<div class="widget-top">'; $output .= '<div class="widget-title">'; $output .= '<h4>' . enlightenment_template_function_name($function) . '</h4>'; $output .= enlightenment_close_tag('div'); $output .= enlightenment_close_tag('div'); $output .= enlightenment_close_tag('div'); } $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '<div class="widget-liquid-right">'; $output .= '<div id="widgets-right">'; $output .= '<div class="widgets-holder-wrap">'; $output .= '<div id="sidebar-' . esc_attr($args['hook']) . '" class="widgets-sortables hooked-functions-' . esc_attr($args['hook']) . '">'; $output .= '<div class="sidebar-name">'; $output .= '<h3>Hooked Functions <span class="spinner"></span></h3>'; $output .= '</div>'; foreach ($hooked_functions as $function) { $output .= enlightenment_open_tag('div', 'widget', '', 'data-function="' . $function . '"'); $output .= '<div class="widget-top">'; $output .= '<div class="widget-title">'; $output .= '<h4>' . enlightenment_template_function_name($function) . '</h4>'; $output .= enlightenment_close_tag('div'); $output .= enlightenment_close_tag('div'); $output .= enlightenment_close_tag('div'); } $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= enlightenment_hidden_input(array('name' => $args['name'], 'value' => join(',', $hooked_functions)), false); ob_start(); ?> <script> jQuery(document).ready(function($) { var submitted = false; $('form').submit(function() { submitted = true; }); $('.available-functions-<?php echo esc_attr($args['hook']); ?> .widget-list').sortable({ connectWith: '.hooked-functions-<?php echo esc_attr($args['hook']); ?> ', items: '.widget', placeholder: "widget-placeholder", revert: 'invalid', }); $('.hooked-functions-<?php echo esc_attr($args['hook']); ?> ').sortable({ connectWith: '.available-functions-<?php echo esc_attr($args['hook']); ?> .widget-list', items: '.widget', placeholder: "widget-placeholder", revert: 'invalid', activate: function(event, ui) { $(this).parent().addClass('widget-hover'); }, deactivate: function(event, ui) { $(this).parent().removeClass('widget-hover'); }, change: function(event, ui) { window.onbeforeunload = function(e) { if( ! submitted ) { var message = '<?php _e('The changes you made will be lost if you navigate away from this page.', 'enlightenment'); ?> '; e = e || window.event; // For IE and Firefox if(e) { e.returnValue = message; } // For Safari return message; } }; }, stop: function(event, ui) { if( $(ui.item).parent().hasClass('widgets-sortables') ) { var functions = []; $('.widget', $(ui.item).parent()).each(function() { functions.push($(this).data('function')); }); $(ui.item).closest('.widget-liquid-right').next('input').val(functions.join()); } }, receive: function(event, ui) { var functions = []; $('.widget', $(ui.item).parent()).each(function() { functions.push($(this).data('function')); }); $(ui.item).closest('.widget-liquid-right').next('input').val(functions.join()); }, remove: function(event, ui) { var functions = []; $('.widget', $(ui.item).closest('.widget-liquid-left').next('.widget-liquid-right')).each(function() { functions.push($(this).data('function')); }); $(ui.item).closest('.widget-liquid-left').next('.widget-liquid-right').next('input').val(functions.join()); }, }); }); </script> <?php $output .= ob_get_clean(); $output .= '<br style="clear:both">'; if (!$echo) { return $output; } echo $output; }
function enlightenment_close_container() { echo enlightenment_close_tag(); }
function enlightenment_entry_audio($args = null) { $defaults = array('container' => 'div', 'container_class' => 'entry-attachment', 'echo' => true); $defaults = apply_filters('enlightenment_entry_audio_args', $defaults); $args = wp_parse_args($args, $defaults); global $more; $more = true; $content = get_the_content(); $more = false; $output = enlightenment_open_tag($args['container'], $args['container_class']); if (preg_match('/\\[(\\[?)(audio)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)/s', $content, $matches)) { $output .= do_shortcode($matches[0]); } else { $output .= enlightenment_get_first_embed(); } $output .= enlightenment_close_tag($args['container']); $output = apply_filters('enlightenment_entry_audio', $output, $args); if (!$args['echo']) { return $output; } echo $output; }