Exemple #1
0
/**
 * Numeric slider / Range
 *
 * @since    1.0
 * @version  1.2.2
 */
function wma_field_slider($field, $page_template = null)
{
    // Helper variables
    // Definition
    $field = wp_parse_args((array) $field, array('type' => 'slider', 'id' => 'id', 'label' => '', 'description' => '', 'class' => '', 'default' => '', 'min' => 0, 'max' => 10, 'step' => 1, 'zero' => true, 'conditional' => ''));
    // Value processing
    $value = wma_meta_option($field['id']);
    if ($value || $field['zero'] && 0 === intval($value)) {
        $value = esc_attr(intval($value));
    } else {
        $value = esc_attr(intval($field['default']));
    }
    // Field ID setup
    $field['id'] = WM_METABOX_FIELD_PREFIX . $field['id'];
    // Output
    $output = "\r\n\t" . '<tr class="option range-wrap option-' . esc_attr(trim(sanitize_html_class($field['id']) . ' ' . $field['class'])) . '" data-option="' . esc_attr($field['id']) . '"><th>';
    // Label
    $output .= "\r\n\t\t" . '<label for="' . esc_attr($field['id']) . '">' . trim(strip_tags($field['label'], WM_METABOX_LABEL_HTML)) . '</label>';
    $output .= "\r\n\t" . '</th><td>';
    // Input field
    $output .= "\r\n\t\t" . '<input type="number" name="' . esc_attr($field['id']) . '" id="' . esc_attr($field['id']) . '" value="' . esc_attr($value) . '" size="5" maxlength="5" />';
    $output .= "\r\n\t\t" . '<span class="fieldtype-range"><span id="' . esc_attr($field['id']) . '-slider" data-min="' . esc_attr(intval($field['min'])) . '" data-max="' . esc_attr(intval($field['max'])) . '" data-step="' . esc_attr(intval($field['step'])) . '" data-value="' . esc_attr($value) . '"></span></span>';
    // Description
    if (trim($field['description'])) {
        $output .= "\r\n\t\t" . '<p class="description">' . trim($field['description']) . '</p>';
    }
    // Reset default value button
    if (trim($field['default'])) {
        $output .= "\r\n\t\t" . '<a data-option="' . esc_attr($field['id']) . '" class="button-default-value default-slider" title="' . esc_attr__('Use a default value', 'webman-amplifier') . '"><span>' . esc_attr($field['default']) . '</span></a>';
    }
    echo $output;
    // Conditional display
    do_action('wmhook_metabox_' . 'conditional', $field, $field['id']);
    echo "\r\n\t" . '</td></tr>';
}
Exemple #2
0
 function wma_field_checkbox($field, $page_template = null)
 {
     //Field definition array
     $field = wp_parse_args((array) $field, array('type' => 'checkbox', 'id' => 'id', 'label' => '', 'description' => '', 'value' => true, 'class' => '', 'attributes' => '', 'repeater' => false, 'conditional' => ''));
     //Value processing
     $field['value'] = esc_attr($field['value']);
     if ($field['repeater'] && is_array($field['repeater']) && isset($field['repeater']['value'])) {
         $value = $field['repeater']['value'];
     } else {
         $value = wma_meta_option($field['id']);
     }
     $value = esc_attr($value);
     //Field ID setup
     if ($field['repeater'] && is_array($field['repeater']) && isset($field['repeater']['id'])) {
         $field['id'] = $field['repeater']['id'];
     } else {
         $field['id'] = WM_METABOX_FIELD_PREFIX . $field['id'];
     }
     //Output
     $output = "\r\n\t" . '<tr class="option checkbox-wrap option-' . trim(sanitize_html_class($field['id']) . ' ' . $field['class']) . '" data-option="' . $field['id'] . '"><th colspan="2">';
     //Input field
     $output .= "\r\n\t\t" . '<input type="' . $field['type'] . '" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . $field['value'] . '" class="fieldtype-checkbox" ' . trim(checked($value, $field['value'], false) . ' ' . $field['attributes'] . ' /') . '>';
     //Label
     $output .= ' <label for="' . $field['id'] . '">' . trim(strip_tags($field['label'], WM_METABOX_LABEL_HTML)) . '</label>';
     //Description
     if (trim($field['description'])) {
         $output .= "\r\n\t\t" . '<p class="description">' . trim($field['description']) . '</p>';
     }
     echo $output;
     //Conditional display
     do_action('wmhook_metabox_' . 'conditional', $field, $field['id']);
     echo "\r\n\t" . '</th></tr>';
 }
Exemple #3
0
 function wma_field_repeater($field, $page_template = null)
 {
     //Field definition array
     $field = wp_parse_args((array) $field, array('type' => 'repeater', 'id' => 'id', 'label' => '', 'description' => '', 'fields' => '', 'default' => array(''), 'class' => '', 'button-text' => '+', 'conditional' => ''));
     //Value processing
     $values = (array) wma_meta_option($field['id']);
     $values = array_filter($values);
     if (!is_array($values) || empty($values)) {
         $values = $field['default'];
     }
     //Field ID setup
     $field['id'] = WM_METABOX_FIELD_PREFIX . $field['id'];
     //Output
     $output = "\r\n\t" . '<tr class="option repeater-wrap option-' . trim($field['id'] . ' ' . $field['class']) . '" data-option="' . $field['id'] . '"><th>';
     //Label
     $output .= "\r\n\t\t" . '<label for="' . $field['id'] . '">' . trim(strip_tags($field['label'], WM_METABOX_LABEL_HTML)) . '</label>';
     $output .= "\r\n\t" . '</th><td>';
     //Description
     if (trim($field['description'])) {
         $output .= "\r\n\t\t" . '<p class="description">' . trim($field['description']) . '</p>';
     }
     $output .= "\r\n\t\t" . '<div class="repeater-cells">';
     echo $output;
     //Repeater cells
     if (is_array($values) && !empty($values)) {
         $i = 0;
         foreach ($values as $value) {
             if (is_array($field['fields']) && !empty($field['fields'])) {
                 $output = "\r\n\t\t" . '<table class="repeater-cell">';
                 //Controls row
                 $output .= "\r\n\t\t\t" . '<thead class="repeater-cell-controls"><tr><th colspan="2">';
                 $output .= "\r\n\t\t\t\t" . '<a class="button button-move-cell" data-id="' . $field['id'] . '" title="' . __('Move the item', 'webman-amplifier') . '">&equiv;</a>';
                 $output .= "\r\n\t\t\t\t" . '<a class="button button-remove-cell" data-id="' . $field['id'] . '" title="' . __('Remove this item', 'webman-amplifier') . '">-</a>';
                 $output .= "\r\n\t\t\t" . '</th></tr></thead>';
                 $output .= "\r\n\t\t\t" . '<tbody>';
                 echo $output;
                 //Fields row
                 foreach ($field['fields'] as $cell_field) {
                     if (isset($cell_field['type']) && in_array($cell_field['type'], array('checkbox', 'color', 'radio', 'text', 'textarea', 'select'))) {
                         //Passing special repeater values into field generator/renderer
                         $cell_value = isset($value[$cell_field['id']]) ? $value[$cell_field['id']] : null;
                         $cell_field['repeater'] = array('id' => $field['id'] . '[' . $i . ']' . '[' . $cell_field['id'] . ']', 'value' => $cell_value);
                         //Display form fields using action hook (echo the function return)
                         do_action('wmhook_metabox_' . 'render_' . $cell_field['type'], $cell_field, '');
                     }
                 }
                 echo "\r\n\t\t" . '<!-- /repeater-cell --></tbody></table>';
             }
             $i++;
         }
     }
     //Add repeater cell button
     echo "\r\n\t\t" . '</div> <!-- /repeater-cells -->';
     echo "\r\n\t\t" . '<a href="#" class="button button-add-cell" data-id="' . $field['id'] . '">' . $field['button-text'] . '</a>';
     //Conditional display
     do_action('wmhook_metabox_' . 'conditional', $field, $field['id']);
     echo "\r\n\t" . '</td></tr>';
 }
/**
 * Shortcode markup: section (row)
 */
function wm_section_markup($output, $atts)
{
    //Helper variables
    $prepend = $append = $sections_layout = '';
    $video_formats = array('mp4', 'm4v', 'webm', 'ogv', 'wmv', 'flv');
    if ('sections' == wma_meta_option('sidebar')) {
        $sections_layout = true;
    }
    //video_url
    $atts['video_url'] = array_filter(explode(',', str_replace(' ', '', $atts['video_url'])));
    if (!empty($atts['video_url'])) {
        if (1 === count($atts['video_url'])) {
            $atts['video_url'] = array('src="' . esc_url($atts['video_url'][0]) . '"');
        } else {
            foreach ($atts['video_url'] as $key => $url) {
                foreach ($video_formats as $format) {
                    if (stripos($url, '.' . $format)) {
                        $atts['video_url'][$key] = $format . '="' . esc_url($url) . '"';
                    }
                }
            }
        }
        $atts['video_url'] = do_shortcode(apply_filters('wm_section_markup_video_url', '<div class="wm-row-video">[wm_video ' . implode(' ', $atts['video_url']) . ' loop="on" autoplay="on" /]<div class="overlay"></div></div>'), $atts);
    } else {
        $atts['video_url'] = '';
    }
    //Modify class
    if ($atts['font_color']) {
        $atts['class'] .= ' custom-font-color';
    }
    //Section markup
    if ($sections_layout) {
        //Modify class
        if ($atts['padding']) {
            $atts['class'] .= ' no-wrap-inner-padding';
        }
        //Section HTML wrapper
        $prepend .= "\r\n\r\n" . '<div class="wm-section {class}"{attributes}>' . "\r\n\r\n" . $atts['video_url'];
        $append .= "\r\n\r\n" . '</div> <!-- /wm-section -->' . "\r\n\r\n";
        //Apply default theme section inner wrappers
        if (!$atts['disable_container']) {
            $prepend .= apply_filters('wmhook_section_inner_wrappers', '');
            $append = apply_filters('wmhook_section_inner_wrappers_close', '') . $append;
        }
    }
    //Output
    $replacements = array('{attributes}' => implode(' ', $atts['attributes']), '{class}' => $atts['class'], '{content}' => $atts['content']);
    $output = strtr($prepend . $atts['html'][$atts['behaviour']] . $append, $replacements);
    return $output;
}
     $link .= in_array($link_atts[2], array('_self', '_blank')) ? ' target="' . esc_attr($link_atts[2]) . '"' : ' data-target="' . esc_attr($link_atts[2]) . '"';
 }
 // Output the posts item
 $output_item = apply_filters('wmhook_shortcode_' . $shortcode . '_item_output_pre', '', $post_id, $atts);
 if (empty($output_item)) {
     $class_item = '';
     // Testimonial title (for accessibility)
     $output_item .= '<' . tag_escape($atts['heading_tag']) . ' class="screen-reader-text">' . get_the_title($post_id) . '</' . tag_escape($atts['heading_tag']) . '>';
     // Testimonial content
     $output_item .= do_shortcode('<blockquote class="wm-testimonials-element wm-html-element content"' . wma_schema_org('review_body') . '>' . wpautop(preg_replace('/<(\\/?)blockquote(.*?)>/', '', get_the_content())) . '</blockquote>');
     // Testimonial author
     if (trim(wma_meta_option('author', $post_id))) {
         $output_item .= '<cite class="wm-testimonials-element wm-html-element source">';
         $output_item .= $link ? '<a' . $link . wma_schema_org('bookmark') . '>' : '';
         $output_item .= has_post_thumbnail($post_id) ? '<span class="wm-testimonials-element wm-html-element image image-container"' . wma_schema_org('image') . '>' . get_the_post_thumbnail($post_id, $image_size, array('title' => esc_attr(get_the_title(get_post_thumbnail_id($post_id))))) . '</span>' : '';
         $output_item .= '<span class="wm-testimonials-element wm-html-element author"' . wma_schema_org('author') . '>' . do_shortcode(strip_tags(wma_meta_option('author', $post_id), '<a><em><i><img><mark><small><strong>')) . '</span>';
         $output_item .= $link ? '</a>' : '';
         $output_item .= '</cite>';
     }
     $output_item .= wma_schema_org('itemprop="name" content="' . get_the_title($post_id) . '"', true);
     $output_item .= wma_schema_org('itemprop="datePublished" content="' . get_the_date('c') . '"', true);
     // Filter the posts item html output
     $output_item = apply_filters('wmhook_shortcode_' . $shortcode . '_item_html', $output_item, $post_id, $atts);
     // Posts single item output
     $class_item .= 'wm-testimonials-item wm-testimonials-item-' . $post_id;
     if (!$atts['testimonial']) {
         $class_item .= ' wm-column width-1-' . $atts['columns'] . $atts['no_margin'] . $alt;
     }
     if (!$atts['testimonial'] && (!$atts['no_margin'] || ' with-margin' === $atts['no_margin']) && !$atts['scroll'] && !$masonry_layout && $i % $atts['columns'] === 0) {
         $class_item .= ' last';
     }
Exemple #6
0
 * @version  1.4
 */
/**
 * Homepage redirect
 *
 * Applies on custom posts that don't need a single post view.
 */
$redirects = (array) apply_filters('wmhook_custom_post_redirects', array('wm_logos' => home_url(), 'wm_modules' => home_url(), 'wm_staff' => home_url(), 'wm_testimonials' => home_url()));
if (in_array(get_post_type($post->ID), array_keys($redirects))) {
    wp_redirect($redirects[get_post_type($post->ID)], 301);
    exit;
}
/**
 * Redirect Projects with custom link applied
 *
 * @since  1.1
 */
if (function_exists('wma_meta_option') && 'wm_projects' == get_post_type($post->ID) && wma_meta_option('link-action', $post->ID)) {
    wp_redirect(esc_url(wma_meta_option('link', $post->ID)), 301);
    exit;
}
/**
 * Actual single post content
 */
get_header();
if (function_exists('wma_amplifier')) {
    get_template_part('loop', 'singular');
} else {
    get_template_part('loop', 'post');
}
get_footer();
Exemple #7
0
     $page_object = get_page_by_path($link_atts[0]);
     $link = $page_object ? ' href="' . esc_url(get_permalink($page_object->ID)) . '"' : '#';
 } elseif ($link_atts[1]) {
     $link = ' href="' . esc_url($link_atts[1]) . '"';
 } else {
     $link = '';
 }
 if ($link && $link_atts[2]) {
     $link .= in_array($link_atts[2], array('_self', '_blank')) ? ' target="' . esc_attr($link_atts[2]) . '"' : ' data-target="' . esc_attr($link_atts[2]) . '"';
 }
 $helpers = array('link' => $link, 'tag' => isset($atts['layout']['tag']) ? 'module_tag' : '');
 $helpers = apply_filters('wmhook_shortcode_' . $shortcode . '_layout_elements_helpers', $helpers, $post_id, $atts);
 $layout_elements = array('content' => do_shortcode('<div class="wm-content-module-element wm-html-element content">' . wpautop(get_the_content()) . '</div>'), 'image' => '', 'morelink' => $helpers['link'] ? '<div class="wm-content-module-element wm-html-element more-link"><a' . $helpers['link'] . '>' . sprintf(apply_filters('wmhook_shortcode_' . 'read_more_text', __('Read more <span class="screen-reader-text">about "%s"</span>&raquo;', 'webman-amplifier'), $shortcode, $post_id, $atts), get_the_title()) . '</a></div>' : '', 'tag' => '', 'title' => $helpers['link'] ? '<div class="wm-content-module-element wm-html-element title"><' . tag_escape($atts['heading_tag']) . '><a' . $helpers['link'] . '>' . get_the_title() . '</a></' . tag_escape($atts['heading_tag']) . '></div>' : '<div class="wm-content-module-element wm-html-element title"><' . tag_escape($atts['heading_tag']) . '>' . get_the_title() . '</' . tag_escape($atts['heading_tag']) . '></div>');
 //image layout element
 $image = has_post_thumbnail($post_id) ? get_the_post_thumbnail($post_id, $image_size, array('title' => esc_attr(get_the_title(get_post_thumbnail_id($post_id))))) : '';
 $icon = array('box' => wma_meta_option('icon-box', $post_id), 'font' => wma_meta_option('icon-font', $post_id), 'color' => wma_meta_option('icon-color', $post_id), 'color-background' => wma_meta_option('icon-color-background', $post_id));
 $image_class = ' featured-image';
 $style_icon = $icon['color'] ? ' style="color: ' . esc_attr($icon['color']) . '"' : '';
 $style_container = $icon['color-background'] ? ' style="background-color: ' . esc_attr($icon['color-background']) . '"' : '';
 if ($icon['box'] && $icon['font']) {
     $image = '<i class="' . esc_attr($icon['font']) . '"' . $style_icon . '></i>';
     $image_class = ' font-icon';
 }
 if ($image && $helpers['link']) {
     $image = '<a' . $helpers['link'] . '>' . $image . '</a>';
 }
 if ($image) {
     $layout_elements['image'] = '<div class="wm-content-module-element wm-html-element image image-container' . esc_attr($image_class) . '"' . $style_container . '>' . $image . '</div>';
 }
 //tag layout element
 if ($helpers['tag']) {
Exemple #8
0
 function wma_schema_org($element = '', $output_meta_tag = false)
 {
     //Requirements check
     if (!$element || apply_filters('wmhook_wmamp_' . 'disable_schema_org', true)) {
         return;
     }
     //Helper variables
     $output = apply_filters('wmhook_wmamp_' . 'schema_org_output_pre', '', $element, $output_meta_tag);
     if ($output) {
         return apply_filters('wmhook_wmamp_' . 'wma_schema_org' . '_output', ' ' . $output, $element, $output_meta_tag);
     }
     $base = apply_filters('wmhook_wmamp_' . 'schema_org_base', 'http://schema.org/', $element, $output_meta_tag);
     $post_id = is_home() ? get_option('page_for_posts') : null;
     $type = wma_meta_option('schemaorg-type', $post_id);
     if (empty($type)) {
         $type = get_post_meta($post_id, 'schemaorg_type', true);
     }
     //Add custom post types that describe a single item to this array
     $itempage_array = (array) apply_filters('wmhook_wmamp_' . 'schema_org_itempage_array', array('wm_projects', 'jetpack-portfolio'), $element, $output_meta_tag);
     //Generate output
     switch ($element) {
         case 'article':
             $output = 'itemscope itemtype="' . $base . 'Article"';
             break;
         case 'article_body':
             $output = 'itemprop="articleBody"';
             break;
         case 'author':
             $output = 'itemprop="author"';
             break;
         case 'bookmark':
             $output = 'itemprop="url"';
             break;
         case 'comment':
             $output = 'itemprop="comment"';
             break;
         case 'creative_work':
             $output = 'itemscope itemtype="' . $base . 'CreativeWork"';
             break;
         case 'creator':
             $output = 'itemprop="creator" itemscope itemtype="' . $base . 'Person"';
             break;
         case 'date_modified':
             $output = 'itemprop="dateModified"';
             break;
         case 'date_published':
         case 'publish_date':
         case 'datePublished':
             $output = 'itemprop="datePublished"';
             break;
         case 'description':
             $output = 'itemprop="description"';
             break;
         case 'entry':
             $output = 'itemscope ';
             if (is_page()) {
                 $output .= 'itemtype="' . $base . 'WebPage"';
             } elseif (is_singular($itempage_array)) {
                 $output .= 'itemprop="workExample" itemtype="' . $base . 'CreativeWork"';
             } elseif ('audio' === get_post_format()) {
                 $output .= 'itemtype="' . $base . 'AudioObject"';
             } elseif ('gallery' === get_post_format()) {
                 $output .= 'itemprop="ImageGallery" itemtype="' . $base . 'ImageGallery"';
             } elseif ('video' === get_post_format()) {
                 $output .= 'itemprop="video" itemtype="' . $base . 'VideoObject"';
             } else {
                 $output .= 'itemprop="blogPost" itemtype="' . $base . 'BlogPosting"';
             }
             break;
         case 'entry_body':
             if (!is_single()) {
                 $output = 'itemprop="description"';
             } elseif (is_page()) {
                 $output = 'itemprop="mainContentOfPage"';
             } else {
                 $output = 'itemprop="articleBody"';
             }
             break;
         case 'footer':
         case 'WPFooter':
             $output = 'itemscope itemtype="' . $base . 'WPFooter"';
             break;
         case 'header':
         case 'WPHeader':
             $output = 'itemscope itemtype="' . $base . 'WPHeader"';
             break;
         case 'headline':
             $output = 'itemprop="headline"';
             break;
         case 'html':
             if (!$type) {
                 if (is_singular($itempage_array)) {
                     $type = 'ItemPage';
                 } elseif (is_singular('post')) {
                     $type = 'BlogPosting';
                 } elseif (is_single()) {
                     $type = 'Article';
                 } elseif (is_author()) {
                     $type = 'ProfilePage';
                 } elseif (is_search()) {
                     $type = 'SearchResultsPage';
                 } elseif (is_archive()) {
                     $type = 'CollectionPage';
                 } else {
                     $type = 'WebPage';
                 }
             }
             $output = 'itemscope itemtype="' . $base . $type . '"';
             break;
         case 'image':
             $output = 'itemprop="image"';
             break;
         case 'item_list':
         case 'ItemList':
             $output = 'itemscope itemtype="' . $base . 'ItemList"';
             break;
         case 'keywords':
             $output = 'itemprop="keywords"';
             break;
         case 'main_content':
             $output = 'itemprop="mainContentOfPage" itemscope itemtype="' . $base . 'WebPageElement"';
             break;
         case 'name':
             $output = 'itemprop="name"';
             break;
         case 'navigation':
             $output = 'itemscope itemtype="' . $base . 'SiteNavigationElement"';
             break;
         case 'person':
         case 'Person':
             $output = 'itemscope itemtype="' . $base . 'Person"';
             break;
         case 'review':
             $output = 'itemprop="review" itemscope itemtype="' . $base . 'Review"';
             break;
         case 'review_body':
             $output = 'itemprop="reviewBody"';
             break;
         case 'sidebar':
         case 'WPSideBar':
             $output = 'itemscope itemtype="' . $base . 'WPSideBar"';
             break;
         case 'SiteNavigationElement':
             $output = 'itemscope itemtype="' . $base . 'SiteNavigationElement"';
             break;
         case 'text':
             $output = 'itemprop="text"';
             break;
         case 'url':
             $output = 'itemprop="url"';
             break;
         default:
             $output = $element;
             break;
     }
     $output = ' ' . $output;
     //Output in <meta> tag
     if ($output_meta_tag) {
         if (false === strpos($output, 'content=')) {
             $output .= ' content="true"';
         }
         $output = '<meta ' . trim($output) . ' />';
     }
     //Output
     return apply_filters('wmhook_wmamp_' . 'wma_schema_org' . '_output', $output, $element, $output_meta_tag);
 }
Exemple #9
0
/**
 * Radio buttons
 *
 * @since    1.0
 * @version  1.2.2
 */
function wma_field_radio($field, $page_template = null)
{
    // Helper variables
    // Definition
    $field = wp_parse_args((array) $field, array('type' => 'radio', 'id' => 'id', 'label' => '', 'description' => '', 'class' => '', 'options' => array(), 'default' => '', 'inline' => false, 'filter' => false, 'repeater' => false, 'custom' => '', 'hide-radio' => false, 'conditional' => ''));
    // Alter class when custom label HTML used
    if (trim($field['custom'])) {
        $field['class'] = 'custom-label ' . $field['class'];
    }
    if ($field['hide-radio']) {
        $field['hide-radio'] = ' hide';
    }
    if ($field['filter']) {
        $field['class'] .= ' filterable';
    }
    // Value processing
    if ($field['repeater'] && is_array($field['repeater']) && isset($field['repeater']['value'])) {
        $value = $field['repeater']['value'];
    } else {
        $value = wma_meta_option($field['id']);
    }
    if ($value) {
        $value = esc_attr($value);
    } else {
        $value = esc_attr($field['default']);
    }
    // Field ID setup
    if ($field['repeater'] && is_array($field['repeater']) && isset($field['repeater']['id'])) {
        $field['id'] = $field['repeater']['id'];
    } else {
        $field['id'] = WM_METABOX_FIELD_PREFIX . $field['id'];
    }
    // Output
    $output = "\r\n\t" . '<tr class="option radio-wrap option-' . esc_attr(trim($field['id'] . ' ' . $field['class'])) . '" data-option="' . esc_attr($field['id']) . '"><th>';
    // Radio group label
    $output .= "\r\n\t\t" . '<strong class="label">' . trim(strip_tags($field['label'], WM_METABOX_LABEL_HTML)) . '</strong>';
    // Description
    if (trim($field['description'])) {
        $output .= "\r\n\t\t" . '<p class="description">' . trim($field['description']) . '</p>';
    }
    // Filter
    if ($field['filter']) {
        $output .= "\r\n\t\t" . '<p class="filter"><input type="text" value="" placeholder="' . esc_attr__('Filter: start typing...', 'webman-amplifier') . '" class="filter-text" /></p>';
    }
    $output .= "\r\n\t" . '</th><td>';
    // Input field
    if (is_array($field['options']) && !empty($field['options'])) {
        $i = 0;
        $output .= "\r\n\t" . '<div class="radio-items">';
        foreach ($field['options'] as $option_value => $option) {
            $i++;
            $output .= "\r\n\t\t";
            $output .= !$field['inline'] ? '<p class="radio-item"' : '<span class="radio-item inline-radio"';
            $output .= ' data-value="' . esc_attr($option_value) . '">';
            $checked = trim(checked($value, $option_value, false) . ' /');
            $option = trim(strip_tags($option, WM_METABOX_LABEL_HTML));
            if (!trim($field['custom'])) {
                $output .= '<input type="' . esc_attr($field['type']) . '" name="' . esc_attr($field['id']) . '" id="' . esc_attr($field['id'] . '-' . $i) . '" value="' . esc_attr($option_value) . '" title="' . esc_attr($option) . '" class="fieldtype-radio" ' . $checked . '> ';
                $output .= '<label for="' . esc_attr($field['id'] . '-' . $i) . '">' . $option . '</label>';
            } else {
                $output .= '<label for="' . esc_attr($field['id'] . '-' . $i) . '">' . trim(str_replace(array('{{value}}', '{{name}}'), array($option_value, $option), $field['custom'])) . '</label>';
                $output .= '<input type="' . esc_attr($field['type']) . '" name="' . esc_attr($field['id']) . '" id="' . esc_attr($field['id'] . '-' . $i) . '" value="' . esc_attr($option_value) . '" title="' . esc_attr($option) . '" class="fieldtype-radio' . esc_attr($field['hide-radio']) . '" ' . $checked . '>';
            }
            $output .= !$field['inline'] ? '</p>' : '</span> ';
        }
        // /foreach
        $output .= "\r\n\t" . '</div>';
    }
    // Reset default value button
    if (trim($field['default'])) {
        $output .= "\r\n\t\t" . '<a data-option="' . esc_attr($field['id']) . '" class="button-default-value" title="' . esc_attr__('Use a default value', 'webman-amplifier') . '"><span>' . esc_attr($field['default']) . '</span></a>';
    }
    echo $output;
    // Conditional display
    do_action('wmhook_metabox_' . 'conditional', $field, $field['id']);
    echo "\r\n\t" . '</td></tr>';
}
Exemple #10
0
 function wma_modules_cp_columns_render($column)
 {
     //Helper variables
     global $post;
     $prefix = 'wmamp-';
     $suffix = '-wm_modules';
     //Columns renderers
     switch ($column) {
         case $prefix . 'link' . $suffix:
             $link = esc_url(stripslashes(wma_meta_option('link')));
             echo '<a href="' . $link . '" target="_blank">' . $link . '</a>';
             break;
         case $prefix . 'slug' . $suffix:
             echo $post->post_name;
             break;
         case $prefix . 'tag' . $suffix:
             $separator = '';
             $terms = get_the_terms($post->ID, 'module_tag');
             if (!is_wp_error($terms) && !empty($terms)) {
                 foreach ($terms as $term) {
                     $termName = isset($term->name) ? $term->name : null;
                     echo $separator . $termName;
                     $separator = ', ';
                 }
             }
             break;
         case $prefix . 'thumb' . $suffix:
             $size = apply_filters('wmhook_wmamp_' . 'cp_admin_thumb_size', 'admin-thumbnail');
             $image = has_post_thumbnail() ? get_the_post_thumbnail(null, $size) : '';
             $fontIcon = wma_meta_option('icon-font');
             $iconColor = wma_meta_option('icon-color');
             $iconBgColor = wma_meta_option('icon-color-background');
             $styleIcon = $iconColor ? ' style="color: ' . $iconColor . '"' : '';
             $styleContainer = $iconBgColor ? ' style="background-color: ' . $iconBgColor . '"' : '';
             if ($fontIcon) {
                 $image = '<i class="' . $fontIcon . '"' . $styleIcon . '></i>';
             }
             $hasThumb = $image ? ' has-thumb' : ' no-thumb';
             echo '<span class="wm-image-container' . $hasThumb . '"' . $styleContainer . '>';
             if (get_edit_post_link()) {
                 edit_post_link($image);
             } else {
                 echo '<a href="' . get_permalink() . '">' . $image . '</a>';
             }
             echo '</span>';
             break;
         default:
             break;
     }
     // /switch
 }
 * can lay out the sidebar in Sections shortcodes (rows) with columns and
 * widget area shortcodes (set class of "sidebar" for widget area shortcode).
 *
 * @package    WebMan WordPress Theme Framework
 * @copyright  2014 WebMan - Oliver Juhas
 *
 * @since    1.0
 * @version  1.1.1
 */
/**
 * Helper variables
 */
$content_area_class = '';
$sidebar_none_posts = apply_filters('wmhook_sidebar_none_posts', array('wm_projects', 'page'));
$sidebar_none_posts = is_singular($sidebar_none_posts);
if (function_exists('wma_meta_option') && 'sections' == wma_meta_option('sidebar')) {
    $sections_layout = true;
} else {
    $sections_layout = false;
}
/**
 * Sidebar implementation
 *
 * Variables setup
 */
$sidebar = wm_sidebar_setup();
/**
 * Actual page/post output
 */
if (!$sections_layout) {
    echo "\r\n\r\n" . '<div class="wrap-inner">';
Exemple #12
0
 // Item_class
 $helper['item_class'] = esc_attr('wm-posts-item wm-posts-item-' . $post_id . ' wm-column width-1-' . $atts['columns'] . $atts['no_margin'] . $alt);
 if ((!$atts['no_margin'] || ' with-margin' === $atts['no_margin']) && !$atts['filter'] && !$atts['scroll'] && !$masonry_layout && $i % $atts['columns'] === 0) {
     $helper['item_class'] .= ' last';
 }
 if ($atts['filter'] && isset($filter_settings[0])) {
     $terms = get_the_terms($post_id, $filter_settings[0]);
     if (!is_wp_error($terms) && !empty($terms)) {
         foreach ($terms as $term) {
             $helper['item_class'] .= ' ' . $filter_settings[0] . '-' . $term->slug;
         }
     }
 }
 // Link
 $helper['link'] = '';
 $link_atts = array(wma_meta_option('link-page', $post_id), wma_meta_option('link', $post_id), wma_meta_option('link-action', $post_id));
 if ('wm_projects' == $atts['post_type'] && !$link_atts[2]) {
     $helper['link'] = ' href="' . esc_url(get_permalink()) . '"';
 } elseif ($link_atts[0]) {
     $page_object = get_page_by_path($link_atts[0]);
     $helper['link'] = $page_object ? ' href="' . esc_url(get_permalink($page_object->ID)) . '"' : '#';
 } elseif ($link_atts[1]) {
     $helper['link'] = ' href="' . esc_url($link_atts[1]) . '"';
 } else {
     $helper['link'] = ' href="' . esc_url(get_permalink()) . '"';
 }
 if (('wm_staff' == $atts['post_type'] || 'wm_logos' == $atts['post_type']) && !$link_atts[0] && !$link_atts[1]) {
     $helper['link'] = '';
 }
 if ($helper['link'] && $link_atts[2]) {
     $helper['link'] .= in_array($link_atts[2], array('_self', '_blank')) ? ' target="' . esc_attr($link_atts[2]) . '"' : ' data-target="' . esc_attr($link_atts[2]) . '"';
        $images = array();
        if (is_array($media_shortcode[1])) {
            $images = $media_shortcode[1];
        } else {
            $posts_images = wm_get_post_images();
            foreach ($posts_images as $image) {
                $images[] = $image['id'];
            }
        }
        if (is_array($images) && !empty($images)) {
            echo do_shortcode(apply_filters('wmhook_post_format_gallery_slideshow_shortcode', '[wm_slideshow ids="' . implode(',', $images) . '" nav="pagination" size="' . $image_size . '" speed="4000" /]'));
        }
    }
}
//If no gallery, display featured image (also, always display featured image on single post page)
if ($is_single && !apply_filters('wmhook_disable_single_featured_image', false) && !(function_exists('wma_meta_option') && wma_meta_option('disable-featured-image')) && !$pagination_suffix) {
    echo wm_thumb(array('attr-link' => wm_schema_org('image'), 'class' => 'image-container post-thumbnail scale-rotate', 'link' => 'bigimage', 'size' => 'content-width'));
} elseif (!$is_single && (!$media_shortcode[0] || !function_exists('wma_amplifier'))) {
    echo wm_thumb(array('attr-link' => wm_schema_org('image'), 'class' => 'image-container post-thumbnail scale-rotate', 'link' => get_permalink(), 'size' => $image_size));
}
?>
	</div>

	<?php 
/**
 * Post title
 */
wm_post_title();
/**
 * Post content
 */
 *
 * Simple wm_projects item template
 * Consist of:
 * 		image,
 * 		title
 *
 * @package     WebMan Amplifier
 * @subpackage  Shortcodes
 *
 * @uses        array $helper  Contains shortcode $atts array plus additional helper variables.
 */
$link_output = array('', '');
if ($helper['link']) {
    $link_output = array('<a' . $helper['link'] . wm_schema_org('bookmark') . '>', '</a>');
}
$project_preview = trim(wma_meta_option('slider'));
?>

<article class="<?php 
echo $helper['item_class'];
?>
"<?php 
echo wm_schema_org('creative_work');
?>
>

	<?php 
if ($project_preview) {
    echo '<div class="wm-posts-element wm-html-element slider">';
    echo $link_output[0] . do_shortcode($project_preview) . $link_output[1];
    echo '</div>';
echo '</' . $helper['atts']['heading_tag'] . '>';
?>
</div>

	<?php 
if (has_post_thumbnail($helper['post_id'])) {
    echo '<div class="wm-posts-element wm-html-element image image-container"' . wm_schema_org('image') . '>';
    echo $link_output[0];
    the_post_thumbnail($helper['image_size'], array('title' => esc_attr(get_the_title(get_post_thumbnail_id($helper['post_id'])))));
    echo $link_output[1];
    echo '</div>';
}
?>

	<?php 
$staff_contacts = wma_meta_option('contacts', $helper['post_id']);
if ($staff_contacts && is_array($staff_contacts)) {
    $output_contacts = '';
    foreach ($staff_contacts as $contact) {
        if (!isset($contact['icon']) || !trim($contact['icon'])) {
            continue;
        }
        if (!isset($contact['title'])) {
            $contact['title'] = '';
        }
        if (!isset($contact['link'])) {
            $contact['link'] = '';
        }
        $title_attr = $contact['title'] ? ' title="' . esc_attr(strip_tags($contact['title'])) . '"' : '';
        $output_contacts .= '<li class="contacts-item"' . wm_schema_org('itemprop="contactPoint"') . '>';
        if ($contact['link']) {
Exemple #16
0
 function wma_projects_cp_columns_render($column)
 {
     //Helper variables
     global $post;
     $prefix = 'wmamp-';
     $suffix = '-wm_projects';
     //Columns renderers
     switch ($column) {
         case $prefix . 'category' . $suffix:
             $terms = get_the_terms($post->ID, 'project_category');
             if (!is_wp_error($terms) && !empty($terms)) {
                 foreach ($terms as $term) {
                     $termName = isset($term->name) ? $term->name : null;
                     echo '<strong class="project-category">' . $termName . '</strong><br />';
                 }
             }
             break;
         case $prefix . 'link' . $suffix:
             $link = esc_url(stripslashes(wma_meta_option('link')));
             echo '<a href="' . $link . '" target="_blank">' . $link . '</a>';
             break;
         case $prefix . 'tag' . $suffix:
             $separator = '';
             $terms = get_the_terms($post->ID, 'project_tag');
             if (!is_wp_error($terms) && !empty($terms)) {
                 foreach ($terms as $term) {
                     $termName = isset($term->name) ? $term->name : null;
                     echo $separator . $termName;
                     $separator = ', ';
                 }
             }
             break;
         case $prefix . 'thumb' . $suffix:
             $size = apply_filters('wmhook_wmamp_' . 'cp_admin_thumb_size', 'thumbnail');
             $image = has_post_thumbnail() ? get_the_post_thumbnail(null, $size) : '';
             $hasThumb = $image ? ' has-thumb' : ' no-thumb';
             echo '<span class="wm-image-container' . $hasThumb . '">';
             if (get_edit_post_link()) {
                 edit_post_link($image);
             } else {
                 echo '<a href="' . get_permalink() . '">' . $image . '</a>';
             }
             echo '</span>';
             break;
         default:
             break;
     }
     // /switch
 }
Exemple #17
0
 function wm_css_background($args = array())
 {
     //Helper variables
     $args = wp_parse_args($args, apply_filters('wmhook_wm_css_background_defaults', array('option_base' => '', 'high_dpi' => false, 'post' => null, 'return' => 'output')));
     $args = apply_filters('wmhook_wm_css_background_args', $args);
     if ($args['post'] && is_object($args['post']) && isset($args['post']->ID)) {
         $args['post'] = $args['post']->ID;
     } else {
         $args['post'] = absint($args['post']);
     }
     //Requirements check
     if ($args['post'] && !function_exists('wma_meta_option')) {
         return;
     }
     $output = $output_defaults = array('attachment' => '', 'color' => '', 'image' => '', 'output' => '', 'position' => '', 'repeat' => '', 'size' => '');
     //Preparing output
     //Background color
     $output['color'] = !$args['post'] ? wm_option($args['option_base'] . 'bg-color') : wma_meta_option($args['option_base'] . 'bg-color', $args['post']);
     if ($output['color']) {
         $output['color'] = '#' . str_replace('#', '', $output['color']);
     }
     //Background image
     $output['image'] = !$args['post'] ? wm_option($args['option_base'] . 'bg-url') : wma_meta_option($args['option_base'] . 'bg-url', $args['post']);
     if (is_array($output['image']) && isset($output['image']['id'])) {
         $attachment = (array) wp_get_attachment_image_src($output['image']['id'], 'full');
         $output['image'] = isset($attachment[0]) ? $attachment[0] : '';
         $output['size'] = isset($attachment[1]) ? $attachment[1] . 'px' : '';
         $output['size'] .= isset($attachment[2]) ? ' ' . $attachment[2] . 'px' : '';
         if ($args['high_dpi']) {
             $attachment = !$args['post'] ? wm_option($args['option_base'] . 'bg-url-hidpi') : wma_meta_option($args['option_base'] . 'bg-url-hidpi', $args['post']);
             $attachment = $attachment && isset($attachment['id']) ? (array) wp_get_attachment_image_src($attachment['id'], 'full') : false;
             if ($attachment && isset($attachment[0])) {
                 $output['image'] = $attachment[0];
             }
         }
     } elseif ($output['image']) {
         $attachment_id = wm_get_image_id_from_url($output['image']);
         if ($attachment_id) {
             $attachment = (array) wp_get_attachment_image_src($attachment_id, 'full');
             $output['size'] = isset($attachment[1]) ? $attachment[1] . 'px' : '';
             $output['size'] .= isset($attachment[2]) ? ' ' . $attachment[2] . 'px' : '';
         }
         if ($args['high_dpi']) {
             $output['image'] = !$args['post'] ? wm_option($args['option_base'] . 'bg-url-hidpi') : wma_meta_option($args['option_base'] . 'bg-url-hidpi', $args['post']);
         }
     }
     if ($output['image']) {
         $output['image'] = ' url(' . trim($output['image']) . ')';
     }
     //Background repeat
     if ($output['image']) {
         $output['repeat'] = !$args['post'] ? wm_option($args['option_base'] . 'bg-repeat') : wma_meta_option($args['option_base'] . 'bg-repeat', $args['post']);
         if (trim($output['repeat'])) {
             $output['repeat'] = ' ' . trim($output['repeat']);
         }
     }
     //Background attachment
     if ($output['image']) {
         $output['attachment'] = !$args['post'] ? wm_option($args['option_base'] . 'bg-attachment') : wma_meta_option($args['option_base'] . 'bg-attachment', $args['post']);
         if (trim($output['attachment'])) {
             $output['attachment'] = ' ' . trim($output['attachment']);
         }
     }
     //Background position
     if ($output['image']) {
         $output['position'] = !$args['post'] ? wm_option($args['option_base'] . 'bg-position') : wma_meta_option($args['option_base'] . 'bg-position', $args['post']);
         if (trim($output['position'])) {
             $output['position'] = ' ' . trim($output['position']);
         }
     }
     //Background size
     if ($output['image']) {
         $image_size = !$args['post'] ? wm_option($args['option_base'] . 'bg-size') : wma_meta_option($args['option_base'] . 'bg-size', $args['post']);
         if ($image_size) {
             $output['size'] = $image_size;
         }
     }
     $output['size'] = trim($output['size']);
     if ($output['size']) {
         $output['size'] = '; background-size: ' . $output['size'];
     }
     //Output string setup
     $output['output'] = $output['color'] . $output['image'] . $output['repeat'] . $output['attachment'] . $output['position'] . $output['size'];
     //If outputing high DPI image, check if image set, if not output nothing (not even background-size)!
     if ($args['high_dpi'] && !$output['image']) {
         $output = $output_defaults;
     }
     //Filter $output array
     $output = apply_filters('wmhook_wm_css_background_output_array', $output, $args);
     //Output
     return apply_filters('wmhook_wm_css_background_output', $output[$args['return']], $args);
 }
Exemple #18
0
 function wma_field_textarea($field, $page_template = null)
 {
     //Field definition array
     $field = wp_parse_args((array) $field, array('type' => 'textarea', 'id' => 'id', 'label' => '', 'description' => '', 'default' => '', 'class' => '', 'attributes' => 'rows="3"', 'empty' => false, 'editor' => false, 'repeater' => false, 'conditional' => ''));
     //Value processing
     if ($field['repeater'] && is_array($field['repeater']) && isset($field['repeater']['value'])) {
         $value = $field['repeater']['value'];
     } else {
         $value = wma_meta_option($field['id']);
     }
     if ($value || $field['empty']) {
         $value = !$field['editor'] ? esc_textarea($value) : $value;
     } else {
         $value = !$field['editor'] ? esc_textarea($field['default']) : $field['default'];
     }
     //Field ID setup
     if ($field['repeater'] && is_array($field['repeater']) && isset($field['repeater']['id'])) {
         $field['id'] = $field['repeater']['id'];
     } else {
         $field['id'] = WM_METABOX_FIELD_PREFIX . $field['id'];
     }
     //Output
     $output = "\r\n\t" . '<tr class="option textarea-wrap option-' . trim(sanitize_html_class($field['id']) . ' ' . $field['class']) . '" data-option="' . $field['id'] . '"><th>';
     //Label
     $output .= "\r\n\t\t" . '<label for="' . $field['id'] . '">' . trim(strip_tags($field['label'], WM_METABOX_LABEL_HTML)) . '</label>';
     $output .= "\r\n\t" . '</th><td>';
     //Input field
     if (!$field['editor']) {
         $output .= "\r\n\t\t" . '<textarea name="' . $field['id'] . '" id="' . $field['id'] . '" class="fieldtype-textarea" ' . trim($field['attributes']) . '>' . $value . '</textarea>';
     } else {
         echo $output;
         wp_editor($value, $field['id']);
         $output = '';
     }
     //Description
     if (trim($field['description'])) {
         $output .= "\r\n\t\t" . '<p class="description">' . trim($field['description']) . '</p>';
     }
     //Reset default value button
     if (trim($field['default']) && !$field['editor']) {
         $output .= "\r\n\t\t" . '<a data-option="' . $field['id'] . '" class="button-default-value" title="' . __('Use a default value', 'webman-amplifier') . '"><span>' . $field['default'] . '</span></a>';
     }
     echo $output;
     //Conditional display
     do_action('wmhook_metabox_' . 'conditional', $field, $field['id']);
     echo "\r\n\t" . '</td></tr>';
 }
Exemple #19
0
<?php

/**
 * Post meta (custom) fields
 *
 * This file is being included into "../class-shortcodes.php" file's shortcode_render() method.
 *
 * @since  1.0.9
 *
 * @param  boolean custom  Whether to output the native WordPress Custom Field. Otherwise outputs wma
 * @param  string field
 * @param  absint post_id
 */
//Shortcode attributes
$defaults = apply_filters('wmhook_shortcode_' . '_defaults', array('custom' => false, 'field' => '', 'post_id' => get_the_id()), $shortcode);
$atts = apply_filters('wmhook_shortcode_' . '_attributes', $atts, $shortcode);
$atts = shortcode_atts($defaults, $atts, $prefix_shortcode . $shortcode);
//Validation
//custom
$atts['custom'] = trim($atts['custom']);
//post_id
$atts['post_id'] = absint($atts['post_id']);
//field
$atts['field'] = trim($atts['field']);
if (!$atts['custom']) {
    $atts['field'] = str_replace(WM_METABOX_FIELD_PREFIX, '', $atts['field']);
}
//Output
if ($atts['field']) {
    $output = !$atts['custom'] ? wma_meta_option($atts['field'], $atts['post_id']) : get_post_meta($atts['post_id'], $atts['field'], true);
}
Exemple #20
0
 function wm_blog_page_query()
 {
     //Helper variables
     global $paged, $page, $wm_blog_page_id;
     //Requirements check
     if (!function_exists('wma_meta_option') || !$wm_blog_page_id) {
         return;
     }
     $page = get_query_var('page');
     $paged = isset($paged) && $paged ? $paged : 1;
     $pagination_page = 1;
     if ($page || $paged) {
         $pagination_page = max($page, $paged);
     }
     $article_count = wma_meta_option('blog-posts-count', $wm_blog_page_id);
     $cats_action = wma_meta_option('blog-categories-action', $wm_blog_page_id) ? wma_meta_option('blog-categories-action', $wm_blog_page_id) : 'category__in';
     $cats = wma_meta_option('blog-categories', $wm_blog_page_id) ? array_filter(wma_meta_option('blog-categories', $wm_blog_page_id)) : array();
     //Get categories IDs in array
     if (0 < count($cats)) {
         $cat_temp = array();
         foreach ($cats as $cat) {
             if (isset($cat['category']) && $cat['category']) {
                 $cat = $cat['category'];
                 if (!is_numeric($cat)) {
                     //Category slugs to IDs
                     $cat_object = get_category_by_slug($cat);
                     $cat_temp[] = is_object($cat_object) && isset($cat_object->term_id) ? $cat_object->term_id : null;
                 } else {
                     $cat_temp[] = $cat;
                 }
             }
         }
         array_filter($cat_temp);
         //remove empty (if any)
         $cats = $cat_temp;
     }
     //Preparing output
     $query_args = array('posts_per_page' => absint($article_count), 'paged' => absint($pagination_page));
     if (0 < count($cats)) {
         $query_args[$cats_action] = $cats;
     }
     $blog_posts = new WP_Query(apply_filters('wmhook_wm_blog_page_query_args', $query_args, $wm_blog_page_id));
     //Output
     return apply_filters('wmhook_wm_blog_page_query_output', $blog_posts);
 }
Exemple #21
0
 function wma_field_gallery($field, $page_template = null)
 {
     //Field definition array
     $field = wp_parse_args((array) $field, array('type' => 'gallery', 'id' => 'id', 'label' => '', 'description' => '', 'class' => '', 'default' => '', 'size' => 'thumbnail', 'button-text' => __('Set images', 'webman-amplifier'), 'conditional' => ''));
     //Value processing
     $value = wma_meta_option($field['id']);
     $value = preg_replace('/[^0-9\\,]/', '', $value);
     //Field ID setup
     $field['id'] = WM_METABOX_FIELD_PREFIX . $field['id'];
     //Output
     $output = "\r\n\t" . '<tr class="option gallery-wrap option-' . trim(sanitize_html_class($field['id']) . ' ' . $field['class']) . '" data-option="' . $field['id'] . '"><th>';
     //Label
     $output .= "\r\n\t\t" . '<label for="' . $field['id'] . '" class="button-set-gallery" data-id="' . $field['id'] . '">' . trim(strip_tags($field['label'], WM_METABOX_LABEL_HTML)) . '</label>';
     $output .= "\r\n\t" . '</th><td>';
     //Input field
     $output .= "\r\n\t\t";
     $output .= '<input type="hidden" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . $value . '" />';
     //Image upload button
     $output .= '<a href="#" class="button button-set-gallery" data-id="' . $field['id'] . '">' . $field['button-text'] . '</a>';
     //Description
     if (trim($field['description'])) {
         $output .= "\r\n\t\t" . '<p class="description">' . trim($field['description']) . '</p>';
     }
     //Image preview
     $value = array_filter(explode(',', $value));
     $output .= "\r\n\t\t" . '<div class="gallery-preview gallery-' . $field['id'] . '">';
     if (is_array($value) && !empty($value)) {
         foreach ($value as $image_id) {
             $output .= '<a class="button-set-gallery" data-id="' . $field['id'] . '" title="' . __('Edit images', 'webman-amplifier') . '">';
             $output .= wp_get_attachment_image(absint($image_id), $field['size']);
             $output .= '</a>';
         }
     }
     $output .= '</div>';
     $output .= "\r\n\t\t" . '<img class="gallery-loading gallery-loading-' . $field['id'] . '" src="' . WMAMP_ASSETS_URL . 'images/meta/loading.gif" width="16" height="16" alt="' . __('Loading images', 'webman-amplifier') . '" title="' . __('Loading images', 'webman-amplifier') . '" />';
     //Reset default value button
     $output .= "\r\n\t\t" . '<a data-option="' . $field['id'] . '" class="button-default-value default-gallery" title="' . __('Remove images', 'webman-amplifier') . '"><span>' . $field['default'] . '</span></a>';
     echo $output;
     //Conditional display
     do_action('wmhook_metabox_' . 'conditional', $field, $field['id']);
     echo "\r\n\t" . '</td></tr>';
 }
Exemple #22
0
 function wma_field_select($field, $page_template = null)
 {
     //Field definition array
     $field = wp_parse_args((array) $field, array('type' => 'select', 'id' => 'id', 'label' => '', 'description' => '', 'class' => '', 'attributes' => '', 'options' => array(), 'default' => '', 'repeater' => false, 'conditional' => ''));
     //Value processing
     if ($field['repeater'] && is_array($field['repeater']) && isset($field['repeater']['value'])) {
         $value = $field['repeater']['value'];
     } else {
         $value = wma_meta_option($field['id']);
     }
     if ($value && is_array($value)) {
         $value = (array) $value;
     } elseif ($value) {
         $value = esc_attr($value);
     } else {
         $value = esc_attr($field['default']);
     }
     //Field ID setup
     if ($field['repeater'] && is_array($field['repeater']) && isset($field['repeater']['id'])) {
         $field['id'] = $field['repeater']['id'];
     } else {
         $field['id'] = WM_METABOX_FIELD_PREFIX . $field['id'];
     }
     //Output
     $output = "\r\n\t" . '<tr class="option select-wrap option-' . trim(sanitize_html_class($field['id']) . ' ' . $field['class']) . '" data-option="' . $field['id'] . '"><th>';
     //Label
     $output .= "\r\n\t\t" . '<label for="' . $field['id'] . '">' . trim(strip_tags($field['label'], WM_METABOX_LABEL_HTML)) . '</label>';
     $output .= "\r\n\t" . '</th><td>';
     //Input field
     $suffix = '';
     if (false !== strpos($field['attributes'], 'multiple')) {
         $suffix = '[]';
     }
     $output .= "\r\n\t\t" . '<select name="' . $field['id'] . $suffix . '" id="' . $field['id'] . '" class="fieldtype-select" ' . trim($field['attributes']) . '>';
     if (is_array($field['options']) && !empty($field['options'])) {
         foreach ($field['options'] as $option_value => $option) {
             if (false === strpos($option_value, 'OPTGROUP')) {
                 //classic options
                 if (!is_array($value)) {
                     $selected = selected($value, $option_value, false);
                 } else {
                     $selected = in_array($option_value, $value) ? ' selected="selected"' : '';
                 }
                 $output .= "\r\n\t\t\t\t" . '<option value="' . $option_value . '"' . $selected . '>' . wp_strip_all_tags($option) . '</option>';
             } elseif ('OPTGROUP' === substr($option_value, 1)) {
                 //open option group
                 $output .= "\r\n\t\t\t" . '<optgroup label="' . esc_attr($option) . '">';
             } elseif ('/OPTGROUP' === substr($option_value, 1)) {
                 //close option group
                 $output .= "\r\n\t\t\t" . '</optgroup>';
             }
         }
     }
     $output .= "\r\n\t\t" . '</select>';
     //Description
     if (trim($field['description'])) {
         $output .= "\r\n\t\t" . '<p class="description">' . trim($field['description']) . '</p>';
     }
     //Reset default value button
     if (trim($field['default'])) {
         $output .= "\r\n\t\t" . '<a data-option="' . $field['id'] . '" class="button-default-value" title="' . __('Use a default value', 'webman-amplifier') . '"><span>' . $field['default'] . '</span></a>';
     }
     echo $output;
     //Conditional display
     do_action('wmhook_metabox_' . 'conditional', $field, $field['id']);
     echo "\r\n\t" . '</td></tr>';
 }