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 / image.php

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

38 lines 1.0 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 Image extends Abstracts\Interpreter {
9 protected string $field;
10
11 public function __construct( string $name, array $setting, bool $is_richtext = false ) {
12 parent::__construct( $name, $setting, $is_richtext );
13 $this->field = strval( $this->setting[0] ?? '' );
14 }
15 public function content() : string {
16
17 switch ( $this->field ) {
18 case 'featured-image':
19 $this->content = get_the_post_thumbnail_url( get_the_ID(), 'full' );
20 break;
21
22 case 'site-logo':
23 $this->content = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' )[0] ?? '';
24 break;
25
26 case 'author-profile-picture':
27 $author_id = get_post_field( 'post_author', get_the_ID() );
28 $this->content = get_avatar_url( $author_id );
29 break;
30
31 case 'user-profile-picture':
32 $this->content = is_user_logged_in() ? get_avatar_url( get_current_user_id() ) : '';
33 break;
34 }
35 return $this->content;
36 }
37 }
38