/home/crealab/pueblito.brainware.com.co/wp-content/plugins/scroll_magic/includes/widget.class.php
<?php
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'bb_scrollmacgic_widget' ) ) {
function wpb_load_widget() {
register_widget( 'bb_scrollmacgic_widget' );
}
add_action( 'widgets_init', 'wpb_load_widget' );
class bb_scrollmacgic_widget extends WP_Widget {
function __construct() {
parent::__construct(
'bb_scrollmacgic_widget',
esc_html__('ScrollMagic', 'bestbug'),
array( 'description' => esc_html__( 'Displays a Scene.', 'bestbug' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
echo $args['before_widget'];
if(!is_admin()) {
echo do_shortcode('[scrollmagic id='.$instance['id'].']');
} else {
echo ('[scrollmagic id='.$instance['id'].']');
}
echo $args['after_widget'];
}
public function form( $instance ) {
$args = array(
'numberposts' => -1,
'post_type' => WPSG_POSTTYPE
);
$accounts = get_posts( $args );
if ( isset( $instance[ 'id' ] ) ) {
$id = $instance[ 'id' ];
}else{
$id ="";
}
?>
<p>
<label for="<?php echo $this->get_field_id( 'id' ); ?>">Choose your Scene:</label>
<select class="widefat" name="<?php echo $this->get_field_name( 'id' ); ?>" id="<?php echo $this->get_field_id( 'id' ); ?>">
<?php
foreach ($accounts as $key => $value) {
?>
<option value="<?php echo esc_html($value->ID); ?>" <?php if($id==$value->ID): echo esc_html('selected'); endif;?>><?php echo esc_html($value->post_title); ?></option>
<?php
}
?>
</select>
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['id'] = ( ! empty( $new_instance['id'] ) ) ? strip_tags( $new_instance['id'] ) : '';
return $instance;
}
}
}