PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.8
4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 4.2.1 All 138 releases
learnpress / inc / abstracts / abstract-shortcode.php

abstract-shortcode.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.3.8, at inc/abstracts/abstract-shortcode.php

85 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 * Abstract Class for Shortcodes.
4 *
5 * @author ThimPress
6 * @category Abstract
7 * @package Learnpress/Classes
8 * @version 3.0.0
9 */
10
11 /**
12 * Prevent loading this file directly
13 */
14 defined( 'ABSPATH' ) || exit();
15
16
17 if ( ! class_exists( 'LP_Abstract_Shortcode' ) ) {
18
19 /**
20 * Class LP_Abstract_Shortcode
21 */
22 abstract class LP_Abstract_Shortcode {
23 /**
24 * Shortcode attributes.
25 *
26 * @var array|null
27 */
28 protected $_atts = null;
29
30 /**
31 * @var string
32 */
33 protected $_name = '';
34
35 /**
36 * LP_Abstract_Shortcode constructor.
37 *
38 * @param mixed $atts
39 */
40 public function __construct( $atts = '' ) {
41 $this->_atts = (array) $atts;
42 }
43
44 /**
45 * Return content of the shortcode.
46 *
47 * @return mixed
48 */
49 abstract function output();
50
51 /**
52 * Get shortcode attributes.
53 *
54 * @return mixed
55 */
56 public function get_atts() {
57 return apply_filters( 'learn-press/shortcode-' . $this->get_name() . '-atts', $this->_atts );
58 }
59
60 /**
61 * Get default name of shortcode (without prefix learn_press_) if it is not set.
62 *
63 * @return mixed|string
64 */
65 public function get_name() {
66 if ( ! $this->_name ) {
67 if ( preg_match( '~^lp_(.*)_shortcode$~i', get_class( $this ), $m ) ) {
68 $this->_name = preg_replace( '~_~', '-', strtolower( $m[1] ) );
69 }
70 }
71
72 return $this->_name;
73 }
74
75 /**
76 * Convert to string
77 *
78 * @return mixed
79 */
80 public function __toString() {
81 return $this->output();
82 }
83 }
84 }
85