-
Notifications
You must be signed in to change notification settings - Fork 16
/
tweet-old-post.php
262 lines (225 loc) · 8.22 KB
/
tweet-old-post.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
/**
* Main loader file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link https://revive.social
* @since 3.0.0
* @package ROP
*
* @wordpress-plugin
* Plugin Name: Revive Social
* Plugin URI: https://revive.social/
* Description: WordPress plugin that automatically schedules and posts your content to multiple social networks (including Facebook, X, LinkedIn, and Instagram), helping you promote and drive more traffic to your website. For questions, comments, or feature requests, <a href="http://revive.social/support/?utm_source=plugindesc&utm_medium=announce&utm_campaign=top">contact </a> us!
* Version: 9.1.3
* Author: revive.social
* Author URI: https://revive.social/
* WordPress Available: yes
* Pro Slug: tweet-old-post-pro
* Requires License: no
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: tweet-old-post
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( function_exists( 'phpversion' ) ) {
if ( version_compare( phpversion(), '7.4', '<' ) ) {
add_action( 'admin_notices', 'rop_php_notice' );
add_action( 'admin_init', 'deactivate_rop', 1 );
return;
}
}
if ( defined( 'PHP_VERSION' ) ) {
if ( version_compare( PHP_VERSION, '7.4', '<' ) ) {
add_action( 'admin_notices', 'rop_php_notice' );
add_action( 'admin_init', 'deactivate_rop', 1 );
return;
}
}
/**
* Shows a notice with a doc link to a fix for sites which have Buffer connected.
*
* @since 8.6.2
*/
function rop_buffer_present_notice() {
?>
<div class="notice notice-error is-dismissible">
<?php echo sprintf( __( '%1$s %2$sRevive Social:%3$s You have Buffer account(s) connected to Revive Social. You need to remove these accounts to avoid issues with the plugin. Plugin has been deactivated. %4$sClick here to read the article with the fix.%5$s %6$s', 'tweet-old-post' ), '<p>', '<b>', '</b>', '<a href="https://docs.revive.social/article/1318-fix-php-fatal-error-uncaught-exception-invalid-service-name-given" target="_blank">', '</a>', '</p>' ); ?>
</div>
<?php
}
/**
* Detects if there's a buffer account connected to ROP.
*
* Disables ROP if any are found
*
* @since 8.6.2
*/
function rop_buffer_present() {
$rop_data = get_option( 'rop_data' );
if ( empty( $rop_data['services'] ) ) {
return;
}
$services = $rop_data['services'];
foreach ( $services as $service ) {
if ( isset( $service['service'] ) && strpos( $service['service'], 'buffer' ) !== false ) {
add_action( 'admin_notices', 'rop_buffer_present_notice' );
if ( ! function_exists( 'deactivate_plugins' ) ) {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
deactivate_plugins( 'tweet-old-post/tweet-old-post.php' );
return;
}
}
}
add_action( 'init', 'rop_buffer_present', 1 );
/**
* Shows a notice for sites running PHP less than 5.6.
*
* @since 8.1.4
*/
function rop_php_notice() {
?>
<div class="notice notice-error is-dismissible">
<?php echo sprintf( __( '%1$s You\'re using a PHP version lower than 7.4! Revive Social requires at least %2$sPHP 7.4%3$s to function properly. Plugin has been deactivated. %4$sLearn more here%5$s. %6$s', 'tweet-old-post' ), '<p>', '<b>', '</b>', '<a href="https://docs.revive.social/article/947-how-to-update-your-php-version" target="_blank">', '</a>', '</p>' ); ?>
</div>
<?php
}
/**
* Deactivates Revive Old Posts.
*
* @since 8.1.4
*/
function deactivate_rop() {
if ( is_plugin_active( 'tweet-old-post/tweet-old-post.php' ) ) {
deactivate_plugins( 'tweet-old-post/tweet-old-post.php' );
}
}
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-rop-activator.php
*/
function rop_activation() {
Rop_Activator::activate();
}
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-rop-deactivator.php
*/
function rop_deactivation() {
Rop_Deactivator::deactivate();
}
register_activation_hook( __FILE__, 'rop_activation' );
register_deactivation_hook( __FILE__, 'rop_deactivation' );
/**
* 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 8.0.0
*/
function run_rop() {
// Is the remote Cron in use ?
$use_remote_cron = get_option( 'rop_use_remote_cron', false );
$use_remote_cron = filter_var( $use_remote_cron, FILTER_VALIDATE_BOOLEAN );
define( 'ROP_CRON_ALTERNATIVE', $use_remote_cron );
define( 'ROP_LITE_VERSION', '9.1.3' );
define( 'ROP_LITE_BASE_FILE', __FILE__ );
$debug = false;
if ( function_exists( 'wp_get_environment_type' ) ) {
if ( wp_get_environment_type() !== 'production' ) {
$debug = true;
}
}
define( 'ROP_DEBUG', $debug );
define( 'ROP_LITE_PATH', plugin_dir_path( __FILE__ ) );
define( 'ROP_PRO_PATH', WP_PLUGIN_DIR . '/tweet-old-post-pro/' );
define( 'ROP_PATH', plugin_dir_path( __FILE__ ) );
define( 'ROP_LITE_URL', plugin_dir_url( __FILE__ ) );
define( 'ROP_STATUS_ALERT', 6 ); // How many consecutive errors count towards status alert "Status: Error (check logs)"
define( 'ROP_TEMP_IMAGES', plugin_dir_path( __FILE__ ) . 'temp-images/' ); // Path for external images downloaded for sharing
// Authorization APP Data
define( 'ROP_AUTH_APP_URL', 'https://app.revive.social' );
define( 'ROP_APP_FACEBOOK_PATH', '/fb_auth' );
define( 'ROP_APP_TWITTER_PATH', '/tw_auth' );
define( 'ROP_APP_LINKEDIN_PATH', '/li_auth' );
define( 'ROP_APP_TUMBLR_PATH', '/tumblr_auth' );
define( 'ROP_APP_GMB_PATH', '/gmb_auth' );
define( 'ROP_APP_VK_PATH', '/vk_auth' );
define( 'ROP_INSTALL_TOKEN_OPTION', 'rop_install_token' );
define( 'ROP_POST_SHARING_CONTROL_API', ROP_AUTH_APP_URL . '/wp-json/auth-option/v1/post-sharing-control' );
define( 'ROP_POST_ON_X_API', ROP_AUTH_APP_URL . '/wp-json/auth-option/v1/post-on-x' );
add_filter(
'themeisle_sdk_compatibilities/' . basename( ROP_LITE_PATH ),
function ( $compatibilities ) {
$compatibilities['RopPRO'] = array(
'basefile' => defined( 'ROP_PRO_DIR_PATH' ) ? ROP_PRO_DIR_PATH . 'tweet-old-post-pro.php' : '',
'required' => '3.0',
'tested_up' => '3.1',
);
return $compatibilities;
}
);
add_filter(
'tweet_old_post_welcome_metadata',
function () {
return array(
'is_enabled' => ! defined( 'ROP_PRO_DIR_PATH' ),
'pro_name' => 'Revive Old Post Pro',
'logo' => ROP_LITE_URL . 'assets/img/logo_rop.png',
'cta_link' => tsdk_utmify( add_query_arg( array( 'discount' => 'LOYALUSER582' ), Rop_I18n::UPSELL_LINK ), 'rop-welcome', 'notice' ),
);
}
);
$vendor_file = ROP_LITE_PATH . '/vendor/autoload.php';
if ( is_readable( $vendor_file ) ) {
require_once $vendor_file;
}
if ( defined( 'ROP_CRON_ALTERNATIVE' ) && true === ROP_CRON_ALTERNATIVE ) {
if ( class_exists( 'RopCronSystem\Rop_Cron_Core' ) ) {
new RopCronSystem\Rop_Cron_Core();
}
}
add_filter(
'themeisle_sdk_products',
function ( $products ) {
$products[] = ROP_LITE_BASE_FILE;
return $products;
}
);
add_filter(
'tweet_old_post_about_us_metadata',
function() {
$global_settings = new \Rop_Global_Settings();
return array(
'logo' => ROP_LITE_URL . 'assets/img/logo_rop.png',
'location' => 'TweetOldPost',
'has_upgrade_menu' => $global_settings->license_type() < 1,
'upgrade_text' => esc_html__( 'Upgrade to Pro', 'tweet-old-post' ),
'upgrade_link' => function_exists( 'tsdk_utmify' ) ? tsdk_utmify( Rop_I18n::UPSELL_LINK, 'aboutUsPage' ) : esc_url( Rop_I18n::UPSELL_LINK ),
);
}
);
add_filter( 'themeisle_sdk_enable_telemetry', '__return_true' );
$plugin = new Rop();
$plugin->run();
}
require( plugin_dir_path( __FILE__ ) . '/class-rop-autoloader.php' );
Rop_Autoloader::define_namespaces( array( 'Rop' ) );
/**
* Invocation of the Autoloader::loader method.
*
* @since 8.0.0
*/
spl_autoload_register( array( 'Rop_Autoloader', 'loader' ) );
run_rop();