PluginProbe
Portfolio Block – show off your work with stunning layouts / trunk
Portfolio Block – show off your work with stunning layouts vtrunk
2.1.5 2.1.3 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1
portfolio-block / includes / rootPlugin / ShortCode.php

ShortCode.php in Portfolio Block – show off your work with stunning layouts trunk, at includes/rootPlugin/ShortCode.php

54 lines 939 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace PFB;
3
4 class Shortcode
5 {
6 function __construct()
7 {
8 add_shortcode('pfb', [$this, 'onAddShortcode']);
9 }
10
11 function onAddShortcode($atts)
12 {
13 $post_id = $atts['id'];
14 $post = get_post($post_id);
15
16 if (!$post) {
17 return '';
18 }
19
20 if (post_password_required($post)) {
21 return get_the_password_form($post);
22 }
23
24 switch ($post->post_status) {
25 case 'publish':
26 return $this->displayContent($post);
27
28 case 'private':
29 if (current_user_can('read_private_posts')) {
30 return $this->displayContent($post);
31 }
32 return '';
33
34 case 'draft':
35 case 'pending':
36 case 'future':
37 if (current_user_can('edit_post', $post_id)) {
38 return $this->displayContent($post);
39 }
40 return '';
41
42 default:
43 return '';
44 }
45 }
46
47 function displayContent($post)
48 {
49 $blocks = parse_blocks($post->post_content);
50 return render_block($blocks[0]);
51
52 }
53
54 }