| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WP to Buffer |
| 4 |
* Plugin URI: http://www.wpzinc.com/plugins/wp-to-buffer-pro |
| 5 |
* Version: 3.8.3 |
| 6 |
* Author: WP Zinc |
| 7 |
* Author URI: http://www.wpzinc.com |
| 8 |
* Description: Send WordPress Pages, Posts or Custom Post Types to your Buffer (buffer.com) account for scheduled publishing to social networks. |
| 9 |
*/ |
| 10 |
|
| 11 |
/** |
| 12 |
* WP to Buffer Class |
| 13 |
* |
| 14 |
* @package WP_To_Buffer |
| 15 |
* @author Tim Carr |
| 16 |
* @version 1.0.0 |
| 17 |
* @copyright WP Zinc |
| 18 |
*/ |
| 19 |
class WP_To_Buffer { |
| 20 |
|
| 21 |
/** |
| 22 |
* Holds the class object. |
| 23 |
* |
| 24 |
* @since 3.1.4 |
| 25 |
* |
| 26 |
* @var object |
| 27 |
*/ |
| 28 |
public static $instance; |
| 29 |
|
| 30 |
/** |
| 31 |
* Plugin |
| 32 |
* |
| 33 |
* @since 3.0.0 |
| 34 |
* |
| 35 |
* @var object |
| 36 |
*/ |
| 37 |
public $plugin = ''; |
| 38 |
|
| 39 |
/** |
| 40 |
* Dashboard |
| 41 |
* |
| 42 |
* @since 3.1.4 |
| 43 |
* |
| 44 |
* @var object |
| 45 |
*/ |
| 46 |
public $dashboard = ''; |
| 47 |
|
| 48 |
/** |
| 49 |
* Classes |
| 50 |
* |
| 51 |
* @since 3.4.9 |
| 52 |
* |
| 53 |
* @var array |
| 54 |
*/ |
| 55 |
public $classes = ''; |
| 56 |
|
| 57 |
/** |
| 58 |
* Constructor. Acts as a bootstrap to load the rest of the plugin |
| 59 |
* |
| 60 |
* @since 1.0.0 |
| 61 |
*/ |
| 62 |
public function __construct() { |
| 63 |
|
| 64 |
// Bail if the Pro version of the Plugin is active |
| 65 |
if ( class_exists( 'WP_To_Buffer_Pro' ) ) { |
| 66 |
return; |
| 67 |
} |
| 68 |
|
| 69 |
// Plugin Details |
| 70 |
$this->plugin = new stdClass; |
| 71 |
$this->plugin->name = 'wp-to-buffer'; |
| 72 |
$this->plugin->filter_name = 'wp_to_buffer'; |
| 73 |
$this->plugin->displayName = 'WP to Buffer'; |
| 74 |
|
| 75 |
$this->plugin->settingsName = 'wp-to-buffer-pro'; // Settings key - used in both Free + Pro, and for oAuth |
| 76 |
$this->plugin->account = 'Buffer'; |
| 77 |
$this->plugin->version = '3.8.3'; |
| 78 |
$this->plugin->buildDate = '2022-10-25 12:00:00'; |
| 79 |
$this->plugin->requires = '5.0'; |
| 80 |
$this->plugin->tested = '6.0.3'; |
| 81 |
$this->plugin->folder = plugin_dir_path( __FILE__ ); |
| 82 |
$this->plugin->url = plugin_dir_url( __FILE__ ); |
| 83 |
$this->plugin->documentation_url= 'https://www.wpzinc.com/documentation/wordpress-buffer-pro'; |
| 84 |
$this->plugin->support_url = 'https://www.wpzinc.com/support'; |
| 85 |
$this->plugin->upgrade_url = 'https://www.wpzinc.com/plugins/wordpress-to-buffer-pro'; |
| 86 |
$this->plugin->review_name = 'wp-to-buffer'; |
| 87 |
$this->plugin->review_notice = sprintf( __( 'Thanks for using %s to schedule your social media statuses on Buffer!', $this->plugin->name ), $this->plugin->displayName ); |
| 88 |
|
| 89 |
$this->plugin->default_schedule = 'queue_bottom'; |
| 90 |
|
| 91 |
// Upgrade Reasons |
| 92 |
$this->plugin->upgrade_reasons = array( |
| 93 |
array( |
| 94 |
__( 'Post to Instagram and Pinterest', $this->plugin->name ), |
| 95 |
__( 'Pro supports Direct Posting to Instagram Business Profiles and Pinterest Boards', $this->plugin->name ), |
| 96 |
), |
| 97 |
array( |
| 98 |
__( 'Multiple, Customisable Status Messages', $this->plugin->name ), |
| 99 |
__( 'Each Post Type and Social Network can have multiple, unique status message and settings', $this->plugin->name ), |
| 100 |
), |
| 101 |
array( |
| 102 |
__( 'Conditionally send Status Messages', $this->plugin->name ), |
| 103 |
__( 'Only send status(es) to Buffer based on Post Author(s), Taxonomy Term(s) and/or Custom Field Values', $this->plugin->name ), |
| 104 |
), |
| 105 |
array( |
| 106 |
__( 'More Scheduling Options', $this->plugin->name ), |
| 107 |
__( 'Each status update can be added to the start/end of your Buffer queue, posted immediately or scheduled at a specific time', $this->plugin->name ), |
| 108 |
), |
| 109 |
array( |
| 110 |
__( 'Dynamic Status Tags', $this->plugin->name ), |
| 111 |
__( 'Dynamically build status updates with data from the Post Author and Custom Fields', $this->plugin->name ), |
| 112 |
), |
| 113 |
array( |
| 114 |
__( 'Separate Statuses per Social Network', $this->plugin->name ), |
| 115 |
__( 'Define different statuses for each Post Type and Social Network', $this->plugin->name ), |
| 116 |
), |
| 117 |
array( |
| 118 |
__( 'Per-Post Settings', $this->plugin->name ), |
| 119 |
__( 'Override Settings on Individual Posts: Each Post can have its own Buffer settings', $this->plugin->name ), |
| 120 |
), |
| 121 |
array( |
| 122 |
__( 'Repost Old Posts', $this->plugin->name ), |
| 123 |
__( 'Automatically Revive Old Posts that haven\'t been updated in a while, choosing the number of days, weeks or years to re-share content on social media.', $this->plugin->name ), |
| 124 |
), |
| 125 |
array( |
| 126 |
__( 'Bulk Publish Old Posts', $this->plugin->name ), |
| 127 |
__( 'Manually re-share evergreen WordPress content and revive old posts with the Bulk Publish option', $this->plugin->name ), |
| 128 |
), |
| 129 |
array( |
| 130 |
__( 'The Events Calendar and Event Manager Integration', $this->plugin->name ), |
| 131 |
__( 'Schedule Posts to Buffer based on your Event\'s Start or End date, and display Event-specific details in your status updates', $this->plugin->name ), |
| 132 |
), |
| 133 |
array( |
| 134 |
__( 'SEO Integration', $this->plugin->name ), |
| 135 |
__( 'Display SEO-specific information in your status updates from All-In-One SEO Pack, Rank Math, SEOPress and Yoast SEO', $this->plugin->name ), |
| 136 |
), |
| 137 |
array( |
| 138 |
__( 'WooCommerce Integration', $this->plugin->name ), |
| 139 |
__( 'Display Product-specific information in your status updates', $this->plugin->name ), |
| 140 |
), |
| 141 |
array( |
| 142 |
__( 'Autoblogging and Frontend Post Submission Integration', $this->plugin->name ), |
| 143 |
__( 'Pro supports autoblogging and frontend post submission Plugins, including User Submitted Posts, WP Property Feed, WPeMatico and WP Job Manager', $this->plugin->name ), |
| 144 |
), |
| 145 |
array( |
| 146 |
__( 'Shortcode Support', $this->plugin->name ), |
| 147 |
__( 'Use shortcodes in status updates', $this->plugin->name ), |
| 148 |
), |
| 149 |
array( |
| 150 |
__( 'Full Image Control', $this->plugin->name ), |
| 151 |
__( 'Choose to display the WordPress Featured Image with your status updates, or define up to 4 custom images for each Post.', $this->plugin->name ), |
| 152 |
), |
| 153 |
array( |
| 154 |
__( 'WP-Cron and WP-CLI Compatible', $this->plugin->name ), |
| 155 |
__( 'Optionally enable WP-Cron to send status updates via Cron, speeding up UI performance and/or choose to use WP-CLI for reposting old posts', $this->plugin->name ), |
| 156 |
), |
| 157 |
); |
| 158 |
|
| 159 |
// Dashboard Submodule |
| 160 |
if ( ! class_exists( 'WPZincDashboardWidget' ) ) { |
| 161 |
require_once $this->plugin->folder . '_modules/dashboard/class-wpzincdashboardwidget.php'; |
| 162 |
} |
| 163 |
$this->dashboard = new WPZincDashboardWidget( $this->plugin, 'https://www.wpzinc.com/wp-content/plugins/lum-deactivation' ); |
| 164 |
|
| 165 |
// Defer loading of Plugin Classes |
| 166 |
add_action( 'init', array( $this, 'initialize' ), 1 ); |
| 167 |
add_action( 'init', array( $this, 'upgrade' ), 2 ); |
| 168 |
|
| 169 |
} |
| 170 |
|
| 171 |
/** |
| 172 |
* Initializes required and licensed classes |
| 173 |
* |
| 174 |
* @since 3.4.9 |
| 175 |
*/ |
| 176 |
public function initialize() { |
| 177 |
|
| 178 |
$this->classes = new stdClass; |
| 179 |
|
| 180 |
// Initialize required classes |
| 181 |
$this->classes->admin = new WP_To_Social_Pro_Admin( self::$instance ); |
| 182 |
$this->classes->ajax = new WP_To_Social_Pro_AJAX( self::$instance ); |
| 183 |
$this->classes->api = new WP_To_Social_Pro_Buffer_API( self::$instance ); |
| 184 |
$this->classes->common = new WP_To_Social_Pro_Common( self::$instance ); |
| 185 |
$this->classes->cron = new WP_To_Social_Pro_Cron( self::$instance ); |
| 186 |
$this->classes->image = new WP_To_Social_Pro_Image( self::$instance ); |
| 187 |
$this->classes->install = new WP_To_Social_Pro_Install( self::$instance ); |
| 188 |
$this->classes->log = new WP_To_Social_Pro_Log( self::$instance ); |
| 189 |
$this->classes->media_library = new WP_To_Social_Pro_Media_Library( self::$instance ); |
| 190 |
$this->classes->notices = new WP_To_Social_Pro_Notices( self::$instance ); |
| 191 |
$this->classes->post = new WP_To_Social_Pro_Post( self::$instance ); |
| 192 |
$this->classes->publish = new WP_To_Social_Pro_Publish( self::$instance ); |
| 193 |
$this->classes->screen = new WP_To_Social_Pro_Screen( self::$instance ); |
| 194 |
$this->classes->settings = new WP_To_Social_Pro_Settings( self::$instance ); |
| 195 |
$this->classes->twitter_api = new WP_To_Social_Pro_Twitter_API( self::$instance ); |
| 196 |
$this->classes->validation = new WP_To_Social_Pro_Validation( self::$instance ); |
| 197 |
|
| 198 |
// Run the migration routine from Free + Pro v2.x --> Pro v3.x |
| 199 |
if ( is_admin() ) { |
| 200 |
$this->classes->settings->migrate_settings(); |
| 201 |
} |
| 202 |
|
| 203 |
} |
| 204 |
|
| 205 |
/** |
| 206 |
* Runs the upgrade routine once the plugin has loaded |
| 207 |
* |
| 208 |
* @since 3.2.5 |
| 209 |
*/ |
| 210 |
public function upgrade() { |
| 211 |
|
| 212 |
// Run upgrade routine |
| 213 |
$this->get_class( 'install' )->upgrade(); |
| 214 |
|
| 215 |
} |
| 216 |
|
| 217 |
/** |
| 218 |
* Returns the given class |
| 219 |
* |
| 220 |
* @since 3.4.9 |
| 221 |
* |
| 222 |
* @param string $name Class Name |
| 223 |
*/ |
| 224 |
public function get_class( $name ) { |
| 225 |
|
| 226 |
// If the class hasn't been loaded, throw a WordPress die screen |
| 227 |
// to avoid a PHP fatal error. |
| 228 |
if ( ! isset( $this->classes->{ $name } ) ) { |
| 229 |
// Define the error |
| 230 |
$error = new WP_Error( 'wp_to_buffer_get_class', sprintf( __( '%s: Error: Could not load Plugin class <strong>%s</strong>', $this->plugin->name ), $this->plugin->displayName, $name ) ); |
| 231 |
|
| 232 |
// Depending on the request, return or display an error |
| 233 |
// Admin UI |
| 234 |
if ( is_admin() ) { |
| 235 |
wp_die( |
| 236 |
$error, |
| 237 |
sprintf( __( '%s: Error', $this->plugin->name ), $this->plugin->displayName ), |
| 238 |
array( |
| 239 |
'back_link' => true, |
| 240 |
) |
| 241 |
); |
| 242 |
} |
| 243 |
|
| 244 |
// Cron / CLI |
| 245 |
return $error; |
| 246 |
} |
| 247 |
|
| 248 |
// Return the class object |
| 249 |
return $this->classes->{ $name }; |
| 250 |
|
| 251 |
} |
| 252 |
|
| 253 |
/** |
| 254 |
* Returns the singleton instance of the class. |
| 255 |
* |
| 256 |
* @since 3.1.4 |
| 257 |
* |
| 258 |
* @return object Class. |
| 259 |
*/ |
| 260 |
public static function get_instance() { |
| 261 |
|
| 262 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { |
| 263 |
self::$instance = new self; |
| 264 |
} |
| 265 |
|
| 266 |
return self::$instance; |
| 267 |
|
| 268 |
} |
| 269 |
|
| 270 |
} |
| 271 |
|
| 272 |
/** |
| 273 |
* Define the autoloader for this Plugin |
| 274 |
* |
| 275 |
* @since 3.4.7 |
| 276 |
* |
| 277 |
* @param string $class_name The class to load |
| 278 |
*/ |
| 279 |
function WP_To_Buffer_Autoloader( $class_name ) { |
| 280 |
|
| 281 |
// Define the required start of the class name |
| 282 |
$class_start_name = array( |
| 283 |
'WP_To_Social_Pro', |
| 284 |
); |
| 285 |
|
| 286 |
// Get the number of parts the class start name has |
| 287 |
$class_parts_count = count( explode( '_', $class_start_name[0] ) ); |
| 288 |
|
| 289 |
// Break the class name into an array |
| 290 |
$class_path = explode( '_', $class_name ); |
| 291 |
|
| 292 |
// Bail if it's not a minimum length |
| 293 |
if ( count( $class_path ) < $class_parts_count ) { |
| 294 |
return; |
| 295 |
} |
| 296 |
|
| 297 |
// Build the base class path for this class |
| 298 |
$base_class_path = ''; |
| 299 |
for ( $i = 0; $i < $class_parts_count; $i++ ) { |
| 300 |
$base_class_path .= $class_path[ $i ] . '_'; |
| 301 |
} |
| 302 |
$base_class_path = trim( $base_class_path, '_' ); |
| 303 |
|
| 304 |
// Bail if the first parts don't match what we expect |
| 305 |
if ( ! in_array( $base_class_path, $class_start_name ) ) { |
| 306 |
return; |
| 307 |
} |
| 308 |
|
| 309 |
// Define the file name we need to include |
| 310 |
$file_name = strtolower( implode( '-', array_slice( $class_path, $class_parts_count ) ) ) . '.php'; |
| 311 |
|
| 312 |
// Define the paths with file name we need to include |
| 313 |
$include_paths = array( |
| 314 |
dirname( __FILE__ ) . '/vendor/includes/admin/' . $file_name, |
| 315 |
dirname( __FILE__ ) . '/vendor/includes/global/' . $file_name, |
| 316 |
dirname( __FILE__ ) . '/includes/admin/' . $file_name, |
| 317 |
dirname( __FILE__ ) . '/includes/global/' . $file_name, |
| 318 |
); |
| 319 |
|
| 320 |
// Iterate through the include paths to find the file |
| 321 |
foreach ( $include_paths as $path_file ) { |
| 322 |
if ( file_exists( $path_file ) ) { |
| 323 |
require_once( $path_file ); |
| 324 |
return; |
| 325 |
} |
| 326 |
} |
| 327 |
|
| 328 |
} |
| 329 |
spl_autoload_register( 'WP_To_Buffer_Autoloader' ); |
| 330 |
|
| 331 |
// Load Activation, Cron and Deactivation functions |
| 332 |
include_once( dirname( __FILE__ ) . '/includes/admin/activation.php' ); |
| 333 |
include_once( dirname( __FILE__ ) . '/includes/admin/cron.php' ); |
| 334 |
include_once( dirname( __FILE__ ) . '/includes/admin/deactivation.php' ); |
| 335 |
register_activation_hook( __FILE__, 'wp_to_buffer_activate' ); |
| 336 |
if ( version_compare( get_bloginfo( 'version' ), '5.1', '>=' ) ) { |
| 337 |
add_action( 'wp_insert_site', 'wp_to_buffer_activate_new_site' ); |
| 338 |
} else { |
| 339 |
add_action( 'wpmu_new_blog', 'wp_to_buffer_activate_new_site' ); |
| 340 |
} |
| 341 |
add_action( 'activate_blog', 'wp_to_buffer_activate_new_site' ); |
| 342 |
register_deactivation_hook( __FILE__, 'wp_to_buffer_deactivate' ); |
| 343 |
|
| 344 |
/** |
| 345 |
* Main function to return Plugin instance. |
| 346 |
* |
| 347 |
* @since 3.4.9 |
| 348 |
*/ |
| 349 |
function WP_To_Buffer() { |
| 350 |
|
| 351 |
return WP_To_Buffer::get_instance(); |
| 352 |
|
| 353 |
} |
| 354 |
|
| 355 |
// Finally, initialize the Plugin. |
| 356 |
$wp_to_buffer = WP_To_Buffer(); |