post_type_object( $post_type );
if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) {
return false;
}
return true;
}
/**
* Get user notices.
*
* Retrieve the list of notices for the current user.
*
* @since 2.0.0
* @access public
* @static
*
* @return array A list of user notices.
*/
public static function get_user_notices() {
$notices = get_user_meta( get_current_user_id(), self::ADMIN_NOTICES_KEY, true );
return is_array( $notices ) ? $notices : [];
}
/**
* Is admin notice viewed.
*
* Whether the admin notice was viewed by the current user.
*
* @since 1.0.0
* @access public
* @static
*
* @param int $notice_id The notice ID.
*
* @return bool Whether the admin notice was viewed by the user.
*/
public static function is_user_notice_viewed( $notice_id ) {
$notices = self::get_user_notices();
if ( empty( $notices[ $notice_id ] ) ) {
return false;
}
// BC: Handles old structure ( `[ 'notice_id' => 'true' ]` ).
if ( 'true' === $notices[ $notice_id ] ) {
return true;
}
return $notices[ $notice_id ]['is_viewed'] ?? false;
}
/**
* Checks whether the current user is allowed to upload JSON files.
*
* Note: The 'json-upload' capability is managed by the Role Manager as a part of its blacklist restrictions.
* In this context, we are negating the user's permission check to use it as a whitelist, allowing uploads.
*
* @return bool Whether the current user can upload JSON files.
*/
public static function is_current_user_can_upload_json() {
return current_user_can( 'manage_options' ) || ! Plugin::instance()->role_manager->user_can( 'json-upload' );
}
public static function is_current_user_can_use_custom_html() {
return current_user_can( 'manage_options' ) || ! Plugin::instance()->role_manager->user_can( 'custom-html' );
}
/**
* Set admin notice as viewed.
*
* Flag the admin notice as viewed by the current user, using an authenticated ajax request.
*
* Fired by `wp_ajax_elementor_set_admin_notice_viewed` action.
*
* @since 1.0.0
* @access public
* @static
*/
public static function ajax_set_admin_notice_viewed() {
// phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
$notice_id = Utils::get_super_global_value( $_REQUEST, 'notice_id' );
if ( ! $notice_id ) {
wp_die();
}
self::set_user_notice( $notice_id );
if ( ! wp_doing_ajax() ) {
wp_safe_redirect( admin_url() );
die;
}
wp_die();
}
/**
* @param $notice_id
* @param $is_viewed
* @param $meta
*
* @return void
*/
public static function set_user_notice( $notice_id, $is_viewed = true, $meta = null ) {
$notices = self::get_user_notices();
if ( ! is_array( $meta ) ) {
$meta = $notices[ $notice_id ]['meta'] ?? [];
}
$notices[ $notice_id ] = [
'is_viewed' => $is_viewed,
'meta' => $meta,
];
update_user_meta( get_current_user_id(), self::ADMIN_NOTICES_KEY, $notices );
}
/**
* @since 2.1.0
* @access public
* @static
*/
public static function set_introduction_viewed( array $data ) {
$user_introduction_meta = self::get_introduction_meta();
$user_introduction_meta[ $data['introductionKey'] ] = true;
update_user_meta( get_current_user_id(), self::INTRODUCTION_KEY, $user_introduction_meta );
}
/**
* @throws \Exception
*/
public static function register_as_beta_tester( array $data ) {
if ( ! current_user_can( 'install_plugins' ) ) {
throw new \Exception( __( 'You do not have permission to install plugins.', 'elementor' ) );
}
update_user_meta( get_current_user_id(), self::BETA_TESTER_META_KEY, true );
$response = wp_safe_remote_post(
self::BETA_TESTER_API_URL,
[
'timeout' => 25,
'body' => [
'api_version' => ELEMENTOR_VERSION,
'site_lang' => get_bloginfo( 'language' ),
'beta_tester_email' => $data['betaTesterEmail'],
],
]
);
$response_code = (int) wp_remote_retrieve_response_code( $response );
if ( 200 === $response_code ) {
self::set_introduction_viewed( [
'introductionKey' => Beta_Testers::BETA_TESTER_SIGNUP,
] );
}
}
/**
* @param string $key
*
* @return array|mixed|string
* @since 2.1.0
* @access public
* @static
*/
public static function get_introduction_meta( $key = '' ) {
$user_introduction_meta = get_user_meta( get_current_user_id(), self::INTRODUCTION_KEY, true );
if ( ! $user_introduction_meta ) {
$user_introduction_meta = [];
}
if ( $key ) {
return empty( $user_introduction_meta[ $key ] ) ? '' : $user_introduction_meta[ $key ];
}
return $user_introduction_meta;
}
/**
* Get a user option with default value as fallback.
*
* @param string $option - Option key.
* @param int $user_id - User ID
* @param mixed $default - Default fallback value.
*
* @return mixed
*/
public static function get_user_option_with_default( $option, $user_id, $default ) {
$value = get_user_option( $option, $user_id );
return ( false === $value ) ? $default : $value;
}
/**
* Get dismissed editor notices.
*
* Retrieve the list of dismissed editor notices for the current user.
*
* @since 3.19.0
* @access public
* @static
*
* @return array A list of dismissed editor notices.
*/
public static function get_dismissed_editor_notices() {
$notices = get_user_meta( get_current_user_id(), self::DISMISSED_EDITOR_NOTICES_KEY, true );
return is_array( $notices ) ? $notices : [];
}
/**
* Set dismissed editor notices for the current user.
*
* @since 3.19.0
* @access public
* @static
*
* @param array $data Editor notices.
*
* @return void
*/
public static function set_dismissed_editor_notices( array $data ) {
$editor_notices = self::get_dismissed_editor_notices();
if ( ! in_array( $data['dismissId'], $editor_notices, true ) ) {
$editor_notices[] = $data['dismissId'];
update_user_meta( get_current_user_id(), self::DISMISSED_EDITOR_NOTICES_KEY, $editor_notices );
}
}
}
Fatal error: Uncaught Error: Class 'Elementor\User' not found in /home/sportuga/public_html/wp-content/plugins/elementor/includes/plugin.php:743
Stack trace:
#0 /home/sportuga/public_html/wp-content/plugins/elementor/includes/plugin.php(647): Elementor\Plugin->init_components()
#1 /home/sportuga/public_html/wp-includes/class-wp-hook.php(324): Elementor\Plugin->init('')
#2 /home/sportuga/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#3 /home/sportuga/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#4 /home/sportuga/public_html/wp-settings.php(695): do_action('init')
#5 /home/sportuga/public_html/wp-config.php(102): require_once('/home/sportuga/...')
#6 /home/sportuga/public_html/wp-load.php(50): require_once('/home/sportuga/...')
#7 /home/sportuga/public_html/wp-blog-header.php(13): require_once('/home/sportuga/...')
#8 /home/sportuga/public_html/index.php(17): require('/home/sportuga/...')
#9 {main}
thrown in /home/sportuga/public_html/wp-content/plugins/elementor/includes/plugin.php on line 743