Articles of wp admin

Is there alternative to WP_List_Table?

I need to create html tables in a admin pages. It should be responsive. After a research I find the WP_List_Table. But in codex page, This class’s access is marked as private. That means it is not intended for use by plugin and theme developers as it is subject to change without warning in any […]

Redirect Plugins.php to New Plugin Page

I have a multisite install and need to redirect the default plugin page to another admin page that will handle plugins. For example, if they request /wp-admin/plugins.php, then it should redirect them to /wp-admin/admin.php?page=pretty-plugins.php if they are not a network admin. The code below is what I have come up with so far, but I […]

Users are redirected to homepage instead of wp-admin

After migrating my wordpress site users who are not Admins are redirected to the site’s homepage after login. On the old site they were redirected on wp-admin. The Administrator is redirected to wp_admin as it should. I want the users to be redirected to wp-admin after login. I changed siteurl from the database (wp_options), also […]

Displaying Title in Title Tag on Edit page?

I want to change the title tag in the edit page, so that I can read the title of my edit page in my browser tabs: function edit_admin_title_tag() { global $post; $title_tag = ‘<title>’. $post->post_title .'</title>’; echo $title_tag; } add_action( ‘admin_head’, ‘edit_admin_title_tag’ ); How can I delete/overwrite the default title tag?

TinyMCE custom button retrieve value from custom field

I’m creating a plugin that adds a custom button to the default TinyMCE editor in WordPress admin. The following code builds this simple plugin mkay-tinymce-extra-button.php function mkay_enqueue_plugin_script( $plugin_array ){ $plugin_array[‘subscriptionPlugin’] = plugin_dir_url( __FILE__ ) . ‘mkay-tinymce-extra-buttons.js’; return $plugin_array; } add_filter( ‘mce_external_plugins’, ‘mkay_enqueue_plugin_script’ ); function mkay_register_buttons_editor( $buttons ){ array_push( $buttons, ‘subscription’ ); return $buttons; } add_filter( […]

How to add post_author column to custom post type

I’ve created a custom post type with this code: register_post_type( ‘custom_type’, array( ‘labels’ => $labels, ‘description’ => ”, ‘public’ => false, ‘publicly_queryable’ => false, ‘exclude_from_search’ => true, ‘show_in_nav_menus’ => false, ‘show_ui’ => true, ‘show_in_menu’ => true, ‘show_in_admin_bar’ => true, ‘menu_icon’ => $icon, ‘can_export’ => false, ‘delete_with_user’ => false, ‘hierarchical’ => false, ‘has_archive’ => false, ‘query_var’ […]

WordPress site 500 error

I was recently working on my sisters wordpress site and I was trying to remove the footer text from the template. I went into function.php and removed one line of code for the copyright. After saving the page, the website no longer loaded, and also going to the wp-admin page gives the same 500 error. […]

How to have same admin login for more than one site?

I am curerently working on a project in which one site act as a parent site and other sites will act as child sites. All of these sites will come under same domain name. For example my parent site url will be like ” www.mysite.com”. And the other sites url will be like ” www.mysite.com/childsite […]

Get current session in WP admin

Trying to access sessions in the WP admin and access a variable from it. function tasks_admin_sessions() { if(!session_id()) { session_start(); } } add_action( ‘admin_init’, ‘tasks_admin_sessions’, 1 ); $nonce = $_session[‘wp_nonce’] $completed_url = admin_url( “post.php?post=$post_id&action=trash&_wpnonce=$nonce” ); but I get: Notice: Undefined variable: _session What am I missing in my code to get the session variables?

wp-admin AJAX with Fetch API is done without user

TL;DR – Why is my user account not logged in during an AJAX request which is made inside wp-admin? I have the following setup: <?php add_action(‘wp_ajax_foobar_action’, ‘foobar_action’); add_action(‘wp_ajax_nopriv_foobar_action’, ‘foobar_action’); function foobar_action() { check_ajax_referrer(); wp_send_json((object) [‘msg’ => ‘hello world’]); } add_action(‘admin_print_scripts’, function () { printf(‘<script type=”text/javascript”>window.custom_nonce = “%s”;</script>’, wp_create_nonce()); }); And in JS: var msg = […]