| Server IP : 27.254.66.5 / Your IP : 216.73.217.39 Web Server : Apache/2 System : Linux cs82.hostneverdie.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 User : technic2 ( 1951) PHP Version : 7.4.30 Disable Function : apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd,exec, fp, fput, highlight_file, ini_alter, ini_restore, inject_code, passthru,phpAds_remoteInfo, phpAds_XmlRpc,phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid,posix_setuid, posix_setuid, posix_uname,proc_open,proc_close, proc_get_status, proc_nice, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, show_source,sleep,pcntl_exec,virtual,suexec,dbmopen,dl,symlink,disk_free_space,diskfreespace,leak MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/technic2/public_html/old-website/wp-content/plugins/popup-maker/classes/Admin/ |
Upload File : |
<?php
/*******************************************************************************
* Copyright (c) 2019, Code Atlantic LLC
******************************************************************************/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class PUM_Admin_Pages
*
* @since 1.7.0
*/
class PUM_Admin_Pages {
/**
* @var array
*/
public static $pages = array();
/**
*
*/
public static function init() {
add_action( 'admin_menu', array( __CLASS__, 'register_pages' ) );
add_action( 'admin_head', array( __CLASS__, 'reorder_admin_submenu' ) );
add_action( 'admin_menu', array( 'PUM_Admin_Extend', 'append_count_to_menu_item' ), 999 );
}
/**
* Returns the requested pages handle.
*
* @param $key
*
* @return bool|mixed
*/
public static function get_page( $key ) {
return isset( self::$pages[ $key ] ) ? self::$pages[ $key ] : false;
}
/**
* Creates the admin submenu pages under the Popup Maker menu and assigns their
* links to global variables
*/
public static function register_pages() {
$admin_pages = apply_filters( 'pum_admin_pages', array(
'subscribers' => array(
'page_title' => __( 'Subscribers', 'popup-maker' ),
'capability' => 'manage_options',
'callback' => array( 'PUM_Admin_Subscribers', 'page' ),
),
'settings' => array(
'page_title' => __( 'Settings', 'popup-maker' ),
'capability' => 'manage_options',
'callback' => array( 'PUM_Admin_Settings', 'page' ),
),
'extensions' => array(
'page_title' => __( 'Extend', 'popup-maker' ),
'capability' => 'edit_posts',
'callback' => array( 'PUM_Admin_Extend', 'page' ),
),
'support' => array(
'page_title' => __( 'Help & Support', 'popup-maker' ),
'capability' => 'edit_posts',
'callback' => array( 'PUM_Admin_Support', 'page' ),
),
'tools' => array(
'page_title' => __( 'Tools', 'popup-maker' ),
'capability' => 'manage_options',
'callback' => array( 'PUM_Admin_Tools', 'page' ),
),
) );
foreach ( $admin_pages as $key => $page ) {
$page = wp_parse_args( $page, array(
'parent_slug' => 'edit.php?post_type=popup',
'page_title' => '',
'menu_title' => '',
'capability' => 'manage_options',
'menu_slug' => '',
'callback' => '',
) );
// Backward compatibility.
$page['capability'] = apply_filters( 'popmake_admin_submenu_' . $key . '_capability', $page['capability'] );
if ( empty( $page['menu_slug'] ) ) {
$page['menu_slug'] = 'pum-' . $key;
}
if ( ! empty( $page['page_title'] ) && empty( $page['menu_title'] ) ) {
$page['menu_title'] = $page['page_title'];
} elseif ( ! empty( $page['menu_title'] ) && empty( $page['page_title'] ) ) {
$page['page_title'] = $page['menu_title'];
}
self::$pages[ $key ] = add_submenu_page( $page['parent_slug'], $page['page_title'], $page['menu_title'], $page['capability'], $page['menu_slug'], $page['callback'] );
// For backward compatibility.
$GLOBALS[ "popmake_" . $key . "_page" ] = self::$pages[ $key ];
}
// Add shortcut to theme editor from Appearance menu.
add_theme_page( __( 'Popup Themes', 'popup-maker' ), __( 'Popup Themes', 'popup-maker' ), 'edit_posts', 'edit.php?post_type=popup_theme' );
}
/**
* Submenu filter function. Tested with Wordpress 4.1.1
* Sort and order submenu positions to match our custom order.
*
* @since 1.4
*/
public static function reorder_admin_submenu() {
global $submenu;
if ( isset( $submenu['edit.php?post_type=popup'] ) ) {
// Sort the menu according to your preferences
usort( $submenu['edit.php?post_type=popup'], array( __CLASS__, 'reorder_submenu_array' ) );
}
}
/**
* Reorders the submenu by title.
*
* Forces $first_pages to load in order at the beginning of the menu
* and $last_pages to load in order at the end. All remaining menu items will
* go out in generic order.
*
* @since 1.4
*
* @param $a
* @param $b
*
* @return int
*/
public static function reorder_submenu_array( $a, $b ) {
$first_pages = apply_filters( 'pum_admin_submenu_first_pages', array(
__( 'All Popups', 'popup-maker' ),
__( 'Add New', 'popup-maker' ),
__( 'All Themes', 'popup-maker' ),
__( 'Categories', 'popup-maker' ),
__( 'Tags', 'popup-maker' ),
) );
$last_pages = apply_filters( 'pum_admin_submenu_last_pages', array(
__( 'Extend', 'popup-maker' ),
__( 'Settings', 'popup-maker' ),
__( 'Tools', 'popup-maker' ),
__( 'Support Forum', 'freemius' ),
__( 'Account', 'freemius' ),
__( 'Contact Us', 'freemius' ),
__( 'Help & Support', 'popup-maker' ),
) );
$a_val = strip_tags( $a[0], false );
$b_val = strip_tags( $b[0], false );
// Sort First Page Keys.
if ( in_array( $a_val, $first_pages ) && ! in_array( $b_val, $first_pages ) ) {
return - 1;
} elseif ( ! in_array( $a_val, $first_pages ) && in_array( $b_val, $first_pages ) ) {
return 1;
} elseif ( in_array( $a_val, $first_pages ) && in_array( $b_val, $first_pages ) ) {
$a_key = array_search( $a_val, $first_pages );
$b_key = array_search( $b_val, $first_pages );
return ( $a_key < $b_key ) ? - 1 : 1;
}
// Sort Last Page Keys.
if ( in_array( $a_val, $last_pages ) && ! in_array( $b_val, $last_pages ) ) {
return 1;
} elseif ( ! in_array( $a_val, $last_pages ) && in_array( $b_val, $last_pages ) ) {
return - 1;
} elseif ( in_array( $a_val, $last_pages ) && in_array( $b_val, $last_pages ) ) {
$a_key = array_search( $a_val, $last_pages );
$b_key = array_search( $b_val, $last_pages );
return ( $a_key < $b_key ) ? - 1 : 1;
}
// Sort remaining keys
return $a > $b ? 1 : - 1;
}
}