admin
2 months ago
custom_post
2 months ago
admin_notices.php
2 months ago
conditions.php
2 months ago
custom_post.php
2 months ago
error_notices.php
2 months ago
functions.php
2 months ago
ico.png
2 months ago
information_notices.php
2 months ago
libraries.php
2 months ago
plugin-variation.php
2 months ago
settings_fields.php
2 months ago
updater.php
2 months ago
widget.php
2 months ago
widget.php
59 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Widget |
| 4 | */ |
| 5 | |
| 6 | if ( ! class_exists( 'BeRocket_Widget' ) ) { |
| 7 | |
| 8 | class BeRocket_Widget extends WP_Widget { |
| 9 | public static $defaults = array( |
| 10 | 'title' => '', |
| 11 | ); |
| 12 | |
| 13 | public function __construct( $name, $normal_name, $description = '' ) { |
| 14 | parent::__construct( "berocket_" . $name . "_widget", $normal_name, |
| 15 | array( "description" => $description ) |
| 16 | ); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * WordPress widget |
| 21 | */ |
| 22 | public function widget( $args, $instance ) { |
| 23 | $instance = wp_parse_args( (array) $instance, self::$defaults ); |
| 24 | $options = $args['plugin_class']::get_option(); |
| 25 | |
| 26 | set_query_var( 'title', apply_filters( 'ce_widget_title', $instance[ 'title' ] ) ); |
| 27 | set_query_var( 'args', $args ); |
| 28 | |
| 29 | echo $args[ 'before_widget' ]; |
| 30 | $args['plugin_class']::br_get_template_part( apply_filters( 'berocket_widget_template', 'widget', $args['plugin_class']::info ) ); |
| 31 | echo $args[ 'after_widget' ]; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Update widget settings |
| 36 | */ |
| 37 | public function update( $new_instance, $old_instance ) { |
| 38 | $instance = $old_instance; |
| 39 | $instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] ); |
| 40 | |
| 41 | return $instance; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Widget settings form |
| 46 | */ |
| 47 | public function form( $instance ) { |
| 48 | $instance = wp_parse_args( (array) $instance, self::$defaults ); |
| 49 | $title = strip_tags( $instance[ 'title' ] ); |
| 50 | ?> |
| 51 | <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> <input |
| 52 | class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" |
| 53 | name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" |
| 54 | value="<?php echo esc_attr( $title ); ?>"/></p> |
| 55 | <?php |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 |