Load plugin scripts and styles only on plugin page

When you register a plugin option page you get a hook from the registration function: $hook = add_menu_page( ‘T5 Demo’, // page title ‘T5 Demo’, // menu title ‘manage_options’, // capability ‘t5-demo’, // menu slug ‘my_render_page’ // callback function ); Use this hook to enqueue the scripts and styles: add_action( “admin_print_styles-$hook”, “my_enqueue_style” ); add_action( “admin_print_scripts-$hook”, … Read more

How to remove list view from media library?

This is a little hacky, but doesn’t require you to edit core files, which you should never do, as you are aware. add_action(‘admin_init’, function() { $_GET[‘mode’] = ‘grid’; }, 100); This will always force the mode into grid view. What it does not do, it does not remove the List View icon it does not … Read more

sort child pages on admin

As I couldn’t find any filter to override the WP_Posts_List_Table class, I propose a quite hacky solution by doing this: Query only parents in pre_get_posts; Query their children on wp and change $wp_query->posts accordingly. This might need some more work as I’m probably breaking pagination numbers or so. // Use a query variable to control … Read more

Notification that the admin is online

This should get you started. I’ve used a timeout of 5 minutes to allow for time sitting idle on the website. You could improve the accuracy with a script (if the current user is the admin) & pinging an AJAX request every few minutes to update the admin_last_seen timestamp. /** * Check if the admin … Read more

How can I target WordPress 3.8 new interface MP6 with CSS?

While it’s not specific to MP6 (I am not following its development) and its CSS, to me your question sounds like “how to check that WP version is equal to greater than one some feature was introduced in?”. So I would just examine content of $wp_version global. If it’s 3.8 feature then anything with fitting … Read more

Allowing admin-ajax.php to receive “application/json” instead of “x-www-form-urlencoded”

it seems the latter only accepts x-www-form-urlencoded That’s not completely true. WordPress admin-ajax.php takes the action from $_REQUEST[‘action’] and $_REQUEST is equal to: array_merge($_POST, $_GET); But what many people don’t realize is that $_GET in PHP is not the data was sent to page using HTTP GET method, in fact, you can use whatever HTTP … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)