' . esc_html__('Cookie Notice, Promotional Bar on frontend', 'adminify') . '
' . wp_kses_post($html) . '
';
echo wp_kses_post($html_content);
}
/**
* User Defined Settings
*/
public static function get_user_preference($key)
{
$userid = get_current_user_id();
$current = get_user_meta($userid, 'pxlbsadminify_preferences', true);
$value = false;
if (is_array($current)) {
if (isset($current[$key])) {
$value = $current[$key];
}
}
return $value;
}
/**
* Sanitises and strips tags of input from ajax
*
* @since 1.0.0
* @variables $values = item to clean (array or string)
*/
public static function clean_ajax_input($values)
{
if (is_array($values)) {
foreach ($values as $index => $in) {
if (is_array($in)) {
$values[$index] = self::clean_ajax_input($in);
} else {
$values[$index] = wp_strip_all_tags($in);
}
}
} else {
$values = wp_strip_all_tags($values);
}
return $values;
}
/**
* Check Ajax Error Messages
*
* @param [type] $message
*
* @return void
*/
public static function ajax_error_message($message)
{
$returndata = [];
$returndata['error'] = true;
$returndata['error_message'] = $message;
return wp_json_encode($returndata);
}
/**
* Get All Updates
* Themes, Plugins, Core etc
*
* @return void
*/
public static function get_all_updates()
{
$allupdates = [];
$allupdates['total'] = 0;
$allupdates['wordpress'] = 0;
$allupdates['theme'] = 0;
$allupdates['plugin'] = 0;
if (!is_admin()) {
return $allupdates;
}
if (!current_user_can('install_plugins')) {
return $allupdates;
}
$updatesTotal = 0;
if (is_super_admin() && is_admin()) {
$pluginUpdates = get_plugin_updates();
$themeUpdates = get_theme_updates();
$wpUpdates = get_core_updates();
if (isset($wpUpdates[0])) {
$wpversion = $wpUpdates[0]->version;
global $wp_version;
if ($wpversion > $wp_version) {
$wpUpdates = 1;
} else {
$wpUpdates = 0;
}
} else {
$wpUpdates = 0;
}
$updatesTotal = count($pluginUpdates) + count($themeUpdates) + $wpUpdates;
$allupdates['total'] = $updatesTotal;
$allupdates['wordpress'] = $wpUpdates;
$allupdates['theme'] = $themeUpdates;
$allupdates['plugin'] = $pluginUpdates;
}
return $allupdates;
}
/**
* Upgrade Pro Icon
*
* @return string
*/
public static function upgrade_pro_icon()
{
return '';
}
// Upgrade to Pro Notice
public static function upgrade_pro_img_notice( $image ){
return '
';
}
// Upgrade to Pro Notice Class
public static function upgrade_pro_notice_class($notice = '')
{
if(empty($notice)){
// return ' adminify-depend-visible adminify-depend-on adminify-pro-notice ';
return ' adminify-pro-feature adminify-pro-notice';
} else {
echo esc_attr($notice);
}
}
// Upgrade to Pro Notice
public static function upgrade_pro_notice($custom_message = '', $style='')
{
if (empty($custom_message)) {
$pro_content = '' . __('(Upgrade to Pro)', 'adminify') . '';
} else {
$pro_content = $custom_message;
}
if($style === 'inline'){
return '' . $pro_content . '';
}
$upgrade_notice_msg = sprintf(
'
%1$s %2$s
',
self::upgrade_pro_icon(),
self::kses_custom($pro_content)
);
return self::kses_custom($upgrade_notice_msg);
}
/**
* Documentation SVG Icon
*/
public static function docs_icon()
{
return '';
}
/**
* Video Tutorials SVG Icon
*/
public static function video_tutorials_icon()
{
return '';
}
/**
* Facebook Group SVG Icon
*/
public static function fbgroup_icon()
{
return '';
}
/**
* Support SVG Icon
*/
public static function support_icon()
{
return '';
}
/* White Label Upgrade Pro */
public static function white_label_upgrade()
{
?>
Pro for White Labeling', 'adminify')) ); ?>
%1$s can be completely re-branded with your own brand Logo, Name and Author Details. Your clients will never know what tools you are using to build their website and will think that this is your own tool set. White-labeling works as long as your license is active. ', 'adminify'), esc_html(PXLBSADMINIFY)) );
?>
$name) {
$options[$id] = $name;
}
} else {
$options['no_template'] = __('No saved templates found!', 'adminify');
}
return $options;
}
public static function get_section_template_options()
{
$type = 'section';
$page_templates = self::get_page_templates($type);
$options[-1] = __('Select', 'adminify');
if (count($page_templates)) {
foreach ($page_templates as $id => $name) {
$options[$id] = $name;
}
} else {
$options['no_template'] = __('No saved templates found!', 'adminify');
}
return $options;
}
public static function get_page_template_options()
{
$type = 'page';
$page_templates = self::get_page_templates($type);
$options[-1] = __('Select', 'adminify');
if (count($page_templates)) {
foreach ($page_templates as $id => $name) {
$options[$id] = $name;
}
} else {
$options['no_template'] = __('No saved templates found!', 'adminify');
}
return $options;
}
/**
* Common preset CSS variables (padding / sizing / typography
* defaults) shared by every theme preset and by the Pro
* custom-color preset path. Extracted so the Pro filter
* (Pro/Classes/OutputCSS_Body_Pro::build_custom_color_preset())
* can reuse the same defaults instead of re-declaring them.
*
* @return array
*/
public static function get_common_preset_vars()
{
return [
'--adminify-menu-vertical-padding' => '10px',
'--adminify-menu-horizontal-padding' => '8px',
'--adminify-menu-wrapper-padding-top' => '16px',
'--adminify-menu-wrapper-padding-right' => '8px',
'--adminify-menu-wrapper-padding-bottom' => '16px',
'--adminify-menu-wrapper-padding-left' => '8px',
'--adminify-submenu-vertical-padding' => '4px',
'--adminify-submenu-wrapper-padding-top' => '8px',
'--adminify-submenu-wrapper-padding-right' => '0px',
'--adminify-submenu-wrapper-padding-bottom' => '8px',
'--adminify-submenu-wrapper-padding-left' => '28px',
'--adminify-menu-font-size' => '13px',
'--adminify-menu-line-height' => '20px',
'--adminify-menu-letter-spacing' => '',
'--adminify-menu-width' => '260px',
];
}
public static function get_theme_presets($theme = null)
{
$common_var = self::get_common_preset_vars();
$presets = [
// Base/ Default Preset
'preset1' => [
'--adminify-preset-background' => '#F9F9F9',
'--adminify-primary' => '#3a3ae9',
// '--adminify-text-color' => '#ffffff',
'--adminify-menu-border' => '#dedee7',
'--adminify-menu-bg' => '#ffffff',
'--adminify-menu-hover-bg' => '#3a3ae9',
'--adminify-menu-text-color' => '#48455f',
'--adminify-menu-text-hover-color' => '#ffffff',
'--adminify-menu-active-bg' => '#3a3ae9',
'--adminify-menu-active-color' => '#ffffff',
'--adminify-submenu-wrapper-bg' => '#ffffff',
'--adminify-submenu-hover-bg' => 'transparent',
'--adminify-submenu-text-color' => '#48455f',
'--adminify-submenu-text-hover-color' => '#3a3ae9',
'--adminify-submenu-active-bg' => 'transparent',
'--adminify-submenu-active-color' => '#3a3ae9',
'--adminify-notif-bg-color' => '#3a3ae9',
'--adminify-notif-color' => '#ffffff',
],
'preset2' => [
'--adminify-preset-background' => '#F9F9F9',
'--adminify-primary' => '#0347FF',
'--adminify-notif-bg-color' => '#FF1C69',
// '--adminify-text-color' => '#ffffff',
'--adminify-menu-border' => '#404052',
'--adminify-menu-bg' => '#14142B',
'--adminify-menu-hover-bg' => '#0347FF',
'--adminify-menu-text-color' => '#ffffff',
'--adminify-menu-text-hover-color' => '#ffffff',
'--adminify-menu-active-bg' => '#0347FF',
'--adminify-menu-active-color' => '#ffffff',
'--adminify-submenu-wrapper-bg' => '#14142B',
'--adminify-submenu-hover-bg' => 'transparent',
'--adminify-submenu-text-color' => '#ffffff',
'--adminify-submenu-text-hover-color' => '#0347FF',
'--adminify-submenu-active-bg' => 'transparent',
'--adminify-submenu-active-color' => '#0347FF',
'--adminify-notif-bg-color' => '#0347FF',
'--adminify-notif-color' => '#ffffff',
],
];
$pro_presets = apply_filters('pxlbsadminify_settings/color_presets', $common_var);
if( !empty(array_key_exists('preset3', $pro_presets)) ) {
$presets = array_merge($presets, $pro_presets);
}
// Merge $common_var variable with every preset
foreach ($presets as $key => $value) {
$presets[$key] = array_merge($value, $common_var);
}
// return all presets
if (is_null($theme)) {
return $presets;
}
// return specific preset
if (array_key_exists($theme, $presets)) {
return $presets[$theme];
}
// specific preset not found (Pro-only/custom theme saved while Pro add-on inactive).
// Fall back to base preset so core CSS vars (--adminify-menu-width) always emit.
return isset($presets['preset1']) ? $presets['preset1'] : $common_var;
}
public static function get_page_templates($type = '')
{
$args = [
'post_type' => 'elementor_library',
'posts_per_page' => -1,
];
if ($type) {
$args['tax_query'] = [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- intentional taxonomy filter on an admin-side query.
[
'taxonomy' => 'elementor_library_type',
'field' => 'slug',
'terms' => $type,
],
];
}
$page_templates = get_posts($args);
$options = [];
if (!empty($page_templates) && !is_wp_error($page_templates)) {
foreach ($page_templates as $post) {
$options[$post->ID] = $post->post_title;
}
}
return $options;
}
public static function assets_ext($ext)
{
if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
return $ext;
}
return '.min' . $ext;
}
public static function kses_atts_map(array $attrs)
{
return array_fill_keys(array_values($attrs), true);
}
/**
* Whether the site is served over HTTPS well enough to run the Adminify UI.
*
* Mirrors the exact condition that gates the dashboard frame in
* Inc/Admin/Admin.php ( is_ssl() + an https:// site URL ), so the AJAX
* gate behaviour stays consistent with where the UI actually loads.
*
* @return array{ready:bool,message:string}
*/
public static function adminify_ui_https_status()
{
$is_ssl = is_ssl();
$site_https = ( 0 === stripos( (string) site_url(), 'https://' ) );
if ( $is_ssl && $site_https ) {
return [
'ready' => true,
'message' => '',
];
}
if ( ! $site_https ) {
$message = esc_html__( 'Site URL is not HTTPS. Switch to HTTPS first.', 'adminify' );
} else {
$message = esc_html__( 'Open the dashboard over HTTPS first.', 'adminify' );
}
return [
'ready' => false,
'message' => $message,
];
}
public static function kses_allowed_html()
{
/**
* 'post' returns the tags allowed in post content (a, p, strong, em, etc.),
* which we then extend with the custom tags below (svg, form fields, style).
* https://developer.wordpress.org/reference/functions/wp_kses_allowed_html/
*/
$allowed_tags = wp_kses_allowed_html('post');
if( !is_array($allowed_tags) ) $allowed_tags = [];
$custom_tags = [
'select' => self::kses_atts_map(['class', 'id', 'style', 'width', 'height', 'title', 'data', 'name', 'autofocus', 'disabled', 'multiple', 'required', 'size']),
'input' => self::kses_atts_map(['class', 'id', 'style', 'width', 'height', 'title', 'data', 'name', 'autofocus', 'disabled', 'required', 'size', 'type', 'checked', 'readonly', 'placeholder', 'value', 'maxlength', 'min', 'max', 'multiple', 'pattern', 'step', 'autocomplete']),
'textarea' => self::kses_atts_map(['class', 'id', 'style', 'width', 'height', 'title', 'data', 'name', 'autofocus', 'disabled', 'required', 'rows', 'cols', 'wrap', 'maxlength']),
'option' => self::kses_atts_map(['class', 'id', 'label', 'disabled', 'label', 'selected', 'value']),
'optgroup' => self::kses_atts_map(['disabled', 'label', 'class', 'id']),
'form' => self::kses_atts_map(['class', 'id', 'data', 'style', 'width', 'height', 'accept-charset', 'action', 'autocomplete', 'enctype', 'method', 'name', 'novalidate', 'rel', 'target']),
'svg' => self::kses_atts_map(['class', 'xmlns', 'viewbox', 'width', 'height', 'fill', 'stroke', 'aria-hidden', 'aria-labelledby', 'role']),
'rect' => self::kses_atts_map(['rx', 'width', 'height', 'fill']),
'path' => self::kses_atts_map(['d', 'fill', 'fill-rule', 'clip-rule', 'stroke', 'stroke-width', 'stroke-linecap', 'stroke-linejoin']),
'g' => self::kses_atts_map(['fill']),
'defs' => self::kses_atts_map(['fill']),
'linearGradient' => self::kses_atts_map(['id', 'x1', 'x2', 'y1', 'y2', 'gradientUnits']),
'stop' => self::kses_atts_map(['stop-color', 'offset', 'stop-opacity']),
'style' => self::kses_atts_map(['type']),
'div' => self::kses_atts_map(['class', 'id', 'style']),
'ul' => self::kses_atts_map(['class', 'id', 'style']),
'li' => self::kses_atts_map(['class', 'id', 'style']),
'label' => self::kses_atts_map(['class', 'for']),
'span' => self::kses_atts_map(['class', 'id', 'style']),
'h1' => self::kses_atts_map(['class', 'id', 'style']),
'h2' => self::kses_atts_map(['class', 'id', 'style']),
'h3' => self::kses_atts_map(['class', 'id', 'style']),
'h4' => self::kses_atts_map(['class', 'id', 'style']),
'h5' => self::kses_atts_map(['class', 'id', 'style']),
'h6' => self::kses_atts_map(['class', 'id', 'style']),
'a' => self::kses_atts_map(['class', 'href', 'target', 'rel']),
'p' => self::kses_atts_map(['class', 'id', 'style', 'data']),
'table' => self::kses_atts_map(['class', 'id', 'style']),
'thead' => self::kses_atts_map(['class', 'id', 'style']),
'tbody' => self::kses_atts_map(['class', 'id', 'style']),
'tr' => self::kses_atts_map(['class', 'id', 'style']),
'th' => self::kses_atts_map(['class', 'id', 'style']),
'td' => self::kses_atts_map(['class', 'id', 'style']),
'i' => self::kses_atts_map(['class', 'id', 'style']),
'button' => self::kses_atts_map(['class', 'id']),
'nav' => self::kses_atts_map(['class', 'id', 'style']),
'time' => self::kses_atts_map(['datetime']),
'br' => [],
'strong' => [],
'style' => [],
'img' => self::kses_atts_map(['class', 'src', 'alt', 'height', 'width', 'srcset', 'id', 'loading']),
];
return array_merge_recursive($allowed_tags, $custom_tags);
}
/**
* Sanitize a string with wp_kses() using the extended allowed-tags list.
*
* @param string $content
* @return string
*/
public static function kses_custom($content)
{
return wp_kses( stripslashes_deep($content), self::kses_allowed_html() );
}
/**
* Missing Addon/Plugin Notice
*
* @param [type] $args
*
* @return void
*/
public static function missing_plugin_notice( $plugin_name = '' )
{
$missing_plugin_notice = sprintf(
/* translators: 1: Plugin name, 2: Addons/plugins admin page URL, 3: "Install Now" link text */
__('"%1$s" plugin is not Activated! Please install and activate %1$s Plugin
';
}
/**
* Update Existing Data to New Options data
*
* @param [type] $get_option_value
* @param [type] $update_option_value
* @param [type] $option_name
*
* @return void
*/
public static function update_options($get_option_value, $option_name)
{
// Retrieve the current option value
$current_value = get_option($option_name);
// $current_value = self::$option_data;
// Initialize the current value if it's empty
if (empty($current_value)) {
$current_value = [];
}
// If $get_option_value is provided, use it to update the current value
if (!empty($get_option_value)) {
// Ensure current value is an array before merging
if (!is_array($current_value)) {
$current_value = [];
}
// Merge the provided value into the current value
$current_value = array_merge($current_value, $get_option_value);
}
// Update the specific key within the option with the new value
// $current_value[$option_key] = $update_option_value;
// Update the option with the new value
update_option($option_name, $current_value);
// Optionally, return the updated value
return get_option($option_name);
}
/**
* Replace Array Keys
*
* @return void
*/
public static function replace_keys($sourceArray, $newArray){
$new_value = [];
if( ! is_array($sourceArray)) $sourceArray = [];
foreach ($newArray as $key => $value) {
if (!array_key_exists($key, $sourceArray)) {
return $sourceArray;
}
$new_value[$value] = $sourceArray[$key];
unset($sourceArray[$key]);
}
return array_merge($sourceArray, $new_value);
}
/**
* Move Array Keys
*
* @return void
*/
public static function move_keys(&$sourceArray, $keysToMove)
{
$destinationArray = [];
foreach ($keysToMove as $key) {
if (array_key_exists($key, $sourceArray)) {
$destinationArray[$key] = $sourceArray[$key];
unset($sourceArray[$key]);
}
}
return $destinationArray;
}
/**
* Remove unnecessary keys.
*
* @param string $option_name The name of the option.
* @param array $keys_to_remove An array of keys to remove.
*/
public static function removeKeys($sourceArray, $keysToRemove)
{
foreach ($keysToRemove as $key) {
if (array_key_exists($key, $sourceArray)) {
unset($sourceArray[$key]);
}
}
return $sourceArray;
}
/**
* Move Nested Keys
*
* @return void
*/
public static function moveNestedKeys(&$sourceArray, $moveInstructions) {
$destinationArray = [];
foreach ($moveInstructions as $sourcePath => $destPath) {
$sourcePathArray = explode('.', $sourcePath);
$destPathArray = explode('.', $destPath);
$sourceValue = self::getNestedValue($sourceArray, $sourcePathArray);
if ($sourceValue !== null) {
self::setNestedValue($destinationArray, $destPathArray, $sourceValue);
self::unsetNestedValue($sourceArray, $sourcePathArray);
}
}
return array_merge_recursive($sourceArray, $destinationArray);
}
public static function getNestedValue(&$array, $pathArray) {
$value = &$array;
foreach ($pathArray as $key) {
if (is_array($value) && array_key_exists($key, $value)) {
$value = &$value[$key];
} else {
return null;
}
}
return $value;
}
public static function setNestedValue(&$array, $pathArray, $value) {
$temp = &$array;
foreach ($pathArray as $key) {
if (!isset($temp[$key])) {
$temp[$key] = [];
}
$temp = &$temp[$key];
}
$temp = $value;
}
public static function unsetNestedValue(&$array, $pathArray) {
$temp = &$array;
foreach ($pathArray as $key) {
if (isset($temp[$key])) {
if (count($pathArray) === 1) {
unset($temp[$key]);
} else {
self::unsetNestedValue($temp[$key], array_slice($pathArray, 1));
}
return;
}
}
}
/**
*
* Checkbox Method
*/
public static function checkboxes(&$old_db, $checkbox_keys) {
$result = [];
$parentKey = "";
$childKey = "";
$thirdStep = [];
foreach ($checkbox_keys as $key => $value) {
$sourceArray = explode(".", $value);
foreach ($sourceArray as $x => $element) {
if (!array_key_exists($element, $result) && $x === 0) {
$parentKey = $element;
if (count($sourceArray) === 3) {
$result[$element] = [];
} else {
$result[$element] = [];
}
}
if ($x === 1 && !empty($old_db[$key])) {
$childKey = $element;
if (count($sourceArray) === 3) {
$result[$parentKey][$element] = [];
} else {
$result[$parentKey][] = $element;
}
} elseif ($x === 1 && empty($old_db[$key]) && count($sourceArray) === 3) {
$childKey = $element;
if (!array_key_exists($element, $result[$parentKey])) {
$result[$parentKey][$element] = [];
}
}
if ($x === 2 && !empty($old_db[$key]) && count($sourceArray) === 3) {
$thirdStep[] = $element;
$result[$parentKey][$childKey] = $thirdStep;
}
}
}
return array_merge_recursive($old_db, $result);
}
/**
* Inline "Upgrade to Pro" marker rendered next to a checkbox option
* label in the free build.
*
* Returns the rocket-icon + (Upgrade to Pro) span the settings UI
* has rendered historically. The
* Inc/Admin/AdminSettings::render_pro_locked_field() handler
* detects this span inside a checkbox
and strips name= + sets
* disabled on the enclosed input so the locked option cannot submit
* a value.
*
* Returns an empty string when the Pro plugin is active so the Pro
* UI is unchanged.
*/
public static function upgrade_pro_class($inline_badge = false){
if (function_exists('jltwp_adminify') && jltwp_adminify()->can_use_premium_code__premium_only()) {
return '';
}
if (!empty($inline_badge)){
return 'Pro';
}
return '' . self::upgrade_pro_icon() . ' (Upgrade to Pro)' . '';
}
/**
* Inline "Pro" badge rendered next to a field title in the free
* build.
*
* Returns the legacy Pro
* markup. The render handler detects fields whose class list
* contains adminify-pro-fieldset / -feature / -notice (the
* Pro-style classes used alongside this badge) and neutralises
* the inputs at render time.
*
* Returns an empty string when the Pro plugin is active.
*/
public static function upgrade_pro_badge($badge_text = 'Pro'){
if (function_exists('jltwp_adminify') && jltwp_adminify()->can_use_premium_code__premium_only()) {
return '';
}
if (!empty($badge_text)){
return '' . esc_html($badge_text) . '';
}
return '';
}
public static function new_badge($badge_text = 'New') {
if( empty( $badge_text ) ) {
return '';
}
return '' . esc_html($badge_text) . '';
}
/*
* Compares the version of WordPress running to the $version specified.
* Usage: Utils::check_wp_version('>=', '4.0')
version_compare( $wp_version, '4.3', '>=' )
* @param string $operator
* @param string $version
* @returns boolean
*/
public static function check_wp_version( $operator = '>', $version = '6.6' ) {
global $wp_version;
return version_compare( $wp_version, $version, $operator );
}
public static function help_urls($module_name = '', $docs = '', $youtube = '', $facebook_grp = '', $support = '')
{
$help_content = '';
// Modules ( sanitize the label so the returned template is safe to echo ).
// Callers may pass benign markup (e.g. an empty used for layout/icons),
// so use wp_kses_post() — it keeps that markup while stripping scripts. esc_html()
// would print the tags literally (e.g. "" shown as text).
$module_name = empty($module_name) ? '' : wp_kses_post($module_name);
$help_content_urls = '';
// Docs
if (!empty($docs)) {
$help_content_urls .= ' ' . self::docs_icon() . ' Docs';
}
// youtube
if (!empty($youtube)) {
$help_content_urls .= '' . self::video_tutorials_icon() . ' Video Tutorial';
}
// facebook_grp
if (!empty($facebook_grp)) {
$help_content_urls .= '' . self::fbgroup_icon() . ' Facebook Group';
}
// Support
if ( !empty($support)) {
$help_content_urls .= '' . self::support_icon() . ' Support';
}
$help_content = sprintf( '%1$s
%2$s
', $module_name, $help_content_urls );
return $help_content;
}
/**
* Check if the request is coming from an iframe.
*
* @param None
* @throws None
* @return bool
*/
public static function is_iframe()
{
return isset($_SERVER["HTTP_SEC_FETCH_DEST"]) && strtolower(sanitize_text_field(wp_unslash($_SERVER["HTTP_SEC_FETCH_DEST"]))) === "iframe";
// $isIframe = isset($_SERVER["HTTP_SEC_FETCH_DEST"]) && strtolower($_SERVER["HTTP_SEC_FETCH_DEST"]) === "iframe";
// if ( $isIframe ) return true;
// if ( isset($_GET['adminify-iframe']) ) return true;
// return false;
}
/**
* Whether the current request renders a full admin page.
*
* Endpoints like async-upload.php run through wp-admin/admin.php (so `admin_init`
* fires) but answer with a raw payload - an attachment ID, JSON, an HTML fragment.
* Printing the Admin UI frame into those responses corrupts them: the media uploader
* on media-new.php reads the response as an attachment ID and gives up when it is not
* numeric. `wp_doing_ajax()` does not catch these: async-upload.php only defines
* DOING_AJAX for the `upload-attachment` action, which media-new.php does not send.
*
* @return bool
*/
public static function is_admin_page_request()
{
if ( wp_doing_ajax() || wp_doing_cron() || wp_is_json_request() ) {
return false;
}
if ( ( defined('REST_REQUEST') && REST_REQUEST ) || ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) || ( defined('WP_CLI') && WP_CLI ) ) {
return false;
}
$pagenow = isset($GLOBALS['pagenow']) ? $GLOBALS['pagenow'] : '';
if ( empty($pagenow) && isset($_SERVER['PHP_SELF']) ) {
$pagenow = basename( sanitize_text_field( wp_unslash($_SERVER['PHP_SELF']) ) );
}
$raw_response_endpoints = [
'admin-ajax.php',
'admin-post.php',
'async-upload.php',
'load-scripts.php',
'load-styles.php',
'ms-files.php',
'wp-cron.php',
];
return ! in_array( $pagenow, $raw_response_endpoints, true );
}
/**
* Load a template file.
*
* @param string $template_name The name of the template file to load.
* @throws None
* @return void
*/
public static function load_template($template_name)
{
require_once PXLBSADMINIFY_PATH . 'Inc/Admin/Frames/Templates/' . $template_name;
}
/**
* Multisite Check
* @param URL
* @return Admin_URL
*/
public static function maybe_network_admin_url($url) {
if ( is_network_admin() ) {
return network_admin_url($url);
}
return admin_url($url);
}
/**
* Sluggify a string and replace hyphens with underscores.
* @param string $string The string to sluggify.
* @return string The sluggified string with underscores.
*/
public static function sluggify_with_underscores($string) {
$slug = sanitize_title($string);
$slug = str_replace('-', '_', $slug);
return $slug;
}
}