Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/* ----------------------------------------------------------------------------
ADD FEATURED IMAGE TO FEED
*/
function featuredtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');
/* ----------------------------------------------------------------------------
DISABLE SELF PING
*/
//Pass the variable by reference to the function, so the function can modify the variable.
function no_self_ping (&$links) {
$home = get_option( 'home' );
foreach ( $links as $l => $link )
//Find the position of the first occurrence of a substring in a string.
//($a === $b) Identical operator. TRUE if $a is equal to $b, and they are of the same type.
if ( 0 === strpos( $link, $home ) )
//Unset the variable
unset($links[$l]);
}
//Hooks the function to the specific action (pre_ping)
add_action( 'pre_ping', 'no_self_ping' );
//Let Contributor Role to Upload Media
if ( current_user_can('contributor') && !current_user_can('upload_files') )
add_action('admin_init', 'allow_contributor_uploads');
function allow_contributor_uploads() {
$contributor = get_role('contributor');
$contributor->add_cap('upload_files');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.