Skip to content

Instantly share code, notes, and snippets.

View richtabor's full-sized avatar

Rich Tabor richtabor

View GitHub Profile
@richtabor
richtabor / Others:
Last active April 3, 2017 21:52
Programmatically filter the default color selections in Ava.
ava_customizer_default__black
ava_customizer_default__white
ava_customizer_default__accent
ava_customizer_default__lightgray
ava_customizer_default__lightyellow
@richtabor
richtabor / charmed-remove-strikethrough.css
Created September 29, 2016 09:49
Remove the Strikethrough effect on Charmed and Charmed Pro
.header .active,
.header a:hover,
.logo_text:hover,
.site-archive a:hover,
.current-menu-item a,
.portfolio .project-meta a:hover {
text-decoration: underline !important;
}
<?php
/**
* Third Party Styles
* More info: https://github.com/grappler/wp-standard-handles
*/
// Incorrect
wp_enqueue_style( 'prefix-font-awesome', get_template_directory_uri() . '/css/font-awesome.css', array(), '4.2.0', 'all' );
// Corrrect
<?php
// Functions
function prefix_setup()
// Classes
class Prefix_Class {}
// Global Variables
global $prefix_passengers;
<?php
// Use anytime HTML element encloses a section of data:
echo esc_html( $no_html );
// Use on all URLs, including those in the 'src' and 'href' attributes of an HTML element:
<img src="<?php echo esc_url( $escaped_url ); ?>" />
// Use for inline Javascript:
<a href="#" onclick="<?php echo esc_js( $escaped_js ); ?>"><?php esc_html__( 'Click Here', 'text-domain' ); ?></a>
<?php
// These are incorrect:
__( 'Some String', 'text-domain' ); _e( 'Some string', 'text-domain' );
// Instead, use:
esc_html__( 'Some String', 'text-domain' ); esc_html_e( 'Some String', 'text-domain' );
/**
* For strings with necessary HTML, use the following:
* Note that I'm only including the actual allowed HTML for this specific string.
<?php
// Include a plugin from the WordPress Repository:
array(
'name' => esc_html__( 'WooCommerce', 'text-domain' ),
'slug' => 'woocommerce',
'required' => false,
),
// Include a plugin bundled within a WordPress theme:
array(
@richtabor
richtabor / google-fonts-the-right-way.php
Last active April 3, 2019 04:43
Demonstrates how to properly include Google Fonts into WordPress themes. Ref: http://themeshaper.com/2014/08/13/how-to-add-google-fonts-to-wordpress-themes/
if ( ! function_exists( 'prefix_fonts_url' ) ) :
/**
* Register Google fonts.
*
* @return string Google fonts URL for the theme.
*/
function prefix_fonts_url() {
$fonts_url = '';
$fonts = array();
$subsets = '';
<use xlink:href="<?php echo is_customize_preview() ? esc_url( get_template_directory_uri() . '/images/sprite.svg' ) : '' ; ?>#sprite">"></use>