/**
  * Check if live editor is active
  * @return bool Live editor active?
  */
 public static function is_active()
 {
     return Pootle_Page_Builder_Live_Editor_Public::instance()->_active;
 }
 /**
  * Initiates public class and adds public hooks
  * @since 2.0.0
  */
 private function _public()
 {
     //Instantiating public class
     $this->public = Pootle_Page_Builder_Live_Editor_Public::instance();
     //Adds frontend actions
     add_action('wp', array($this->public, 'init_live_editing'));
     //Ajax action to save live editor data and render new grid
     add_action('wp_ajax_pootlepb_live_editor', array($this->public, 'sync'));
     //Ajax action to save live editor data and render new grid
     add_action('wp_ajax_nopriv_pootlepb_live_editor', array($this->public, 'sync'));
     //Ajax action to save live editor data and render new grid
     add_action('wp_ajax_pootlepb_live_page', array($this->admin, 'new_live_page'));
     //Ajax action to save live editor data and render new grid
     add_action('wp_ajax_nopriv_pootlepb_live_page', array($this->admin, 'new_live_page'));
 }
    /**
     * @param $admin_bar
     */
    function admin_bar_menu($admin_bar)
    {
        ?>
		<style>
			#wpadminbar #wp-admin-bar-pootle-live-editor .ab-item:before {
				content: "\f180";
				top: 1px;
			}

			#wpadminbar li#wp-admin-bar-ppb-publish {
				display: block;
			}

			#wp-admin-bar-ppb-publish > a:before {
				content: "\f319";
				top: 2px;
			}

			li[id^="wp-admin-bar-ppb-"] a {
				clear: both;
			}

			li[id^="wp-admin-bar-ppb-new-live-"] a:before {
				content: '\f180';
			}
			li#wp-admin-bar-ppb-live-post-settings a:before {
				content: "\f111";
			}
		</style>
		<?php 
        global $post;
        //Checking nonce
        $nonce = filter_input(INPUT_GET, 'ppbLiveEditor');
        $new_live_page_url = admin_url('admin-ajax.php');
        $new_live_page_url = wp_nonce_url($new_live_page_url, 'ppb-new-live-post', 'ppbLiveEditor') . '&action=pootlepb_live_page';
        $admin_bar->add_menu(array('parent' => 'new-content', 'id' => 'ppb-new-live-page', 'title' => 'Live Page', 'href' => $new_live_page_url));
        $admin_bar->add_menu(array('parent' => 'new-content', 'id' => 'ppb-new-live-post', 'title' => 'Live Post', 'href' => $new_live_page_url . '&post_type=post'));
        if (wp_verify_nonce($nonce, 'ppb-live-edit-nonce') || wp_verify_nonce($nonce, 'ppb-live-' . get_the_id())) {
            if ('draft' == Pootle_Page_Builder_Live_Editor_Public::instance()->post_status()) {
                $args = array('id' => 'ppb-publish', 'title' => 'Save/Publish', 'href' => '#ppb-live-save-publish', 'meta' => array('title' => __('Save and publish your changes.')));
                $admin_bar->add_menu($args);
                $args['parent'] = 'ppb-publish';
                if ('post' == get_post_type()) {
                    $args['id'] = 'ppb-live-post-settings';
                    $args['href'] = '#ppb-live-post-settings';
                    $args['title'] = 'Post settings';
                    $admin_bar->add_menu($args);
                }
                $args['id'] = 'ppb-live-update-changes';
                $args['href'] = '#ppb-live-update-changes';
                $args['title'] = 'Save';
                $admin_bar->add_menu($args);
                $args['id'] = 'ppb-live-publish-changes';
                $args['href'] = '#ppb-live-publish-changes';
                $args['title'] = 'Publish';
                $admin_bar->add_menu($args);
            } else {
                $args = array('id' => 'ppb-publish', 'title' => 'Update', 'href' => '#ppb-live-update-changes', 'meta' => array('title' => __('Save and publish your changes.')));
                $admin_bar->add_menu($args);
                if ('post' == get_post_type()) {
                    $args['parent'] = 'ppb-publish';
                    $args['id'] = 'ppb-live-post-settings';
                    $args['href'] = '#ppb-live-post-settings';
                    $args['title'] = 'Post settings';
                    $admin_bar->add_menu($args);
                }
            }
        } else {
            if (pootlepb_is_panel(true)) {
                $nonce_url = wp_nonce_url(get_the_permalink($post->ID), 'ppb-live-' . $post->ID, 'ppbLiveEditor');
                $args = array('id' => 'pootle-live-editor', 'title' => 'Live edit', 'href' => $nonce_url, 'meta' => array('title' => __('Live edit this page with pootle page builder')));
                $admin_bar->add_menu($args);
            }
        }
    }