Skip to content

Instantly share code, notes, and snippets.

View wplit's full-sized avatar
💭
I may be slow to respond.

David Browne wplit

💭
I may be slow to respond.
View GitHub Profile
@wplit
wplit / snippet.php
Created June 16, 2019 07:33
Ensure all Embed Gutenberg Blocks are Responsive by Default
add_theme_support( 'responsive-embeds' );
@wplit
wplit / snippet.php
Created June 16, 2019 07:53
Remove Favicon Completely from WP
add_action('wp_head', 'lit_no_favicon');
function lit_no_favicon() {
echo '<link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon" />';
}
@wplit
wplit / snippet.php
Last active June 16, 2019 08:01
Strip WP menu markup down to bare minimum
// Removes all CSS classes & ID's from menu items (only allows those listed)
add_filter('nav_menu_css_class', 'lit_strip_nav_menu');
add_filter('nav_menu_item_id', 'lit_strip_nav_menu');
function lit_strip_nav_menu($var) {
return is_array($var) ? array_intersect($var, array(
'current-menu-item',
'menu-item',
'menu-item-has-children',
'sub-menu'
)
@wplit
wplit / snippet.php
Last active June 16, 2019 08:24
Add Global Colours to WP Editor
// Adds brand colours to editor palette for content editors
add_theme_support( 'editor-color-palette', array(
array(
'name' => 'Primary',
'slug' => 'primary',
'color' => '#db164d', // Replace with your colour
),
array(
'name' => 'Secondary',
'slug' => 'secondary',
@wplit
wplit / code-block.php
Created June 16, 2019 22:47
Use custom logo inside template
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
@wplit
wplit / snippet.php
Last active June 16, 2019 23:09
Enable custom logo in WordPress
add_theme_support( 'custom-logo',
array(
'height' => 200,
'width' => 200,
'flex-width' => true,
)
);
@wplit
wplit / editor-styles.css
Created June 16, 2019 23:50
Change Width of Block Editor to Match Oxygen Template (in editor-styles.css)
/* Change max-width to match template */
.wp-block {
max-width: 720px;
}
@wplit
wplit / snippet.php
Last active June 20, 2019 04:51
Adds quick link to resign shortcodes in admin bar, useful when moving between staging - dev areas when using Oxygen
add_action( 'admin_bar_menu', 'lit_resign_adminbar_item', 1002 );
/**
* Adds "Resign" menu item in the WordPress admin bar.
*
* @param WP_Admin_Bar $admin_bar WP_Admin_Bar instance, passed by reference.
*/
function lit_resign_adminbar_item( $admin_bar ) {
if( !class_exists( 'CT_Component' ) ) {
return;
@wplit
wplit / snippet.php
Last active June 20, 2019 04:52
Call function that inserts google tag manager code just after opening body tag (for use with Oxygen & Duracell Tomi's Google Tag Manager for WordPress)
add_action( 'plugins_loaded', 'lit_oxy_gtm' );
function lit_oxy_gtm() {
if( class_exists( 'CT_Component' ) ) {
add_action( 'ct_before_builder', 'lit_add_gtm_tag' );
}
}
@wplit
wplit / snippet.php
Created June 16, 2019 23:58
Add default Gutenberg block styles
add_theme_support( 'wp-block-styles' );