Skip to content

Instantly share code, notes, and snippets.

View chrisdigital's full-sized avatar

Chris C. chrisdigital

View GitHub Profile
@chrisdigital
chrisdigital / gist:a1264367998b8582b0d2
Created July 28, 2015 21:54
WordPress : How to find out the current template being used for current page
//http://www.wpinsite.com/code-snippets/how-to-get-the-name-of-the-current-wordpress-page-template
//https://wordpress.org/support/topic/get-name-of-page-template-on-a-page
/**
* Get the name of the current page template name.
* @return string
*/
function get_page_template_name() {
if(is_page()) {
global $post;
<?php
//Drop this in your functions.php file in a safe place
//Change all references to "borough" or "Borough" to the taxonomy you need (pay attention to the correct capitalization)
//Then save the edited functions.php
//Find this new filter in: WP Admin > Events > Settings > Filterbar
//Docs for TribeEventsFilter: http://docs.tri.be/Filter-Bar/class-TribeEventsFilter.html
//
//
//This addresses adding/registering the taxonomy to WordPress and the filter functionality to Events Calendar Pro Filter Bar in one shot
//
# Compiled source #
###################
.pict
.svg
.gif
.jpg
.swf
.fla
.flv
.psd
@chrisdigital
chrisdigital / Frontend user profile in WordPress
Created May 6, 2013 13:27
Setting up a editable user profile in WordPress on the frontend.
//How to edit a user profile on the front end?
//http://wordpress.stackexchange.com/questions/9775/how-to-edit-a-user-profile-on-the-front-end
//Forcing nickname as display_name in custom edit profile template
//http://wordpress.stackexchange.com/questions/35403/forcing-nickname-as-display-name-in-custom-edit-profile-template
///////
<?php
@chrisdigital
chrisdigital / Overriding selected theme in WordPress
Created May 2, 2013 09:44
Overriding selected theme (open phpMyAdmin) to switch to default to combat server 500 error directly in database for WordPress.
//http://designgala.com/how-to-change-wordpress-theme-directly-from-database/
UPDATE wp_options SET option_value = 'default' WHERE option_name = 'template';
UPDATE wp_options SET option_value = 'default' WHERE option_name = 'stylesheet';
UPDATE wp_options SET option_value = 'default' WHERE option_name = 'current_theme';
@chrisdigital
chrisdigital / move WordPress multisite
Created May 1, 2013 05:39
Moving WordPress multisite to a new domain (example shown copies production to development environment.)
//http://wordpress.org/support/topic/transfer-multisite-to-another-server
//http://halfelf.org/2012/moving-wordpress-multisite/
//http://codex.wordpress.org/Moving_WordPress
//http://www.realisingdesigns.com/2010/09/16/moving-the-domain-of-a-wordpress-multisite-install/
UPDATE wp_options SET option_value = replace(option_value, 'www.production.com', 'beta.development.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'www.production.com', 'beta.development.com');
UPDATE wp_posts SET post_content = replace(post_content, 'www.production.com', 'beta.development.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'www.production.com', 'beta.development.com');
@chrisdigital
chrisdigital / gist:5428443
Created April 21, 2013 04:05
Disable author page in Wordpress redirect to hp
#
#http://wordpress.stackexchange.com/questions/74924/disable-author-pages-for-specific-users
#
function tst() {
global $wp_query;
if (is_author() && !empty($wp_query->query['author_name'])) {
$author = get_user_by('login',$wp_query->query['author_name']);
if ( 1 === $author->ID) {
wp_safe_redirect(get_bloginfo('url'),'301'); // or whatever you want
}
@chrisdigital
chrisdigital / Wordpress - Remove theme options of parent in child theme
Last active December 13, 2015 18:08
Sometimes when customizing a commercial Wordpress theme, you want to BLOW UP (remove) the theme options/settings and have your css files do the heavy lifting. Here's how to rip them out via your "child theme setup function."
// Naturally, this is relative to each theme,
// you're going to have to hunt to figure out
// what the items are called in your functions.php
// of parent theme or framework code
// theme prefix = most likely your theme folder name
// Read these threads for context...
// http://wordpress.org/support/topic/overriding-twentyeleven-theme-optionsphp
// http://stackoverflow.com/questions/8994887/how-to-remove-wordpress-theme-options-from-child-theme
// http://codex.wordpress.org/Function_Reference/remove_submenu_page
@chrisdigital
chrisdigital / grab_image_description_pinterest
Last active December 12, 2015 07:58
Grab image description for Pinterest. Extending functionality of "Pinterest Image Pin" Wordpress plugin... http://wordpress.org/extend/plugins/pinterest-image-pin/
/* Now wrapped in an if statement, checking for information to tag onto url even exists in current dom.
It also now encodes parentheses.
It was failing silently on some pages and wasn't sure why but it's fixed now.
I think the pinterest plugin uses multiple links and so I'm only targeting the .pin-it-button class link specfcally now.
I also chained a bunch of .txt stripping (.replace()) events together */
if(jQuery("div.specifications").length > 0){
//target the anchor/image link in the selector we're focused on...
var pinTarget = jQuery(".sdjpip_linkbox a.pin-it-button");
@chrisdigital
chrisdigital / PHP Date converter
Last active September 28, 2017 15:14
Little date function to convert XX/XX/XXXX into verbose date (e.g. "January 11, 2015")
```Php
function dateConvert($x_date){
$x_date = explode('/', $x_date, 4);
$x_months = array('','January','Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$x_month = intval($x_date[0]);
$x_day = intval($x_date[1]);
$x_year = $x_date[2];
return ($x_months[$x_month]." ".$x_day. ", ".$x_year);
}```