|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
Plugin Name: Post Promoter Pro |
|
4
|
|
|
Plugin URI: https://postpromoterpro.com |
|
5
|
|
|
Description: Maximize your social media presence on Twitter, Facebook, and LinkedIn. |
|
6
|
|
|
Version: 2.3-beta2 |
|
7
|
|
|
Author: Post Promoter Pro |
|
8
|
|
|
Author URI: https://postpromoterpro.com |
|
9
|
|
|
License: GPLv2 |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
define( 'PPP_PATH', plugin_dir_path( __FILE__ ) ); |
|
13
|
|
|
define( 'PPP_VERSION', '2.3-beta2' ); |
|
14
|
|
|
define( 'PPP_FILE', plugin_basename( __FILE__ ) ); |
|
15
|
|
|
define( 'PPP_URL', plugins_url( '/', PPP_FILE ) ); |
|
16
|
|
|
|
|
17
|
|
|
define( 'PPP_STORE_URL', 'https://postpromoterpro.com' ); |
|
18
|
|
|
define( 'PPP_PLUGIN_NAME', 'Post Promoter Pro' ); |
|
19
|
|
|
if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
20
|
|
|
// load our custom updater |
|
21
|
|
|
include( PPP_PATH . '/includes/EDD_SL_Plugin_Updater.php' ); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
class PostPromoterPro { |
|
25
|
|
|
private static $ppp_instance; |
|
26
|
|
|
|
|
27
|
|
|
private function __construct() { |
|
28
|
|
|
add_action( 'init', array( $this, 'ppp_loaddomain' ), 1 ); |
|
29
|
|
|
|
|
30
|
|
|
if ( ! is_callable( 'curl_init' ) ) { |
|
31
|
|
|
add_action( 'admin_notices', array( $this, 'no_curl' ) ); |
|
32
|
|
|
} else { |
|
33
|
|
|
global $ppp_options, $ppp_social_settings, $ppp_share_settings; |
|
34
|
|
|
|
|
35
|
|
|
include PPP_PATH . '/includes/general-functions.php'; |
|
36
|
|
|
include PPP_PATH . '/includes/share-functions.php'; |
|
37
|
|
|
include PPP_PATH . '/includes/cron-functions.php'; |
|
38
|
|
|
include PPP_PATH . '/includes/filters.php'; |
|
39
|
|
|
include PPP_PATH . '/includes/libs/social-loader.php'; |
|
40
|
|
|
include PPP_PATH . '/includes/libs/class-wp-logging.php'; |
|
41
|
|
|
|
|
42
|
|
|
if ( is_admin() ) { |
|
43
|
|
|
include PPP_PATH . '/includes/admin/upgrades.php'; |
|
44
|
|
|
include PPP_PATH . '/includes/admin/do-upgrades.php'; |
|
45
|
|
|
include PPP_PATH . '/includes/admin/actions.php'; |
|
46
|
|
|
include PPP_PATH . '/includes/admin/admin-pages.php'; |
|
47
|
|
|
include PPP_PATH . '/includes/admin/admin-ajax.php'; |
|
48
|
|
|
include PPP_PATH . '/includes/admin/meta-boxes.php'; |
|
49
|
|
|
include PPP_PATH . '/includes/admin/welcome.php'; |
|
50
|
|
|
include PPP_PATH . '/includes/admin/dashboard.php'; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
register_activation_hook( PPP_FILE, array( $this, 'activation_setup' ) ); |
|
54
|
|
|
|
|
55
|
|
|
$ppp_options = get_option( 'ppp_options' ); |
|
56
|
|
|
$ppp_social_settings = get_option( 'ppp_social_settings' ); |
|
57
|
|
|
$ppp_share_settings = get_option( 'ppp_share_settings' ); |
|
58
|
|
|
|
|
59
|
|
|
$this->hooks(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Get the singleton instance of our plugin |
|
66
|
|
|
* @return class The Instance |
|
67
|
|
|
* @access public |
|
68
|
|
|
*/ |
|
69
|
1 |
|
public static function getInstance() { |
|
70
|
1 |
|
if ( !self::$ppp_instance ) { |
|
71
|
|
|
self::$ppp_instance = new PostPromoterPro(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
1 |
|
return self::$ppp_instance; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Nag if cURL is disabled |
|
79
|
|
|
* @return void |
|
80
|
|
|
*/ |
|
81
|
|
|
public function no_curl() { |
|
82
|
|
|
?> |
|
83
|
|
|
<div class="no-curl"> |
|
84
|
|
|
<p><?php _e( 'Post Promoter Pro requires cURL to be enabled. Please enable it to continue using the plugin.', 'ppp-txt' ); ?></p> |
|
85
|
|
|
</div> |
|
86
|
|
|
<?php |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* On activation, setup the default options |
|
91
|
|
|
* @return void |
|
92
|
|
|
*/ |
|
93
|
|
|
public function activation_setup() { |
|
94
|
|
|
// If the settings already exist, don't do this |
|
95
|
|
|
if ( get_option( 'ppp_options' ) ) { |
|
96
|
|
|
return; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
$default_settings['post_types']['post'] = '1'; |
|
|
|
|
|
|
100
|
|
|
update_option( 'ppp_options', $default_settings ); |
|
101
|
|
|
|
|
102
|
|
|
$default_share_settings['twitter']['share_on_publish'] = '1'; |
|
|
|
|
|
|
103
|
|
|
$default_share_settings['facebook']['share_on_publish'] = '1'; |
|
104
|
|
|
$default_share_settings['linkedin']['share_on_publish'] = '1'; |
|
105
|
|
|
update_option( 'ppp_share_settings', $default_share_settings ); |
|
106
|
|
|
|
|
107
|
|
|
set_transient( '_ppp_activation_redirect', 'true', 30 ); |
|
108
|
|
|
|
|
109
|
|
|
ppp_set_upgrade_complete( 'upgrade_post_meta' ); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
private function hooks() { |
|
113
|
|
|
if ( is_admin() ) { |
|
114
|
|
|
add_action( 'admin_init', array( $this, 'ppp_register_settings' ) ); |
|
115
|
|
|
add_action( 'admin_init', 'ppp_upgrade_plugin', 1 ); |
|
116
|
|
|
|
|
117
|
|
|
// Handle licenses |
|
118
|
|
|
add_action( 'admin_init', array( $this, 'plugin_updater' ) ); |
|
119
|
|
|
add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
120
|
|
|
add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
121
|
|
|
|
|
122
|
|
|
add_action( 'admin_menu', array( $this, 'ppp_setup_admin_menu' ), 1000, 0 ); |
|
123
|
|
|
add_filter( 'plugin_action_links', array( $this, 'plugin_settings_links' ), 10, 2 ); |
|
124
|
|
|
add_action( 'admin_enqueue_scripts', array( $this, 'load_custom_scripts' ), 99 ); |
|
125
|
|
|
add_action( 'admin_enqueue_scripts', array( $this, 'load_styles' ), PHP_INT_MAX ); |
|
126
|
|
|
add_action( 'wp_trash_post', 'ppp_remove_scheduled_shares', 10, 1 ); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
add_action( 'init', array( $this, 'get_actions' ) ); |
|
130
|
|
|
add_action( 'save_post', 'ppp_schedule_share', 99, 2); |
|
131
|
|
|
add_action( 'transition_post_status', 'ppp_share_on_publish', 99, 3); |
|
132
|
|
|
add_action( 'init', 'ppp_add_image_sizes' ); |
|
133
|
|
|
add_filter( 'wp_log_types', array( $this, 'register_log_type' ), 10, 1 ); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Queue up the JavaScript file for the admin page, only on our admin page |
|
138
|
|
|
* @param string $hook The current page in the admin |
|
139
|
|
|
* @return void |
|
140
|
|
|
* @access public |
|
141
|
|
|
*/ |
|
142
|
|
|
public function load_custom_scripts( $hook ) { |
|
143
|
|
|
|
|
144
|
|
|
$allowed_pages = array( |
|
145
|
|
|
'toplevel_page_ppp-options', |
|
146
|
|
|
'post-promoter_page_ppp-social-settings', |
|
147
|
|
|
'post-new.php', |
|
148
|
|
|
'post.php', |
|
149
|
|
|
'post-promoter_page_ppp-schedule-info', |
|
150
|
|
|
); |
|
151
|
|
|
|
|
152
|
|
|
$allowed_pages = apply_filters( 'ppp_admin_scripts_pages', $allowed_pages, $hook ); |
|
153
|
|
|
|
|
154
|
|
|
if ( ! in_array( $hook, $allowed_pages ) ) { |
|
155
|
|
|
return; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
wp_enqueue_script( 'jquery-ui-core' ); |
|
159
|
|
|
wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
160
|
|
|
|
|
161
|
|
|
$jquery_ui_timepicker_path = PPP_URL . 'includes/scripts/libs/jquery-ui-timepicker-addon.js'; |
|
162
|
|
|
wp_enqueue_script( 'ppp_timepicker_js', $jquery_ui_timepicker_path , array( 'jquery', 'jquery-ui-core' ), PPP_VERSION, true ); |
|
163
|
|
|
wp_enqueue_script( 'ppp_core_custom_js', PPP_URL.'includes/scripts/js/ppp_custom.js', 'jquery', PPP_VERSION, true ); |
|
164
|
|
|
|
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
public function load_styles( $hook ) { |
|
|
|
|
|
|
168
|
|
|
|
|
169
|
|
|
// List of people who make it impossible to override their jQuery UI as it's in their core CSS...so only |
|
170
|
|
|
// load ours if they don't exist |
|
171
|
|
|
if ( ! wp_style_is( 'ot-admin-css' ) && ! wp_style_is( 'jquery-ui-css' ) ) { |
|
172
|
|
|
wp_enqueue_style( 'jquery-ui-css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/flick/jquery-ui.css' ); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
wp_register_style( 'ppp_admin_css', PPP_URL . 'includes/scripts/css/admin-style.css', false, PPP_VERSION ); |
|
176
|
|
|
wp_enqueue_style( 'ppp_admin_css' ); |
|
177
|
|
|
|
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* Adds the Settings and Post Promoter Pro Link to the Settings page list |
|
182
|
|
|
* @param array $links The current list of links |
|
183
|
|
|
* @param string $file The plugin file |
|
184
|
|
|
* @return array The new list of links, with our additional ones added |
|
185
|
|
|
* @access public |
|
186
|
|
|
*/ |
|
187
|
|
|
public function plugin_settings_links( $links, $file ) { |
|
188
|
|
|
if ( $file != PPP_FILE ) { |
|
189
|
|
|
return $links; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
$settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=ppp-options' ), __( 'Settings', 'ppp-txt' ) ); |
|
193
|
|
|
|
|
194
|
|
|
array_unshift( $links, $settings_link ); |
|
195
|
|
|
|
|
196
|
|
|
return $links; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* Add the Pushover Notifications item to the Settings menu |
|
201
|
|
|
* @return void |
|
202
|
|
|
* @access public |
|
203
|
|
|
*/ |
|
204
|
|
|
public function ppp_setup_admin_menu() { |
|
205
|
|
|
$role = apply_filters( 'ppp_manage_role', 'administrator' ); |
|
206
|
|
|
|
|
207
|
|
|
add_menu_page( |
|
208
|
|
|
__( 'Post Promoter', 'ppp-txt' ), |
|
209
|
|
|
__( 'Post Promoter', 'ppp-txt' ), |
|
210
|
|
|
$role, |
|
211
|
|
|
'ppp-options', |
|
212
|
|
|
'ppp_admin_page' |
|
213
|
|
|
); |
|
214
|
|
|
|
|
215
|
|
|
add_submenu_page( |
|
216
|
|
|
'ppp-options', |
|
217
|
|
|
__( 'Social Settings', 'ppp-txt' ), |
|
218
|
|
|
__( 'Social Settings', 'ppp-txt' ), |
|
219
|
|
|
$role, |
|
220
|
|
|
'ppp-social-settings', |
|
221
|
|
|
'ppp_display_social' |
|
222
|
|
|
); |
|
223
|
|
|
|
|
224
|
|
|
add_submenu_page( |
|
225
|
|
|
'ppp-options', |
|
226
|
|
|
__( 'Schedule', 'ppp-txt' ), |
|
227
|
|
|
__( 'Schedule', 'ppp-txt' ), |
|
228
|
|
|
$role, |
|
229
|
|
|
'ppp-schedule-info', |
|
230
|
|
|
'ppp_display_schedule' |
|
231
|
|
|
); |
|
232
|
|
|
|
|
233
|
|
|
add_submenu_page( |
|
234
|
|
|
'ppp-options', |
|
235
|
|
|
__( 'System Info', 'ppp-txt' ), |
|
236
|
|
|
__( 'System Info', 'ppp-txt' ), |
|
237
|
|
|
$role, |
|
238
|
|
|
'ppp-system-info', |
|
239
|
|
|
'ppp_display_sysinfo' |
|
240
|
|
|
); |
|
241
|
|
|
|
|
242
|
|
|
add_submenu_page( |
|
243
|
|
|
null, |
|
244
|
|
|
__( 'PPP Upgrades', 'ppp-txt' ), |
|
245
|
|
|
__( 'PPP Upgrades', 'ppp-txt' ), |
|
246
|
|
|
$role, |
|
247
|
|
|
'ppp-upgrades', |
|
248
|
|
|
'ppp_upgrades_screen' |
|
249
|
|
|
); |
|
250
|
|
|
|
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* Register/Whitelist our settings on the settings page, allow extensions and other plugins to hook into this |
|
255
|
|
|
* @return void |
|
256
|
|
|
* @access public |
|
257
|
|
|
*/ |
|
258
|
|
|
public function ppp_register_settings() { |
|
259
|
|
|
register_setting( 'ppp-options', 'ppp_options' ); |
|
260
|
|
|
register_setting( 'ppp-options', '_ppp_license_key', array( $this, 'ppp_sanitize_license' ) ); |
|
261
|
|
|
|
|
262
|
|
|
register_setting( 'ppp-social-settings', 'ppp_social_settings' ); |
|
263
|
|
|
register_setting( 'ppp-share-settings', 'ppp_share_settings' ); |
|
264
|
|
|
do_action( 'ppp_register_additional_settings' ); |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
/** |
|
268
|
|
|
* Load the Text Domain for i18n |
|
269
|
|
|
* @return void |
|
270
|
|
|
* @access public |
|
271
|
|
|
*/ |
|
272
|
|
|
public function ppp_loaddomain() { |
|
273
|
|
|
load_plugin_textdomain( 'ppp-txt', false, '/post-promoter-pro/languages/' ); |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
/** |
|
277
|
|
|
* Sets up the EDD SL Plugin updated class |
|
278
|
|
|
* @return void |
|
279
|
|
|
*/ |
|
280
|
|
|
public function plugin_updater() { |
|
281
|
|
|
|
|
282
|
|
|
if ( defined( 'NO_AUTO_UPDATE' ) && true === NO_AUTO_UPDATE ) { |
|
283
|
|
|
return; |
|
284
|
|
|
} |
|
285
|
|
|
|
|
286
|
|
|
$license_key = trim( get_option( '_ppp_license_key' ) ); |
|
287
|
|
|
|
|
288
|
|
|
if ( empty( $license_key ) ) { |
|
289
|
|
|
add_action( 'admin_notices', array( $this, 'no_license_nag' ) ); |
|
290
|
|
|
return; |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
// setup the updater |
|
294
|
|
|
$edd_updater = new EDD_SL_Plugin_Updater( PPP_STORE_URL, __FILE__, array( |
|
|
|
|
|
|
295
|
|
|
'version' => PPP_VERSION, // current version number |
|
296
|
|
|
'license' => $license_key, // license key (used get_option above to retrieve from DB) |
|
297
|
|
|
'item_name' => PPP_PLUGIN_NAME, // name of this plugin |
|
298
|
|
|
'author' => 'Post Promoter Pro' // author of this plugin |
|
299
|
|
|
) |
|
300
|
|
|
); |
|
301
|
|
|
} |
|
302
|
|
|
|
|
303
|
|
|
/** |
|
304
|
|
|
* If no license key is saved, show a notice |
|
305
|
|
|
* @return void |
|
306
|
|
|
*/ |
|
307
|
|
|
public function no_license_nag() { |
|
308
|
|
|
?> |
|
309
|
|
|
<div class="updated"> |
|
310
|
|
|
<p> |
|
311
|
|
|
<?php printf( |
|
312
|
|
|
__( 'Post Promoter Pro requires your license key to work, please <a href="%s">enter it now</a>.', 'ppp-txt' ), |
|
313
|
|
|
admin_url( 'admin.php?page=ppp-options' ) |
|
314
|
|
|
); |
|
315
|
|
|
?> |
|
316
|
|
|
</p> |
|
317
|
|
|
</div> |
|
318
|
|
|
<?php |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
/** |
|
322
|
|
|
* Deactivates the license key |
|
323
|
|
|
* @return void |
|
324
|
|
|
*/ |
|
325
|
|
|
public function deactivate_license() { |
|
326
|
|
|
// listen for our activate button to be clicked |
|
327
|
|
|
if( isset( $_POST['ppp_license_deactivate'] ) ) { |
|
328
|
|
|
|
|
329
|
|
|
// run a quick security check |
|
330
|
|
|
if( ! check_admin_referer( 'ppp_deactivate_nonce', 'ppp_deactivate_nonce' ) ) { |
|
331
|
|
|
return; |
|
332
|
|
|
} |
|
333
|
|
|
// get out if we didn't click the Activate button |
|
334
|
|
|
|
|
335
|
|
|
// retrieve the license from the database |
|
336
|
|
|
$license = trim( get_option( '_ppp_license_key' ) ); |
|
337
|
|
|
|
|
338
|
|
|
|
|
339
|
|
|
// data to send in our API request |
|
340
|
|
|
$api_params = array( |
|
341
|
|
|
'edd_action'=> 'deactivate_license', |
|
342
|
|
|
'license' => $license, |
|
343
|
|
|
'item_name' => urlencode( PPP_PLUGIN_NAME ) // the name of our product in EDD |
|
344
|
|
|
); |
|
345
|
|
|
|
|
346
|
|
|
// Call the custom API. |
|
347
|
|
|
$response = wp_remote_get( add_query_arg( $api_params, PPP_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) ); |
|
348
|
|
|
|
|
349
|
|
|
// make sure the response came back okay |
|
350
|
|
|
if ( is_wp_error( $response ) ) { |
|
351
|
|
|
return false; |
|
352
|
|
|
} |
|
353
|
|
|
|
|
354
|
|
|
// decode the license data |
|
355
|
|
|
$license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
356
|
|
|
|
|
357
|
|
|
// $license_data->license will be either "deactivated" or "failed" |
|
358
|
|
|
if( $license_data->license == 'deactivated' ) { |
|
359
|
|
|
delete_option( '_ppp_license_key_status' ); |
|
360
|
|
|
} |
|
361
|
|
|
|
|
362
|
|
|
} |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
|
|
/** |
|
366
|
|
|
* Activates the license key provided |
|
367
|
|
|
* @return void |
|
368
|
|
|
*/ |
|
369
|
|
|
public function activate_license() { |
|
370
|
|
|
// listen for our activate button to be clicked |
|
371
|
|
|
if( isset( $_POST['ppp_license_activate'] ) ) { |
|
372
|
|
|
|
|
373
|
|
|
// run a quick security check |
|
374
|
|
|
if( ! check_admin_referer( 'ppp_activate_nonce', 'ppp_activate_nonce' ) ) { |
|
375
|
|
|
return; |
|
376
|
|
|
} |
|
377
|
|
|
// get out if we didn't click the Activate button |
|
378
|
|
|
|
|
379
|
|
|
// retrieve the license from the database |
|
380
|
|
|
$license = trim( get_option( '_ppp_license_key' ) ); |
|
381
|
|
|
|
|
382
|
|
|
|
|
383
|
|
|
// data to send in our API request |
|
384
|
|
|
$api_params = array( |
|
385
|
|
|
'edd_action' => 'activate_license', |
|
386
|
|
|
'license' => $license, |
|
387
|
|
|
'item_name' => urlencode( PPP_PLUGIN_NAME ), |
|
388
|
|
|
); |
|
389
|
|
|
|
|
390
|
|
|
// Call the custom API. |
|
391
|
|
|
$response = wp_remote_get( add_query_arg( $api_params, PPP_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) ); |
|
392
|
|
|
|
|
393
|
|
|
// make sure the response came back okay |
|
394
|
|
|
if ( is_wp_error( $response ) ) { |
|
395
|
|
|
return false; |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
|
|
// decode the license data |
|
399
|
|
|
$license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
400
|
|
|
|
|
401
|
|
|
// $license_data->license will be either "active" or "inactive" |
|
402
|
|
|
|
|
403
|
|
|
update_option( '_ppp_license_key_status', $license_data->license ); |
|
404
|
|
|
|
|
405
|
|
|
} |
|
406
|
|
|
} |
|
407
|
|
|
|
|
408
|
|
|
/** |
|
409
|
|
|
* Sanatize the liscense key being provided |
|
410
|
|
|
* @param string $new The License key provided |
|
411
|
|
|
* @return string Sanitized license key |
|
412
|
|
|
*/ |
|
413
|
|
|
public function ppp_sanitize_license( $new ) { |
|
414
|
|
|
$old = get_option( '_ppp_license_key' ); |
|
415
|
|
|
if( $old && $old != $new ) { |
|
416
|
|
|
delete_option( '_ppp_license_key_status' ); // new license has been entered, so must reactivate |
|
417
|
|
|
} |
|
418
|
|
|
return $new; |
|
419
|
|
|
} |
|
420
|
|
|
|
|
421
|
|
|
/** |
|
422
|
|
|
* Hook to listen for our actions |
|
423
|
|
|
* |
|
424
|
|
|
* @return void |
|
425
|
|
|
*/ |
|
426
|
|
|
public function get_actions() { |
|
427
|
|
|
if ( isset( $_GET['ppp_action'] ) ) { |
|
428
|
|
|
do_action( 'ppp_' . $_GET['ppp_action'], $_GET ); |
|
429
|
|
|
} |
|
430
|
|
|
} |
|
431
|
|
|
|
|
432
|
|
|
/** |
|
433
|
|
|
* Register our log type for when items are shared |
|
434
|
|
|
* |
|
435
|
|
|
* @since 2.3 |
|
436
|
|
|
* @param array $log_types Array of log types |
|
437
|
|
|
* @return array |
|
438
|
|
|
*/ |
|
439
|
|
|
public function register_log_type( $log_types ) { |
|
|
|
|
|
|
440
|
|
|
$types[] = 'ppp_share'; |
|
|
|
|
|
|
441
|
|
|
return $types; |
|
442
|
|
|
} |
|
443
|
|
|
|
|
444
|
|
|
} |
|
445
|
|
|
|
|
446
|
|
|
/** |
|
447
|
|
|
* Load and access the one true instance of Post Promoter Pro |
|
448
|
|
|
* |
|
449
|
|
|
* @return object The Post_Promoter_Pro instance |
|
450
|
|
|
*/ |
|
451
|
|
|
function post_promoter_pro() { |
|
452
|
1 |
|
global $ppp_loaded; |
|
453
|
|
|
|
|
454
|
1 |
|
$ppp_loaded = PostPromoterPro::getInstance(); |
|
455
|
1 |
|
return $ppp_loaded; |
|
456
|
|
|
} |
|
457
|
|
|
add_action( 'plugins_loaded', 'post_promoter_pro' ); |
|
458
|
|
|
|
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArrayis initialized the first time when the foreach loop is entered. You can also see that the value of thebarkey is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.