New answers tagged

0

I improve the solution of @brasofilo as it is have small bug - on page reload with not best internet connection menu will appear for very short time. To avoid it I added a bit of more css: add_action('admin_head', 'wpse_52099_script_enqueuer'); function wpse_52099_script_enqueuer() { if(!current_user_can('administrator')) { echo <<<HTML ...


-2

After upvoting kaiser's answer I still feel the urge to point out that you are unlikely to write php code without DB access which will impact performance in a measurable way (unless you totally fuck it up). Theoretically speaking, the filter option should be more performant, especially in memory consumption (this is due to the fact core handles translation ...


4

Additionally to kaiser's answer, you can load customized .mo files that overrides the original file using load_textdomain_mofile filter. For example: add_filter( 'load_textdomain_mofile', 'cyb_filter_load_textdomain_mofile', 10, 2 ); function cyb_filter_load_textdomain_mofile( $mofile, $domain ) { if ( $domain == 'some-textdomain-to-override' ) { ...


4

Yes, you can use the gettext filter. No, it's not the fastest filter, but that is only true when you add a callback to that filter in the wild: Bad Example This is bad as it makes a string comparison for every of the hundreds of translatable requests in the current request: add_filter( 'gettext', function( $translated, $original, $domain ) { return ...


1

I believe you're looking for the network_admin_menu hook. The Codex page for network_admin_menu has the following example: add_action('network_admin_menu', 'function_name'); function function_name() { add_menu_page( "page_title", "menu_title", 'capability', 'menu_slug', 'function_callback' ); }


0

The base argument for paginate_links() should be: admin_url( 'admin.php?page=lismovim-withdraw-slug&paged=%_%' ) ... where %_% is replaced by format, which should be: '%#%' ... which is replaced by the page number.


0

Well guys i post answet for anybody interested! I edited mr_permissions_roles_admin_page_restriction function because i noticed one thing: the restrictions i save are URL! so well here it is: function mr_permissions_roles_admin_page_restriction($screen) { $block=FALSE; $url=str_replace('/wp-admin/','',$_SERVER['REQUEST_URI']); global $menu; ...


1

Great question. As far as I can tell there isn't a way to filter this list (there's a long trac ticket about a proposal to, if you're interested, and also related (but different) questions on this site here and here). Because there's no filter, you may have to resort to doing it with jQuery. We can add our own scripts to the admin footer using the ...


0

Make sure you set your define( 'WP_DEBUG', false ); Else the notices and possible errors may cause 404.


1

Quickie Run only when you need to run and only run where you need to run Your code is almost there but you are not running at the particular time,if we use the your code it runs first and then filtered again by WooCommerce. So we have two options. Change priority of the filter Hook the code to run properly I think just unsetting ...


2

Based on cjbj's answer above, this is what I did... I went to /wp-includes/admin-bar.php and copied the relevant code with a slight modification (see below) into my plugin. Here is the end result: if ( !current_user_can('edit_posts') ) return; $awaiting_mod = wp_count_comments(); $awaiting_mod = $awaiting_mod->moderated; $awaiting_text = sprintf( ...


3

After you have removed the comments bubble, you add it again. The trick is that in the $args of add_node you have to set parent to top-secondary. So it will look like this: add_action( 'admin_bar_menu', 'wpse227079_toolbar_link_to_bubble', 999 ); function wpse227079_toolbar_link_to_bubble ( $wp_admin_bar ) { $args = array( 'id' ...


1

One way to move it to the very right would be like this: #wp-admin-bar-comments { float: right !important; } This will put it to the right of the Howdy message. I am not 100% sure if you want it on a specific side.


0

You can use the global variable $submenu. Example to list the child menu of parent post menu:- function admin_init_callback() { global $submenu; $sumenu_list = $submenu['edit.php']; var_dump($sumenu_list); //array of submenu } add_action('admin_init', 'admin_init_callback', 999); Profi660 EDIT: Not needed to be used with admin_init hook. I ...


0

I see two options here - override the CSS, or remove the "active" classes with JavaScript (sadly there is no action/filter that we can do this server-side) - I opted for the JS approach, it's cleaner, leaner and meaner: function wpse_227037_remove_menu_classes() { echo '<script>jQuery( ".wp-has-current-submenu.wp-menu-open" ).removeClass( ...


0

WordPress has a fairly good roles and capabilities system already and, IMHO, you'd find it easier working with that. When the admin menu is constructed, every item on the admin menu is subject to a check on a relevant capability. Similarly every attempt to use an admin screen is checked. It's possible to use map_meta_cap to rework some of these ...


2

No, it is not possible to create third level menu in admin panel. If you look at the definition of add_submenu_page, you need to mention the parent slug name. For eg: add_menu_page ( 'Test Menu', 'Test Menu', 'read', 'testmainmenu', '', '' ); add_submenu_page ( 'testmainmenu', 'Test Menu', 'Child1', 'read', 'child1', ''); The first parameter of the ...


5

Just create a "placeholder" menu that you can then assign all your post types to: function wpse_226690_admin_menu() { add_menu_page( 'Events Manager', 'Events Manager', 'read', 'events-manager', '', // Callback, leave empty 'dashicons-calendar', 1 // Position ); } add_action( 'admin_menu', ...


1

My choice would be to use WP_List_Table. If you continue reading the Codex it makes it clear that it is commonly used by third party code. "Someday" it might go away, but I doubt it will happen abruptly (if at all). If it does change, there will probably be a newer solution to replace it. EDIT: Another thought. if you feel really can't use WP_List_Table ...


1

Why not extend WP_List_Table? It creates responsive tables that collapse to an accordion when the table width exceeds the screen size. See Class Reference/WP List Table. You might take a look at the code in this plugin to get started: Custom List Table Example


-1

You can make tables responsive using CSS. I recommend applying a class to the , and referencing that class in CSS code setting dimensions to percentages. ...Something like will respond very well to .respond {width:100%; height: 100%}. If you want the responsiveness to be really awesome, you can address different devices explicitly in CSS using media ...


-1

Solved.. it turns out the link dialog does not work if the body has the "modal-open" class.


-1

Without installing any plugin we can add the social bookmarks. I found following article for this. adding social share buttons without wordpress plugin


1

You can use get_current_screen() to check on which page you are then make a redirect to specific admin page. get_current_screen() return the screen object like WP_Screen Object ( [action] => [base] => dashboard [columns:WP_Screen:private] => 0 [id] => dashboard [in_admin:protected] => site [is_network] => ...



Top 50 recent answers are included