* @link https://www.fireplugins.com * @copyright Copyright © 2021 FirePlugins All Rights Reserved * @license GNU GPLv3 or later */ namespace FireBox\Core\Admin\Includes; if (!defined('ABSPATH')) { exit; // Exit if accessed directly. } use \FPFramework\Admin\Library\Library as FrameworkLibrary; class Library extends FrameworkLibrary { /** * The Modal ID. * * @var String */ protected $modal_id = 'fbSelectTemplate'; /** * Library categories. * * @var array */ protected $categories = [ 'all' => 'FPF_ALL', 'popup' => 'FB_POPUP', 'fullscreen' => 'FB_FULLSCREEN', 'slidein' => 'FB_SLIDEIN', 'floatingbar' => 'FB_FLOATING_BAR', 'sidebar' => 'FB_SIDEBAR', 'specials' => 'FB_SPECIALS' ]; /** * The library settings * * @var array */ protected $library_settings; public function __construct() { $this->setup(); add_action('current_screen', [$this, 'validate']); // set default post title add_filter('default_title', [$this, 'presetPostTitle'], 10, 2); // set default post content add_filter('default_content', [$this, 'presetPostContent']); } /** * Plugin library settings * * @return void */ private function setup() { $this->library_settings = [ 'id' => $this->modal_id, 'title' => 'FB_LIBRARY', 'support_request_label' => 'FB_REQUEST_POPUP', 'categories' => $this->categories, 'plugin_dir' => FBOX_PLUGIN_DIR, 'plugin' => 'firebox', 'plugin_name' => firebox()->_('PLUGIN_NAME'), 'blank_template_label' => 'FB_BLANK_POPUP', 'blank_template_desc' => 'FPF_START_FROM_SCRATCH', 'noresults_create_from_scratch_label' => 'FB_CREATE_FROM_SCRATCH', 'template_use_url' => 'post-new.php?post_type=firebox&template=', 'license_type' => FBOX_LICENSE_TYPE == 'pro' ? 'pro' : 'free' ]; $this->setupAjax(); } /** * Set the default post title if we have selected a template via the Library * * @param string $post_title * @param object $post * * @return string */ public function presetPostTitle($post_title, $post) { $template = isset($_GET['template']) ? sanitize_text_field($_GET['template']) : ''; if ($template == 'blank') { return; } $box = \FireBox\Core\Helpers\BoxHelper::getBoxFromTemplate(); if (empty($box)) { return $post_title; } return $box->post_title; } /** * Sets the default post content if we have selected a template via the Library * * @param string * * @return string */ public function presetPostContent($content) { $template = isset($_GET['template']) ? sanitize_text_field($_GET['template']) : ''; if ($template == 'blank') { return; } $box = \FireBox\Core\Helpers\BoxHelper::getBoxFromTemplate(); if (empty($box)) { return $content; } return $box->post_content; } /** * Runs only on specific FireBox pages * * @return void */ public function validate() { $current_screen = get_current_screen(); $allowed_pages = [ 'toplevel_page_firebox', 'edit-firebox' ]; if (!in_array($current_screen->id, $allowed_pages)) { return false; } $this->run(); } /** * Runs the module * * @return void */ private function run() { // render custom actions add_action('fpframework/modal/' . $this->modal_id . '/header/prepend_actions', [$this, 'set_modal_actions']); // add custom footer links add_action('fpframework/library/' . $this->modal_id . '/footer/prepend_links', [$this, 'set_modal_footer_links']); $this->init(); } /** * Renders any other actions in the modal header * * @return void */ public function set_modal_actions() { ?>
  • _('FB_BLANK_POPUP')); ?>