PluginProbe
FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager / 10
FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager v10
10.56 1.2.1 10 10.1 10.2 10.3 10.31 10.32 10.33 10.34 10.50 10.51 10.52 10.53 10.55 9.0 9.0.1 9.4 trunk 1.0.0 1.1 1.2
easy-code-manager / framework / ServicesFW / Shortcode.service.class.php

Shortcode.service.class.php in FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager 10, at framework/ServicesFW/Shortcode.service.class.php

103 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 /**
7 *
8 */
9 abstract class CJTServicesShortcodeService extends CJTServicesWPService {
10
11 /**
12 * put your comment there...
13 *
14 * @var mixed
15 */
16 private $callback;
17
18 /**
19 * put your comment there...
20 *
21 * @var mixed
22 */
23 private $shortcodes = array();
24
25 /**
26 * put your comment there...
27 *
28 */
29 public function __construct() {
30
31 $this->callback = array( $this, '_doShortcode' );
32 }
33
34 /**
35 * put your comment there...
36 *
37 * @param mixed $attrs
38 * @param mixed $content
39 * @param mixed $tag
40 */
41 public function _doShortcode($attrs, $content, $tag) {
42
43 # Get requested Shortcode config
44 $shortcode =& $this->shortcodes[ $tag ];
45 $shortcodeConfig =& $shortcode[ 'config' ];
46
47 # Push Shortcode parameters
48 $shortcodeConfig['parameters'] = array( 'attrs' => & $attrs, 'content' => & $content, 'tag' => & $tag );
49
50 # Get Controller
51 $this->controller =& $this->getControllerFactory()->getController( array_merge( $this->config, $shortcodeConfig ) );
52
53 # Dispatch action
54 $this->controller->dispatch( $shortcodeConfig[ 'route' ][ 'action' ] );
55
56 # Save models state
57 $this->controller->saveState();
58
59 # Return shortcoee replacement
60 return $this->controller->getResponse();
61 }
62
63 /**
64 * put your comment there...
65 *
66 * @param mixed $name
67 */
68 public function & addShortcode($name) {
69
70 # Create shortcode structure, add it to list
71 $this->shortcodes[ $name ] = array( 'name' => $name, 'config' => & $this->serviceConfig[ $name ] );
72
73 return $this;
74 }
75
76 /**
77 * put your comment there...
78 *
79 */
80 protected abstract function defineShortcodes();
81
82 /**
83 * put your comment there...
84 *
85 */
86 public function & start() {
87
88 # Let Model class define Shortcodes
89 $this->defineShortcodes();
90
91 # Add shortcodes at the correct hook
92 foreach ( $this->shortcodes as $shortcode ) {
93
94 # Register Wordpress shortcode
95 add_shortcode( $shortcode[ 'name' ], $this->callback );
96
97 }
98
99 return $this;
100 }
101
102 }
103