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 September 10, 2018 23:17
Remove Google Fonts from Oxygen Builder
// Remove Google Fonts from Oxygen
remove_action('wp_head', 'add_web_font',0);
@wplit
wplit / plugin.php
Last active May 5, 2021 17:30
Enqueuing custom CSS inside the Oxygen Builder
/**
* Loads CSS inside the Oxygen Builder
*/
add_action( 'plugins_loaded', 'lit_oxy_builder_css' );
function lit_oxy_builder_css() {
if( class_exists( 'CT_Component' ) ) {
add_action( 'oxygen_enqueue_ui_scripts', 'lit_oxy_ui_scripts' );
}
}
@wplit
wplit / snippet.php
Last active April 3, 2019 21:24
Remove default component CSS from Oxygen
// Remove default Oxygen.css
add_action( 'oxygen_enqueue_scripts', 'lit_dequeue_scripts' );
function lit_dequeue_scripts() {
wp_dequeue_style("oxygen");
}
@wplit
wplit / plugin.php
Last active April 16, 2019 16:10
Add backend styles for gutenberg, where style-editor.css is not available from theme. (like with Oxygen)
add_action( 'enqueue_block_editor_assets', 'lit_add_gutenberg_styles' );
/**
* Add backend styles for Gutenberg
*/
function lit_add_gutenberg_styles() {
wp_enqueue_style( 'custom-gutenberg-editor-styles', plugin_dir_url( __FILE__ ) . '/editor-styles.css');
}
@wplit
wplit / editor-styles.css
Created November 13, 2018 00:27
Change Gutenberg editor width
/* Main column width */
.wp-block {
max-width: 900px;
}
/* Width of "wide" blocks */
.wp-block[data-align="wide"] {
max-width: 1100px;
}
@wplit
wplit / snippet.php
Created December 5, 2018 23:00
Remove unused Oxygen's footer script markup
remove_action("wp_footer", "ct_footer_script_hook", 20);
@wplit
wplit / code-block.js
Last active December 7, 2018 00:14
add fade out effect to element on scroll
jQuery(function( $ ){
var element = $( ".element-class" );
function fade_element() {
window_scroll = $(this).scrollTop();
element.css({
'opacity' : 1-(window_scroll/300),
'transform' : "translate(0,"+ +(window_scroll/2) + "px)" });
});
@wplit
wplit / shortcodes.php
Last active February 12, 2021 03:52
Shortcodes for Oxygen's shortcode wrapper component to show/hide content based on if we're on an AMP page or not. For use with Oxygen Builder and AMP for WordPress plugin.
add_shortcode( 'show_if_amp', 'lit_show_on_amp_only' );
/**
* Add a custom shortcode to show content if we're on amp page.
*
* Sample usage: [show_if_amp]content[/show_if_amp]
*
* @param array $atts An associative array of attributes, or an empty string if no attributes are given.
* @param string $content The enclosed content.
* @return void|string Enclosed content for amp pages and non-amp pages
*/
@wplit
wplit / snippet.php
Last active January 16, 2019 22:08
Conditionally remove WP block editor (gutenberg) library CSS from front
add_action( 'wp_print_styles', 'lit_deregister_editor_styles', 100 );
/**
* Removes WP block editor styles
*/
function lit_deregister_editor_styles() {
if ( !is_singular('post') ) { // If isn't a single post, remove excess block libary CSS
wp_dequeue_style( 'wp-block-library' );
}
@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' );
}
}