/**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 protected function get_control()
 {
     $out = '';
     $this->option_args['classes'][] = 'kopa-ui-radio-list';
     $this->option_args['classes'] = array_merge($this->classes, $this->option_args['classes']);
     $this->set_attribute('autocomplete', 'off');
     $this->option_args['type'] = 'radio';
     $this->option_args['is_append_label_before_control'] = FALSE;
     $this->option_args['name'] = $this->name;
     if ($this->options) {
         foreach ($this->options as $option) {
             $option['id'] = "{$this->name}-{$option['value']}";
             $option['classes'] = $this->option_args['classes'];
             if (isset($option['attributes']) && isset($this->attributes)) {
                 $option['attributes'] = array_merge($this->attributes, $option['attributes']);
             } else {
                 $option['attributes'] = $this->attributes;
             }
             if ($option['value'] == $this->value) {
                 $option['attributes']['checked'] = 'checked';
                 $option['classes'][] = 'radio-item-selected';
             }
             $control = new KopaControl();
             $out .= $control->get_html(array_merge($this->option_args, $option));
         }
     }
     return $out;
 }
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 function init()
 {
     $out = '';
     for ($i = 0; $i < count($this->fields); $i++) {
         $field = $this->fields[$i];
         $field['value'] = isset($this->settings[$field['id']]) ? $this->settings[$field['id']] : $field['default'];
         $wrap_classes = array('kopa-metabox-wrap', 'clearfix', 'row');
         $wrap_classes[] = 0 == $i % 2 ? 'even' : 'odd';
         if (0 == $i) {
             $wrap_classes[] = 'kopa-metabox-wrap-first';
         }
         if (count($this->fields) - 1 == $i) {
             $wrap_classes[] = 'kopa-metabox-wrap-last';
         }
         if (!isset($field['label']) || empty($field['label']) || isset($field['is_append_label_before_control']) && false == $field['is_append_label_before_control']) {
             $field['wrap_begin'] = sprintf('<div class="%1$s"><div class="col-md-12 clearfix">', implode(' ', $wrap_classes));
             $field['wrap_end'] = '</div></div>';
         } else {
             $field['wrap_begin'] = sprintf('<div class="%1$s">', implode(' ', $wrap_classes));
             $field['wrap_end'] = '</div>';
             $field['label_begin'] = '<div class="col-sm-3">';
             $field['label_end'] = '</div>';
             $field['control_begin'] = '<div class="col-sm-9">';
             $field['control_end'] = '</div>';
             $field['help_begin'] = '<div class="col-sm-9 col-sm-offset-3">';
             $field['help_end'] = '</div>';
         }
         $out .= KopaControl::get_html($field);
     }
     return $out;
 }
        /**
         * 
         *
         * @package Kopa
         * @subpackage Core
         * @author thethangtran <*****@*****.**>
         * @since 1.0.0
         *      
         */
        public function form($instance)
        {
            $defaults = array();
            // INIT DEFAULTS
            if (!empty($this->groups)) {
                foreach ($this->groups as $group) {
                    $fields = $group['fields'];
                    foreach ($fields as $field) {
                        $slug = empty($field['name']) ? NULL : $field['name'];
                        $default = empty($field['default']) ? NULL : $field['default'];
                        if (!empty($slug)) {
                            $defaults[$slug] = $default;
                        }
                    }
                }
            }
            $instance = wp_parse_args((array) $instance, $defaults);
            // INIT CONTROLS
            ?>
            <div class="kopa-widget-wrap">
                <div class="row clearfix">
                    <?php 
            if (!empty($this->groups)) {
                foreach ($this->groups as $group) {
                    $fields = $group['fields'];
                    $size = isset($group['size']) ? (int) $group['size'] : 12;
                    ?>
                            <div class="<?php 
                    printf('col-sm-%s', $size);
                    ?>
">
                                <?php 
                    $i = 0;
                    foreach ($fields as $field) {
                        $field['value'] = $instance[$field['name']];
                        $wrap_classes = array('kopa-widget-control-wrap', 'clearfix');
                        $wrap_classes[] = 0 == $i % 2 ? 'even' : 'odd';
                        $field['wrap_begin'] = sprintf('<div class="%1$s">', implode(' ', $wrap_classes));
                        $field['wrap_end'] = '</div>';
                        $field['id'] = $this->get_field_id($field['id']);
                        $field['name'] = $this->get_field_name($field['name']);
                        $i++;
                        echo KopaControl::get_html($field);
                    }
                    ?>
                            </div>
                            <?php 
                }
            }
            ?>
                </div>
            </div>
            <?php 
        }
Beispiel #4
0
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 public function get_html()
 {
     $label = $this->get_label();
     $help = $this->get_help();
     $sub_controls = '';
     if (!empty($this->sub_fields)) {
         foreach ($this->sub_fields as $field) {
             $sub_controls .= KopaControl::get_html($field);
         }
     }
     $pattern = $this->is_append_label_before_control ? '%1$s %2$s' : '%2$s %1$s';
     $control = $this->control_begin . $this->get_control() . $sub_controls . $this->control_end;
     return $this->wrap_begin . sprintf($pattern, $label, $control) . $help . $this->wrap_end;
 }
Beispiel #5
0
 /**
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0         
  */
 function kopa_save_theme_options_loop($field, &$opts)
 {
     $name = $field['name'];
     $data = isset($_POST[$name]) ? $_POST[$name] : (isset($field['default']) ? $field['default'] : '');
     $value = KopaControl::filter_post_data($field, $data);
     $opts[$name] = $value;
     if (isset($field['sub_fields'])) {
         $sub_fields = $field['sub_fields'];
         foreach ($sub_fields as $sub_field) {
             kopa_save_theme_options_loop($sub_field, $opts);
         }
     }
     if ('radio-list' == $field['type']) {
         $options = $field['options'];
         if ($options) {
             foreach ($options as $option) {
                 if (isset($option['sub_fields'])) {
                     foreach ($option['sub_fields'] as $sub_field) {
                         kopa_save_theme_options_loop($sub_field, $opts);
                     }
                 }
             }
         }
     }
 }
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 protected function get_control()
 {
     global $google_font, $font_opts;
     $font_opts = array_merge(array('off' => __('-- None (turn off this feature) --', kopa_get_domain())), $font_opts);
     $styles = '';
     $weight_opts = array('400' => 'regular');
     if ('off' != $this->value['family']) {
         $current_font = $google_font['items'][$this->value['family']];
         foreach ($current_font['variants'] as $weight) {
             $tmp_value = $weight;
             if ('regular' == $weight) {
                 $tmp_value = '400';
             } else {
                 if ('italic' == $weight) {
                     $tmp_value = '400italic';
                 }
             }
             $weight_opts[$tmp_value] = $weight;
         }
         $font_family = str_replace(' ', '+', $google_font['items'][$this->value['family']]['family']);
         $styles = sprintf('font-family:\'%s\'; font-size:%spx; font-weight:%s; line-height:%spx; text-transform: %s;', $font_family, $this->value['size'], $this->value['weight'], $this->value['line-height'], $this->value['text-transform']);
         if (strlen($this->value['weight']) > 3) {
             $styles .= "font-style:italic;";
         } else {
             $styles .= "font-style:normal;";
         }
         $cbos_opacity = 'opacity: 1;';
     } else {
         $styles = 'display:none;';
         $cbos_opacity = 'opacity: 0.3;';
     }
     $html = '';
     if ($this->is_show_caption) {
         #HEADER
         $html .= '<div class="kopa-font-ui-caption row clearfix">';
         $html .= '<div class="col-xs-4"><span>';
         $html .= sprintf('Font family', kopa_get_domain());
         $html .= '</span></div>';
         $html .= '<div class="col-xs-2"><span>';
         $html .= sprintf('Font size', kopa_get_domain());
         $html .= '</span></div>';
         $html .= '<div class="col-xs-2"><span>';
         $html .= sprintf('Font weight', kopa_get_domain());
         $html .= '</span></div>';
         $html .= '<div class="col-xs-2"><span>';
         $html .= sprintf('Line height', kopa_get_domain());
         $html .= '</span></div>';
         $html .= '<div class="col-xs-2"><span>';
         $html .= sprintf('Text Transform', kopa_get_domain());
         $html .= '</span></div>';
         $html .= '</div>';
     }
     #BODY
     $html .= '<div class="row clearfix">';
     $html .= '<div class="col-xs-4">';
     $html .= KopaControl::get_html(array('type' => 'select', 'id' => sprintf('%s-family', $this->name), 'name' => sprintf('%s[family]', $this->name), 'options' => $font_opts, 'value' => $this->value['family'], 'attributes' => array('onchange' => sprintf('KopaThemeOptions.onChangeFontFamily(event, jQuery(this), jQuery(\'#%s-preview\'));', $this->name)), 'classes' => array('kopa-font-family', 'percent100')));
     $html .= '</div>';
     $html .= '<div class="col-xs-2">';
     $html .= KopaControl::get_html(array('type' => 'select-number', 'id' => sprintf('%s-size', $this->name), 'name' => sprintf('%s[size]', $this->name), 'min' => 1, 'max' => 70, 'step' => 1, 'suffix' => ' px', 'attributes' => array('style' => $cbos_opacity, 'onchange' => sprintf('KopaThemeOptions.onChangeFontSize(event, jQuery(this), jQuery(\'#%s-preview\'));', $this->name)), 'value' => (int) $this->value['size'], 'classes' => array('kopa-font-size', 'percent100')));
     $html .= '</div>';
     $html .= '<div class="col-xs-2">';
     $html .= KopaControl::get_html(array('type' => 'select', 'id' => sprintf('%s-weight', $this->name), 'name' => sprintf('%s[weight]', $this->name), 'options' => $weight_opts, 'attributes' => array('style' => $cbos_opacity, 'onchange' => sprintf('KopaThemeOptions.onChangeFontWeight(event, jQuery(this), jQuery(\'#%s-preview\'));', $this->name)), 'value' => $this->value['weight'], 'classes' => array('kopa-font-weight', 'percent100')));
     $html .= '</div>';
     $html .= '<div class="col-xs-2">';
     $html .= KopaControl::get_html(array('type' => 'select-number', 'id' => sprintf('%s-line-height', $this->name), 'name' => sprintf('%s[line-height]', $this->name), 'min' => 1, 'max' => 70, 'step' => 1, 'suffix' => ' px', 'attributes' => array('style' => $cbos_opacity, 'onchange' => sprintf('KopaThemeOptions.onChangeLineHeight(event, jQuery(this), jQuery(\'#%s-preview\'));', $this->name)), 'value' => (int) $this->value['line-height'], 'classes' => array('kopa-line-height', 'percent100')));
     $html .= '</div>';
     $html .= '<div class="col-xs-2">';
     $html .= KopaControl::get_html(array('type' => 'select', 'id' => sprintf('%s-text-transform', $this->name), 'name' => sprintf('%s[text-transform]', $this->name), 'attributes' => array('style' => $cbos_opacity, 'onchange' => sprintf('KopaThemeOptions.onChangeTextTransform(event, jQuery(this), jQuery(\'#%s-preview\'));', $this->name)), 'value' => $this->value['text-transform'], 'classes' => array('kopa-text-transform', 'percent100'), 'options' => array('none' => __('--None--', kopa_get_domain()), 'capitalize' => __('Capitalize', kopa_get_domain()), 'lowercase' => __('Lower Case', kopa_get_domain()), 'uppercase' => __('Upper Case', kopa_get_domain()))));
     $html .= '</div>';
     $html .= '</div>';
     $html .= '<div class="row clearfix">';
     $html .= '<div class="col-xs-12">';
     $html .= '<p style="' . $styles . '" id="' . $this->name . '-preview" class="kopa-font-ui-preview"><span>' . __('Grumpy wizards make toxic brew for the evil Queen and Jack', kopa_get_domain()) . '</span></p>';
     $html .= '</div>';
     $html .= '</div>';
     return $html;
 }
    ?>
                    <div class="<?php 
    echo implode(' ', $tab_classes);
    ?>
" id="<?php 
    printf('tab-%s', $slug);
    ?>
">
                        <p class="kopa-tab-title"><?php 
    echo $tab['title'];
    ?>
</p>
                        <div class="kopa-tab-body">
    <?php 
    $args = array('type' => 'layout', 'id' => $slug, 'name' => $slug, 'value' => $tmp_kopaSettings[$slug], 'template_hierarchy' => $slug);
    echo KopaControl::get_html($args);
    ?>
                        </div>
                    </div>
    <?php 
}
?>
            </div>
            <p class="frm-submit-block frm-submit-bottom-block">
                <button type="submit" class="btn btn-primary"><i class="dashicons dashicons-yes"></i>&nbsp;<?php 
_e('Save', kopa_get_domain());
?>
</button>
            </p>
<?php 
wp_nonce_field("kopa_save_layout_setting", "ajax_nonce");
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 public static function get_form($template_hierarchy, $setting = array(), $name = '')
 {
     $kopa_sidebar_position = KopaInit::get_positions();
     $kopa_layout = KopaInit::get_layouts();
     $kopa_template_hierarchy = KopaInit::get_template_hierarchy();
     $sidebars = get_option(KOPA_OPT_PREFIX . 'sidebars');
     $obj = $kopa_template_hierarchy[$template_hierarchy];
     $html = '<div class="layout-manage-wrap">';
     $html .= '<div class="row clearfix">';
     #FORM
     $html .= '<div class="col-md-5">';
     #CBO Layouts
     $cbo_layout_opts = array();
     foreach ($obj['layouts'] as $tmp_layout_slug) {
         $tmp_layout = $kopa_layout[$tmp_layout_slug];
         $cbo_layout_opts[$tmp_layout['slug']] = $tmp_layout['title'];
     }
     $tmp_cbo = array('type' => 'select', 'id' => sprintf("cbo_layout_%s", $name), 'name' => sprintf("%s[layout_slug]", $name), 'label' => __('Select the layout', kopa_get_domain()), 'options' => $cbo_layout_opts, 'wrap_begin' => '<div class="row-layout-wrap row clearfix">', 'wrap_end' => '</div>', 'control_begin' => '<div class="col-md-12">', 'control_end' => '</div>', 'label_begin' => '<div class="col-layout-title col-md-12">', 'label_end' => '</div>', 'classes' => array('cbo_layout'), 'value' => $setting['layout_slug'], 'attributes' => array('onchange' => 'KopaLayout.onChange(event, jQuery(this));'));
     $html .= KopaControl::get_html($tmp_cbo);
     #END-CBO Layouts
     foreach ($obj['layouts'] as $tmp_layout_slug) {
         $tmp_layout = $kopa_layout[$tmp_layout_slug];
         $classes = array('row-sidebars-wrap', 'row', 'clearfix');
         $classes[] = $setting['layout_slug'] == $tmp_layout['slug'] ? 'row-sidebars-active' : 'row-sidebars-deactive';
         $classes[] = "row-sidebars-for-layout-{$tmp_layout['slug']}";
         $html .= sprintf('<div class="%s">', implode(' ', $classes));
         $html .= '<div class="col-md-12">';
         $tmp_positions = $tmp_layout['positions'];
         for ($i = 0; $i < count($tmp_positions); $i++) {
             $tmp_position = $tmp_positions[$i];
             $tmp_cbo = array('type' => 'select', 'id' => sprintf("cbo_%s_%s", $name, $tmp_position), 'name' => sprintf("%s[sidebars][%s][]", $name, $tmp_layout_slug), 'options' => $sidebars, 'label' => $kopa_sidebar_position[$tmp_position]['title'], 'wrap_begin' => '<div class="row-sidebar-wrap row clearfix">', 'wrap_end' => '</div>', 'control_begin' => '<div class="col-xs-7">', 'control_end' => '</div>', 'label_begin' => '<div class="col-xs-5 col-sidebar-title">', 'label_end' => '</div>', 'classes' => array('cbo_sidebar'), 'value' => $setting['sidebars'][$tmp_layout_slug][$i]);
             $html .= KopaControl::get_html($tmp_cbo);
         }
         $html .= '</div>';
         $html .= '</div>';
     }
     $html .= '</div>';
     #END-FORM
     #THUMBNAIL
     $html .= '<div class="col-md-7 col-layout-thumb">';
     foreach ($obj['layouts'] as $tmp_layout_slug) {
         $classes = array('img-responsive');
         $classes[] = $setting['layout_slug'] == $tmp_layout_slug ? 'layout-thumb-active' : 'layout-thumb-deactive';
         $classes[] = "thumb-for-layout-{$tmp_layout_slug}";
         $html .= sprintf('<img src="%s" class="%s">', get_template_directory_uri() . "/library/images/layout/{$tmp_layout_slug}.png", implode(' ', $classes));
     }
     $html .= '</div>';
     #END-THUMBNAIL
     $html .= '</div>';
     $html .= '</div>';
     return $html;
 }
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 private function filter_post_data($data, $field)
 {
     return KopaControl::filter_post_data($field, $data);
 }
    ?>
">
                    <p class="kopa-tab-title"><?php 
    echo $tab['title'];
    ?>
</p>
                    <div class="kopa-tab-body">
                        <?php 
    foreach ($tab['fields'] as $field) {
        $field['value'] = get_option(KOPA_OPT_PREFIX . $field['name']);
        if (empty($field['label']) || !isset($field['label'])) {
            $theme_options_args['control_begin'] = '<div class="col-xs-12">';
        } else {
            $theme_options_args['control_begin'] = '<div class="col-xs-9">';
        }
        echo KopaControl::get_html(array_merge($theme_options_args, $field));
    }
    ?>
                    </div>
                </div>
                <?php 
}
?>
        </div>           
    </div>
</div>
<?php 
wp_nonce_field("kopa_add_sidebar", "kopa_add_sidebar_ajax_nonce", false);
?>
            
<?php 
Beispiel #11
0
/**
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @since 1.0.0
 */
function kopa_in_widget_form($t, $return, $instance)
{
    if (!in_array($t->id_base, array('kopa_slider_text', 'kopa_owl_slider'))) {
        return;
    }
    $default = array('background-color' => '#FFFFFF', 'background-opacity' => 1, 'background-image' => '', 'background-type' => '', 'parallax-height' => 600);
    $instance = wp_parse_args((array) $instance, $default);
    $background = array('title' => __('Parallax Background', kopa_get_domain()), 'help' => NULL, 'fields' => array());
    $background['fields'][] = array('type' => 'color', 'id' => 'background-color', 'name' => 'background-color', 'default' => '', 'classes' => array(), 'label' => NULL, 'help' => NULL);
    $background['fields'][] = array('type' => 'select-number', 'id' => 'background-opacity', 'name' => 'background-opacity', 'label' => __('Opacity (only for background color)', kopa_get_domain()), 'default' => 100, 'min' => 0, 'max' => 100, 'step' => 5, 'suffix' => '%');
    $background['fields'][] = array('type' => 'media', 'id' => 'background-image', 'name' => 'background-image', 'default' => '', 'classes' => array(), 'label' => __('Image', kopa_get_domain()), 'help' => NULL);
    $background['fields'][] = array('type' => 'select', 'id' => 'background-type', 'name' => 'background-type', 'default' => 'repeat', 'classes' => array(), 'label' => __('Type', kopa_get_domain()), 'help' => NULL, 'options' => array('repeat' => __('Repeat', kopa_get_domain()), 'no-repeat' => __('No Repeat', kopa_get_domain()), 'cover' => __('Cover', kopa_get_domain())));
    $background['fields'][] = array('type' => 'number', 'id' => 'parallax-height', 'name' => 'parallax-height', 'default' => 0, 'classes' => array(), 'label' => __('Parallax height', kopa_get_domain()), 'help' => __('Enter <code>0</code> to disable parallax.', kopa_get_domain()));
    $groups = array('bonus-background' => $background);
    foreach ($groups as $key => $group) {
        ?>
        <div class="kopa-widget-bonus-wrap">
            <p class="kopa-widget-bonus-caption clearfix">
                <?php 
        echo $group['title'];
        ?>
                <?php 
        $group_checked = '';
        $group_inner_style = 'display: none;';
        if (isset($instance[$key]) && 'true' == $instance[$key]) {
            $group_checked = 'checked=checked';
            $group_inner_style = 'display: block;';
        }
        ?>
                <input onclick="KopaWidget.clickBonusSection(event, jQuery(this));" <?php 
        echo $group_checked;
        ?>
 class="pull-right" type="checkbox" value="true" name="<?php 
        echo $t->get_field_name($key);
        ?>
" id="<?php 
        echo $t->get_field_name($key);
        ?>
">
                <?php 
        printf('<i>%s</i>', $group['help']);
        ?>
            </p>
            <div class="kopa-widget-bonus-inner" style="<?php 
        echo $group_inner_style;
        ?>
">
                <?php 
        $i = 0;
        foreach ($group['fields'] as $field) {
            $field['value'] = $instance[$field['name']];
            $wrap_classes = array('kopa-widget-control-wrap', 'clearfix');
            $wrap_classes[] = 0 == $i % 2 ? 'even' : 'odd';
            $field['wrap_begin'] = sprintf('<div class="%1$s">', implode(' ', $wrap_classes));
            $field['wrap_end'] = '</div>';
            $field['id'] = $t->get_field_id($field['id']);
            $field['name'] = $t->get_field_name($field['name']);
            $i++;
            echo KopaControl::get_html($field);
        }
        ?>
            </div>
        </div>
        <?php 
    }
    ?>
    <?php 
    return array($t, $return, $instance);
}