| @@ -1,0 +1,39 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * User Points Widget | |
| 4 | + * | |
| 5 | + * @package GamiPress\Widgets\Widget\User_Points | |
| 6 | + * @author GamiPress <[email protected]>, Ruben Garcia <[email protected]> | |
| 7 | + * @since 1.0.0 | |
| 8 | + */ | |
| 9 | +// Exit if accessed directly | |
| 10 | +if( !defined( 'ABSPATH' ) ) exit; | |
| 11 | + | |
| 12 | +class GamiPress_User_Points_Widget extends GamiPress_Widget { | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * Shortcode for this widget. | |
| 16 | + * | |
| 17 | + * @var string | |
| 18 | + */ | |
| 19 | + protected $shortcode = 'gamipress_user_points'; | |
| 20 | + | |
| 21 | + public function __construct() { | |
| 22 | + parent::__construct( | |
| 23 | + $this->shortcode . '_widget', | |
| 24 | + __( 'GamiPress: User Points', 'gamipress' ), | |
| 25 | + __( 'Display current or specific user points balance.', 'gamipress' ) | |
| 26 | + ); | |
| 27 | + } | |
| 28 | + | |
| 29 | + public function get_fields() { | |
| 30 | + return GamiPress()->shortcodes[$this->shortcode]->fields; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public function get_widget( $args, $instance ) { | |
| 34 | + // Build shortcode attributes from widget instance | |
| 35 | + $atts = gamipress_build_shortcode_atts( $this->shortcode, $instance ); | |
| 36 | + | |
| 37 | + echo gamipress_do_shortcode( $this->shortcode, $atts ); | |
| 38 | + } | |
| 39 | +} | |