PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.7.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.7.2
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / classes / Visualizer / Module.php

Module.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 1.7.2, at classes/Visualizer/Module.php

147 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // +----------------------------------------------------------------------+
4 // | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
5 // +----------------------------------------------------------------------+
6 // | This program is free software; you can redistribute it and/or modify |
7 // | it under the terms of the GNU General Public License, version 2, as |
8 // | published by the Free Software Foundation. |
9 // | |
10 // | This program is distributed in the hope that it will be useful, |
11 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 // | GNU General Public License for more details. |
14 // | |
15 // | You should have received a copy of the GNU General Public License |
16 // | along with this program; if not, write to the Free Software |
17 // | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
18 // | MA 02110-1301 USA |
19 // +----------------------------------------------------------------------+
20 // | Author: Eugene Manuilov <eugene@manuilov.org> |
21 // +----------------------------------------------------------------------+
22 /**
23 * Base class for all modules. Implements routine methods required by all modules.
24 *
25 * @category Visualizer
26 * @package Module
27 *
28 * @since 1.0.0
29 */
30 class Visualizer_Module {
31
32 /**
33 * The instance of wpdb class.
34 *
35 * @since 1.0.0
36 *
37 * @access protected
38 * @var wpdb
39 */
40 protected $_wpdb = null;
41
42 /**
43 * The plugin instance.
44 *
45 * @since 1.0.0
46 *
47 * @access protected
48 * @var Visualizer_Plugin
49 */
50 protected $_plugin = null;
51
52 /**
53 * Constructor.
54 *
55 * @since 1.0.0
56 * @global wpdb $wpdb Current database connection.
57 *
58 * @access public
59 * @param Visualizer_Plugin $plugin The instance of the plugin.
60 */
61 public function __construct( Visualizer_Plugin $plugin ) {
62 global $wpdb;
63
64 $this->_wpdb = $wpdb;
65 $this->_plugin = $plugin;
66 }
67
68 /**
69 * Registers an action hook.
70 *
71 * @since 1.0.0
72 * @uses add_action() To register action hook.
73 *
74 * @access protected
75 * @param string $tag The name of the action to which the $method is hooked.
76 * @param string $method The name of the method to be called.
77 * @param bool $methodClass The root of the method.
78 * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
79 * @param int $accepted_args optional. The number of arguments the function accept (default 1).
80 * @return Visualizer_Module
81 */
82 protected function _addAction( $tag, $method, $methodClass = null, $priority = 10, $accepted_args = 1 ) {
83 add_action( $tag, array( $methodClass ? $methodClass : $this, $method ), $priority, $accepted_args );
84 return $this;
85 }
86
87 /**
88 * Registers AJAX action hook.
89 *
90 * @since 1.0.0
91 *
92 * @access public
93 * @param string $tag The name of the AJAX action to which the $method is hooked.
94 * @param string $method Optional. The name of the method to be called. If the name of the method is not provided, tag name will be used as method name.
95 * @param bool $methodClass The root of the method.
96 * @param boolean $private Optional. Determines if we should register hook for logged in users.
97 * @param boolean $public Optional. Determines if we should register hook for not logged in users.
98 * @return Visualizer_Module
99 */
100 protected function _addAjaxAction( $tag, $method = '', $methodClass = null, $private = true, $public = false ) {
101 if ( $private ) {
102 $this->_addAction( 'wp_ajax_' . $tag, $method, $methodClass );
103 }
104
105 if ( $public ) {
106 $this->_addAction( 'wp_ajax_nopriv_' . $tag, $method, $methodClass );
107 }
108
109 return $this;
110 }
111
112 /**
113 * Registers a filter hook.
114 *
115 * @since 1.0.0
116 * @uses add_filter() To register filter hook.
117 *
118 * @access protected
119 * @param string $tag The name of the filter to hook the $method to.
120 * @param type $method The name of the method to be called when the filter is applied.
121 * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
122 * @param int $accepted_args optional. The number of arguments the function accept (default 1).
123 * @return Visualizer_Module
124 */
125 protected function _addFilter( $tag, $method, $priority = 10, $accepted_args = 1 ) {
126 add_filter( $tag, array( $this, $method ), $priority, $accepted_args );
127 return $this;
128 }
129
130 /**
131 * Registers a hook for shortcode tag.
132 *
133 * @since 1.0.0
134 * @uses add_shortcode() To register shortcode hook.
135 *
136 * @access protected
137 * @param string $tag Shortcode tag to be searched in post content.
138 * @param string $method Hook to run when shortcode is found.
139 * @return Visualizer_Module
140 */
141 protected function _addShortcode( $tag, $method ) {
142 add_shortcode( $tag, array( $this, $method ) );
143 return $this;
144 }
145
146 }
147