first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,170 @@
<?php
/**
* Functions for Admin Conditionals
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Determines whether the current page is an popup maker admin page.
*
* @since 1.7.0
*
* @return bool
*/
function pum_is_admin_page() {
if ( ! is_admin() || ! did_action( 'wp_loaded' ) ) {
return false;
}
$typenow = pum_typenow();
$tests = [
'popup' === $typenow,
'popup_theme' === $typenow,
! empty( $GLOBALS['hook_suffix'] ) && in_array( $GLOBALS['hook_suffix'], PUM_Admin_Pages::$pages ),
];
return in_array( true, $tests );
}
/**
* Determines whether the current admin page is the All Popups page.
*
* @since 1.12
* @return bool True if current page is All Popups page.
*/
function pum_is_all_popups_page() {
$screen = get_current_screen();
$tests = [
pum_is_admin_page(),
'edit-popup' === $screen->id,
pum_typenow() === 'popup',
];
return ! in_array( false, $tests, true );
}
/**
* Determines whether the current admin page is the popup editor.
*
* @since 1.7.0
*
* @return bool
*/
function pum_is_popup_editor() {
global $pagenow;
$tests = [
is_admin(),
pum_is_admin_page(),
'popup' === pum_typenow(),
in_array( $pagenow, [ 'post-new.php', 'post.php' ] ),
];
return ! in_array( false, $tests );
}
/**
* Determines whether the current admin page is the popup theme editor.
*
* @since 1.7.0
*
* @return bool
*/
function pum_is_popup_theme_editor() {
global $pagenow;
$tests = [
is_admin(),
pum_is_admin_page(),
'popup_theme' === pum_typenow(),
in_array( $pagenow, [ 'post-new.php', 'post.php' ] ),
];
return ! in_array( false, $tests );
}
/**
* Determines whether the current admin page is the extensions page.
*
* @since 1.7.0
*
* @param null|string $key
*
* @return bool
*/
function pum_is_submenu_page( $key = null ) {
$tests = [
is_admin(),
pum_is_admin_page(),
! pum_is_popup_editor(),
! pum_is_popup_theme_editor(),
$key && ! empty( $GLOBALS['hook_suffix'] ) ? PUM_Admin_Pages::get_page( $key ) === $GLOBALS['hook_suffix'] : true,
! isset( $key ) && ! empty( $GLOBALS['hook_suffix'] ) ? in_array( $GLOBALS['hook_suffix'], PUM_Admin_Pages::$pages ) : true,
];
return ! in_array( false, $tests );
}
/**
* Determines whether the current admin page is the subscriptions page.
*
* @since 1.7.0
*
* @return bool
*/
function pum_is_subscriptions_page() {
return pum_is_submenu_page( 'subscriptions' );
}
/**
* Determines whether the current admin page is the extensions page.
*
* @since 1.7.0
*
* @return bool
*/
function pum_is_extensions_page() {
return pum_is_submenu_page( 'extensions' );
}
/**
* Determines whether the current admin page is the settings page.
*
* @since 1.7.0
*
* @return bool
*/
function pum_is_settings_page() {
return pum_is_submenu_page( 'settings' );
}
/**
* Determines whether the current admin page is the tools page.
*
* @since 1.7.0
*
* @return bool
*/
function pum_is_tools_page() {
return pum_is_submenu_page( 'tools' );
}
/**
* Determines whether the current admin page is the support page.
*
* @since 1.7.0
*
* @return bool
*/
function pum_is_support_page() {
return pum_is_submenu_page( 'support' );
}

View File

@@ -0,0 +1,81 @@
<?php
/**
* Functions for General Admin
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Gets the current admin screen post type.
*
* @return bool|string
*/
function pum_typenow() {
if ( ! empty( $GLOBALS['typenow'] ) ) {
return $GLOBALS['typenow'];
}
// when editing pages, $typenow isn't set until later!
// try to pick it up from the query string
if ( ! empty( $_GET['post_type'] ) ) {
return sanitize_text_field( $_GET['post_type'] );
} elseif ( ! empty( $_GET['post'] ) && $_GET['post'] > 0 ) {
$post = get_post( $_GET['post'] );
} elseif ( ! empty( $_POST['post_ID'] ) && $_POST['post_ID'] > 0 ) {
$post = get_post( $_POST['post_ID'] );
}
return isset( $post ) && is_object( $post ) && $post->ID > 0 ? $post->post_type : false;
}
/**
* Generates an Popup Maker admin URL based on the given type.
*
* @since 1.7.0
*
* @param string $type Optional. Type of admin URL. Accepts 'tools', 'settings'. Default empty
* @param array $query_args Optional. Query arguments to append to the admin URL. Default empty array.
*
* @return string Constructed admin URL.
*/
function pum_admin_url( $type = '', $query_args = [] ) {
$page = '';
$whitelist = PUM_Admin_Pages::$pages;
if ( in_array( $type, $whitelist, true ) ) {
$page = "pum-{$type}";
}
$admin_query_args = array_merge( [ 'page' => $page ], $query_args );
$url = add_query_arg( $admin_query_args, admin_url( 'edit.php?post_type=popup' ) );
/**
* Filters the Popup Maker admin URL.
*
* @param string $url Admin URL.
* @param string $type Admin URL type.
* @param array $query_args Query arguments originally passed to pum_admin_url().
*/
return apply_filters( 'pum_admin_url', $url, $type, $query_args );
}
/**
* @return array
*/
function pum_support_assist_args() {
return [
// Forces the dashboard to force logout any users.
'nouser' => true,
'fname' => wp_get_current_user()->first_name,
'lname' => wp_get_current_user()->last_name,
'email' => wp_get_current_user()->user_email,
'url' => home_url(),
];
}