array( 'name' => esc_html__( 'Logo', 'mega' ), 'description' => esc_html__( 'Logo block', 'mega' )),
'before' => '
',
'after' => '
',
'class_base'=> 'ys-logo'
);
parent::__construct( __CLASS__, $args );
}
public function settings( $form )
{
$form->add_control( 'Mega_Control_Select', array( 'label' => esc_html__( 'Type', 'mega' ), 'value' => 'text', 'name' => 'type',
'choices' => array(
'text' => esc_html__( 'Text', 'mega' ),
'image' => esc_html__( 'Image', 'mega' )
)
));
$form->add_sub_control( 'Mega_Control_Text', array( 'control' => 'type', 'control_value' => 'text', 'label' => esc_html__( 'Text', 'mega' ), 'value' => get_stylesheet(), 'name' => 'text' ));
$form->add_sub_control( 'Mega_Control_Text', array( 'control' => 'type', 'control_value' => 'image', 'label' => esc_html__( 'Image URL', 'mega' ), 'name' => 'image' ));
$form->add_sub_control( 'Mega_Control_Number', array( 'control' => 'type', 'control_value' => 'image', 'label' => esc_html__( 'Image Width (px)', 'mega' ), 'name' => 'width' ));
}
public function block()
{
extract( $this->mega['settings'] );
$image = mega_auto_tag( 'img', array( 'attr' => array(
'src' => esc_url( $image ),
'alt' => $text
)));
echo mega_auto_tag( 'a', array(
'text' => $type === 'text' ? esc_html( $text ) : $image,
'attr' => array(
'href' => home_url( '/' ),
'class' => $type,
'title' => get_bloginfo( 'description' ),
'style' => $type === 'image' ? 'width: ' . $width . 'px;' : ''
)
));
}
}