cyberdaemon
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [Online Active Users] Fatal Error after UpdateI’ve already fixed it)))
Forum: Plugins
In reply to: [Online Active Users] Fatal Error after UpdateCreate class-webi-custom-widget.php in the plugin root.
Place here –<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Webi_Custom_Widget' ) ) {
/**
* Custom widget to display the online active users count.
*
* @package Online_Active_Users
*/
class Webi_Custom_Widget extends WP_Widget {
/**
* Constructor.
*/
public function __construct() {
parent::__construct(
'webi_custom_widget',
__( 'WP Online Active User', 'online-active-users' ),
array( 'description' => __( 'Display Online Active Users.', 'online-active-users' ) )
);
}
/**
* Front-end display.
*
* @param array $args Widget arguments.
* @param array $instance Saved widget settings.
*/
public function widget( $args, $instance ) {
echo $args['before_widget'];
if ( ! empty( $instance['title'] ) ) {
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
}
if ( isset( $GLOBALS['wpoau_plugin'] ) && $GLOBALS['wpoau_plugin'] instanceof Webi_Active_User ) {
$active_users_count = $GLOBALS['wpoau_plugin']->wpoau_online_users( 'count' );
} else {
$wpoau_plugin = new Webi_Active_User();
$active_users_count = $wpoau_plugin->wpoau_online_users( 'count' );
}
echo '<div class="webi-widget-content">';
echo '<p>' . esc_html__( 'Online Active Users:', 'online-active-users' ) . ' <strong>' . absint( $active_users_count ) . '</strong></p>';
echo '</div>';
echo $args['after_widget'];
}
/**
* Back-end widget form.
*
* @param array $instance Widget settings.
*/
public function form( $instance ) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Active Users', 'online-active-users' );
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'online-active-users' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
</p>
<?php
}
/**
* Save widget settings.
*
* @param array $new_instance New settings.
* @param array $old_instance Old settings.
* @return array
*/
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : '';
return $instance;
}
}
}
Viewing 2 replies - 1 through 2 (of 2 total)