| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * WP to Buffer class. |
| 4 | 4 | * |
| 5 | - * @package WP_To_Buffer_Pro | |
| 5 | + * @package WP_To_Buffer | |
| 6 | 6 | * @author WP Zinc |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | /** |
| @@ -19,9 +19,9 @@ | ||
| 19 | 19 | * Holds the class object. |
| 20 | 20 | * |
| 21 | 21 | * @since 3.1.4 |
| 22 | 22 | * |
| 23 | - * @var object | |
| 23 | + * @var object|null | |
| 24 | 24 | */ |
| 25 | 25 | public static $instance; |
| 26 | 26 | |
| 27 | 27 | /** |
| @@ -30,9 +30,9 @@ | ||
| 30 | 30 | * @since 3.0.0 |
| 31 | 31 | * |
| 32 | 32 | * @var object |
| 33 | 33 | */ |
| 34 | - public $plugin = ''; | |
| 34 | + public $plugin; | |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Dashboard |
| 38 | 38 | * |
| @@ -39,9 +39,9 @@ | ||
| 39 | 39 | * @since 3.1.4 |
| 40 | 40 | * |
| 41 | 41 | * @var object |
| 42 | 42 | */ |
| 43 | - public $dashboard = ''; | |
| 43 | + public $dashboard; | |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Classes |
| 47 | 47 | * |
| @@ -46,11 +46,11 @@ | ||
| 46 | 46 | * Classes |
| 47 | 47 | * |
| 48 | 48 | * @since 3.4.9 |
| 49 | 49 | * |
| 50 | - * @var array | |
| 50 | + * @var object | |
| 51 | 51 | */ |
| 52 | - public $classes = ''; | |
| 52 | + public $classes; | |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * Constructor. Acts as a bootstrap to load the rest of the plugin |
| 56 | 56 | * |
| @@ -67,25 +67,103 @@ | ||
| 67 | 67 | $this->plugin->settingsName = 'wp-to-buffer-pro'; // Settings key - used in both Free + Pro, and for oAuth. |
| 68 | 68 | $this->plugin->account = 'Buffer'; |
| 69 | 69 | $this->plugin->version = WP_TO_BUFFER_PLUGIN_VERSION; |
| 70 | 70 | $this->plugin->buildDate = WP_TO_BUFFER_PLUGIN_BUILD_DATE; |
| 71 | - $this->plugin->requires = '5.0'; | |
| 72 | - $this->plugin->tested = '6.1.1'; | |
| 73 | 71 | $this->plugin->folder = WP_TO_BUFFER_PLUGIN_PATH; |
| 74 | 72 | $this->plugin->url = WP_TO_BUFFER_PLUGIN_URL; |
| 75 | 73 | $this->plugin->documentation_url = 'https://www.wpzinc.com/documentation/wordpress-buffer-pro'; |
| 76 | 74 | $this->plugin->support_url = 'https://www.wpzinc.com/support'; |
| 77 | 75 | $this->plugin->upgrade_url = 'https://www.wpzinc.com/plugins/wordpress-to-buffer-pro'; |
| 78 | - $this->plugin->review_name = 'wp-to-buffer'; | |
| 79 | - $this->plugin->review_notice = sprintf( | |
| 80 | - /* translators: Plugin Name */ | |
| 81 | - __( 'Thanks for using %s to schedule your social media statuses on Buffer!', 'wp-to-buffer' ), | |
| 82 | - $this->plugin->displayName | |
| 76 | + | |
| 77 | + // Logo. | |
| 78 | + $this->plugin->logo = WP_TO_BUFFER_PLUGIN_URL . 'lib/social/assets/images/icons/buffer-dark.svg'; | |
| 79 | + $this->plugin->header_background_color = '#ffffff'; | |
| 80 | + $this->plugin->header_primary_text_color = '#3d3d3d'; | |
| 81 | + $this->plugin->header_secondary_text_color = '#6e6e6e'; | |
| 82 | + | |
| 83 | + // Review. | |
| 84 | + $this->plugin->review_name = 'wp-to-buffer'; | |
| 85 | + $this->plugin->review_notice = sprintf( | |
| 86 | + 'Thanks for using %s to schedule your social media statuses on %s!', | |
| 87 | + $this->plugin->displayName, | |
| 88 | + $this->plugin->account | |
| 83 | 89 | ); |
| 84 | 90 | |
| 91 | + // ConvertKit Form UID. | |
| 92 | + $this->plugin->convertkit_form_uid = '71346c6086'; | |
| 93 | + | |
| 85 | 94 | // Default Settings. |
| 86 | - $this->plugin->default_schedule = 'queue_bottom'; | |
| 95 | + $this->plugin->default_schedule = 'immediate'; | |
| 87 | 96 | |
| 97 | + // Defer loading of Plugin Classes. | |
| 98 | + add_action( 'init', array( $this, 'initialize' ), 1 ); | |
| 99 | + add_action( 'init', array( $this, 'upgrade' ), 2 ); | |
| 100 | + | |
| 101 | + // Admin Menus. | |
| 102 | + add_action( $this->plugin->filter_name . '_admin_admin_menu', array( $this, 'admin_menus' ) ); | |
| 103 | + | |
| 104 | + // Add queue_end Schedule Option. | |
| 105 | + add_filter( $this->plugin->filter_name . '_get_schedule_options', array( $this, 'get_schedule_options' ) ); | |
| 106 | + | |
| 107 | + } | |
| 108 | + | |
| 109 | + /** | |
| 110 | + * Defines the schedule options available for statuses in WP to Buffer (Free). | |
| 111 | + * | |
| 112 | + * @since 6.2.0 | |
| 113 | + * | |
| 114 | + * @param array $schedule Schedule Options. | |
| 115 | + * @return array Schedule Options | |
| 116 | + */ | |
| 117 | + public function get_schedule_options( $schedule ) { | |
| 118 | + | |
| 119 | + // Buffer supports a queue, in addition to the always-available immediate option. | |
| 120 | + $schedule['queue_end'] = __( 'Add to End of Queue', 'wp-to-buffer' ); | |
| 121 | + | |
| 122 | + return $schedule; | |
| 123 | + | |
| 124 | + } | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * Register menus and submenus. | |
| 128 | + * | |
| 129 | + * @since 3.9.7 | |
| 130 | + * | |
| 131 | + * @param string $minimum_capability Minimum required capability. | |
| 132 | + */ | |
| 133 | + public function admin_menus( $minimum_capability ) { | |
| 134 | + | |
| 135 | + // Menus. | |
| 136 | + add_menu_page( $this->plugin->displayName, $this->plugin->displayName, $minimum_capability, $this->plugin->name . '-settings', array( $this->get_class( 'admin' ), 'settings_screen' ), $this->plugin->url . 'lib/social/assets/images/icons/' . strtolower( $this->plugin->account ) . '-light.svg' ); | |
| 137 | + | |
| 138 | + // Register Submenu Pages. | |
| 139 | + $settings_page = add_submenu_page( $this->plugin->name . '-settings', __( 'Settings', 'wp-to-buffer' ), __( 'Settings', 'wp-to-buffer' ), $minimum_capability, $this->plugin->name . '-settings', array( $this->get_class( 'admin' ), 'settings_screen' ) ); | |
| 140 | + | |
| 141 | + // Logs. | |
| 142 | + if ( $this->get_class( 'log' )->is_enabled() ) { | |
| 143 | + $log_page = add_submenu_page( $this->plugin->name . '-settings', __( 'Logs', 'wp-to-buffer' ), __( 'Logs', 'wp-to-buffer' ), $minimum_capability, $this->plugin->name . '-log', array( $this->get_class( 'admin' ), 'log_screen' ) ); | |
| 144 | + add_action( "load-$log_page", array( $this->get_class( 'log' ), 'add_screen_options' ) ); | |
| 145 | + } | |
| 146 | + | |
| 147 | + $upgrade_page = add_submenu_page( $this->plugin->name . '-settings', __( 'Upgrade', 'wp-to-buffer' ), __( 'Upgrade', 'wp-to-buffer' ), $minimum_capability, $this->plugin->name . '-upgrade', array( $this->get_class( 'admin' ), 'upgrade_screen' ) ); | |
| 148 | + | |
| 149 | + } | |
| 150 | + | |
| 151 | + /** | |
| 152 | + * Initializes required classes | |
| 153 | + * | |
| 154 | + * @since 3.4.9 | |
| 155 | + */ | |
| 156 | + public function initialize() { | |
| 157 | + | |
| 158 | + // Define translation strings. | |
| 159 | + $this->plugin->review_notice = sprintf( | |
| 160 | + /* translators: 1: Plugin Name, 2: Social Network */ | |
| 161 | + __( 'Thanks for using %1$s to schedule your social media statuses on %2$s!', 'wp-to-buffer' ), | |
| 162 | + $this->plugin->displayName, | |
| 163 | + $this->plugin->account | |
| 164 | + ); | |
| 165 | + | |
| 88 | 166 | // Upgrade Reasons. |
| 89 | 167 | $this->plugin->upgrade_reasons = array( |
| 90 | 168 | array( |
| 91 | 169 | __( 'Post to Instagram and Pinterest', 'wp-to-buffer' ), |
| @@ -91,8 +169,12 @@ | ||
| 91 | 169 | __( 'Post to Instagram and Pinterest', 'wp-to-buffer' ), |
| 92 | 170 | __( 'Pro supports Direct Posting to Instagram Business Profiles and Pinterest Boards', 'wp-to-buffer' ), |
| 93 | 171 | ), |
| 94 | 172 | array( |
| 173 | + __( 'Multiple Buffer Account Support', 'wp-to-buffer' ), | |
| 174 | + __( 'Pro supports connecting multiple Buffer accounts to a single WordPress site', 'wp-to-buffer' ), | |
| 175 | + ), | |
| 176 | + array( | |
| 95 | 177 | __( 'Multiple, Customisable Status Messages', 'wp-to-buffer' ), |
| 96 | 178 | __( 'Each Post Type and Social Network can have multiple, unique status message and settings', 'wp-to-buffer' ), |
| 97 | 179 | ), |
| 98 | 180 | array( |
| @@ -144,9 +226,9 @@ | ||
| 144 | 226 | __( 'Use shortcodes in status updates', 'wp-to-buffer' ), |
| 145 | 227 | ), |
| 146 | 228 | array( |
| 147 | 229 | __( 'Full Image Control', 'wp-to-buffer' ), |
| 148 | - __( 'Choose to display the WordPress Featured Image with your status updates, or define up to 4 custom images for each Post.', 'wp-to-buffer' ), | |
| 230 | + __( 'Choose to display one or more images in your status updates, from the Post\'s Featured Image, the Media Gallery, the Post Content or an Advanced Custom Fields Image or Gallery.', 'wp-to-buffer' ), | |
| 149 | 231 | ), |
| 150 | 232 | array( |
| 151 | 233 | __( 'WP-Cron and WP-CLI Compatible', 'wp-to-buffer' ), |
| 152 | 234 | __( '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', 'wp-to-buffer' ), |
| @@ -152,56 +234,32 @@ | ||
| 152 | 234 | __( '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', 'wp-to-buffer' ), |
| 153 | 235 | ), |
| 154 | 236 | ); |
| 155 | 237 | |
| 156 | - // Dashboard Submodule. | |
| 157 | - if ( ! class_exists( 'WPZincDashboardWidget' ) ) { | |
| 158 | - require_once $this->plugin->folder . '_modules/dashboard/class-wpzincdashboardwidget.php'; | |
| 159 | - } | |
| 160 | - $this->dashboard = new WPZincDashboardWidget( $this->plugin, 'https://www.wpzinc.com/wp-content/plugins/lum-deactivation' ); | |
| 238 | + // Shared admin module (autoloaded from lib/shared). | |
| 239 | + $this->dashboard = new \WPZinc\Shared\Admin_UI( $this->plugin ); | |
| 161 | 240 | |
| 162 | - // Defer loading of Plugin Classes. | |
| 163 | - add_action( 'init', array( $this, 'initialize' ), 1 ); | |
| 164 | - add_action( 'init', array( $this, 'upgrade' ), 2 ); | |
| 165 | - | |
| 166 | - // Localization. | |
| 167 | - add_action( 'plugins_loaded', array( $this, 'load_language_files' ) ); | |
| 168 | - | |
| 169 | - } | |
| 170 | - | |
| 171 | - /** | |
| 172 | - * Initializes required classes | |
| 173 | - * | |
| 174 | - * @since 3.4.9 | |
| 175 | - */ | |
| 176 | - public function initialize() { | |
| 177 | - | |
| 241 | + // Initialize Plugin classes. | |
| 178 | 242 | $this->classes = new stdClass(); |
| 179 | 243 | |
| 180 | 244 | // 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->date = new WP_To_Social_Pro_Date( self::$instance ); | |
| 187 | - $this->classes->image = new WP_To_Social_Pro_Image( self::$instance ); | |
| 188 | - $this->classes->install = new WP_To_Social_Pro_Install( self::$instance ); | |
| 189 | - $this->classes->log = new WP_To_Social_Pro_Log( self::$instance ); | |
| 190 | - $this->classes->media_library = new WP_To_Social_Pro_Media_Library( self::$instance ); | |
| 191 | - $this->classes->notices = new WP_To_Social_Pro_Notices( self::$instance ); | |
| 192 | - $this->classes->post = new WP_To_Social_Pro_Post( self::$instance ); | |
| 193 | - $this->classes->publish = new WP_To_Social_Pro_Publish( self::$instance ); | |
| 194 | - $this->classes->screen = new WP_To_Social_Pro_Screen( self::$instance ); | |
| 195 | - $this->classes->settings = new WP_To_Social_Pro_Settings( self::$instance ); | |
| 196 | - $this->classes->twitter_api = new WP_To_Social_Pro_Twitter_API( self::$instance ); | |
| 197 | - $this->classes->validation = new WP_To_Social_Pro_Validation( self::$instance ); | |
| 245 | + $this->classes->admin = new \WPZinc\Social\Admin( self::$instance ); | |
| 246 | + $this->classes->ajax = new \WPZinc\Social\Ajax( self::$instance ); | |
| 247 | + $this->classes->api = new \WPZinc\Social\Buffer_API( self::$instance ); | |
| 248 | + $this->classes->common = new \WPZinc\Social\Common( self::$instance ); | |
| 249 | + $this->classes->cron = new \WPZinc\Social\Cron( self::$instance ); | |
| 250 | + $this->classes->date = new \WPZinc\Social\Date( self::$instance ); | |
| 251 | + $this->classes->image = new \WPZinc\Social\Image( self::$instance ); | |
| 252 | + $this->classes->install = new \WPZinc\Social\Install( self::$instance ); | |
| 253 | + $this->classes->log = new \WPZinc\Social\Log( self::$instance ); | |
| 254 | + $this->classes->media_library = new \WPZinc\Social\Media_Library( self::$instance ); | |
| 255 | + $this->classes->notices = new \WPZinc\Social\Notices( self::$instance ); | |
| 256 | + $this->classes->post = new \WPZinc\Social\Post( self::$instance ); | |
| 257 | + $this->classes->publish = new \WPZinc\Social\Publish( self::$instance ); | |
| 258 | + $this->classes->screen = new \WPZinc\Social\Screen( self::$instance ); | |
| 259 | + $this->classes->settings = new \WPZinc\Social\Settings( self::$instance ); | |
| 260 | + $this->classes->validation = new \WPZinc\Social\Validation( self::$instance ); | |
| 198 | 261 | |
| 199 | - // Run the migration routine from Free + Pro v2.x --> Pro v3.x. | |
| 200 | - if ( is_admin() ) { | |
| 201 | - $this->classes->settings->migrate_settings(); | |
| 202 | - } | |
| 203 | - | |
| 204 | 262 | } |
| 205 | 263 | |
| 206 | 264 | /** |
| 207 | 265 | * Runs the upgrade routine once the plugin has loaded |
| @@ -215,19 +273,8 @@ | ||
| 215 | 273 | |
| 216 | 274 | } |
| 217 | 275 | |
| 218 | 276 | /** |
| 219 | - * Loads plugin textdomain | |
| 220 | - * | |
| 221 | - * @since 3.8.4 | |
| 222 | - */ | |
| 223 | - public function load_language_files() { | |
| 224 | - | |
| 225 | - load_plugin_textdomain( 'wp-to-buffer', false, $this->plugin->name . '/languages/' ); | |
| 226 | - | |
| 227 | - } | |
| 228 | - | |
| 229 | - /** | |
| 230 | 277 | * Returns the given class |
| 231 | 278 | * |
| 232 | 279 | * @since 3.4.9 |
| 233 | 280 | * |
| @@ -274,8 +321,29 @@ | ||
| 274 | 321 | |
| 275 | 322 | } |
| 276 | 323 | |
| 277 | 324 | /** |
| 325 | + * Helper method to determine whether this Plugin supports a specific feature. | |
| 326 | + * | |
| 327 | + * Typically used by the lib/ classes. | |
| 328 | + * | |
| 329 | + * @since 3.5.5 | |
| 330 | + * | |
| 331 | + * @param string $feature Feature. | |
| 332 | + * @return bool Feature Supported | |
| 333 | + */ | |
| 334 | + public function supports( $feature ) { | |
| 335 | + | |
| 336 | + // Define supported featured. | |
| 337 | + $supported_features = array( | |
| 338 | + 'webp', | |
| 339 | + ); | |
| 340 | + | |
| 341 | + return in_array( $feature, $supported_features, true ); | |
| 342 | + | |
| 343 | + } | |
| 344 | + | |
| 345 | + /** | |
| 278 | 346 | * Returns the singleton instance of the class. |
| 279 | 347 | * |
| 280 | 348 | * @since 3.1.4 |
| 281 | 349 | * |
| @@ -282,9 +350,9 @@ | ||
| 282 | 350 | * @return object Class. |
| 283 | 351 | */ |
| 284 | 352 | public static function get_instance() { |
| 285 | 353 | |
| 286 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { | |
| 354 | + if ( ! self::$instance instanceof self ) { | |
| 287 | 355 | self::$instance = new self(); |
| 288 | 356 | } |
| 289 | 357 | |
| 290 | 358 | return self::$instance; |