This repository was archived by the owner on Sep 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvo-plugin.php
More file actions
executable file
·132 lines (110 loc) · 4.22 KB
/
Copy pathconvo-plugin.php
File metadata and controls
executable file
·132 lines (110 loc) · 4.22 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
125
126
127
128
129
130
131
132
<?php
/**
* Convoworks WP plugin
*
* Plugin Name: Convoworks WP
* Description: The most versatile no-code solution for WordPress!
* UID: convoworks-wp
* Plugin URI: https://convoworks.com
* Update URI: https://convoworks.com/wp-content/uploads/convoworks/deploy/info.json
* Author: ZEF Development
* Version: 0.24.01
* Author URI: https://zef.dev
* Text Domain: convoworks-wp
* License: GPLv3 or later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
if (! defined('ABSPATH')) {
die('You are not allowed to call this page directly.');
}
if (! defined('CONVOWP_LOCAL')) {
define('CONVOWP_LOCAL', false);
}
if (! defined('CONVO_UTIL_DISABLE_GZIP_ENCODING')) {
// faster Rest responses, but can cause problemss in development and debuging
define('CONVO_UTIL_DISABLE_GZIP_ENCODING', false);
}
if (!defined('CONVOWORKS_SECRET_KEY')) {
define('CONVOWORKS_SECRET_KEY', 'tb32tfvHag-skMP2YOdrv');
}
use Convo\Wp\Providers\ConvoWPPlugin;
use Convo\Wp\Providers\PluginActivator;
use Convo\Wp\RequestLogCleanup;
define('CONVOWP_VERSION', '0.24.01');
define('CONVOWP_PLUGIN_SLUG', plugin_basename(__FILE__));
define('CONVOWP_FILE', __FILE__);
define('CONVOWP_PATH', __DIR__);
define('CONVOWP_URL', plugin_dir_url(__FILE__));
define('CONVOWP_ASSETS_URL', CONVOWP_URL . 'public/assets/');
define('CONVOWP_PREFIX', 'convo_');
// for database updates
define('CONVO_DB_VERSION', '1.0.12');
// Request log retention (in days). Can be overridden in wp-config.php
if (!defined('CONVO_REQUEST_LOG_RETENTION_DAYS')) {
define('CONVO_REQUEST_LOG_RETENTION_DAYS', 90);
}
// Define lib constants
define('CONVOWP_LIB_COMMON_PATH', CONVOWP_PATH . '/lib/common/');
// CONVO RELATED
define('CONVO_DATA_PATH', wp_upload_dir()['basedir'] . '/convoworks');
define('CONVO_MEDIA_BASE_URL', wp_upload_dir()['baseurl'] . '/convoworks');
define('CONVO_BASE_URL', site_url());
define('CONVO_PUBLIC_REST_BASE_URL', CONVO_BASE_URL . '/wp-json/convo/v1/public');
// Initialize the plugin
if (version_compare(PHP_VERSION, '7.2', ">=")) {
add_filter('update_plugins_convoworks.com', 'convoworks_wp_check_for_updates', 10, 3);
// Add autoloader
if (CONVOWP_LOCAL) {
require_once __DIR__ . '/vendor/autoload.php';
} else {
require_once __DIR__ . '/vendor/scoper-autoload.php';
}
$plugin = new ConvoWPPlugin();
$plugin->init();
// Schedule request log cleanup (runs via WP-Cron).
add_action('init', [RequestLogCleanup::class, 'schedule']);
add_action(RequestLogCleanup::HOOK, [RequestLogCleanup::class, 'cleanup']);
} else {
if (is_admin()) {
add_action('all_admin_notices', function () {
echo esc_html('<div class="error"><p>You need PHP v7.2+ to use the ConvoWp plugin. You currently have ' . PHP_VERSION . '</p></div>');
});
}
}
function convoworks_wp_check_for_updates($update, $plugin_data, $plugin_file)
{
static $response = false;
if (empty($plugin_data['UpdateURI']) || !empty($update)) {
return $update;
}
if ($response === false) {
$response = wp_remote_get($plugin_data['UpdateURI']);
}
// $logger->debug('Response: ' . print_r($response, true));
if (is_a($response, 'WP_Error')) {
/** @var WP_Error $response */
error_log('Error updating plugin [Convoworks WP]: ' . implode("\n", $response->get_error_messages()));
return $update;
}
$code = wp_remote_retrieve_response_code($response);
if ($code < 200 || $code >= 300) {
error_log('Error updating plugin [Convoworks WP]: HTTP ' . $code);
return $update;
}
if (empty($response['body'])) {
return $update;
}
$custom_plugins_data = json_decode($response['body'], true);
if (!empty($custom_plugins_data[$plugin_file])) {
return $custom_plugins_data[$plugin_file];
} else {
return $update;
}
}
// Plugin activation and deactivation
if (version_compare(PHP_VERSION, '7.2', ">=")) {
register_activation_hook(__FILE__, [PluginActivator::class, 'activate']);
register_deactivation_hook(__FILE__, [PluginActivator::class, 'deactivate']);
add_action('activated_plugin', [PluginActivator::class, 'afterActivate']);
add_action('deactivated_plugin', [PluginActivator::class, 'afterDeactivate']);
}