File: /home/lesanew/www/wp-content/plugins/neobeat-core/inc/shortcodes/video-button/video-button.php
<?php
if ( ! function_exists( 'neobeat_core_add_video_button_shortcode' ) ) {
/**
* Function that add shortcode into shortcodes list for registration
*
* @param $shortcodes array
*
* @return array
*/
function neobeat_core_add_video_button_shortcode( $shortcodes ) {
$shortcodes[] = 'NeoBeatCoreVideoButton';
return $shortcodes;
}
add_filter( 'neobeat_core_filter_register_shortcodes', 'neobeat_core_add_video_button_shortcode' );
}
if ( class_exists( 'NeoBeatCoreShortcode' ) ) {
class NeoBeatCoreVideoButton extends NeoBeatCoreShortcode {
public function map_shortcode() {
$this->set_shortcode_path( NEOBEAT_CORE_SHORTCODES_URL_PATH . '/video-button' );
$this->set_base( 'neobeat_core_video_button' );
$this->set_name( esc_html__( 'Video Button', 'neobeat-core' ) );
$this->set_description( esc_html__( 'Shortcode that adds video button element', 'neobeat-core' ) );
$this->set_category( esc_html__( 'NeoBeat Core', 'neobeat-core' ) );
$this->set_option( array(
'field_type' => 'text',
'name' => 'custom_class',
'title' => esc_html__( 'Custom Class', 'neobeat-core' ),
) );
$this->set_option( array(
'field_type' => 'text',
'name' => 'video_link',
'title' => esc_html__( 'Video Link', 'neobeat-core' ),
) );
$this->set_option( array(
'field_type' => 'image',
'name' => 'video_image',
'title' => esc_html__( 'Image', 'neobeat-core' ),
'description'=> esc_html__( 'Select image from media library', 'neobeat-core' )
) );
$this->set_option( array(
'field_type' => 'color',
'name' => 'play_button_color',
'title' => esc_html__( 'Play Button Color', 'neobeat-core' )
) );
$this->set_option( array(
'field_type' => 'text',
'name' => 'play_button_size',
'title' => esc_html__( 'Play Button Size (px)', 'neobeat-core' )
) );
$this->set_option( array(
'field_type' => 'select',
'name' => 'box_shadow',
'title' => esc_html__( 'Shadow', 'neobeat-core' ),
'options' => neobeat_core_get_select_type_options_pool( 'no_yes', false )
) );
}
public function render( $options, $content = null ) {
parent::render( $options );
$atts = $this->get_atts();
$atts['holder_classes'] = $this->get_holder_classes( $atts );
$atts['play_button_styles'] = $this->get_play_button_styles( $atts );
return neobeat_core_get_template_part( 'shortcodes/video-button', 'templates/video-button', '', $atts );
}
private function get_holder_classes( $atts ) {
$holder_classes = $this->init_holder_classes();
$holder_classes[] = 'qodef-video-button';
$holder_classes[] = ! empty( $atts['custom_class'] ) ? esc_attr( $atts['custom_class'] ) : '';
$holder_classes[] = ! empty( $params['video_image'] ) ? 'qodef-vb-has-img' : '';
return implode( ' ', $holder_classes );
}
private function get_play_button_styles( $atts ) {
$styles = array();
if ( ! empty( $atts['play_button_color'] ) ) {
$styles[] = '-webkit-text-stroke-color: ' . $atts['play_button_color'];
$styles[] = 'color: ' . $atts['play_button_color'];
}
if ( ! empty( $atts['play_button_size'] ) ) {
if ( qode_framework_string_ends_with_typography_units( $atts['play_button_size'] ) ) {
$styles[] = 'font-size: ' . $atts['play_button_size'];
} else {
$styles[] = 'font-size: ' . intval( $atts['play_button_size'] ) . 'px';
}
$styles[] = 'width: ' . 3 * intval( $atts['play_button_size'] ) . 'px';
$styles[] = 'height: ' . 3 * intval( $atts['play_button_size'] ) . 'px';
}
return implode( ';', $styles );
}
}
}