Load script on frontend from widget plugin

In general to load css or js into admin you need to use admin_enqueue_scripts hook, so it can be like this in functional style: add_action( ‘admin_enqueue_scripts’, function( $hook_suffix ){ wp_enqueue_style(‘i-widget’, plugins_url( ‘i-widget.min.css’ , __FILE__), array(), null); wp_enqueue_script(‘swiper’, plugins_url( ‘swiper.min.js’, __FILE__), array(‘jquery’), null); }, 99 ); wp_enqueue_script(‘i-widget’, plugins_url( ‘i-widget.min.js’, __FILE__), array(‘jquery’, ‘swiper’), null); }, 99 ); … Read more

Uncaught Error: Call to undefined function wp_get_current_user() in

You have to call TopAuthor() function in plugins_loaded orinit action. You are getting Fatal error: Uncaught Error: Call to undefined function wp_get_current_user() because wp_get_current_user() is a pluggable function. You can not call when your plugin is included. You have to wait for the action plugins_loaded or init. Call your TopAuthor() function using init or plugins_loaded … Read more