示例#1
0
function clearbase_query_attachments($type = '', $folder_id = null)
{
    $post = get_post($folder_id);
    if (!isset($post) || 'clearbase_folder' != $post->post_type) {
        return new WP_Error('clearbase_invalid_folder', __('You must specify a valid clearbase folder', 'clearbase'));
    }
    return new WP_Query(apply_filters('clearbase_query_media_args', array('post_type' => 'attachment', 'post_mime_type' => $type, 'post_status' => 'any', 'post_parent' => $post->ID, 'orderby' => 'menu_order', 'order' => clearbase_get_value('postmeta.attachment_order', 'DESC', $post->ID), 'posts_per_page' => -1)));
}
示例#2
0
/**
* Gets a Clearbase controller
*
* @param string $selector
* @return mixed|Clearbase_View_Controller|null
*/
function clearbase_get_controller($selector = '', $traverse = true)
{
    $controllers = clearbase_get_controllers();
    if (empty($selector) || is_numeric($selector) || $selector instanceof WP_Post) {
        //attempt to load a controller from a folder;
        $folder = clearbase_load_folder($selector);
        $controller_id = clearbase_get_value('postmeta.clearbase_controller', '', $folder);
        while ($traverse && empty($id) && !is_wp_error($folder) && 0 != $folder->post_parent) {
            $folder = clearbase_load_folder($folder->post_parent);
            $controller_id = clearbase_get_value('postmeta.clearbase_controller', '', $folder);
        }
        $selector = $controller_id;
    }
    $controller = $controllers[$selector];
    return apply_filters('clearbase_get_controller', $controller, $selector);
}
示例#3
0
function _clearbase_sort_posts()
{
    global $wpdb;
    $posts = isset($_REQUEST['attachments']) ? $_REQUEST['attachments'] : $_REQUEST['posts'];
    if (!isset($posts) || !is_array($posts) || 0 == count($posts)) {
        wp_send_json_success();
        exit;
    }
    //sort the posts by the menu_order value
    asort($posts);
    reset($posts);
    //get the first post id
    $post = get_post(key($posts));
    //if the result is not a valid WP_Post
    if (!$post instanceof WP_Post) {
        wp_send_json_success();
        exit;
    }
    //get the sorting order
    $order = clearbase_get_value('postmeta.attachment_order', 'DESC', $post->post_parent);
    //ensure a correct order value
    if ('ASC' != $order || 'DESC' != $order) {
        $order = 'DESC';
    }
    $post__in = implode(',', array_map('absint', array_keys($posts)));
    //get the starting menu order from the database
    $menu_order = $wpdb->get_var($wpdb->prepare("SELECT menu_order FROM {$wpdb->posts} \n        WHERE ID IN ({$post__in}) ORDER BY menu_order {$order} LIMIT 1", $post->post_parent));
    if ('DESC' == $order && $menu_order < count($posts)) {
        //If the menu_order has gotten out of sync.  We need to do a hard reset
        //of all posts in the specified folder to ensure that sorting by DESC will perform correctly.
        $p = clearbase_get_attachments($post->post_parent);
        $posts = array();
        for ($i = 0, $c = count($p); $i < $c; $i++) {
            $posts[$p[$i]->ID] = $p[$i]->menu_order;
        }
        $menu_order = count($posts);
    }
    foreach ($posts as $post_id => $value) {
        if (!($p = get_post($post_id))) {
            continue;
        }
        wp_update_post(array('ID' => $post_id, 'menu_order' => $menu_order));
        $menu_order = max('DESC' == $order ? $menu_order - 1 : $menu_order + 1, 0);
    }
    wp_send_json_success();
}
示例#4
0
function clearbase_init_menus()
{
    $page = clearbase_empty_default($_GET, 'page', '');
    $folder_id = 0;
    if (0 === strrpos($page, 'cbfolder')) {
        $folder_id = absint(substr(strrchr($page, "_"), 1));
        $page = 'cbfolder';
    }
    global $cb_admin_view;
    switch ($page) {
        case 'clearbase':
        case 'cbfolder':
            require_once CLEARBASE_DIR . '/views/class-view-workspace.php';
            $cb_admin_view = new Clearbase_View_Workspace($folder_id);
            break;
        case 'clearbase-settings':
            require_once CLEARBASE_DIR . '/views/class-view-admin-settings.php';
            $cb_admin_view = new Clearbase_View_Admin_Settings();
            break;
    }
    /*
    Render the main Clearbase menus
    */
    add_menu_page(__('Clearbase', 'clearbase'), __('Clearbase', 'clearbase'), 'manage_options', 'clearbase', '_clearbase_admin_render_view', 'dashicons-screenoptions');
    //now add the sub menus
    add_submenu_page('clearbase', __('Clearbase Framework', 'clearbase'), __('Folders', 'clearbase'), 'manage_options', 'clearbase', '_clearbase_admin_render_view');
    add_submenu_page('clearbase', __('Clearbase Settings', 'clearbase'), __('Settings', 'clearbase'), 'manage_options', 'clearbase-settings', '_clearbase_admin_render_view');
    //now loop through all of the root clearbase folders that have menus specified
    $query = new WP_Query(array('post_type' => 'clearbase_folder', 'post_parent' => 0, 'meta_query' => array(array('key' => 'menu', 'compare' => 'EXISTS'))));
    global $post;
    while ($query->have_posts()) {
        $query->the_post();
        $meta = clearbase_get_value('postmeta.menu', array());
        if ('yes' != clearbase_empty_default($meta, 'show', 'no')) {
            continue;
        }
        $menu_slug = 'cbfolder_' . get_the_ID();
        add_menu_page(clearbase_empty_default($meta, 'page_title', get_the_title()), clearbase_empty_default($meta, 'title', get_the_title()), clearbase_empty_default($meta, 'capability', 'manage_options'), $menu_slug, '_clearbase_admin_render_view', clearbase_empty_default($meta, 'icon', 'dashicons-screenoptions'), clearbase_empty_default($meta, 'position', 21));
        //fire the parent menu
        do_action('clearbase_folder_menu', $menu_slug);
    }
}
 /** WP_Media_List_Table does not provide a filter for managing get_views() so,
  *  so we have done the next best thing.  Override
  *
  * @global wpdb  $wpdb
  * @global array $post_mime_types
  * @global array $avail_post_mime_types
  * @return array
  */
 public function get_views()
 {
     global $wpdb, $cb_post_id, $post_mime_types, $avail_post_mime_types;
     $type_links = array();
     // $_num_posts = (array) wp_count_attachments();
     $_num_posts = (array) clearbase_count_attachments($cb_post_id);
     //$_total_posts = array_sum($_num_posts) - $_num_posts['trash'];
     $media_filter = clearbase_get_value('media_filter', '', clearbase_get_folder_settings($cb_post_id));
     if (empty($media_filter)) {
         $media_filter = array_keys($post_mime_types);
     }
     $matches = wp_match_mime_types($media_filter, array_keys($_num_posts));
     $num_posts = array();
     foreach ($matches as $type => $reals) {
         foreach ($reals as $real) {
             $num_posts[$type] = isset($num_posts[$type]) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
         }
     }
     $selected = empty($_GET['attachment-filter']) ? ' selected="selected"' : '';
     if (count($num_posts) > 1) {
         $_total_posts = array_sum($num_posts) - $_num_posts['trash'];
         $type_links['all'] = "<option value=''{$selected}>" . sprintf(_nx('All (%s)', 'All (%s)', $_total_posts, 'uploaded files'), number_format_i18n($_total_posts)) . '</option>';
     }
     foreach ($post_mime_types as $mime_type => $label) {
         if (!wp_match_mime_types($mime_type, $avail_post_mime_types)) {
             continue;
         }
         $selected = '';
         if (!empty($_GET['attachment-filter']) && strpos($_GET['attachment-filter'], 'post_mime_type:') === 0 && wp_match_mime_types($mime_type, str_replace('post_mime_type:', '', $_GET['attachment-filter']))) {
             $selected = ' selected="selected"';
         }
         if (!empty($num_posts[$mime_type])) {
             $type_links[$mime_type] = '<option value="post_mime_type:' . esc_attr($mime_type) . '"' . $selected . '>' . sprintf(translate_nooped_plural($label[2], $num_posts[$mime_type]), number_format_i18n($num_posts[$mime_type])) . '</option>';
         }
     }
     // $type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</option>';
     if (!empty($_num_posts['trash'])) {
         $type_links['trash'] = '<option value="trash"' . (isset($_GET['attachment-filter']) && $_GET['attachment-filter'] == 'trash' ? ' selected="selected"' : '') . '>' . sprintf(_nx('Trash (%s)', 'Trash (%s)', $_num_posts['trash'], 'uploaded files'), number_format_i18n($_num_posts['trash'])) . '</option>';
     }
     return $type_links;
 }
示例#6
0
        public function Render($data = null)
        {
            $this->enqueue_registered();
            $folder = get_post($data);
            if (!isset($folder) || 'clearbase_folder' != $folder->post_type) {
                echo '<p class="error">' . __('FlexSlider: You must specify a valid clearbase folder', 'clearbase_flexslider') . '</p>';
                return false;
            }
            //$folder_settings = clearbase_get_folder_settings($post->ID);
            //$filter = clearbase_get_value('media_filter', 'image', $folder_settings);
            $query = clearbase_query_attachments('image', $folder);
            $settings = clearbase_get_value('postmeta.clearbase_flexslider', null, $folder);
            $classes = apply_filters('clearbase_flexslider_classes', 'flexslider clearbase-flexslider');
            $image_size = clearbase_get_value('image_size', 'flexslider-default', $settings);
            $show_title = clearbase_get_value('show_title', true, $settings);
            $show_caption = clearbase_get_value('show_caption', true, $settings);
            ?>

            <div id="<?php 
            echo "clearbase-flexslider-{$folder->ID}";
            ?>
" class="<?php 
            echo $classes;
            ?>
">			
                <ul class="slides">
                    <?php 
            while ($query->have_posts()) {
                $query->the_post();
                ?>
                    <li>
                        <?php 
                if ('' != clearbase_get_value('postmeta.flexslider_url', '')) {
                    ?>
                            <a href="<?php 
                    echo clearbase_get_value('postmeta.flexslider_url', '');
                    ?>
" rel="bookmark">
                                <?php 
                    echo wp_get_attachment_image(get_the_ID(), $image_size);
                    ?>
                            </a>
                        <?php 
                } else {
                    ?>
                            <?php 
                    echo wp_get_attachment_image(get_the_ID(), $image_size);
                    ?>
                        <?php 
                }
                ?>
                        <?php 
                if ($show_title && $show_caption) {
                    ?>
                            <div class="slide-excerpt slide-<?php 
                    the_ID();
                    ?>
">
                            <div class="slide-excerpt-inner">
                            <?php 
                    if ($show_title) {
                        ?>
                                <h2>
                                    <?php 
                        echo esc_html(get_the_title());
                        ?>
                                </h2>
                            <?php 
                    }
                    ?>
                            <?php 
                    if ($show_caption) {
                        ?>
                                <p>
                                    <?php 
                        echo esc_html(get_the_excerpt());
                        ?>
                                </p>
                            <?php 
                    }
                    ?>

                            </div><!-- end .slide-excerpt-inner  -->
                            </div><!-- end .slide-excerpt  -->
                        <?php 
                }
                ?>
                    </li>
                    <?php 
            }
            ?>
                </ul><!-- end ul.slides -->
            </div><!-- end .flexslider -->
            <?php 
            $output = 'jQuery(document).ready(function($) {
                $("#clearbase-flexslider-' . $folder->ID . '").flexslider({
                    animation: "' . esc_js(clearbase_get_value('animation', 'slide', $settings)) . '",
                    animationDuration: ' . clearbase_get_value('animationDuration', 800, $settings) . ',
                    directionNav: ' . ('yes' == clearbase_get_value('directionNav', 'yes', $settings) ? 'true' : 'false') . ',
                    controlNav: ' . ('yes' == clearbase_get_value('controlNav', 'yes', $settings) ? 'true' : 'false') . ',
                    slideshowSpeed: ' . clearbase_get_value('slideshowSpeed', 4000, $settings) . '
                });
              });';
            $output = str_replace(array("\n", "\t", "\r"), '', $output);
            echo '<script type=\'text/javascript\'>' . $output . '</script>';
        }
    protected function render_subfolder_actions($post)
    {
        $actions = array();
        if (current_user_can('edit_post', $post->ID) && !$this->is_trash) {
            $actions['edit'] = '<a href="' . clearbase_workspace_url(array('id' => $post->ID, 'cbaction' => 'edit', 'back' => clearbase_current_url(true))) . '" title="' . __('Edit Folder', 'clearbase') . '">' . __('Edit', 'clearbase') . '</a>';
        }
        if (clearbase_get_value($this->is_parent_settings ? 'allow_nesting' : 'allow_child_nesting', true, $this->settings)) {
            $actions['move'] = "<a class='move-post' title='" . esc_attr__('Move this folder to another folder', 'clearbase') . "' href='" . clearbase_workspace_url(array('id' => $post->ID, 'cbaction' => 'move', 'cbnonce' => wp_create_nonce('move'))) . "'>" . __('Move', 'clearbase') . "</a>";
        }
        if (current_user_can('delete_post', $post->ID)) {
            $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__('Delete this folder permanently') . "' href='" . clearbase_workspace_url(array('id' => $post->ID, 'cbaction' => 'delete', 'cbnonce' => wp_create_nonce('delete'))) . "'>" . __('Delete', 'clearbase') . "</a>";
            //MEDIA LIST VIEW NOT WORKING
        }
        $actions = apply_filters("clearbase_{$this->ID()}_subfolder_actions", $actions, $post);
        $action_count = count($actions);
        if (!$action_count) {
            return;
        }
        $i = 0;
        ?>
      <div class="folder-actions-container">
        <div class="folder-actions">
        <?php 
        foreach ($actions as $action => $link) {
            ++$i == $action_count ? $sep = '' : ($sep = ' | ');
            echo "<span class='{$action}'>{$link}{$sep}</span>";
        }
        ?>
 
        </div>
      </div>
      <?php 
    }
示例#8
0
    public function RenderEditor()
    {
        global $post, $cb_post;
        //assign the clearbase post object to the wp $post object for this context
        $post = $cb_post;
        foreach ($this->fields as $field) {
            if (!isset($field['type'])) {
                continue;
            }
            if (!isset($field['id'])) {
                $field['id'] = '';
            }
            if (!isset($field['title'])) {
                $field['title'] = isset($field['name']) ? $field['name'] : '';
            }
            if (!isset($field['class'])) {
                $field['class'] = '';
            }
            if (!isset($field['css'])) {
                $field['css'] = '';
            }
            if (!isset($field['default'])) {
                $field['default'] = '';
            }
            if (!isset($field['desc'])) {
                $field['desc'] = '';
            }
            if (!isset($field['desc_tip'])) {
                $field['desc_tip'] = false;
            }
            $convertedID = str_replace('.', '-', $field['id']);
            // Custom attribute handling
            $custom_attributes = array();
            if (!empty($field['custom_attributes']) && is_array($field['custom_attributes'])) {
                foreach ($field['custom_attributes'] as $attribute => $attribute_value) {
                    $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
                }
            }
            // Description handling
            if ($field['desc_tip'] === true) {
                $description = '';
                $tip = $field['desc'];
            } elseif (!empty($field['desc_tip'])) {
                $description = $field['desc'];
                $tip = $field['desc_tip'];
            } elseif (!empty($field['desc'])) {
                $description = $field['desc'];
                $tip = '';
            } else {
                $description = $tip = '';
            }
            if ($description && in_array($field['type'], array('textarea', 'radio'))) {
                $description = '<p style="margin-top:0">' . wp_kses_post($description) . '</p>';
            } elseif ($description && in_array($field['type'], array('checkbox'))) {
                $description = wp_kses_post($description);
            } elseif ($description) {
                $description = '<span class="description">' . wp_kses_post($description) . '</span>';
            }
            if ($tip && in_array($field['type'], array('checkbox'))) {
                $tip = '<p class="description">' . $tip . '</p>';
            } elseif ($tip) {
                $tip = '<img />';
                //'<img class="help_tip" data-tip="' . esc_attr( $tip ) . '" src="' . WC()->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
            }
            // Switch based on type
            switch ($field['type']) {
                // Section Titles
                case 'sectionstart':
                    if (!empty($field['title'])) {
                        echo '<h3>' . esc_html($field['title']) . '</h3>';
                    }
                    if (!empty($field['desc'])) {
                        echo wpautop(wptexturize(wp_kses_post($field['desc'])));
                    }
                    echo '<table class="form-table ' . $field['class'] . '">' . "\n\n";
                    if (!empty($field['id'])) {
                        do_action('clearbase_editor_section_' . sanitize_title($field['id']));
                    }
                    break;
                    // Section Ends
                // Section Ends
                case 'sectionend':
                    if (!empty($field['id'])) {
                        do_action('clearbase_editor_section_' . sanitize_title($field['id']) . '_end');
                    }
                    echo '</table>';
                    if (!empty($field['id'])) {
                        do_action('clearbase_editor_section_' . sanitize_title($field['id']) . '_after');
                    }
                    break;
                case 'post_title':
                    ?>
<tr valign="top">
                    <th scope="row" class="titledesc">
                        <label for="post-post_title"><?php 
                    echo __('Title', 'clearbase');
                    ?>
</label>
                    </th>
                    <td class="forminp forminp-text">
                        <input
                            name="post-post_title"
                            id="post-post_title"
                            type="text"
                            style="min-width: 300px"
                            value="<?php 
                    echo esc_attr($post->post_title);
                    ?>
"
                            class=""
                        /> <?php 
                    //Render the permalink editor
                    $sample_permalink_html = get_sample_permalink_html($post->ID);
                    // $shortlink = wp_get_shortlink($post->ID, 'post');
                    // if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) )
                    //     $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
                    if (!('pending' == get_post_status($post) && !current_user_can($post_type_object->cap->publish_posts))) {
                        $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
                        ?>
                                <div id="edit-slug-box" class="hide-if-no-js">
                                <?php 
                        if ($has_sample_permalink) {
                            echo $sample_permalink_html;
                        }
                        ?>
                                </div>
                            <?php 
                    }
                    ?>
                    </td>
                </tr>
                <tr valign="top" class="hide-if-js">
                    <th scope="row" class="titledesc">
                            <label for="post-post_name"><?php 
                    echo esc_html(__('Slug', 'clearbase'));
                    ?>
</label>
                            <?php 
                    echo $tip;
                    ?>
                    </th>
                    <td class="forminp forminp-text">
                      <input
                        name="post-post_name"
                        id="post-post_name"
                        type="text"
                        style="min-width: 300px"
                        value="<?php 
                    echo esc_attr($post->post_name);
                    ?>
"
                        class=""
                        /> <?php 
                    echo __('Specifies the permalink slug', 'clearbase');
                    ?>
                    </td>
                </tr>
                <?php 
                    break;
                    // Standard text inputs and subtypes like 'number'
                // Standard text inputs and subtypes like 'number'
                case 'text':
                case 'email':
                case 'number':
                case 'color':
                case 'password':
                    $type = $field['type'];
                    $class = '';
                    $option_value = clearbase_get_value($field['id'], $field['default']);
                    if ($field['type'] == 'color') {
                        $type = 'text';
                        $field['class'] .= 'colorpick';
                        $description .= '<div id="colorPickerDiv_' . $convertedID . ' " class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>';
                    }
                    ?>
<tr valign="top" class="<?php 
                    echo $field['tr_class'];
                    ?>
">
                            <th scope="row" class="titledesc <?php 
                    echo $field['th_class'];
                    ?>
">
                                    <label for="<?php 
                    echo $convertedID;
                    ?>
"><?php 
                    echo esc_html($field['title']);
                    ?>
</label>
                                    <?php 
                    echo $tip;
                    ?>
                            </th>
	                    <td class="forminp forminp-<?php 
                    echo sanitize_title($field['type']);
                    echo $field['td_class'];
                    ?>
">
	                    	<input
	                    		name="<?php 
                    echo $convertedID;
                    ?>
"
	                    		id="<?php 
                    echo $convertedID;
                    ?>
"
	                    		type="<?php 
                    echo esc_attr($type);
                    ?>
"
	                    		style="<?php 
                    echo esc_attr($field['css']);
                    ?>
"
	                    		value="<?php 
                    echo esc_attr($option_value);
                    ?>
"
	                    		class="<?php 
                    echo esc_attr($field['class']);
                    ?>
"
	                    		<?php 
                    echo implode(' ', $custom_attributes);
                    ?>
	                    		/> <?php 
                    echo $description;
                    ?>
	                    </td>
	                </tr><?php 
                    break;
                    // Textarea
                // Textarea
                case 'textarea':
                    $option_value = clearbase_get_value($field['id'], $field['default']);
                    ?>
<tr valign="top" class="<?php 
                    echo $field['tr_class'];
                    ?>
">
						<th scope="row" class="titledesc <?php 
                    echo $field['th_class'];
                    ?>
">
							<label for="<?php 
                    echo $convertedID;
                    ?>
"><?php 
                    echo esc_html($field['title']);
                    ?>
</label>
							<?php 
                    echo $tip;
                    ?>
						</th>
	                    <td class="forminp forminp-<?php 
                    echo sanitize_title($field['type']);
                    echo $field['td_class'];
                    ?>
">
	                    	<?php 
                    echo $description;
                    ?>

	                        <textarea
	                        	name="<?php 
                    echo $convertedID;
                    ?>
"
	                        	id="<?php 
                    echo $convertedID;
                    ?>
"
	                        	style="<?php 
                    echo esc_attr($field['css']);
                    ?>
"
	                        	class="<?php 
                    echo esc_attr($field['class']);
                    ?>
"
	                        	<?php 
                    echo implode(' ', $custom_attributes);
                    ?>
	                        	><?php 
                    echo esc_textarea($option_value);
                    ?>
</textarea>
	                    </td>
	                </tr><?php 
                    break;
                    // Select boxes
                // Select boxes
                case 'select':
                case 'multiselect':
                    $option_value = clearbase_get_value($field['id'], $field['default']);
                    ?>
<tr valign="top" class="<?php 
                    echo $field['tr_class'];
                    ?>
">
						<th scope="row" class="titledesc <?php 
                    echo $field['th_class'];
                    ?>
">
							<label for="<?php 
                    echo $convertedID;
                    ?>
"><?php 
                    echo esc_html($field['title']);
                    ?>
</label>
							<?php 
                    echo $tip;
                    ?>
						</th>
	                    <td class="forminp forminp-<?php 
                    echo sanitize_title($field['type']);
                    echo $field['td_class'];
                    ?>
">
	                    	<select
	                    		name="<?php 
                    echo $convertedID;
                    if ($field['type'] == 'multiselect') {
                        echo '[]';
                    }
                    ?>
"
	                    		id="<?php 
                    echo $convertedID;
                    ?>
"
	                    		style="<?php 
                    echo esc_attr($field['css']);
                    ?>
"
	                    		class="<?php 
                    echo esc_attr($field['class']);
                    ?>
"
	                    		<?php 
                    echo implode(' ', $custom_attributes);
                    ?>
	                    		<?php 
                    if ($field['type'] == 'multiselect') {
                        echo 'multiple="multiple"';
                    }
                    ?>
	                    		>
		                    	<?php 
                    foreach ($field['options'] as $key => $val) {
                        ?>
			                        	<option value="<?php 
                        echo esc_attr($key);
                        ?>
" <?php 
                        if (is_array($option_value)) {
                            selected(in_array($key, $option_value), true);
                        } else {
                            selected($option_value, $key);
                        }
                        ?>
><?php 
                        echo $val;
                        ?>
</option>
			                        	<?php 
                    }
                    ?>
	                       </select> <?php 
                    echo $description;
                    ?>
	                    </td>
	                </tr><?php 
                    break;
                    // Radio inputs
                // Radio inputs
                case 'radio':
                    $option_value = clearbase_get_value($field['id'], $field['default']);
                    ?>
<tr valign="top" class="<?php 
                    echo $field['tr_class'];
                    ?>
">
						<th scope="row" class="titledesc <?php 
                    echo $field['th_class'];
                    ?>
">
							<label for="<?php 
                    echo $convertedID;
                    ?>
"><?php 
                    echo esc_html($field['title']);
                    ?>
</label>
							<?php 
                    echo $tip;
                    ?>
						</th>
	                    <td class="forminp forminp-<?php 
                    echo sanitize_title($field['type']);
                    echo $field['td_class'];
                    ?>
">
	                    	<fieldset>
	                    		<?php 
                    echo $description;
                    ?>
	                    		<ul>
	                    		<?php 
                    foreach ($field['options'] as $key => $val) {
                        ?>
			                        	<li>
			                        		<label><input
				                        		name="<?php 
                        echo $convertedID;
                        ?>
"
				                        		value="<?php 
                        echo $key;
                        ?>
"
				                        		type="radio"
					                    		style="<?php 
                        echo esc_attr($field['css']);
                        ?>
"
					                    		class="<?php 
                        echo esc_attr($field['class']);
                        ?>
"
					                    		<?php 
                        echo implode(' ', $custom_attributes);
                        ?>
					                    		<?php 
                        checked($key, $option_value);
                        ?>
				                        		/> <?php 
                        echo $val;
                        ?>
</label>
			                        	</li>
			                        	<?php 
                    }
                    ?>
	                    		</ul>
	                    	</fieldset>
	                    </td>
	                </tr><?php 
                    break;
                    // Checkbox input
                // Checkbox input
                case 'checkbox':
                    $option_value = clearbase_get_value($field['id'], $field['default']);
                    $visbility_class = array();
                    if (!isset($field['hide_if_checked'])) {
                        $field['hide_if_checked'] = false;
                    }
                    if (!isset($field['show_if_checked'])) {
                        $field['show_if_checked'] = false;
                    }
                    if ($field['hide_if_checked'] == 'yes' || $field['show_if_checked'] == 'yes') {
                        $visbility_class[] = 'hidden_option';
                    }
                    if ($field['hide_if_checked'] == 'option') {
                        $visbility_class[] = 'hide_options_if_checked';
                    }
                    if ($field['show_if_checked'] == 'option') {
                        $visbility_class[] = 'show_options_if_checked';
                    }
                    if (!isset($field['checkboxgroup']) || 'start' == $field['checkboxgroup']) {
                        ?>
		            		<tr valign="top" class="<?php 
                        echo esc_attr(implode(' ', $visbility_class));
                        echo $field['tr_class'];
                        ?>
">
								<th scope="row" class="titledesc <?php 
                        echo $field['th_class'];
                        ?>
"><?php 
                        echo esc_html($field['title']);
                        ?>
</th>
								<td class="forminp forminp-checkbox <?php 
                        echo $field['td_class'];
                        ?>
">
									<fieldset>
						<?php 
                    } else {
                        ?>
		            		<fieldset class="<?php 
                        echo esc_attr(implode(' ', $visbility_class));
                        ?>
">
	            		<?php 
                    }
                    if (!empty($field['title'])) {
                        ?>
	            			<legend class="screen-reader-text"><span><?php 
                        echo esc_html($field['title']);
                        ?>
</span></legend>
	            		<?php 
                    }
                    ?>
						<label for="<?php 
                    echo $convertedID;
                    ?>
">
							<input
								name="<?php 
                    echo $convertedID;
                    ?>
"
								id="<?php 
                    echo $convertedID;
                    ?>
"
								type="checkbox"
								value="1"
								<?php 
                    checked($option_value, 'yes');
                    ?>
								<?php 
                    echo implode(' ', $custom_attributes);
                    ?>
							/> <?php 
                    echo $description;
                    ?>
						</label> <?php 
                    echo $tip;
                    ?>
					<?php 
                    if (!isset($field['checkboxgroup']) || 'end' == $field['checkboxgroup']) {
                        ?>
									</fieldset>
								</td>
							</tr>
						<?php 
                    } else {
                        ?>
							</fieldset>
						<?php 
                    }
                    break;
                    // Default: run an action
                // Default: run an action
                default:
                    if (is_callable($field['render'])) {
                        call_user_func($field['render'], $field);
                    }
                    do_action('clearbase_editor_field_' . $field['type'], $field);
                    break;
            }
        }
    }