Example #1
0
<?php

global $pb_options;
$options = function_exists('cws_get_pb_options') ? cws_get_pb_options() : null;
?>

<!-- Text -->
<?php 
if (!$options || in_array('text', $options['modules'])) {
    ?>

<div id="cws-pb-text" style="display:none">
	<div class="row row_options">
		<label for="title">Widget Title:</label>
		<input type="text" name="title">
	</div>
	<div class="row">
		<div class="cws_tmce_buttons">
			<a href="#" id="insert-media-button" class="button insert-media add_media" title="Add Media"><span class="wp-media-buttons-icon"></span> Add Media</a>
			<div class="cws_tmce_controls">
				<a href="#" id="cws-switch-text" class="button" data-editor="content" data-mode="tmce" title="Switch to Text">Switch to Text</a>
			</div>
		</div>
		<div class="cws-pb-tmce">
			<textarea class="wp-editor-area" name="cws-pb-content" id="cws-pb-content"></textarea>
		</div>
	</div>
</div>
<?php 
}
?>
Example #2
0
function cws_pb_portfolio_shortcode($args)
{
    extract(shortcode_atts(array('cats' => '', 'cols' => '2', 'items' => '10'), $args));
    $pb_options = function_exists('cws_get_pb_options') ? cws_get_pb_options() : null;
    $port_post_type = $pb_options && isset($pb_options['portfolio']['options']['post_type']) ? $pb_options['portfolio']['options']['post_type'] : 'portfolio';
    $port_tax = $pb_options && isset($pb_options['portfolio']) ? $pb_options['portfolio']['options']['taxonomy'] : 'cws-portfolio-type';
    $arr = array('posts_per_page' => $items, 'post_type' => $port_post_type, 'ignore_sticky_posts' => true, 'tax_query' => array(array('taxonomy' => $port_tax, 'field' => 'slug', 'terms' => explode(',', str_replace('|', '%', $cats)))));
    if (empty($cats)) {
        unset($arr['tax_query']);
    }
    $output = '';
    $r = new WP_Query($arr);
    if ($r->have_posts()) {
        while ($r->have_posts()) {
            $r->the_post();
            $output .= '<div class="item">';
            $thumb_id = get_post_thumbnail_id(get_the_ID());
            $output .= '<div class="pic" data-id="' . $thumb_id . '">';
            $img = wp_get_attachment_image_src($thumb_id, 'thumbnail');
            $output .= '<img src="' . bfi_thumb($img[0], array('width' => 48, 'height' => 48)) . '" alt="">';
            $output .= '</div></div>';
        }
        $output .= '<div class="clearfix"></div>';
    }
    wp_reset_query();
    return $output;
}