Skip to content

Instantly share code, notes, and snippets.

/** The name of the database for WordPress */
define('DB_NAME', 'wp_db_prod_main');
/** MySQL database username */
define('DB_USER', 'wp_db_prod');
/** MySQL database password */
define('DB_PASSWORD', 'passmyWPw0rd!');
/** MySQL hostname */
cd /var/www/html
wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
mv wordpress blog
//setup wp-config
cd blog
mv wp-config-sample.php wp-config.php
vi wp-config.php
yum install php php-mysql
service httpd restart
cd /var/www/html
vi test.php
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
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. */
//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');
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');
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 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 );
//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);
}