Server IP : 104.21.38.3 / Your IP : 108.162.226.203 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/wwwroot/coircraft.com/wp-content/plugins/caldera-forms/classes/admin/ |
Upload File : |
<?php class Caldera_Forms_Admin_Page { /** * Name of dashicon for menu * * @since 1.7.0 * * @var string */ protected $assets; /** * Used to form menu slug `caldera-forms-$page_postfix` * * @since 1.7.0 * * @var string */ protected $page_postfix; /** * String to render in admin or callback function to create that string. * * @since 1.7.0 * * @var string|callable */ protected $render; /** * Name of dashicon for menu * * @since 1.7.0 * * @var string */ protected $menu_label; /** * Name of dashicon for menu * * @since 1.7.0 * * @var string */ protected $menu_icon; /** * Caldera_Forms_Admin_Page constructor. * * @since 1.7.0 * * @param string $page_postfix Used to form menu slug `caldera-forms-$page_postfix` * @param string $menu_label The label to use in the menu * @param string|callable $render String to render in admin or callback function to create that string. * @param array $assets List of handles for scripts and styles to enqueue. * @param null|string $menu_icon Name of dashicon for menu */ public function __construct($page_postfix, $menu_label, $render, array $assets = [], $menu_icon = null) { $this->page_postfix = $this->page_prefix() . $page_postfix; $this->menu_label = $menu_label; $this->menu_icon = !$menu_icon ? 'admin-page' : trim(str_replace('dashicons-', '', $menu_icon)); $this->assets = wp_parse_args($assets, [ 'script' => [], 'styles' => [] ]); $this->render = $render; } /** * Get the page prefix for this menu * * @since 1.7.0 * * @return string */ public function get_page_postfix() { return str_replace($this->page_prefix(), '', $this->page_postfix); } /** * Create admin page view * * @since 1.7.0 */ public function display() { $label = sprintf( '<span class="caldera-forms-menu-dashicon"><span class="dashicons dashicons-%s"></span>%s</span>', esc_attr($this->menu_icon), $this->menu_label); add_submenu_page( \Caldera_Forms::PLUGIN_SLUG, $this->menu_label, $label, 'manage_options', $this->page_postfix, [$this, 'render'] ); } /** * Render admin page view * * @since 1.7.0 */ public function render() { $this->enqueue_assets(); $handle = !empty($this->assets['scripts']) && isset($this->assets['scripts'][0]) ? $this->assets['scripts'][0] : 'admin'; caldera_forms_print_cf_forms_var($handle); wp_enqueue_script('wp-api-request'); Caldera_Forms_Admin_Assets::set_cf_admin(Caldera_Forms_Render_Assets::make_slug($handle)); if (is_callable($this->render)) { call_user_func($this->render); } else { echo $this->render; } /** * Runs after the HTML for an admin client is outputted * * @since 1.7.0 * * @param Caldera_Forms_Admin_Page $page */ do_action('caldera_forms_client_element_rendered', $this); } /** * Enqueue assets for this page * * @since 1.7.0 */ public function enqueue_assets() { Caldera_Forms_Render_Assets::maybe_register(); if (!empty($this->assets['scripts'])) { foreach ($this->assets['scripts'] as $handle) { Caldera_Forms_Render_Assets::enqueue_script($handle); } } if (!empty($this->assets['styles'])) { foreach ($this->assets['styles'] as $handle) { Caldera_Forms_Render_Assets::enqueue_style($handle); } } Caldera_Forms_Admin_Assets::enqueue_style('editor-grid'); Caldera_Forms_Admin_Assets::enqueue_style('admin'); } /** * @return string */ private function page_prefix() { return Caldera_Forms::PLUGIN_SLUG . '-'; } }