PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.5.6
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.5.6
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.5.6, at classes/Visualizer/Module.php

145 lines 5.2 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 /**
24 * Base class for all modules. Implements routine methods required by all modules.
25 *
26 * @category Visualizer
27 * @package Module
28 *
29 * @since 1.0.0
30 */
31 class Visualizer_Module {
32
33 /**
34 * The instance of wpdb class.
35 *
36 * @since 1.0.0
37 *
38 * @access protected
39 * @var wpdb
40 */
41 protected $_wpdb = null;
42
43 /**
44 * The plugin instance.
45 *
46 * @since 1.0.0
47 *
48 * @access protected
49 * @var Visualizer_Plugin
50 */
51 protected $_plugin = null;
52
53 /**
54 * Constructor.
55 *
56 * @since 1.0.0
57 * @global wpdb $wpdb Current database connection.
58 *
59 * @access public
60 * @param Visualizer_Plugin $plugin The instance of the plugin.
61 */
62 public function __construct( Visualizer_Plugin $plugin ) {
63 global $wpdb;
64
65 $this->_wpdb = $wpdb;
66 $this->_plugin = $plugin;
67 }
68
69 /**
70 * Registers an action hook.
71 *
72 * @since 1.0.0
73 * @uses add_action() To register action hook.
74 *
75 * @access protected
76 * @param string $tag The name of the action to which the $method is hooked.
77 * @param string $method The name of the method to be called.
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 boolean $private Optional. Determines if we should register hook for logged in users.
96 * @param boolean $public Optional. Determines if we should register hook for not logged in users.
97 * @return Visualizer_Module
98 */
99 protected function _addAjaxAction( $tag, $method = '', $methodClass=NULL, $private = true, $public = false ) {
100 if ( $private ) {
101 $this->_addAction( 'wp_ajax_' . $tag, $method, $methodClass );
102 }
103
104 if ( $public ) {
105 $this->_addAction( 'wp_ajax_nopriv_' . $tag, $method, $methodClass );
106 }
107
108 return $this;
109 }
110
111 /**
112 * Registers a filter hook.
113 *
114 * @since 1.0.0
115 * @uses add_filter() To register filter hook.
116 *
117 * @access protected
118 * @param string $tag The name of the filter to hook the $method to.
119 * @param type $method The name of the method to be called when the filter is applied.
120 * @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.
121 * @param int $accepted_args optional. The number of arguments the function accept (default 1).
122 * @return Visualizer_Module
123 */
124 protected function _addFilter( $tag, $method, $priority = 10, $accepted_args = 1 ) {
125 add_filter( $tag, array( $this, $method ), $priority, $accepted_args );
126 return $this;
127 }
128
129 /**
130 * Registers a hook for shortcode tag.
131 *
132 * @since 1.0.0
133 * @uses add_shortcode() To register shortcode hook.
134 *
135 * @access protected
136 * @param string $tag Shortcode tag to be searched in post content.
137 * @param string $method Hook to run when shortcode is found.
138 * @return Visualizer_Module
139 */
140 protected function _addShortcode( $tag, $method ) {
141 add_shortcode( $tag, array( $this, $method ) );
142 return $this;
143 }
144
145 }