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
| <?php global $current_user; | |
| get_currentuserinfo(); | |
| echo 'Username: ' . $current_user->user_login . "\n"; | |
| echo 'User email: ' . $current_user->user_email . "\n"; | |
| echo 'User first name: ' . $current_user->user_firstname . "\n"; | |
| echo 'User last name: ' . $current_user->user_lastname . "\n"; | |
| echo 'User display name: ' . $current_user->display_name . "\n"; | |
| echo 'User ID: ' . $current_user->ID . "\n"; | |
| ?> |
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_filter( 'post_thumbnail_html', 'remove_wps_width_attribute', 10 ); | |
| add_filter( 'image_send_to_editor', 'remove_wps_width_attribute', 10 ); | |
| function remove_wps_width_attribute( $html ) { | |
| $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html ); | |
| return $html; | |
| } |
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( 'pre_get_posts', function ( $q ) { | |
| if( $q->is_home() && $q->is_main_query() ) { | |
| $q->set( 'cat', CATEGORY_ID ); | |
| $q->set( 'posts_per_page', 3 ); | |
| } | |
| }); |
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 close_comments( $posts ) { | |
| if ( !is_single() ) { return $posts; } | |
| if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( 30 * 24 * 60 * 60 ) ) { | |
| $posts[0]->comment_status = 'closed'; | |
| $posts[0]->ping_status = 'closed'; | |
| } | |
| return $posts; | |
| } | |
| add_filter( 'the_posts', 'close_comments' ); |
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_shortcode( 'member', 'member_check_shortcode' ); | |
| function member_check_shortcode( $atts, $content = null ) { | |
| if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) | |
| return $content; | |
| return ''; | |
| } | |
| Uses:=============== |
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 minWord($content){ | |
| global $post; | |
| $num = 100; //set this to the minimum number of words | |
| $content = $post->post_content; | |
| if (str_word_count($content) < $num) | |
| wp_die( __('Error: your post is below the minimum word count.') ); | |
| } | |
| add_action('publish_post', 'minWord'); |
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_filter('body_class','browser_body_class'); | |
| function browser_body_class($classes) { | |
| global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone; | |
| if($is_lynx) $classes[] = 'lynx'; | |
| elseif($is_gecko) $classes[] = 'gecko'; | |
| elseif($is_opera) $classes[] = 'opera'; | |
| elseif($is_NS4) $classes[] = 'ns4'; | |
| elseif($is_safari) $classes[] = 'safari'; | |
| elseif($is_chrome) $classes[] = 'chrome'; | |
| elseif($is_IE) $classes[] = 'ie'; |
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 search_posts_filter( $query ){ | |
| if ($query->is_search){ | |
| $query->set('post_type',array('post','custom_post_type1', 'custom_post_type2')); | |
| } | |
| return $query; | |
| } | |
| add_filter('pre_get_posts','search_posts_filter'); |
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 JebamaxWord($title){ | |
| global $post; | |
| $title = $post->post_title; | |
| if (str_word_count($title) >= 10 ) //set this to the maximum number of words | |
| wp_die( __('Error: your post title is over the maximum word count.') ); | |
| } | |
| add_action('publish_post', 'JebamaxWord'); |