Storing custom dashboard widget options in wordpress

Solution pulled from OP. Ok fixed. In widget-config.php there is no check if the form has been submitted, so every time you load configuration it updates with empty values or keeps default ones. Add this check if (!empty($_POST)) before updating options values and display stored value of number-input: <input type=”text” name=”number” value=”<?php echo self::get_dashboard_widget_option(self::wid, ‘example_number’); … Read more

Enqueue script in specific page

Inside admin-header.php, there’s the following set of hooks: do_action(‘admin_enqueue_scripts’, $hook_suffix); do_action(“admin_print_styles-$hook_suffix”); do_action(‘admin_print_styles’); do_action(“admin_print_scripts-$hook_suffix”); do_action(‘admin_print_scripts’); do_action(“admin_head-$hook_suffix”); do_action(‘admin_head’); The one to always use it admin_enqueue_scripts, both for stylesheet and scripts. More info in this answer. It has one additional argument, the $hook_suffix. This argument is exactly the same as the return value that you get from add_submenu_page() … Read more

Remove Visual Composer Tab from Dashboard Menu [closed]

It is not easy to find it out, but it is pretty easy if you know how. Add this following code to your themes functions.php. function custom_menu_page_removing() { remove_menu_page(‘vc-welcome’); //vc } add_action( ‘admin_init’, ‘custom_menu_page_removing’ ); (Previously been admin_menu, now is admin_init) This is how to find out for the next time: If you want to … Read more

Hide php Notices in Dashboard

I don’t know how to move the notices to the bottom or if that’s possible at all. To disable the debug mode in wp-admin write in wp-config.php: define( ‘WP_DEBUG’, FALSE === strpos( $_SERVER[‘REQUEST_URI’], ‘/wp-admin/’ ) ); Untested: You could try to enable warnings in admin with: // happens early in wp-admin/admin.php add_filter( ‘secure_auth_redirect’, ‘wpse_67728_error_warnings’ ); … Read more

How to Change the Categories Order in the Admin Dashboard?

Found an answer in this answer. add_filter( ‘get_terms_args’, ‘wpse_53094_sort_get_terms_args’, 10, 2 ); function wpse_53094_sort_get_terms_args( $args, $taxonomies ) { global $pagenow; if( !is_admin() || (‘post.php’ != $pagenow && ‘post-new.php’ != $pagenow) ) return $args; $args[‘orderby’] = ‘slug’; $args[‘order’] = ‘DESC’; return $args; } The order may be ASC or DESC, and the orderby can be: count … Read more

Custom Role does not have access to dashboard

You have to give the capability a true or false, like this: add_role(‘user’, ‘User’, array( ‘read’ => true )); To fix it, first remove the role and than re-add it again. remove_role(‘user’); add_role(‘user’, ‘User’, array(‘read’ => true)); http://codex.wordpress.org/Function_Reference/add_role

Change default admin page for specific role(s)

In your theme’s functions.php: function hide_the_dashboard() { global $current_user; // is there a user ? if ( is_array( $current_user->roles ) ) { // substitute your role(s): if ( in_array( ‘custom_role’, $current_user->roles ) ) { // hide the dashboard: remove_menu_page( ‘index.php’ ); } } } add_action( ‘admin_menu’, ‘hide_the_dashboard’ ); function your_login_redirect( $redirect_to, $request, $user ) { … Read more

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