Add IE Support for HTML5 Shiv
// Double check the src
function add_ie_html5_shim() {
echo '<!–[if lt IE 9]>';
echo '<script src=”http://html5shim.googlecode.com/svn/trunk/html5.js”></script>';
echo '<![endif]–>';
}
if ($GLOBALS['is_IE']) {
add_action('wp_head', 'add_ie_html5_shim');
}
Hopefully you’re not still supporting IE – unless you’re charging out the wazoo to the customer to do so.
Builder: Add DOM Element Before Container
// Add DOM element to Builder before container output (right after opening body tag)
function add_dom_element() {
echo '<div class"custom-class></div>';
}
add_action('builder_layout_engine_render_container', 'add_dom_element' );
No longer using Builder. It was good while they kept it up to date. Not so much now.
WP: add_role() remove_role()
// Only need to load a page once to get this into db, then comment out (or place in theme/plugin activation)
// WP Codex: http://codex.wordpress.org/Roles_and_Capabilities
$result = add_role(
'basic_contributor',
__( 'Basic Contributor' ),
array(
'read' => true, // true allows this capability
'edit_posts' => true,
'delete_posts' => false, // Use false to explicitly deny
)
);
if ( null !== $result ) {
echo 'Yay! New role created!';
} else {
echo 'Oh... the basic_contributor role already exists.';
}
// Or remove a role
remove_role( 'basic_contributor' );
WP: Shortcode
function callback( $atts, $content = '' ) {
extract( shortcode_atts( array(
'text' => '',
'link' => '',
), $atts ) );
return '';
}
add_shortcode( 'name', 'callback' );
Copyright
// anywhere
printf( 'Copyright © 2010-%s COMPANY_NAME. All Rights Reserved', date( 'Y' ) );
// in WP/CP with translation/textdomain
printf( __( 'Copyright © 2010-%s COMPANY_NAME. All Rights Reserved', 'textdomain' ), date( 'Y' ) );
// can also make future year(s) conditional
$year = date('Y');
$copyright_years = $year == '2014' ? $year : '2014-'.$year;
WP: Plugins: Get Custom Post Type Template
/**
* get_template
*
* @since 0.1
*/
function get_custom_post_type_template( $template ) {
global $post;
if ( $post->post_type == 'my_post_type' ) {
$template = dirname( __FILE__ ) . '/post-type-template.php';
}
return $template;
}
add_filter( 'template_include', 'get_custom_post_type_template' );
/* more filters (from http://codex.wordpress.org/Template_Hierarchy)
archive_template
author_template
category_template
tag_template
taxonomy_template
date_template
home_template
front_page_template
page_template
paged_template
search_template
single_template
attachment_template
*/
Builder: Add Classes to Modules
/**
* Add classes to Builder modules
*
* Function name calling shouldn't be 'it_builder_loaded'
* in case parent theme is using it already.
*/
if ( ! function_exists( 'oz_builder_loaded' ) ) {
function oz_builder_loaded() {
// --> module label class
builder_register_module_style( 'content', 'Blue ', 'content-blue' );
builder_register_module_style( 'widget-bar', 'Blue (full width)', 'widget-bar-blue' );
builder_register_module_style( 'navigation', 'Subnav Blue', 'subnav-blue' );
builder_register_module_style( 'html', 'Blue Background', 'html-blue' );
builder_register_module_style( 'image', 'Blue Background (full width)', 'image-blue');
builder_register_module_style( 'header', 'White Header', 'header-white');
builder_register_module_style( 'footer', 'White Footer', 'footer-white');
}
add_action( 'it_libraries_loaded', 'oz_builder_loaded' );
}
No longer using Builder. It was good while they kept it up to date. Not so much now.