Example #1
0
 /**
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0         
  */
 function kopa_add_sidebar()
 {
     check_ajax_referer('kopa_add_sidebar', 'ajax_nonce');
     $new_sidebar = $_POST['new_sidebar'];
     $new_sidebar_slug = KopaUtil::str_uglify($new_sidebar);
     $result = array();
     $result['log'] = '';
     $result['html'] = '';
     // check exists with hidden sidebar
     if ('sidebar_hide' == $new_sidebar_slug) {
         $result['log'] = __('This sidebar is existing. Please enter other name.', kopa_get_domain());
     } else {
         //get all sidebars
         $sidebars = get_option(KOPA_OPT_PREFIX . 'sidebars');
         $exist_sidebars = array_keys($sidebars);
         // check exists with current sidebars
         if (in_array($new_sidebar_slug, $exist_sidebars)) {
             $result['log'] = __('This sidebar is existing. Please enter other name.', kopa_get_domain());
         } else {
             // add new
             $sidebars[$new_sidebar_slug] = $new_sidebar;
             update_option(KOPA_OPT_PREFIX . 'sidebars', $sidebars);
             // return html
             $result['html'] = '<tr>';
             $result['html'] .= sprintf('<td><span>%s<span></td>', $new_sidebar);
             $result['html'] .= sprintf('<td><a href="#" onclick="KopaSidebar.rename(event, jQuery(this),\'%s\');" class="btn btn-success btn-sm"><i class="dashicons dashicons-edit"></i></a></td>', $new_sidebar_slug);
             $result['html'] .= sprintf('<td><a href="#" onclick="KopaSidebar.remove(event, jQuery(this),\'%s\',\'%s\');" class="btn btn-danger btn-sm"><i class="dashicons dashicons-trash"></i></a></td>', $new_sidebar_slug, $new_sidebar);
             $result['html'] .= '</tr>';
         }
     }
     echo json_encode($result);
     exit;
 }
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 public function uglify($string)
 {
     return KopaUtil::str_uglify($string);
 }
Example #3
0
    } else {
        $tab_classes[] = 'tab_deactive';
    }
    ?>
                    <div class="<?php 
    echo implode(' ', $tab_classes);
    ?>
" id="<?php 
    printf('tab-%s', $slug);
    ?>
">
                        <?php 
    foreach ($tab['groups'] as $groups) {
        ?>
                            <div id="<?php 
        printf('kopa-group-%s', KopaUtil::str_uglify($groups['title']));
        ?>
">                        
                                <p class="kopa-tab-title clearfix"><span class="kopa-tab-title-left pull-left"><?php 
        echo $groups['title'];
        ?>
</span></p>
                                <div class="kopa-tab-body" style="display: <?php 
        echo $sub_tab_display;
        ?>
;">
                                    <?php 
        foreach ($groups['fields'] as $field) {
            $field['value'] = KopaOptions::get_option($field['name'], $field['default']);
            if (empty($field['label']) || !isset($field['label'])) {
                $theme_options_args['control_begin'] = '<div class="col-xs-12">';