Server : Apache System : Linux ls31.server.ly 3.10.0-962.3.2.lve1.5.68.el7.x86_64 #1 SMP Wed Apr 6 11:12:23 UTC 2022 x86_64 User : medchoco ( 2906) PHP Version : 8.3.16 Disable Function : mail Directory : /home/medchoco/www/wp-content/themes/puca/inc/widgets/ |
Upload File : |
<?php class Tbaybase_Tbay_Popup_Newsletter extends Tbay_Widget { public function __construct() { parent::__construct( 'tbay_popup_newsletter', esc_html__('Tbay Popup Newsletter Widget', 'puca'), array( 'description' => esc_html__( 'Show Popup Newsletter', 'puca' ), ) ); $this->widgetName = 'popup_newsletter'; add_action('admin_enqueue_scripts', array($this, 'scripts')); } public function scripts() { wp_enqueue_script( 'tbay-upload-image', TBAY_FRAMEWORK_URL . 'assets/upload.js', array( 'jquery', 'wp-pointer' ), TBAY_FRAMEWORK_VERSION, true ); } public function getTemplate() { $this->template = 'popup-newsletter.php'; } public function widget( $args, $instance ) { $this->display($args, $instance); } public function form( $instance ) { $defaults = array('title' => 'Newsletter', 'description' => "Put your content here", 'image' => ''); $instance = wp_parse_args( (array) $instance, $defaults ); // Widget admin form ?> <p> <label for="<?php echo esc_attr($this->get_field_id( 'title' )); ?>"><strong><?php esc_html_e('Title:', 'puca');?></strong></label> <input type="text" id="<?php echo esc_attr($this->get_field_id( 'title' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" value="<?php echo esc_attr( $instance['title'] ) ; ?>" class="widefat" /> </p> <p> <label for="<?php echo esc_attr($this->get_field_id( 'description' )); ?>"><?php esc_html_e( 'Description:', 'puca' ); ?></label> <textarea class="widefat" id="<?php echo esc_attr($this->get_field_id( 'description' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'description' )); ?>" cols="20" rows="3"><?php echo trim( $instance['description'] ) ; ?></textarea> </p> <label for="<?php echo esc_attr($this->get_field_id( 'image' )); ?>"><?php esc_html_e( 'Image:', 'puca' ); ?></label> <div class="screenshot"> <?php if ( isset($instance['image']) && $instance['image'] ) { ?> <img src="<?php echo esc_url($instance['image']); ?>" style="max-width:100%"> <?php } ?> </div> <input class="widefat upload_image" id="<?php echo esc_attr($this->get_field_id( 'image' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'image' )); ?>" type="hidden" value="<?php echo esc_attr($instance['image']); ?>" /> <div class="upload_image_action"> <input type="button" class="button add-image" value="Add"> <input type="button" class="button remove-image" value="Remove"> </div> <?php } public function update( $new_instance, $old_instance ) { $instance = array(); $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; $instance['description'] = ( ! empty( $new_instance['description'] ) ) ? strip_tags( $new_instance['description'] ) : ''; $instance['image'] = ( ! empty( $new_instance['image'] ) ) ? strip_tags( $new_instance['image'] ) : ''; return $instance; } }