This commit is contained in:
2026-07-02 15:54:39 -06:00
commit 9883323161
17470 changed files with 4470592 additions and 0 deletions
@@ -0,0 +1,170 @@
<?php
class WLCMS_Admin_Core
{
private function asset_version($file) {
$path = WLCMS_ASSETS_DIR . $file;
return file_exists($path) ? (string) filemtime($path) : WLCMS_VERSION;
}
function __construct()
{
add_action('admin_menu', array($this, 'add_option_menu'));
add_action( 'admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
}
/**
* Add WLCMS to setting menu
*
* @return void
*/
public function add_option_menu()
{
$page = add_options_page(
__('White Label CMS', 'white-label-cms'), // Page title
__('White Label CMS', 'white-label-cms'), // Menu name
'manage_options', // Permissions
'wlcms-plugin.php', // Menu slug
array($this, 'view') // Function callback
);
add_action('load-' . $page, array($this, 'load'));
}
/**
* wlcms setting menu page is loaded
*
* @return void
*/
public function load()
{
if(!is_wlcms_super_admin()) {
wp_redirect(admin_url());
exit;
}
do_action("wlcms_load-page");
// Check if initial setup
if (!wlcms_field_setting('version') && !isset($_GET['view'])) {
wp_redirect(wlcms()->admin_url('wizard'));
exit;
}
// Register scripts
add_action("admin_enqueue_scripts", array($this, 'enqueue_scripts'));
//check store;
$this->store();
}
public function admin_enqueue_scripts()
{
$setting_js = 'js/admin.js';
wp_register_script(
'wlcms-admin',
WLCMS_ASSETS_URL . $setting_js,
array('jquery'),
$this->asset_version($setting_js)
);
wp_enqueue_script(['wlcms-admin']);
}
public function enqueue_scripts()
{
$setting_js = 'js/admin-settings.js';
wp_register_script(
'wlcms-admin-settings',
WLCMS_ASSETS_URL . $setting_js,
array('jquery', 'select2', 'wp-color-picker', 'jquery-validate'),
$this->asset_version($setting_js)
);
$jquery_validate = 'js/jquery.validatev1.19.5.min.js';
wp_register_script(
'jquery-validate',
WLCMS_ASSETS_URL . $jquery_validate,
array('jquery'),
$this->asset_version($jquery_validate)
);
$ays_before_js = 'js/ays-beforeunload-shim.js';
wp_register_script(
'ays-beforeunload-shim',
WLCMS_ASSETS_URL . $ays_before_js,
array('jquery'),
$this->asset_version($ays_before_js)
);
$areyousure_js = 'js/jquery-areyousure.js';
wp_register_script(
'jquery-areyousure',
WLCMS_ASSETS_URL . $areyousure_js,
array('jquery'),
$this->asset_version($areyousure_js)
);
$setting_css = 'css/admin-settings.css';
wp_register_style(
'wlcms-admin-settings',
WLCMS_ASSETS_URL . $setting_css,
array('select2', 'wp-color-picker'),
$this->asset_version($setting_css)
);
wp_register_style('select2', WLCMS_ASSETS_URL . 'css/select2.min.css');
wp_register_script('select2', WLCMS_ASSETS_URL . 'js/select2.min.js');
wp_enqueue_script(array('select2', 'wp-color-picker', 'ays-beforeunload-shim', 'jquery-areyousure', 'wlcms-admin-settings'));
wp_enqueue_style(array('select2', 'wp-color-picker', 'wlcms-admin-settings'));
wp_localize_script(
'wlcms-admin-settings',
'wlcms_settings',
array(
'loginurl' => site_url("/wp-login.php"),
'adminurl' => admin_url("index.php"),
'wlcms_ajax_nonce' => wp_create_nonce("wlcms_ajax_nonce")
)
);
}
private function store()
{
do_action('wlcms_save_before_validation');
if (!isset($_POST['wlcms-settings'])) {
return;
}
if (isset($_POST['wlcms-action']) && $_POST['wlcms-action'] == 'reset') {
return;
}
// nonce checking
if (!isset($_POST['wlcms-settings_nonce'])
|| !wp_verify_nonce($_POST['wlcms-settings_nonce'], 'wlcms-settings-action')) {
print 'Sorry, your nonce did not verify.';
exit;
}
wlcms()->Settings()->store();
return;
}
public function view()
{
$wlcms = wlcms();
$view = $wlcms->get_active_view();
$wlcms->admin_view($view);
}
}
@@ -0,0 +1,529 @@
<?php
class WLCMS_Admin_Dashboard extends WLCMS_Previewable
{
private $is_dashboard_all_hidden;
public function __construct()
{
//Check and set if it is a preview
$this->check_preview();
add_action('wp_dashboard_setup', array($this, 'dashboard_setup'), 999);
add_action("wp_ajax_hide_vum_dashboard", array($this, "hide_vum_dashboard"));
add_action("admin_init", array($this, "reset_welcome_dashboard"));
add_action("init", array($this, "init"));
}
public function init()
{
$welcome_panels = wlcms_field_setting('welcome_panel');
if (!$welcome_panels || !is_array($welcome_panels)) {
return;
}
if (!count($welcome_panels) === 0) {
return;
}
$pages = [];
foreach ($welcome_panels as $panel) {
if ($panel && is_array($panel) && isset($panel['template_type']) && $panel['template_type'] == 'page' && isset($panel['page_id_page'])) {
$pages[] = (int) $panel['page_id_page'];
}
}
if (count($pages) > 0) {
wlcms()->require_class("Welcome_Messages/Welcome_Messages_Page");
$template = new Welcome_Messages_Page();
$template->init($pages);
}
}
public function dashboard_setup()
{
$this->reset_dashboard_style();
$this->add_own_rss_panel();
$this->dashboard_title();
$this->set_welcome_metabox();
//Old version setting 2.0.2
if (!wlcms_field_setting('dashboard_role_stat')) {
if (is_wlcms_admin()) return;
} else {
$dashboard_widgets_visibility_roles = wlcms_esc_html_deep(wlcms_field_setting('dashboard_widgets_visibility_roles'));
if (!$dashboard_widgets_visibility_roles) return;
if (!$this->has_current_user_role($dashboard_widgets_visibility_roles))
return;
}
$this->set_dashboard_all_hidden();
$this->remove_metaboxes();
$this->remove_dashed_border();
}
private function reset_dashboard_style()
{
wlcms_set_css(
'.wlcms-welcome-panel .elementor div,
.wlcms-welcome-panel .elementor h1,
.wlcms-welcome-panel .elementor h2,
.wlcms-welcome-panel .elementor h3,
.wlcms-welcome-panel .elementor h4,
.wlcms-welcome-panel .elementor h5,
.wlcms-welcome-panel .fl-builder-content p,
.wlcms-welcome-panel p',
array(
'border' => '0',
'font-size' => '100%',
'font' => 'inherit',
'line-height' => 'inherit',
'vertical-align' => 'baseline',
'color' => 'unset'
)
);
wlcms_set_css(
'.wlcms-welcome-panel .welcome-panel-content > h2',
array(
'width' => '95%',
'padding' => '0 21px'
)
);
wlcms_set_css(
'.wlcms-welcome-panel .wlcms-welcome-content',
array(
'padding' => '20px'
)
);
wlcms_set_css(
'.wlcms-welcome-panel .welcome-panel-content',
array(
'max-width' => 'none!important',
'margin-left' => '0!important',
'justify-content' => 'flex-start',
'min-height' => 'auto'
)
);
wlcms_set_css(
'.wlcms-welcome-panel .elementor-section-full_width',
array(
'width' => '100%!important',
'left' => '0!important'
)
);
wlcms_set_css('.wlcms-welcome-panel', array(
'position' => 'relative',
"border" => "1px solid #c3c4c7",
"box-shadow" => "0 1px 1px rgb(0 0 0 / 4%)",
"background" => "#fff",
"font-size" => "13px",
"line-height" => "1.7",
"margin" => "16px 0"
));
wlcms_set_css('.wlcms-welcome-panel .welcome-panel-close:before', array(
"background" => "0 0",
"color" => "#787c82",
"content" => '"\f153"',
"display" => "block",
"font" => "normal 16px/20px dashicons",
"speak" => "never",
"height" => "20px",
"text-align" => "center",
"width" => "20px",
"-webkit-font-smoothing" => "antialiased",
"-moz-osx-font-smoothing" => "grayscale",
"position" => "absolute",
"top" => "8px",
"left" => "0",
"transition" => "all .1s ease-in-out",
));
wlcms_set_css('.wlcms-welcome-panel, .wlcms-welcome-panel .welcome-panel-content', array(
'padding' => '0!important',
));
wlcms_set_css('.wlcms-welcome-panel a', array(
"color" => "#2271b1",
));
wlcms_set_css(
'.wlcms-welcome-panel .welcome-panel-close',
array(
'top' => '0!important',
'right' => '0!important',
'background' => 'white!important',
'z-index' => '1000',
"position" => "absolute",
"top" => "0",
"right" => "0",
"padding" => "10px 15px 10px 24px",
"font-size" => "13px",
"line-height" => "1.23076923",
"text-decoration" => "none"
)
);
}
private function set_dashboard_all_hidden()
{
$this->is_dashboard_all_hidden = (bool) $this->get_settings('hide_all_dashboard_panels');
}
public function is_dashboard_all_hidden()
{
return $this->is_dashboard_all_hidden;
}
/**
* Change Dashboard H1 Title by using js
*
* @return void
*/
private function dashboard_title()
{
global $wp_version;
$dashboard_title = '';
if ($icon = $this->get_settings('dashboard_icon')) {
$dashboard_title .= '<span id=\"wlcms_dashboard_logo\"><img src=\"' . esc_url($icon) . '\" alt=\"\" /></span>';
wlcms_set_css('.index-php #wlcms_dashboard_logo img', array('vertical-align' => 'middle', 'padding-right' => '10px'));
}
if ($title = $this->get_settings('dashboard_title')) {
$dashboard_title .= '<span id=\"wlcms_dashboard_title\">' . esc_attr($title) . '</span>';
}
if (version_compare($wp_version, '3.8-beta', '>=')) {
wlcms_add_js('jQuery(".index-php #wpbody-content .wrap h1:eq(0)").html("' . $dashboard_title . '")');
return;
}
wlcms_add_js('jQuery("#icon-index").html("' . $dashboard_title . '")');
return;
}
/**
* Removed Wordpress Dashboard metaboxes if set to true
*
* @return void
*/
private function remove_metaboxes()
{
global $wp_meta_boxes;
$wlcms_widgets = wlcms_esc_html_deep($this->get_settings('dashboard_widgets'));
if (!(isset($wp_meta_boxes['dashboard']) && is_array($wp_meta_boxes['dashboard']))) {
return;
}
foreach ($wp_meta_boxes['dashboard'] as $section_key => $section) {
if (!is_array($section)) {
continue;
}
foreach ($section as $position_key => $position) {
if (!is_array($position)) {
continue;
}
foreach ($position as $widget_id => $widget) {
if ($this->is_wlcms_widget($widget_id)) {
continue;
} elseif (!$this->is_dashboard_all_hidden()) {
if ($wlcms_widgets && is_array($wlcms_widgets) && count($wlcms_widgets) > 0) {
if (!in_array($widget_id, $wlcms_widgets)) {
continue;
}
} else {
continue;
}
}
unset($wp_meta_boxes['dashboard'][$section_key][$position_key][$widget_id]);
}
}
}
}
private function is_wlcms_widget($dashboard_key = false)
{
if (!$dashboard_key) {
return false;
}
if (strpos($dashboard_key, 'custom_vum_widget') !== false) {
return true;
}
return in_array($dashboard_key, $this->excluded_widgets());
}
private function excluded_widgets()
{
return apply_filters('wlcms_exclude_dashboard_metaboxes', array('wlcms_rss_box'));
}
/**
* Add Own Welcome panel if set to true
*
* @return void
*/
private function set_welcome_metabox()
{
$user_id = get_current_user_id();
if ($user_id == 0) {
return false;
}
$welcome_panels = wlcms_field_setting('welcome_panel');
if (!$welcome_panels || !is_array($welcome_panels)) {
return;
}
if (!count($welcome_panels) === 0) {
return;
}
$admin_Dashboard_Welcome_Message = wlcms()->require_class("Admin_Dashboard_Welcome_Message");
$admin_Dashboard_Welcome_Message = new Admin_Dashboard_Welcome_Message();
foreach ($welcome_panels as $key => $welcome_panel) {
if (!$this->is_welcome_panel_visible($welcome_panel) || !is_array($welcome_panel)) {
continue;
}
$welcome_content_hidden = get_user_meta($user_id, 'vum_hide_dashboard' . $key, true);
if ($welcome_content_hidden && isset($welcome_panel['dismissible'])) {
continue;
}
$admin_Dashboard_Welcome_Message->set($welcome_panel, $key);
$admin_Dashboard_Welcome_Message->handle();
}
$admin_Dashboard_Welcome_Message->make_welcome_panel($welcome_panels);
wlcms_set_css('.index-php .wlcms-welcome-panel-content', array('margin' => '13px', 'padding-bottom' => '25px!important'));
}
private function is_welcome_panel_visible($setting)
{
if (!isset($setting['is_active'])) {
return false;
}
if ($setting['is_active'] != '1') {
return false;
}
if (
!isset($setting['visible_to'])
|| (isset($setting['visible_to']) && !$setting['visible_to'])
)
return false;
$roles = $setting['visible_to'];
return $this->has_current_user_role($roles);
}
private function has_current_user_role($roles)
{
$user_role = wlcms_current_user_roles();
return in_array($user_role, $roles);
}
/**
* Remove Dashboard Border Line if set to true
*
* @return void
*/
private function remove_dashed_border()
{
if (!$this->get_settings('remove_empty_dash_panel')) {
return;
}
wlcms_set_css('body.index-php #dashboard-widgets .postbox-container .empty-container', array('border' => '0', 'visibility' => 'hidden'));
}
/**
* Remove Wordpress Core News and Event if set to troe
*
* @return void
*/
public function remove_news_and_events()
{
if (!$this->get_settings('hide_news_and_events')) {
return;
}
remove_meta_box('dashboard_primary', 'dashboard', 'core');
wlcms_add_js(';jQuery("#community-events").remove();jQuery(".community-events-footer").remove();jQuery("#dashboard_primary h2 span").remove();');
}
/**
* Add RSS Dashboard Metabox
*
* @return void
*/
public function add_own_rss_panel()
{
if (!$this->get_settings('add_own_rss_panel')) {
return;
}
if (!$this->get_settings('rss_feed_address')) {
return;
}
$title = '';
$this->get_settings('rss_title');
if ($logo = $this->get_settings('rss_logo')) {
$title .= '<img src="' . esc_url($logo) . '" height="16" width="16" alt="Logo" style="padding-right:5px;vertical-align:bottom;"/> ';
}
if ($rss_title = $this->get_settings('rss_title')) {
$title .= $rss_title;
}
wp_add_dashboard_widget(
'wlcms_rss_box',
!empty($title) ? $title : '&nbsp;',
array($this, 'rss_box')
);
}
/**
* Display RSS Metabox to the dashboard
* called by wp_add_dashboard_widget
*
* @return void
*/
public function rss_box()
{
include_once(ABSPATH . WPINC . '/feed.php');
$num_items = $this->get_settings('rss_feed_number_of_item');
$introduction = $this->get_settings('rss_introduction');
$show_post_content = $this->get_settings('show_post_content');
$url = $this->get_settings('rss_feed_address');
if ($introduction) {
echo '<p>' . wp_kses_post($introduction) . '</p>';
}
$rss = fetch_feed($url);
if ($error = is_wp_error($rss)) {
echo '<div class="warning-text">' . esc_html($rss->get_error_message()) . '</div>';
wlcms_set_css(
'.index-php .warning-text',
array('color' => 'rgba(240, 116, 95, 0.808)', 'display' => 'block')
);
return;
}
$maxitems = $rss->get_item_quantity($num_items);
$rss_items = $rss->get_items(0, $maxitems);
if ($maxitems == 0) {
echo 'No items.';
return;
}
$rss_list = '<ul>';
foreach ($rss_items as $item) :
$rss_list .= sprintf(
'<li><strong><a href="%s" title="Posted %s" target="_blank">%s</a> </strong> <br />',
esc_url($item->get_permalink()),
$item->get_date('j F Y | g:i a'),
esc_html($item->get_title())
);
if ($show_post_content) :
$rss_list .= wp_kses_post($item->get_content());
endif;
$rss_list .= '</li>';
endforeach;
$rss_list .= '</ul>';
echo $rss_list;
}
public function hide_vum_dashboard()
{
if (!wp_verify_nonce($_REQUEST['nonce'], "vum_hide_dashboard_nonce")) {
exit("No naughty business please");
}
$user_id = get_current_user_id();
if ($user_id == 0) {
return false;
}
$key = sanitize_text_field($_POST['key']);
update_user_meta($user_id, 'vum_hide_dashboard' . $key, 1);
echo json_encode(array('type' => 'success'));
exit;
}
public function reset_welcome_dashboard()
{
if (!isset($_GET['wlcms-action'])) return;
if ($_GET['wlcms-action'] !== 'reset-welcome-dashboard') return;
if (!isset($_GET['dashboard'])) return;
if (!is_wlcms_super_admin()) return;
$key = sanitize_text_field($_GET['dashboard']);
delete_metadata('user', 0, 'vum_hide_dashboard' . $key, '', true);
WLCMS_Queue('Welcome dashboard message successfully reset.');
}
public function widgets()
{
global $wp_meta_boxes;
if (isset($wp_meta_boxes['dashboard']) && is_array($wp_meta_boxes['dashboard'])) {
return $wp_meta_boxes['dashboard'];
}
require_once ABSPATH . '/wp-admin/includes/dashboard.php';
set_current_screen('dashboard');
//remove wlcms hook
remove_action('wp_dashboard_setup', array($this, 'dashboard_setup'), 999);
wp_dashboard_setup();
//re-apply wlcms hook
add_action('wp_dashboard_setup', array($this, 'dashboard_setup'), 999);
set_current_screen(get_current_screen());
return $wp_meta_boxes['dashboard'];
}
}
@@ -0,0 +1,63 @@
<?php
class Admin_Dashboard_Welcome_Message
{
private $settings, $key;
public function set($settings, $key)
{
$this->settings = $settings;
$this->key = $key;
}
public function handle()
{
if ( !(isset($this->settings['template_type']) && $this->settings['template_type']) ) {
return;
}
$type = $this->settings['template_type'];
wlcms()->require_class("Welcome_Messages/Welcome_Messages_Elementor");
wlcms()->require_class("Welcome_Messages/Welcome_Messages_Html");
wlcms()->require_class("Welcome_Messages/Welcome_Messages_Beaver_Builder");
wlcms()->require_class("Welcome_Messages/Welcome_Messages_Page");
if( $type == 'Elementor' ){
$template = new Welcome_Messages_Elementor();
}elseif( $type == 'Beaver Builder' ){
$template = new Welcome_Messages_Beaver_Builder();
}elseif( $type == 'page' ){
$template = new Welcome_Messages_Page();
}else {
$template = new Welcome_Messages_Html();
}
$template->process($this->settings, $this->key);
}
public function make_welcome_panel()
{
$nonce = wp_create_nonce("vum_hide_dashboard_nonce");
$link = admin_url('admin-ajax.php');
$welcome = sprintf(";jQuery('.wlcms-welcome-panel a.welcome-panel-close').on('click', function(e){
e.preventDefault();
var vum_panel = jQuery(this).parent('.wlcms-welcome-panel');
jQuery.ajax({
type : 'post',
dataType : 'json',
url : '%s',
data : {action: 'hide_vum_dashboard', key : vum_panel.data('welcome_key'), nonce: '%s'},
success: function(response) {
if(response.type == 'success') {
vum_panel.hide();
}
}
})
});", $link, $nonce);
wlcms_add_js($welcome);
}
}
@@ -0,0 +1,669 @@
<?php
class WLCMS_Admin_Menus
{
private $admin_menus;
private $admin_bar_menus = array();
private $is_wlcms_admin = false;
private $admin_bar_menu_setting = false;
private $submenu_placeholder = '_wlcms_';
private $wlcms_admin_bar_menus_option = 'wlcms_admin_bar_menus';
private $hide_woo_home = false;
public function __construct()
{
add_action('init', array($this, 'set_wlcms_admin'), 10);
add_action('admin_init', array($this, 'admin_init'));
add_action('wlcms_save_addtional_settings', array($this, 'save'), 12, 1);
add_action('admin_menu', array($this, 'rebuild_user_admin_menu'), 9999999); // rebuild sidebar menu
add_action('wp_before_admin_bar_render', array($this, 'init_admin_bar_menu'), 9999999); // setup admin bar menu
}
public function admin_init()
{
$this->set_admin_bar_menu_setting();
$this->compile_menus();
}
public function set_wlcms_admin()
{
//Remove actions from preview mode
if (defined('DOING_AJAX') && DOING_AJAX) {
remove_action('admin_init', array($this, 'admin_init'));
remove_action('admin_init', array($this, 'rebuild_user_admin_menu'), 9999999);
return;
}
if (!is_user_logged_in()) {
return;
}
$wlcms_admin = wlcms_field_setting('wlcms_admin');
if (!$wlcms_admin) {
return;
}
//Check if the current user is editor and with legacy menu
if ($this->is_legacy_menu_role()) {
return;
}
$current_user = wp_get_current_user();
$this->is_wlcms_admin = in_array($current_user->ID, $wlcms_admin);
}
public function is_legacy_menu_role()
{
if (!wlcms_field_setting('legacy_menu')) {
return false;
}
$user = wp_get_current_user();
$role = (array)$user->roles;
if (!in_array('editor', $role, true)) {
return false;
}
return true;
}
/**
* check current user is wlcms admin or super admin
*
* @return boolean
*/
public function has_visible_roles()
{
if (is_multisite() && is_super_admin()) {
return true;
}
return $this->is_wlcms_admin();
}
public function enable_admin_menu()
{
return wlcms_field_setting('enable_wlcms_admin');
}
/**
* check current user is wlcms admin
*
*/
public function is_wlcms_admin()
{
return $this->is_wlcms_admin;
}
public function save($settings)
{
if (!isset($_POST['enable_wlcms_admin'])) {
$settings->remove('admin_menus');
$settings->remove('admin_bar_menus');
return;
}
$this->save_sidemenu($settings);
$this->save_admin_bar_menu($settings);
if (!isset($_POST['remove_legacy_menu'])) {
return;
}
$settings->remove('legacy_menu');
}
private function save_sidemenu($settings)
{
$menus = $this->get_admin_menus();
$db_menu_main = array();
$db_menu = array();
// No menu selected
if (!isset($_POST['admin_menus'])) {
$settings->remove('admin_menus');
return $settings;
}
$post_main_menu = isset($_POST['admin_menus']['main']) ? $_POST['admin_menus']['main'] : array();
$post_sub_menu = isset($_POST['admin_menus']['sub']) ? $_POST['admin_menus']['sub'] : array();
$sidebar_url = wlcms()->Branding()->sidebar_menu_url();
if (is_array($menus) && $menus > 0) :
foreach ($menus as $main_key => $main_menu) {
if ($main_key == $sidebar_url) {
continue;
}
if (!in_array($main_key, $post_main_menu)) {
$db_menu['main'][] = $main_key;
}
if (isset($main_menu['submenus']) && is_array($main_menu['submenus']) && count($main_menu['submenus'])) {
foreach ($main_menu['submenus'] as $sub_key => $submenu) {
if ($sub_key == $sidebar_url) {
continue;
}
$submenu_value = $submenu['slug'];
if (!in_array($submenu_value, $post_sub_menu)) {
$db_menu['sub'][] = $submenu_value;
}
}
}
}
endif;
if (count($db_menu)) {
$settings->set('admin_menus', $db_menu);
} else {
$settings->remove('admin_menus');
}
return $settings;
}
private function save_admin_bar_menu($settings)
{
$menus = get_option($this->wlcms_admin_bar_menus_option, array());
// No menu selected
if (!isset($_POST['admin_bar_menus'])) {
$settings->remove('admin_bar_menus');
return;
}
$post_menu = isset($_POST['admin_bar_menus']) ? $_POST['admin_bar_menus'] : array();
$db_menu = array();
if (is_array($menus) && $menus > 0) :
foreach ($menus as $menu_key => $menu) {
if (!in_array($menu_key, $post_menu)) {
$db_menu[] = $menu_key;
}
}
endif;
if (count($db_menu)) {
$settings->set('admin_bar_menus', $db_menu);
}
}
/**
* Re-organize sidebar menus
* Combine menu and submenu in single array
*
* @return void
*/
public function compile_menus()
{
global $menu, $submenu;
$output = array();
$sidebar_url = wlcms()->Branding()->sidebar_menu_url();
if (is_array($menu) && count($menu) > 0) {
foreach ($menu as $menu_item) {
if (!isset($menu_item[0], $menu_item[2])) {
continue;
}
// some menu items are seperators, skip them
if ($menu_item[0] == '') {
continue;
}
if ($menu_item[2] == $sidebar_url) {
continue;
}
$menu_name = preg_replace('#(<span.*?>).*?(</span>)#', '', $menu_item[0]);
$menu_key = $menu_item[2];
$output[$menu_key] = array(
'name' => $menu_name,
'slug' => $menu_item[2],
'submenus' => array()
);
}
}
if (is_array($submenu) && count($submenu) > 0) :
foreach ($submenu as $key => $submenu_item) {
$mainmenu_key = $key;
// If a submenu does not have a valid parent, skip
if (!isset($output[$mainmenu_key])) {
continue;
}
foreach ($submenu_item as $sm_info) {
$submenu_item = remove_query_arg('return', $sm_info[2]);
$submenu_key = sanitize_title($submenu_item);
$menu_name = '';
if (isset($sm_info[0]) && $sm_info[0] != '' && !is_null($sm_info[0])) {
$menu_name = preg_replace('#(<span.*?>).*?(</span>)#', '', $sm_info[0]);
}
$slug = $mainmenu_key . $this->get_submenu_placeholder() . $submenu_key;
$output[$key]['submenus'][$submenu_key] = array(
'name' => $menu_name,
'slug' => $slug
);
}
}
endif;
$this->admin_menus = $output;
}
/**
* Sibar Admin menu getter
*
* @return array
*/
public function get_admin_menus()
{
return $this->admin_menus;
}
/**
* remove sidebar menus that enable by wlcms
*
* @return void
*/
public function rebuild_user_admin_menu()
{
global $submenu;
if (!$this->enable_admin_menu() && !$this->is_legacy_menu_role()) {
return;
}
if ($this->has_visible_roles()) {
return;
}
$setting_admin_menus = wlcms_field_setting('admin_menus');
if (isset($setting_admin_menus['main']) && is_array($setting_admin_menus['main'])) {
foreach ($setting_admin_menus['main'] as $menu_item) {
$this->remove_menu_page($menu_item);
}
}
if (isset($setting_admin_menus['sub']) && is_array($setting_admin_menus['sub'])) {
foreach ($setting_admin_menus['sub'] as $submenu_item) {
$submenu_list = explode($this->get_submenu_placeholder(), $submenu_item);
$main_menu = $submenu_list[0];
$main_submenu = $submenu_list[1];
$this->remove_submenu_page($main_menu, $main_submenu);
}
$this->fix_woocommerce();
$this->fix_yoast($setting_admin_menus['sub']);
}
}
/**
* Get sidebar sub-menu
*
* @return array
*/
public function get_new_submenus($key)
{
return isset($this->admin_menus[$key]) ? $this->admin_menus[$key] : false;
}
/**
* Remove a top-level admin menu.
*
* @global array $menu
*
* @param string $menu_slug The slug of the menu.
* @return array|bool The removed menu on success, false if not found.
*/
public function remove_menu_page($menu_slug)
{
global $menu;
if (!is_array($menu)) {
return false;
}
foreach ($menu as $i => $item) {
$menu_item = remove_query_arg('return', $item[2]);
$menu_item = urldecode($menu_item);
if ($menu_slug == $menu_item) {
unset($menu[$i]);
return $item;
}
}
return false;
}
/**
* Remove an admin submenu.
*
* @global array $submenu
*
* @param string $menu_slug The slug for the parent menu.
* @param string $submenu_slug The slug of the submenu.
* @return array|bool The removed submenu on success, false if not found.
*/
function remove_submenu_page($menu_slug, $submenu_slug)
{
global $submenu;
if (!isset($submenu[$menu_slug]) || !is_array($submenu[$menu_slug]))
return false;
foreach ($submenu[$menu_slug] as $i => $item) {
$submenu_item = remove_query_arg('return', $item[2]);
$submenu_item = sanitize_title($submenu_item);
//Patch whitelist
if (in_array($submenu_slug, array('wc-admin'))) {
$this->hide_woo_home = true;
continue;
}
if ($submenu_slug == $submenu_item) {
unset($submenu[$menu_slug][$i]);
return $item;
}
}
return false;
}
public function fix_woocommerce()
{
global $submenu;
if (!isset($submenu) || !$this->hide_woo_home) {
return false;
}
if (!isset($submenu['woocommerce'])) {
return false;
}
$home = $submenu['woocommerce'][0];
$home[1] = 'manage_woocommerce';
unset($submenu['woocommerce'][0]);
$count = count($submenu['woocommerce']);
if ($count == 0) {
wlcms_set_hidden_css('li.toplevel_page_woocommerce');
}
$submenu['woocommerce'] = array_values($submenu['woocommerce']);
$home[0] = '';
$home[3] = '';
$submenu['woocommerce'][$count] = $home;
wlcms_set_hidden_css('li.toplevel_page_woocommerce li > a:empty');
}
public function fix_yoast($sub)
{
global $menu;
if (array_search('wpseo_dashboard_wlcms_wpseo_workouts', $sub) === false) {
return;
}
foreach ($menu as $key => $item) {
if ($item[2] == 'wpseo_workouts') {
unset($menu[$key]);
break;
}
}
}
public function init_admin_bar_menu()
{
$this->set_admin_bar_menu();
$this->buid_new_admin_bar_menu();
}
/**
* Prepare white label cms admin bar menu and build in multidimentional array
*
* @return void
*/
private function set_admin_bar_menu()
{
global $wp_admin_bar;
$nodes = $wp_admin_bar->get_nodes();
if (!$nodes || !is_array($nodes)) {
return;
}
// Admin menus is not set from action hoo admin_init
// Use for saving menus
if (is_admin()) {
$screen = get_current_screen();
if ($screen && $screen->id == WLCMS_SCREEN_ID) {
update_option($this->wlcms_admin_bar_menus_option, $nodes, false);
}
}
$wlcms_admin_bar = $this->_createMenuTree($nodes);
$this->admin_bar_menus = $wlcms_admin_bar;
}
/**
* Add all main menu
*
* @param object $flat
* @param integer $root
* @return array
*/
private function _createMenuTree($flat, $root = 0)
{
$parents = array();
$sub_root = array();
if (is_array($flat) && $flat > 0) :
foreach ($flat as $a) {
if ($this->excluded_admin_menu($a->id)) continue;
$menu_parent = ($a->parent == '') ? false : $a->parent;
$parents[$menu_parent][] = $a;
}
$sub_root = isset($parents[$root]) ? $parents[$root] : array();
endif;
return $this->_createMenuBranch($parents, $sub_root);
}
/**
* Add all sub menu to each main menu
*
* @param array $parents main menus
* @param object $children
* @return array
*/
private function _createMenuBranch(&$parents, $children)
{
$tree = array();
if (is_array($children) && $children > 0) :
foreach ($children as $child) {
if (isset($parents[$child->id])) {
$child->sub = $this->_createMenuBranch($parents, $parents[$child->id]);
}
$tree[] = $child;
}
endif;
return $tree;
}
/**
* check if the menu is listed from excluded items
*
* @param string $menu
* @return boolean
*/
private function excluded_admin_menu($menu = '')
{
$exclude = array('menu-toggle', 'wlcms-admin-logo', 'wp-logo');
return in_array($menu, $exclude);
}
/**
* Create admin bar menu base from the wlcms settings
*
* @return void
*/
private function buid_new_admin_bar_menu()
{
global $wp_admin_bar;
if ($this->has_visible_roles()) {
return;
}
$admin_bar_menu = wlcms_field_setting('admin_bar_menus');
if (!$admin_bar_menu || ($admin_bar_menu && !is_array($admin_bar_menu))) {
return;
}
if (!count($admin_bar_menu)) {
return;
}
$nodes = $wp_admin_bar->get_nodes();
if (is_array($nodes) && count($nodes) > 0) :
foreach ($nodes as $menu) {
if ($this->excluded_admin_menu($menu->id)) continue;
if (in_array($menu->id, $admin_bar_menu)) {
$wp_admin_bar->remove_menu($menu->id);
}
}
endif;
}
/**
* Getter of admin bar menus list
*
* @return void
*/
public function get_admin_bar_menus()
{
return $this->admin_bar_menus;
}
/**
* Change menu Title for wlcms settings
*
* @param object $menu
* @return string
*/
public function get_menu_title($menu)
{
if (!isset($menu->title)) {
return '';
}
$title = trim(wp_strip_all_tags($menu->title));
return ((!$title || empty($title)) ? '-' : $title) . ' <small>(' . $menu->id . ')</small>';
}
public function set_admin_bar_menu_setting()
{
$this->admin_bar_menu_setting = wlcms_field_setting('admin_bar_menus');
}
public function get_admin_bar_menu_setting()
{
return $this->admin_bar_menu_setting;
}
public function get_admin_bar_menu_html($menu, $depth = 0)
{
$out = '';
if (!is_array($menu) && $depth > 0) {
return $out;
}
$ul_class_wrapper = '';
if ($depth > 0) {
$out .= '<a href="javascript:void(0)" class="wlcms-toggle-arrow"></a>';
$ul_class_wrapper = ' class="sub_menu_wrapper"';
}
$out .= '<ul' . $ul_class_wrapper . '>';
$out .= '<input type="hidden" value="top-secondary" name="admin_bar_menus[]">
<input type="hidden" value="my-account" name="admin_bar_menus[]">
<input type="hidden" value="user-actions" name="admin_bar_menus[]">
<input type="hidden" value="logout" name="admin_bar_menus[]">
';
foreach ($menu as $menu_props) {
$menu_key = $menu_props->id;
$checked_sub = '';
$admin_bar_menu_setting = $this->get_admin_bar_menu_setting();
$checked_sub = ' checked="checked"';
if ($admin_bar_menu_setting && in_array($menu_key, $admin_bar_menu_setting)) {
$checked_sub = '';
}
$disabled = '';
if (in_array($menu_key, array('top-secondary', 'my-account', 'user-actions', 'logout'))) {
$disabled = ' disabled';
}
$sub_html = (isset($menu_props->sub)) ? $this->get_admin_bar_menu_html($menu_props->sub, ($depth + 1)) : '';
$out .= sprintf(
'
<li><input class="wlcms-toggle wlcms-toggle-light" id="admin_bar_menus_%1$s"%5$s name="admin_bar_menus[]" value="%1$s" type="checkbox" %2$s/>
<label class="wlcms-toggle-btn%5$s" for="admin_bar_menus_%1$s"></label><label class="toggle-label" for="admin_bar_menus_%1$s">%3$s</label>
%4$s
</li>
',
$menu_key,
$checked_sub,
$this->get_menu_title($menu_props),
$sub_html,
$disabled
);
}
$out .= '</ul>';
return $out;
}
public function get_submenu_placeholder()
{
return $this->submenu_placeholder;
}
}
@@ -0,0 +1,141 @@
<?php
class WLCMS_Admin_Script
{
private $css = array();
private $admin_css = '';
private $bulk_css = array();
private $hidded_elements = array();
private $js = array();
private $additional_css;
public function __construct()
{
add_action('admin_footer', array($this, 'footer_script'));
add_action('wp_footer', array($this, 'footer_script'), 99999);
add_action('in_admin_header', array($this, 'header_css'), 99999);
add_action('wp_head', array($this, 'header_css'), 99999);
}
public function header_css()
{
// no need to append scripts for guest users
if (!is_user_logged_in()) {
return;
}
$scripts = "<!-- WLCMS Style-->\n";
if (count($this->css) || count($this->hidded_elements) || count($this->bulk_css) || !empty($this->admin_css)) {
$scripts .= sprintf('<style type="text/css">%s</style>', $this->compiled_header_css());
}
$scripts .= "\n<!-- WLCMS End Style-->";
echo $scripts;
}
private function compiled_header_css()
{
$content = $this->admin_css . $this->compileCss() . $this->additional_css;
$content = wp_kses($content, array('\'', '\"'));
$content = str_replace('&gt;', '>', $content);
return $content;
}
public function footer_script()
{
$scripts = '';
// no need to append scripts for guest users
if (!is_user_logged_in()) {
return;
}
if (count($this->js)) {
$scripts .= '<script type="text/javascript">';
$scripts .= '/* <![CDATA[ */';
$scripts .= ' jQuery(document).ready(function() { ' . $this->compileJs() . ' });';
$scripts .= '/* ]]> */';
$scripts .= '</script>';
}
if (!empty($scripts)) {
$scripts = "<!-- WLCMS Scripts-->\n" . $scripts . "\n<!-- WLCMS End Scripts-->";
}
echo $scripts;
}
public function set_CssHidden($props)
{
$this->hidded_elements[] = $props;
}
public function setCss($element, $props = array())
{
$this->css[$element] = $props;
}
public function appendCss($css)
{
$this->bulk_css[] = $css;
}
private function _setHiddenCss()
{
$hidden = implode(',', $this->hidded_elements);
if (!empty($hidden)) {
$this->setCss($hidden, array('display' => 'none!important'));
}
}
private function _setBulkCss()
{
return implode('', $this->bulk_css);
}
public function appendJs($js)
{
$this->js[] = $js;
}
function compileJs()
{
return implode('', $this->js);
}
function appendAdminCss($admin_css)
{
$this->admin_css = $admin_css;
}
function compileCss()
{
$this->_setHiddenCss();
if (!count($this->css) && !$this->bulk_css) {
return;
}
$css_output = '';
foreach ($this->css as $element => $props) {
$css_output .= $element . '{';
foreach ($props as $prop => $value) {
$css_output .= $prop . ':' . $value . ';';
}
$css_output .= '}';
}
$css_output .= $this->_setBulkCss();
return $css_output;
}
public function additional_css($css)
{
$this->additional_css .= $css;
}
}
@@ -0,0 +1,165 @@
<?php
class WLCMS_Admin_Settings
{
public function __construct()
{
add_action('admin_menu', array($this, 'admin_menu'), 9999);
add_action('admin_init', array($this, 'init'), 9999);
add_filter('mce_css', array($this, 'custom_editor_stylesheet'));
add_action('admin_init', array($this, 'admin_init'));
add_action('init', array($this, 'remove_admin_bar'));
add_action("wp_ajax_wlcms_inital_search", [$this, "search_initial_pages"]);
add_action("wp_ajax_wlcms_search_pages", [$this, "search_pages"]);
}
public function admin_init()
{
$this->remove_nag_messages();
$this->remove_editor_wp_logo();
}
public function init()
{
$this->set_admin_css();
$this->hide_screen_options();
}
public function remove_editor_wp_logo()
{
if (!wlcms_field_setting('hide_wordpress_logo_and_links')) {
return;
}
$image = $this->get_editor_wp_logo();
wlcms_set_hidden_css('.edit-post-header .edit-post-fullscreen-mode-close svg');
wlcms_set_css('.editor-header__back-button:has(.wlcms_icon)', array('background' => '#000'));
wlcms_add_js(' var wlcms_change_back = setInterval(function() {if(jQuery(".edit-post-fullscreen-mode-close .wlcms_icon").length == 0 ){ jQuery(".edit-post-fullscreen-mode-close").html("' . $image . '");}if(jQuery(".edit-post-fullscreen-mode-close_site-icon").length > 0){jQuery(".edit-post-fullscreen-mode-close_site-icon").remove();}}, 1000);');
}
private function get_editor_wp_logo()
{
$gutenberg_exit_icon = wlcms_field_setting('gutenberg_exit_icon');
$admin_bar_logo = wlcms_field_setting('admin_bar_logo');
if ($gutenberg_exit_icon) {
$icon = "";
if ($gutenberg_exit_icon == 'admin-bar-logo') {
$icon = wlcms_field_setting('admin_bar_logo');
} elseif ($gutenberg_exit_icon == 'custom-icon') {
$icon = wlcms_field_setting('gutenberg_exit_custom_icon');
} else {
return '<span class=\"wlcms_icon dashicons dashicons-exit\"></span>';
}
return '<span id=\"wlcms_dashboard_logo\" class=\"wlcms_icon\"><img src=\"' . esc_url($icon) . '\" alt=\"\" /></span>';
}
if ($admin_bar_logo) {
return '<span id=\"wlcms_dashboard_logo\" class=\"wlcms_icon\"><img src=\"' . esc_url($admin_bar_logo) . '\" alt=\"\" /></span>';
}
return '<span class=\"wlcms_icon wlcms_dashboard_exitdashicons dashicons-exit\"></span>';
}
public function remove_admin_bar()
{
if (!wlcms_field_setting('hide_admin_bar_all')) {
return;
}
return $this->disable_admin_bar_menu();
}
private function disable_admin_bar_menu()
{
add_filter('show_admin_bar', '__return_false');
}
public function admin_menu()
{
if (!is_admin()) {
return;
}
}
public function hide_screen_options()
{
if (wlcms_field_setting('hide_screen_options')) {
add_filter('screen_options_show_screen', '__return_false');
}
}
private function set_admin_css()
{
if (wlcms_field_setting('hide_help_box')) {
wlcms_set_hidden_css("#contextual-help-link-wrap");
}
if (!$admin_style = wlcms_field_setting('settings_custom_css_admin')) {
return;
}
wlcms()->Admin_Script()->appendAdminCss($admin_style);
}
public function custom_editor_stylesheet($mce_css)
{
$mce_style = wlcms_field_setting('settings_custom_css_url');
if (!$mce_style) {
return $mce_css;
}
if (filter_var($mce_style, FILTER_VALIDATE_URL) === false) {
$mce_style = get_stylesheet_directory_uri() . '/' . $mce_style;
}
$mce_css .= ',' . esc_url($mce_style);
return $mce_css;
}
private function remove_nag_messages()
{
if (!wlcms_field_setting('hide_nag_messages')) {
return;
}
remove_action('admin_notices', 'update_nag', 3);
remove_action('admin_notices', 'maintenance_nag', 10);
remove_action('network_admin_notices', 'update_nag', 3);
}
public function wp_version_check()
{
remove_action('init', 'wp_version_check');
}
public function search_initial_pages()
{
$ids = [(int) $_GET['q']];
$data = wlcms_get_pages_by_ids($ids);
wp_send_json([
'initials' => reset($data)
]);
wp_die();
}
public function search_pages()
{
$q = isset($_GET['q']) ? $_GET['q'] : '';
wp_send_json([
'results' => wlcms_search_pages($q),
'pagination' => ['more' => false]
]);
wp_die();
}
}
@@ -0,0 +1,231 @@
<?php
class WLCMS_Branding extends WLCMS_Previewable
{
public function __construct()
{
//Check and set if it is a preview
$this->check_preview();
add_action('init', array($this, 'init'));
add_filter('admin_title', array($this, 'admin_title'), 10, 2);
add_action('admin_bar_menu', array($this, 'admin_bar_logo'));
add_action('admin_bar_menu', array($this, 'admin_bar_howdy_text'), 10000);
add_filter('admin_footer_text', array($this, 'admin_footer'), 2000);
add_action('admin_menu', array($this, 'admin_menu'), 0);
add_filter('admin_body_class', array($this, 'admin_body_class'), 12);
}
public function init()
{
if ($this->get_settings('hide_wp_version')) {
add_filter('update_footer', '__return_false', 11);
}
if ($this->get_settings('hide_wordpress_logo_and_links')) {
wlcms_set_hidden_css('#wp-admin-bar-wp-logo');
wlcms_set_hidden_css('#wpadminbar .quicklinks li .blavatar');
}
// Setup css for the admin bar logo
if ($this->get_settings('admin_bar_logo')) {
/**
* Create css for admin bar custom logo
*/
$css_args = array();
$css_args['vertical-align'] = 'middle!important';
//limit admin logo height
$css_args['max-height'] = '20px!important';
$css_args['margin'] = '0 auto';
$css_args['vertical-align'] = 'middle';
wlcms_set_css('.wlcms-admin-logo img', $css_args);
wlcms_set_css(
'.wlcms-admin-logo .ab-item, .wlcms-admin-logo a',
array(
'line-height' => '28px!important',
'display' => 'flex',
'align-items' => 'center'
)
);
wlcms_set_css('#footer-left img', array('vertical-align' => 'middle', 'max-height' => '50px', 'margin-right' => '5px'));
wlcms_set_css('#footer-left a', array('text-decoration' => 'none'));
}
}
public function admin_title($admin_title)
{
if ($custom_admin_title = esc_attr($this->get_settings('custom_page_title'))) {
$admin_title = str_replace(
"&#8212; WordPress",
"&#8212; " . $custom_admin_title,
$admin_title
);
}
return $admin_title;
}
public function admin_body_class($classes)
{
$classes = trim($classes) . ' ' . (!is_wlcms_admin() ? 'not-' : '') . 'wlcms-admin ';
return $classes;
}
public function admin_bar_logo($wp_admin_bar)
{
$admin_menu_bar_url = esc_url($this->get_settings('admin_bar_url'));
$admin_menu_bar_alt_text = esc_attr($this->get_settings('admin_bar_alt_text'));
$admin_menu_bar_image = esc_url($this->get_settings('admin_bar_logo'));
if (!$admin_menu_bar_image) {
return;
}
/**
* Add custom logo to the admin bar menu
*/
$args = array(
'id' => 'wlcms-admin-logo',
'href' => $admin_menu_bar_url,
'title' => sprintf('<img src="%s" alt="%s" />', $admin_menu_bar_image, $admin_menu_bar_alt_text),
'meta' => array('class' => 'wlcms-admin-logo', 'title' => $admin_menu_bar_alt_text, 'target' => '_blank')
);
$wp_admin_bar->add_node($args);
}
public function sidebar_menu_url()
{
if ($this->get_settings('use_developer_side_menu_image')) {
return esc_url($this->get_settings('developer_url'));
}
return esc_url($this->get_settings('side_menu_link_url'));
}
public function admin_menu()
{
global $menu;
$sidebar_url = esc_url($this->get_settings('side_menu_link_url'));
$sidebar_text = esc_attr($this->get_settings('side_menu_alt_text'));
$sidebar_image = esc_url($this->get_settings('side_menu_image'));
$collapsed_sidebar_image = esc_url($this->get_settings('collapsed_side_menu_image'));
if (!$sidebar_image) {
return;
}
$logo = sprintf('<img src=\"%s\" alt=\"%s\" class=\"large-side-bar-logo\" /><img src=\"%s\" alt=\"%s\" class=\"collapsed-side-bar-logo\" />', $sidebar_image, $sidebar_text, $collapsed_sidebar_image, $sidebar_text);
$target = '_self';
if ($sidebar_url) {
$domain = wp_parse_url($sidebar_url);
if (isset($domain['host'])) {
if (strpos($_SERVER['HTTP_HOST'], $domain['host']) === false) {
$target = '_blank';
}
}
}
if ($sidebar_url) {
$logo = sprintf('<a href=\"%s\" title=\"%s\" target=\"%s\">%s</a>', $sidebar_url, $sidebar_text, $target, $logo);
}
wlcms_set_css('.collapsed-side-bar-logo', array('display' => 'none', 'padding' => '5px', 'max-width' => '36px'));
wlcms_set_css('.folded .collapsed-side-bar-logo', array('display' => 'block', 'margin' => '0 auto', 'max-width' => '25px'));
wlcms_set_css('.large-side-bar-logo', array('display' => 'block', 'max-width' => '150px', 'margin' => '0 auto', 'padding' => '5px'));
wlcms_set_css('.folded .large-side-bar-logo', array('display' => 'none'));
wlcms_add_js(sprintf('jQuery("#adminmenuwrap").prepend("<span class=\"wlcms-logo\">%s</span>");', $logo));
wlcms()->Admin_Script()->additional_css('
@media only screen and (max-width: 960px) {
.wlcms-logo .large-side-bar-logo{
display:none;
}
.wlcms-logo .collapsed-side-bar-logo{
display:block;
}
}');
}
public function admin_bar_howdy_text($wp_admin_bar)
{
$admin_bar_howdy_text = esc_attr($this->get_settings('admin_bar_howdy_text'));
if (!$admin_bar_howdy_text) {
return;
}
$account_node = $wp_admin_bar->get_node('my-account');
if (!isset($account_node->title)) {
return;
}
$wp_admin_bar->add_node(array(
'id' => 'my-account',
'title' =>
str_replace(
str_replace(', %s', ',', __( 'Howdy, %s' )),
$admin_bar_howdy_text, $account_node->title
),
));
}
/**
* Use custom footer
*
* @return mixed
*/
public function admin_footer($original_text)
{
$footer_html = wp_kses_post($this->get_settings('footer_html'));
$footer_url = esc_url($this->get_settings('footer_url'));
$footer_text = esc_attr($this->get_settings('footer_text'));
$footer_image = esc_url($this->get_settings('footer_image'));
$developer_name = esc_attr($this->get_settings('developer_name'));
if ($footer_html) {
return $footer_html;
}
$footer_main_text = "";
if ($footer_image) {
$footer_main_text .= '<img src="' . $footer_image . '" alt="" /> ';
}
if ($footer_text) {
$footer_main_text .= $footer_text;
}
if (empty($footer_main_text)) {
if (wlcms_field_setting('hide_wordpress_logo_and_links')) {
return '';
}
return $original_text;
}
if (!$footer_url) {
return $footer_main_text;
}
$footer_html = '<a href="' . $footer_url . '" title="' . $developer_name . '" target="_blank">' . $footer_main_text . '</a>';
return $footer_html;
}
}
@@ -0,0 +1,30 @@
<?php
/**
* Define the internationalization functionality
*
* Loads and defines the internationalization files for this plugin
* so that it is ready for translation.
*/
class WLCMS_I18n
{
function __construct()
{
add_action('init', array($this, 'load_textdomain'));
}
public function load_textdomain()
{
$domain = 'white-label-cms';
$plugin_rel_path = $domain . '/languages/';
load_plugin_textdomain(
$domain,
false,
$plugin_rel_path
);
}
}
new WLCMS_I18n();
@@ -0,0 +1,177 @@
<?php
class WLCMS_Loader
{
const CLASS_DIR = 'includes/classes/';
const VIEW_DIR = 'view/';
private $admin_core_class;
private $wizard_class;
private $admin_menus_class;
private $settings_class;
private $login_class;
private $branding_class;
private $admin_script_class;
private $admin_dashboard_class;
private $admin_settings_class;
private $upgrade_class;
private $admin_url;
private static $_instance; //The single instance
function __construct()
{
$this->loadClasses();
}
public static function getInstance()
{
if (!self::$_instance) { // If no instance then make one
self::$_instance = new self();
}
return self::$_instance;
}
private function loadClasses()
{
$this->require_class('Messages');
$this->require_class('Previewable');
$this->require_class('Admin_Core');
$this->admin_core_class = new WLCMS_Admin_Core();
$this->require_class('Wizard');
$this->wizard_class = new WLCMS_Wizard();
$this->require_class('Admin_Script');
$this->admin_script_class = new WLCMS_Admin_Script();
$this->require_class('Settings');
$this->settings_class = new WLCMS_Settings();
$this->require_class('Upgrade');
$this->upgrade_class = new WLCMS_Upgrades();
$this->require_class('Admin_Menus');
$this->admin_menus_class = new WLCMS_Admin_Menus();
$this->require_class('Login');
$this->login_class = new WLCMS_Login();
$this->require_class('Branding');
$this->branding_class = new WLCMS_Branding();
$this->require_class('Admin_Dashboard');
$this->admin_dashboard_class = new WLCMS_Admin_Dashboard();
$this->require_class('Admin_Settings');
$this->admin_settings_class = new WLCMS_Admin_Settings();
}
public function Admin_Core()
{
return $this->admin_core_class;
}
public function Wizard()
{
return $this->wizard_class;
}
public function Settings()
{
return $this->settings_class;
}
public function Upgrade()
{
return $this->upgrade_class;
}
public function Admin_Dashboard()
{
return $this->admin_dashboard_class;
}
public function Admin_Menus()
{
return $this->admin_menus_class;
}
public function Login()
{
return $this->login_class;
}
public function Branding()
{
return $this->branding_class;
}
public function Admin_Script()
{
return $this->admin_script_class;
}
public function Admin_Settings()
{
return $this->admin_settings_class;
}
public function require_class($file = "")
{
return $this->required(self::CLASS_DIR . $file);
}
public function admin_url($view = 'settings')
{
return admin_url('options-general.php?page=wlcms-plugin.php&view=' . $view);
}
public function required($file = "")
{
$dir = WLCMS_DIR;
if (empty($dir) || !is_dir($dir)) {
return false;
}
$file = path_join($dir, $file . '.php');
if (!file_exists($file)) {
return false;
}
require_once $file;
}
public function get_view($file = "")
{
$this->required(self::VIEW_DIR . $file);
}
public function admin_view($file = "")
{
$this->get_view('admin/' . $file);
}
public function get_active_view()
{
$default = 'settings';
if (!isset($_GET['view'])) {
return $default;
}
$available = array('wizard', 'settings');
$view = wp_filter_kses($_GET['view']);
return (in_array($view, $available)) ? $view : $default;
}
}
@@ -0,0 +1,359 @@
<?php
class WLCMS_Login extends WLCMS_Previewable
{
public function __construct()
{
//Check and set if it is a preview
$this->check_preview();
add_action('login_footer', array($this, 'scripts'), 1000);
add_action('init', array($this, 'preview_init'));
add_action('wlcms_before_save_preview', array($this, 'save_preview_login'), 10, 2);
add_action('wlcms_save_addtional_settings', array($this, 'save_preview_login'), 10, 2);
// Save the preview settings
add_action('wp_ajax_wlcms_save_login_preview_settings', array($this, 'store_preview'));
add_filter('wlcms_setting_fields', array($this, 'setting_fields'), 11, 1);
}
public function preview_init()
{
if (!isset($_GET['wlcms-action'])) {
return;
}
if ($_GET['wlcms-action'] != 'preview') {
return;
}
if (current_user_can('manage_options')) {
return;
}
wp_die(__('Sorry, you are not allowed to do this action.'));
}
public function save_preview_login($setting, $placeholder)
{
// ignore if it has width or height request
if (isset($_REQUEST['logo_width']) || isset($_REQUEST['logo_height']))
return;
$logo = esc_url($setting->get($placeholder . 'login_logo'));
if ($logo) {
$imagesize = @getimagesize($logo);
if ($imagesize) {
list($width, $height) = $imagesize;
$setting->set($placeholder . 'logo_width', $width);
$setting->set($placeholder . 'logo_height', $height);
}
}
return $setting;
}
public function scripts()
{
wp_print_scripts(array('jquery'));
echo '<script>';
echo 'jQuery(document).ready(function(){';
echo $this->set_custom_login_js();
echo $this->get_js();
echo '});';
echo '</script>';
echo '<style type="text/css">';
echo $this->compiled_login_css();
echo '</style>';
}
private function compiled_login_css()
{
$content = $this->set_custom_css();
$content .= $this->set_background_css();
$content .= $this->set_logo_css();
$content .= $this->set_form_css();
$content .= $this->set_links_css();
$content = wp_kses($content, array('\'', '\"'));
$content = str_replace('&gt;', '>', $content);
return $content;
}
private function get_js()
{
$js = 'jQuery("#login").wrap("<div id=\'wlcms-login-wrapper\'></div>");';
if ($this->get_db_setting('login_logo')) {
$js .= ';jQuery(\'#login h1 a\').attr(\'title\',\'' . get_bloginfo('name') . '\');jQuery(\'#login h1 a\').attr(\'href\',\'' . get_bloginfo('url') . '\');';
}
return $js;
}
private function set_logo_css()
{
$logo_css = '#login h1 a, .login h1 a { ';
if ($login_logo = $this->get_db_setting('login_logo')) {
$logo_css .= 'background-image: url(' . esc_url($login_logo) . ')!important;';
}
$has_width = false;
if ($logo_width = $this->get_db_setting('logo_width')) {
$logo_css .= 'width:' . wlcms_css_metrics(esc_attr($logo_width)) . '!important;';
$has_width = true;
} else {
$logo_css .= 'width:auto!important;';
}
// Add logo max-width same width with the form
$logo_css .= 'max-width:100%;';
$has_height = false;
if ($logo_height = $this->get_db_setting('logo_height')) {
$has_height = true;
$logo_css .= 'height:' . wlcms_css_metrics(esc_attr($logo_height)) . ';';
}
//Add logo background size
$logo_css_background_size = 'background-size:contain;background-position-y: center;';
if ($has_height && $has_width) {
$logo_css_background_size = sprintf('background-size:%s %s;', wlcms_css_metrics($logo_width), wlcms_css_metrics(esc_attr($logo_height)));
}
$logo_css .= $logo_css_background_size;
if ($logo_bottom_margin = $this->get_db_setting('logo_bottom_margin')) {
$logo_css .= 'margin-bottom: ' . esc_attr($logo_bottom_margin) . 'px!important;';
}
$logo_css .= '}'; // close #login h1 a, .login h1 a
if ($retina_login_logo = $this->get_db_setting('retina_login_logo')) {
$logo_css .= '@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
#login h1 a, .login h1 a { background-image: url(' . esc_url($retina_login_logo) . ')!important;}
}';
}
return $logo_css;
}
private function set_background_css()
{
$body_login = 'body.login{';
if ($this->get_db_setting('full_screen_background_image')) {
$body_login .= '-webkit-background-size: cover !important;';
$body_login .= '-moz-background-size: cover !important;';
$body_login .= '-o-background-size: cover !important;';
$body_login .= 'background-size: cover !important;';
}
if ($background_color = $this->get_db_setting('background_color')) {
$body_login .= 'background-color:' . esc_attr($background_color) . '!important;';
}
if ($background_image = $this->get_db_setting('background_image')) {
$body_login .= 'background-image: url(' . esc_url($background_image) . ')!important;';
}
if ($background_positions = $this->get_db_setting('background_positions')) {
$body_login .= 'background-position:' . esc_attr($background_positions) . '!important;';
}
if ($background_repeat = $this->get_db_setting('background_repeat')) {
$body_login .= 'background-repeat:' . esc_attr($background_repeat) . '!important;';
}
$body_login .= '}';
return $body_login;
}
private function set_form_css()
{
$form_css = '';
if ($form_label_color = $this->get_db_setting('form_label_color')) {
$form_css .= '#loginform label{ color:' . esc_attr($form_label_color) . '}';
}
if ($form_background_color = $this->get_db_setting('form_background_color')) {
$form_css .= '#loginform{ background-color:' . esc_attr($form_background_color) . '}';
}
/**
* Submit Button css
*/
$form_button_text_color = esc_attr($this->get_db_setting('form_button_text_color'));
$form_button_color = esc_attr($this->get_db_setting('form_button_color'));
if ($form_button_text_color || $form_button_color) {
$form_css .= '#loginform input[type=submit],#loginform .submit input[type=button]{ ';
if ($form_button_text_color) {
$form_css .= 'color:' . $form_button_text_color . '!important;';
$form_css .= 'text-shadow: none;';
$form_css .= 'border-color: none;';
$form_css .= 'box-shadow: none;';
}
if ($form_button_color) {
$form_css .= 'background-color:' . $form_button_color . '!important; border: 0;box-shadow:none';
}
$form_css .= '}';
}
/**
* Submit Button Hover
*/
$form_button_text_hover_color = esc_attr($this->get_db_setting('form_button_text_hover_color'));
$form_button_hover_color = esc_attr($this->get_db_setting('form_button_hover_color'));
if ($form_button_hover_color || $form_button_text_hover_color) {
$form_css .= '#loginform input[type=submit]:hover,#loginform .submit input[type=button]:hover{ ';
if ($form_button_text_hover_color) {
$form_css .= 'color:' . $form_button_text_hover_color . '!important;';
}
if ($form_button_hover_color) {
$form_css .= 'background-color:' . $form_button_hover_color . '!important;';
}
$form_css .= '}';
}
return $form_css;
}
private function set_links_css()
{
$form_css = '';
if ($this->get_db_setting('hide_register_lost_password')) {
$form_css .= 'p#nav{display:none;}';
}
if ($this->get_db_setting('hide_back_to_link')) {
$form_css .= 'p#backtoblog{display:none;}';
}
if ($back_to_register_link_color = esc_attr($this->get_db_setting('back_to_register_link_color'))) {
$form_css .= 'p#backtoblog a, p#nav a{color:' . $back_to_register_link_color . '!important;}';
}
if ($back_to_register_link_hover_color = esc_attr($this->get_db_setting('back_to_register_link_hover_color'))) {
$form_css .= 'p#backtoblog a:hover, p#nav a:hover{color:' . $back_to_register_link_hover_color . '!important;}';
}
if ($privacy_policy_link_color = esc_attr($this->get_db_setting('privacy_policy_link_color'))) {
$form_css .= 'a.privacy-policy-link{color:' . $privacy_policy_link_color . '!important;text-decoration:none}';
}
if ($privacy_policy_link_hover_color = esc_attr($this->get_db_setting('privacy_policy_link_hover_color'))) {
$form_css .= 'a.privacy-policy-link:hover{color:' . $privacy_policy_link_hover_color . '!important;}';
}
return $form_css;
}
private function set_custom_css()
{
$content = $this->get_db_setting('login_custom_css');
$content = wp_kses($content, array('\'', '\"'));
$content = str_replace('&gt;', '>', $content);
return $content;
}
private function set_custom_login_js()
{
return wlcms_esc_html_e($this->get_db_setting('login_custom_js'));
}
public function settings()
{
if ($this->saving_preview_section() == 'wizard') {
return $this->wizard_settings();
}
return $this->complete_settings();
}
/**
* Settings to be stored in preview mode
*
* @return array
*/
private function wizard_settings()
{
$settings = array(
'login_logo' => '',
'add_retina_logo' => false,
'retina_login_logo' => '',
);
return $settings;
}
/**
* Settings to be included to the overall setting
* it includes fields from preview mode
* @return void
*/
public function complete_settings()
{
$settings = array(
'logo_bottom_margin' => 0,
'logo_width' => false,
'logo_height' => false,
'background_color' => '#ffffff',
'background_image' => '',
'full_screen_background_image' => false,
'background_positions' => 'center center',
'background_repeat' => 'no-repeat',
'hide_register_lost_password' => false,
'hide_back_to_link' => false,
'form_background_color' => '',
'form_label_color' => '',
'form_button_color' => '',
'form_button_text_color' => '',
'form_button_hover_color' => '',
'form_button_text_hover_color' => '',
'back_to_register_link_color' => '',
'back_to_register_link_hover_color' => '',
'privacy_policy_link_color' => '',
'privacy_policy_link_hover_color' => '',
'login_custom_css' => '',
'login_custom_js' => ''
);
return array_merge($settings, $this->wizard_settings());
}
public function saving_preview_section()
{
$sections = array('wizard', 'settings');
if (!isset($_REQUEST['form_section'])) {
return;
}
if (!in_array($_REQUEST['form_section'], $sections)) {
return;
}
return wp_filter_kses($_REQUEST['form_section']);
}
public function setting_fields($settings)
{
return array_merge($settings, $this->complete_settings());
}
}
@@ -0,0 +1,55 @@
<?php
class WLCMS_Messages
{
public static function queue($message, $class = '')
{
$default_allowed_classes = array('error', 'warning', 'success', 'info');
$allowed_classes = apply_filters('wlcms_messages_allowed_classes', $default_allowed_classes);
$default_class = apply_filters('wlcms_messages_default_class', 'success');
if (!in_array($class, $allowed_classes)) {
$class = $default_class;
}
$messages = maybe_unserialize(get_option('_wlcms_messages', array()));
$messages[$class][] = $message;
update_option('_wlcms_messages', $messages);
}
public static function show()
{
$group_messages = maybe_unserialize(get_option('_wlcms_messages'));
if (!$group_messages) {
return;
}
$errors = "";
if (is_array($group_messages)) {
foreach ($group_messages as $class => $messages) {
$errors .= '<div class="notice notice-' . $class . ' is-dismissible"">';
$prev_message = '';
foreach ($messages as $message) {
if ($prev_message != $message)
$errors .= '<p>' . $message . '</p>';
$prev_message = $message;
}
$errors .= '</div>';
}
}
delete_option('_wlcms_messages');
echo $errors;
}
}
if (class_exists('WLCMS_Messages') && !function_exists('WLCMS_Queue')) {
function WLCMS_Queue($message, $class = null)
{
WLCMS_Messages::queue($message, $class);
}
}
add_action('admin_notices', array('WLCMS_Messages', 'show'));
@@ -0,0 +1,80 @@
<?php
class WLCMS_Previewable
{
public $is_preview = false;
public $preview_setting_key_placeholder = '_';
public $preview_section;
public function check_preview()
{
if (!isset($_GET['wlcms-action'])) {
return;
}
if ($_GET['wlcms-action'] != 'preview') {
return;
}
$this->is_preview = true;
$this->preview_section = isset($_GET['preview_section']) ? wp_filter_kses($_GET['preview_section']) : '';
}
public function place_holder()
{
return ($this->is_preview) ? $this->preview_setting_key_placeholder : '';
}
public function get_placeholder_key()
{
return $this->preview_setting_key_placeholder;
}
public function store_preview()
{
check_ajax_referer('wlcms_ajax_nonce');
$settings = wlcms()->Settings();
foreach ($this->settings() as $key => $default) {
$setting_value = (isset($_POST[$key])) ? wlcms_kses($_POST[$key]) : $default;
$settings->set($this->preview_setting_key_placeholder . $key, $setting_value);
}
do_action('wlcms_before_save_preview', $settings, $this->preview_setting_key_placeholder);
$settings->save();
exit;
}
public function preview_section()
{
return $this->preview_section;
}
public function settings()
{
return [];
}
public function get_settings($key)
{
return $this->get_db_setting($key);
}
public function setting_key($key)
{
if ($this->is_preview) {
$key = $this->preview_setting_key_placeholder . $key;
}
return $key;
}
public function get_db_setting($key)
{
return wlcms_db_field_setting($this->setting_key($key));
}
}
@@ -0,0 +1,388 @@
<?php
class WLCMS_Settings
{
private $settings;
function __construct()
{
$this->init_settings();
add_filter('wp_kses_allowed_html', array($this, 'kses_allowed_html'), 10, 2);
add_action('admin_init', array($this, 'init'));
add_filter('plugin_action_links', array($this, 'plugin_settings'), 10, 2);
add_action('wlcms_after_body', array($this, 'add_import_html'));
}
public function init()
{
// check or initiate import
$this->import();
if (!isset($_GET['wlcms-action'])) {
return;
}
// check or initiate reset
$this->reset_plugin();
// check or initiate export
$this->export();
}
public function plugin_settings($links, $file)
{
if (WLCMS_BASENAME == $file) {
// Add your custom link
$custom_link = '<a href="' . admin_url('options-general.php?page=wlcms-plugin.php&wlcms-action=reset&_wlcms_anonce=' . wp_create_nonce('wlcms-action-nonce')) . '"onclick="return confirm(\'Are you sure you want to reset?\')">Reset</a>';
// Insert the custom link at the beginning of the array
array_unshift($links, $custom_link);
}
return $links;
}
public function kses_allowed_html($tags, $context)
{
if ('post' === $context) {
$tags['iframe'] = array(
'align' => true,
'width' => true,
'height' => true,
'frameborder' => true,
'name' => true,
'src' => true,
'id' => true,
'class' => true,
'style' => true,
'scrolling' => true,
'marginwidth' => true,
'marginheight' => true,
'allowfullscreen' => true,
'mozallowfullscreen' => true,
'webkitallowfullscreen' => true,
);
$tags['embed'] = array(
'src' => true,
'height' => true,
'width' => true,
'style' => true,
'type' => true,
);
}
return $tags;
}
public function get($key = "", $default = false)
{
if (!isset($this->settings[$key])) {
return $default;
}
$value = wlcms_removeslashes($this->settings[$key]);
if (empty($value) || is_null($value)) {
return false;
}
if (is_array($value) && count($value) == 0) {
return false;
}
return $value;
}
public function reset()
{
$this->settings = array();
}
public function setAll($value)
{
$this->settings = $value;
}
public function getAll()
{
return $this->settings;
}
public function set($key, $value)
{
$this->settings[$key] = $value;
}
public function remove($key)
{
if (isset($this->settings[$key])) {
unset($this->settings[$key]);
}
}
public function save()
{
update_option("wlcms_options", $this->settings);
}
public function store()
{
do_action('wlcms_before_saving', $this);
$this->reset();
$this->set('version', WLCMS_VERSION);
foreach ($this->keys() as $key) {
$setting_value = '';
if (isset($_POST[$key])) {
$setting_value = wlcms_kses($_POST[$key]);
}
$this->set($key, $setting_value);
}
$placeholder = ''; // use the same method used by preview wizard
do_action('wlcms_save_addtional_settings', $this, $placeholder);
$this->save();
do_action('wlcms_after_saving', $this);
WLCMS_Queue('Settings saved.');
wp_redirect(wlcms()->admin_url());
exit;
}
public function init_settings()
{
$settings = get_option("wlcms_options", false);
if (!$settings) {
$settings = $this->default_options();
}
$this->settings = $settings;
}
public function add_import_html()
{
wlcms()->admin_view('parts/import-settings');
}
public function import()
{
if (!is_wlcms_super_admin()) {
return;
}
if (!isset($_POST['wlcms-settings_nonce'])) return;
if (!is_admin() && !current_user_can('manage_options')) {
return;
}
if (!isset($_POST['wlcms-settings']) && !isset($_FILES['import_file'])) {
return;
}
if (!isset($_FILES['import_file'])) {
return;
}
if ($_FILES['import_file']['size'] == 0 && $_FILES['import_file']['name'] == '') {
return;
}
// check nonce
if (!wp_verify_nonce($_POST['wlcms-settings_nonce'], 'wlcms-settings-action')) {
WLCMS_Queue('Sorry, your nonce did not verify.', 'error');
wp_redirect(wlcms()->admin_url());
exit;
}
$import_field = 'import_file';
$temp_file_raw = $_FILES[$import_field]['tmp_name'];
$temp_file = esc_attr($temp_file_raw);
$arr_file_type = $_FILES[$import_field];
$uploaded_file_type = $arr_file_type['type'];
$allowed_file_types = array('application/json');
if (!in_array($uploaded_file_type, $allowed_file_types)) {
WLCMS_Queue('Upload a valid .json file.', 'error');
wp_redirect(wlcms()->admin_url());
exit;
}
$settings = (array)json_decode(
file_get_contents($temp_file),
true
);
unlink($temp_file);
if (!$settings) {
WLCMS_Queue('Nothing to import, please check your json file format.', 'error');
wp_redirect(wlcms()->admin_url());
exit;
}
// Validate the JSON schema: only accept keys the plugin actually
// recognises so arbitrary options cannot be injected via import.
$allowed_keys = array_merge($this->keys(), array('version'));
$settings = array_intersect_key($settings, array_flip($allowed_keys));
// Sanitize imported values the same way the regular save path does
// (see store()), so untrusted JSON cannot smuggle in unescaped markup.
$settings = wlcms_kses($settings);
$this->setAll($settings);
$this->save();
WLCMS_Queue('Your Import has been completed.');
wp_redirect(wlcms()->admin_url());
exit;
}
public function export()
{
if (!is_wlcms_super_admin()) {
return;
}
if (!isset($_GET['wlcms-action']) || (isset($_GET['wlcms-action']) && $_GET['wlcms-action'] != 'export')) {
return;
}
if (!wp_verify_nonce($_REQUEST['_wlcms_anonce'], 'wlcms-action-nonce')) {
WLCMS_Queue('Sorry, your nonce did not verify.', 'error');
wp_redirect(wlcms()->admin_url());
exit;
}
$settings = $this->getAll();
if (!is_array($settings)) {
$settings = array();
}
$settings = json_encode($settings);
header('Content-disposition: attachment; filename=wlcms-settings.json');
header('Content-type: application/json');
echo $settings;
exit;
}
public function reset_plugin()
{
global $wpdb;
if (!current_user_can('install_plugins')) {
return false;
}
if ($_GET['wlcms-action'] != 'reset') {
return;
}
if (!wp_verify_nonce($_REQUEST['_wlcms_anonce'], 'wlcms-action-nonce')) {
WLCMS_Queue('Sorry, your nonce did not verify.', 'error');
wp_redirect(admin_url());
exit;
}
delete_option("wlcms_options");
$wpdb->get_results($wpdb->prepare("DELETE FROM $wpdb->options WHERE option_name LIKE %s", 'wlcms_o_%'));
WLCMS_Queue('Settings reset.');
wp_redirect(wlcms()->admin_url());
exit;
}
public function keys()
{
return array_keys($this->default_options());
}
public function get_default_option($key)
{
$settings = $this->default_options();
return isset($settings[$key]) ? $settings[$key] : null;
}
public function default_options()
{
$settings = array(
'developer_icon' => '',
'use_developer_icon_footer' => 1,
'developer_icon_footer_url' => '',
'developer_side_menu_image' => '',
'developer_icon_admin_bar' => false,
'developer_branding_footer' => false,
'use_developer_side_menu_image' => false,
'hide_wordpress_logo_and_links' => false,
'hide_wp_version' => false,
'admin_bar_logo' => '',
'admin_bar_logo_width' => 15,
'admin_bar_alt_text' => '',
'admin_bar_howdy_text' => '',
'admin_bar_url' => '',
'side_menu_image' => '',
'collapsed_side_menu_image' => '',
'side_menu_link_url' => '',
'side_menu_alt_text' => '',
'gutenberg_exit_icon' => '',
'gutenberg_exit_custom_icon' => '',
'footer_image' => '',
'footer_url' => '',
'footer_html' => '',
'dashboard_icon' => '',
'dashboard_title' => 'Dashboard',
'dashboard_role_stat' => false,
'dashboard_widgets_visibility_roles' => array('administrator', 'editor', 'author', 'contributor', 'subscriber'),
'dashboard_widgets' => array(),
'hide_all_dashboard_panels' => false,
'hide_at_a_glance' => false,
'hide_activities' => false,
'hide_recent_comments' => false,
'hide_quick_press' => false,
'hide_news_and_events' => false,
'remove_empty_dash_panel' => false,
'welcome_panel' => array(
array(
'is_active' => false,
'show_title' => false,
'template_type' => 'html',
'visible_to' => array('administrator', 'editor', 'author', 'contributor', 'subscriber'),
), array(
'is_active' => false,
'show_title' => false,
'template_type' => 'html',
'visible_to' => array('administrator', 'editor', 'author', 'contributor', 'subscriber'),
)
),
'add_own_rss_panel' => false,
'rss_feed_number_of_item' => 3,
'show_post_content' => false,
'rss_introduction' => '',
'rss_logo' => '',
'rss_title' => '',
'wlcms_admin' => false,
'admin_menus' => false,
'enable_wlcms_admin' => false,
'admin_bar_menus' => false,
'hide_admin_bar_all' => false,
'hide_help_box' => false,
'hide_screen_options' => false,
'hide_nag_messages' => false,
'settings_custom_css_admin' => '',
'settings_custom_css_url' => ''
);
return apply_filters('wlcms_setting_fields', $settings);
}
}
@@ -0,0 +1,412 @@
<?php
class WLCMS_Upgrades
{
private $menu_class;
private $legacy_menus = array();
private $legacy_submenus = array();
private $legacy_db_setting = array();
private $settings;
public function __construct()
{
add_action('admin_init', array($this, 'upgrader_process_complete'), 999999);
}
public function upgrader_process_complete()
{
global $wpdb;
$this->settings = wlcms()->Settings();
if (version_compare($this->settings->get('version'), '2.3', '<')) {
$this->process_upgrade_settings_dashboard();
}
$this->process_legacy();
}
public function process_upgrade_settings_dashboard()
{
$widgets = [];
if ($this->settings->get('hide_at_a_glance') || $this->settings->get('hide_all_dashboard_panels')) {
$widgets[] = 'dashboard_right_now';
$this->settings->remove('hide_at_a_glance');
}
if ($this->settings->get('hide_activities') || $this->settings->get('hide_all_dashboard_panels')) {
$widgets[] = 'dashboard_activity';
$this->settings->remove('hide_activities');
}
if ($this->settings->get('hide_recent_comments') || $this->settings->get('hide_all_dashboard_panels')) {
$widgets[] = 'dashboard_recent_comments';
$this->settings->remove('hide_recent_comments');
}
if ($this->settings->get('hide_news_and_events') || $this->settings->get('hide_all_dashboard_panels')) {
$widgets[] = 'dashboard_primary';
$this->settings->remove('hide_news_and_events');
}
if ($this->settings->get('hide_quick_press')) {
$widgets[] = 'dashboard_quick_press';
$this->settings->remove('hide_quick_press');
}
$this->settings->set('dashboard_widgets', $widgets);
$this->settings->set('version', WLCMS_VERSION);
$this->settings->save();
}
public function process_legacy()
{
global $wpdb;
$legacy_version = get_option('wlcms_o_ver', false);
if (!$legacy_version) {
return;
}
$new_wlcms_options = get_option('wlcms_options', false);
if ($legacy_version && $new_wlcms_options) {
return;
}
$newdbsetting = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->options WHERE option_name = %s", 'wlcms_options'));
if ($legacy_version && $newdbsetting) {
return;
}
$this->do_import();
}
public function do_import()
{
$this->get_settings();
$this->perform();
}
private function get_settings()
{
global $wpdb;
// Get all WLCMS vals from options table
$results = $wpdb->get_results($wpdb->prepare("SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE %s", 'wlcms_o_%'));
// Are there any options to grab?
if (!$results) return;
// Loop through results and prep array.
foreach ($results as $result) :
if ($result->option_value == '') continue;
$this->legacy_db_setting[$result->option_name] = $result->option_value;
endforeach;
}
public function upgrade_reset()
{
$this->settings = wlcms()->Settings();
}
private function perform()
{
$admin_bar_menu = array();
$this->upgrade_reset();
$this->settings->reset();
$this->settings->set('version', WLCMS_VERSION);
foreach ($this->legacy_mapping() as $key => $setting_key) {
if ($new_setting = $this->get_legacy_setting($setting_key)) {
if ($new_setting == 'true')
$new_setting = 1;
$this->settings->set($key, $new_setting);
}
}
$this->settings->set('legacy_menu', '1');
$this->menu_class = wlcms()->Admin_Menus();
//Post
$this->get_legacy_menu_settings('wlcms_o_hide_posts', 'edit.php');
if (!$this->get_legacy_setting('wlcms_o_hide_posts')) {
$admin_bar_menu[] = 'new-post';
}
//Media
$this->get_legacy_menu_settings('wlcms_o_hide_media', 'upload.php');
if (!$this->get_legacy_setting('wlcms_o_hide_media')) {
$admin_bar_menu[] = 'new-media';
}
//Pages
$this->get_legacy_menu_settings('wlcms_o_hide_pages', 'edit.php?post_type=page');
if (!$this->get_legacy_setting('wlcms_o_hide_pages')) {
$admin_bar_menu[] = 'new-page';
}
//Comments
$this->get_legacy_menu_settings('wlcms_o_hide_comments', 'edit-comments.php');
if (!$this->get_legacy_setting('wlcms_o_hide_comments')) {
$admin_bar_menu[] = 'comments';
}
//User
$this->get_legacy_menu_settings('wlcms_o_hide_profile', 'users.php');
if (!$this->get_legacy_setting('wlcms_o_hide_profile')) {
$admin_bar_menu[] = 'new-user';
}
//Tools
$this->get_legacy_menu_settings('wlcms_o_hide_tools', 'tools.php');
if (count($admin_bar_menu)) {
$this->settings->set('admin_bar_menus', $admin_bar_menu);
}
$this->hide_sidebar_menu('plugins.php');
$this->hide_sidebar_menu('options-general.php');
//Appearance
$this->get_legacy_appearance_menu_settings();
$this->settings->set('admin_menus', array('main' => $this->legacy_menus, 'sub' => $this->legacy_submenus));
//Set Admin users to be wlcms admin
$adminusers = get_users('role=administrator');
if (count($adminusers)) :
$wlcms_admin = array();
foreach ($adminusers as $user) :
$wlcms_admin[] = $user->user_email;
endforeach;
$this->settings->set('wlcms_admin', $wlcms_admin);
endif;
//Welcome Dashboard
$welcome = array();
if ($this->get_legacy_setting('wlcms_o_show_welcome')) {
$welcome[] = array(
'is_active' => true,
'template_type' => 'html',
'show_title' => true,
'is_fullwidth' => false,
'visible_to' => $this->get_legacy_roles($this->get_legacy_setting('wlcms_o_welcome_visible_to')),
'title' => $this->get_legacy_setting('wlcms_o_welcome_title'),
'description' => $this->get_legacy_setting('wlcms_o_welcome_text'),
);
}
//Second Panel
if ($this->get_legacy_setting('wlcms_o_welcome_text1')) {
$welcome[] = array(
'is_active' => true,
'template_type' => 'html',
'show_title' => true,
'is_fullwidth' => false,
'visible_to' => $this->get_legacy_roles($this->get_legacy_setting('wlcms_o_welcome_visible_to1')),
'title' => $this->get_legacy_setting('wlcms_o_welcome_title1'),
'description' => $this->get_legacy_setting('wlcms_o_welcome_text1'),
);
}
$this->settings->set('welcome_panel', $welcome);
if ($this->get_legacy_setting('wlcms_o_login_custom_logo')) {
$this->settings->set('logo_width', false);
$this->settings->set('logo_height', false);
}
if ($this->get_legacy_setting('wlcms_o_loginbg_white')) {
$this->settings->set('background_color', '#FFF');
}
//Delete all legacy options
$this->delete_legacy_settings();
//Save new settings
$this->settings->save();
$redirect_url = admin_url();
if (current_user_can('manage_options')) {
$redirect_url = wlcms()->admin_url();
}
wp_redirect($redirect_url);
exit;
}
private function get_legacy_setting($key)
{
return isset($this->legacy_db_setting[$key]) ? $this->legacy_db_setting[$key] : false;
}
private function get_legacy_appearance_menu_settings()
{
$menus = array();
$new_sub_menus = array();
$get_submenu_placeholder = $this->menu_class->get_submenu_placeholder();
$url = 'themes.php';
$count_sub_menus = 0;
$theme_subs = array(
'wlcms_o_subtemplate_hide_16' => 'custom-header',
'wlcms_o_subtemplate_hide_15' => 'customize-php038autofocus%5bcontrol%5dheader_image',
'wlcms_o_subtemplate_hide_10' => 'nav-menus-php',
'wlcms_o_subtemplate_hide_7' => 'widgets-php',
'wlcms_o_subtemplate_hide_6' => 'customize-php',
'wlcms_o_subtemplate_hide_5' => 'themes-php'
);
if ($this->get_legacy_setting('wlcms_o_editor_template_access') == 0) {
$theme_subs['wlcms_o_subtemplate_hide_theme-php'] = 'themes-php';
foreach ($theme_subs as $theme_sub_key => $theme_sub) {
$this->legacy_submenus[] = $url . $get_submenu_placeholder . $theme_sub;
$count_sub_menus++;
}
$this->legacy_menus[] = $url;
return;
}
if ($this->get_legacy_setting('wlcms_o_editor_template_access') == 1) {
$submenus = $this->menu_class->get_new_submenus($url);
if ($submenus) {
$count_sub_menus = 0;
foreach ($theme_subs as $theme_sub_key => $theme_sub) {
if ($this->get_legacy_setting($theme_sub_key)) {
$this->legacy_submenus[] = $url . $get_submenu_placeholder . $theme_sub;
$count_sub_menus++;
}
}
if ($count_sub_menus == count($submenus['submenus'])) {
$this->legacy_menus[] = $url;
}
}
}
}
private function get_legacy_menu_settings($option = "", $url = "")
{
if (!$this->get_legacy_setting($option)) {
return;
}
$this->hide_sidebar_menu($url);
}
private function hide_sidebar_menu($url)
{
$this->legacy_menus[] = $url;
$submenus = $this->menu_class->get_new_submenus($url);
if (!$submenus) {
return;
}
foreach ($submenus['submenus'] as $submenu) {
$this->legacy_submenus[] = $submenu['slug'];
}
}
private function get_legacy_roles($key)
{
$roles = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
$allowed_roles = array();
foreach ($roles as $role) {
$allowed_roles[] = $role;
if ($key == $role) {
break;
}
}
return $allowed_roles;
}
private function delete_legacy_settings()
{
global $wpdb;
delete_option('wlcms_o_ver');
$wpdb->get_results($wpdb->prepare("DELETE FROM $wpdb->options WHERE option_name = %s", 'wlcms_o_ver'));
}
private function legacy_settings()
{
return array_flip($this->legacy_mapping());
}
public function legacy_mapping()
{
return array(
'developer_name' => 'wlcms_o_developer_name',
'developer_url' => 'wlcms_o_developer_url',
'developer_icon' => 'wlcms_o_adminbar_custom_logo',
'admin_bar_alt_text' => 'wlcms_o_developer_name',
'admin_bar_url' => 'wlcms_o_developer_url',
'hide_wordpress_logo_and_links' => 'wlcms_o_hide_wp_adminbar',
'hide_wp_version' => 'wlcms_o_hide_wpversion',
'custom_page_title' => 'wlcms_o_admin_page_title',
'admin_bar_logo' => 'wlcms_o_adminbar_custom_logo',
'footer_image' => 'wlcms_o_footer_custom_logo',
'footer_text' => 'wlcms_o_developer_name',
'footer_url' => 'wlcms_o_developer_url',
'login_logo' => 'wlcms_o_login_custom_logo',
'retina_login_logo' => 'wlcms_o_login_custom_logo',
'background_color' => 'wlcms_o_loginbg_white',
'login_custom_css' => 'wlcms_o_login_bg_css',
'login_custom_js' => 'wlcms_o_login_bg_js',
'dashboard_icon' => 'wlcms_o_header_custom_logo',
'dashboard_title' => 'wlcms_o_dashboard_override',
'hide_all_dashboard_panels' => 'wlcms_o_dashboard_others',
'hide_at_a_glance' => 'wlcms_o_dashboard_remove_right_now',
'hide_activities' => 'wlcms_o_dashboard_remove_activity_panel',
'hide_recent_comments' => 'wlcms_o_dashboard_remove_recent_comments',
'remove_empty_dash_panel' => 'wlcms_o_dashboard_border',
'own_welcome_panel' => 'wlcms_o_show_welcome',
'own_welcome_panel_visible_to' => 'wlcms_o_welcome_visible_to',
'own_welcome_panel_title' => 'wlcms_o_welcome_title',
'welcome_panel_description' => 'wlcms_o_welcome_text',
'second_panel_title' => 'wlcms_o_welcome_title1',
'second_panel_visible_to' => 'wlcms_o_welcome_visible_to1',
'second_panel_description' => 'wlcms_o_welcome_text1',
'add_own_rss_panel' => 'wlcms_o_show_rss_widget',
'rss_feed_number_of_item' => 'wlcms_o_rss_num_items',
'show_post_content' => 'wlcms_o_rss_show_intro',
'rss_introduction' => 'wlcms_o_rss_intro_html',
'rss_feed_address' => 'wlcms_o_rss_value',
'rss_logo' => 'wlcms_o_rss_logo',
'rss_title' => 'wlcms_o_rss_title',
'hide_help_box' => 'wlcms_o_dashboard_remove_help_box',
'hide_screen_options' => 'wlcms_o_dashboard_remove_screen_options',
'hide_nag_messages' => 'wlcms_o_dashboard_remove_nag_update',
'settings_custom_css_admin' => 'wlcms_o_custom_css',
'settings_custom_css_url' => 'wlcms_o_welcome_stylesheet'
);
}
}
@@ -0,0 +1,44 @@
<?php
class Welcome_Messages_Beaver_Builder
{
private $key;
private $settings;
private $template;
public function process($settings, $key)
{
if (!isset($settings['page_id_beaver'])) return;
$this->key = $key;
$this->settings = $settings;
$this->template = $settings['page_id_beaver'];
add_action('in_admin_header', array($this, 'welcome_panel'));
add_action('admin_enqueue_scripts', 'FLBuilder::register_layout_styles_scripts');
}
public function template()
{
echo do_shortcode('[fl_builder_insert_layout id="' . esc_attr($this->template) . '"]');
}
public function welcome_panel()
{
?>
<div id="welcome-panel<?php echo $this->key ?>" data-welcome_key="<?php echo $this->key ?>" class="wlcms-welcome-panel" style="display:none">
<?php
if (isset($this->settings['dismissible'])) :
?><a class="welcome-panel-close" href="#" aria-label="Dismiss the welcome panel">Dismiss</a>
<?php endif ?>
<div class="welcome-panel-content welcome-panel-content<?php echo $this->key ?>">
<?php if (isset($this->settings['page_id_beaver']) && isset($this->settings['show_title'])) : ?>
<h2>
<?php echo get_the_title($this->settings['page_id_beaver']) ?>
</h2>
<?php endif; ?>
<?php $this->template(); ?>
</div>
</div>
<?php
$welcome = sprintf(";jQuery('#welcome-panel%1\$d').insertBefore('#dashboard-widgets-wrap');jQuery('#welcome-panel%1\$d').show();", $this->key);
wlcms_add_js($welcome);
}
}
@@ -0,0 +1,58 @@
<?php
class Welcome_Messages_Elementor
{
private $key;
private $settings;
public function process($settings, $key)
{
if (!isset($settings['page_id_elementor'])) return;
if ($settings['page_id_elementor'] == "") return;
$this->key = $key;
$this->settings = $settings;
add_action('in_admin_header', array($this, 'welcome_panel'));
}
public function welcome_panel()
{
$has_dismissable = isset($this->settings['dismissible']);
$is_show_title = isset($this->settings['page_id_elementor']) && isset($this->settings['show_title']);
?>
<div id="welcome-panel<?php echo $this->key ?>" data-welcome_key="<?php echo $this->key ?>" class="wlcms-welcome-panel" style="display:none">
<?php
if ($has_dismissable) :
?><a class="welcome-panel-close" href="#" aria-label="Dismiss the welcome panel">Dismiss</a>
<?php endif ?>
<div class="welcome-panel-content welcome-panel-content<?php echo $this->key ?>">
<?php if ($has_dismissable || $is_show_title) : ?>
<?php if ($is_show_title) : ?>
<h2>
<?php echo get_the_title($this->settings['page_id_elementor']) ?>
</h2>
<?php endif; ?>
<?php endif; ?>
<?php $this->template(); ?>
</div>
</div>
<?php
$welcome = sprintf(";jQuery('#welcome-panel%1\$d').insertBefore('#dashboard-widgets-wrap');jQuery('#welcome-panel%1\$d').show();", $this->key);
wlcms_add_js($welcome);
}
public function template()
{
if (!$this->settings['page_id_elementor']) {
return;
}
$elementor = @Elementor\Plugin::instance();
$elementor->frontend->register_styles();
$elementor->frontend->enqueue_styles();
$elementor->frontend->register_scripts();
$elementor->frontend->enqueue_scripts();
echo $elementor->frontend->get_builder_content((int) $this->settings['page_id_elementor'], true);
}
}
@@ -0,0 +1,55 @@
<?php
class Welcome_Messages_Html
{
private $key;
private $settings;
public function process($settings, $key)
{
$this->key = $key;
$this->settings = $settings;
if (isset($this->settings['is_fullwidth']) && $this->settings['is_fullwidth'] == 1) {
add_action('in_admin_header', array($this, 'welcome_panel'));
return;
}
wp_add_dashboard_widget(
'custom_vum_widget' . $key,
isset($this->settings['title']) ? $this->settings['title'] : '&nbsp;',
array($this, 'welcome_description'),
null,
array('desc' => $this->template())
);
}
public function welcome_description($post, $callback_args)
{
echo $callback_args['args']['desc'];
}
public function welcome_panel()
{ ?>
<div id="welcome-panel<?php echo $this->key ?>" data-welcome_key="<?php echo $this->key ?>" class="wlcms-welcome-panel">
<?php
if (isset($this->settings['dismissible'])) :
?><a class="welcome-panel-close" href="#" aria-label="Dismiss the welcome panel">Dismiss</a>
<?php endif ?>
<div class="welcome-panel-content welcome-panel-content<?php echo $this->key ?>" style="padding-bottom:20px">
<?php if (isset($this->settings['title'])) : ?>
<h2><?php echo esc_html($this->settings['title']) ?></h2>
<?php endif; ?>
<div class="wlcms-welcome-content">
<?php echo $this->template(); ?>
</div>
</div>
</div>
<?php
$welcome = sprintf(";jQuery('#welcome-panel%1\$d').insertBefore('#dashboard-widgets-wrap');jQuery('#welcome-panel%1\$d').show();", $this->key);
wlcms_add_js($welcome);
}
public function template()
{
return isset($this->settings['description']) ? wpautop(wp_kses_post($this->settings['description'])) : '';
}
}
@@ -0,0 +1,79 @@
<?php
class Welcome_Messages_Page
{
private $key;
private $settings;
private $template;
private $pages = [];
public function init($pages = [])
{
if (!count($pages)) {
return;
}
$this->pages = $pages;
add_action('wp', array($this, 'wp'));
}
public function wp()
{
$this->hide_admin_menu_bar();
}
private function hide_admin_menu_bar()
{
if (!isset($_GET['wlcms-welcome-dashboard'])) {
return;
}
add_filter('show_admin_bar', '__return_false');
}
public function process($settings, $key)
{
if (!isset($settings['page_id_page'])) return;
$this->key = $key;
$this->settings = $settings;
$this->template = $settings['page_id_page'];
add_action('in_admin_header', array($this, 'welcome_panel'));
}
public function template()
{
if (!$this->template || ($this->template && $this->template == '')) {
return;
}
$url = get_permalink($this->template);
$url = add_query_arg('wlcms-welcome-dashboard', 'true', $url);
$url = esc_url($url);
echo "<iframe class=\"responsive-iframe\" onLoad=\"wlcms_iframe_height(this)\" frameborder=\"0\" scrolling=\"no\" width=\"100%\" src=\"{$url}\"></iframe>";
}
public function welcome_panel()
{
?>
<div id="welcome-panel<?php echo $this->key ?>" data-welcome_key="<?php echo $this->key ?>" class="wlcms-welcome-panel" style="display:none">
<?php
if (isset($this->settings['dismissible'])) :
?><a class="welcome-panel-close" href="#" aria-label="Dismiss the welcome panel">Dismiss</a>
<?php endif ?>
<div class="welcome-panel-content welcome-panel-content<?php echo $this->key ?>">
<?php if (isset($this->settings['page_id_page']) && isset($this->settings['show_title'])) : ?>
<h2>
<?php echo get_the_title($this->settings['page_id_page']) ?>
</h2>
<?php endif; ?>
<?php $this->template(); ?>
</div>
</div>
<?php
$welcome = sprintf(";jQuery('#welcome-panel%1\$d').insertBefore('#dashboard-widgets-wrap');jQuery('#welcome-panel%1\$d').show();", $this->key);
wlcms_add_js($welcome);
}
}
@@ -0,0 +1,102 @@
<?php
class WLCMS_Wizard extends WLCMS_Previewable
{
public function __construct()
{
//Check and set if it is a preview
$this->check_preview();
add_filter('wlcms_setting_fields', array($this, 'setting_fields'), 10, 1);
// add_action('wlcms_before_saving', array($this, 'store'));
add_action('wp_ajax_wlcms_save_dashboard_preview_settings', array($this, 'store_preview'));
add_action('wlcms_save_addtional_settings', array($this, 'before_save'), 10, 2);
add_action('wlcms_before_save_preview', array($this, 'before_save'), 10, 2);
}
public function before_save($settings, $placeholder)
{
if (!isset($_POST['wlcms_wizzard'])) {
return $settings;
}
if (isset($_POST['wizard_developer_name'])) {
$developer_name = wlcms_kses($_POST['wizard_developer_name']);
$settings->set($placeholder . 'developer_name', $developer_name);
$settings->set($placeholder . 'admin_bar_alt_text', $developer_name);
$settings->set($placeholder . 'side_menu_alt_text', $developer_name);
$settings->set($placeholder . 'rss_title', $developer_name);
}
if (isset($_POST['wizard_developer_url'])) {
$developer_url = wlcms_kses($_POST['wizard_developer_url']);
$settings->set($placeholder . 'admin_bar_url', $developer_url);
$settings->set($placeholder . 'side_menu_link_url', $developer_url);
$settings->set($placeholder . 'footer_url', $developer_url);
}
if (isset($_POST['client_business_name'])) {
$custom_page_title = wlcms_kses($_POST['client_business_name']);
$settings->set($placeholder . 'custom_page_title', $custom_page_title);
$settings->set($placeholder . 'dashboard_title', $custom_page_title);
}
if (isset($_POST['rss_feed_address']) && !empty($_POST['rss_feed_address'])) {
$settings->set($placeholder . 'add_own_rss_panel', true);
}
$settings->set($placeholder . 'welcome_panel', array(
array(
'is_active' => false,
'show_title' => false,
'template_type' => 'html',
'visible_to' => array('administrator', 'editor', 'author', 'contributor', 'subscriber'),
), array(
'is_active' => false,
'show_title' => false,
'template_type' => 'html',
'visible_to' => array('administrator', 'editor', 'author', 'contributor', 'subscriber'),
)
));
return $settings;
}
public function settings()
{
$settings = $this->wizard_settings();
$wizard_settings = array(
'version' => WLCMS_VERSION,
'use_developer_side_menu_image' => false,
'developer_icon_admin_bar' => false,
'developer_branding_footer' => false,
'hide_wordpress_logo_and_links' => true,
'hide_at_a_glance' => true,
'hide_activities' => true,
'hide_recent_comments' => true,
'hide_quick_press' => true,
'hide_news_and_events' => true,
'remove_empty_dash_panel' => true,
'hide_wp_version' => true,
'rss_title' => '&nbsp;'
);
return array_merge($wizard_settings, $settings);
}
public function wizard_settings()
{
return array(
'developer_name' => '',
'footer_text' => '',
'rss_feed_address' => '',
'custom_page_title' => '',
);
}
public function setting_fields($settings)
{
return array_merge($settings, $this->wizard_settings());
}
}
@@ -0,0 +1,4 @@
<?php
if (!defined('ABSPATH')) {
die('Access denied.');
}