Skip to content

Instantly share code, notes, and snippets.

View danielmcclure's full-sized avatar

Daniel McClure danielmcclure

View GitHub Profile
@danielmcclure
danielmcclure / Replace Page Template from Within WordPress Plugin
Created October 31, 2013 00:38
Replace Page Template from Within WordPress Plugin
//Template Replacement
add_action("template_redirect", 'custom_template_redirect');
function custom_template_redirect() {
global $wp;
$plugindir = dirname( __FILE__ );
//A Custom Post Type
if ($wp->query_vars["post_type"] == 'product') {
$templatefilename = 'single-product.php';
@danielmcclure
danielmcclure / Define Absolute Paths within WordPress Plugin
Created October 31, 2013 01:12
Define Absolute Paths within WordPress Plugin
if (!defined('MYPLUGIN_THEME_DIR'))
define('MYPLUGIN_THEME_DIR', ABSPATH . 'wp-content/themes/' . get_template());
if (!defined('MYPLUGIN_PLUGIN_NAME'))
define('MYPLUGIN_PLUGIN_NAME', trim(dirname(plugin_basename(__FILE__)), '/'));
if (!defined('MYPLUGIN_PLUGIN_DIR'))
define('MYPLUGIN_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . MYPLUGIN_PLUGIN_NAME);
if (!defined('MYPLUGIN_PLUGIN_URL'))
@danielmcclure
danielmcclure / wp-config.php
Last active November 1, 2018 20:58
Increase WordPress Memory Allocation
/* Increase WordPress Memory Allocation */
define( 'WP_MEMORY_LIMIT', '128M' );
define('FORCE_SSL_ADMIN' , true);
@danielmcclure
danielmcclure / Disable File Editing from WordPress Dashboard
Created August 22, 2014 02:07
Disable File Editing from WordPress Dashboard
define('DISALLOW_FILE_EDIT' , true);
@danielmcclure
danielmcclure / Force Two Column WordPress Dashboard
Created August 22, 2014 04:38
Force Two Column WordPress Dashboard
//* Add Dashboard Column Settings
function bm_custom_dashboard_columns() {
add_screen_option(
'layout_columns',
array(
'max' => 2,
'default' => 1
)
);
}
< ?php
/**
* @package HSTS
* @version 1.0
*/
/*
Plugin Name: HSTS - HTTP Strict Transport Security enforcement plugin
Author: kang@insecure.ws
Version: 1.0
Author URI: https://www.insecure.ws
add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' );
function load_dashicons_front_end() {
wp_enqueue_style( 'dashicons' );
}
@danielmcclure
danielmcclure / Google Fonts for WordPress
Created October 28, 2014 08:47
Add Google Fonts to WordPress
/**
* Additional Styles
* @since 1.0.0
*/
function font_styles() {
if ( !is_admin() ) {
// register styles
wp_register_style('googlefonts', 'http://fonts.googleapis.com/css?family=Oswald:400,300,700', array(), false, 'all');
@danielmcclure
danielmcclure / remove-attribution.php
Created December 10, 2014 00:24
Removes the attribution link from the Thesis Theme
<?php
/* Remove Thesis Attribution Link (Developer License Holders Only) */
remove_action('thesis_hook_footer', 'thesis_attribution');