balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

user.php (1964B)


      1 <?php
      2 namespace Elementor\Modules\System_Info\Reporters;
      3 
      4 if ( ! defined( 'ABSPATH' ) ) {
      5 	exit; // Exit if accessed directly.
      6 }
      7 
      8 /**
      9  * Elementor user report.
     10  *
     11  * Elementor system report handler class responsible for generating a report for
     12  * the user.
     13  *
     14  * @since 1.0.0
     15  */
     16 class User extends Base {
     17 
     18 	public function is_enabled() {
     19 		return (bool) wp_get_current_user()->ID;
     20 	}
     21 
     22 	/**
     23 	 * Get user reporter title.
     24 	 *
     25 	 * Retrieve user reporter title.
     26 	 *
     27 	 * @since 1.0.0
     28 	 * @access public
     29 	 *
     30 	 * @return string Reporter title.
     31 	 */
     32 	public function get_title() {
     33 		return 'User';
     34 	}
     35 
     36 	/**
     37 	 * Get user report fields.
     38 	 *
     39 	 * Retrieve the required fields for the user report.
     40 	 *
     41 	 * @since 1.0.0
     42 	 * @access public
     43 	 *
     44 	 * @return array Required report fields with field ID and field label.
     45 	 */
     46 	public function get_fields() {
     47 		return [
     48 			'role' => 'Role',
     49 			'locale' => 'WP Profile lang',
     50 			'agent' => 'User Agent',
     51 		];
     52 	}
     53 
     54 	/**
     55 	 * Get user role.
     56 	 *
     57 	 * Retrieve the user role.
     58 	 *
     59 	 * @since 1.0.0
     60 	 * @access public
     61 	 *
     62 	 * @return array {
     63 	 *    Report data.
     64 	 *
     65 	 *    @type string $value The user role.
     66 	 * }
     67 	 */
     68 	public function get_role() {
     69 		$role = null;
     70 
     71 		$current_user = wp_get_current_user();
     72 		if ( ! empty( $current_user->roles ) ) {
     73 			$role = $current_user->roles[0];
     74 		}
     75 
     76 		return [
     77 			'value' => $role,
     78 		];
     79 	}
     80 
     81 	/**
     82 	 * Get user profile language.
     83 	 *
     84 	 * Retrieve the user profile language.
     85 	 *
     86 	 * @since 1.0.0
     87 	 * @access public
     88 	 *
     89 	 * @return array {
     90 	 *    Report data.
     91 	 *
     92 	 *    @type string $value User profile language.
     93 	 * }
     94 	 */
     95 	public function get_locale() {
     96 		return [
     97 			'value' => get_locale(),
     98 		];
     99 	}
    100 
    101 	/**
    102 	 * Get user agent.
    103 	 *
    104 	 * Retrieve user agent.
    105 	 *
    106 	 * @since 1.0.0
    107 	 * @access public
    108 	 *
    109 	 * @return array {
    110 	 *    Report data.
    111 	 *
    112 	 *    @type string $value HTTP user agent.
    113 	 * }
    114 	 */
    115 	public function get_agent() {
    116 		return [
    117 			'value' => esc_html( $_SERVER['HTTP_USER_AGENT'] ),
    118 		];
    119 	}
    120 }