array( 'name' => esc_html__( 'Feature: Auto', 'mega' ), 'description' => esc_html__( 'Feature: Auto', 'mega' )), 'class_base' => 'ys-box-auto' )); } public function settings( $form ) { parent::settings( $form ); $form->add_sub_control( 'Mega_Control_Text', array( 'control' => 'gfx_type', 'control_value' => 'image', 'label' => esc_html__( 'Custom Image URL', 'mega' ), 'name' => 'image_url' )); $form->add_sub_control( 'Mega_Control_Checklist', array( 'control' => 'gfx_type', 'control_value' => 'image', '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_Select', array( 'label' => esc_html__( 'Pages, Posts or Category Posts', 'mega' ), 'value' => 'posts', 'name' => 'type', 'choices' => array( 'cats' => esc_html__( 'Category Posts', 'mega' ), 'posts' => esc_html__( 'Posts', 'mega' ), 'pages' => esc_html__( 'Pages', 'mega' ) ) )); $form->add_sub_control( 'Mega_Control_Number', array( 'control' => 'type', 'control_value' => 'cats', 'label' => esc_html__( 'Number of Results', 'mega' ), 'value' => 1, 'name' => 'count' )); $form->add_sub_control( 'Mega_Control_Select', array( 'control' => 'type', 'control_value' => 'cats', 'label' => esc_html__( 'Select a Category', 'mega' ), 'name' => 'cat', 'use_list' => 1, 'list' => 'mega_cat_list' )); //$form->add_sub_control( 'Mega_Control_onOff', array( 'control' => 'type', 'control_value' => 'pages', 'label' => esc_html__( 'Random Page', 'mega' ), 'value' => 1, 'name' => 'rand_pages' ));//need 2 fix $form->add_sub_control( 'Mega_Control_Checklist', array( 'control' => 'type', 'control_value' => 'pages', 'label' => esc_html__( 'Select Pages', 'mega' ), 'value' => array( 0 => 1 ), 'name' => 'pages', 'use_list' => 1, 'list' => 'mega_page_list' )); $form->add_sub_control( 'Mega_Control_onOff', array( 'control' => 'type', 'control_value' => 'posts', 'label' => esc_html__( 'Random Post', 'mega' ), 'value' => 1, 'name' => 'rand_posts' )); $form->add_sub_control( 'Mega_Control_Checklist', array( 'control' => 'rand_posts', 'control_value' => 'false', 'label' => esc_html__( 'Select Posts', 'mega' ), 'value' => array( 0 => 1 ), 'name' => 'posts', 'use_list' => 1, 'list' => 'mega_post_list' )); $form->add_control( 'Mega_Control_Select', array( 'label' => esc_html__( 'Order By', 'mega' ), '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__( 'Excerpt Character Count', 'mega' ), 'value' => 80, 'name' => 'excerpt_count' ));//110 $form->add_control( 'Mega_Control_onOff', array( 'label' => esc_html__( 'Title', 'mega' ), 'value' => 1, 'name' => 'show_title' )); $form->add_sub_control( 'Mega_Control_Number', array( 'control' => 'show_title', 'control_value' => 'true', 'label' => esc_html__( 'Title Character Count', 'mega' ), 'value' => 35, 'name' => 'title_count' )); $form->add_control( 'Mega_Control_onOff', array( 'label' => esc_html__( 'Link', 'mega' ), 'value' => 1, 'name' => 'show_link' )); $form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Custom Link URL', 'mega' ), 'value' => '', 'name' => 'link' )); $form->add_sub_control( 'Mega_Control_onOff', array( 'control' => 'show_link', 'control_value' => 'true', 'label' => esc_html__( 'Show Button', 'mega' ), 'value' => 0, 'name' => 'show_button' )); $form->add_sub_control( 'Mega_Control_onOff', array( 'control' => 'show_button', 'control_value' => 'true', 'label' => esc_html__( 'Show button as text', 'mega' ), 'value' => 0, 'name' => 'button_as_text' )); $form->add_sub_control( 'Mega_Control_Text', array( 'control' => 'show_button', 'control_value' => 'true', 'label' => esc_html__( 'Button Label', 'mega' ), 'value' => esc_html__( 'Continue reading', 'mega' ), 'name' => 'button_label' )); } public function callback() { $this->getPostQuery(); } public function block() { extract( $this->mega['settings'] ); echo $this->before(); $content = ''; if ( $gfx_position !== 'bottom' ) echo $this->getGFX(); $style = $gfx && ( $gfx_position === 'left' OR $gfx_position === 'right' ) ? 'width: calc(100% - ' . $gfx_width . '%);' : ''; if ( empty( $link )) $link = get_permalink(); if ( isset( $title_desc ) && !empty( $title_desc ) && $title_desc_pos === 'top' ) $content .= '
' . esc_html( $title_desc ) . '
'; if ( $show_title ) { $this->autoTagTitle( $show_link ? $link : '', mega_clean_words( $title_count, get_the_title() )); $content .= $this->getTitle(); } if ( isset( $title_desc ) && !empty( $title_desc ) && $title_desc_pos === 'bottom' ) $content .= '
' . esc_html( $title_desc ) . '
'; $content .= mega_auto_tag( 'div', array( 'text' => esc_html( mega_clean_words( $excerpt_count, get_the_excerpt() )), 'attr' => array( 'class' => 'text clamp' ))); if ( $show_link && $show_button ) { $content .= $this->getButton( $link, $button_label ); } echo $this->getWrapper( $content, $style ); if ( $gfx_position === 'bottom' ) echo $this->getGFX(); echo $this->after(); } }