public function init()
{
if (is_admin() || !$this->is_edit_mode()) {
return;
}
add_filter('show_admin_bar', '__return_false');
// Remove all WordPress actions
remove_all_actions('wp_head');
remove_all_actions('wp_print_styles');
remove_all_actions('wp_print_head_scripts');
remove_all_actions('wp_footer');
// Handle `wp_head`
add_action('wp_head', 'wp_enqueue_scripts', 1);
add_action('wp_head', 'wp_print_styles', 8);
add_action('wp_head', 'wp_print_head_scripts', 9);
add_action('wp_head', [$this, 'editor_head_trigger'], 30);
// Handle `wp_footer`
add_action('wp_footer', 'wp_print_footer_scripts', 20);
add_action('wp_footer', 'wp_auth_check_html', 30);
add_action('wp_footer', [$this, 'wp_footer']);
// Handle `wp_enqueue_scripts`
add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts'], 999999);
add_action('wp_enqueue_scripts', [$this, 'enqueue_styles'], 999999);
$post_id = get_the_ID();
// Change mode to Builder
Plugin::instance()->db->set_edit_mode($post_id);
// Post Lock
if (!$this->get_locked_user($post_id)) {
$this->lock_post($post_id);
}
// Setup default heartbeat options
add_filter('heartbeat_settings', function ($settings) {
$settings['interval'] = 15;
return $settings;
});
// Tell to WP Cache plugins do not cache this request.
Utils::do_not_cache();
// Print the panel
$this->print_panel_html();
die;
}