PluginProbe
Advanced Access Manager – Access Governance for WordPress / 6.9.0
Advanced Access Manager – Access Governance for WordPress v6.9.0
7.1.4 7.1.2 7.1.3 6.8.4 6.8.5 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13 6.9.14 6.9.15 6.9.16 6.9.17 6.9.18 6.9.19 6.9.2 6.9.20 6.9.21 6.9.22 6.9.23 6.9.24 6.9.25 6.9.26 All 210 releases
advanced-access-manager / application / Shortcode / Factory.php
Factory.php
88 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * ======================================================================
5 * LICENSE: This file is subject to the terms and conditions defined in *
6 * file 'license.txt', which is part of this source code package. *
7 * ======================================================================
8 */
9
10 /**
11 * Shortcode factory for the [aam] shortcode
12 *
13 * @since 6.6.0 https://github.com/aamplugin/advanced-access-manager/issues/90
14 * @since 6.0.0 Initial implementation of the class
15 *
16 * @package AAM
17 * @version 6.6.0
18 */
19 class AAM_Shortcode_Factory
20 {
21
22 /**
23 * Shortcode handler based on the provided attributes
24 *
25 * @var AAM_Core_Contract_ShortcodeInterface
26 *
27 * @access protected
28 * @version 6.0.0
29 */
30 protected $handler = null;
31
32 /**
33 * Initialize shortcode factory
34 *
35 * @param array $args
36 * @param string $content
37 *
38 * @return void
39 *
40 * @since 6.6.0 https://github.com/aamplugin/advanced-access-manager/issues/90
41 * @since 6.0.0 Initial implementation of the method
42 *
43 * @access public
44 * @version 6.6.0
45 */
46 public function __construct($args, $content)
47 {
48 $cnt = strtolower(!empty($args['context']) ? $args['context'] : 'content');
49
50 if ($cnt === 'content') {
51 $this->handler = new AAM_Shortcode_Handler_Content($args, $content);
52 } elseif ($cnt === 'loginredirect') {
53 $this->handler = new AAM_Shortcode_Handler_LoginRedirect($args, $content);
54 } elseif ($cnt === 'loginform') {
55 $this->handler = new AAM_Shortcode_Handler_LoginForm($args);
56 } else {
57 $this->handler = apply_filters(
58 'aam_shortcode_filter', null, $cnt, $args, $content
59 );
60 }
61 }
62
63 /**
64 * Process the short-code
65 *
66 * @return string
67 *
68 * @access public
69 * @version 6.0.0
70 */
71 public function process()
72 {
73 $content = null;
74
75 if (is_a($this->handler, 'AAM_Core_Contract_ShortcodeInterface')) {
76 $content = $this->handler->run();
77 } else {
78 _doing_it_wrong(
79 __CLASS__ . '::' . __METHOD__,
80 'No valid strategy found for the given context',
81 AAM_VERSION
82 );
83 }
84
85 return $content;
86 }
87
88 }