Skip to content

Instantly share code, notes, and snippets.

@lynt-smitka
Created June 30, 2021 17:43
Show Gist options
  • Save lynt-smitka/d00edb1c5d6f87ff57bd61ee5ff73de8 to your computer and use it in GitHub Desktop.
Save lynt-smitka/d00edb1c5d6f87ff57bd61ee5ff73de8 to your computer and use it in GitHub Desktop.
Oxygen - shortcode render
function lynt_save_oxygen( $meta_id, $object_id, $meta_key, $meta_value ) {
if ( 'ct_builder_shortcodes' !== $meta_key ) return;
$post = get_post( $object_id );
if ( 'page' !== $post->post_type ) return;
$content = "<!-- wp:html -->\n" . do_shortcode( $meta_value ) . "\n<!-- /wp:html -->";
$postarr = [
'ID' => $post->ID,
'post_content' => $content
];
wp_update_post( $postarr );
}
add_action( 'updated_postmeta', 'lynt_save_oxygen', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment