Created
June 9, 2019 17:15
-
-
Save iamkingsleyf/2117318f530ac9cd4c25b244904e72f8 to your computer and use it in GitHub Desktop.
This file contains 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 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