This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function performance( $visible = false ) { | |
$stat = sprintf( '%d queries in %.3f seconds, using %.2fMB memory', | |
get_num_queries(), | |
timer_stop( 0, 3 ), | |
memory_get_peak_usage() / 1024 / 1024 | |
); | |
echo $visible ? $stat : "<!-- {$stat} -->" ; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// unregister all default WP Widgets | |
function unregister_default_wp_widgets() { | |
unregister_widget('WP_Widget_Pages'); | |
unregister_widget('WP_Widget_Calendar'); | |
unregister_widget('WP_Widget_Archives'); | |
unregister_widget('WP_Widget_Links'); | |
unregister_widget('WP_Widget_Meta'); | |
unregister_widget('WP_Widget_Search'); | |
unregister_widget('WP_Widget_Text'); | |
unregister_widget('WP_Widget_Categories'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AUTOMATICALLY EXTRACT THE FIRST IMAGE FROM THE POST | |
function getImage($num) { | |
global $more; | |
$more = 1; | |
$link = get_permalink(); | |
$content = get_the_content(); | |
$count = substr_count($content, '<img'); | |
$start = 0; | |
for($i=1;$i<=$count;$i++) { | |
$imgBeg = strpos($content, '<img', $start); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****** Add Thumbnails in Manage Posts/Pages List ******/ | |
if ( !function_exists('AddThumbColumn') && function_exists('add_theme_support') ) { | |
// for post and page | |
add_theme_support('post-thumbnails', array( 'post', 'page' ) ); | |
function AddThumbColumn($cols) { | |
$cols['thumbnail'] = __('Thumbnail'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function update_active_plugins($value = '') { | |
/* | |
The $value array passed in contains the list of plugins with time | |
marks when the last time the groups was checked for version match | |
The $value->reponse node contains an array of the items that are | |
out of date. This response node is use by the 'Plugins' menu | |
for example to indicate there are updates. Also on the actual | |
plugins listing to provide the yellow box below a given plugin | |
to indicate action is needed by the user. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets'); | |
function my_custom_dashboard_widgets() { | |
global $wp_meta_boxes; | |
// Remove these dashboard widgets... | |
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); | |
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); | |
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//remove pings to self | |
function no_self_ping( &$links ) { | |
$home = get_option( 'home' ); | |
foreach ( $links as $l => $link ) | |
if ( 0 === strpos( $link, $home ) ) | |
unset($links[$l]); | |
} | |
add_action( 'pre_ping', 'no_self_ping' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function new_excerpt_length($length) { | |
return 100; | |
} | |
add_filter('excerpt_length', 'new_excerpt_length'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CUSTOM USER PROFILE FIELDS | |
function my_custom_userfields( $contactmethods ) { | |
// ADD CONTACT CUSTOM FIELDS | |
$contactmethods['contact_phone_office'] = 'Office Phone'; | |
$contactmethods['contact_phone_mobile'] = 'Mobile Phone'; | |
$contactmethods['contact_office_fax'] = 'Office Fax'; | |
// ADD ADDRESS CUSTOM FIELDS | |
$contactmethods['address_line_1'] = 'Address Line 1'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CUSTOMIZE ADMIN MENU ORDER | |
function custom_menu_order($menu_ord) { | |
if (!$menu_ord) return true; | |
return array( | |
'index.php', // this represents the dashboard link | |
'edit.php?post_type=events', // this is a custom post type menu | |
'edit.php?post_type=news', | |
'edit.php?post_type=articles', | |
'edit.php?post_type=faqs', | |
'edit.php?post_type=mentors', |