Exemplo n.º 1
0
 function beforeSave($options = array())
 {
     $pathCategories = '';
     if (empty($this->id)) {
         // On created
         if (!empty($this->data['ProductCategory']['name'])) {
             if (!empty($this->data['ParentCategory']['slug'])) {
                 $pathCategories = $this->data['ParentCategory']['slug'] . '_';
             }
             $pathCategories .= trim($this->data['ProductCategory']['name']);
             $this->data['ProductCategory']['slug'] = generateSlug(trim($pathCategories));
         }
     } else {
         //$ TODO: HACKHACK to rebuild proper slugs -- remove this section !!!
         // On updated
         if (!empty($this->data['ProductCategory']['name'])) {
             if (!empty($this->data['ParentCategory']['slug'])) {
                 $pathCategories = $this->data['ParentCategory']['slug'] . '_';
             }
             $pathCategories .= trim($this->data['ProductCategory']['name']);
             $this->data['ProductCategory']['slug'] = Inflector::slug(trim($pathCategories));
         }
     }
     return true;
 }
Exemplo n.º 2
0
 public function create($options = array())
 {
     $valid = validate($options, $this->data_types, array('name'));
     // Make sure all the options are valid
     if ($valid === true) {
         // See if this record already exists
         $options['slug'] = generateSlug($options['name']);
         $tag = $this->read("tags.slug = '" . $options['slug'] . "'", 1, 1);
         // If not, add it
         if (!isset($tag->tag_id)) {
             $q = $this->db->insert_string($this->table, $options);
             $res = $this->db->query($q);
             // Check for errors
             $this->sendException();
             // If good, return full label
             if ($res === true) {
                 $tag_id = $this->db->insert_id();
                 return $this->read($tag_id);
             }
             // Else return error
             return false;
         }
         // If already exists, just return it
         return $tag;
     }
     return formatErrors($valid);
 }
Exemplo n.º 3
0
function be_themes_widgets_init()
{
    global $be_themes_data;
    register_sidebar(array('name' => __('Default Right Sidebar', 'paws'), 'id' => 'right-sidebar', 'description' => __('Widget area of Right Sidebar template pages', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h5>', 'after_title' => '</h5>'));
    register_sidebar(array('name' => __('Default Left Sidebar', 'be-themes'), 'id' => 'left-sidebar', 'description' => __('Header Widget Area', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h5>', 'after_title' => '</h5>'));
    register_sidebar(array('name' => __('Footer Column 1', 'be-themes'), 'id' => 'footer-widget-1', 'description' => __('Footer widget area', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h5>', 'after_title' => '</h5>'));
    register_sidebar(array('name' => __('Footer Column 2', 'be-themes'), 'id' => 'footer-widget-2', 'description' => __('Footer widget area', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h5>', 'after_title' => '</h5>'));
    register_sidebar(array('name' => __('Footer Column 3', 'be-themes'), 'id' => 'footer-widget-3', 'description' => __('Footer widget area', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h5>', 'after_title' => '</h5>'));
    register_sidebar(array('name' => __('Footer Column 4', 'be-themes'), 'id' => 'footer-widget-4', 'description' => __('Footer widget area', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h5>', 'after_title' => '</h5>'));
    if (!empty($be_themes_data['custom_sidebars']) && sizeof($be_themes_data['custom_sidebars']) > 0) {
        foreach ($be_themes_data['custom_sidebars'] as $sidebar) {
            register_sidebar(array('name' => __($sidebar, 'be-themes'), 'id' => generateSlug($sidebar, 45), 'description' => '', 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h5>', 'after_title' => '</h5>'));
        }
    }
}
Exemplo n.º 4
0
function be_themes_widgets_init()
{
    global $be_themes_data;
    register_sidebar(array('name' => __('Default Sidebar', 'be-themes'), 'id' => 'default-sidebar', 'description' => __('Widget area of Sidebar template pages', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h6>', 'after_title' => '</h6>'));
    register_sidebar(array('name' => __('Footer Column 1', 'be-themes'), 'id' => 'footer-widget-1', 'description' => __('Footer widget area', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h6>', 'after_title' => '</h6>'));
    register_sidebar(array('name' => __('Footer Column 2', 'be-themes'), 'id' => 'footer-widget-2', 'description' => __('Footer widget area', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h6>', 'after_title' => '</h6>'));
    register_sidebar(array('name' => __('Footer Column 3', 'be-themes'), 'id' => 'footer-widget-3', 'description' => __('Footer widget area', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h6>', 'after_title' => '</h6>'));
    register_sidebar(array('name' => __('Footer Column 4', 'be-themes'), 'id' => 'footer-widget-4', 'description' => __('Footer widget area', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h6>', 'after_title' => '</h6>'));
    register_sidebar(array('name' => __('Slidebar', 'be-themes'), 'id' => 'sliderbar-area', 'description' => __('Widget area of Slidebar', 'be-themes'), 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h6>', 'after_title' => '</h6>'));
    if (isset($be_themes_data['custom_sidebars']) && sizeof($be_themes_data['custom_sidebars']) > 0 && !empty($be_themes_data['custom_sidebars'])) {
        //var_dump( $be_themes_data['custom_sidebars'] );
        foreach ($be_themes_data['custom_sidebars'] as $sidebar) {
            if (!empty($sidebar)) {
                register_sidebar(array('name' => $sidebar, 'id' => generateSlug($sidebar, 45), 'description' => '', 'before_widget' => '<div class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h6>', 'after_title' => '</h6>'));
            }
        }
    }
}
Exemplo n.º 5
0
function memberlite_registerCustomSidebar($name, $id = NULL)
{
    if (empty($id)) {
        $id = generateSlug($name, 45);
    }
    return register_sidebar(array('name' => __($name, 'memberlite'), 'id' => $id, 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
}
function show_cmsms_meta_box()
{
    global $post, $custom_all_meta_fields;
    $cmsms_option = cmsms_get_global_options();
    echo '<input type="hidden" name="custom_meta_box_nonce" value="' . wp_create_nonce(basename(__FILE__)) . '" />';
    foreach ($custom_all_meta_fields as $field) {
        $meta = get_post_meta($post->ID, $field['id'], true);
        if (isset($field['std']) && $meta === '') {
            $meta = $field['std'];
        }
        if (!isset($field['hide'])) {
            $field['hide'] = 'false';
        }
        if ($field['type'] != 'tabs' && $field['type'] != 'tab_start' && $field['type'] != 'tab_finish' && $field['type'] != 'content_start' && $field['type'] != 'content_finish') {
            echo '<tr class="cmsms_tr_' . $field['type'] . '"' . ($field['hide'] == 'true' ? ' style="display:none;"' : '') . '>' . '<th>' . '<label for="' . $field['id'] . '">' . $field['label'] . '</label>' . '</th>' . '<td>';
        }
        switch ($field['type']) {
            case 'tab_start':
                echo '<div id="' . $field['id'] . '" class="nav-tab-content' . ($field['std'] === 'true' ? ' nav-tab-content-active' : '') . '">' . '<table class="form-table">';
                break;
            case 'tab_finish':
                echo '</table>' . '</div>';
                break;
            case 'content_start':
                echo '<table id="' . $field['id'] . '" class="form-table' . ($field['box'] === 'true' ? ' cmsms_box' : '') . '"' . ($field['hide'] === 'true' ? ' style="display:none;"' : '') . '>';
                break;
            case 'content_finish':
                echo '</table>';
                break;
            case 'tabs':
                echo '<h4 class="nav-tab-wrapper" id="' . $field['id'] . '">';
                foreach ($field['options'] as $option) {
                    echo '<a href="#' . $option['value'] . '" class="nav-tab' . ($field['std'] === $option['value'] ? ' nav-tab-active' : '') . '">' . $option['label'] . '</a>';
                }
                echo '</h4>';
                break;
            case 'text':
                echo '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . $meta . '" size="30" />' . '<br />' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'textcode':
                echo '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . htmlspecialchars(stripslashes($meta)) . '" size="30" />' . '<br />' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'text_long':
                echo '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . $meta . '" size="70" />' . '<br />' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'number':
                echo '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . $meta . '" size="5" />' . '<br />' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'textarea':
                echo '<textarea name="' . $field['id'] . '" id="' . $field['id'] . '" cols="50" rows="4">' . $meta . '</textarea>' . '<br />' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'checkbox':
                echo '<input type="checkbox" name="' . $field['id'] . '" id="' . $field['id'] . '" value="true"' . ($meta === 'false' ? '' : ' checked="checked"') . ' /> &nbsp; ' . '<label for="' . $field['id'] . '">' . $field['desc'] . '</label>';
                break;
            case 'radio':
                foreach ($field['options'] as $option) {
                    echo '<input type="radio" name="' . $field['id'] . '" id="' . $field['id'] . '_' . $option['value'] . '" value="' . $option['value'] . '"' . ($meta === $option['value'] ? ' checked="checked"' : '') . ' /> &nbsp; ' . '<label for="' . $field['id'] . '_' . $option['value'] . '">' . $option['label'] . '</label>' . '<br />';
                }
                echo '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'radio_img':
                echo '<table>' . '<tr>';
                foreach ($field['options'] as $option) {
                    echo '<td style="text-align:center;">' . '<input type="radio" name="' . $field['id'] . '" id="' . $field['id'] . '_' . $option['value'] . '" value="' . $option['value'] . '"' . ($meta === $option['value'] ? ' checked="checked"' : '') . ' />' . '<br />' . '<label for="' . $field['id'] . '_' . $option['value'] . '">' . '<img src="' . $option['img'] . '" alt="' . $option['label'] . '" />' . '<br />' . $option['label'] . '</label>' . '</td>';
                }
                echo '</tr>' . '</table>' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'checkbox_group':
                $i = 0;
                foreach ($field['options'] as $option) {
                    echo '<input type="checkbox" value="' . $option['value'] . '" name="' . $field['id'] . '[' . $i . ']" id="' . $field['id'] . '_' . $option['value'] . '"' . ($meta && in_array($option['value'], $meta) ? ' checked="checked"' : '') . ' /> &nbsp; ' . '<label for="' . $field['id'] . '_' . $option['value'] . '">' . $option['label'] . '</label>' . '<br />';
                    $i++;
                }
                echo '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'select':
                echo '<select name="' . $field['id'] . '" id="' . $field['id'] . '">';
                foreach ($field['options'] as $option) {
                    echo '<option value="' . $option['value'] . '"' . ($meta === $option['value'] ? ' selected="selected"' : '') . '>' . $option['label'] . ' &nbsp;</option>';
                }
                echo '</select>' . '<br />' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'select_sidebar':
                echo '<select name="' . $field['id'] . '" id="' . $field['id'] . '">' . '<option value="">' . __('Default Sidebar', 'cmsmasters') . ' &nbsp;</option>';
                if (!empty($cmsms_option[CMSMS_SHORTNAME . '_sidebar'])) {
                    foreach ($cmsms_option[CMSMS_SHORTNAME . '_sidebar'] as $sidebar_id => $sidebar_name) {
                        echo '<option value="' . generateSlug($sidebar_name, 45) . '"' . ($meta !== '' && $meta === generateSlug($sidebar_name, 45) ? ' selected="selected"' : '') . '>' . $sidebar_name . ' &nbsp;</option>';
                    }
                }
                echo '</select>' . '<br />' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'select_slider':
                $sliderManager = new cmsmsSliderManager();
                $sliders = $sliderManager->getSliders();
                echo '<select name="' . $field['id'] . '" id="' . $field['id'] . '">' . '<option value="">' . __('Select Slider', 'cmsmasters') . ' &nbsp;</option>';
                if (!empty($sliders)) {
                    foreach ($sliders as $slider) {
                        echo '<option value="' . $slider['id'] . '"' . ($meta !== '' && (int) $meta === $slider['id'] ? ' selected="selected"' : '') . '>' . $slider['name'] . ' &nbsp;</option>';
                    }
                }
                echo '</select>' . '<br />' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'select_post_categ':
                $categories = get_categories();
                echo '<select name="' . $field['id'] . '" id="' . $field['id'] . '">' . '<option value="">' . __('Select Blog Category', 'cmsmasters') . ' &nbsp;</option>';
                foreach ($categories as $category) {
                    echo '<option value="' . $category->cat_ID . '"' . ($meta !== '' && (int) $meta === $category->cat_ID ? ' selected="selected"' : '') . '>' . $category->cat_name . ' &nbsp;</option>';
                }
                echo '</select>' . '<br />' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'select_project_type':
                $types = get_terms('pj-categs', array('orderby' => 'name', 'hide_empty' => 0));
                echo '<select name="' . $field['id'] . '" id="' . $field['id'] . '">' . '<option value="">' . __('Select Project Type', 'cmsmasters') . ' &nbsp;</option>';
                if (is_array($types) && !empty($types)) {
                    foreach ($types as $type) {
                        echo '<option value="' . $type->slug . '"' . ($meta !== '' && $meta === $type->slug ? ' selected="selected"' : '') . '>' . $type->name . ' &nbsp;</option>';
                    }
                }
                echo '</select>' . '<br />' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'select_tl_categ':
                $tl_categs = get_terms('tl-categs', array('hide_empty' => 0));
                echo '<select name="' . $field['id'] . '" id="' . $field['id'] . '">' . '<option value="">' . __('Select Testimonial Category', 'cmsmasters') . ' &nbsp;</option>';
                if (is_array($tl_categs) && !empty($tl_categs)) {
                    foreach ($tl_categs as $tl_categ) {
                        echo '<option value="' . $tl_categ->slug . '"' . ($meta !== '' && $meta === $tl_categ->slug ? ' selected="selected"' : '') . '>' . $tl_categ->name . ' &nbsp;</option>';
                    }
                }
                echo '</select>' . '<br />' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'image':
                $image = $field['std'];
                if (is_numeric($image)) {
                    $image = wp_get_attachment_image_src($image, 'medium');
                    $image = $image[0];
                }
                echo '<span class="custom_default_image" style="display:none">' . $image . '</span>';
                if (is_numeric($meta)) {
                    $image = wp_get_attachment_image_src($meta, 'medium');
                    $image = $image[0];
                }
                echo '<input id="' . $field['id'] . '" name="' . $field['id'] . '" type="hidden" class="custom_upload_image" value="' . $meta . '" />' . '<img src="' . $image . '" class="custom_preview_image" alt="" style="max-width:250px;" />' . '<br />' . '<input id="' . $field['id'] . '_image_button" class="cmsms_options_upload_image_button button" type="button" value="' . __('Choose Image', 'cmsmasters') . '" />' . '<small>&nbsp; ' . '<a href="#" class="custom_clear_image_button">' . ($field['cancel'] == 'true' ? __('Cancel', 'cmsmasters') : __('Default Image', 'cmsmasters')) . '</a>' . '</small>' . '<div style="clear:both;"></div>' . '<br />' . '<span class="description">' . $field['desc'] . '</span>' . '<script type="text/javascript">' . 'jQuery(document).ready(function () { ' . '(function ($) { ' . "\$('#" . $field['id'] . "_image_button').bind('click', function (e) { " . 'e.preventDefault(); ' . '$(e.target).cmsmsMediaUploader( { ' . "frameId : 'cmsms-" . $field['id'] . "-media-frame', " . "frameClass : 'media-frame cmsms-media-frame cmsms-" . $field['id'] . "-media-frame', " . "frameTitle : '" . __('Choose image', 'cmsmasters') . "', " . "frameButton : '" . __('Choose', 'cmsmasters') . "', " . 'multiple : false ' . '} ); ' . '} ); ' . '} )(jQuery); ' . '} ); ' . '</script>';
                break;
            case 'color':
                echo '<input type="text" id="' . $field['id'] . '" name="' . $field['id'] . '" value="' . $meta . '" class="my-color-field" data-default-color="' . $field['std'] . '" />' . '<script type="text/javascript">' . 'jQuery(document).ready(function () { ' . '(function ($) { ' . "\$('#" . $field['id'] . "').wpColorPicker(); " . '} )(jQuery); ' . '} ); ' . '</script>';
                break;
            case 'icon':
                echo '<input type="hidden" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . $meta . '" />' . '<ul class="cmsms_heading_icons_list">';
                if (!empty($cmsms_option[CMSMS_SHORTNAME . '_heading_icons'])) {
                    foreach ($cmsms_option[CMSMS_SHORTNAME . '_heading_icons'] as $icon_numb => $icon_id) {
                        $image = wp_get_attachment_image_src($icon_id, 'thumbnail');
                        echo '<li id="cmsms_heading_icon_' . $icon_numb . '" class="cmsms_heading_icon ' . ($meta !== '' && $meta === $icon_id ? ' selected' : '') . '">' . '<a href="' . $icon_id . '">' . '<img src="' . $image[0] . '" alt="" />' . '</a>' . '</li>';
                    }
                } else {
                    echo '<li>' . __('Add new heading icons', 'cmsmasters') . ' <a href="' . admin_url() . 'admin.php?page=cmsms-settings-icon&tab=heading">' . __('here', 'cmsmasters') . '</a>.</li>';
                }
                echo '</ul>' . '<div style="clear:both;"></div>' . '<a href="#" class="cmsms_heading_icons_cancel">' . __('Cancel', 'cmsmasters') . '</a>' . '<div style="clear:both;"></div>' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'repeatable':
                echo '<ul id="' . $field['id'] . '-repeatable" class="custom_repeatable">';
                $i = 0;
                if ($meta) {
                    foreach ($meta as $row) {
                        if ($row !== '') {
                            echo '<li>' . '<span class="sort hndle">|||</span>' . '<input type="text" name="' . $field['id'] . '[' . $i . ']" id="' . $field['id'] . '[' . $i . ']" value="' . $row . '" size="30" />' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                        } else {
                            if ($i === 0) {
                                echo '<li style="display:none;">' . '<span class="sort hndle">|||</span>' . '<input type="text" name="' . $field['id'] . '[' . $i . ']" id="' . $field['id'] . '[' . $i . ']" value="" size="30" />' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                            }
                        }
                        $i++;
                    }
                } else {
                    echo '<li style="display:none;">' . '<span class="sort hndle">|||</span>' . '<input type="text" name="' . $field['id'] . '[' . $i . ']" id="' . $field['id'] . '[' . $i . ']" value="" size="30" />' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                }
                echo '</ul>' . '<a class="repeatable-add button" href="#">+</a>' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'repeatable_link':
                $post_items = get_posts(array('post_type' => 'post', 'posts_per_page' => -1));
                $page_items = get_posts(array('post_type' => 'page', 'posts_per_page' => -1));
                $project_items = get_posts(array('post_type' => 'project', 'posts_per_page' => -1));
                echo '<div class="ovh">' . '<div class="fl"><strong>' . __('Title', 'cmsmasters') . '</strong></div>' . '<div class="fl"><strong>' . __('Link', 'cmsmasters') . '</strong></div>' . '</div>' . '<ul id="' . $field['id'] . '-repeatable" class="custom_repeatable">';
                $i = 0;
                if ($meta !== '') {
                    foreach ($meta as $row) {
                        if ($row[0] !== '' && $row[1] !== '') {
                            echo '<li>' . '<span class="sort hndle"></span>' . '<input type="text" name="' . $field['id'] . '[' . $i . '][0]" id="' . $field['id'] . '[' . $i . '][0]" value="' . $row[0] . '" size="10" class="cmsms_name" />' . '<input type="text" name="' . $field['id'] . '[' . $i . '][1]" id="' . $field['id'] . '[' . $i . '][1]" value="' . $row[1] . '" size="25" class="cmsms_link" />' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                        } else {
                            if ($i === 0) {
                                echo '<li style="display:none;">' . '<span class="sort hndle"></span>' . '<input type="text" name="' . $field['id'] . '[' . $i . '][0]" id="' . $field['id'] . '[' . $i . '][0]" value="" size="10" class="cmsms_name" />' . '<input type="text" name="' . $field['id'] . '[' . $i . '][1]" id="' . $field['id'] . '[' . $i . '][1]" value="" size="25" class="cmsms_link" />' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                            }
                        }
                        $i++;
                    }
                } else {
                    echo '<li style="display:none;">' . '<span class="sort hndle"></span>' . '<input type="text" name="' . $field['id'] . '[' . $i . '][0]" id="' . $field['id'] . '[' . $i . '][0]" value="" size="10" class="cmsms_name" />' . '<input type="text" name="' . $field['id'] . '[' . $i . '][1]" id="' . $field['id'] . '[' . $i . '][1]" value="" size="25" class="cmsms_link" />' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                }
                echo '</ul>' . '<select name="' . $field['id'] . '-select" id="' . $field['id'] . '-select">' . '<optgroup label="' . __('Blank Field', 'cmsmasters') . '">' . '<option value="">' . __('Select Link', 'cmsmasters') . '</option>' . '</optgroup>' . '<optgroup label="' . __('Posts', 'cmsmasters') . '">';
                foreach ($post_items as $post_item) {
                    echo '<option value="' . get_permalink($post_item->ID) . '">' . $post_item->post_title . '</option>';
                }
                echo '</optgroup>' . '<optgroup label="' . __('Pages', 'cmsmasters') . '">';
                foreach ($page_items as $page_item) {
                    echo '<option value="' . get_permalink($page_item->ID) . '">' . $page_item->post_title . '</option>';
                }
                echo '</optgroup>' . '<optgroup label="' . __('Projects', 'cmsmasters') . '">';
                foreach ($project_items as $project_item) {
                    echo '<option value="' . get_permalink($project_item->ID) . '">' . $project_item->post_title . '</option>';
                }
                echo '</optgroup>' . '</select> &nbsp; ' . '<a class="repeatable-link-add button" href="#">+</a>' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'repeatable_multiple':
                echo '<div class="ovh">' . '<div class="fl"><strong>' . __('Title', 'cmsmasters') . '</strong></div>' . '<div class="fl"><strong>' . __('Values', 'cmsmasters') . '</strong></div>' . '</div>' . '<ul id="' . $field['id'] . '-repeatable" class="custom_repeatable">';
                $i = 0;
                if ($meta !== '') {
                    foreach ($meta as $row) {
                        if ($row[0] !== '' && $row[1] !== '') {
                            echo '<li>' . '<span class="sort hndle"></span>' . '<input type="text" name="' . $field['id'] . '[' . $i . '][0]" id="' . $field['id'] . '[' . $i . '][0]" value="' . $row[0] . '" size="10" class="cmsms_name" />' . '<textarea name="' . $field['id'] . '[' . $i . '][1]" id="' . $field['id'] . '[' . $i . '][1]" cols="25" rows="2" class="cmsms_val">' . $row[1] . '</textarea>' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                        } else {
                            if ($i === 0) {
                                echo '<li style="display:none;">' . '<span class="sort hndle"></span>' . '<input type="text" name="' . $field['id'] . '[' . $i . '][0]" id="' . $field['id'] . '[' . $i . '][0]" value="" size="10" class="cmsms_name" />' . '<textarea name="' . $field['id'] . '[' . $i . '][1]" id="' . $field['id'] . '[' . $i . '][1]" cols="25" rows="2" class="cmsms_val"></textarea>' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                            }
                        }
                        $i++;
                    }
                } else {
                    echo '<li style="display:none;">' . '<span class="sort hndle"></span>' . '<input type="text" name="' . $field['id'] . '[' . $i . '][0]" id="' . $field['id'] . '[' . $i . '][0]" value="" size="10" class="cmsms_name" />' . '<textarea name="' . $field['id'] . '[' . $i . '][1]" id="' . $field['id'] . '[' . $i . '][1]" cols="25" rows="2" class="cmsms_val"></textarea>' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                }
                echo '</ul>' . '<a class="repeatable-multiple-add button" href="#">+</a>' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'repeatable_media':
                echo '<select name="' . $field['id'] . '-select" id="' . $field['id'] . '-select">' . '<option value="">' . __('Select Format', 'cmsmasters') . ' &nbsp;</option>';
                foreach ($field['media'] as $key => $value) {
                    echo '<option value="' . $key . '">' . $value . '</option>';
                }
                echo '</select> &nbsp; ' . '<a class="repeatable-media-add button" href="#">+</a>' . '<br />' . '<ul id="' . $field['id'] . '-repeatable" class="custom_repeatable">';
                $i = 0;
                if ($meta !== '') {
                    foreach ($meta as $row) {
                        if ($row[1] !== '') {
                            echo '<li>' . '<input type="text" readonly="readonly" name="' . $field['id'] . '[' . $i . '][0]" id="' . $field['id'] . '[' . $i . '][0]" value="' . $row[0] . '" size="5" class="cmsms_format" />' . '<input type="text" name="' . $field['id'] . '[' . $i . '][1]" id="' . $field['id'] . '[' . $i . '][1]" value="' . $row[1] . '" size="30" class="cmsms_link" />' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                        } else {
                            if ($i === 0) {
                                echo '<li style="display:none;">' . '<input type="text" readonly="readonly" name="' . $field['id'] . '[' . $i . '][0]" id="' . $field['id'] . '[' . $i . '][0]" value="" size="5" class="cmsms_format" />' . '<input type="text" name="' . $field['id'] . '[' . $i . '][1]" id="' . $field['id'] . '[' . $i . '][1]" value="" size="30" class="cmsms_link" />' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                            }
                        }
                        $i++;
                    }
                } else {
                    echo '<li style="display:none;">' . '<input type="text" readonly="readonly" name="' . $field['id'] . '[' . $i . '][0]" id="' . $field['id'] . '[' . $i . '][0]" value="" size="5" class="cmsms_format" />' . '<input type="text" name="' . $field['id'] . '[' . $i . '][1]" id="' . $field['id'] . '[' . $i . '][1]" value="" size="30" class="cmsms_link" />' . '<a class="repeatable-remove button" href="#">x</a>' . '</li>';
                }
                echo '</ul>' . '<span class="description">' . $field['desc'] . '</span>';
                break;
            case 'images_list':
                if ($meta !== '') {
                    $ids = array();
                    $meta_array = explode(',', $meta);
                    foreach ($meta_array as $meta_val) {
                        $ids[] = str_replace('img_', '', $meta_val);
                    }
                }
                echo '<a href="#" id="' . $field['id'] . '_images_button" class="button open_gallery_post_image_list">' . __('Choose images', 'cmsmasters') . '</a>' . '<ul class="gallery_post_image_list selected_list">';
                if ($meta !== '') {
                    foreach ($ids as $id) {
                        $image = wp_get_attachment_image_src($id, 'thumbnail');
                        echo '<li>' . '<a href="' . $id . '" style="background-image:url(' . $image[0] . ');">' . '<span></span>' . '</a>' . '</li>';
                    }
                }
                echo '</ul>' . '<input type="hidden" id="' . $field['id'] . '" name="' . $field['id'] . '" value="' . $meta . '" class="gallery_post_images" />' . '<span class="description">' . $field['desc'] . '</span>' . '<script type="text/javascript">' . '(function ($) { ' . "\$(document.body).delegate('#" . $field['id'] . "_images_button', 'click', function (e) { " . 'e.preventDefault(); ' . '$(e.target).cmsmsMediaUploader( { ' . "frameId : 'cmsms-" . $field['id'] . "-media-frame', " . "frameClass : 'media-frame cmsms-media-frame cmsms-" . $field['id'] . "-media-frame', " . "frameTitle : '" . __('Choose images', 'cmsmasters') . "', " . "frameButton : '" . __('Choose', 'cmsmasters') . "', " . 'multiple : true ' . '} ); ' . '} ); ' . '} )(jQuery); ' . '</script>';
                break;
        }
        if ($field['type'] != 'tabs' && $field['type'] != 'tab_start' && $field['type'] != 'tab_finish' && $field['type'] != 'content_start' && $field['type'] != 'content_finish') {
            echo '</td>' . '</tr>';
        }
    }
}
Exemplo n.º 7
0
 function be_gmaps($atts, $content)
 {
     extract(shortcode_atts(array('address' => '', 'latitude' => '', 'longitude' => '', 'height' => '300', 'zoom' => '14', 'style' => 'default', 'marker' => '', 'animate' => 0, 'animation_type' => 'fadeIn'), $atts));
     $output = '';
     $animate = isset($animate) && 1 == $animate ? 'be-animate' : '';
     $full = wp_get_attachment_image_src($marker, 'full');
     $marker_image = $full[0];
     if (!empty($latitude) && !empty($longitude)) {
         $map_error = false;
     } else {
         if (!empty($address)) {
             //&& !empty($api_key) ) {
             $map_error = false;
             $transient_var = generateSlug($address, 10);
             $transient_result = get_transient($transient_var);
             if (!$transient_result) {
                 //$coordinates = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=true');
                 $response = wp_remote_get('https://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address));
                 //. '&key='.urlencode( $api_key ) );
                 if (is_wp_error($response)) {
                     $map_error = true;
                     delete_transient($transient_var);
                 } else {
                     $coordinates = wp_remote_retrieve_body($response);
                     if (is_wp_error($coordinates)) {
                         $map_error = true;
                         delete_transient($transient_var);
                     } else {
                         $coordinates_check = json_decode($coordinates);
                         if ($coordinates_check->status == 'OK') {
                             $latitude = $coordinates_check->results[0]->geometry->location->lat;
                             $longitude = $coordinates_check->results[0]->geometry->location->lng;
                             set_transient($transient_var, $coordinates, 24 * HOUR_IN_SECONDS);
                         } else {
                             $map_error = true;
                             delete_transient($transient_var);
                         }
                     }
                 }
             } else {
                 $coordinates_check = json_decode($transient_result);
                 $latitude = $coordinates_check->results[0]->geometry->location->lat;
                 $longitude = $coordinates_check->results[0]->geometry->location->lng;
             }
         } else {
             $map_error = true;
         }
     }
     if (true === $map_error) {
         $output .= '<div class="be-notification error">' . __('Your Server is Unable to connect to the Google Geocoding API, kindly visit <a href="http://www.latlong.net/convert-address-to-lat-long.html" target="_blank">THIS LINK </a>, find out the latitude and longitude of your address and enter it manually in the Google Maps Module of the Page Builder ', 'be-themes') . '</div>';
     } else {
         $output .= '<div class="gmap-wrapper ' . $animate . '" style="height:' . $height . 'px;" data-animation="' . $animation_type . '"><div class="gmap map_960" data-address="' . $address . '" data-zoom="' . $zoom . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '" data-marker="' . $marker_image . '" data-style="' . $style . '"></div></div>';
     }
     return $output;
 }
Exemplo n.º 8
0
function the_widgets_init()
{
    if (!function_exists('register_sidebars')) {
        return;
    }
    register_sidebar(array('name' => __('Sidebar', 'cmsmasters'), 'id' => 'sidebar_default', 'description' => __('Widgets in this area will be shown in all left and right sidebars till you don\'t use custom sidebar.', 'cmsmasters'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>'));
    register_sidebar(array('name' => __('Top Sidebar', 'cmsmasters'), 'id' => 'sidebar_top', 'description' => __('Widgets in this area will be shown at the top of middle block, above the content.', 'cmsmasters'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>'));
    register_sidebar(array('name' => __('Middle Sidebar', 'cmsmasters'), 'id' => 'sidebar_middle', 'description' => __('Widgets in this area will be shown at the bottom of middle block below the content, but above bottom sidebar and footer.', 'cmsmasters'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>'));
    register_sidebar(array('name' => __('Bottom Sidebar', 'cmsmasters'), 'id' => 'sidebar_bottom', 'description' => __('Widgets in this area will be shown at the bottom of middle block below the content and middle sidebar, but above footer.', 'cmsmasters'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h5 class="widgettitle">', 'after_title' => '</h5>'));
    $cmsms_option = cmsms_get_global_options();
    if (isset($cmsms_option[CMSMS_SHORTNAME . '_sidebar']) && sizeof($cmsms_option[CMSMS_SHORTNAME . '_sidebar']) > 0) {
        foreach ($cmsms_option[CMSMS_SHORTNAME . '_sidebar'] as $sidebar) {
            register_sidebar(array('name' => $sidebar, 'id' => generateSlug($sidebar, 45), 'description' => __('Custom sidebar created with cmsmasters admin panel.', 'cmsmasters'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>'));
        }
    }
}
Exemplo n.º 9
0
 public function up()
 {
     set_time_limit(0);
     // Check for all tables required for this migration
     parent::checkForTables(array('marks', 'migrations', 'users', 'users_marks', 'users_smartlabels'));
     // Check all columns need per table are found
     // marks, users and users_marks
     parent::checkForColumns(array('recipe', 'id', 'title', 'url', 'oembed', 'dateadded'), 'marks');
     parent::checkForColumns(array('salt', 'status', 'date_joined', 'admin'), 'users');
     parent::checkForColumns(array('addedby', 'groups', 'status', 'id', 'urlid', 'userid', 'tags', 'note', 'dateadded', 'datearchived'), 'users_marks');
     // Make sure all tables are INNODB, UTF-8
     // Original migration they were not
     // If anyone download that version and ran successfully, some keys may not be created correctly
     $this->db->query("ALTER TABLE `marks` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
     $this->db->query("ALTER TABLE `migrations` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
     $this->db->query("ALTER TABLE `users` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
     $this->db->query("ALTER TABLE `users_marks` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
     $this->db->query("ALTER TABLE `users_smartlabels` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
     // Drop all group releated tables
     $this->db->query("DROP TABLE IF EXISTS `groups`");
     $this->db->query("DROP TABLE IF EXISTS `groups_invites`");
     $this->db->query("DROP TABLE IF EXISTS `users_groups`");
     /*
     - Start updates for labels table
     - Import default system labels
     - Import any user smart labels
     */
     // Create new labels table
     $this->db->query("\n        CREATE TABLE IF NOT EXISTS `labels` (\n          `label_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'The auto-incremented key.',\n          `smart_label_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'If a smart label, the label_id to use if a match is found.',\n          `user_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'If a label but owned by a user, place the users.user_id here.',\n          `name` varchar(50) DEFAULT NULL COMMENT 'The name of the label.',\n          `slug` varchar(50) DEFAULT NULL COMMENT 'The slug of the label.',\n          `domain` varchar(255) DEFAULT NULL COMMENT 'The hostname of the domain to match. Keep in all lowercase.',\n          `path` varchar(100) DEFAULT NULL COMMENT 'The path to find to for smartlabels to match. If null, just match host.',\n          `smart_key` varchar(32) DEFAULT NULL COMMENT 'MD5 checksum of domain and path for lookup purposes.',\n          `active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1 is active, 0 if not. Defaults to 1.',\n          `created_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n          `last_updated` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'The last datetime this record was updated.',\n          PRIMARY KEY (`label_id`),\n          CONSTRAINT `FK_label_smart_label_id` FOREIGN KEY (`smart_label_id`) REFERENCES `labels` (`label_id`)   ON UPDATE CASCADE ON DELETE CASCADE,\n          CONSTRAINT `FK_label_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`)   ON UPDATE CASCADE ON DELETE CASCADE,\n          UNIQUE `slug`(slug),\n          INDEX `smart_label_id`(smart_label_id),\n          INDEX `user_id`(user_id),\n          INDEX `smart_key`(smart_key)\n        ) ENGINE=`InnoDB` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;\n      ");
     // Add default data to labels
     // Default: Unlabeled, Read, Watch, Listen, Buy, Eat & Drink, Do
     // Then add all the smart labels
     $default_labels = array('unlabeled' => array('label_id' => 1, 'name' => 'Unlabeled'), 'read' => array('label_id' => 2, 'name' => 'Read'), 'watch' => array('label_id' => 3, 'name' => 'Watch'), 'listen' => array('label_id' => 4, 'name' => 'Listen'), 'buy' => array('label_id' => 5, 'name' => 'Buy'), 'eatdrink' => array('label_id' => 6, 'name' => 'Eat & Drink'), 'do' => array('label_id' => 7, 'name' => 'Do'));
     foreach ($default_labels as $label) {
         $slug = generateSlug($label['name']);
         $this->db->query("INSERT INTO `labels` (`label_id`, `name`, `slug`, `created_on`) VALUES ('" . $label['label_id'] . "', '" . $label['name'] . "', '" . $slug . "', '" . date('Y-m-d H:i:s') . "')");
     }
     // Start default system smart labels
     $smart_labels = array('2' => array('php.net', 'api.rubyonrails.org', 'ruby-doc.org', 'docs.jquery.com', 'codeigniter.com', 'css-tricks.com', 'developer.apple.com'), '3' => array('youtube.com', 'viddler.com', 'devour.com', 'ted.com', 'vimeo.com'), '5' => array('svpply.com', 'amazon.com', 'fab.com', 'zappos.com'), '6' => array('simplyrecipes.com', 'allrecipes.com', 'epicurious.com', 'foodnetwork.com', 'food.com'));
     // Loop thru smart labels and add them up
     foreach ($smart_labels as $label_id => $arr) {
         foreach ($arr as $domain) {
             $smart_info = getSmartLabelInfo('http://' . $domain);
             $this->db->query("\n              INSERT INTO `labels`\n              (`smart_label_id`, `domain`, `smart_key`, `created_on`)\n              VALUES ('" . $label_id . "', '" . $smart_info['domain'] . "', '" . $smart_info['key'] . "', '" . date('Y-m-d H:i:s') . "')\n            ");
         }
     }
     // Now open users_smartlabels, import into labels
     $labels = $this->db->query("SELECT userid, domain, path, label FROM users_smartlabels");
     if ($labels->num_rows() >= 1) {
         foreach ($labels->result() as $label) {
             // Proceed only if domain is not empty
             $current_label = strtolower($label->label);
             if (!empty($label->domain) && !empty($label->userid) && is_numeric($label->userid) && !empty($current_label) && array_key_exists($current_label, $default_labels)) {
                 // Standardize label domain, path and smart key
                 $smart_info = getSmartLabelInfo($label->domain . $label->path);
                 $domain = $smart_info['domain'];
                 $path = $smart_info['path'];
                 $md5 = $smart_info['key'];
                 $label_id = $default_labels[$current_label]['label_id'];
                 $path = empty($label->path) ? '' : "'" . $label->path . "', ";
                 $path_c = empty($label->path) ? '' : "`path`, ";
                 // Find an occurences of this record
                 $q = $this->db->query("\n              SELECT COUNT(*) FROM labels\n              WHERE user_id = '" . $label->userid . "'\n              AND domain = '" . $domain . "'\n              AND smart_label_id = '" . $label_id . "'\n            ");
                 $row = $q->row();
                 $total = (int) $row->{'COUNT(*)'};
                 // If not found, add it
                 if ($total < 1) {
                     $res = $this->db->query("\n                INSERT INTO `labels`\n                (`smart_label_id`, `user_id`, `domain`, " . $path_c . "`smart_key`, `created_on`)\n                VALUES ('" . $label_id . "', '" . $label->userid . "', '" . $domain . "', " . $path . "'" . $md5 . "', '" . date('Y-m-d H:i:s') . "')\n              ");
                 }
             }
         }
     }
     /*
     - End labels import
     */
     /*
     - Start updates for marks table
     */
     // Move all recipes to oembed column
     // oembed will be renamed embed for all embeddable content
     $marks = $this->db->query("SELECT id, recipe FROM `marks` WHERE recipe != '' AND LOWER(recipe) != 'none' AND recipe IS NOT NULL");
     if ($marks->num_rows() >= 1) {
         foreach ($marks->result() as $mark) {
             $res = $this->db->query("UPDATE `marks` SET `oembed` = '" . addslashes($mark->recipe) . "' WHERE `id` = '" . $mark->id . "'");
         }
     }
     // Update marks table
     $this->db->query("ALTER TABLE `marks` DROP COLUMN `recipe`");
     $this->db->query("ALTER TABLE `marks` CHANGE COLUMN `id` `mark_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'The auto-incremented id for marks.'");
     $this->db->query("ALTER TABLE `marks` DROP PRIMARY KEY, ADD PRIMARY KEY (`mark_id`)");
     $this->db->query("ALTER TABLE `marks` CHANGE COLUMN `title` `title` varchar(150) NOT NULL COMMENT 'The title from the page being bookmarked.'");
     $this->db->query("ALTER TABLE `marks` CHANGE COLUMN `url` `url` text NOT NULL COMMENT 'The full url from the page being bookmarked.'");
     $this->db->query("ALTER TABLE `marks` ADD COLUMN `url_key` varchar(32) DEFAULT NULL COMMENT 'The MD5 checksum of the url for lookup purposes.' AFTER `url`");
     $this->db->query("ALTER TABLE `marks` CHANGE COLUMN `oembed` `embed` text DEFAULT NULL COMMENT 'The embedded content that could appear on the mark\\'s info page.'");
     $this->db->query("ALTER TABLE `marks` CHANGE COLUMN `dateadded` `created_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'The datetime this record was created.'");
     $this->db->query("ALTER TABLE `marks` ADD COLUMN `embed_processed` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1 = yes, 0 if not. Defaults to 0.' AFTER `embed`");
     $this->db->query("ALTER TABLE `marks` ADD COLUMN `last_updated` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'The last datetime this record was updated.' AFTER `created_on`");
     // Update embed column to NULL if 'None'
     $res = $this->db->query("UPDATE `marks` SET embed = NULL WHERE LOWER(embed) = 'none'");
     // Set embed to processed if NOT NULL OR isn't in LAST DAY
     $res = $this->db->query("UPDATE `marks` SET embed_processed = '1' WHERE embed IS NOT NULL OR UNIX_TIMESTAMP(created_on) < '" . strtotime('today') . "'");
     // Get all urls from marks table, create MD5 checksum, update record
     $marks = $this->db->query("SELECT mark_id, url FROM `marks`");
     // If any exists, move on
     if ($marks->num_rows() >= 1) {
         // Set up empty arrays to hold marks that may get deleted or changed
         $deleted = array();
         $changed = array();
         // Loop thru results
         foreach ($marks->result() as $mark) {
             // If no url, remove it from DB and add to deleted list
             if (empty($mark->url)) {
                 $res = $this->db->query("DELETE FROM `marks` WHERE `mark_id` = '" . $mark->mark_id . "'");
                 array_push($deleted, $mark->mark_id);
             } else {
                 $checksum = md5($mark->url);
                 $record = $this->db->query("SELECT mark_id FROM `marks` WHERE `url_key` = '" . $checksum . "' LIMIT 1");
                 if ($record->num_rows() == 1) {
                     $record = $record->row();
                     $changed[$mark->mark_id] = $record->mark_id;
                     $res = $this->db->query("DELETE FROM `marks` WHERE `mark_id` = '" . $mark->mark_id . "'");
                 } else {
                     $res = $this->db->query("UPDATE `marks` SET `url_key` = '" . $checksum . "' WHERE `mark_id` = '" . $mark->mark_id . "'");
                 }
             }
         }
         // If the deleted array is not empty
         // Remove any user marks that are attached to it
         if (!empty($deleted)) {
             foreach ($deleted as $mark_id) {
                 $res = $this->db->query("DELETE FROM `users_marks` WHERE `urlid` = '" . $mark_id . "'");
             }
         }
         // If the changed array is not empty
         // Update any user marks from the old mark id to the new one
         if (!empty($changed)) {
             foreach ($changed as $old_id => $new_id) {
                 $res = $this->db->query("UPDATE `users_marks` SET `urlid` = '" . $new_id . "' WHERE `urlid` = '" . $old_id . "'");
             }
         }
     }
     // Finally, add a unique index for url key
     $this->db->query("ALTER TABLE `marks` ADD UNIQUE `url_key`(url_key)");
     /*
     - End updates for marks table
     */
     // Update users table
     // We are moving to active = 1 or 0 column, before altering table, switch active = 1, inactive = 0
     $res = $this->db->query("UPDATE `users` SET status = '0' WHERE status <> 'active'");
     $res = $this->db->query("UPDATE `users` SET status = '1' WHERE status = 'active'");
     $this->db->query("ALTER TABLE `users` DROP COLUMN `salt`");
     $this->db->query("ALTER TABLE `users` CHANGE COLUMN `status` `active` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1 = active, 0 = inactive' AFTER `password`");
     $this->db->query("ALTER TABLE `users` CHANGE COLUMN `date_joined` `created_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'The datetime the account was created'");
     $this->db->query("ALTER TABLE `users` CHANGE COLUMN `admin` `admin` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1 = admin, 0 = admin' AFTER `active`");
     $this->db->query("ALTER TABLE `users` ADD COLUMN `user_token` varchar(30) NOT NULL DEFAULT '0' COMMENT 'Unique user token.' AFTER `password`");
     // Add user tokens
     // Must check if they exist already
     $users = $this->db->query("SELECT user_id FROM `users`");
     if ($users->num_rows() >= 1) {
         foreach ($users->result() as $obj) {
             do {
                 $user_token = generateToken(30);
                 $res = $this->db->query("SELECT user_id FROM `users` WHERE user_token = '" . $user_token . "'");
             } while (isset($res->user_id));
             // Update user record
             $res = $this->db->query("UPDATE `users` SET user_token = '" . $user_token . "' WHERE user_id = '" . $obj->user_id . "'");
         }
     }
     // Update user token column to be no default
     // Add unique index
     $this->db->query("ALTER TABLE `users` CHANGE COLUMN `user_token` `user_token` varchar(30) NOT NULL COMMENT 'Unique user token.'");
     $this->db->query("ALTER TABLE `users` ADD UNIQUE `user_token`(user_token)");
     // Remove the users_smartlabels table
     $this->db->query("DROP TABLE IF EXISTS `users_smartlabels`");
     /*
     - Start users_to_marks transistion
     */
     // Update `tags` field to a single numeric in order to translate to a FK for labels
     // Move group id to user_marks_to_groups table
     $marks = $this->db->query("SELECT id, urlid, tags, groups, status FROM `users_marks`");
     $archived = array();
     $delete = array();
     if ($marks->num_rows() >= 1) {
         // Loop thru results
         foreach ($marks->result() as $mark) {
             $tags = explode(',', $mark->tags);
             $label_id = 1;
             $group_id = $mark->groups;
             $mark_id = $mark->id;
             // Figure if we should delete this mark
             $res = $this->db->query("SELECT mark_id FROM marks WHERE mark_id = '" . $mark->urlid . "' LIMIT 1");
             if ($res->num_rows() < 1) {
                 array_push($delete, $mark_id);
             }
             // If it was archived, save here to update later
             if (strtolower($mark->status) == 'archive') {
                 array_push($archived, $mark_id);
             }
             foreach ($tags as $tag) {
                 $tag = trim(strtolower($tag));
                 if (array_key_exists($tag, $default_labels)) {
                     $label_id = $default_labels[$tag]['label_id'];
                     break;
                 }
             }
             // Update tags
             $res = $this->db->query("UPDATE `users_marks` SET tags = '" . $label_id . "' WHERE id = '" . $mark_id . "'");
         }
     }
     // Remove any urlids in users_marks that do NOT exist in marks table
     // If we skip this step the FK creation will fail
     // Data is a bit dirty because when marks were deleted, it never deleted their children, leaving little orphan annies
     // Fix it!
     if (!empty($delete)) {
         foreach ($delete as $id) {
             $res = $this->db->query("DELETE FROM `users_marks` WHERE id = '" . $id . "'");
         }
     }
     // Update table name & structure
     $this->db->query("RENAME TABLE `users_marks` TO `users_to_marks`");
     $this->db->query("ALTER TABLE `users_to_marks` DROP COLUMN `addedby`");
     $this->db->query("ALTER TABLE `users_to_marks` DROP COLUMN `groups`");
     $this->db->query("ALTER TABLE `users_to_marks` DROP COLUMN `status`");
     $this->db->query("ALTER TABLE `users_to_marks` CHANGE COLUMN `id` `users_to_mark_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'The auto-incremented key.'");
     $this->db->query("ALTER TABLE `users_to_marks` DROP PRIMARY KEY, ADD PRIMARY KEY (`users_to_mark_id`)");
     $this->db->query("ALTER TABLE `users_to_marks` CHANGE COLUMN `urlid` `mark_id` bigint(20) UNSIGNED NOT NULL COMMENT 'The mark_id from marks.mark_id.' AFTER `users_to_mark_id`");
     $this->db->query("ALTER TABLE `users_to_marks` CHANGE COLUMN `userid` `user_id` bigint(20) UNSIGNED NOT NULL COMMENT 'The user_id from users.user_id' AFTER `mark_id`");
     $this->db->query("ALTER TABLE `users_to_marks` CHANGE COLUMN `tags` `label_id` bigint(20) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'The label_id from labels.label_id.'");
     $this->db->query("ALTER TABLE `users_to_marks` CHANGE COLUMN `note` `notes` text DEFAULT NULL");
     $this->db->query("ALTER TABLE `users_to_marks` CHANGE COLUMN `dateadded` `created_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'The datetime this record was created.'");
     $this->db->query("ALTER TABLE `users_to_marks` CHANGE COLUMN `datearchived` `archived_on` datetime DEFAULT NULL COMMENT 'The datetime this mark was archived. NULL = not archived.'");
     $this->db->query("ALTER TABLE `users_to_marks` ADD COLUMN `last_updated` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'The last datetime this record was updated.' AFTER `archived_on`");
     $this->db->query("ALTER TABLE `users_to_marks` ADD INDEX `mark_id`(mark_id)");
     $this->db->query("ALTER TABLE `users_to_marks` ADD INDEX `user_id`(user_id)");
     $this->db->query("ALTER TABLE `users_to_marks` ADD INDEX `label_id`(label_id)");
     $this->db->query("ALTER TABLE `users_to_marks` ADD CONSTRAINT `FK_utm_mark_id` FOREIGN KEY (`mark_id`) REFERENCES `marks` (`mark_id`)   ON UPDATE CASCADE ON DELETE CASCADE");
     $this->db->query("ALTER TABLE `users_to_marks` ADD CONSTRAINT `FK_utm_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`)   ON UPDATE CASCADE ON DELETE CASCADE");
     $this->db->query("ALTER TABLE `users_to_marks` ADD CONSTRAINT `FK_utm_label_id` FOREIGN KEY (`label_id`) REFERENCES `labels` (`label_id`)   ON UPDATE CASCADE ON DELETE CASCADE");
     // Fix archived marks
     // First set all date_archived fields to NULL properly
     $res = $this->db->query("UPDATE `users_to_marks` SET archived_on = NULL WHERE archived_on IS NOT NULL");
     if (!empty($archived)) {
         foreach ($archived as $users_to_mark_id) {
             $res = $this->db->query("UPDATE `users_to_marks` SET archived_on = '" . date('Y-m-d H:i:s') . "' WHERE users_to_mark_id = '" . $users_to_mark_id . "'");
         }
     }
     /*
     - End users_to_marks transistion
     */
     // Create new tags table
     $this->db->query("\n        CREATE TABLE `tags` (\n          `tag_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'The auto-incremented key fro tags.',\n          `name` varchar(100) NOT NULL COMMENT 'The tag name.',\n          `slug` varchar(100) NOT NULL COMMENT 'The tag slug name.',\n          PRIMARY KEY (`tag_id`),\n          INDEX `name`(name),\n          UNIQUE `slug`(slug)\n        ) ENGINE=`InnoDB` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;\n      ");
     // Create new user_marks_to_tags table
     $this->db->query("\n        CREATE TABLE `user_marks_to_tags` (\n          `user_marks_to_tag_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'The auto-incremented key.',\n          `tag_id` bigint(20) UNSIGNED NOT NULL COMMENT 'The tag id from tags.tag_id',\n          `user_id` bigint(20) UNSIGNED NOT NULL COMMENT 'The user id from users.user_id',\n          `users_to_mark_id` bigint(20) UNSIGNED NOT NULL COMMENT 'The user mark id from users_to_marks.users_to_mark_id',\n          PRIMARY KEY (`user_marks_to_tag_id`),\n          INDEX `users_to_mark_id`(users_to_mark_id),\n          INDEX `tag_id`(tag_id),\n          INDEX `user_id`(user_id),\n          CONSTRAINT `FK_umtt_tag_id` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`tag_id`)   ON UPDATE CASCADE ON DELETE CASCADE,\n          CONSTRAINT `FK_umtt_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`)   ON UPDATE CASCADE ON DELETE CASCADE,\n          CONSTRAINT `FK_umtt_mark_id` FOREIGN KEY (`users_to_mark_id`) REFERENCES `users_to_marks` (`users_to_mark_id`)   ON UPDATE CASCADE ON DELETE CASCADE\n        ) ENGINE=`InnoDB` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;\n      ");
 }
Exemplo n.º 10
0
 /**
  * Add tags for specified mark
  *
  * @param array $tags
  * @param int $mark_id
  */
 private function addTags($tags, $mark_id)
 {
     if (!empty($tags) && is_array($tags)) {
         // Update users_to_marks record
         $this->CI->load->model('tags_model', 'tag');
         $this->CI->load->model('user_marks_to_tags_model', 'mark_to_tag');
         $tag_ids = array();
         foreach ($tags as $k => $tag) {
             $tag_name = trim($tag);
             $slug = generateSlug($tag);
             if (!empty($slug)) {
                 $tag = $this->CI->tag->read("slug = '" . $slug . "'", 1, 1, 'tag_id');
                 if (!isset($tag->tag_id)) {
                     $tag = $this->CI->tag->create(array('name' => $tag_name, 'slug' => $slug));
                 }
                 // Add tag to mark
                 if (isset($tag->tag_id)) {
                     $res = $this->CI->mark_to_tag->create(array('users_to_mark_id' => $mark_id, 'tag_id' => $tag->tag_id, 'user_id' => $this->importData['user_id']));
                 }
                 // Save all tag ids
                 if (isset($res->tag_id)) {
                     array_push($tag_ids, $res->tag_id);
                 }
             }
         }
         // Delete old tags
         $delete_where = !empty($tag_ids) ? " AND tag_id <> '" . implode("' AND tag_id <> '", $tag_ids) . "'" : '';
         $delete = $this->CI->mark_to_tag->delete("users_to_mark_id = '" . $mark_id . "' AND user_id = '" . $this->importData['user_id'] . "'" . $delete_where);
     }
 }
Exemplo n.º 11
0
function insertTag($params)
{
    /*
    * Script will attempt to insert tag to 'terms' and 'term_taxonomy' tables
    * You will get an error if you provided invalid field names.
    
    ** REQUIRED PARAMS
    name - tag name
    taxonomy - 'tag' or 'category' only
    
    If taxonomy = 'tag' then :
    1. check 'terms'
    2. if tag does exist in 'terms' then get tag id from 'terms' and insert new record into 'term_taxonomy' with existent id and taxonomy = 'tag'
    3. if tag doesn't exist in 'terms' then insert it into 'terms' and then into 'term_taxonomy' with new id
    
    If taxonomy = 'category' then :
    1. check 'terms'
    2. if tag does exist in 'terms' then get tag id from 'terms' and insert new record into 'term_taxonomy' with existent id and taxonomy = 'category'
    3. if tag doesn't exist in 'terms' then insert it into 'terms'
    3a. then insert two records into 'term_taxonomy' - first one with taxonomy = 'category' and second one with taxonomy = 'tag'
    	
    ** OTHER PARAMS
    verbose - for displaying results (true = display ids only, false - all fields from 'term_taxonomy')
    name/value pairs to set parameters for the tag :
    - slug
    - parentid (optional) - if doesn't exist then parentid = id = autoincrement
    - description
    - color
    - date1
    - date2
    - displyorder
    */
    if (isset($params['name']) && isset($params['taxonomy']) && ($params['taxonomy'] == 'tag' || $params['taxonomy'] == 'category')) {
        // gets array of field names for the table 'term_taxonomy'
        $columnsArray = getTableColumns('term_taxonomy');
        // checks whether tag is already exist in the table 'terms'
        $sendParams = array();
        $slug = generateSlug($params['name']);
        // generate the slug using Name parameter
        $sql = "SELECT id FROM `terms` WHERE slug = :slug";
        $sendParams['slug'] = $slug;
        $result = queryDatabase($sql, $sendParams);
        $isnewtag = false;
        // false if tag does exist in 'terms'
        if ($result->rowCount() > 0) {
            // tag does exist in 'terms'
            $row = $result->fetch(PDO::FETCH_ASSOC);
            $idTerms = $row['id'];
            // get term id
        } else {
            $sendParams = array();
            // get auto-increment for the new record
            $autoIncrementTerms = getAutoIncrement('terms');
            // insert into 'terms'
            $sql = "INSERT INTO `terms` (id,name,slug) VALUES (:id,:name,:slug)";
            $sendParams['name'] = processText($params['name']);
            $sendParams['id'] = $autoIncrementTerms;
            if (isset($params['slug'])) {
                $sendParams['slug'] = processText($params['slug']);
            } else {
                $sendParams['slug'] = $slug;
            }
            if ($result = queryDatabase($sql, $sendParams)) {
                $isnewtag = true;
                // changes to true if tag didn't exist before
                $idTerms = $autoIncrementTerms;
                // set term id as auto-increment
            } else {
                die("Query Failed: " . $result->errorInfo());
            }
        }
        // if 'taxonomy' parameter is equal to 'tag'
        if ($params['taxonomy'] == "tag") {
            // insert one record to 'term_taxonomy'
            $sendParams = array();
            $sql = "INSERT into `term_taxonomy` (id,parentid,termid,";
            foreach ($params as $key => $value) {
                if ($key != 'action' && $key != 'parentid' && $key != 'name' && $key != 'slug' && $key != 'parentid' && $key != 'termid' && $key != 'verbose') {
                    if (in_array($key, $columnsArray)) {
                        // checks for misspelling of field name
                        $sql .= $key . ",";
                    } else {
                        die("Unknown field name '{$key}'.");
                    }
                }
            }
            // remove last comma
            $sql = substr($sql, 0, strlen($sql) - 1);
            $sql .= ")";
            // put values into SQL
            $sql .= " VALUES (";
            // get auto-increment for the new record
            $autoIncrementTermTax = getAutoIncrement('term_taxonomy');
            $sql .= "'" . $autoIncrementTermTax . "',";
            // id
            if (isset($params['parentid'])) {
                // if parentid is set
                $sql .= "'" . $params['parentid'] . "',";
                // parentid
            } else {
                // if parentid is not set then parentid = id
                $sql .= "'" . $autoIncrementTermTax . "',";
            }
            $sql .= "'" . $idTerms . "',";
            // termid
            foreach ($params as $key => $value) {
                if ($key != 'action' && $key != 'id' && $key != 'name' && $key != 'slug' && $key != 'parentid' && $key != 'termid' && $key != 'verbose') {
                    $sql .= ":" . $key . ",";
                    $sendParams[$key] = processText($value);
                }
            }
            // remove last comma
            $sql = substr($sql, 0, strlen($sql) - 1);
            $sql .= ")";
        } else {
            if ($params['taxonomy'] == "category") {
                // insert records to 'term_taxonomy':
                // first with taxonomy = 'category', ALWAYS
                // second with taxonomy = 'tag', ONLY IF tag doesn't exist in 'terms'
                $sendParams = array();
                $sql = "INSERT into `term_taxonomy` (id,parentid,termid,taxonomy,";
                foreach ($params as $key => $value) {
                    if ($key != 'action' && $key != 'parentid' && $key != 'name' && $key != 'slug' && $key != 'parentid' && $key != 'termid' && $key != 'taxonomy' && $key != 'verbose') {
                        if (in_array($key, $columnsArray)) {
                            // checks for misspelling of field name
                            $sql .= $key . ",";
                        } else {
                            die("Unknown field name '{$key}'.");
                        }
                    }
                }
                // remove last comma
                $sql = substr($sql, 0, strlen($sql) - 1);
                $sql .= ")";
                // put values into SQL
                $sql .= " VALUES ";
                // first with taxonomy = 'category'
                ///////////////////////////////////////////////////////////////
                $sql .= "(";
                // get auto-increment for the new record
                $autoIncrementTermTax = getAutoIncrement('term_taxonomy');
                $sql .= "'" . $autoIncrementTermTax . "',";
                // id
                if (isset($params['parentid'])) {
                    // if parentid is set
                    $sql .= "'" . $params['parentid'] . "',";
                    // parentid
                } else {
                    // if parentid is not set then parentid = id
                    $sql .= "'" . $autoIncrementTermTax . "',";
                }
                $sql .= "'" . $idTerms . "',";
                // termid
                $sql .= "'category',";
                // taxonomy
                foreach ($params as $key => $value) {
                    if ($key != 'action' && $key != 'id' && $key != 'name' && $key != 'slug' && $key != 'parentid' && $key != 'termid' && $key != 'taxonomy' && $key != 'verbose') {
                        $sql .= ":" . $key . ",";
                        $sendParams[$key] = processText($value);
                    }
                }
                // remove last comma
                $sql = substr($sql, 0, strlen($sql) - 1);
                $sql .= ")";
                ///////////////////////////////////////////////////////////////
                if ($isnewtag) {
                    // tag was inserted to 'terms'
                    // so insert second record with taxonomy = 'tag'
                    ///////////////////////////////////////////////////////////////
                    $sql .= ", (";
                    $nextTermTax = $autoIncrementTermTax + 1;
                    $sql .= "'" . $nextTermTax . "',";
                    // id
                    if (isset($params['parentid'])) {
                        // if parentid is set
                        $sql .= "'" . $params['parentid'] . "',";
                        // parentid
                    } else {
                        // if parentid is not set then parentid = id
                        $sql .= "'" . $nextTermTax . "',";
                    }
                    $sql .= "'" . $idTerms . "',";
                    // termid
                    $sql .= "'tag',";
                    // taxonomy
                    foreach ($params as $key => $value) {
                        if ($key != 'action' && $key != 'id' && $key != 'name' && $key != 'slug' && $key != 'parentid' && $key != 'termid' && $key != 'taxonomy' && $key != 'verbose') {
                            $sql .= ":" . $key . ",";
                            //$sendParams[$key] = processText($value);
                        }
                    }
                    // remove last comma
                    $sql = substr($sql, 0, strlen($sql) - 1);
                    $sql .= ")";
                    ///////////////////////////////////////////////////////////////
                }
            } else {
                die("Invalid Taxonomy parameter.");
            }
        }
        // insert to 'term_taxonomy' and get the results
        if ($result = queryDatabase($sql, $sendParams, $insertid)) {
            // SELECT fields according to Verbose parameter
            if (isset($params['verbose']) && $params['verbose'] == 'true' && $isnewtag && $params['taxonomy'] == 'category') {
                $sql = "SELECT id, parentid, termid FROM `term_taxonomy` WHERE id = '" . $autoIncrementTermTax . "'";
            } else {
                if (isset($params['verbose']) && $params['verbose'] == 'true') {
                    $sql = "SELECT id, parentid, termid FROM `term_taxonomy` WHERE id = '" . $insertid . "'";
                } else {
                    if ((!isset($params['verbose']) || isset($params['verbose']) && $params['verbose'] == 'true') && $isnewtag && $params['taxonomy'] == 'category') {
                        $sql = "SELECT * FROM `term_taxonomy` WHERE id = '" . $autoIncrementTermTax . "'";
                    } else {
                        if (!isset($params['verbose']) || isset($params['verbose']) && $params['verbose'] == 'true') {
                            $sql = "SELECT * FROM `term_taxonomy` WHERE id = '" . $insertid . "'";
                        } else {
                            $sql = "SELECT id FROM `term_taxonomy` WHERE id = '" . $insertid . "'";
                        }
                    }
                }
            }
            // verbose = false
            if ($result = queryDatabase($sql)) {
                return $result;
            } else {
                die("Query Failed: " . $result->errorInfo());
            }
        } else {
            die("Query Failed: " . $result->errorInfo());
        }
    } else {
        die("No tag name or taxonomy provided; or invalid taxonomy parameter.");
    }
}
<?php

/**
 * @package WordPress
 * @subpackage Newgate
 * @since Newgate 1.0
 * 
 * Content Composer Template Operator
 * Created by CMSMasters
 * 
 */
require '../../../../../../../wp-load.php';
global $posts;
if (isset($_POST['type']) && $_POST['type'] == 'add') {
    $name = $_POST['name'];
    $content = stripslashes($_POST['content']);
    $ins_post_ID = wp_insert_post(array('post_title' => $name, 'post_name' => generateSlug($name, 30), 'post_content' => $content, 'post_status' => 'draft', 'post_type' => 'content_template'));
    echo '<option value="cmsms_template_' . $ins_post_ID . '">' . $name . '</option>';
} else {
    if (isset($_POST['type']) && $_POST['type'] == 'load') {
        $id = $_POST['id'];
        $template = get_post($id);
        echo $template->post_content;
    } else {
        if (isset($_POST['type']) && $_POST['type'] == 'del') {
            $id = $_POST['id'];
            $template = wp_delete_post($id, true);
            echo $template->ID;
        }
    }
}
Exemplo n.º 13
0
 public function edit($label_id = 0)
 {
     // Figure correct way to handle if no mark id
     if (empty($label_id) || !is_numeric($label_id)) {
         $this->data['errors'] = formatErrors(30);
     } else {
         // Set the columns that CAN be updated
         $types = array('label', 'smart');
         // Lookup label_id to get type
         $user_where = parent::isAdmin() === true && isset($this->clean->admin) && !empty($this->clean->admin) ? "labels.user_id IS NULL" : "labels.user_id = '" . $this->user_id . "'";
         $where = "(labels.user_id IS NULL AND labels.label_id= '" . $label_id . "' AND labels.smart_label_id IS NULL) OR (" . $user_where . " AND labels.label_id= '" . $label_id . "' AND labels.smart_label_id IS NOT NULL)";
         $label = $this->labels->readComplete($where, 1);
         // If no type found, there was no label for this id/user combo
         if (!isset($label->type)) {
             $this->data['errors'] = formatErrors(31);
         } elseif ($label->type == 'label' && parent::isAdmin() === false) {
             $this->data['errors'] = formatErrors(37);
         } elseif (!array_key_exists($label->type, $types)) {
             $this->data['errors'] = formatErrors(33);
         } else {
             $options = array();
             $total = 0;
             // Figure options per label type
             if ($label->type == 'smart') {
                 if (isset($this->db_clean->url) && !empty($this->db_clean->url)) {
                     $smart_info = getSmartLabelInfo($this->db_clean->url);
                     $options['domain'] = $smart_info['domain'];
                     $options['path'] = $smart_info['path'];
                     $options['smart_key'] = $smart_info['key'];
                     $total = $this->labels->count($user_where . " AND labels.smart_key = '" . $options['smart_key'] . "'");
                 }
                 // If label is sent, add to options
                 if (isset($this->db_clean->label_id) && !is_numeric($this->db_clean->label_id)) {
                     $options['smart_label_id'] = $this->db_clean->label_id;
                 }
             } else {
                 if (isset($this->db_clean->name) && !empty($this->db_clean->name)) {
                     $options['name'] = $this->db_clean->name;
                     $options['slug'] = generateSlug($options['name']);
                     $total = $this->labels->count("labels.user_id IS NULL AND labels.slug = '" . $options['slug'] . "'");
                 }
             }
             // Figure if there was an active state passed
             if (isset($this->db_clean->active) && ($this->db_clean->active == 0 || $this->db_clean->active == 1)) {
                 $options['active'] = $this->db_clean->active;
             }
             // If no options, return error
             if (empty($options)) {
                 $this->data['errors'] = formatErrors(35);
             } elseif ($total > 0) {
                 $this->data['errors'] = formatErrors(34);
             } else {
                 $label = $this->labels->update($where, $options);
                 // If update failed, tell the user
                 if ($label === false) {
                     $this->data['errors'] = formatErrors(39);
                 } else {
                     $this->data['label'] = $label;
                 }
             }
         }
     }
     // Figure view
     $this->figureView();
 }
function cmsms_form_field_fn($args = array())
{
    $cmsms_option = cmsms_get_global_options();
    extract($args);
    $settings_output = cmsms_get_settings();
    $cmsms_option_name = $settings_output['cmsms_option_name'];
    $options = get_option($cmsms_option_name);
    if (!isset($options[$id])) {
        $options[$id] = $std;
    }
    $field_class = $class != '' ? ' ' . $class : '';
    switch ($type) {
        case 'text':
            $options[$id] = esc_attr(stripslashes($options[$id]));
            echo '<input class="regular-text' . $field_class . '" type="text" id="' . $id . '" name="' . $cmsms_option_name . '[' . $id . ']" value="' . $options[$id] . '" />' . ($desc != '' ? '<br />' . '<span class="description">' . $desc . '</span>' : '');
            break;
        case 'multi-text':
            foreach ($choices as $item) {
                $item = explode('|', $item);
                $item[0] = esc_html($item[0]);
                if (!empty($options[$id])) {
                    foreach ($options[$id] as $option_key => $option_val) {
                        if ($item[1] == $option_key) {
                            $value = $option_val;
                        }
                    }
                } else {
                    $value = '';
                }
                echo '<span>' . $item[0] . ':</span> ' . '<input class="' . $field_class . '" type="text" id="' . $id . '|' . $item[1] . '" name="' . $cmsms_option_name . '[' . $id . '|' . $item[1] . ']" value="' . $value . '" />' . '<br />';
            }
            echo $desc != '' ? '<span class="description">' . $desc . '</span>' : '';
            break;
        case 'textarea':
            $options[$id] = esc_html(stripslashes($options[$id]));
            echo '<textarea class="textarea' . $field_class . '" type="text" id="' . $id . '" name="' . $cmsms_option_name . '[' . $id . ']" rows="5" cols="30">' . $options[$id] . '</textarea>' . ($desc != '' ? '<br />' . '<span class="description">' . $desc . '</span>' : '');
            break;
        case 'select':
            echo '<select id="' . $id . '" class="select' . $field_class . '" name="' . $cmsms_option_name . '[' . $id . ']">';
            foreach ($choices as $item) {
                $item = explode('|', $item);
                $item[0] = esc_html($item[0]);
                $selected = $options[$id] == $item[1] ? ' selected="selected"' : '';
                echo '<option value="' . $item[1] . '"' . $selected . '>' . $item[0] . '</option>';
            }
            echo '</select>' . ($desc != '' ? '<br />' . '<span class="description">' . $desc . '</span>' : '');
            break;
        case 'select_sidebar':
            echo '<select id="' . $id . '" class="select' . $field_class . '" name="' . $cmsms_option_name . '[' . $id . ']">' . '<option value="">' . __('None', 'cmsmasters') . ' &nbsp;</option>' . '<option value="default"' . ($options[$id] !== '' && $options[$id] === 'default' ? ' selected="selected"' : '') . '>' . __('Default Sidebar', 'cmsmasters') . ' &nbsp;</option>';
            foreach ($cmsms_option[CMSMS_SHORTNAME . '_sidebar'] as $sidebar_id => $sidebar_name) {
                echo '<option value="' . generateSlug($sidebar_name, 45) . '"' . ($options[$id] !== '' && $options[$id] === generateSlug($sidebar_name, 45) ? ' selected="selected"' : '') . '>' . $sidebar_name . ' &nbsp;</option>';
            }
            echo '</select>' . '<br />' . ($desc != '' ? '<br />' . '<span class="description">' . $desc . '</span>' : '');
            break;
        case 'checkbox':
            echo '<input class="checkbox' . $field_class . '" type="checkbox" id="' . $id . '" name="' . $cmsms_option_name . '[' . $id . ']" value="1" ' . checked($options[$id], 1, false) . ' /> &nbsp;' . ($desc != '' ? '<span class="description">' . $desc . '</span>' : '');
            break;
        case 'multi-checkbox':
            foreach ($choices as $item) {
                $item = explode('|', $item);
                $item[0] = esc_html($item[0]);
                $checked = '';
                if (isset($options[$id][$item[1]]) && $options[$id][$item[1]] == 'true') {
                    $checked = ' checked="checked"';
                }
                echo '<input class="checkbox' . $field_class . '" type="checkbox" id="' . $id . '|' . $item[1] . '" name="' . $cmsms_option_name . '[' . $id . '|' . $item[1] . ']" value="1"' . $checked . ' /> &nbsp;' . '<label for="' . $id . '|' . $item[1] . '">' . $item[0] . '</label>' . '<br />';
            }
            echo $desc != '' ? '<span class="description">' . $desc . '</span>' : '';
            break;
        case 'number':
            $options[$id] = esc_attr(stripslashes($options[$id]));
            echo '<input class="small-text' . $field_class . '" type="number" id="' . $id . '" name="' . $cmsms_option_name . '[' . $id . ']" value="' . $options[$id] . '" />' . ($desc != '' ? ' &nbsp; ' . '<span class="description">' . $desc . '</span>' : '');
            break;
        case 'radio':
            foreach ($choices as $item) {
                $item = explode('|', $item);
                $item[0] = esc_html($item[0]);
                echo '<input class="radio' . $field_class . '" type="radio" id="' . $id . '|' . $item[1] . '" name="' . $cmsms_option_name . '[' . $id . ']" value="' . $item[1] . '" ' . checked($options[$id], $item[1], false) . ' /> &nbsp;' . '<label for="' . $id . '|' . $item[1] . '">' . $item[0] . '</label>' . '<br />';
            }
            echo $desc != '' ? '<span class="description">' . $desc . '</span>' : '';
            break;
        case 'radio_img':
            foreach ($choices as $item) {
                $item = explode('|', $item);
                $item[0] = esc_html($item[0]);
                echo '<div style="text-align:center; float:left; margin-right:20px;">' . '<input class="radio' . $field_class . '" type="radio" id="' . $id . '|' . $item[2] . '" name="' . $cmsms_option_name . '[' . $id . ']" value="' . $item[2] . '" ' . checked($options[$id], $item[2], false) . ' />' . '<br />' . '<label for="' . $id . '|' . $item[2] . '">' . '<img src="' . $item[1] . '" alt="' . $item[0] . '" title="' . $item[0] . '" />' . '<br />' . $item[0] . '</label>' . '</div>';
            }
            echo $desc != '' ? '<div style="clear:both;"></div>' . '<br />' . '<span class="description">' . $desc . '</span>' : '';
            break;
        case 'color':
            $options[$id] = esc_attr(stripslashes($options[$id]));
            echo '<input type="text" id="' . $id . '" name="' . $cmsms_option_name . '[' . $id . ']" value="' . $options[$id] . '" class="my-color-field" data-default-color="' . $std . '" />' . '<br />' . '<span class="description">' . ($desc != '' ? $desc . '<br />' : '') . '</span>' . '<script type="text/javascript">' . 'jQuery(document).ready(function () { ' . '(function ($) { ' . "\$('#" . $id . "').wpColorPicker(); " . '} )(jQuery); ' . '} ); ' . '</script>';
            break;
        case 'upload':
            $options[$id] = esc_attr(stripslashes($options[$id]));
            $image = $std;
            echo '<span id="' . $id . '_default" class="custom_default_image" style="display:none;">' . $image . '</span>';
            if (isset($options[$id]) && $options[$id] != '' && $options[$id] != $std) {
                if (is_numeric($options[$id])) {
                    $image = wp_get_attachment_image_src($options[$id], 'medium');
                    $image = $image[0];
                } else {
                    $image = $options[$id];
                }
            }
            echo '<input id="' . $id . '" name="' . $cmsms_option_name . '[' . $id . ']" type="hidden" class="custom_upload_image" value="' . (isset($options[$id]) && $options[$id] != '' && $options[$id] != $std ? $options[$id] : $std) . '" />' . '<img src="' . $image . '" id="' . $id . '_preview" class="custom_preview_image" alt="" />' . '<br />' . '<input id="' . $id . '_button" class="custom_upload_image_button button" type="button" value="' . __('Choose Image', 'cmsmasters') . '" />' . ' &nbsp; &nbsp; ' . '<small>' . '<a href="#" id="' . $id . '_clear" class="custom_clear_image_button">' . __('Default Image', 'cmsmasters') . '</a>' . '</small>' . '<div style="clear:both;"></div>' . ($desc != '' ? '<br />' . '<span class="description">' . $desc . '</span>' : '') . '<script type="text/javascript">' . 'jQuery(document).ready(function () { ' . '(function ($) { ' . "\$('#" . $id . "_button').bind('click', function (e) { " . 'e.preventDefault(); ' . '$(e.target).cmsmsMediaUploader( { ' . "frameId : 'cmsms-" . $id . "-media-frame', " . "frameClass : 'media-frame cmsms-media-frame cmsms-" . $id . "-media-frame', " . "frameTitle : '" . __('Choose image', 'cmsmasters') . "', " . "frameButton : '" . __('Choose', 'cmsmasters') . "', " . 'multiple : false ' . '} ); ' . '} ); ' . '} )(jQuery); ' . '} ); ' . '</script>';
            break;
        case 'typorgaphy':
            $system_font = in_array('system_font', $choices) ? true : false;
            $google_font = in_array('google_font', $choices) ? true : false;
            $font_color = in_array('font_color', $choices) ? true : false;
            $font_size = in_array('font_size', $choices) ? true : false;
            $line_height = in_array('line_height', $choices) ? true : false;
            $font_weight = in_array('font_weight', $choices) ? true : false;
            $font_style = in_array('font_style', $choices) ? true : false;
            if ($system_font) {
                echo '<div class="cmsms_admin_block">' . '<select class="select" id="' . $id . '_system_font" name="' . $cmsms_option_name . '[' . $id . '_system_font]">';
                foreach (cmsms_system_fonts_list() as $key => $value) {
                    echo '<option value="' . $key . '"' . ($options[$id . '_system_font'] == $key ? ' selected="selected"' : '') . '>' . $value . '</option>';
                }
                echo '</select>' . ' &nbsp; ' . '<label for="' . $id . '_system_font">' . __('System Font', 'cmsmasters') . '</label>' . '</div>';
            }
            if ($google_font) {
                echo '<div class="cmsms_admin_block">' . '<select class="select" id="' . $id . '_google_font" name="' . $cmsms_option_name . '[' . $id . '_google_font]">';
                foreach (cmsms_google_fonts_list() as $key => $value) {
                    echo '<option value="' . $key . '"' . ($options[$id . '_google_font'] == $key ? ' selected="selected"' : '') . '>' . $value . '</option>';
                }
                echo '</select>' . ' &nbsp; ' . '<label for="' . $id . '_google_font">' . __('Google Font', 'cmsmasters') . '</label>' . '</div>';
            }
            if ($font_color) {
                echo '<div class="cmsms_admin_block" style="padding-bottom:20px;">' . '<input type="text" id="' . $id . '_font_color" name="' . $cmsms_option_name . '[' . $id . '_font_color]" value="' . $options[$id . '_font_color'] . '" class="my-color-field" data-default-color="' . $std['font_color'] . '" />' . ' &nbsp; ' . '<label for="' . $id . '_font_color" style="padding-bottom:15px;">' . __('Font Color', 'cmsmasters') . '</label>' . '</div>' . '<script type="text/javascript">' . 'jQuery(document).ready(function () { ' . '(function ($) { ' . "\$('#" . $id . "_font_color').wpColorPicker(); " . '} )(jQuery); ' . '} ); ' . '</script>';
            }
            if ($font_size) {
                echo '<div class="cmsms_admin_block">' . '<input class="small-text" type="text" id="' . $id . '_font_size_number" name="' . $cmsms_option_name . '[' . $id . '_font_size]" value="' . $options[$id . '_font_size'] . '" /> ' . ' &nbsp; ' . '<label for="' . $id . '_font_size_number">' . __('Font Size', 'cmsmasters') . ' <em>(' . __('in pixels', 'cmsmasters') . ')</em></label>' . '</div>';
            }
            if ($line_height) {
                echo '<div class="cmsms_admin_block">' . '<input class="small-text" type="text" id="' . $id . '_line_height_number" name="' . $cmsms_option_name . '[' . $id . '_line_height]" value="' . $options[$id . '_line_height'] . '" /> ' . ' &nbsp; ' . '<label for="' . $id . '_line_height_number">' . __('Line Height', 'cmsmasters') . ' <em>(' . __('in pixels', 'cmsmasters') . ')</em></label>' . '</div>';
            }
            if ($font_weight) {
                echo '<div class="cmsms_admin_block">' . '<select class="select" id="' . $id . '_font_weight" name="' . $cmsms_option_name . '[' . $id . '_font_weight]">';
                foreach (cmsms_font_weight_list() as $key => $value) {
                    echo '<option value="' . $key . '"' . ($options[$id . '_font_weight'] == $key ? ' selected="selected"' : '') . '>' . $value . '</option>';
                }
                echo '</select>' . ' &nbsp; ' . '<label for="' . $id . '_font_weight">' . __('Font Weight', 'cmsmasters') . '</label>' . '</div>';
            }
            if ($font_style) {
                echo '<div class="cmsms_admin_block">' . '<select class="select" id="' . $id . '_font_style" name="' . $cmsms_option_name . '[' . $id . '_font_style]">';
                foreach (cmsms_font_style_list() as $key => $value) {
                    echo '<option value="' . $key . '"' . ($options[$id . '_font_style'] == $key ? ' selected="selected"' : '') . '>' . $value . '</option>';
                }
                echo '</select>' . ' &nbsp; ' . '<label for="' . $id . '_font_style">' . __('Font Style', 'cmsmasters') . '</label>' . '</div>';
            }
            echo $desc != '' ? '<span class="description">' . $desc . '</span>' : '';
            break;
        case 'sidebar':
            echo '<script type="text/javascript"> ' . 'jQuery(document).ready(function () { ' . "jQuery('.sidebar_management').on('click', '.sidebar_del', function () { " . "var del_sidebar_number = Number(jQuery('#custom_sidebars_number').val()) - 1; " . "jQuery('#custom_sidebars_number').val(del_sidebar_number); " . 'jQuery(this).parent().remove(); ' . 'var li_input = undefined, ' . "li_input_val = '';" . 'for (var n = 1; n <= del_sidebar_number; n += 1) { ' . "li_input = jQuery('.sidebar_management ul li:eq(' + (n - 1) + ')').find('input[type=\"hidden\"]');" . "li_input_val = li_input.attr('name').split('_-_');" . "jQuery('.sidebar_management ul li:eq(' + (n - 1) + ')').find('input[type=\"hidden\"]').attr( { name :  li_input_val[0] + '_-_' + n + ']'} );" . '} ' . 'return false; ' . '} ); ' . "jQuery('#add_sidebar').click(function () { " . "if (jQuery('#new_sidebar_name').val() !== '') { " . "var sidebar_number = Number(jQuery('#custom_sidebars_number').val()) + 1; " . "jQuery('#custom_sidebars_number').val(sidebar_number); " . "jQuery('.sidebar_management ul').append('<li>' + " . "'<a href=\"#\" class=\"sidebar_del\">" . __('Delete', 'cmsmasters') . "</a> ' + " . "jQuery('#new_sidebar_name').val() + " . "'<input type=\"hidden\" name=\"" . $cmsms_option_name . "[" . $id . "_-_' + sidebar_number + ']\" value=\"' + jQuery('#new_sidebar_name').val() + '\" />' + " . "'</li>'); " . "jQuery('#new_sidebar_name').val(''); " . '}' . 'return false; ' . '} ); ' . '} ); ' . '</script>' . ($desc != '' ? '<span class="description">' . $desc . '</span>' . '<br />' . '<br />' : '') . '<div class="sidebar_management">' . '<p>' . '<input class="all-options" type="text" id="new_sidebar_name" />' . '<input class="button" type="button" id="add_sidebar" value="' . __('Add Sidebar', 'cmsmasters') . '" />' . '</p>' . '<div></div>' . '<ul>';
            if (isset($options[$id]) && is_array($options[$id])) {
                $i = 0;
                foreach ($options[$id] as $sidebar) {
                    $i++;
                    echo '<li>' . '<a href="#" class="sidebar_del">' . __('Delete', 'cmsmasters') . '</a> ' . $sidebar . '<input type="hidden" name="' . $cmsms_option_name . '[' . $id . '_-_' . $i . ']" value="' . $sidebar . '" />' . '</li>';
                }
            }
            echo '</ul>' . '<input id="custom_sidebars_number" type="hidden" name="' . $cmsms_option_name . '[' . $id . '_number]" value="' . (isset($options[$id]) && is_array($options[$id]) ? $i : 0) . '" />' . '</div>';
            break;
        case 'heading':
            echo ($desc != '' ? '<span class="description">' . $desc . '</span>' . '<br />' . '<br />' : '') . '<div class="icon_management">' . '<p>' . '<input id="' . $id . '_button" class="heading_upload_image_button button" type="button" value="' . __('Add Icons', 'cmsmasters') . '" />' . '</p>' . '<div></div>' . '<ul>';
            if (isset($options[$id]) && is_array($options[$id])) {
                $i = 0;
                foreach ($options[$id] as $icon) {
                    $image = wp_get_attachment_image_src($icon, 'thumbnail');
                    $image = $image[0];
                    $i++;
                    echo '<li>' . '<div>' . '<img src="' . $image . '" alt="" class="icon_list_image" />' . '<input type="hidden" name="' . $cmsms_option_name . '[' . $id . '_-_' . $i . ']" value="' . $icon . '" />' . '</div>' . '<a href="#" class="icon_del" title="' . __('Delete', 'cmsmasters') . '">' . __('Delete', 'cmsmasters') . '</a> ' . '</li>';
                }
            }
            echo '</ul>' . '<input id="heading_icons_number" type="hidden" name="' . $cmsms_option_name . '[' . $id . '_number]" value="' . $i . '" />' . '</div>' . '<script type="text/javascript">' . 'jQuery(document).ready(function () { ' . '(function ($) { ' . "\$('#" . $id . "_button').bind('click', function (e) { " . 'e.preventDefault(); ' . '$(e.target).cmsmsMediaUploader( { ' . "frameId : 'cmsms-" . $id . "-media-frame', " . "frameClass : 'media-frame cmsms-media-frame cmsms-" . $id . "-media-frame', " . "frameTitle : '" . __('Choose heading icons', 'cmsmasters') . "', " . "frameButton : '" . __('Choose', 'cmsmasters') . "', " . "optionName : '" . $cmsms_option_name . "', " . "optionID : '" . $id . "', " . "deleteText : '" . __('Delete', 'cmsmasters') . "', " . 'multiple : true ' . '} ); ' . '} ); ' . '} )(jQuery); ' . '} ); ' . '</script>';
            break;
        case 'social':
            echo ($desc != '' ? '<span class="description">' . $desc . '</span>' . '<br />' . '<br />' : '') . '<div class="icon_management">' . '<p>' . '<img src="" class="icon_preview_image" alt="" style="display:none;" />' . '<small style="display:none;">' . '<a href="#" class="icon_clear_image_button">[X] ' . __('Cancel', 'cmsmasters') . '</a>' . '</small>' . '<span class="cl"></span>' . '<span class="icon_upload_link" style="display:none;">' . '<input class="my-color-field" type="text" id="new_icon_color" value="#000000" data-default-color="#000000" />' . '<label for="new_icon_color">' . __('Choose Color for This Icon', 'cmsmasters') . '</label>' . '<br /><br />' . '<input class="all-options" type="text" id="new_icon_link" /> ' . '<label for="new_icon_link">' . __('Enter Link for This Icon', 'cmsmasters') . '</label>' . '<br />' . '<input class="all-options" type="text" id="new_icon_title" /> ' . '<label for="new_icon_title">' . __('Enter Title for This Icon', 'cmsmasters') . '</label>' . '<br /><br />' . '<input type="checkbox" id="new_icon_target" value="true" /> ' . '<label for="new_icon_target">' . __('Open Link in a New Tab', 'cmsmasters') . '</label>' . '</span>' . '<span class="cl"></span>' . '<input class="icon_upload_image all-options" type="hidden" id="new_icon_name" />' . '<input id="' . $id . '_button" class="icon_upload_image_button button" type="button" value="' . __('Choose new social icon image', 'cmsmasters') . '" />' . '<span class="cl"><br /></span>' . '<input class="button-primary" type="button" id="add_icon" value="' . __('Add Icon', 'cmsmasters') . '" />' . '<input class="button-primary" type="button" id="edit_icon" value="' . __('Save Icon', 'cmsmasters') . '" style="display:none;" />' . '</p>' . '<div></div>' . '<ul>';
            if (isset($options[$id]) && is_array($options[$id])) {
                $i = 0;
                foreach ($options[$id] as $icon) {
                    $icon_array = explode('|', $icon);
                    if (is_numeric($icon_array[0])) {
                        $image = wp_get_attachment_image_src($icon_array[0], 'thumbnail');
                        $image = $image[0];
                    } else {
                        $image = $icon_array[0];
                    }
                    $i++;
                    echo '<li>' . '<div>' . '<img src="' . $image . '" alt="" class="icon_list_image" />' . '<input type="hidden" id="' . $cmsms_option_name . '_' . $id . '_-_' . $i . '" name="' . $cmsms_option_name . '[' . $id . '_-_' . $i . ']" value="' . $icon . '" />' . '</div>' . '<a href="#" class="icon_del" title="' . __('Delete', 'cmsmasters') . '">' . __('Delete', 'cmsmasters') . '</a> ' . '<a href="#" class="icon_edit" title="' . __('Edit', 'cmsmasters') . '">' . __('Edit', 'cmsmasters') . '</a> ' . '</li>';
                }
            }
            echo '</ul>' . '<input id="custom_icons_number" type="hidden" name="' . $cmsms_option_name . '[' . $id . '_number]" value="' . $i . '" />' . '</div>' . '<script type="text/javascript"> ' . 'jQuery(document).ready(function () { ' . "jQuery('#add_icon').click(function () { " . "if (jQuery('#new_icon_name').val() !== '') { " . "var icon_number = Number(jQuery('#custom_icons_number').val()) + 1; " . "jQuery('#custom_icons_number').val(icon_number); " . "jQuery('.icon_management ul').append('<li>' + " . "'<div>' + " . "'<img src=\"' + jQuery('#new_icon_name').parent().find('.icon_preview_image').attr('src') + '\" alt=\"\" class=\"icon_list_image\" />' + " . "'<input type=\"hidden\" id=\"" . $cmsms_option_name . "_" . $id . "_-_' + icon_number + '\" name=\"" . $cmsms_option_name . "[" . $id . "_-_' + icon_number + ']\" value=\"' + jQuery('#new_icon_name').val() + '|' + jQuery('#new_icon_color').val() + '|' + jQuery('#new_icon_link').val() + '|' + jQuery('#new_icon_title').val() + '|' + ((jQuery('#new_icon_target').is(':checked')) ? 'true' : 'false') + '\" />' + " . "'</div>' + " . "'<a href=\"#\" class=\"icon_del\" title=\"" . __('Delete', 'cmsmasters') . "\">" . __('Delete', 'cmsmasters') . "</a> ' + " . "'<a href=\"#\" class=\"icon_edit\" title=\"" . __('Edit', 'cmsmasters') . "\">" . __('Edit', 'cmsmasters') . "</a> ' + " . "'</li>'); " . "jQuery('#new_icon_name').val(''); " . "jQuery('#new_icon_color').val('#000000'); " . "jQuery('#new_icon_link').val(''); " . "jQuery('#new_icon_title').val(''); " . "jQuery('.icon_preview_image').attr( { src : '' } ).hide();" . "jQuery('.icon_clear_image_button').parent().hide();" . "jQuery('.icon_upload_link').hide();" . '}' . 'return false; ' . '} ); ' . '(function ($) { ' . "\$('#" . $id . "_button').bind('click', function (e) { " . 'e.preventDefault(); ' . '$(e.target).cmsmsSocialUploader( { ' . "frameId : 'cmsms-" . $id . "-media-frame', " . "frameClass : 'media-frame cmsms-media-frame cmsms-" . $id . "-media-frame', " . "frameTitle : '" . __('Choose heading icons', 'cmsmasters') . "', " . "frameButton : '" . __('Choose', 'cmsmasters') . "', " . "optionName : '" . $cmsms_option_name . "', " . "optionID : '" . $id . "' " . '} ); ' . '} ); ' . '} )(jQuery); ' . '} ); ' . '</script>';
            break;
    }
}