What is the proper way to get logged in user id in a plugin?

If you’re inside a plugin, WordPress is already loaded. You don’t need to load it yourself. Inside whatever function needs the user ID, you need to do two things: Globalize the user data variable Populate the user data variable Here’s some pseudocode: function some_function_that_needs_user_info() { global $current_user; get_currentuserinfo(); // Now reference $current_user->ID in your code. … Read more

Wrap text around shortcode

Without seeing your show_sticky_posts, show_lastest_posts, show_lastest_missions,show_all_posts_from_categories i can guess that the shortcode content is always before the post content beacuse this functions are echoing/outputing the result and a shortcode should return content instead so you can try using output buffer of PHP like this: function show_posts_handler( $atts, $content=null, $code=”” ) { //code 4 displaying extract( … Read more

Using a multiple element in widget form

I would remove the jQuery save function that was added… and then… Try this for the form function: public function form( $instance ) { // Code for editing/adding title and adding IDs to the <select> object // … <?php printf ( ‘<select multiple=”multiple” name=”%s[]” id=”%s” class=”widefat” size=”15″ style=”margin-bottom:10px”>’, $this->get_field_name(‘ID_list’), $this->get_field_id(‘ID_list’) ); // Each individual option … Read more

Plugin – Make sure jquery is loaded in my settings page plus my JS file

First use add_options_page() – shorter wrapper, better practice. Second you need to save its return in some (global or static) variable. That is often used thingie and confusingly referenced by different names in documentation. Global $hook_suffix holds such value for current page. function create_admin_pages() { global $my_page; $my_page = add_options_page(… From there it is something … Read more