array( 'name' => esc_html__( 'Ads', 'mega' ), 'description' => esc_html__( 'Ads block', 'mega' )),//Ad Manager? Ad? 'universal' => true ); parent::__construct( __CLASS__, $args ); } public function settings( $form ) { $form->add_control( 'Mega_Control_Select', array( 'label' => esc_html__( 'Alignment', 'mega' ), 'value' => 'center', 'name' => 'align', 'choices' => array( 'left' => esc_html__( 'Left', 'mega' ), 'center' => esc_html__( 'Center', 'mega' ), 'right' => esc_html__( 'Right', 'mega' ) ) )); $form->add_control( 'Mega_Control_Select', array( 'label' => esc_html__( 'Ad Size', 'mega' ), 'desc' => esc_html__( 'Enter size as (width)x(height), i.e 100x100', 'mega' ), 'value' => '120x240', 'name' => 'size', 'choices' => array( '120x240' => esc_html__( '120 x 240', 'mega' ), '120x600' => esc_html__( '120 x 600', 'mega' ), '160x600' => esc_html__( '160 x 600', 'mega' ), '125x125' => esc_html__( '125 x 125', 'mega' ), '180x150' => esc_html__( '180 x 150', 'mega' ), '200x200' => esc_html__( '200 x 200', 'mega' ), '250x250' => esc_html__( '250 x 250', 'mega' ), '300x250' => esc_html__( '300 x 250', 'mega' ), '234x60' => esc_html__( '234 x 60', 'mega' ), '320x50' => esc_html__( '320 x 50', 'mega' ), '468x60' => esc_html__( '468 x 60', 'mega' ), '728x90' => esc_html__( '728 x 90', 'mega' ) ) )); $form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Link', 'mega' ), 'name' => 'link' )); $form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Image', 'mega' ), 'name' => 'image' )); $form->add_control( 'Mega_Control_Textarea', array( 'label' => esc_html__( 'Custom Code', 'mega' ), 'desc' => wp_kses( __( 'Use the following snippets of code to output the necessary information:

Link - [link]
Image - [image]
Width - [width]
Height - [height]', 'mega' ), array( 'br' => true, 'strong' => true )), 'value' => '', 'name' => 'code' )); } public function block()//add adsense support // type: image & link or addsense { extract( $this->mega['settings'] ); $size = explode( 'x', $size ); $image = empty( $image ) ? sprintf( 'http://placehold.it/%sx%s/fff', $size[0], $size[1] ) : $image; echo '
'; echo mega_parse_message( array( 'link' => $link, 'image' => $image, 'width' => $size[0], 'height' => $size[1] ), $code ); echo '
'; } } class Mega_Block_Post_Ads extends Mega_Walker//Mega_Block_Ads { public function __construct() { $args = array( 'profile' => array( 'name' => esc_html__( 'Post Ads', 'mega' ), 'description' => esc_html__( 'Post Ads block', 'mega' )),//Post_Ad_Capture 'whitelist' => array( 'Mega_Block_Ads' ) ); parent::__construct( __CLASS__, $args ); $this->addTemplate( array( $this->addChild( 'Mega_Block_Form_Select', array( 'label' => esc_html__( 'Loop Position Type', 'mega' ), 'value' => 'after', 'name' => 'loop_pos_type', 'options' => array( 'after' => esc_html__( 'After (x) Post Number', 'mega' ), 'every' => esc_html__( 'Every Post Number', 'mega' ) ) ), array( $this->addChild( 'Mega_Block_Form_Sub_Field_Wrapper', array( 'value' => 'after' ), array( $this->addChild( 'Mega_Block_Form_Number', array( 'label' => esc_html__( 'After Post Number', 'mega' ), 'value' => 2, 'name' => 'loop_pos_after' )) )), $this->addChild( 'Mega_Block_Form_Sub_Field_Wrapper', array( 'value' => 'every' ), array( $this->addChild( 'Mega_Block_Form_Number', array( 'label' => esc_html__( 'Every Post Number', 'mega' ), 'value' => 3, 'name' => 'loop_pos_every' )) )) ) ) )); } public function callback() { extract( $this->mega['settings'] ); global $wp_query; $i = $wp_query->current_post; if ( $i !== -1 ) if ( $loop_pos_type === 'after' && $i !== $loop_pos_after OR $loop_pos_type === 'every' && $i % $loop_pos_every ) return; parent::callback(); } }