adding this code crashes my site…help!
-
hello, i’m attempting to add this code to my site, but when i do, it makes my site completely inaccessible.
i tried to fiddle on my site locally, but it ruined that too, and i can’t access it anymore. i’m hoping someone out there could take a look at my site and possible help me figure out what’s wrong?this is the code i’m trying to add to my functions.php file:
function insert_pinterest($content) { global $post; $posturl = urlencode(get_permalink()); //Get the post URL $pinspan = '<span class="pinterest-button">'; $pinurl = '<a href="https://pinterest.com/pin/create/button/?url='.$posturl.'&media='; $pindescription = '&description='.urlencode(get_the_title()); $pinfinish = '" class="pin-it">'; $pinend = '</span>'; $pattern = '/<img(.*?)src="(.*?).(bmp|gif|jpeg|jpg|png)"(.*?) \/>/i'; $replacement = $pinspan.$pinurl.'$2.$3'.$pindescription.$pinfinish.'<img$1src="$2.$3" $4 />'.$pinend; $content = preg_replace( $pattern, $replacement, $content ); //Fix the link problem $newpattern = '/<a(.*?)><span class="pinterest-button"><a(.*?)><\/a><img(.*?)\/><\/span><\/a>/i'; $replacement = '<span class="pinterest-button"><a$2><a$1><img$3\/></span>'; $content = preg_replace( $newpattern, $replacement, $content ); return $content; } add_filter( 'the_content', 'insert_pinterest' );
- The topic ‘adding this code crashes my site…help!’ is closed to new replies.