array( 'name' => esc_html__( 'Posts', 'mega' ), 'description' => esc_html__( 'Recent, popular & random posts block', 'mega' )),
'universal' => true,
'class_base'=> 'ys-recent-posts'
);
parent::__construct( __CLASS__, $args );
}
public function settings( $form )
{
$form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Title', 'mega' ), 'value' => esc_html__( 'Blog Posts', 'mega' ), 'name' => 'title' ));
$form->add_control( 'Mega_Control_Number', array( 'label' => esc_html__( 'Title length', 'mega' ), 'value' => 40, 'name' => 'title_length' ));
$form->add_control( 'Mega_Control_Select', array( 'label' => esc_html__( 'Order By', 'mega' ), 'pro' => 1, 'value' => 'date', 'name' => 'order',
'choices' => array(
'date' => esc_html__( 'Date', 'mega' ),
'rand' => esc_html__( 'Random', 'mega' ),
'comment_count' => esc_html__( 'Comment Count', 'mega' )
)
));
$form->add_control( 'Mega_Control_Number', array( 'label' => esc_html__( 'Number of Results', 'mega' ), 'pro' => 1, 'value' => 3, 'name' => 'count' ));
$form->add_control( 'Mega_Control_Select', array( 'label' => esc_html__( 'Select a Category', 'mega' ), 'name' => 'cat', 'use_list' => 1, 'list' => 'mega_cat_list' ));
$form->add_control( 'Mega_Control_onOff', array( 'label' => esc_html__( 'Image', 'mega' ), 'value' => 1, 'name' => 'image' ));
$form->add_sub_control( 'Mega_Control_Number', array( 'control' => 'image', 'control_value' => 'true', 'label' => esc_html__( 'Image Width (px)', 'mega' ), 'value' => 28, 'name' => 'width' ));
$form->add_sub_control( 'Mega_Control_Number', array( 'control' => 'image', 'control_value' => 'true', 'label' => esc_html__( 'Image Height (px)', 'mega' ), 'value' => 28, 'name' => 'height' ));
$form->add_sub_control( 'Mega_Control_Checklist', array( 'control' => 'image', 'control_value' => 'true', 'label' => esc_html__( 'Image Sources', 'mega' ), 'value' => array( 'featured' => 1, 'first' => 1, 'ph' => 1 ), 'name' => 'sources',
'choices' => array(
'featured' => esc_html__( 'Featured', 'mega' ),
'first' => esc_html__( 'First', 'mega' ),
'ph' => esc_html__( 'Placeholder', 'mega' )
)
));
$form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Layout', 'mega' ), 'desc' => wp_kses( __( 'Use [title], [excerpt] and [meta] snippets to format the layout order.
Title - [title]
Excerpt - [excerpt]
Meta - [meta]', 'mega' ), array( 'br' => true, 'strong' => true )), 'pro' => 1, 'value' => '[title][meta]', 'name' => 'layout' ));
$form->add_control( 'Mega_Control_Number', array( 'label' => esc_html__( 'Excerpt length', 'mega' ), 'value' => 40, 'name' => 'length' ));
$form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Meta', 'mega' ), 'desc' => wp_kses( __( 'Use [date], [comments] and [author] snippets to format the meta order.
Date - [date]
Comments - [comments]
Author - [author]', 'mega' ), array( 'br' => true, 'strong' => true )), 'pro' => 1, 'value' => '[comments][date]', 'name' => 'meta' ));
$form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Date Format', 'mega' ), 'value' => esc_html__( 'F jS, Y', 'mega' ), 'name' => 'date' ));
}
public function block()
{
extract( $this->mega['settings'] );
$query = new WP_Query( array(
'post_type' => 'post',
'orderby' => $order,
'ignore_sticky_posts' => 1,
'posts_per_page' => $count,
'cat' => $cat
));
echo '