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; |
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 { |
View oxygen-repeater-dynamic-query.php
/* | |
* Example of related posts repeater for any CPT with taxonomy: | |
* - Filter query to prevent altering queries inside the repeater items, | |
* - Retrieve post category slug in taxonomy terms : I have only one for each post, so I just take first element. | |
* (You might need to add error tests, of course, if you don't accept empty results, | |
* for instance if you forgot to set post category.) | |
* - Set tax_query arg with taxonomy slug | |
* (for instance 'category' for standard posts category, 'post_tag' for tags, 'product_cat' for WooCommerce products) | |
* - Set random order | |
* - Exclude current post |
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() { |
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 | |
*/ |
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; |