Files

67 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2018-04-03 15:04:14 +03:00
<?php
namespace um\admin;
2023-11-03 17:31:18 +02:00
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
2018-04-03 15:04:14 +03:00
if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
/**
* Class Admin_Functions
* @package um\admin\core
*/
class Admin_Functions {
2018-11-21 14:01:18 +02:00
/**
* Check wp-admin nonce
*
* @param bool $action
*/
2023-11-03 17:31:18 +02:00
public function check_ajax_nonce( $action = false ) {
$nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
2018-11-21 14:01:18 +02:00
$action = empty( $action ) ? 'um-admin-nonce' : $action;
if ( ! wp_verify_nonce( $nonce, $action ) ) {
wp_send_json_error( esc_js( __( 'Wrong Nonce', 'ultimate-member' ) ) );
}
}
2018-04-03 15:04:14 +03:00
/**
* Boolean check if we're viewing UM backend
*
2023-11-17 17:25:47 +02:00
* @deprecated 2.8.0
2023-11-03 17:31:18 +02:00
*
2018-04-03 15:04:14 +03:00
* @return bool
*/
2023-11-03 17:31:18 +02:00
public function is_um_screen() {
2023-11-17 17:25:47 +02:00
_deprecated_function( __METHOD__, '2.8.0', 'UM()->admin()->screen()->is_own_screen()' );
2023-11-03 17:31:18 +02:00
return UM()->admin()->screen()->is_own_screen();
2018-04-03 15:04:14 +03:00
}
/**
* Check if current page load UM post type
*
2023-11-17 17:25:47 +02:00
* @deprecated 2.8.0
2023-11-03 17:31:18 +02:00
*
2018-04-03 15:04:14 +03:00
* @return bool
*/
2023-11-03 17:31:18 +02:00
public function is_plugin_post_type() {
2023-11-17 17:25:47 +02:00
_deprecated_function( __METHOD__, '2.8.0', 'UM()->admin()->screen()->is_own_post_type()' );
2023-11-03 17:31:18 +02:00
return UM()->admin()->screen()->is_own_post_type();
2018-04-03 15:04:14 +03:00
}
2018-04-04 15:12:30 +03:00
/**
* If page now show content with restricted post/taxonomy
*
2023-11-17 17:25:47 +02:00
* @deprecated 2.8.0
2023-11-03 17:31:18 +02:00
*
2018-04-04 15:12:30 +03:00
* @return bool
*/
2023-11-03 17:31:18 +02:00
public function is_restricted_entity() {
2023-11-17 17:25:47 +02:00
_deprecated_function( __METHOD__, '2.8.0', 'UM()->admin()->screen()->is_restricted_entity()' );
2023-11-03 17:31:18 +02:00
return UM()->admin()->screen()->is_restricted_entity();
2018-04-04 15:12:30 +03:00
}
2018-04-03 15:04:14 +03:00
}
}