-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinstawp-connect.php
More file actions
124 lines (103 loc) · 4.86 KB
/
instawp-connect.php
File metadata and controls
124 lines (103 loc) · 4.86 KB
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
<?php global $migrate_id;
/**
* @link https://instawp.com/
* @since 0.0.1
* @package instawp
*
* @wordpress-plugin
* Plugin Name: InstaWP Connect
* Description: 1-click WordPress plugin for Staging, Migrations, Management, Sync and Companion plugin for InstaWP.
* Version: 0.1.3.3
* Author: InstaWP Team
* Author URI: https://instawp.com/
* License: GPL-3.0+
* License URI: http://www.gnu.org/copyleft/gpl.html
* Text Domain: instawp-connect
* Domain Path: /languages
*/
use InstaWP\Connect\Helpers\Curl;
use InstaWP\Connect\Helpers\Helper;
use InstaWP\Connect\Helpers\Option;
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
global $wpdb;
defined( 'INSTAWP_PLUGIN_VERSION' ) || define( 'INSTAWP_PLUGIN_VERSION', '0.1.3.3' );
defined( 'INSTAWP_API_DOMAIN_PROD' ) || define( 'INSTAWP_API_DOMAIN_PROD', 'https://app.instawp.io' );
defined( 'INSTAWP_PLUGIN_URL' ) || define( 'INSTAWP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
defined( 'INSTAWP_PLUGIN_DIR' ) || define( 'INSTAWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
defined( 'INSTAWP_PLUGIN_FILE' ) || define( 'INSTAWP_PLUGIN_FILE', plugin_basename( __FILE__ ) );
defined( 'INSTAWP_DEFAULT_BACKUP_DIR' ) || define( 'INSTAWP_DEFAULT_BACKUP_DIR', 'instawpbackups' );
defined( 'INSTAWP_BACKUP_DIR' ) || define( 'INSTAWP_BACKUP_DIR', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . INSTAWP_DEFAULT_BACKUP_DIR . DIRECTORY_SEPARATOR );
defined( 'INSTAWP_DOCS_URL_PLUGIN' ) || define( 'INSTAWP_DOCS_URL_PLUGIN', esc_url( 'https://instawp.to/docs/plugin-errors' ) );
defined( 'INSTAWP_PLUGIN_SLUG' ) || define( 'INSTAWP_PLUGIN_SLUG', 'instawp-connect' );
defined( 'INSTAWP_PLUGIN_NAME' ) || define( 'INSTAWP_PLUGIN_NAME', plugin_basename( __FILE__ ) );
defined( 'INSTAWP_DB_TABLE_EVENTS' ) || define( 'INSTAWP_DB_TABLE_EVENTS', $wpdb->prefix . 'instawp_events' );
defined( 'INSTAWP_DB_TABLE_SYNC_HISTORY' ) || define( 'INSTAWP_DB_TABLE_SYNC_HISTORY', $wpdb->prefix . 'instawp_sync_history' );
defined( 'INSTAWP_DB_TABLE_EVENT_SITES' ) || define( 'INSTAWP_DB_TABLE_EVENT_SITES', $wpdb->prefix . 'instawp_event_sites' );
defined( 'INSTAWP_DB_TABLE_EVENT_SYNC_LOGS' ) || define( 'INSTAWP_DB_TABLE_EVENT_SYNC_LOGS', $wpdb->prefix . 'instawp_event_sync_logs' );
defined( 'INSTAWP_DB_TABLE_ACTIVITY_LOGS' ) || define( 'INSTAWP_DB_TABLE_ACTIVITY_LOGS', $wpdb->prefix . 'instawp_activity_logs' );
defined( 'INSTAWP_DEFAULT_MAX_FILE_SIZE_ALLOWED' ) || define( 'INSTAWP_DEFAULT_MAX_FILE_SIZE_ALLOWED', 50 );
defined( 'INSTAWP_EVENTS_SYNC_PER_PAGE' ) || define( 'INSTAWP_EVENTS_SYNC_PER_PAGE', 5 );
defined( 'INSTAWP_API_URL' ) || define( 'INSTAWP_API_URL', '/api/v1' );
/**
* @global instaWP $instawp_plugin
*/
global $instawp_plugin;
require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/class-instawp.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/functions.php';
function instawp_plugin_activate() {
InstaWP_Tools::instawp_reset_permalink();
do_action( 'instawp_prepare_large_files_list' );
// set default user for sync settings if user empty
$default_user = Option::get_option( 'instawp_default_user' );
if ( empty( $default_user ) ) {
Option::update_option( 'instawp_default_user', get_current_user_id() );
}
$instawp_sync_tab_roles = Option::get_option( 'instawp_sync_tab_roles' );
if ( empty( $instawp_sync_tab_roles ) ) {
$user = wp_get_current_user();
$roles = (array) $user->roles;
Option::update_option( 'instawp_sync_tab_roles', $roles );
}
$connect_id = instawp_get_connect_id();
if ( ! empty( $connect_id ) ) {
$response = Curl::do_curl( "connects/{$connect_id}/restore", array( 'url' => Helper::wp_site_url( '', true ) ) );
if ( empty( $response['success'] ) ) {
Option::delete_option( 'instawp_api_options' );
}
}
}
/*Deactivate Hook Handle*/
function instawp_plugin_deactivate() {
InstaWP_Tools::instawp_reset_permalink();
Option::delete_option( 'instawp_last_heartbeat_sent' );
Option::delete_option( 'instawp_migration_details' );
$connect_id = instawp_get_connect_id();
if ( ! empty( $connect_id ) ) {
Curl::do_curl( "connects/{$connect_id}/delete", array(), array(), 'DELETE' );
}
}
register_activation_hook( __FILE__, 'instawp_plugin_activate' );
register_deactivation_hook( __FILE__, 'instawp_plugin_deactivate' );
/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @since 1.0
*/
if ( isset( $instawp_plugin ) && is_a( $instawp_plugin, 'instaWP' ) ) {
return;
}
function run_instawp() {
$instawp_plugin = new instaWP();
$GLOBALS['instawp_plugin'] = $instawp_plugin;
$GLOBALS['instawp'] = $instawp_plugin;
}
add_filter( 'got_rewrite', '__return_true' );
run_instawp();