How to limit wordpress menu depth in admin panel

Follow up on @jmarceli’s and @squarecandy’s great answers. Here is a solution that allows for: Easier scaling (set an object in the php action) Updates to the correct menu depth when the location checkboxes are changed /** * Limit max menu depth in admin panel */ function limit_admin_menu_depth($hook) { if ($hook != ‘nav-menus.php’) return; wp_register_script(‘limit-admin-menu-depth’, … Read more

remove_menu_page doesn’t work on custom plugin menus

Place this below temporary code in your functions.php or any where that can be executed. add_action( ‘admin_init’, ‘the_dramatist_debug_admin_menu’ ); function the_dramatist_debug_admin_menu() { echo ‘<pre>’ . print_r( $GLOBALS[ ‘menu’ ], TRUE) . ‘</pre>’; } Then search for the plugin-slug. In which array you find it copy the [2] value and put it in remove_menu_page(‘the [2] value’) … Read more

Admin settings update updating every time home page is hit?

A much better hook to use would the the update_option_{option_name} dynamic hook, which only runs after your specific option has been updated. So something like: add_action(‘update_option_woocommerce_email_send_time’, ‘send_time’) function update_send_time() { // Add code here to update cron job } The only problem you’ll get here is that scheduling the cron job for a time earlier … Read more

Add “external” link to admin menu in the backend

you can create a function that redirects to the front-end like this: function redirect_home_987(){ wp_redirect( home_url() ); exit; } and call that function in WordPress default add_menu_page function like this: add_menu_page( ‘redirecting’, ‘View Site’, ‘read’, ‘my-top-level-handle’, ‘redirect_home_987’); Hope this helps

Remove “posts” from admin but show a custom post

Doing this search, I’ve found this fine answer by Chris_O. There’s even a jQuery solution I proposed there. Anyway, the function remove_menu_page(‘edit.php’); only removes the Posts menu. But, as we learn from Chris answer, remove_menu_page(‘edit.php?post_type=athletes’); removes the Custom Post Type menu. To really block access to the URL, as we’re merely hiding the menu item, … Read more

Show Custom Taxonomy Inside Custom Menu

You have some messed up code. I have reformatted your code to code which actually works. The following solution allows you to give your Custom Post Type menu a menu name of what ever you want. Just change the label “menu_name”. POST TYPE // Create the news custom post type register_post_type(‘nwcm_news’, array( ‘labels’ => array( … Read more

Meta Boxes: ‘admin_init’ or ‘add_meta_boxes’ hook?

Have a look at this list: http://codex.wordpress.org/Plugin_API/Action_Reference It doesn’t matter which one you use as long as it’s not too early and not too late. It’s best to use intuitive and predictable hooks, so add_meta_boxes is preferred. Someday in the future WordPress may change something and by using the most appropriate hooks you increase your … Read more

Adding Category/Tag/Taxonomy Support to Images/Media

Here’s how I recently added a custom taxonomy to the media library as a sortable column: // Add a new column add_filter(‘manage_media_columns’, ‘add_topic_column’); function add_topic_column($posts_columns) { $posts_columns[‘att_topic’] = _x(‘Topic’, ‘column name’); return $posts_columns; } // Register the column as sortable function topic_column_register_sortable( $columns ) { $columns[‘att_topic’] = ‘att_topic’; return $columns; } add_filter( ‘manage_upload_sortable_columns’, ‘topic_column_register_sortable’ ); … Read more

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