// toggle hide/show of an element $(“#DivID”).toggle(1000); // do something when animation is complete $(“#DivID”).toggle(1000, function () { alert(“Toggle Complete”); }); // hide an element $(“#DivID”).hide(1000); // do something when animation is complete $(“#DivID”).hide(1000, function () { alert(“Hide Complete”); }); // show an element $(“#DivID”).show(1000); // do something when animation is complete $(“#DivID”).show(1000, function () […]
Articles Tagged: 2015
Common Selectors
// get element by id $(“#ElementID”).whatever(); // get element by css class $(“.ClassName”).whatever(); // get elements where id contains a string $(“[id*=’value’]”).whatever(); // get elements where id starts with a string $(“[id^=’value’]”).whatever(); // get elements where id ends with a string $(“[id$=’value’]”).whatever(); // get all elements of certain type (can use “p”, “a”, “div” – […]
@Media
/* CSS Document */ // Small screens @media only screen { } /* Define mobile styles */ @media only screen and (max-width: 40em) { } /* max-width 640px, mobile-only styles, use when QAing mobile issues */ // Medium screens @media only screen and (min-width: 40.063em) { } /* min-width 641px, medium screens */ @media only […]
Kitchen Sink
Add Link to WordPress “All-Settings”
As we’ve explained before, WordPress makes it easy to view and edit your blog settings from the Admin area. Thanks to a file named options.php, WordPress will display all of your database settings and enable you to edit a majority of them. To view this page, you need to log in as Admin and enter […]
Get Role
/*———————————————————————————–*/ /* GET role /*———————————————————————————–*/ function get_user_role() { global $current_user; $user_roles = $current_user->roles; $user_role = array_shift($user_roles); return $user_role; }
Another Way to Change the “Howdy” message to “Welcome”
/*************************************************************** * Change Howdy to Welcome ***************************************************************/ function change_howdy($translated, $text, $domain) { if (!is_admin() || ‘default’ != $domain) return $translated; if (false !== strpos($translated, ‘Howdy’)) return str_replace(‘Howdy’, ‘Welcome’, $translated); return $translated; add_filter(‘gettext’, ‘change_howdy’, 10, 3);
Changing “Posts” menu name in admin (e.g. “Articles”)
// hook the translation filters add_filter(‘gettext’,’change_post_to_article’); add_filter(‘ngettext’,’change_post_to_article’); function change_post_to_article( $translated ) { $translated = str_ireplace(‘Post’,’Article’,$translated );// ireplace is PHP5 only return $translated; } Credits to smashingmagazine.com
Remove WordPress Admin Bar Menu Items
function dashboard_tweaks() { global $wp_admin_bar; $wp_admin_bar->remove_menu(‘wp-logo’); $wp_admin_bar->remove_menu(‘about’); $wp_admin_bar->remove_menu(‘wporg’); $wp_admin_bar->remove_menu(‘documentation’); $wp_admin_bar->remove_menu(‘support-forums’); $wp_admin_bar->remove_menu(‘feedback’); $wp_admin_bar->remove_menu(‘view-site’); } add_action( ‘wp_before_admin_bar_render’, ‘dashboard_tweaks’ ); Reference: http://pastebin.com/Wrk0JPxw
Remove Admin Backend Menus for all users, except User #1 (usually the first Admin)
/*———————————————————————————–*/ /* Restrict access /*———————————————————————————–*/ function remove_menus () { global $menu; $user = wp_get_current_user(); if ($user->ID!=1) { // Is not administrator, $restricted = array(__(‘Dashboard’), __(‘Posts’), __(‘Media’), __(‘Links’), __(‘Pages’), __(‘Appearance’), __(‘Tools’), __(‘Users’), __(‘Settings’), __(‘Comments’), __(‘Plugins’)); end ($menu); while (prev($menu)){ $value = explode(‘ ‘,$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:”” , $restricted)){unset($menu[key($menu)]);} } } } add_action(‘admin_menu’, ‘remove_menus’);