Issue with plugin sub menu and pages

Your code has a syntax error, extra close-curly in new_menu(). Your test_sub_menu() function has all the vars that are used in new_menu() – but they’re not global or called to from new_menu(), so they do nothing and the functions do nothing but return undefined errors. $parent_slug = ‘new-menu’; should be instead, for a subpage, the … Read more

how to save wp_editor html content in options table

echo ‘<form action=”” class=”booked-settings-form” method=”post”>’; $default_content=”<p>Mail formate</p>”; $editor_id = ‘customerCleanerMail’; $option_name=”customerCleanerMail”; $default_content=html_entity_decode($default_content); $default_content=stripslashes($default_content); wp_editor( $default_content, $editor_id,array(‘textarea_name’ => $option_name,’media_buttons’ => false,’editor_height’ => 350,’teeny’ => true) ); submit_button(‘Save’, ‘primary’); echo ‘</form>’; if(isset($_POST[‘customerCleanerMail’]) ){ $var2=htmlentities(wpautop($_POST[‘customerCleanerMail’])); $fff=update_option(‘customerCleanerMail’, $var2); } In form section i used wp_editor with his options, wp_editor work like html editor but when you store these data … Read more

Using function from enqueued .js file in theme in plugin?

Yes. Dependencies work across all of WP, it doesn’t matter where you enqueue your script. All that matters is that you define your dependencies correctly, and you’re doing that. If, however, you plan to publish both the theme and the plugin as standalone versions, you shouldn’t rely on your plugin being used with your theme, … Read more

AJAX call to admin-ajax.php by subscriber returns home page

I have also faced same issue, after checking my functions.php codes,I found following code. add_action(‘init’, ‘blockusers_init’); function blockusers_init() { if (is_admin() && !current_user_can(‘administrator’)) { wp_redirect(home_url()); exit; } } This code redirects the ajax call to home page. To resolve this, add DOING_AJAX condition, add_action(‘init’, ‘blockusers_init’); function blockusers_init() { if (is_admin() && !current_user_can(‘administrator’) && !defined(‘DOING_AJAX’)) { … Read more

I need to refresh page to display wp_get_current_user() : why?

This is because of your plugin code is executed much earlier, than wp-login.php. You can read about WordPress loading sequence here, for example. To behave properly, your code must be executed in ‘wp_login’ hook: add_action( ‘wp_login’, ‘wp_login_action’, 10, 2 ); function wp_login_action( $user_login, $user ) { current_user = wp_get_current_user(); print_r($current_user); }

How to output functions from plugin inside theme

Looks like function render_content_show_hide() is a method of class. If you want access this function directly – you can create new class instance. If your plugin code looks like: class Shortcode_Builder{ //…methods public function render_content_show_hide( $attr, $content = null, $shortcode_name=”” ) { //… } //…other methods. } Create new instance $builder = new Shortcode_Builder(); And … Read more