PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.8.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.8.0
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / includes / frontend / dynamic-content / interpreters / user-info.php

user-info.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.8.0, at includes/frontend/dynamic-content/interpreters/user-info.php

58 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Frontend\DynamicContent\Interpreters;
3
4 use ABlocks\Helper;
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8 class UserInfo extends Abstracts\Interpreter {
9 protected string $field;
10 protected string $pre;
11 protected string $post;
12 protected string $default;
13
14 public function __construct( string $name, array $setting, bool $is_richtext = false ) {
15 parent::__construct( $name, $setting, $is_richtext );
16 $this->field = strval( $this->setting[0] ?? '' );
17 $this->pre = strval( $this->setting[3] ?? '' );
18 $this->post = strval( $this->setting[4] ?? '' );
19 $this->default = strval( $this->setting[5] ?? '' );
20 }
21 public function content() : string {
22 if ( ! is_user_logged_in() ) {
23 return '';
24 }
25 $current_user = wp_get_current_user();
26 switch ( $this->field ) {
27 case 'id':
28 $this->content = $current_user->ID;
29 break;
30 case 'display-name':
31 $this->content = $current_user->display_name;
32 break;
33 case 'username':
34 $this->content = $current_user->user_login;
35 break;
36 case 'first-name':
37 $this->content = $current_user->first_name;
38 break;
39 case 'last-name':
40 $this->content = $current_user->last_name;
41 break;
42 case 'bio':
43 $this->content = $current_user->description;
44 break;
45 case 'email':
46 $this->content = $current_user->user_email;
47 break;
48 case 'website':
49 $this->content = $current_user->user_url;
50 break;
51 case 'user-meta':
52 $this->content = get_user_meta( $current_user->ID, $this->setting[1] ?? '', true );
53 break;
54 }//end switch
55 return $this->pre . ( $this->content === '' ? $this->default : $this->content ) . $this->post;
56 }
57 }
58