Skip to content

Instantly share code, notes, and snippets.

Steven-Rose

Block or report user

Report or block Steven-Rose

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Steven-Rose
Steven-Rose / gist:3943830
Created Oct 24, 2012
VI: Select all + delete, select all + copy
View gist:3943830
Select all and delete (actually move to buffer)
:%d
Select all and copy to buffer
:%y
Use p to paste the buffer.
@Steven-Rose
Steven-Rose / gist:4199020
Created Dec 3, 2012
Drupal: Title/Page URLs
View gist:4199020
SELECT node.nid, node.type, node_revision.title, url_alias.alias AS url, if(node.changed = 0,FROM_UNIXTIME(node.created),FROM_UNIXTIME(node.changed)) AS last_modified
FROM node INNER JOIN node_revision ON (node.vid = node_revision.vid) INNER JOIN url_alias ON (url_alias.source = CONCAT('node/', node_revision.nid))
WHERE node.status = 1
ORDER BY url;
@Steven-Rose
Steven-Rose / gist:4159376
Created Nov 28, 2012
Drupal: Flush cache
View gist:4159376
truncate table `cache`;
truncate table `cache_admin_menu`;
truncate table `cache_block`;
truncate table `cache_bootstrap`;
truncate table `cache_field`;
truncate table `cache_filter`;
truncate table `cache_form`;
truncate table `cache_image`;
truncate table `cache_libraries`;
truncate table `cache_menu`;
@Steven-Rose
Steven-Rose / gist:2045328
Created Mar 15, 2012
WP: Add Google+ button to your posts automatically (updates todo)
View gist:2045328
add_filter('the_content', 'wpr_google_plusone');
function wpr_google_plusone($content) {
$content = $content.'<div class="plusone"><g:plusone size="tall" href="'.get_permalink().'"></g:plusone></div>';
return $content;
}
add_action ('wp_enqueue_scripts','wpr_google_plusone_script');
function wpr_google_plusone_script() {
wp_enqueue_script('google-plusone', 'https://apis.google.com/js/plusone.js', array(), null);
}
@Steven-Rose
Steven-Rose / gist:2027360
Created Mar 13, 2012
WP: Simpler login url
View gist:2027360
http://website.com/login
RewriteRule ^login$ http://yoursite.com/wp-login.php [NC,L]
@Steven-Rose
Steven-Rose / gist:2027368
Created Mar 13, 2012
WP: Obfuscate email addresses
View gist:2027368
[mailto]email@yourdomain.com[/mailto]
function mail_shortcode( $atts , $content=null ) {
for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';';
return '<a href="mailto:'.$encodedmail.'">'.$encodedmail.'</a>';
}
add_shortcode('mailto', 'mail_shortcode');
@Steven-Rose
Steven-Rose / gist:1979604
Created Mar 5, 2012
WP: Replace excerpt ellipsis with post permalink
View gist:1979604
function replace_excerpt($content) {
return str_replace('[...]',
'... <div class="more-link"><a href="'. get_permalink() .'">Continue Reading</a></div>',
$content
);
}
add_filter('the_excerpt', 'replace_excerpt');
- Via http://css-tricks.com/snippets/wordpress/replace-excerpt-ellipsis-with-permalink/
@Steven-Rose
Steven-Rose / gist:1895273
Created Feb 23, 2012
WP: Allow authors to add rel="me"
View gist:1895273
function yoast_allow_rel() {
global $allowedtags;
$allowedtags['a']['rel'] = array ();
}
add_action( 'wp_loaded', 'yoast_allow_rel' );
Via: http://yoast.com/wordpress-rel-author-rel-me/
@Steven-Rose
Steven-Rose / gist:1895294
Created Feb 23, 2012
WP: Add extra contact methods from user info
View gist:1895294
function add_contact_methods( $contactmethods ) {
// Add Google Profiles
$contactmethods['google_profile'] = 'Google Profile URL';
return $contactmethods;
}
add_filter( 'user_contactmethods', 'add_contact_methods', 10, 1);
Author.php
@Steven-Rose
Steven-Rose / gist:1772336
Created Feb 8, 2012
WP: Uploads directory path
View gist:1772336
$upload_dir = wp_upload_dir();
echo $upload_dir['baseurl'];
You can’t perform that action at this time.