| @@ -1,338 +1,91 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* Plugin Name: WP to Buffer | |
| 4 | -* Plugin URI: http://www.wpzinc.com/plugins/wp-to-buffer-pro | |
| 5 | -* Version: 3.8.1 | |
| 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 | |
| 3 | + * WP to Buffer WordPress Plugin. | |
| 4 | + * | |
| 5 | + * @package WP_To_Buffer | |
| 6 | + * @author WP Zinc | |
| 7 | + * | |
| 8 | + * @wordpress-plugin | |
| 9 | + * Plugin Name: WP to Buffer | |
| 10 | + * Plugin URI: https://www.wpzinc.com/plugins/wordpress-to-buffer-pro | |
| 11 | + * Version: 6.2.5 | |
| 12 | + * Author: WP Zinc | |
| 13 | + * Author URI: https://www.wpzinc.com | |
| 14 | + * Description: Send WordPress Pages, Posts or Custom Post Types to your Buffer (buffer.com) account for scheduled publishing to social networks. | |
| 15 | + * Text Domain: wp-to-buffer | |
| 16 | + * License: GPLv3 or later | |
| 17 | + * License URI: https://www.gnu.org/licenses/gpl-3.0.html | |
| 18 | 18 | */ |
| 19 | -class WP_To_Buffer { | |
| 20 | 19 | |
| 21 | - /** | |
| 22 | - * Holds the class object. | |
| 23 | - * | |
| 24 | - * @since 3.1.4 | |
| 25 | - * | |
| 26 | - * @var object | |
| 27 | - */ | |
| 28 | - public static $instance; | |
| 20 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 21 | + exit; // Exit if accessed directly. | |
| 22 | +} | |
| 29 | 23 | |
| 30 | - /** | |
| 31 | - * Plugin | |
| 32 | - * | |
| 33 | - * @since 3.0.0 | |
| 34 | - * | |
| 35 | - * @var object | |
| 36 | - */ | |
| 37 | - public $plugin = ''; | |
| 24 | +// Bail if Plugin is alread loaded. | |
| 25 | +if ( class_exists( 'WP_To_Buffer' ) ) { | |
| 26 | + return; | |
| 27 | +} | |
| 38 | 28 | |
| 39 | - /** | |
| 40 | - * Dashboard | |
| 41 | - * | |
| 42 | - * @since 3.1.4 | |
| 43 | - * | |
| 44 | - * @var object | |
| 45 | - */ | |
| 46 | - public $dashboard = ''; | |
| 29 | +// Define Plugin version and build date. | |
| 30 | +define( 'WP_TO_BUFFER_PLUGIN_VERSION', '6.2.5' ); | |
| 31 | +define( 'WP_TO_BUFFER_PLUGIN_BUILD_DATE', '2026-09-18 18:00:00' ); | |
| 47 | 32 | |
| 48 | - /** | |
| 49 | - * Classes | |
| 50 | - * | |
| 51 | - * @since 3.4.9 | |
| 52 | - * | |
| 53 | - * @var array | |
| 54 | - */ | |
| 55 | - public $classes = ''; | |
| 33 | +// Define Plugin paths. | |
| 34 | +define( 'WP_TO_BUFFER_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); | |
| 35 | +define( 'WP_TO_BUFFER_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); | |
| 56 | 36 | |
| 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.1'; | |
| 78 | - $this->plugin->buildDate = '2022-06-09 18:00:00'; | |
| 79 | - $this->plugin->requires = '5.0'; | |
| 80 | - $this->plugin->tested = '6.0'; | |
| 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 | 37 | /** |
| 273 | 38 | * Define the autoloader for this Plugin |
| 274 | 39 | * |
| 275 | 40 | * @since 3.4.7 |
| 276 | 41 | * |
| 277 | - * @param string $class_name The class to load | |
| 42 | + * @param string $class_name The class to load. | |
| 278 | 43 | */ |
| 279 | -function WP_To_Buffer_Autoloader( $class_name ) { | |
| 44 | +function wp_to_buffer_autoloader( $class_name ) { | |
| 280 | 45 | |
| 281 | - // Define the required start of the class name | |
| 282 | - $class_start_name = array( | |
| 283 | - 'WP_To_Social_Pro', | |
| 284 | - ); | |
| 46 | + // Only handle this vendor's namespaced classes. | |
| 47 | + if ( strpos( $class_name, 'WPZinc\\' ) !== 0 ) { | |
| 48 | + return; | |
| 49 | + } | |
| 285 | 50 | |
| 286 | - // Get the number of parts the class start name has | |
| 287 | - $class_parts_count = count( explode( '_', $class_start_name[0] ) ); | |
| 51 | + // Build the file name from the class' short name. | |
| 52 | + // e.g. WPZinc\Social\Log_Table -> class-log-table.php. | |
| 53 | + $class_parts = explode( '\\', $class_name ); | |
| 54 | + $short_name = end( $class_parts ); | |
| 55 | + $file_name = 'class-' . str_replace( '_', '-', strtolower( $short_name ) ) . '.php'; | |
| 288 | 56 | |
| 289 | - // Break the class name into an array | |
| 290 | - $class_path = explode( '_', $class_name ); | |
| 57 | + // Map the sub-namespace to the directories to search. | |
| 58 | + $namespace_paths = array( | |
| 59 | + 'Social' => array( | |
| 60 | + WP_TO_BUFFER_PLUGIN_PATH . 'lib/social/includes', | |
| 61 | + WP_TO_BUFFER_PLUGIN_PATH . 'includes', | |
| 62 | + ), | |
| 63 | + 'Shared' => array( | |
| 64 | + WP_TO_BUFFER_PLUGIN_PATH . 'lib/shared', | |
| 65 | + ), | |
| 66 | + ); | |
| 291 | 67 | |
| 292 | - // Bail if it's not a minimum length | |
| 293 | - if ( count( $class_path ) < $class_parts_count ) { | |
| 294 | - return; | |
| 295 | - } | |
| 68 | + $sub_namespace = isset( $class_parts[1] ) ? $class_parts[1] : ''; | |
| 69 | + if ( ! isset( $namespace_paths[ $sub_namespace ] ) ) { | |
| 70 | + return; | |
| 71 | + } | |
| 296 | 72 | |
| 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, '_' ); | |
| 73 | + foreach ( $namespace_paths[ $sub_namespace ] as $path ) { | |
| 74 | + if ( file_exists( $path . '/' . $file_name ) ) { | |
| 75 | + require_once $path . '/' . $file_name; | |
| 76 | + return; | |
| 77 | + } | |
| 78 | + } | |
| 303 | 79 | |
| 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 | 80 | } |
| 329 | -spl_autoload_register( 'WP_To_Buffer_Autoloader' ); | |
| 81 | +spl_autoload_register( 'wp_to_buffer_autoloader' ); | |
| 330 | 82 | |
| 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' ); | |
| 83 | +// Load Activation, Cron and Deactivation functions. | |
| 84 | +require_once WP_TO_BUFFER_PLUGIN_PATH . 'includes/activation.php'; | |
| 85 | +require_once WP_TO_BUFFER_PLUGIN_PATH . 'includes/cron.php'; | |
| 86 | +require_once WP_TO_BUFFER_PLUGIN_PATH . 'includes/functions.php'; | |
| 87 | +require_once WP_TO_BUFFER_PLUGIN_PATH . 'includes/deactivation.php'; | |
| 335 | 88 | register_activation_hook( __FILE__, 'wp_to_buffer_activate' ); |
| 336 | 89 | if ( version_compare( get_bloginfo( 'version' ), '5.1', '>=' ) ) { |
| 337 | 90 | add_action( 'wp_insert_site', 'wp_to_buffer_activate_new_site' ); |
| 338 | 91 | } else { |
| @@ -343,14 +96,15 @@ | ||
| 343 | 96 | |
| 344 | 97 | /** |
| 345 | 98 | * Main function to return Plugin instance. |
| 346 | 99 | * |
| 347 | - * @since 3.4.9 | |
| 100 | + * @since 3.8.1 | |
| 348 | 101 | */ |
| 349 | -function WP_To_Buffer() { | |
| 350 | - | |
| 351 | - return WP_To_Buffer::get_instance(); | |
| 102 | +function WP_To_Buffer() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName | |
| 352 | 103 | |
| 104 | + return WP_To_Buffer::get_instance(); | |
| 105 | + | |
| 353 | 106 | } |
| 354 | 107 | |
| 355 | 108 | // Finally, initialize the Plugin. |
| 356 | -$wp_to_buffer = WP_To_Buffer(); | |
| 109 | +require_once WP_TO_BUFFER_PLUGIN_PATH . 'includes/class-wp-to-buffer.php'; | |
| 110 | +$wp_to_buffer = WP_To_Buffer(); | |