Skip to content

Instantly share code, notes, and snippets.

View richtabor's full-sized avatar

Rich Tabor richtabor

View GitHub Profile
@bradyvercher
bradyvercher / register-plugin-icons.php
Created October 4, 2017 22:30
Register icons to display on the Manage Plugins screen for plugins that aren't in the WordPress.org directory.
<?php
/**
* Register plugin icons.
*
* WordPress 4.9 introduced icons in the list table on the Manage Plugins
* screen. The icons are pulled from the W.org update API. If an icon isn't
* available, a generic plugin Dashicon is shown instead.
*
* @param array $value Plugin update data.
* @return array
<?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.
/**
* Customize the default success message presented on the contact template.
*/
function prefix_custom_success_msg() {
esc_html_e('Wohoo! We have received your mail!', 'mark');
}
add_filter( 'bean_contactform_success_msg', 'prefix_custom_success_msg' );
<?php
/**
* Escape all translations with
*/
__( ‘Some String’, ‘text-domain’ ); _e( ‘Some string’, ‘text-domain’ );.
/**
* When there is no HTML use:
*/
@richtabor
richtabor / gist:8d8612f9cca006d192e6
Last active August 29, 2015 14:20
bean_custom_form_filters fix - Basically add these keys and values to the $defaults array in the bean_custom_form_filters function, located within functions.php
'id_submit' => 'submit',
'class_submit' => 'submit',
'name_submit' => 'submit',
'submit_field' => '<p class="form-submit">%1$s %2$s</a>',
'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />',