how to render dashboard widgets conditionaly in wordpress admin

// PHP 5.3 syntax – anonymous functions (Closures) add_action(‘wp_dashboard_setup’, function(){ if(current_user_can(‘activate_plugins’)){ // Administrator wp_add_dashboard_widget(‘dbwidget-Administrator’, ‘#Administrator’, function(){ // Print widget here }); }elseif(current_user_can(‘delete_others_posts’)){ // Editor wp_add_dashboard_widget(‘dbwidget-Editor’, ‘#Editor’, function(){ // Print widget here }); }elseif(current_user_can(‘delete_published_posts’)){ // Author wp_add_dashboard_widget(‘dbwidget-Author’, ‘#Author’, function(){ // Print widget here }); }elseif(current_user_can(‘edit_posts’)){ // Contributor wp_add_dashboard_widget(‘dbwidget-Contributor’, ‘#Contributor’, function(){ // Print widget here }); }elseif(current_user_can(‘read’)){ … Read more

Can you echo PHP code from a variable?

Since actual output seems to be done via echoing global variable nothing prevents you to change that variable to something else (between the points where theme creates and echoes it). Like a result of advertisement manager function call. However I think it would make more sense to stick with one of two functionalities rather than … Read more

Modify pages widget and make a plugin?

Widgets are class based, so it is quite easy to extend them. Create your class by extending WP_Widget_Pages (just like it extends baseline Widget). Copy method(s) you want to modify into your class and make changes in there. You would probably want to extend and modify name and such so it is not confused/conflicted with … Read more

Minification Plugins break my website

This is normal, minification of CSS/HTML and JS is not a magic button. If you have no plugins and 1 style-sheet and minimal javascript (aka not more than 1 function) it will work, but anything above that and your looking at conflict and load order problems. To properly minify takes work, you have to either … Read more