Skip to content

Instantly share code, notes, and snippets.

View ajskelton's full-sized avatar

Anthony ajskelton

View GitHub Profile
@ajskelton
ajskelton / Mediawiki #Ask Asset_Tags
Created December 21, 2013 20:49
A semantic mediawiki ask codeblock for all data sorted by asset tag
{{#ask: [[Category:Asset_Tags]]
| ?Manufacturer
| ?Device_Name
| ?Serial_Number
| ?Model_Number
| ?Location
| format=broadtable
| limit=500
}}
@ajskelton
ajskelton / Contact-Form-7 only on pages with form
Created March 23, 2014 12:08
Contact Form 7 - Removes the loading of CF7 files on every page, and only on the "Contact" page.
add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
function my_deregister_javascript() {
if ( !is_page('Contact') ) {
wp_deregister_script( 'contact-form-7' );
}
}
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
if ( !is_page('Contact') ) {
wp_deregister_style( 'contact-form-7' );
@ajskelton
ajskelton / getRGB(hex)
Last active December 31, 2016 14:42
A function that takes a HEX code and returns the rgb value.
function getRGB(hex) {
if(hex[0] === '#') {
hex = hex.substring(1,7);
}
var r = parseInt(hex.substring(0,2),16);
var g = parseInt(hex.substring(2,4),16);
var b = parseInt(hex.substring(4,6),16);
return 'rgb(' + r + ', ' + g + ', ' + b + ')';
@ajskelton
ajskelton / SassMeister-input-HTML.html
Created June 16, 2014 14:28
Generated by SassMeister.com.
<div class="container">
<header></header>
<section id="hero"></section>
<h2>photography &amp; design</h2>
<section id="services">
<ul>
<li><h3>portraits</h3></li>
<li><h3>events</h3></li>
<li><h3>maternity</h3></li>
<li><h3>promotional</h3></li>
@ajskelton
ajskelton / Remove Wordpress Media Player Styling
Last active November 21, 2018 19:23
A function and hook to remove the styling for the WordPress Media Player
function remove_mediaelement_styles() {
wp_dequeue_style('wp-mediaelement');
wp_deregister_style('wp-mediaelement');
}
add_action( 'wp_print_styles', 'remove_mediaelement_styles' );
@ajskelton
ajskelton / WordPress Speed Boosts
Last active November 21, 2018 19:23
Code snippits to speed up WordPress site
// Limit post revisions to 3
define( 'WP_POST_REVISIONS', 3 );
// Empty trash every 7 days instead of the default 30
define('EMPTY_TRASH_DAYS', 7);
@ajskelton
ajskelton / WP Customizer - Text
Last active February 27, 2023 11:57
Add a Text field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_text_setting_id', array(
'capability' => 'edit_theme_options',
'default' => 'Lorem Ipsum',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( 'themeslug_text_setting_id', array(
'type' => 'text',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Text' ),
@ajskelton
ajskelton / WP Customizer - Textarea
Last active December 14, 2022 15:10
Add a Textarea field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_textarea_setting_id', array(
'capability' => 'edit_theme_options',
'default' => 'Lorem Ipsum Dolor Sit amet',
'sanitize_callback' => 'sanitize_textarea_field',
) );
$wp_customize->add_control( 'themeslug_textarea_setting_id', array(
'type' => 'textarea',
'section' => 'custom_section', // // Add a default or your own section
'label' => __( 'Custom Text Area' ),
@ajskelton
ajskelton / WP Customizer - Date
Last active January 10, 2020 00:52
Add a Date field to the WordPress Customizer. Includes sanitize function for displaying date as '2016-10-25'.
$wp_customize->add_setting( 'date_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_date',
) );
$wp_customize->add_control( 'date_setting_id', array(
'type' => 'date',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Date' ),
'description' => __( 'This is a custom date control.' ),
@ajskelton
ajskelton / WP Customizer - URL
Last active May 5, 2020 15:01
Add a URL field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_url_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_url',
) );
$wp_customize->add_control( 'themeslug_url_setting_id', array(
'type' => 'url',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom URL' ),
'description' => __( 'This is a custom url input.' ),