/**
 * Makes page builder content visible to WP SEO
 *
 * @param string $content Post content
 * @param object $post Post object
 *
 * @return string Post content
 * @since 0.1.0
 */
function pootlepb_text_content($content, $post = null)
{
    if (empty($post)) {
        global $post;
    }
    $post_id = empty($post->ID) ? $post->ID : false;
    if (!apply_filters('pootlepb_dump_ppb_content', (bool) $post_id, $post_id)) {
        return $content;
    }
    if ('content' == get_option('pootlepb-content-deactivation')) {
        $ppb_output = pootlepb_get_text_content($post->ID);
    } else {
        $ppb_output = Pootle_Page_Builder_Render_Layout::render($post->ID);
    }
    if ($ppb_output) {
        return $ppb_output;
    } else {
        return $content;
    }
}
 /**
  * Saves setting from front end via ajax
  * @since 1.1.0
  */
 public function sync()
 {
     if ($this->init_live_editing()) {
         $id = $_POST['post'];
         if (!empty($_POST['data'])) {
             foreach ($_POST['data']['widgets'] as $i => $wid) {
                 if (!empty($wid['info']['style'])) {
                     $_POST['data']['widgets'][$i]['info']['style'] = wp_unslash($wid['info']['style']);
                     $_POST['data']['widgets'][$i]['text'] = wp_unslash($wid['text']);
                 }
             }
         }
         if (filter_input(INPUT_POST, 'publish')) {
             // Update post
             $live_page_post = array('ID' => $id);
             if ('Publish' == filter_input(INPUT_POST, 'publish')) {
                 $live_page_post['post_status'] = 'publish';
             }
             $live_page_post = $this->savePostMeta($live_page_post);
             /**
              * Fired before saving pootle page builder post meta
              * @param array $ppb_data Page builder data
              * @param Int $post_id Post ID
              * @param WP_Post $post Post object
              */
             do_action('pootlepb_save_post', $_POST['data'], $id, get_post($id));
             foreach ($_POST['data']['widgets'] as $i => $wid) {
                 if (!empty($wid['info']['style'])) {
                     $_POST['data']['widgets'][$i]['info']['style'] = wp_slash($wid['info']['style']);
                     $_POST['data']['widgets'][$i]['text'] = wp_slash($wid['text']);
                 }
             }
             // Update PPB data
             update_post_meta($id, 'panels_data', $_POST['data']);
             // Generate post content
             $post_content = pootlepb_text_content('', (object) $live_page_post);
             if ($post_content) {
                 $live_page_post['post_content'] = $post_content;
             }
             // Update post
             wp_update_post($live_page_post, true);
             echo get_permalink($id);
         } else {
             $the_query = new WP_Query(array('post_type' => 'any', 'post__in' => array($id), 'ignore_sticky_posts' => 1));
             if ($the_query->have_posts()) {
                 while ($the_query->have_posts()) {
                     $the_query->the_post();
                     $live_page_post = $this->savePostMeta(array('ID' => $id));
                     // Update post
                     wp_update_post($live_page_post, true);
                     echo Pootle_Page_Builder_Render_Layout::render($id, $_POST['data']);
                 }
             }
         }
     }
     die;
 }