| @@ -7,143 +7,143 @@ | ||
| 7 | 7 | use WPDeveloper\BetterDocs\Traits\EditorHelper; |
| 8 | 8 | use WPDeveloper\BetterDocs\Admin\Customizer\Defaults; |
| 9 | 9 | |
| 10 | 10 | abstract class Shortcode extends Base { |
| 11 | - use EditorHelper; | |
| 11 | + use EditorHelper; | |
| 12 | 12 | |
| 13 | - /** | |
| 14 | - * Global Settings Reference. | |
| 15 | - * @var Settings | |
| 16 | - */ | |
| 17 | - protected $settings; | |
| 18 | - /** | |
| 19 | - * Global Query Reference. | |
| 20 | - * @var Query | |
| 21 | - */ | |
| 22 | - protected $query; | |
| 23 | - /** | |
| 24 | - * Utility Helper | |
| 25 | - * @var Helper | |
| 26 | - */ | |
| 27 | - protected $helper; | |
| 28 | - /** | |
| 29 | - * Customizer Defaults. | |
| 30 | - * @var Defaults | |
| 31 | - */ | |
| 32 | - protected $customizer; | |
| 13 | + /** | |
| 14 | + * Global Settings Reference. | |
| 15 | + * @var Settings | |
| 16 | + */ | |
| 17 | + protected $settings; | |
| 18 | + /** | |
| 19 | + * Global Query Reference. | |
| 20 | + * @var Query | |
| 21 | + */ | |
| 22 | + protected $query; | |
| 23 | + /** | |
| 24 | + * Utility Helper | |
| 25 | + * @var Helper | |
| 26 | + */ | |
| 27 | + protected $helper; | |
| 28 | + /** | |
| 29 | + * Customizer Defaults. | |
| 30 | + * @var Defaults | |
| 31 | + */ | |
| 32 | + protected $customizer; | |
| 33 | 33 | |
| 34 | - public function __construct( Settings $settings, Query $query, Helper $helper, Defaults $defaults ) { | |
| 35 | - $this->settings = $settings; | |
| 36 | - $this->query = $query; | |
| 37 | - $this->helper = $helper; | |
| 38 | - $this->customizer = $defaults; | |
| 34 | + public function __construct( Settings $settings, Query $query, Helper $helper, Defaults $defaults ) { | |
| 35 | + $this->settings = $settings; | |
| 36 | + $this->query = $query; | |
| 37 | + $this->helper = $helper; | |
| 38 | + $this->customizer = $defaults; | |
| 39 | 39 | |
| 40 | - // add_action( 'betterdocs_before_shortcode_load', [$this, 'enqueue_scripts'], 11, 1 ); | |
| 41 | - } | |
| 40 | + // add_action( 'betterdocs_before_shortcode_load', [$this, 'enqueue_scripts'], 11, 1 ); | |
| 41 | + } | |
| 42 | 42 | |
| 43 | - /** | |
| 44 | - * Shortcode Tag Name. | |
| 45 | - * @return string | |
| 46 | - */ | |
| 47 | - abstract public function get_name(); | |
| 43 | + /** | |
| 44 | + * Shortcode Tag Name. | |
| 45 | + * @return string | |
| 46 | + */ | |
| 47 | + abstract public function get_name(); | |
| 48 | 48 | |
| 49 | - /** | |
| 50 | - * A list of default attributes. | |
| 51 | - * @return array | |
| 52 | - */ | |
| 53 | - abstract public function default_attributes(); | |
| 49 | + /** | |
| 50 | + * A list of default attributes. | |
| 51 | + * @return array | |
| 52 | + */ | |
| 53 | + abstract public function default_attributes(); | |
| 54 | 54 | |
| 55 | - /** | |
| 56 | - * Individual shortcode render callback. | |
| 57 | - * @param mixed $atts | |
| 58 | - * @param mixed $content | |
| 59 | - * @return mixed | |
| 60 | - */ | |
| 61 | - abstract public function render( $atts, $content = null ); | |
| 55 | + /** | |
| 56 | + * Individual shortcode render callback. | |
| 57 | + * @param mixed $atts | |
| 58 | + * @param mixed $content | |
| 59 | + * @return mixed | |
| 60 | + */ | |
| 61 | + abstract public function render( $atts, $content = null ); | |
| 62 | 62 | |
| 63 | - public function get_style_depends() { | |
| 64 | - return []; | |
| 65 | - } | |
| 63 | + public function get_style_depends() { | |
| 64 | + return []; | |
| 65 | + } | |
| 66 | 66 | |
| 67 | - public function get_script_depends() { | |
| 68 | - return []; | |
| 69 | - } | |
| 67 | + public function get_script_depends() { | |
| 68 | + return []; | |
| 69 | + } | |
| 70 | 70 | |
| 71 | - public function enqueue_scripts() { | |
| 72 | - foreach ( $this->get_style_depends() as $handle ) { | |
| 73 | - wp_enqueue_style( $handle ); | |
| 74 | - } | |
| 71 | + public function enqueue_scripts() { | |
| 72 | + foreach ( $this->get_style_depends() as $handle ) { | |
| 73 | + wp_enqueue_style( $handle ); | |
| 74 | + } | |
| 75 | 75 | |
| 76 | - foreach ( $this->get_script_depends() as $handle ) { | |
| 77 | - wp_enqueue_script( $handle ); | |
| 78 | - } | |
| 79 | - } | |
| 76 | + foreach ( $this->get_script_depends() as $handle ) { | |
| 77 | + wp_enqueue_script( $handle ); | |
| 78 | + } | |
| 79 | + } | |
| 80 | 80 | |
| 81 | - /** | |
| 82 | - * Shortcode render callback, which is hooked with add_shortcode function. | |
| 83 | - * | |
| 84 | - * @param mixed $atts | |
| 85 | - * @param mixed $content | |
| 86 | - * | |
| 87 | - * @return bool|string | |
| 88 | - */ | |
| 89 | - final public function render_with_hooks( $atts, $content = null ) { | |
| 90 | - $this->enqueue_scripts(); | |
| 81 | + /** | |
| 82 | + * Shortcode render callback, which is hooked with add_shortcode function. | |
| 83 | + * | |
| 84 | + * @param mixed $atts | |
| 85 | + * @param mixed $content | |
| 86 | + * | |
| 87 | + * @return bool|string | |
| 88 | + */ | |
| 89 | + final public function render_with_hooks( $atts, $content = null ) { | |
| 90 | + $this->enqueue_scripts(); | |
| 91 | 91 | |
| 92 | - $atts = $this->remove_deprecated_attributes( $atts ); | |
| 93 | - $this->transform_attribute_types( $atts ); | |
| 92 | + $atts = $this->remove_deprecated_attributes( $atts ); | |
| 93 | + $this->transform_attribute_types( $atts ); | |
| 94 | 94 | |
| 95 | - $this->client_attributes = empty( $atts ) ? [] : $atts; | |
| 96 | - do_action( 'betterdocs_before_shortcode_load', $this ); | |
| 97 | - $this->set_attributes( $atts ); | |
| 95 | + $this->client_attributes = empty( $atts ) ? [] : $atts; | |
| 96 | + do_action( 'betterdocs_before_shortcode_load', $this ); | |
| 97 | + $this->set_attributes( $atts ); | |
| 98 | 98 | |
| 99 | - // reset attributes; | |
| 100 | - $this->reset_attributes(); | |
| 99 | + // reset attributes; | |
| 100 | + $this->reset_attributes(); | |
| 101 | 101 | |
| 102 | - do_action_ref_array( 'betterdocs_before_render', [ & $this, 'shortcode'] ); | |
| 103 | - ob_start(); | |
| 104 | - $this->render( $atts, $content = null ); | |
| 105 | - $content = ob_get_clean(); | |
| 102 | + do_action_ref_array( 'betterdocs_before_render', [ & $this, 'shortcode' ] ); | |
| 103 | + ob_start(); | |
| 104 | + $this->render( $atts, $content = null ); | |
| 105 | + $content = ob_get_clean(); | |
| 106 | 106 | |
| 107 | - do_action_ref_array( 'betterdocs_after_render', [ & $this, 'shortcode'] ); | |
| 107 | + do_action_ref_array( 'betterdocs_after_render', [ & $this, 'shortcode' ] ); | |
| 108 | 108 | |
| 109 | - return $content; | |
| 110 | - } | |
| 109 | + return $content; | |
| 110 | + } | |
| 111 | 111 | |
| 112 | - protected function transform_attribute_types( &$atts ) { | |
| 113 | - if ( is_array( $atts ) ) { | |
| 114 | - $_default_attributes = $this->default_attributes(); | |
| 112 | + protected function transform_attribute_types( &$atts ) { | |
| 113 | + if ( is_array( $atts ) ) { | |
| 114 | + $_default_attributes = $this->default_attributes(); | |
| 115 | 115 | |
| 116 | - foreach ( $atts as $key => $value ) { | |
| 117 | - if ( isset( $_default_attributes[$key] ) ) { | |
| 118 | - $type = gettype( $_default_attributes[$key] ); | |
| 116 | + foreach ( $atts as $key => $value ) { | |
| 117 | + if ( isset( $_default_attributes[ $key ] ) ) { | |
| 118 | + $type = gettype( $_default_attributes[ $key ] ); | |
| 119 | 119 | |
| 120 | - if ( $type === 'boolean' ) { | |
| 121 | - $atts[$key] = $atts[$key] == 'false' || $atts[$key] == '' ? false : true; | |
| 122 | - } | |
| 123 | - } | |
| 124 | - } | |
| 125 | - } | |
| 126 | - } | |
| 120 | + if ( $type === 'boolean' ) { | |
| 121 | + $atts[ $key ] = $atts[ $key ] == 'false' || $atts[ $key ] == '' ? false : true; | |
| 122 | + } | |
| 123 | + } | |
| 124 | + } | |
| 125 | + } | |
| 126 | + } | |
| 127 | 127 | |
| 128 | - /** | |
| 129 | - * This method is responsive for set shortcode attributes in a property. | |
| 130 | - * @param mixed $atts | |
| 131 | - * @return array | |
| 132 | - */ | |
| 133 | - private function set_attributes( $atts ) { | |
| 134 | - $this->attributes = shortcode_atts( | |
| 135 | - apply_filters( "betterdocs_shortcodes_default_atts", $this->default_attributes(), $this->get_name() ), | |
| 136 | - $atts | |
| 137 | - ); | |
| 128 | + /** | |
| 129 | + * This method is responsive for set shortcode attributes in a property. | |
| 130 | + * @param mixed $atts | |
| 131 | + * @return array | |
| 132 | + */ | |
| 133 | + private function set_attributes( $atts ) { | |
| 134 | + $this->attributes = shortcode_atts( | |
| 135 | + apply_filters( 'betterdocs_shortcodes_default_atts', $this->default_attributes(), $this->get_name() ), | |
| 136 | + $atts | |
| 137 | + ); | |
| 138 | 138 | |
| 139 | - return $this->attributes; | |
| 140 | - } | |
| 139 | + return $this->attributes; | |
| 140 | + } | |
| 141 | 141 | |
| 142 | - public function isset( $key, $value = null ) { | |
| 143 | - if ( null === $value ) { | |
| 144 | - return isset( $this->attributes[$key] ) && ! empty( $this->attributes[$key] ); | |
| 145 | - } | |
| 142 | + public function isset( $key, $value = null ) { | |
| 143 | + if ( null === $value ) { | |
| 144 | + return isset( $this->attributes[ $key ] ) && ! empty( $this->attributes[ $key ] ); | |
| 145 | + } | |
| 146 | 146 | |
| 147 | - return isset( $this->attributes[$key] ) && $this->attributes[$key] == $value; | |
| 148 | - } | |
| 147 | + return isset( $this->attributes[ $key ] ) && $this->attributes[ $key ] == $value; | |
| 148 | + } | |
| 149 | 149 | } |