Use ‘get’ form action within a WordPress plugin admin page

Try to use this code, <form action=”http://www.mydomain.com/wp-admin/admin.php” method=”get”> <input type=”hidden” name=”page” value=”my-plugin.php” /> <input type=”text” class=”mydatepicker” name=”start_date” value=””/> <input type=”submit” value=”submit”> </form> This will show the url like this… http://www.mydomain.com/wp-admin/admin.php?page=my-plugin.php&start_date=2014-04-03 Check and let me know your comments, if it works

Add Custom Script in Other Plugin’s Options page

There are several ways to add scripts only to certain admin pages. The best option, from my point of view, is to hook into admin_enqueue_scripts and use the $hook parameter: add_action(‘admin_enqueue_scripts’, ‘cyb_admin_scripts’); function cyb_admin_scripts( $hook ) { //You may need adjustment here to match for page //If the URL of your page is admin.php?page=psbg, the … Read more

hide default post body field in backend

add_action(‘init’, ‘init_remove_support’,100); function init_remove_support() { $post_type=”your post type”; remove_post_type_support( $post_type, ‘editor’); } Add this to your themes functions.php and it should take care of it. cheers 🙂

Add sub menu page in your plugin

The add_submenu_page first parameter should be the top menu page handle which in you case is a-qoute so: function a_qoute_admin_action(){ add_menu_page( __(‘Reservations Pages’),// the page title __(‘Donation’),//menu title ‘edit_themes’,//capability ‘a-qoute’,//menu slug/handle this is what you need!!! ‘qoute_settings’,//callback function ”,//icon_url, ”//position ); add_submenu_page( ‘a-qoute’, ‘Donations Log’, //page title ‘Donations Log’, //menu title ‘edit_themes’, //capability, ‘DonationsLog’,//menu slug … Read more

Seems that admin_post_{action} does not executing

It’s simply the wrong endpoint. The admin_post_* hook and its admin_post_nopriv_* counterpart is not fired for any admin page with the appropriate action request variable set, it only triggers for requests hitting wp-admin/admin-post.php. Try https://test.local/wp-admin/admin-post.php?action=test instead. I should add that using admin-post.php for handling plugin actions might not be appropriate. If you wanted to return … Read more

Show excerpt if no title in admin view

You can try the following approach using the the_title filter in the edit.php screen: /** * Modify post titles in the edit.php screen. * If the post title is empty, then show max 10 words from the post content instead. */ add_action( ‘load-edit.php’, function() { add_filter( ‘the_title’, function( $title ) { $post = get_post(); if( … Read more

How to switch theme if the current user is admin?

You are sort of doing this in a roundabout way. WordPress has a function called switch_theme(): add_action( ‘setup_theme’, ‘switch_user_theme’ ); function switch_user_theme() { if ( current_user_can( ‘manage_options’ ) ) { switch_theme(‘twentytwelve’); } else { switch_theme(‘twentythirteen’); } } The argument is the directory of the theme you want. I can’t help but think this is a … Read more