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 08:15
Add html5 support for comments, search, gallery and captions.
add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );
@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 / 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 / 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 / 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
Created June 16, 2019 23:58
Add default Gutenberg block styles
add_theme_support( 'wp-block-styles' );
@wplit
wplit / snippet.php
Created August 1, 2019 23:42
Is single post (of post type) condition
add_action('init', 'lit_register_condition_single_post_type');
function lit_register_condition_single_post_type() {
global $oxy_condition_operators;
$postTypes = get_post_types();
oxygen_vsb_register_condition('Single Post Type', array('options'=> array_keys($postTypes)), $oxy_condition_operators['simple'], 'lit_condition_single_post_type_callback', 'Post');
}
@wplit
wplit / code-block.js
Created August 20, 2019 06:58
remove IDs from repeater component in Oxygen (to remove Lighthouse Error)
jQuery(".oxy-dynamic-list").find("*").removeAttr('id');
@wplit
wplit / shortcodes.php
Created October 20, 2019 01:10
Shortcode for adding post classes inside Oxygen Repeater
add_shortcode( 'repeater_post_class', 'lit_post_class_sc' );
/**
* Shortcode for adding post classes inside Oxygen Repeater
*/
function lit_post_class_sc( $atts, $content = null ) {
$postclasses = join( ' ', get_post_class() );
return '<div class="'. $postclasses . '" />' . $content . '</div>';
@wplit
wplit / snippet.php
Last active December 17, 2019 21:29
change order of default query
add_action( 'pre_get_posts', 'search_filter' );
function search_filter($query) {
if ( ! is_admin() && $query->is_main_query() ) {
if ( $query->is_search ) {
$query->set( 'order', 'ASC' );
}
}
}