PluginProbe
Flash Toolkit / 1.2.3
Flash Toolkit v1.2.3
trunk 1.0 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6
flash-toolkit / flash-toolkit.php

flash-toolkit.php in Flash Toolkit 1.2.3, at flash-toolkit.php

242 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Flash Toolkit
4 * Plugin URI: http://themegrill.com/theme/flash
5 * Description: Flash Toolkit is a companion for Flash WordPress theme by ThemeGrill
6 * Version: 1.2.3
7 * Author: ThemeGrill
8 * Author URI: http://themegrill.com
9 * License: GPLv3 or later
10 * Text Domain: flash-toolkit
11 * Domain Path: /i18n/languages/
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // Exit if accessed directly.
16 }
17
18 if ( ! class_exists( 'FlashToolkit' ) ) :
19
20 /**
21 * FlashToolkit main class.
22 *
23 * @class FlashToolkit
24 * @version 1.0.0
25 */
26 final class FlashToolkit {
27
28 /**
29 * Plugin version.
30 *
31 * @var string
32 */
33 public $version = '1.2.3';
34
35 /**
36 * Instance of this class.
37 *
38 * @var object
39 */
40 protected static $_instance = null;
41
42 /**
43 * Return an instance of this class.
44 *
45 * @return object A single instance of this class.
46 */
47 public static function instance() {
48 // If the single instance hasn't been set, set it now.
49 if ( is_null( self::$_instance ) ) {
50 self::$_instance = new self();
51 }
52
53 return self::$_instance;
54 }
55
56 /**
57 * Cloning is forbidden.
58 *
59 * @since 1.0
60 */
61 public function __clone() {
62 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'flash-toolkit' ), '1.0' );
63 }
64
65 /**
66 * Unserializing instances of this class is forbidden.
67 *
68 * @since 1.0
69 */
70 public function __wakeup() {
71 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'flash-toolkit' ), '1.0' );
72 }
73
74 /**
75 * FlashToolkit Constructor.
76 */
77 public function __construct() {
78 $this->define_constants();
79 $this->includes();
80 $this->init_hooks();
81
82 do_action( 'flash_toolkit_loaded' );
83 }
84
85 /**
86 * Hook into actions and filters.
87 */
88 private function init_hooks() {
89 register_activation_hook( __FILE__, array( 'FT_Install', 'install' ) );
90 register_deactivation_hook( __FILE__, array( 'FT_Install', 'deactivate' ) );
91 add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
92 add_action( 'admin_notices', array( $this, 'theme_support_missing_notice' ) );
93 }
94
95 /**
96 * Define FT Constants.
97 */
98 private function define_constants() {
99 $this->define( 'FT_PLUGIN_FILE', __FILE__ );
100 $this->define( 'FT_ABSPATH', dirname( __FILE__ ) . '/' );
101 $this->define( 'FT_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
102 $this->define( 'FT_VERSION', $this->version );
103 $this->define( 'FT_TEMPLATE_DEBUG_MODE', false );
104 }
105
106 /**
107 * Define constant if not already set.
108 *
109 * @param string $name
110 * @param string|bool $value
111 */
112 private function define( $name, $value ) {
113 if ( ! defined( $name ) ) {
114 define( $name, $value );
115 }
116 }
117
118 /**
119 * What type of request is this?
120 *
121 * @param string $type admin or frontend.
122 *
123 * @return bool
124 */
125 private function is_request( $type ) {
126 switch ( $type ) {
127 case 'admin' :
128 return is_admin();
129 case 'frontend' :
130 return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
131 }
132 }
133
134 /**
135 * Includes.
136 */
137 private function includes() {
138 include_once( FT_ABSPATH . 'includes/functions-flash-core.php' );
139 include_once( FT_ABSPATH . 'includes/functions-flash-widget.php' );
140 include_once( FT_ABSPATH . 'includes/class-flash-autoloader.php' );
141 include_once( FT_ABSPATH . 'includes/class-flash-install.php' );
142 include_once( FT_ABSPATH . 'includes/class-flash-ajax.php' );
143 include_once( FT_ABSPATH . 'includes/class-flash-inline-style.php' );
144
145 if ( $this->is_request( 'admin' ) ) {
146 include_once( FT_ABSPATH . 'includes/admin/class-flash-admin.php' );
147 }
148
149 if ( is_flash_pro_active() ) {
150 include_once( FT_ABSPATH . 'includes/class-flash-sidebars.php' );
151 }
152
153 include_once( FT_ABSPATH . 'includes/class-flash-post-types.php' ); // Registers post types
154 }
155
156 /**
157 * Load Localisation files.
158 *
159 * Note: the first-loaded translation file overrides any following ones if the same translation is present.
160 *
161 * Locales found in:
162 * - WP_LANG_DIR/flash-toolkit/flash-toolkit-LOCALE.mo
163 * - WP_LANG_DIR/plugins/flash-toolkit-LOCALE.mo
164 */
165 public function load_plugin_textdomain() {
166 $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
167 $locale = apply_filters( 'plugin_locale', $locale, 'flash-toolkit' );
168
169 unload_textdomain( 'flash-toolkit' );
170 load_textdomain( 'flash-toolkit', WP_LANG_DIR . '/flash-toolkit/flash-toolkit-' . $locale . '.mo' );
171 load_plugin_textdomain( 'flash-toolkit', false, plugin_basename( dirname( __FILE__ ) ) . '/i18n/languages' );
172 }
173
174 /**
175 * Theme support fallback notice.
176 *
177 * @return string
178 */
179 public function theme_support_missing_notice() {
180 $theme = wp_get_theme();
181 $parent = $theme->parent();
182
183 // Check with ThemeGrill Flash Theme is installed.
184 if ( ( $theme != 'Flash' ) && ( $theme != 'Flash Pro' ) && ( $parent != 'Flash' ) && ( $parent != 'Flash Pro' ) ) {
185 echo '<div class="error notice is-dismissible"><p><strong>' . __( 'Flash Toolkit', 'flash-toolkit' ) . '</strong> &#8211; ' . sprintf( __( 'This plugin requires %s by ThemeGrill to work.', 'flash-toolkit' ), '<a href="http://www.themegrill.com/themes/flash/" target="_blank">' . __( 'Flash Theme', 'flash-toolkit' ) . '</a>' ) . '</p></div>';
186 }
187 }
188
189 /**
190 * Get the plugin url.
191 *
192 * @return string
193 */
194 public function plugin_url() {
195 return untrailingslashit( plugins_url( '/', __FILE__ ) );
196 }
197
198 /**
199 * Get the plugin path.
200 *
201 * @return string
202 */
203 public function plugin_path() {
204 return untrailingslashit( plugin_dir_path( __FILE__ ) );
205 }
206
207 /**
208 * Get the template path.
209 *
210 * @return string
211 */
212 public function template_path() {
213 return apply_filters( 'flash_toolkit_template_path', 'flash-toolkit/' );
214 }
215
216 /**
217 * Get Ajax URL.
218 *
219 * @return string
220 */
221 public function ajax_url() {
222 return admin_url( 'admin-ajax.php', 'relative' );
223 }
224 }
225
226 endif;
227
228 /**
229 * Main instance of FlashToolkit.
230 *
231 * Returns the main instance of FT to prevent the need to use globals.
232 *
233 * @return FlashToolkit
234 * @since 1.0
235 */
236 function FT() {
237 return FlashToolkit::instance();
238 }
239
240 // Global for backwards compatibility.
241 $GLOBALS['flashtoolkit'] = FT();
242