Skip to content

Instantly share code, notes, and snippets.

@JPry
JPry / admin_htaccess.txt
Created November 7, 2011 21:02 — forked from norcross/admin_htaccess.txt
WCPhilly Admin
# custom login link
RewriteRule ^login$ http://localhost/whitelabel/wp-login.php [NC,L]
@JPry
JPry / esp-common-functions.php
Created December 18, 2011 04:41
Common functions included with Genesis themes
<?php
// Some common ESP functions
// Change the login URL to the site homepage
add_filter( 'login_headerurl', 'esp_change_login_url' );
function esp_change_login_url( $message ) {
return get_bloginfo( 'url' );
}
// Change the login title text
@JPry
JPry / category-part-1.php
Created January 6, 2012 04:13
Files used to add town specific category archives and styling
<?php
// First, get the current query object so we can work with it
$current_query = get_queried_object();
// Run only if the parent category is "Towns" and the sidebars are active for that town
if ( get_cat_ID( 'Towns' ) == $current_query->category_parent ) {
add_filter( 'does_city_style', 'does_site_town_name' );
if ( is_active_sidebar( $current_query->slug . '-featured-top' ) || is_active_sidebar( $current_query->slug . '-bottom-left' ) || is_active_sidebar( $current_query->slug . '-bottom-right' ) ) {
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'does_category_featured_top' );
<?php
/**
* This is an example of the proper way to take advantage of wp_cron() processes. For more information,
* see http://codex.wordpress.org/Function_Reference/wp_cron.
*
*/
// We use an if statement to see if there is already a scheduled event so that we don't add one for every page view.
if ( ! wp_next_scheduled( 'foxyshop_email_cron_test' ) ) {
wp_schedule_event( time(), 'hourly', 'foxyshop_email_cron_test' );
@JPry
JPry / remove-wpe-info.php
Last active January 19, 2022 20:52
Remove WP Engine info from WP Dashboard
<?php
// Remove all evidence of WP Engine from the Dashboard, unless the logged in user is "wpengine"
$user = wp_get_current_user();
if ( $user->user_login != 'wpengine' ) {
add_action( 'admin_init', 'jpry_remove_menu_pages' );
add_action( 'admin_bar_menu', 'jpry_remove_admin_bar_links', 999 );
}
/**
@JPry
JPry / gist:2399833
Last active October 3, 2015 05:27
If Statement sample
<?php
if ( $user->user_login == 'johnsmith' ) {
add_action( 'admin_init', 'jpry_remove_menu_pages' );
add_action( 'admin_bar_menu', 'jpry_remove_admin_bar_links', 999 );
}
?>
@JPry
JPry / stylesheetversion.php
Created June 25, 2012 20:52
Version your stylesheet when using Genesis theme
<?php
remove_action( 'genesis_meta', 'genesis_load_stylesheet' );
add_action( 'genesis_meta', 'jpry_load_stylesheet' );
function jpry_load_stylesheet() {
$theme_info = wp_get_theme();
wp_enqueue_style( 'jpry-style', get_stylesheet_uri(), array(), $theme_info->Version, 'screen' );
}
?>
@JPry
JPry / class-rewrites.php
Created October 31, 2012 15:21
WP Rewrite example
<?php
class jpry_custom_rewrites {
/**
* Additional query vars that WordPress should recognize
*
* @var array
*/
var $query_vars = array( 'date_hash', 'partner_hash', 'partner_id' );
@JPry
JPry / wp-fix.sql
Created November 7, 2012 15:32
Remove funky characters in WordPress database
update wp_posts set post_content = replace(post_content,'’','\'');
update wp_posts set post_title = replace(post_title,'’','\'');
update wp_comments set comment_content = replace(comment_content,'’','\'');
update wp_postmeta set meta_value = replace(meta_value,'’','\'');
update wp_posts set post_content = replace(post_content,'…','...');
update wp_posts set post_title = replace(post_title,'…','...');
update wp_comments set comment_content = replace(comment_content,'…','...');
update wp_postmeta set meta_value = replace(meta_value,'…','...');