예제 #1
0
function strProper($str)
{
    $parts = explode(' ', $str);
    $rez = '';
    foreach ($parts as $p) {
        if (trim($p)) {
            $rez .= ($rez ? ' ' : '') . themerex_strtoupper(themerex_substr($p, 0, 1)) . themerex_strtolower(themerex_substr($p, 1));
        }
    }
    return $rez;
}
예제 #2
0
 function themerex_admin_taxonomy_filter()
 {
     global $typenow;
     if (get_theme_option('admin_add_filters') != 'yes' || $typenow != 'post') {
         return;
     }
     $taxes = array('post_format', 'post_tag');
     foreach ($taxes as $tax) {
         $tax_obj = get_taxonomy($tax);
         $terms = getTaxonomiesByPostType(array($typenow), array($tax));
         if (count($terms) > 0) {
             $tax_name = themerex_strtolower($tax_obj->labels->name);
             $tax = str_replace(array('post_tag'), array('tag'), $tax);
             echo "<select name='{$tax}' id='{$tax}' class='postform'>";
             echo "<option value=''>All {$tax_name}</option>";
             foreach ($terms as $term) {
                 $slug = is_object($term) ? $term->slug : $term['slug'];
                 $name = is_object($term) ? $term->name : $term['name'];
                 $count = is_object($term) ? $term->count : $term['count'];
                 echo '<option value=' . $slug . ($_GET[$tax] == $slug ? ' selected="selected"' : '') . '>' . str_replace(array('post-format-'), array(''), $name) . ' (' . $count . ')</option>';
             }
             echo "</select>";
         }
     }
 }
예제 #3
0
function sc_param_is_off($prm)
{
    return empty($prm) || $prm === 0 || in_array(themerex_strtolower($prm), array('false', 'off', 'no', 'none', 'hide'));
}
예제 #4
0
function showBreadcrumbs($args = array())
{
    global $wp_query, $post;
    $args = array_merge(array('home' => '', 'home_url' => '', 'show_all_filters' => true, 'show_all_posts' => true, 'truncate_title' => 0, 'truncate_add' => '...', 'echo' => true), is_array($args) ? $args : array('home' => $args));
    $rez = '';
    $rez2 = '';
    $rez_all = '';
    $type = getBlogType();
    $title = getShortString(getBlogTitle(), $args['truncate_title'], $args['truncate_add']);
    $cat = '';
    $parentTax = '';
    if (!in_array($type, array('home', 'frontpage'))) {
        $need_reset = true;
        $parent = 0;
        $post_id = 0;
        if ($type == 'page' || $type == 'attachment') {
            $pageParentID = isset($wp_query->post->post_parent) ? $wp_query->post->post_parent : 0;
            $post_id = $type == 'page' ? isset($wp_query->post->ID) ? $wp_query->post->ID : 0 : $pageParentID;
            while ($pageParentID > 0) {
                $pageParent = get_post($pageParentID);
                $rez2 = '<li class="cat_post"><a href="' . get_permalink($pageParent->ID) . '">' . getShortString($pageParent->post_title, $args['truncate_title'], $args['truncate_add']) . '</a></li>' . $rez2;
                if (($pageParentID = $pageParent->post_parent) > 0) {
                    $page_id = $pageParentID;
                }
            }
        } else {
            if ($type == 'single') {
                $post_id = isset($wp_query->post->ID) ? $wp_query->post->ID : 0;
            }
        }
        $depth = 0;
        $ex_cats = explode(',', get_theme_option('exclude_cats'));
        $taxonomy = themerex_strpos($type, 'woocommerce') !== false ? array('product_cat') : array('category');
        do {
            if ($depth++ == 0) {
                if (in_array($type, array('single', 'attachment', 'woocommerce_product'))) {
                    if ($type != 'woocommerce_product' && $args['show_all_filters']) {
                        $post_format = get_post_format($post_id);
                        if (($tpl_id = getTemplatePageId('only-' . $post_format)) > 0) {
                            $rez_all .= '<li class="all"><a href="' . get_permalink($tpl_id) . '">' . sprintf(__('All %s', 'themerex'), getPostFormatName($post_format, false)) . '</a></li>';
                        }
                    }
                    $cats = getCategoriesByPostId($post_id, $taxonomy);
                    $cat = $cats ? $cats[0] : false;
                    if ($cat) {
                        if (!in_array($cat['term_id'], $ex_cats)) {
                            $cat_link = get_term_link($cat['slug'], $cat['taxonomy']);
                            $rez2 = '<li class="cat_post"><a href="' . $cat_link . '">' . getShortString($cat['name'], $args['truncate_title'], $args['truncate_add']) . '</a></li>' . $rez2;
                        }
                    } else {
                        $post_type = get_post_type($post_id);
                        $parentTax = 'category' . ($post_type == 'post' ? '' : '_' . $post_type);
                    }
                } else {
                    if ($type == 'category') {
                        $cat = get_term_by('id', get_query_var('cat'), 'category', ARRAY_A);
                    } else {
                        if (themerex_strpos($type, 'woocommerce') !== false) {
                            if (is_product_category()) {
                                $cat = get_term_by('slug', get_query_var('product_cat'), 'product_cat', ARRAY_A);
                            }
                        }
                    }
                }
                if ($cat) {
                    $parent = $cat['parent'];
                    $parentTax = $cat['taxonomy'];
                }
            }
            if ($parent) {
                $cat = get_term_by('id', $parent, $parentTax, ARRAY_A);
                if ($cat) {
                    if (!in_array($cat['term_id'], $ex_cats)) {
                        $cat_link = get_term_link($cat['slug'], $cat['taxonomy']);
                        $rez2 = '<li class="cat_parent"><a href="' . $cat_link . '">' . getShortString($cat['name'], $args['truncate_title'], $args['truncate_add']) . '</a></li>' . $rez2;
                    }
                    $parent = $cat['parent'];
                }
            }
        } while ($parent);
        if (themerex_strpos($type, 'woocommerce') !== false && !in_array(themerex_strtolower($title), array('shop')) && ($shop_id = get_option('woocommerce_shop_page_id')) > 0) {
            $rez_all = '<li class="all"><a href="' . get_permalink($shop_id) . '">' . __('Shop', 'themerex') . '</a></li>' . $rez_all;
        }
        if ($args['show_all_posts'] && !in_array(themerex_strtolower($title), array('all posts')) && ($blog_id = getTemplatePageId('template-blog')) > 0) {
            $rez_all = '<li class="all"><a href="' . get_permalink($blog_id) . '">' . __('All Posts', 'themerex') . '</a></li>' . $rez_all;
        }
        $rez3 = '';
        if (themerex_strpos($type, 'woocommerce') === false && is_archive() && is_object($post)) {
            $year = get_the_time('Y');
            $month = get_the_time('m');
            if (is_day() || is_month()) {
                $rez3 .= '<li class="cat_parent"><a href="' . get_year_link($year) . '">' . $year . '</a></li>';
            }
            if (is_day()) {
                $rez3 .= '<li class="cat_parent"><a href="' . get_month_link($year, $month) . '">' . prepareDateForTranslation(get_the_date('F')) . '</a></li>';
            }
        }
        if (!is_front_page()) {
            // && !is_home()
            $rez .= '<ul class="breadcrumbs">' . (isset($args['home']) && $args['home'] != '' ? '<li class="home"><a href="' . ($args['home_url'] ? $args['home_url'] : home_url()) . '">' . $args['home'] . '</a></li>' : '') . $rez_all . $rez2 . $rez3 . ($title ? '<li class="current">' . $title . '</li>' : '') . '</ul>';
        }
    }
    if ($args['echo'] && !empty($rez)) {
        echo $rez;
    }
    return $rez;
}
예제 #5
0
 function themerex_strtoproper($text)
 {
     $rez = '';
     $last = ' ';
     for ($i = 0; $i < themerex_strlen($text); $i++) {
         $ch = themerex_substr($text, $i, 1);
         $rez .= themerex_strpos(' .,:;?!()[]{}+=', $last) !== false ? themerex_strtoupper($ch) : themerex_strtolower($ch);
         $last = $ch;
     }
     return $rez;
 }
예제 #6
0
function sc_param_is_inherit($prm)
{
    return in_array(themerex_strtolower($prm), array('inherit', 'default'));
}
function is_inherit_option($value)
{
    while (is_array($value)) {
        foreach ($value as $val) {
            $value = $val;
            break;
        }
    }
    return themerex_strtolower($value) == 'inherit';
    //in_array(themerex_strtolower($value), array('default', 'inherit'));
}
예제 #8
0
function theme_options_show_field($field, $value = null, &$flags)
{
    if ($value !== null) {
        $field['val'] = $value;
    }
    if (!isset($field['val']) || $field['val'] == '') {
        $field['val'] = 'default';
    }
    if ($flags['inherit'] && isset($field['options']) && is_array($field['options'])) {
        $field['options'] = themerex_array_merge(array('default' => 'Inherit'), $field['options']);
    }
    if (isset($flags['radio_as_select']) && $flags['radio_as_select'] && $field['type'] == 'radio') {
        $field['type'] = 'select';
    }
    if (isset($flags['clear_shortname']) && $flags['clear_shortname'] && isset($field['id'])) {
        $field['id'] = get_option_name($field['id']);
    }
    $menu = '';
    $output = '';
    $name_hook = str_replace(" ", "-", preg_replace("[^A-Za-z0-9]", "", themerex_strtolower($field['name'])));
    if (isset($flags['heading_as_tabs']) && $flags['heading_as_tabs'] && $field['type'] == 'heading') {
        $field['type'] = 'group';
        $field['tab'] = $name_hook;
        $field['tabs'] = array($name_hook => $field['name']);
    }
    if (in_array($field['type'], array('group', 'groupend', 'heading')) && $flags['group_opened']) {
        $output .= '</div>';
        if (!$flags['tabs_opened']) {
            $output .= '</div>';
        } else {
            if (in_array($field['type'], array('groupend', 'heading'))) {
                $output .= '</div>';
                $flags['tabs_opened'] = false;
            }
        }
        $flags['group_opened'] = false;
    }
    if ($field['type'] == 'group') {
        $flags['group_opened'] = true;
        if (isset($field['tabs'])) {
            if (!isset($flags['heading_as_tabs']) || !$flags['heading_as_tabs']) {
                $output .= '<div class="opt_tabs"' . (isset($field['std']) ? ' id="' . $field['std'] . '"' : '') . '><ul>';
            }
            foreach ($field['tabs'] as $id => $title) {
                if (!isset($flags['heading_as_tabs']) || !$flags['heading_as_tabs']) {
                    $output .= '<li id="tab_' . $id . '"><a href="#content_' . $id . '">' . $title . '</a></li>';
                } else {
                    $menu .= '<li id="tab_' . $id . '"><a href="#content_' . $id . '">' . $title . '</a></li>';
                }
            }
            if (!isset($flags['heading_as_tabs']) || !$flags['heading_as_tabs']) {
                $output .= '</ul>';
            }
            $flags['tabs_opened'] = true;
        }
        if (isset($field['tab'])) {
            $output .= '<div class="opt_group opt_content" id="content_' . $field['tab'] . '">';
        } else {
            $output .= '<div class="opt_group' . (isset($field['tabs']) ? ' opt_tabs' : '') . '"' . (isset($field['std']) ? ' id="' . $field['std'] . '"' : '') . '>';
            $output .= '<h3 class="toggle">' . $field['name'] . '</h3><div class="opt_content' . (isset($field['closed']) && $field['closed'] ? ' closed' : '') . '">';
        }
    }
    if (!in_array($field['type'], array("heading", "hidden", "group", "groupend"))) {
        $class = '';
        if (isset($field['class'])) {
            $class = $field['class'];
        }
        $output .= '<div class="section section-' . str_replace(array('list', 'range'), array('select', 'select'), $field['type']) . ' ' . $class . '">' . "\n";
        $output .= '<h3 class="heading">' . $field['name'] . '</h3>' . "\n";
        $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
    }
    if (isset($field['enable'])) {
        $tmp = explode('|', $field['val']);
        $field['val'] = $tmp[0];
        if (isset($tmp[1])) {
            $field['enable'] = $tmp[1];
        }
    }
    switch ($field['type']) {
        case 'hidden':
            $output .= '<input class="of-input" name="' . $field['id'] . '" id="' . $field['id'] . '" type="' . $field['type'] . '" value="' . htmlspecialchars($field['val'] == 'default' ? '' : $field['val']) . '" />';
            break;
        case 'text':
            $inc = isset($field['increment']) && $field['increment'];
            if ($inc) {
                $arr = explode(',', $field['val']);
                $output .= '<div class="of-increment-area">';
            } else {
                $arr = array($field['val']);
            }
            for ($i = 0; $i < count($arr); $i++) {
                $sb = explode('|', $arr[$i]);
                if (count($sb) == 1) {
                    $sb[1] = $i + 1;
                }
                $output .= ($inc ? '<div class="of-increment-item"><input type="hidden" name="' . $field['id'] . '_numbers[]" value="' . $sb[1] . '" />' : '') . '<input class="of-input' . ($inc ? ' of-incremented' : '') . '" name="' . $field['id'] . ($inc ? '[]' : '') . '" id="' . $field['id'] . '" type="' . $field['type'] . '" value="' . htmlspecialchars($sb[0] == 'default' ? '' : $sb[0]) . '" />' . ($inc ? '<a href="#" class="of-increment-button of-increment-del">-</a></div>' : '');
            }
            if ($inc) {
                $output .= '</div><a href="#" class="of-increment-button of-increment-add">' . __('+ Add item', 'themerex') . '</a>';
            }
            break;
        case 'textarea':
            $cols = isset($field['cols']) && $field['cols'] > 10 ? $field['cols'] : '40';
            $rows = isset($field['rows']) && $field['rows'] > 1 ? $field['rows'] : '8';
            $output .= '<textarea class="of-input" name="' . $field['id'] . '" id="' . $field['id'] . '" cols="' . $cols . '" rows="' . $rows . '">' . htmlspecialchars($field['val'] == 'default' ? '' : $field['val']) . '</textarea>';
            break;
        case 'select':
            $multiple = isset($field['multiple']) && $field['multiple'];
            $output .= '<select class="of-input" name="' . $field['id'] . ($multiple ? '[]' : '') . '" id="' . $field['id'] . '"' . (isset($field['size']) ? ' size="' . $field['size'] . '"' : '') . ($multiple ? ' multiple="multiple"' : '') . '>';
            foreach ($field['options'] as $k => $option) {
                if (is_array($option)) {
                    $title = isset($option['name']) ? $option['name'] : (isset($option['title']) ? $option['title'] : $k);
                } else {
                    $title = $option;
                }
                $output .= '<option' . ($multiple ? in_array($k, explode(',', $field['val'])) : $field['val'] == $k ? ' selected="selected"' : '') . ' value="' . $k . '">' . htmlspecialchars($title) . '</option>';
            }
            $output .= '</select>';
            break;
        case 'checklist':
            $multiple = isset($field['multiple']) && $field['multiple'];
            $i = 0;
            $id = $field['id'];
            $output .= '<ul class="checklist">';
            foreach ($field['options'] as $k => $val) {
                $i++;
                $output .= '<li>';
                $output .= '<input type="' . ($multiple ? 'checkbox' : 'radio') . '" value="' . $k . '" name="' . $id . ($multiple ? '[]' : '') . '" id="' . $id . $i . '"' . (in_array($k, explode(',', $field['val'])) ? ' checked="checked"' : '') . '><label for="' . $id . $i . '">' . $val . '</label>';
                $output .= '</li>';
            }
            $output .= '</ul>';
            break;
        case 'list':
            $output .= '<select class="of-input" name="' . $field['id'] . '" id="' . $field['id'] . '">';
            foreach ($field['options'] as $option) {
                $output .= '<option' . ($field['val'] == $option ? ' selected="selected"' : '') . ' value="' . $option . '">' . htmlspecialchars($option) . '</option>';
            }
            $output .= '</select>';
            break;
        case 'range':
            $output .= '<select class="of-input" name="' . $field['id'] . '" id="' . $field['id'] . '">';
            $output .= '<option value="default">Inherit</option>';
            for ($i = $field['from']; $i <= $field['to']; $i++) {
                $output .= '<option value="' . $i . '" ' . ($field['val'] == $i ? ' selected="selected"' : '') . '>' . $i . '</option>';
            }
            $output .= '</select>';
            break;
        case 'fontsize':
            $output .= '<select class="of-typography of-typography-size" name="' . $field['id'] . '" id="' . $field['id'] . '_size">';
            for ($i = 9; $i < 71; $i++) {
                $output .= '<option value="' . $i . '" ' . ($field['val'] == $i ? ' selected="selected"' : '') . '>' . $i . 'px</option>';
            }
            $output .= '</select>';
            break;
        case "radio":
            foreach ($field['options'] as $key => $option) {
                $output .= '<input class="of-input of-radio" type="radio" name="' . $field['id'] . '" value="' . $key . '" ' . ($field['val'] == $key ? ' checked="checked"' : '') . ' id="' . $field['id'] . '_' . $key . '" /><label for="' . $field['id'] . '_' . $key . '">' . $option . '</label>' . (isset($field['style']) && $field['style'] == 'vertical' ? '<br />' : '');
            }
            break;
        case "checkbox":
            $output .= '<input type="checkbox" class="checkbox of-input" name="' . $field['id'] . '" id="' . $field['id'] . '" value="true" ' . ($field['val'] == 'true' ? ' checked="checked"' : '') . ' /><label for="' . $field['id'] . '">' . $field['name'] . '</label>';
            break;
        case "upload":
        case "upload_min":
        case "mediamanager":
            $upload = $field['val'] == 'default' ? '' : $field['val'];
            if (!empty($upload)) {
                $hide = '';
            } else {
                $hide = 'hide';
            }
            $output .= '<input class="of-input" name="' . $field['id'] . '" id="' . $field['id'] . '_upload" value="' . $upload . '" type="' . ($field['type'] == 'upload_min' ? 'hidden' : 'text') . '" />' . '<div class="upload_button_div">' . '<span class="button image_' . ($field['type'] == 'mediamanager' ? 'media' : 'upload') . '_button" id="' . $field['id'] . '"' . ($field['type'] == 'mediamanager' ? ' data-choose="' . (isset($field['multiple']) && $field['multiple'] ? __('Choose Images', 'themerex') : __('Choose Image', 'themerex')) . '"' . ' data-update="' . (isset($field['multiple']) && $field['multiple'] ? __('Add to Gallery', 'themerex') : __('Choose Image', 'themerex')) . '"' . '	data-multiple="' . (isset($field['multiple']) && $field['multiple'] ? 'true' : 'false') . '"' . ' data-linked-field="' . $field['id'] . '_upload"' : '') . '>' . __('Upload Image', 'themerex') . '</span>' . '<span class="button image_reset_button ' . $hide . '" id="reset_' . $field['id'] . '"' . (empty($upload) ? ' style="display:none;"' : '') . '>' . __('Remove', 'themerex') . '</span>' . '</div>' . "\n";
            //			. '<div class="clear"></div>' . "\n";
            if (!empty($upload)) {
                $output .= '<a class="of-uploaded-image" target="_blank" href="' . $upload . '">';
                $ext = pathinfo($upload, PATHINFO_EXTENSION);
                if (in_array(themerex_strtolower($ext), array('jpg', 'png', 'gif'))) {
                    $output .= '<img class="of-option-image" id="image_' . $field['id'] . '" src="' . $upload . '" alt="" />';
                } else {
                    $fname = pathinfo($upload, PATHINFO_BASENAME);
                    $output .= '<span id="image_' . $field['id'] . '">' . $fname . '</span>';
                }
                $output .= '</a>';
                $output .= '<div class="clear"></div>' . "\n";
            }
            break;
        case "color":
            $output .= '<input class="of-color colorSelector" name="' . $field['id'] . '" id="' . $field['id'] . '" type="text" value="' . ($field['val'] == 'default' ? '' : $field['val']) . '" />';
            break;
        case "images":
            $output .= '<input type="hidden" value="' . $field['val'] . '" name="' . $field['id'] . '" />';
            $i = 0;
            foreach ($field['options'] as $key => $option) {
                $i++;
                $selected = '';
                if ($field['val'] == $key || $i == 1 && $field['val'] == '') {
                    $selected = 'of-radio-img-selected';
                }
                $output .= '<span>';
                if ($key == 'default') {
                    $option = get_template_directory_uri() . '/images/spacer.png';
                }
                $output .= '<img src="' . $option . '" data-icon="' . $key . '" alt="" class="of-radio-img-img ' . $selected . '" />';
                $output .= '</span>';
            }
            break;
        case "icons":
            $i = 0;
            if (isset($field['css']) && $field['css'] != '' && file_exists($field['css'])) {
                $field['options'] = parseIconsClasses($field['css']);
            }
            $output .= '</div>';
            $output .= '<input type="hidden" value="' . $field['val'] . '" name="' . $field['id'] . '" />';
            foreach ($field['options'] as $option) {
                $i++;
                $selected = '';
                if ($field['val'] == $option || $i == 1 && $field['val'] == '') {
                    $selected = 'of-radio-icon-selected';
                }
                $output .= '<span>';
                $output .= '<span class="of-radio-icon-icon ' . $option . ' ' . $selected . '" data-icon="' . $option . '"></span>';
                $output .= '</span>';
            }
            $output .= '<div>';
            break;
        case 'socials':
            $arr = explode(',', $field['val']);
            $output .= '<div class="of-increment-area of-socials-area">';
            for ($i = 0; $i < count($arr); $i++) {
                $sb = explode('|', $arr[$i]);
                if (count($sb) == 1) {
                    $sb[1] = $i + 1;
                }
                if (count($sb) == 2) {
                    $sb[2] = '';
                }
                $j = 0;
                $icons = '';
                $button = '';
                foreach ($field['options'] as $k => $option) {
                    $j++;
                    $selected = '';
                    if ($sb[2] == $k || $j == 1 && $sb[2] == '') {
                        $selected = 'of-radio-img-selected';
                        $button = $option;
                    }
                    $icons .= '<span>';
                    //$output .= '<span class="of-radio-icon-icon '. $option . ' ' . $selected .'" onClick="document.getElementById(\'of-radio-icon-'. $field['id'] . $j.'\').checked = true;"></span>';
                    $icons .= '<img src="' . $option . '" data-icon="' . $k . '" alt="" class="of-radio-img-img ' . $selected . '" />';
                    $icons .= '</span>';
                }
                $output .= '<div class="of-increment-item"><input type="hidden" name="' . $field['id'] . '_numbers[]" value="' . $sb[1] . '" />' . '<input class="of-input of-incremented" name="' . $field['id'] . '[]" id="' . $field['id'] . '" type="text" value="' . htmlspecialchars($sb[0] == 'default' ? '' : $sb[0]) . '" />' . '<a href="#" class="of-socials-button"><img src="' . $button . '" alt="" /></a>' . '<a href="#" class="of-increment-button of-increment-del">-</a>' . '<div class="of-socials-icons">' . '<input type="hidden" value="' . $sb[2] . '" name="' . $field['id'] . '_icons[]" />' . $icons . '</div></div>';
            }
            $output .= '</div><a href="#" class="of-increment-button of-increment-add">' . __('+ Add item', 'themerex') . '</a>';
            break;
        case "info":
            $default = $field['std'];
            $output .= '<div class="info">' . $default . '</div>';
            break;
        case "heading":
            if ($flags['heading_opened']) {
                $output .= '</div>' . "\n";
            }
            $jquery_click_hook = "of-option-" . $name_hook;
            $menu .= '<li><a title="' . $field['name'] . '" href="#' . $jquery_click_hook . '">' . $field['name'] . '</a></li>';
            $output .= '<div class="group" id="' . $jquery_click_hook . '"><h2>' . $field['name'] . '</h2>' . "\n";
            $flags['heading_opened'] = true;
            break;
        default:
            if (function_exists('show_custom_field')) {
                $output .= show_custom_field($field, $field['val']);
            }
    }
    if (!in_array($field['type'], array("heading", "hidden", "group", "groupend"))) {
        //$output .= $field['type']!='checklist' ? '<br/>' : '';
        if (!isset($field['desc'])) {
            $descr = '';
        } else {
            $descr = $field['desc'];
        }
        if (isset($field['enable'])) {
            $output .= '<input type="checkbox" class="checkbox of-enable of-input" name="' . $field['id'] . '_enable" id="' . $field['id'] . '_enable" value="1" ' . ($field['enable'] == '1' ? ' checked="checked"' : '') . ' />';
        }
        $output .= '</div><div class="explain">' . $descr . '</div>' . "\n";
        $output .= '<div class="clear"> </div></div></div>' . "\n";
    }
    return array($output, $menu);
}