array( 'name' => esc_html__( 'Recent Comments', 'mega' ), 'description' => esc_html__( 'Recent Comments Block', 'mega' )), 'universal' => true, 'class_base'=> 'ys-recent-comments' ); parent::__construct( __CLASS__, $args ); } public function settings( $form ) { $form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Title', 'mega' ), 'value' => esc_html__( 'Recent Comments', 'mega' ), 'name' => 'title' )); $form->add_control( 'Mega_Control_Number', array( 'label' => esc_html__( 'Number of comments', 'mega' ), 'pro' => 1, 'value' => 3, 'name' => 'count' )); $form->add_control( 'Mega_Control_onOff', array( 'label' => esc_html__( 'Avatar', 'mega' ), 'pro' => 1, 'value' => 1, 'name' => 'avatar' )); $form->add_sub_control( 'Mega_Control_Number', array( 'control' => 'avatar', 'control_value' => 'true', 'label' => esc_html__( 'Avatar Size (px)', 'mega' ), 'value' => 28, 'name' => 'avatar_size' )); $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][excerpt][meta]', 'name' => 'layout' )); $form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Top', 'mega' ), 'desc' => wp_kses( __( 'Use [author] and [title] snippets to format the title.

Post author - [author]
Post title - [title]', 'mega' ), array( 'br' => true, 'strong' => true )), 'value' => esc_html__( '[author] on [title]', 'mega' ), 'name' => 'top' )); $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], [days] and [author] snippets to format the meta order.

Date - [date]
Days ago - [days]
Comment author - [author]', 'mega' ), array( 'br' => true, 'strong' => true )), 'pro' => 1, 'value' => '[days][author]', 'name' => 'meta' )); } public function block() { extract( $this->mega['settings'] ); echo ''; } public function getMeta( $item, $comm ) { return mega_html( esc_html( $this->getWrap( $item, $comm )), '', '', false ); } public static function getWrap( $item, $comm ) { switch( $item ) { case 'author' : return sprintf( esc_html__( 'By %s', 'mega' ), $comm->comment_author ); case 'date' : return get_the_date(); case 'days' : return sprintf( esc_html__( '%s ago', 'mega' ), human_time_diff( get_comment_date( 'U', $comm->comment_ID ), current_time( 'timestamp' ))); } } }