PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.1
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 / link.php

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

63 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 Link extends Abstracts\Interpreter {
9 protected int $post_id;
10 protected string $field;
11
12 public function __construct( string $name, array $setting, bool $is_richtext = false ) {
13 parent::__construct( $name, $setting, $is_richtext );
14 $this->field = strval( $this->setting[0] ?? '' );
15 $this->post_id = get_the_ID();
16 }
17 public function content() : string {
18 switch ( $this->field ) {
19 case 'internal-url-content':
20 $this->content = get_permalink( $this->setting[2] );
21 break;
22
23 case 'internal-url-taxonomy':
24 $this->content = get_term_link( (int) $this->setting[2] );
25 break;
26
27 case 'internal-url-media':
28 $this->content = get_attachment_link( $this->setting[2] );
29 break;
30
31 case 'internal-url-author':
32 $this->content = get_author_posts_url( $this->setting[2] );
33 break;
34
35 case 'post-url':
36 $this->content = get_permalink( $this->post_id );
37 break;
38
39 case 'site-url':
40 $this->content = get_site_url();
41 break;
42
43 case 'author-url':
44 $this->content = get_author_posts_url( get_the_author_meta( 'ID' ) );
45 break;
46
47 case 'comments-url':
48 $this->content = get_comments_link( $this->post_id );
49 break;
50
51 case 'featured-image-file-url':
52 $this->content = get_the_post_thumbnail_url( $this->post_id, 'full' );
53 break;
54
55 case 'featured-image-attachment-url':
56 $attachment_id = get_post_meta( $this->post_id, '_thumbnail_id', true );
57 $this->content = $attachment_id ? get_permalink( $attachment_id ) : '';
58 break;
59 }//end switch
60 return $this->content;
61 }
62 }
63