| 1 |
<?php |
| 2 |
/** |
| 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: http://www.wpzinc.com/plugins/wp-to-buffer-pro |
| 11 |
* Version: 6.0.1 |
| 12 |
* Author: WP Zinc |
| 13 |
* Author URI: http://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 |
*/ |
| 19 |
|
| 20 |
if ( ! defined( 'ABSPATH' ) ) { |
| 21 |
exit; // Exit if accessed directly. |
| 22 |
} |
| 23 |
|
| 24 |
// Bail if Plugin is alread loaded. |
| 25 |
if ( class_exists( 'WP_To_Buffer' ) ) { |
| 26 |
return; |
| 27 |
} |
| 28 |
|
| 29 |
// Define Plugin version and build date. |
| 30 |
define( 'WP_TO_BUFFER_PLUGIN_VERSION', '6.0.1' ); |
| 31 |
define( 'WP_TO_BUFFER_PLUGIN_BUILD_DATE', '2026-05-28 13:00:00' ); |
| 32 |
|
| 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__ ) ); |
| 36 |
|
| 37 |
/** |
| 38 |
* Define the autoloader for this Plugin |
| 39 |
* |
| 40 |
* @since 3.4.7 |
| 41 |
* |
| 42 |
* @param string $class_name The class to load. |
| 43 |
*/ |
| 44 |
function WP_To_Buffer_Autoloader( $class_name ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName |
| 45 |
|
| 46 |
// Define the required start of the class name. |
| 47 |
$class_start_name = 'WP_To_Social_Pro'; |
| 48 |
|
| 49 |
// Get the number of parts the class start name has. |
| 50 |
$class_parts_count = count( explode( '_', $class_start_name ) ); |
| 51 |
|
| 52 |
// Break the class name into an array. |
| 53 |
$class_path = explode( '_', $class_name ); |
| 54 |
|
| 55 |
// Bail if it's not a minimum length (i.e. doesn't potentially have WP_To_Social_Pro). |
| 56 |
if ( count( $class_path ) < $class_parts_count ) { |
| 57 |
return; |
| 58 |
} |
| 59 |
|
| 60 |
// Build the base class path for this class. |
| 61 |
$base_class_path = ''; |
| 62 |
for ( $i = 0; $i < $class_parts_count; $i++ ) { |
| 63 |
$base_class_path .= $class_path[ $i ] . '_'; |
| 64 |
} |
| 65 |
$base_class_path = trim( $base_class_path, '_' ); |
| 66 |
|
| 67 |
// Bail if the first parts don't match what we expect. |
| 68 |
if ( $base_class_path !== $class_start_name ) { |
| 69 |
return; |
| 70 |
} |
| 71 |
|
| 72 |
// Define the file name. |
| 73 |
$file_name = 'class-' . str_replace( '_', '-', strtolower( $class_name ) ) . '.php'; |
| 74 |
|
| 75 |
// Define the paths to search for the file. |
| 76 |
$include_paths = array( |
| 77 |
WP_TO_BUFFER_PLUGIN_PATH . 'lib/includes', |
| 78 |
WP_TO_BUFFER_PLUGIN_PATH . 'includes', |
| 79 |
); |
| 80 |
|
| 81 |
// Iterate through the include paths to find the file. |
| 82 |
foreach ( $include_paths as $path ) { |
| 83 |
if ( file_exists( $path . '/' . $file_name ) ) { |
| 84 |
require_once $path . '/' . $file_name; |
| 85 |
return; |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
} |
| 90 |
spl_autoload_register( 'wp_to_buffer_autoloader' ); |
| 91 |
|
| 92 |
// Load Activation, Cron and Deactivation functions. |
| 93 |
require_once WP_TO_BUFFER_PLUGIN_PATH . 'includes/activation.php'; |
| 94 |
require_once WP_TO_BUFFER_PLUGIN_PATH . 'includes/cron.php'; |
| 95 |
require_once WP_TO_BUFFER_PLUGIN_PATH . 'includes/deactivation.php'; |
| 96 |
register_activation_hook( __FILE__, 'wp_to_buffer_activate' ); |
| 97 |
if ( version_compare( get_bloginfo( 'version' ), '5.1', '>=' ) ) { |
| 98 |
add_action( 'wp_insert_site', 'wp_to_buffer_activate_new_site' ); |
| 99 |
} else { |
| 100 |
add_action( 'wpmu_new_blog', 'wp_to_buffer_activate_new_site' ); |
| 101 |
} |
| 102 |
add_action( 'activate_blog', 'wp_to_buffer_activate_new_site' ); |
| 103 |
register_deactivation_hook( __FILE__, 'wp_to_buffer_deactivate' ); |
| 104 |
|
| 105 |
/** |
| 106 |
* Main function to return Plugin instance. |
| 107 |
* |
| 108 |
* @since 3.8.1 |
| 109 |
*/ |
| 110 |
function WP_To_Buffer() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName |
| 111 |
|
| 112 |
return WP_To_Buffer::get_instance(); |
| 113 |
|
| 114 |
} |
| 115 |
|
| 116 |
// Finally, initialize the Plugin. |
| 117 |
require_once WP_TO_BUFFER_PLUGIN_PATH . 'includes/class-wp-to-buffer.php'; |
| 118 |
$wp_to_buffer = WP_To_Buffer(); |
| 119 |
|