Skip to content

Instantly share code, notes, and snippets.

@congthien
Created December 9, 2017 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save congthien/42863edca12d5fc6c1242721ec8c71a9 to your computer and use it in GitHub Desktop.
Save congthien/42863edca12d5fc6c1242721ec8c71a9 to your computer and use it in GitHub Desktop.
<?php
namespace Elementor;
function onepress_plus_insert_elementor($atts)
{
if (!class_exists('Elementor\Plugin')) {
return '';
}
$atts = wp_parse_args( $atts, array(
'id' => '',
'slug' => ''
) );
$post = false;
if ( $atts['id'] ) {
$post = get_post( $atts['id'] );
}
if ( ! $post ) {
if ( $atts['slug'] ) {
$post = get_page_by_path( $atts['slug'] );
}
}
if ( ! $post ) {
return '';
}
$post_id = $post->ID;
$response = Plugin::instance()->frontend->get_builder_content_for_display($post_id);
return $response;
}
add_shortcode('onepress_plus_insert_elementor', 'Elementor\onepress_plus_insert_elementor');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment