PluginProbe
Brizy – Page Builder / trunk
Brizy – Page Builder vtrunk
2.8.23 2.8.22 2.8.21 2.8.20 2.8.19 2.8.18 2.8.17 2.8.16 2.8.15 2.8.14 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.15 2.7.16 All 188 releases
brizy / shortcode / abstract-shortcode.php

abstract-shortcode.php in Brizy – Page Builder trunk, at shortcode/abstract-shortcode.php

77 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 abstract class Brizy_Shortcode_AbstractShortcode {
5
6 const BRIZY_SHORTCODES_PREFIX = 'brizy_';
7 const BRIZY_SHORTCODES_ACTION_PREFIX = 'brizy_shortcode_';
8 const BRIZY_SHORTCODES_FILTER_PREFIX = 'brizy_shortcode_filter_';
9
10 /**
11 * Get shortcode name
12 *
13 * @return string
14 */
15 abstract public function getName();
16
17 /**
18 * @param $atts
19 * @param null $content
20 *
21 * @return mixed
22 */
23 abstract public function render( $atts, $content = null );
24
25 /**
26 * @param $atts
27 * @param null $content
28 *
29 * @return string
30 */
31 final public function masterRender( $atts, $content = null ) {
32 ob_start();
33
34 do_action( $this->getBeforeActionName() );
35
36 echo apply_filters( $this->getFilterName(), $this->render( $atts, $content ) );
37
38 do_action( $this->getAfterActionName() );
39
40 return ob_get_clean();
41 }
42
43 /**
44 * Brizy_Shortcode_AbstractShortcode constructor.
45 */
46 public function __construct() {
47 add_shortcode( $this->getShortCodeId(), array( $this, 'masterRender' ) );
48 }
49
50 /**
51 * @return string
52 */
53 private function getShortCodeId() {
54 return self::BRIZY_SHORTCODES_PREFIX . $this->getName();
55 }
56
57 /**
58 * @return string
59 */
60 private function getBeforeActionName() {
61 return self::BRIZY_SHORTCODES_ACTION_PREFIX . 'before_' . $this->getName();
62 }
63
64 /**
65 * @return string
66 */
67 private function getAfterActionName() {
68 return self::BRIZY_SHORTCODES_ACTION_PREFIX . 'after_' . $this->getName();
69 }
70
71 /**
72 * @return string
73 */
74 private function getFilterName() {
75 return self::BRIZY_SHORTCODES_FILTER_PREFIX . $this->getName();
76 }
77 }