'wp2048', 'description' => __('Displays site high score and linked to the game page.', 'wp2048') ); $control_ops = array( 'id_base' => 'wp2048-hs-widget' ); $this->WP_Widget( 'wp2048-hs-widget', __('2048 High Score', 'wp2048'), $widget_ops, $control_ops ); } public function widget( $args, $instance ) { // Widget output extract( $args ); //Our variables from the widget settings. $title = apply_filters('widget_title', $instance['title'] ); $show = $instance['show']; $pageid = $instance['pageid']; // Enqueue the CSS when this Widget appear wp_enqueue_style('2048_widget'); echo $before_widget; // Display the widget title if ( $title ) echo $before_title . $title . $after_title; // Output the High Score or Scoreboard or None if ( $show == 'highscore' ) { $wp2048_highscore = json_decode( get_option('wp2048_highscore'), true ); echo '
'.$wp2048_highscore['score'].'
'; } else if ( $show == 'scoreboard' ) { echo do_shortcode('[scoreboard2048 top=5 link=none]'); } echo '

Join the numbers and get to the 2048 tile!

'; echo 'Play Game'; echo $after_widget; } public function update( $new_instance, $old_instance ) { // Save widget options $instance = $old_instance; //Strip tags from title and name to remove HTML $instance['title'] = strip_tags( $new_instance['title'] ); $instance['show'] = strip_tags( $new_instance['show'] ); $instance['pageid'] = (int)$new_instance['pageid']; return $instance; } public function form( $instance ) { // Output admin widget options form // Set up some default widget settings. $defaults = array( 'title' => __('2048 High Score', 'wp2048'), 'show' => 'highscore', 'pageid' => 0, ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>


>
>
>