Skip to content

Instantly share code, notes, and snippets.

View chuckreynolds's full-sized avatar
🤖
building things

Chuck Reynolds chuckreynolds

🤖
building things
View GitHub Profile
@chuckreynolds
chuckreynolds / wordpress-disable-image-attachment-page.php
Created May 8, 2013 19:14
How to Disable WordPress Image Attachment Pages. Note, Yoast SEO has this as an option under Permalinks but if you're not using that...
wp_redirect(get_permalink($post->post_parent));
@chuckreynolds
chuckreynolds / wordpress-text-widget-oembed.php
Created May 7, 2013 22:24
Enable oEmbed functionality in WordPress text widgets
add_filter( 'widget_text', array( $wp_embed, 'run_shortcode' ), 8 );
add_filter( 'widget_text', array( $wp_embed, 'autoembed'), 8 );
@chuckreynolds
chuckreynolds / dabblet.css
Created May 7, 2013 03:11 — forked from vasilisvg/dabblet.css
A simple menu with a :hover action
/**
* A simple menu with a :hover action
*/
html {
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
font: 100%/2.5 helvetica, arial;
}
@chuckreynolds
chuckreynolds / wp-block-updates-after-time.php
Created April 26, 2013 23:05
Block WordPress Post Updates and Deletion After a Set Period. ganked from here as may need this in future.... http://www.wpbeginner.com/wp-tutorials/how-to-block-wordpress-post-updates-and-deletion-after-a-set-period/
function wpbeginner_restrict_editing( $allcaps, $cap, $args ) {
// Bail out if we're not asking to edit or delete a post ...
if( 'edit_post' != $args[0] && 'delete_post' != $args[0]
// ... or user is admin
|| !empty( $allcaps['manage_options'] )
// ... or user already cannot edit the post
|| empty( $allcaps['edit_posts'] ) )
return $allcaps;
@chuckreynolds
chuckreynolds / wordpress-redirect-post-single-query.php
Created April 4, 2013 20:11
Redirect to post if a search only returns one post.. Just paste the following code snippet into your functions.php file:
add_action('template_redirect', 'redirect_single_post');
function redirect_single_post() {
if (is_search()) {
global $wp_query;
if ($wp_query->post_count == 1) {
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
}
}
}
@chuckreynolds
chuckreynolds / wordpress-activate-link-manager.php
Created March 25, 2013 22:47
In WordPress 3.5+ the removed what used to be known as "links" in the admin. For now... in order to reenable that... use this filter
@chuckreynolds
chuckreynolds / yoast-wpseo-default-setup.ini
Last active December 14, 2015 15:39
For now this is my base setup for Yoast's WordPress SEO plugin - good import for basic technical setup in WP. NOTE: This is not an import and forget it type of thing. I HIGHLY STRESS that you still go through EVERY settings page and Tab in the Yoast SEO plugin settings and make sure you set it up for your exact needs. This is a good start but do…
; This is a settings export file for the WordPress SEO plugin by Yoast.com - http://yoast.com/wordpress/seo/
[wpseo]
ignore_blog_public_warning =
ignore_tour = "ignore"
ignore_page_comments =
ignore_permalink =
ms_defaults_set =
version = "1.4.1"
tracking_popup = "done"
@chuckreynolds
chuckreynolds / wp-null-search-redirect.htaccess
Created March 7, 2013 15:49
Redirect empty searches in WordPress back to root. Empty ?s= suck and WP doesn't handle them. You should.
# Redirect Empty Searches to root
RewriteCond %{QUERY_STRING} ^s=$
RewriteRule ^ /? [L,R=301]
@chuckreynolds
chuckreynolds / wp-rem-update-notify-admins.php
Created February 28, 2013 09:45
Remove WordPress Update Notifications Except for Admins
global $user_login;
get_currentuserinfo();
if (!current_user_can('update_plugins')) { /* checks to see if current user can update plugins */
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}
@chuckreynolds
chuckreynolds / wp-user-custom-fields.php
Created February 28, 2013 09:39
Custom WordPress User Profile Fields. Who EVER fills out the yim/aim/jabber fields in their wordpress profile? not me and not clients lol... in this, it removes those three fields and adds twitter, facebook and google+ profile url fields. How to add those those new fields to the front end is included in comments
// Add custom fields to user profiles
function vuurr_sm_contactmethods( $contactmethods ) {
// Add
$contactmethods['twitter'] = 'Twitter';
$contactmethods['facebook'] = 'Facebook';
$contactmethods['googleplus'] = 'Google+ About';
// Remove
unset($contactmethods['yim']);
unset($contactmethods['aim']);
unset($contactmethods['jabber']);