-
Notifications
You must be signed in to change notification settings - Fork 217
/
unyson.php
155 lines (137 loc) · 4.76 KB
/
unyson.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php if ( ! defined( 'ABSPATH' ) ) die( 'Forbidden' );
/**
* Plugin Name: Unyson
* Plugin URI: http://unyson.io/
* Description: A free drag & drop framework that comes with a bunch of built in extensions that will help you develop premium themes fast & easy.
* Version: 2.7.31
* Author: ThemeFuse
* Author URI: http://themefuse.com
* License: GPL2+
* Text Domain: fw
* Domain Path: /framework/languages
*/
if (defined('FW')) {
/**
* The plugin was already loaded (maybe as another plugin with different directory name)
*/
} else {
require dirname( __FILE__ ) . '/framework/bootstrap.php';
/**
* Plugin related functionality
*
* Note:
* The framework doesn't know that it's used as a plugin.
* It can be localed in the theme directory or any other directory.
* Only its path and uri is known
*/
{
/** @internal */
function _action_fw_plugin_activate() {
update_option( '_fw_plugin_activated', true, false ); // add special option (is used in another action)
// @see framework/bootstrap.php
// must not be loaded
if ( did_action( 'after_setup_theme' ) && ! did_action( 'fw_init' ) ) {
_action_init_framework(); // load (prematurely) the plugin
do_action( 'fw_plugin_activate' );
}
}
register_activation_hook( __FILE__, '_action_fw_plugin_activate' );
/** @internal */
function _action_fw_plugin_check_if_was_activated() {
if (get_option('_fw_plugin_activated')) {
delete_option('_fw_plugin_activated');
do_action('fw_after_plugin_activate');
}
}
add_action(
'current_screen', // as late as possible, but to be able to make redirects (content not started)
'_action_fw_plugin_check_if_was_activated',
100
);
/**
* @param int $blog_id Blog ID
* @param bool $drop True if blog's table should be dropped. Default is false.
* @internal
*/
function _action_fw_delete_blog( $blog_id, $drop ) {
if ($drop) {
global $wpdb; /** @var WPDB $wpdb */
// delete old termmeta table
$wpdb->query("DROP TABLE IF EXISTS `{$wpdb->prefix}fw_termmeta`;");
}
}
add_action( 'delete_blog', '_action_fw_delete_blog', 10, 2 );
/** @internal */
function _filter_fw_plugin_action_list( $actions ) {
return apply_filters( 'fw_plugin_action_list', $actions );
}
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), '_filter_fw_plugin_action_list' );
/** @internal */
function _action_fw_textdomain() {
load_plugin_textdomain( 'fw', false, plugin_basename( dirname( __FILE__ ) ) . '/framework/languages' );
}
add_action( 'fw_before_init', '_action_fw_textdomain', 3 );
/** @internal */
function _filter_fw_tmp_dir( $dir ) {
/**
* Some users force WP_Filesystem to use the 'direct' method <?php define( 'FS_METHOD', 'direct' ); ?> and set chmod 777 to the unyson/ plugin.
* By default tmp dir is WP_CONTENT_DIR.'/tmp' and WP_Filesystem can't create it with 'direct' method, then users can't download and install extensions.
* In order to prevent this situation, create the temporary directory inside the plugin folder.
*/
return dirname( __FILE__ ) . '/tmp';
}
add_filter( 'fw_tmp_dir', '_filter_fw_tmp_dir' );
/** @internal */
final class _FW_Update_Hooks {
public static function _init() {
add_filter( 'upgrader_pre_install', array(__CLASS__, '_filter_fw_check_if_plugin_pre_update'), 9999, 2 );
add_filter( 'upgrader_post_install', array(__CLASS__, '_filter_fw_check_if_plugin_post_update'), 9999, 2 );
add_action( 'automatic_updates_complete', array(__CLASS__, '_action_fw_automatic_updates_complete') );
}
public static function _filter_fw_check_if_plugin_pre_update( $result, $data ) {
if (
!is_wp_error($result)
&&
isset( $data['plugin'] )
&&
plugin_basename( __FILE__ ) === $data['plugin']
) {
/**
* Before plugin update
* The plugin was already download and extracted to a temp directory
* and it's right before being replaced with the new downloaded version
*/
do_action( 'fw_plugin_pre_update' );
}
return $result;
}
public static function _filter_fw_check_if_plugin_post_update( $result, $data ) {
if (
!is_wp_error($result)
&&
isset( $data['plugin'] )
&&
plugin_basename( __FILE__ ) === $data['plugin']
) {
/**
* After plugin successfully updated
*/
do_action( 'fw_plugin_post_update' );
}
return $result;
}
public static function _action_fw_automatic_updates_complete($results) {
if (!isset($results['plugin'])) {
return;
}
foreach ($results['plugin'] as $plugin) {
if (plugin_basename( __FILE__ ) === strtolower($plugin->item->plugin)) {
do_action( 'fw_automatic_update_complete', $plugin->result );
break;
}
}
}
}
_FW_Update_Hooks::_init();
}
}