Viewing File: /home/maglabs/sogefab/wp-content/themes/sofass/inc/widgets/popup_newsletter.php
<?php
class Goalbase_Goal_Popup_Newsletter extends Goal_Widget {
public function __construct() {
parent::__construct(
'goal_popup_newsletter',
esc_html__('Goal Popup Newsletter Widget', 'sofass'),
array( 'description' => esc_html__( 'Show Popup Newsletter', 'sofass' ), )
);
$this->widgetName = 'popup_newsletter';
add_action('admin_enqueue_scripts', array($this, 'scripts'));
}
public function scripts() {
wp_enqueue_script( 'goal-upload-image', GOAL_FRAMEWORK_URL . 'assets/upload.js', array( 'jquery', 'wp-pointer' ), GOAL_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:', 'sofass');?></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:', 'sofass' ); ?></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:', 'sofass' ); ?></label>
<div class="screenshot">
<?php if ( $instance['image'] ) { ?>
<img src="<?php echo esc_url($instance['image']); ?>" />
<?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;
}
}
if ( function_exists('goal_framework_reg_widget') ) {
goal_framework_reg_widget('Goalbase_Goal_Popup_Newsletter');
}
Back to Directory
File Manager