PluginProbe
Gantry 5 Framework / 5.5.9
Gantry 5 Framework v5.5.9
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.5.9, at gantry5.php

133 lines 3.6 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.5.9
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.7 compatible.
18
19 // Fail safe version checks for PHP <5.6.20 as well as PHP <7.1.3.
20 if (PHP_VERSION_ID < 70103) {
21 if (PHP_VERSION_ID < 50620) {
22 if (is_admin()) {
23 add_action('admin_notices', 'gantry5_php_version_error');
24 }
25 return;
26 }
27 if (is_admin()) {
28 add_action('admin_notices', 'gantry5_php_version_warning');
29 }
30 }
31
32 require_once dirname(__FILE__) . '/src/Loader.php';
33
34 if (!defined('GANTRY5_PATH')) {
35 // Works also with symlinks.
36 define('GANTRY5_PATH', rtrim(WP_PLUGIN_DIR, '/\\') . '/gantry5');
37 }
38
39 if (!is_admin()) {
40 return;
41 }
42
43 // Load plugin settings.
44 require_once dirname(__FILE__) . '/admin/settings.php';
45
46 if (!defined('GANTRYADMIN_PATH')) {
47 // Works also with symlinks.
48 define('GANTRYADMIN_PATH', GANTRY5_PATH . '/admin');
49 }
50
51 // Add Gantry 5 defaults on plugin activation
52 // TODO: change the admin_init to a better hook ie. only when plugin updates
53 register_activation_hook(__FILE__, 'gantry5_plugin_defaults');
54 add_action('admin_init', 'gantry5_plugin_defaults');
55
56 function gantry5_plugin_defaults()
57 {
58 $defaults = array(
59 'production' => '0',
60 'use_media_folder' => '0',
61 'assign_posts' => '1',
62 'assign_pages' => '1',
63 'debug' => '0',
64 'offline' => '0',
65 'offline_message' => 'Site is currently in offline mode. Please try again later.',
66 'cache_path' => '',
67 'compile_yaml' => '1',
68 'compile_twig' => '1'
69 );
70
71 $option = (array)get_option('gantry5_plugin');
72
73 update_option('gantry5_plugin', $option + $defaults);
74 }
75
76 add_filter('kses_allowed_protocols', 'add_gantry5_streams_to_kses');
77
78 function add_gantry5_streams_to_kses($protocols)
79 {
80 $streams = array(
81 'gantry-cache',
82 'gantry-themes',
83 'gantry-theme',
84 'gantry-assets',
85 'gantry-media',
86 'gantry-engines',
87 'gantry-engine',
88 'gantry-layouts',
89 'gantry-particles',
90 'gantry-blueprints',
91 'gantry-config',
92 'wp-includes',
93 'wp-content',
94 );
95
96 $protocols = array_merge($protocols, $streams);
97 return $protocols;
98 }
99
100 // Initialize plugin language and fallback to en_US if the .mo file can't be found
101 $domain = 'gantry5';
102 $languages_path = basename(GANTRY5_PATH) . '/admin/languages';
103
104 if (load_plugin_textdomain($domain, false, $languages_path) === false) {
105 add_filter('plugin_locale', 'modify_gantry5_locale', 10, 2);
106 }
107
108 load_plugin_textdomain($domain, false, $languages_path);
109
110 function modify_gantry5_locale($locale, $domain = null)
111 {
112 // Revert the gantry5 domain locale to en_US
113 if (isset($domain) && $domain === 'gantry5') {
114 $locale = 'en_US';
115 }
116
117 return $locale;
118 }
119
120 function gantry5_php_version_error()
121 {
122 echo '<div class="error"><p>';
123 echo sprintf("You are running <b>PHP %s</b>, but <b>Gantry 5 Framework</b> needs at least <b>PHP %s</b> to run.", PHP_VERSION, '5.6.20');
124 echo '</p></div>';
125 }
126
127 function gantry5_php_version_warning()
128 {
129 echo '<div class="error"><p>';
130 echo sprintf('You are running <b>PHP %s</b>. Recommended version of PHP for <b>Gantry 5 Framework</b> is PHP 7.3.1 or later.', PHP_VERSION);
131 echo '</p></div>';
132 }
133