PluginProbe
Gridable / 1.2.2
Gridable v1.2.2
1.2.12 1.2.11 trunk 0.1.0 0.5.0 1.0.0 1.1.0 1.2.0 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9
gridable / includes / class-gridable.php

class-gridable.php in Gridable 1.2.2, at includes/class-gridable.php

241 lines 6.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The file that defines the core plugin class
5 *
6 * A class definition that includes attributes and functions used across both the
7 * public-facing side of the site and the admin area.
8 *
9 * @link https://pixelgrade.com
10 * @since 1.0.0
11 *
12 * @package Gridable
13 * @subpackage Gridable/includes
14 */
15
16 /**
17 * The core plugin class.
18 *
19 * This is used to define internationalization, admin-specific hooks, and
20 * public-facing site hooks.
21 *
22 * Also maintains the unique identifier of this plugin as well as the current
23 * version of the plugin.
24 *
25 * @since 1.0.0
26 * @package Gridable
27 * @subpackage Gridable/includes
28 * @author Pixelgrade <contact@pixelgrade.com>
29 */
30 class Gridable {
31
32 /**
33 * The loader that's responsible for maintaining and registering all hooks that power
34 * the plugin.
35 *
36 * @since 1.0.0
37 * @access protected
38 * @var Gridable_Loader $loader Maintains and registers all hooks for the plugin.
39 */
40 protected $loader;
41
42 /**
43 * The unique identifier of this plugin.
44 *
45 * @since 1.0.0
46 * @access protected
47 * @var string $gridable The string used to uniquely identify this plugin.
48 */
49 protected $gridable;
50
51 /**
52 * The current version of the plugin.
53 *
54 * @since 1.0.0
55 * @access protected
56 * @var string $version The current version of the plugin.
57 */
58 protected $version;
59
60 /**
61 * Define the core functionality of the plugin.
62 *
63 * Set the plugin name and the plugin version that can be used throughout the plugin.
64 * Load the dependencies, define the locale, and set the hooks for the admin area and
65 * the public-facing side of the site.
66 *
67 * @since 1.0.0
68 */
69 public function __construct() {
70
71 $this->gridable = 'gridable';
72 $this->version = '1.2.2';
73
74 $this->load_dependencies();
75 $this->set_locale();
76 $this->define_admin_hooks();
77 $this->define_public_hooks();
78
79 }
80
81 /**
82 * Load the required dependencies for this plugin.
83 *
84 * Include the following files that make up the plugin:
85 *
86 * - Gridable_Loader. Orchestrates the hooks of the plugin.
87 * - Gridable_i18n. Defines internationalization functionality.
88 * - Gridable_Admin. Defines all hooks for the admin area.
89 * - Gridable_Public. Defines all hooks for the public side of the site.
90 *
91 * Create an instance of the loader which will be used to register the hooks
92 * with WordPress.
93 *
94 * @since 1.0.0
95 * @access private
96 */
97 private function load_dependencies() {
98
99 /**
100 * The class responsible for orchestrating the actions and filters of the
101 * core plugin.
102 */
103 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-gridable-loader.php';
104
105 /**
106 * The class responsible for defining internationalization functionality
107 * of the plugin.
108 */
109 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-gridable-i18n.php';
110
111 /**
112 * The class responsible for defining all actions that occur in the admin area.
113 */
114 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-gridable-admin.php';
115
116 /**
117 * The class responsible for defining all actions that occur in the public-facing
118 * side of the site.
119 */
120 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-gridable-public.php';
121
122 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/addons/attributes.php';
123
124 $this->loader = new Gridable_Loader();
125
126 }
127
128 /**
129 * Define the locale for this plugin for internationalization.
130 *
131 * Uses the Gridable_i18n class in order to set the domain and to register the hook
132 * with WordPress.
133 *
134 * @since 1.0.0
135 * @access private
136 */
137 private function set_locale() {
138
139 $plugin_i18n = new Gridable_i18n();
140
141 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
142
143 }
144
145 /**
146 * Register all of the hooks related to the admin area functionality
147 * of the plugin.
148 *
149 * @since 1.0.0
150 * @access private
151 */
152 private function define_admin_hooks() {
153
154 $plugin_admin = new Gridable_Admin( $this->get_gridable(), $this->get_version() );
155
156 add_action( 'media_buttons', array( $plugin_admin, 'add_media_button' ), 15 );
157
158 add_filter( 'mce_external_plugins', array( $plugin_admin, 'add_grider_tinymce_plugin' ) );
159 add_action( 'admin_footer', array( $plugin_admin, 'wp_print_grider_tinymce_templates' ) );
160
161 // also inside the wp-editor we cannot localize parameters, so we simply output the javascript code
162 add_action( 'admin_head', array( $plugin_admin, 'my_add_styles_admin' ) );
163
164 if ( apply_filters( 'gridable_support_for_customizer', true ) && ! wp_doing_ajax() ) {
165 // This is needed for wp-editors added in customizer
166 add_action( 'customize_controls_print_footer_scripts', array( $plugin_admin, 'my_add_styles_admin' ) );
167 add_action( 'customize_controls_print_footer_scripts', array( $plugin_admin, 'wp_print_grider_tinymce_templates' ) );
168 }
169 }
170
171 /**
172 * Register all of the hooks related to the public-facing functionality
173 * of the plugin.
174 *
175 * @since 1.0.0
176 * @access private
177 */
178 private function define_public_hooks() {
179
180 $plugin_public = new Gridable_Public( $this->get_gridable(), $this->get_version() );
181
182 add_action( 'wp_enqueue_scripts', array( $plugin_public, 'enqueue_styles' ) );
183 add_action( 'wp_enqueue_scripts', array( $plugin_public, 'enqueue_scripts' ) );
184 add_shortcode( 'row', array( $plugin_public, 'add_row_shortcode' ) );
185 add_shortcode( 'col', array( $plugin_public, 'add_column_shortcode' ) );
186
187 add_filter( 'the_content', array( $plugin_public, 'parse_content_for_nested_rows' ), 9 );
188
189 // clear lost p tags in front-end
190 if ( ! is_admin() ) {
191 add_filter( 'gridable_the_column_content', array( $plugin_public, 'gridable_fix_lost_p_tags' ), 10, 2 );
192
193 if ( true === apply_filters('gridable_add_empty_column_class', true ) ) {
194 add_filter( 'gridable_column_class', array( $plugin_public, 'gridable_add_empty_column_class' ), 10, 4 );
195 }
196
197 }
198 }
199
200 /**
201 * Run the loader to execute all of the hooks with WordPress.
202 *
203 * @since 1.0.0
204 */
205 public function run() {
206 $this->loader->run();
207 }
208
209 /**
210 * The name of the plugin used to uniquely identify it within the context of
211 * WordPress and to define internationalization functionality.
212 *
213 * @since 1.0.0
214 * @return string The name of the plugin.
215 */
216 public function get_gridable() {
217 return $this->gridable;
218 }
219
220 /**
221 * The reference to the class that orchestrates the hooks with the plugin.
222 *
223 * @since 1.0.0
224 * @return Gridable_Loader Orchestrates the hooks of the plugin.
225 */
226 public function get_loader() {
227 return $this->loader;
228 }
229
230 /**
231 * Retrieve the version number of the plugin.
232 *
233 * @since 1.0.0
234 * @return string The version number of the plugin.
235 */
236 public function get_version() {
237 return $this->version;
238 }
239
240 }
241