PluginProbe
Gantry 5 Framework / 5.2.2
Gantry 5 Framework v5.2.2
5.6.4 5.6.3 trunk 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.2.0 5.2.1 5.2.10 5.2.11 5.2.12 5.2.13 5.2.14 5.2.15 5.2.17 5.2.18 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 All 90 releases
gantry5 / gantry5.php

gantry5.php in Gantry 5 Framework 5.2.2, at gantry5.php

138 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Gantry 5 Framework
4 * Plugin URI: http://gantry.org/
5 * Description: Framework for Gantry 5 based themes.
6 * Version: 5.2.2
7 * Author: RocketTheme, LLC
8 * Author URI: http://rockettheme.com/
9 * License: GNU General Public License v2 or later
10 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11 * Text Domain: gantry5
12 * Domain Path: /admin/languages
13 */
14
15 defined('ABSPATH') or die;
16
17 // NOTE: This file needs to be PHP 5.2 compatible.
18
19 // Fail safe version check for PHP <5.4.0.
20 if (version_compare(PHP_VERSION, '5.4.0', '<')) {
21 if (is_admin()) {
22 add_action('admin_notices', 'gantry5_php_version_warning');
23 }
24 return;
25 }
26
27 require_once dirname(__FILE__) . '/src/Loader.php';
28
29 if (!defined('GANTRY5_PATH')) {
30 // Works also with symlinks.
31 define('GANTRY5_PATH', rtrim(WP_PLUGIN_DIR, '/\\') . '/gantry5');
32 }
33
34 //add_action('upgrader_package_options', 'gantry5_install_prepare_options', 10, 1);
35 add_action('upgrader_process_complete', 'gantry5_install_clear_cache', 10, 2);
36
37 if (!is_admin()) {
38 return;
39 }
40
41 if (!defined('GANTRYADMIN_PATH')) {
42 // Works also with symlinks.
43 define('GANTRYADMIN_PATH', GANTRY5_PATH . '/admin');
44 }
45
46 // Add Gantry 5 defaults on plugin activation
47 // TODO: change the admin_init to a better hook ie. only when plugin updates
48 register_activation_hook(__FILE__, 'gantry5_plugin_defaults');
49 add_action('admin_init', 'gantry5_plugin_defaults');
50
51 function gantry5_plugin_defaults()
52 {
53 $defaults = array(
54 'production' => '1',
55 'debug' => '0',
56 'offline' => '0',
57 'offline_message' => 'Site is currently in offline mode. Please try again later.',
58 'cache_path' => '',
59 );
60
61 $option = (array)get_option('gantry5_plugin');
62
63 update_option('gantry5_plugin', $option + $defaults);
64 }
65
66 add_filter('kses_allowed_protocols', 'add_gantry5_streams_to_kses');
67
68 function add_gantry5_streams_to_kses($protocols)
69 {
70 $streams = array(
71 'gantry-cache',
72 'gantry-themes',
73 'gantry-theme',
74 'gantry-assets',
75 'gantry-media',
76 'gantry-engines',
77 'gantry-engine',
78 'gantry-layouts',
79 'gantry-particles',
80 'gantry-blueprints',
81 'gantry-config',
82 'wp-includes',
83 'wp-content',
84 );
85
86 $protocols = array_merge($protocols, $streams);
87 return $protocols;
88 }
89
90 // Initialize plugin language and fallback to en_US if the .mo file can't be found
91 $domain = 'gantry5';
92 $languages_path = basename(GANTRY5_PATH) . '/admin/languages';
93
94 if (load_plugin_textdomain($domain, false, $languages_path) === false) {
95 add_filter('plugin_locale', 'modify_gantry5_locale', 10, 2);
96 }
97
98 load_plugin_textdomain($domain, false, $languages_path);
99
100 function modify_gantry5_locale($locale, $domain)
101 {
102 // Revert the gantry5 domain locale to en_US
103 if (isset($domain) && $domain == 'gantry5') {
104 $locale = 'en_US';
105 }
106
107 return $locale;
108 }
109
110 function gantry5_php_version_warning()
111 {
112 echo '<div class="error"><p>';
113 echo sprintf("You are running PHP %s, but Gantry 5 Framework needs at least PHP %s to run.", PHP_VERSION, '5.4.0');
114 echo '</p></div>';
115 }
116
117 function gantry5_install_prepare_options($options)
118 {
119 // $options['abort_if_destination_exists'] = 0;
120 return $options;
121 }
122
123 function gantry5_install_clear_cache($upgrader, $options)
124 {
125 // Clear gantry cache after plugin / theme installs.
126 if (isset($options['type']) && in_array($options['type'], array('plugin', 'theme')) && class_exists('Gantry\Framework\Gantry')) {
127 global $wp_filesystem;
128
129 $gantry = \Gantry\Framework\Gantry::instance();
130 $path = $gantry['platform']->getCachePath();
131 if ($wp_filesystem->is_dir($path)) {
132 $wp_filesystem->rmdir($path);
133 }
134 $upgrader->skin->feedback('Gantry 5 cache cleared.');
135 }
136 }
137
138