Skip to content

Instantly share code, notes, and snippets.

function add_opengraph_doctype($output) {
return $output . '
xmlns="https://www.w3.org/1999/xhtml"
xmlns:og="https://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml"';
}
add_filter('language_attributes', 'add_opengraph_doctype');
//Add Open Graph Meta Info from the actual article data, or customize as necessary
function insert_fb_in_head() {
global $post;
if ( !is_singular()) //if it is not a post or a page
return;
//You'll need to find you Facebook profile Id and add it as the admin
echo '<meta property="fb:admins" content="XXXXXXXXX-fb-admin-id"/>';
echo '<meta property="og:title" content="' . get_the_title() . '"/>';
echo '<meta property="og:type" content="article"/>';
echo '<meta property="og:url" content="' . get_permalink() . '"/>';
//Add Open Graph Meta Info from the actual article data, or customize as necessary
function facebook_open_graph() {
global $post;
if ( !is_singular()) //if it is not a post or a page
return;
if($excerpt = $post->post_excerpt)
{
$excerpt = strip_tags($post->post_excerpt);
$excerpt = str_replace("", "'", $excerpt);
}
function add_attribution_backlink( $content ) {
// Process content here and add the backlink
$backlink = ‘<div class=”attribution”>This article first appeared on <a href=”http://premium.wpmudev.org/blog”>WPMU Dev Blog</a></div>’;
$content = $content . $backlink;
return $content;
}
add_filter( 'content_save_pre', ‘add_attribution_backlink’, 10, 1 );
function send_bonus_email( $form_id, $user_data, $user_id )
{
global $service_locator;
$firstName = $user_data['first_name'];
$lastName = $user_data['last_name'];
$email_content = "
Hey there $firstName, Welcome to WPMUDEV. "\r\n"
function publish_post_to_social_media($post_ID) {
global $post;
// Send a tweet
...
//Push URL to Facebook page
...
//Send to Google+ page
...
}
add_action('publish_post', 'publish_post_to_social_media');
//Google Universal Analytics
function google_analytics() { ?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'GA-XXXXXX-XX', 'auto');
ga('send', 'pageview');
add_filter( ‘title_save_pre’, ‘add_sitename_to_title’, 10, 2 );
add_sitename_to_title( $title, $sep ) {
// You might want to check whether the title has been added already before appending the title (again)
/* Retrieve site name. */
$name = get_bloginfo( ‘name’ );
/* Append site name to $title. */
ssh -i "WP_Key_Pair.pem" ec2-user@ec2-54-202-202-135.us-west-2.compute.amazonaws.com
sudo su
yum install httpd
service httpd start
yum install php php-mysql
service httpd restart
cd /var/www/html
vi test.php