Example #1
0
function cws_pb_print_layout($layout)
{
    $out = '';
    foreach ($layout as $key => $v) {
        $row_classes = isset($v['rowclasses']) ? $v['rowclasses'] : 'row row_options ' . $key;
        $out .= '<div class="' . $row_classes . '">';
        if (isset($v['title'])) {
            $out .= '<label for="' . $key . '">' . $v['title'] . '</label>';
        }
        if (isset($v['p_title'])) {
            $out .= '<label for="' . $key . '">' . $v['p_title'] . '</label>';
        }
        $value = isset($v['value']) ? ' value="' . $v['value'] . '"' : '';
        $atts = isset($v['atts']) ? ' ' . $v['atts'] : '';
        switch ($v['type']) {
            case 'text':
            case 'checkbox':
                $out .= '<input type="' . $v['type'] . '" name="' . $key . '"' . $value . $atts . '>';
                break;
            case 'insertmedia':
                $out .= '<div class="cws_tmce_buttons">';
                $out .= '<a href="#" id="insert-media-button" class="button insert-media add_media" data-editor="content" title="Add Media"><span class="wp-media-buttons-icon"></span> Add Media</a>';
                $out .= '<div class="cws_tmce_controls">';
                $out .= '<a href="#" id="cws-switch-text" class="button" data-editor="content" data-mode="tmce" title="Switch to Text">Switch to Text</a>';
                $out .= '</div></div>';
                break;
            case 'textarea':
                $out .= '<textarea name="' . $key . '" rows="3"' . $atts . '>' . (isset($v['value']) ? $v['value'] : '') . '</textarea>';
                break;
            case 'taxonomy':
                $taxonomy = isset($v['taxonomy']) ? $v['taxonomy'] : '';
                $out .= '<select name="' . $key . '"' . $atts . '>';
                $out .= cws_pb_print_taxonomy($taxonomy);
                $out .= '</select>';
                break;
            case 'select':
                $out .= '<select name="' . $key . '"' . $atts . ' data-options="select:options">';
                $source = $v['source'];
                if (is_string($source)) {
                    list($func, $arg0) = explode(' ', $source);
                    $out .= call_user_func_array('cws_pb_print_' . $func, array($arg0));
                } else {
                    foreach ($source as $key => $value) {
                        $selected = isset($value[1]) && true === $value[1] ? ' selected' : '';
                        $data_options = !empty($value[2]) ? ' data-options="' . $value[2] . '"' : '';
                        $out .= '<option value="' . $key . '"' . $data_options . $selected . '>' . $value[0] . '</option>';
                    }
                }
                $out .= '</select>';
                break;
            case 'media':
                //$out .= '<label for="cws-pb-row-img">' . __('Add background image', THEME_SLUG) . '</label>';
                $out .= '<div class="img-wrapper">';
                $out .= '<a id="pb-media-cws-pb">' . __('Click to select image', THEME_SLUG) . '</a>';
                $out .= '<a id="pb-remov-cws-pb" style="display:none">' . __('Remove this image', THEME_SLUG) . '</a>';
                $out .= '<input class="widefat" data-key="' . $key . '" readonly id="cws-pb-row-img" name="p_cws-pb-row-img" type="hidden" value="" />';
                $out .= '<input class="widefat" data-key="' . $key . '" readonly id="cws-pb-row-img-id" name="p_cws-pb-row-img-id" type="hidden" value="" />';
                $out .= '<img id="img-cws-pb" src />';
                $out .= '</div>';
                break;
        }
        $out .= '</div>';
    }
    return $out;
}
Example #2
0
	</div>
</div>
<!-- Ourteam -->
<div id="cws-pb-ourteam" style="display:none">
	<div class="row row_options">
		<label for="title">Title:</label><input type="text" name="title"><br/>
	</div>
	<div class="row row_options">
		<label for="p_render_o">Grid:</label><input name="p_render_o" type="radio" value="grid" checked />
		<label for="p_render_o">Carousel:</label><input name="p_render_o" type="radio" value="carousel"><br/>
	</div>
	<div class="row row_options">
		<label for="p_cats">Select categories</label>
		<select multiple placeholder="Select categories" data-placeholder="Select categories" name="p_cats">
		<?php 
echo cws_pb_print_taxonomy('cws-staff-dept');
?>
		</select>
	</div>
</div>

<?php 
function cws_pb_print_taxonomy($name)
{
    $source = cws_pb_get_taxonomy_array($name);
    $output = '<option value=""></option>';
    foreach ($source as $k => $v) {
        $output .= '<option value="' . $k . '">' . $v . '</option>';
    }
    return $output;
}