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 | |
/* | |
Plugin Name: Posts 2 Posts List Widget | |
Plugin URI: http://friendlywebconsulting.com/ | |
Description: Creates a widget to display posts connected via the Posts 2 Posts plugin by Scribu, found here: http://wordpress.org/extend/plugins/posts-to-posts/ | |
Author: Michelle McGinnis | |
Author URI: http://friendlywebconsulting.com/ | |
Version: 1.0.0-alpha | |
*/ |
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
/** | |
* Display specified content with a word limit | |
* Can be used for excerpts, full content, etc. | |
* In your theme file, use thus to display 40 words of the excerpt: | |
* $excerpt = get_the_excerpt(); | |
* echo string_limit_words( $excerpt, 40 ); | |
* | |
* @param string $string A variable containing the content you wish to display. | |
* @param num $word_limit The number of words to display. | |
* @return string Content limited to the number of words specified. |
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
// FILTER WORDPRESS SEO BY YOAST outputs in the WordPress control panel | |
// remove WP-SEO columns from edit-list pages in admin | |
add_filter( 'wpseo_use_page_analysis', '__return_false' ); | |
// put WP-SEO panel at bottom of edit screens (low priority) | |
add_filter('wpseo_metabox_prio' , 'my_wpseo_metabox_prio' ); | |
function my_wpseo_metabox_prio() { | |
return 'low' ; | |
} |
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
// REPLACE _* *_ WITH <STRONG> HTML IN WIDGET TITLES | |
// usage: _*This*_ word is bold | |
add_filter( 'widget_title', function($title) { | |
$title = str_replace('_*', '<strong>', $title); | |
$title = str_replace('*_', '</strong>', $title); | |
return $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
/* SHORTCODE WHICH INSERTS CURRENT YEAR | |
* usage: [year] | |
*/ | |
add_shortcode('year', 'year_shortcode'); | |
function year_shortcode() { | |
$year = date('Y'); | |
return $year; | |
} |
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
/* SHORTCODE FOR EMAIL OBFUSCATION | |
* usage: [email][email protected][/email] | |
* OR: [email address="[email protected]"]Contact Us[/email] | |
*/ | |
add_shortcode('email', 'emailbot_ssc'); | |
function emailbot_ssc($atts, $content = null) { | |
extract( shortcode_atts( array( | |
'address' => '', | |
), $atts ) ); |
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 a new default avatar to the list in WordPress admin | |
// change path to reflect where your default image lives | |
add_filter( 'avatar_defaults', 'mytheme_addgravatar' ); | |
function mytheme_addgravatar( $avatar_defaults ) { | |
$myavatar = get_bloginfo('stylesheet_directory') . '/_/images/avatar.gif'; | |
$avatar_defaults[$myavatar] = 'New Default Gravatar'; | |
return $avatar_defaults; | |
} |
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
// ENABLE SHORTCODES IN ALL TEXT WIDGETS | |
add_filter('widget_text', 'do_shortcode'); |
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 WIDGET TITLE IF IT BEGINS WITH EXCLAMATION POINT | |
// To use, add a widget and in the Title field put !The title here | |
// The title will show in the control panel, but not on the site itself | |
add_filter( 'widget_title', 'remove_widget_title' ); | |
function remove_widget_title( $widget_title ) { | |
if ( substr ( $widget_title, 0, 1 ) == '!' ) | |
return; | |
else | |
return ( $widget_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
// Allows users to insert your custom image sizes via the Add Media button | |
// In this example, two custom image sizes are added to the defaults | |
add_filter( 'image_size_names_choose', 'my_custom_sizes' ); | |
function my_custom_sizes( $sizes ) { | |
return array_merge( $sizes, array( | |
'thumb-narrow' => __('Narrow Thumbnail'), | |
'thumb-wide' => __('Wide Thumbnail'), | |
) ); | |
} |
OlderNewer