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
| //Anti-Spam Email Shortcode | |
| //Use this shortcode [email][email protected][/email] | |
| function protect_email_address( $atts , $content=null ) { | |
| for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';'; | |
| return '<a href="mailto:'.$encodedmail.'">'.$encodedmail.'</a>'; | |
| } | |
| add_shortcode('email', 'protect_email_address'); |
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
| //Screenshot Snap Shortcode | |
| // Usage: [snap url="http://wordpress.com" alt="WordPress" w="400" h="300" title="WordPress" descr='WordPress is awesome,'] | |
| function ni_screenshot($atts, $content = null) { | |
| extract(shortcode_atts(array( | |
| "snap" => 'http://s.wordpress.com/mshots/v1/', | |
| "url" => 'http://training.ithemes.com', | |
| "w" => '400', | |
| "h" => '300', | |
| "title" => 'Site Title', |
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
| // Removes PRIVATE from Private Page Titles | |
| function remove_private_prefix($title) { | |
| $title = str_replace( | |
| 'Private:', | |
| '', | |
| $title); | |
| return $title; | |
| } | |
| add_filter('the_title','remove_private_prefix'); |
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
| // Make Private Pages show in Parent Page List | |
| function bla_handle_privates_adding( $args ) { | |
| if ( ! current_user_can( 'read_private_pages' ) ) { | |
| return $args; | |
| } | |
| $defaults = array( 'post_status' => 'publish,private' ); | |
| return wp_parse_args( $args, $defaults ); | |
| } | |
| add_filter( 'wp_page_menu_args', 'bla_handle_privates_adding' ); |
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
| // Creates Login Shortcode | |
| // Shortcode Usage: [loginform redirect="http://my-redirect-url.com"] | |
| function pippin_login_form_shortcode( $atts, $content = null ) { | |
| extract( shortcode_atts( array( | |
| 'redirect' => '' | |
| ), $atts ) ); | |
| if (!is_user_logged_in()) { |
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
| // Limit Post Title Size | |
| function maxTitleLength($title) { | |
| global $post; | |
| $title = $post->post_title; | |
| if (str_word_count($title) >= 10) | |
| wp_die( __('Error: your post title is over the maximum word count.')); | |
| } | |
| add_action('publish_post','maxTitleLength'); |
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
| //Limit Search to Post Titles Only | |
| function __search_by_title_only( $search, &$wp_query ) | |
| { | |
| global $wpdb; | |
| if ( empty( $search ) ) | |
| return $search; // skip processing - no search term in query | |
| $q = $wp_query->query_vars; |
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
| //Exclude Pages from Search | |
| function ni_search_filter( $query ) { | |
| if ( $query->is_search && $query->is_main_query() ) { | |
| $query->set( 'post__not_in', array( 10,11,20,105 ) ); | |
| } | |
| } | |
| add_filter( 'pre_get_posts', 'ni_search_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
| // Completely Disable Search | |
| function disable_search( $query, $error = true ) { | |
| if ( is_search() ) { | |
| $query->is_search = false; | |
| $query->query_vars[s] = false; | |
| $query->query[s] = false; | |
| // to error | |
| if ( $error == true ) | |
| $query->is_404 = true; |