Skip to content

Instantly share code, notes, and snippets.

Patrick Daly developdaly

Block or report user

Report or block developdaly

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
@developdaly
developdaly / force-ssl.php
Last active Aug 29, 2015
This snippet will check the current URL's protocol and if it matches http:// then it will redirect to the same URL but replace the protocol with https://
View force-ssl.php
<?php
add_action( 'after_setup_theme', 'my_plugin_force_ssl' );
/**
* Force unencrypted URLs to redirect to an SSL encrypted version.
*/
function my_plugin_force_ssl() {
$protocol = stripos( $_SERVER['SERVER_PROTOCOL'],'https' ) === true ? 'https://' : 'http://';
if( $protocol == 'http://' ) {
@developdaly
developdaly / functions.php
Last active Aug 29, 2015
This code will force HTTPS in the canonical URL meta tag of a WordPress site in an instance where SSL is not the forced protocol.
View functions.php
<?php
add_action( 'after_setup_theme', 'my_theme_setup' );
function my_theme_setup() {
/* Customize the canonical URL. */
remove_filter( 'wp_head', 'rel_canonical' );
add_filter( 'wp_head', 'my_rel_canonical' );
}
View gist:5189640
$(document).ready(function () {
getRate( 'Dealer: New', 72, 72, '.rate-new-72-72' );
});
/**
* Retrieves the interest rate for given minimum and maximum month terms.
*
* @arg type string Required. The description of the product.
@developdaly
developdaly / media_shortcode.php
Last active Mar 16, 2016
This shortcode will reference a media item, configurable via attributes. Using a shortcode is more flexible and won't require database search/replace when migrating domains. Core would benefit from utilizing this system rather than inserting absolute paths to media URLs. A shortcode would keep media references relative to the site's domain.
View media_shortcode.php
<?php
/*
* Plugin Name: Media Shortcode
* Author: developdaly
* Version: 1.0
* Description: This shortcode will reference a media item, configurable via attributes. Using a shortcode is more flexible and won't require database search/replace when migrating domains.
*
* ex. [media id="97"] = <img src="http://example.com/97-300x150.jpg" class="thumbnail">
*
*/
@developdaly
developdaly / sunrise.php
Created Dec 3, 2012
WordPress network sunrise.php for multiple environments with a single database
View sunrise.php
<?php
// Check the current host or server name
if (isset($_SERVER['HTTP_HOST'])) {
$host = $_SERVER['HTTP_HOST'];
} elseif (isset($_SERVER['SERVER_NAME'])) {
$host = $_SERVER['SERVER_NAME'];
}
// Switch the host to the desired domain
@developdaly
developdaly / get_beanstalk_revision.php
Created Nov 28, 2012
This function gets the latest Beanstalk SVN/Git revision number for use in your theme/plugin
View get_beanstalk_revision.php
<?php
/**
* This function looks for the directory that "wp-config.php" resides in
* and then looks for a file named ".revision", the content of which is a
* single integer set by Beanstalk upon deployment.
*
* The purpose is to version static resources so that browsers will
* re-download any cached, outdated versions with the newer version.
*
You can’t perform that action at this time.