| @@ -6,12 +6,12 @@ | ||
| 6 | 6 | * @author WP Zinc |
| 7 | 7 | * |
| 8 | 8 | * @wordpress-plugin |
| 9 | 9 | * Plugin Name: WP to Buffer |
| 10 | - * Plugin URI: http://www.wpzinc.com/plugins/wp-to-buffer-pro | |
| 11 | - * Version: 6.0.4 | |
| 10 | + * Plugin URI: https://www.wpzinc.com/plugins/wordpress-to-buffer-pro | |
| 11 | + * Version: 6.2.4 | |
| 12 | 12 | * Author: WP Zinc |
| 13 | - * Author URI: http://www.wpzinc.com | |
| 13 | + * Author URI: https://www.wpzinc.com | |
| 14 | 14 | * Description: Send WordPress Pages, Posts or Custom Post Types to your Buffer (buffer.com) account for scheduled publishing to social networks. |
| 15 | 15 | * Text Domain: wp-to-buffer |
| 16 | 16 | * License: GPLv3 or later |
| 17 | 17 | * License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| @@ -26,10 +26,10 @@ | ||
| 26 | 26 | return; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Define Plugin version and build date. |
| 30 | -define( 'WP_TO_BUFFER_PLUGIN_VERSION', '6.0.4' ); | |
| 31 | -define( 'WP_TO_BUFFER_PLUGIN_BUILD_DATE', '2026-06-02 12:00:00' ); | |
| 30 | +define( 'WP_TO_BUFFER_PLUGIN_VERSION', '6.2.4' ); | |
| 31 | +define( 'WP_TO_BUFFER_PLUGIN_BUILD_DATE', '2026-08-14 10:00:00' ); | |
| 32 | 32 | |
| 33 | 33 | // Define Plugin paths. |
| 34 | 34 | define( 'WP_TO_BUFFER_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 35 | 35 | define( 'WP_TO_BUFFER_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
| @@ -40,47 +40,38 @@ | ||
| 40 | 40 | * @since 3.4.7 |
| 41 | 41 | * |
| 42 | 42 | * @param string $class_name The class to load. |
| 43 | 43 | */ |
| 44 | -function WP_To_Buffer_Autoloader( $class_name ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName | |
| 44 | +function wp_to_buffer_autoloader( $class_name ) { | |
| 45 | 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 ) { | |
| 46 | + // Only handle this vendor's namespaced classes. | |
| 47 | + if ( strpos( $class_name, 'WPZinc\\' ) !== 0 ) { | |
| 57 | 48 | return; |
| 58 | 49 | } |
| 59 | 50 | |
| 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, '_' ); | |
| 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'; | |
| 66 | 56 | |
| 67 | - // Bail if the first parts don't match what we expect. | |
| 68 | - if ( $base_class_path !== $class_start_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 | + ); | |
| 67 | + | |
| 68 | + $sub_namespace = isset( $class_parts[1] ) ? $class_parts[1] : ''; | |
| 69 | + if ( ! isset( $namespace_paths[ $sub_namespace ] ) ) { | |
| 69 | 70 | return; |
| 70 | 71 | } |
| 71 | 72 | |
| 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 ) { | |
| 73 | + foreach ( $namespace_paths[ $sub_namespace ] as $path ) { | |
| 83 | 74 | if ( file_exists( $path . '/' . $file_name ) ) { |
| 84 | 75 | require_once $path . '/' . $file_name; |
| 85 | 76 | return; |
| 86 | 77 | } |