forked from ThemeFuse/Unyson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunyson.php
153 lines (132 loc) · 4.94 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
<?php if ( ! defined( 'ABSPATH' ) ) die( 'Forbidden' );
/**
* Plugin Name: Unyson
* Plugin URI: http://unyson.themefuse.com/
* 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.3.2
* Author: ThemeFuse
* Author URI: http://themefuse.com
* License: GPL2+
* Text Domain: fw
* Domain Path: /languages/
*/
if (defined('FW')) {
/**
* The plugin was already loaded (maybe as another plugin with different directory name)
*/
} else {
{
/** @internal */
function _filter_fw_framework_plugin_directory_uri() {
return plugin_dir_url( __FILE__ ) . 'framework';
}
add_filter( 'fw_framework_directory_uri', '_filter_fw_framework_plugin_directory_uri' );
}
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 (specified above)
*/
{
/** @internal */
function _action_fw_plugin_activate() {
{
require_once dirname(__FILE__) .'/framework/includes/term-meta/function_fw_term_meta_setup_blog.php';
if (is_multisite() && is_network_admin()) {
global $wpdb;
$blogs = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}'" );
foreach ( $blogs as $blog_id ) {
switch_to_blog( $blog_id );
_fw_term_meta_setup_blog( $blog_id );
}
do {} while ( restore_current_blog() );
} else {
_fw_term_meta_setup_blog();
}
}
// add special option (is used in another action)
update_option('_fw_plugin_activated', true);
}
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', '_action_fw_plugin_check_if_was_activated', 100);
// as late as possible, but to be able to make redirects (content not started)
/** @internal */
function _action_fw_term_meta_new_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
if ( is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
require_once dirname(__FILE__) .'/framework/includes/term-meta/function_fw_term_meta_setup_blog.php';
switch_to_blog( $blog_id );
_fw_term_meta_setup_blog();
do {} while ( restore_current_blog() );
}
}
add_action( 'wpmu_new_blog', '_action_fw_term_meta_new_blog', 10, 6 );
/**
* @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) { // delete table created by the _fw_term_meta_setup_blog() function
/** @var WPDB $wpdb */
global $wpdb;
if (property_exists($wpdb, 'fw_termmeta')) { // it should exist, but check to be sure
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->fw_termmeta};");
}
}
}
add_action( 'delete_blog', '_action_fw_delete_blog', 10, 2 );
/** @internal */
function _filter_fw_check_if_plugin_pre_update( $result, $data ) {
if ( isset( $data['plugin'] ) && $data['plugin'] === plugin_basename( __FILE__ ) ) {
/**
* Before plugin update
*/
do_action( 'fw_plugin_pre_update' );
}
return $result;
}
add_filter( 'upgrader_pre_install', '_filter_fw_check_if_plugin_pre_update', 10, 2 );
/** @internal */
function _filter_fw_check_if_plugin_post_update( $result, $data ) {
if ( isset( $data['plugin'] ) && $data['plugin'] === plugin_basename( __FILE__ ) ) {
/**
* After plugin update
*/
do_action( 'fw_plugin_post_update' );
}
return $result;
}
add_filter( 'upgrader_post_install', '_filter_fw_check_if_plugin_post_update', 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, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
add_action( 'plugins_loaded', '_action_fw_textdomain' );
/** @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' );
}
}