- SSH into your server, then navigate to your domain’s web root:
cd /var/www/vhosts/example.com/httpdocs - Grab the latest WP install
wget http://wordpress.org/latest.tar.gz - Get the files out of the archive:
tar xfz latest.tar.gz - Navigate to the
wordpresssubfolder:
cd wordpress - Copy everything back up to the web root:
cp -rpf * ../ - Navigate back up to web root:
cd .. - Remove the
wordpresssubfolder:
rm -rf wordpress - Remove the downloaded archive file:
rm -f latest.tar.gz
Install WordPress via SSH
How to Conditionally Add Style Sheets for IE in WordPress
Update: http://code.garyjones.co.uk/enqueued-style-sheet-extras/#ie
Over time, Internet Explorer (IE) is getting better at rendering web pages how we want them, but while IE7 and earlier versions still have a (fast-fading) grip, we sometimes still need to provide exclusive styles to make them render our sites in an acceptable way. That is where conditional style sheets are used.
View the code
How to Correctly Add a Tweet Button
The end result from a different Genesis article on How to Add a Tweet Button on Single Posts can also be implemented in an advanced way across all themes, which avoids the need to use invalid markup as suggested by Twitter.
Open up the functions.php file in your child theme and add the following code. The code should be entered at the end of the file, just before the closing ?> if there is one.
add_action( 'wp_print_scripts', 'child_add_tweet_button' );
/**
* Add tweet link and script.
*
* @author Gary Jones
* @link http://code.garyjones.co.uk/add-tweet-button/
*/
function child_add_tweet_button() {
// Only add this to anything not a page
if ( ! is_page() ) {
// Add a script to the bottom of the source
wp_enqueue_script( 'tweet-button', 'http://platform.twitter.com/widgets.js', array(), '', true );
// Filter in the required Twitter link for limited and unlimited content
add_filter( 'the_content', 'child_add_tweet_button_link' );
add_filter( 'the_content_limit', 'child_add_tweet_button_link' );
// Remove stripped link from excerpts.
add_filter( 'wp_trim_excerpt', 'child_remove_stripped_tweet_button' );
// Optionally add it in to excerpts properly (uncomment to use).
//add_filter( 'the_excerpt', 'child_add_tweet_button_link' );
}
}
/**
* Add tweet link.
*
* @author Gary Jones
* @link http://code.garyjones.co.uk/add-tweet-button/
*
* @param string $content HTML markup for post content
* @return string HTML markup for post content
*/
function child_add_tweet_button_link( $content ) {
global $post;
$query_string_parameters = array(
// URL of the page to share
'url' => get_permalink(),
// Screen name of the user to attribute the Tweet to
'via' => 'GaryJ',
// Default Tweet text - here, the post title
'text' => get_the_title( $post->ID ),
// Related accounts that will be suggested to follow once tweet has been shared
'related' => '',
// Count box position - 'horizontal', 'vertical' or 'none'
'count' => 'vertical',
// The language for the Tweet Button - default is English (en)
'lang' => 'en',
// The URL to which your shared URL resolves to
'counturl' => get_permalink()
);
// Optionally use this if you have custom shortlinks set up. Uncomment to use.
//$query_string_parameters['url'] = wp_get_shortlink();
// Construct our URL to pass to Twitter - gets urlencoded here
$twitter_url = add_query_arg( $query_string_parameters, '//twitter.com/share' );
return '<a href="' . htmlspecialchars( $twitter_url ) . '" class="twitter-share-button">Tweet</a>' . $content;
}
/**
* Excerpt strip HTML, so the Tweet link just ends up as "Tweet" prefixed to the first word of the excerpt.
*
* Does mean that you can't start any article with the word Tweet, but this is an edge scenario.
*
* @author Gary Jones
* @link http://code.garyjones.co.uk/add-tweet-button/
*
* @param string $content Plain text
* @return string
*/
function child_remove_stripped_tweet_button( $content ) {
return preg_replace( '/^Tweet/', '', $content, 1 );
}
While being substantially more code, this has several advantages:
- If JavaScript isn’t enabled, the markup is still valid for the default Genesis doctype;
data-*attributes are only valid in HTML5, and while most users will have this switched out of the DOM in favour of the added iframe, the markup added by the first method is invalid for XHTML 1.0 Strict. - The JavaScript from Twitter is only added once, at the bottom of the page, and not every time the button appears, such as on archive pages.
- The “text” argument is explicitely given as the title of the post in which the button appears (and not the title of the page where the post appears), meaning you can add buttons to posts on archive pages, or featured posts widget posts, and have the correct text be used.
- You can easily and optionally enable the button for excerpts as well as limited and unlimited post content.
- You can easily and optionally have your post shortlink as the URL to share, instead of the full permalink. Good if you’re tracking traffic through the shortlink.
- There are no redundant “Tweet” strings added at the beginning of excerpts, where the markup has been stripped.
- There is support for the “related” and “lang” arguments, allowing easier customization.
Genesis Grid Loop
This post has now been updated to Genesis Grid Loop Advanced. The below post is kept for posterity only.
While the simple example of how to use the Genesis grid loop might be enough to get you up and running, there are far more advanced ways you can use the grid loop to really get the best out of it.
This tutorial will go through the steps to adding a variable column balanced grid for any archive page on your site. If you just want the code, skip to the final section. All of the code snippets go at the end of your child theme functions.php file, just before any closing ?> there might be, except for the CSS which will go at the end of your child theme style.css (or css/custom.css for Prose) file.
This tutorial requires Genesis 1.5 or later to work. Adding it to a child theme while running an earlier version of Genesis will kill your site, so go ahead and update Genesis first!
View the explanation and code
PHP Class for Greatest Common Factor
The following class can be used to find the greatest common factor for two or more numbers by using Euclid’s algorithm. It was created from original code at http://www.calculatorsoup.com/calculators/math/gcf.php.