__( 'Displays content from the current post.', 'siteorigin-panels' ),
)
);
}
function widget( $args, $instance ) {
if( is_admin() ) return;
echo $args['before_widget'];
$content = apply_filters('siteorigin_panels_widget_post_content', $this->default_content($instance['type']));
echo $content;
echo $args['after_widget'];
}
/**
* The default content for post types
* @param $type
* @return string
*/
function default_content($type){
global $post;
if(empty($post)) return;
switch($type) {
case 'title' :
return '
' . $post->post_title . '
';
case 'content' :
return '' . wpautop($post->post_content) . '
';
case 'featured' :
if(!has_post_thumbnail()) return '';
return '' . get_the_post_thumbnail($post->ID) . '
';
default :
return '';
}
}
function update($new, $old){
return $new;
}
function form( $instance ) {
$instance = wp_parse_args($instance, array(
'type' => 'content',
));
$types = apply_filters('siteorigin_panels_widget_post_content_types', array(
'' => __('None', 'siteorigin-panels'),
'title' => __('Title', 'siteorigin-panels'),
'featured' => __('Featured Image', 'siteorigin-panels'),
));
?>