Skip to content

Instantly share code, notes, and snippets.

@swinggraphics
swinggraphics / oxy-save-rendered-content.php
Last active Nov 19, 2020
Copy compiled Oxygen page content to post_content for search
View oxy-save-rendered-content.php
/* Copy compiled Oxygen page content to post_content for search */
function sg_save_rendered_page_content( $meta_id, $object_id, $meta_key, $meta_value ) {
// Debugging
// $debug .= preg_replace( '#(\[/[^\]]+?\])#', "$1\n", $meta_value );
// file_put_contents( plugin_dir_path( __FILE__ ) . 'debug.html', $debug );
if ( 'ct_builder_shortcodes' != $meta_key ) return;
// Don't try to render anything with inner content
if ( false !== strpos( $meta_value, '[ct_inner_content' ) ) return;
@ERROPiX
ERROPiX / oxy-cm-theme.scss
Created Sep 21, 2020
An Advanced Scripts snippet to enhance the Oxygen code editor theme
View oxy-cm-theme.scss
/*
Title: Oxygen Code Editor Theme
Type: CSS > Compile SCSS Code
Location: Custom Hooks
Hook name: oxygen_enqueue_ui_scripts
Priority: 10
*/
#oxygen-ui {
.cm-s-default {
@yankiara
yankiara / oxygen-repeater-dynamic-query.php
Last active Apr 12, 2021
Use dynamic queries with Oxygen's repeater
View oxygen-repeater-dynamic-query.php
/* I'll put here different examples of dynamic query for Oxygen repeater :
* - Use one of the following repeater_dynamic_query definitions
* in code block just BEFORE the repeater
* - Set the repeater custom query settings : post type, number of posts, order...
* - Add the remove_action in a code block AFTER the repeater
*/
/****************************************************************************************************
* Display related posts for any CPT with taxonomy:
@ulziibat-n
ulziibat-n / wpseo_schema_organization.php
Created Sep 10, 2019 — forked from nicomollet/wpseo_schema_organization.php
Yoast SEO Organization Schema Replaced By LocalBusiness
View wpseo_schema_organization.php
<?php
/**
* Add LocalBusiness to schema Organization
*
* @api array $data The graph piece to filter.
*
* @return array
*/
function custom_wpseo_schema_organization($data){
@hnq90
hnq90 / functions.php
Created Jan 11, 2018 — forked from yoren/functions.php
Parent Post From Another Post Type And A New URL Structure In WordPress
View functions.php
<?php
// Flush rewrite rules after switch theme
function my_rewrite_flush() {
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_rewrite_flush' );
// A little help so we can get the stylesheet from parent theme
// Remove line 10-19 if this is not a child theme
function my_enqueue_styles() {
@c3mdigital
c3mdigital / cacheable-ajax.php
Last active Jan 30, 2021
Example of how to cache fronted ajax requests in WordPress. This will allow you to use ajax and page caching like varnish or redis. Where ajax requests would normally not be cached using the built in wp_ajax_action method.
View cacheable-ajax.php
<?php
add_filter( 'rewrite_rules_array', 'cache_frontend_ajax_rules' );
/**
* Rewrite rules filter to add rules for front end ajax calls
*
* @param array $rewrite_rules
*
* @return array
*/
@gyrus
gyrus / preload-images.js
Last active Mar 3, 2021
WordPress image preloading
View preload-images.js
/**
* Image preloader
*
* @link http://engineeredweb.com/blog/09/12/preloading-images-jquery-and-javascript
*/
var cache = [];
// Arguments are image paths relative to the current page.
function pilau_preload_images() {
var args_len, i, cache_image;
args_len = arguments.length;