| @@ -179,7 +179,7 @@ | ||
| 179 | 179 | Assert\that( $view )->string()->notEmpty()->file(); | 
| 180 | 180 | |
| 181 | 181 | ob_start(); | 
| 182 | - include( $this->config['view'] ); | |
| 182 | + include( $this->config[ 'view' ] ); | |
| 183 | 183 | |
| 184 | 184 | return ob_get_clean(); | 
| 185 | 185 | } | 
| @@ -29,7 +29,7 @@ discard block | ||
| 29 | 29 | * @package BrightNucleus\Shortcode | 
| 30 | 30 | * @author Alain Schlesser <[email protected]> | 
| 31 | 31 | */ | 
| 32 | -class Shortcode implements ShortcodeInterface {
 | |
| 32 | +class Shortcode implements ShortcodeInterface { | |
| 33 | 33 | |
| 34 | 34 | use ConfigTrait; | 
| 35 | 35 | |
| @@ -88,7 +88,7 @@ discard block | ||
| 88 | 88 | ConfigInterface $config, | 
| 89 | 89 | ShortcodeAttsParser $atts_parser, | 
| 90 | 90 | DependencyManager $dependencies = null | 
| 91 | -	) {
 | |
| 91 | +	) { | |
| 92 | 92 | |
| 93 | 93 | Assert\that( $shortcode_tag )->string()->notEmpty(); | 
| 94 | 94 | |
| @@ -107,8 +107,8 @@ discard block | ||
| 107 | 107 | * @param mixed $context Optional. Arguments to pass on to the Registrable. | 
| 108 | 108 | * @return void | 
| 109 | 109 | */ | 
| 110 | -	public function register( $context = null ) {
 | |
| 111 | -		if ( ! $this->is_needed( $context ) ) {
 | |
| 110 | +	public function register( $context = null ) { | |
| 111 | +		if ( ! $this->is_needed( $context ) ) { | |
| 112 | 112 | return; | 
| 113 | 113 | } | 
| 114 | 114 | $this->context = $context; | 
| @@ -124,13 +124,13 @@ discard block | ||
| 124 | 124 | * @param mixed $context Data about the context in which the call is made. | 
| 125 | 125 | * @return boolean Whether the shortcode is needed or not. | 
| 126 | 126 | */ | 
| 127 | -	protected function is_needed( $context = null ) {
 | |
| 127 | +	protected function is_needed( $context = null ) { | |
| 128 | 128 | |
| 129 | 129 | $is_needed = $this->hasConfigKey( 'is_needed' ) | 
| 130 | 130 | ? $this->getConfigKey( 'is_needed' ) | 
| 131 | 131 | : false; | 
| 132 | 132 | |
| 133 | -		if ( is_callable( $is_needed ) ) {
 | |
| 133 | +		if ( is_callable( $is_needed ) ) { | |
| 134 | 134 | return $is_needed( $context ); | 
| 135 | 135 | } | 
| 136 | 136 | |
| @@ -144,7 +144,7 @@ discard block | ||
| 144 | 144 | * | 
| 145 | 145 | * @return string Shortcode tag. | 
| 146 | 146 | */ | 
| 147 | -	public function get_tag() {
 | |
| 147 | +	public function get_tag() { | |
| 148 | 148 | return (string) $this->shortcode_tag; | 
| 149 | 149 | } | 
| 150 | 150 | |
| @@ -163,15 +163,15 @@ discard block | ||
| 163 | 163 | * render. | 
| 164 | 164 | * @return string The shortcode's HTML output. | 
| 165 | 165 | */ | 
| 166 | -	public function render( $atts, $content = null, $tag = null ) {
 | |
| 166 | +	public function render( $atts, $content = null, $tag = null ) { | |
| 167 | 167 | $context = $this->context; | 
| 168 | 168 | $atts = $this->atts_parser->parse_atts( $atts, $this->get_tag() ); | 
| 169 | 169 | |
| 170 | -		if ( $this->dependencies ) {
 | |
| 170 | +		if ( $this->dependencies ) { | |
| 171 | 171 | $this->dependencies->enqueue( $atts ); | 
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | -		if ( ! $this->hasConfigKey( 'view' ) ) {
 | |
| 174 | +		if ( ! $this->hasConfigKey( 'view' ) ) { | |
| 175 | 175 | return ''; | 
| 176 | 176 | } | 
| 177 | 177 | $view = $this->getConfigKey( 'view' ); | 
| @@ -193,7 +193,7 @@ discard block | ||
| 193 | 193 | * @param string|null $content Inner content to pass to the shortcode. | 
| 194 | 194 | * @return string|false Rendered HTML. | 
| 195 | 195 | */ | 
| 196 | -	public function do_this( array $atts = [ ], $content = null ) {
 | |
| 196 | +	public function do_this( array $atts = [ ], $content = null ) { | |
| 197 | 197 | \BrightNucleus\Shortcode\do_tag( $this->get_tag(), $atts, $content ); | 
| 198 | 198 | } | 
| 199 | 199 | } | 
| @@ -21,7 +21,7 @@ | ||
| 21 | 21 | * @package BrightNucleus\Shortcode | 
| 22 | 22 | * @author Alain Schlesser <[email protected]> | 
| 23 | 23 | */ | 
| 24 | -interface ShortcodeInterface extends Registerable {
 | |
| 24 | +interface ShortcodeInterface extends Registerable { | |
| 25 | 25 | |
| 26 | 26 | /** | 
| 27 | 27 | * Render the shortcode. | 
| @@ -123,7 +123,7 @@ discard block | ||
| 123 | 123 | $atts_parser = new $shortcode_atts_parser( | 
| 124 | 124 | $this->config->getSubConfig( $tag ) | 
| 125 | 125 | ); | 
| 126 | - $this->shortcodes[] = new $shortcode_class( | |
| 126 | + $this->shortcodes[ ] = new $shortcode_class( | |
| 127 | 127 | $tag, | 
| 128 | 128 | $this->config->getSubConfig( $tag ), | 
| 129 | 129 | $atts_parser, | 
| @@ -176,7 +176,7 @@ discard block | ||
| 176 | 176 |  	protected function init_shortcode_ui( $tag ) {
 | 
| 177 | 177 | $shortcode_ui_class = $this->get_shortcode_ui_class( $tag ); | 
| 178 | 178 | |
| 179 | - $this->shortcode_uis[] = new $shortcode_ui_class( | |
| 179 | + $this->shortcode_uis[ ] = new $shortcode_ui_class( | |
| 180 | 180 | $tag, | 
| 181 | 181 | $this->config->getSubConfig( $tag, self::KEY_UI ), | 
| 182 | 182 | $this->dependencies | 
| @@ -208,7 +208,7 @@ discard block | ||
| 208 | 208 | */ | 
| 209 | 209 |  	public function register( $context = null ) {
 | 
| 210 | 210 | $context = $this->validate_context( $context ); | 
| 211 | - $context['page_template'] = $this->get_page_template(); | |
| 211 | + $context[ 'page_template' ] = $this->get_page_template(); | |
| 212 | 212 | |
| 213 | 213 | array_walk( $this->shortcodes, | 
| 214 | 214 |  			function ( $shortcode ) use ( $context ) {
 | 
| @@ -27,7 +27,7 @@ discard block | ||
| 27 | 27 | * @package BrightNucleus\Shortcode | 
| 28 | 28 | * @author Alain Schlesser <[email protected]> | 
| 29 | 29 | */ | 
| 30 | -class ShortcodeManager implements ShortcodeManagerInterface {
 | |
| 30 | +class ShortcodeManager implements ShortcodeManagerInterface { | |
| 31 | 31 | |
| 32 | 32 | use ConfigTrait; | 
| 33 | 33 | |
| @@ -91,7 +91,7 @@ discard block | ||
| 91 | 91 | public function __construct( | 
| 92 | 92 | ConfigInterface $config, | 
| 93 | 93 | DependencyManager $dependencies = null | 
| 94 | -	) {
 | |
| 94 | +	) { | |
| 95 | 95 | $this->processConfig( $config ); | 
| 96 | 96 | $this->dependencies = $dependencies; | 
| 97 | 97 | |
| @@ -103,8 +103,8 @@ discard block | ||
| 103 | 103 | * | 
| 104 | 104 | * @since 0.1.0 | 
| 105 | 105 | */ | 
| 106 | -	protected function init_shortcodes() {
 | |
| 107 | -		foreach ( $this->getConfigKeys() as $tag ) {
 | |
| 106 | +	protected function init_shortcodes() { | |
| 107 | +		foreach ( $this->getConfigKeys() as $tag ) { | |
| 108 | 108 | $this->init_shortcode( $tag ); | 
| 109 | 109 | } | 
| 110 | 110 | } | 
| @@ -116,7 +116,7 @@ discard block | ||
| 116 | 116 | * | 
| 117 | 117 | * @param string $tag The tag of the shortcode to register. | 
| 118 | 118 | */ | 
| 119 | -	protected function init_shortcode( $tag ) {
 | |
| 119 | +	protected function init_shortcode( $tag ) { | |
| 120 | 120 | $shortcode_class = $this->get_shortcode_class( $tag ); | 
| 121 | 121 | $shortcode_atts_parser = $this->get_shortcode_atts_parser_class( $tag ); | 
| 122 | 122 | |
| @@ -130,7 +130,7 @@ discard block | ||
| 130 | 130 | $this->dependencies | 
| 131 | 131 | ); | 
| 132 | 132 | |
| 133 | -		if ( $this->hasConfigKey( $tag, self::KEY_UI ) ) {
 | |
| 133 | +		if ( $this->hasConfigKey( $tag, self::KEY_UI ) ) { | |
| 134 | 134 | $this->init_shortcode_ui( $tag ); | 
| 135 | 135 | } | 
| 136 | 136 | } | 
| @@ -143,7 +143,7 @@ discard block | ||
| 143 | 143 | * @param string $tag Shortcode tag to get the class for. | 
| 144 | 144 | * @return string Class name of the Shortcode. | 
| 145 | 145 | */ | 
| 146 | -	protected function get_shortcode_class( $tag ) {
 | |
| 146 | +	protected function get_shortcode_class( $tag ) { | |
| 147 | 147 | $shortcode_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_CLASS ) | 
| 148 | 148 | ? $this->getConfigKey( $tag, self::KEY_CUSTOM_CLASS ) | 
| 149 | 149 | : self::DEFAULT_SHORTCODE; | 
| @@ -159,7 +159,7 @@ discard block | ||
| 159 | 159 | * @param string $tag Shortcode tag to get the class for. | 
| 160 | 160 | * @return string Class name of the ShortcodeAttsParser. | 
| 161 | 161 | */ | 
| 162 | -	protected function get_shortcode_atts_parser_class( $tag ) {
 | |
| 162 | +	protected function get_shortcode_atts_parser_class( $tag ) { | |
| 163 | 163 | $atts_parser = $this->hasConfigKey( $tag, self::KEY_CUSTOM_ATTS_PARSER ) | 
| 164 | 164 | ? $this->getConfigKey( $tag, self::KEY_CUSTOM_ATTS_PARSER ) | 
| 165 | 165 | : self::DEFAULT_SHORTCODE_ATTS_PARSER; | 
| @@ -173,7 +173,7 @@ discard block | ||
| 173 | 173 | * | 
| 174 | 174 | * @param string $tag The tag of the shortcode to register the UI for. | 
| 175 | 175 | */ | 
| 176 | -	protected function init_shortcode_ui( $tag ) {
 | |
| 176 | +	protected function init_shortcode_ui( $tag ) { | |
| 177 | 177 | $shortcode_ui_class = $this->get_shortcode_ui_class( $tag ); | 
| 178 | 178 | |
| 179 | 179 | $this->shortcode_uis[] = new $shortcode_ui_class( | 
| @@ -191,7 +191,7 @@ discard block | ||
| 191 | 191 | * @param string $tag Configuration settings. | 
| 192 | 192 | * @return string Class name of the ShortcodeUI. | 
| 193 | 193 | */ | 
| 194 | -	protected function get_shortcode_ui_class( $tag ) {
 | |
| 194 | +	protected function get_shortcode_ui_class( $tag ) { | |
| 195 | 195 | $ui_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_UI ) | 
| 196 | 196 | ? $this->getConfigKey( $tag, self::KEY_CUSTOM_UI ) | 
| 197 | 197 | : self::DEFAULT_SHORTCODE_UI; | 
| @@ -206,12 +206,12 @@ discard block | ||
| 206 | 206 | * @param mixed $context Optional. Context information to pass to shortcode. | 
| 207 | 207 | * @return void | 
| 208 | 208 | */ | 
| 209 | -	public function register( $context = null ) {
 | |
| 209 | +	public function register( $context = null ) { | |
| 210 | 210 | $context = $this->validate_context( $context ); | 
| 211 | 211 | $context['page_template'] = $this->get_page_template(); | 
| 212 | 212 | |
| 213 | 213 | array_walk( $this->shortcodes, | 
| 214 | -			function ( $shortcode ) use ( $context ) {
 | |
| 214 | +			function ( $shortcode ) use ( $context ) { | |
| 215 | 215 | /** @var ShortcodeInterface $shortcode */ | 
| 216 | 216 | $shortcode->register( $context ); | 
| 217 | 217 | } ); | 
| @@ -231,8 +231,8 @@ discard block | ||
| 231 | 231 | * @param mixed $context The context as passed in by WordPress. | 
| 232 | 232 | * @return array Validated context. | 
| 233 | 233 | */ | 
| 234 | -	protected function validate_context( $context ) {
 | |
| 235 | -		if ( is_string( $context ) ) {
 | |
| 234 | +	protected function validate_context( $context ) { | |
| 235 | +		if ( is_string( $context ) ) { | |
| 236 | 236 | return [ 'wp_context' => $context ]; | 
| 237 | 237 | } | 
| 238 | 238 | return (array) $context; | 
| @@ -245,7 +245,7 @@ discard block | ||
| 245 | 245 | * | 
| 246 | 246 | * @return string Name of the page template. | 
| 247 | 247 | */ | 
| 248 | -	protected function get_page_template() {
 | |
| 248 | +	protected function get_page_template() { | |
| 249 | 249 | $template = str_replace( | 
| 250 | 250 | \trailingslashit( \get_stylesheet_directory() ), | 
| 251 | 251 | '', | 
| @@ -259,12 +259,12 @@ discard block | ||
| 259 | 259 | * | 
| 260 | 260 | * @since 0.1.0 | 
| 261 | 261 | */ | 
| 262 | -	public function register_shortcode_ui() {
 | |
| 262 | +	public function register_shortcode_ui() { | |
| 263 | 263 | $template = $this->get_page_template(); | 
| 264 | 264 | $context = [ 'page_template' => $template ]; | 
| 265 | 265 | |
| 266 | 266 | array_walk( $this->shortcode_uis, | 
| 267 | -			function ( $shortcode_ui ) use ( $context ) {
 | |
| 267 | +			function ( $shortcode_ui ) use ( $context ) { | |
| 268 | 268 | /** @var ShortcodeUIInterface $shortcode_ui */ | 
| 269 | 269 | $shortcode_ui->register( $context ); | 
| 270 | 270 | } | 
| @@ -281,7 +281,7 @@ discard block | ||
| 281 | 281 | * @param null $content Inner content to pass to the shortcode. | 
| 282 | 282 | * @return string|false Rendered HTML. | 
| 283 | 283 | */ | 
| 284 | -	public function do_tag( $tag, array $atts = [ ], $content = null ) {
 | |
| 284 | +	public function do_tag( $tag, array $atts = [ ], $content = null ) { | |
| 285 | 285 | \BrightNucleus\Shortcode\do_tag( $tag, $atts, $content ); | 
| 286 | 286 | } | 
| 287 | 287 | } |