PluginProbe
Social Media Auto Poster – Schedule & Publish to Buffer / 6.0.9
Social Media Auto Poster – Schedule & Publish to Buffer v6.0.9
6.2.4 6.2.3 6.2.2 6.2.1 6.2.0 6.1.2 6.1.1 6.1.0 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 6.0.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 All 125 releases
wp-to-buffer / includes / class-wp-to-buffer.php

class-wp-to-buffer.php in Social Media Auto Poster – Schedule & Publish to Buffer 6.0.9, at includes/class-wp-to-buffer.php

352 lines 11.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WP to Buffer class.
4 *
5 * @package WP_To_Buffer_Pro
6 * @author WP Zinc
7 */
8
9 /**
10 * Main WP to Buffer class, used to load the Plugin.
11 *
12 * @package WP_To_Buffer
13 * @author WP Zinc
14 * @version 1.0.0
15 */
16 class WP_To_Buffer {
17
18 /**
19 * Holds the class object.
20 *
21 * @since 3.1.4
22 *
23 * @var object
24 */
25 public static $instance;
26
27 /**
28 * Plugin
29 *
30 * @since 3.0.0
31 *
32 * @var object
33 */
34 public $plugin = '';
35
36 /**
37 * Dashboard
38 *
39 * @since 3.1.4
40 *
41 * @var object
42 */
43 public $dashboard = '';
44
45 /**
46 * Classes
47 *
48 * @since 3.4.9
49 *
50 * @var array
51 */
52 public $classes = '';
53
54 /**
55 * Constructor. Acts as a bootstrap to load the rest of the plugin
56 *
57 * @since 1.0.0
58 */
59 public function __construct() {
60
61 // Plugin Details.
62 $this->plugin = new stdClass();
63 $this->plugin->name = 'wp-to-buffer';
64 $this->plugin->filter_name = 'wp_to_buffer';
65 $this->plugin->displayName = 'WP to Buffer';
66
67 $this->plugin->settingsName = 'wp-to-buffer-pro'; // Settings key - used in both Free + Pro, and for oAuth.
68 $this->plugin->account = 'Buffer';
69 $this->plugin->version = WP_TO_BUFFER_PLUGIN_VERSION;
70 $this->plugin->buildDate = WP_TO_BUFFER_PLUGIN_BUILD_DATE;
71 $this->plugin->folder = WP_TO_BUFFER_PLUGIN_PATH;
72 $this->plugin->url = WP_TO_BUFFER_PLUGIN_URL;
73 $this->plugin->documentation_url = 'https://www.wpzinc.com/documentation/wordpress-buffer-pro';
74 $this->plugin->support_url = 'https://www.wpzinc.com/support';
75 $this->plugin->upgrade_url = 'https://www.wpzinc.com/plugins/wordpress-to-buffer-pro';
76
77 // Logo.
78 $this->plugin->logo = WP_TO_BUFFER_PLUGIN_URL . 'lib/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
89 );
90
91 // ConvertKit Form UID.
92 $this->plugin->convertkit_form_uid = '71346c6086';
93
94 // Default Settings.
95 $this->plugin->default_schedule = 'queue_end';
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 }
105
106 /**
107 * Register menus and submenus.
108 *
109 * @since 3.9.7
110 *
111 * @param string $minimum_capability Minimum required capability.
112 */
113 public function admin_menus( $minimum_capability ) {
114
115 // Menus.
116 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/assets/images/icons/' . strtolower( $this->plugin->account ) . '-light.svg' );
117
118 // Register Submenu Pages.
119 $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' ) );
120
121 // Logs.
122 if ( $this->get_class( 'log' )->is_enabled() ) {
123 $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' ) );
124 add_action( "load-$log_page", array( $this->get_class( 'log' ), 'add_screen_options' ) );
125 }
126
127 $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' ) );
128
129 }
130
131 /**
132 * Initializes required classes
133 *
134 * @since 3.4.9
135 */
136 public function initialize() {
137
138 // Define translation strings.
139 $this->plugin->review_notice = sprintf(
140 /* translators: Plugin Name */
141 __( 'Thanks for using %s to schedule your social media statuses on Buffer!', 'wp-to-buffer' ),
142 $this->plugin->displayName
143 );
144
145 // Upgrade Reasons.
146 $this->plugin->upgrade_reasons = array(
147 array(
148 __( 'Post to Instagram and Pinterest', 'wp-to-buffer' ),
149 __( 'Pro supports Direct Posting to Instagram Business Profiles and Pinterest Boards', 'wp-to-buffer' ),
150 ),
151 array(
152 __( 'Multiple Buffer Account Support', 'wp-to-buffer' ),
153 __( 'Pro supports connecting multiple Buffer accounts to a single WordPress site', 'wp-to-buffer' ),
154 ),
155 array(
156 __( 'Multiple, Customisable Status Messages', 'wp-to-buffer' ),
157 __( 'Each Post Type and Social Network can have multiple, unique status message and settings', 'wp-to-buffer' ),
158 ),
159 array(
160 __( 'Conditionally send Status Messages', 'wp-to-buffer' ),
161 __( 'Only send status(es) to Buffer based on Post Author(s), Taxonomy Term(s) and/or Custom Field Values', 'wp-to-buffer' ),
162 ),
163 array(
164 __( 'More Scheduling Options', 'wp-to-buffer' ),
165 __( 'Each status update can be added to the start/end of your Buffer queue, posted immediately or scheduled at a specific time', 'wp-to-buffer' ),
166 ),
167 array(
168 __( 'Dynamic Status Tags', 'wp-to-buffer' ),
169 __( 'Dynamically build status updates with data from the Post Author and Custom Fields', 'wp-to-buffer' ),
170 ),
171 array(
172 __( 'Separate Statuses per Social Network', 'wp-to-buffer' ),
173 __( 'Define different statuses for each Post Type and Social Network', 'wp-to-buffer' ),
174 ),
175 array(
176 __( 'Per-Post Settings', 'wp-to-buffer' ),
177 __( 'Override Settings on Individual Posts: Each Post can have its own Buffer settings', 'wp-to-buffer' ),
178 ),
179 array(
180 __( 'Repost Old Posts', 'wp-to-buffer' ),
181 __( '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.', 'wp-to-buffer' ),
182 ),
183 array(
184 __( 'Bulk Publish Old Posts', 'wp-to-buffer' ),
185 __( 'Manually re-share evergreen WordPress content and revive old posts with the Bulk Publish option', 'wp-to-buffer' ),
186 ),
187 array(
188 __( 'The Events Calendar, Event Manager and Modern Events Calendar Integration', 'wp-to-buffer' ),
189 __( 'Schedule Posts to Buffer based on your Event\'s Start or End date, and display Event-specific details in your status updates', 'wp-to-buffer' ),
190 ),
191 array(
192 __( 'SEO Integration', 'wp-to-buffer' ),
193 __( 'Display SEO-specific information in your status updates from All-In-One SEO Pack, Rank Math, SEOPress and Yoast SEO', 'wp-to-buffer' ),
194 ),
195 array(
196 __( 'WooCommerce Integration', 'wp-to-buffer' ),
197 __( 'Display Product-specific information in your status updates', 'wp-to-buffer' ),
198 ),
199 array(
200 __( 'Autoblogging and Frontend Post Submission Integration', 'wp-to-buffer' ),
201 __( 'Pro supports autoblogging and frontend post submission Plugins, including User Submitted Posts, WP Property Feed, WPeMatico and WP Job Manager', 'wp-to-buffer' ),
202 ),
203 array(
204 __( 'Shortcode Support', 'wp-to-buffer' ),
205 __( 'Use shortcodes in status updates', 'wp-to-buffer' ),
206 ),
207 array(
208 __( 'Full Image Control', 'wp-to-buffer' ),
209 __( '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' ),
210 ),
211 array(
212 __( 'WP-Cron and WP-CLI Compatible', 'wp-to-buffer' ),
213 __( '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' ),
214 ),
215 );
216
217 // Dashboard Submodule.
218 if ( ! class_exists( 'WPZincDashboardWidget' ) ) {
219 require_once $this->plugin->folder . '_modules/dashboard/class-wpzincdashboardwidget.php';
220 }
221 $this->dashboard = new WPZincDashboardWidget( $this->plugin, 'https://www.wpzinc.com/wp-content/plugins/lum-deactivation' );
222
223 // Initialize Plugin classes.
224 $this->classes = new stdClass();
225
226 // Initialize required classes.
227 $this->classes->admin = new WP_To_Social_Pro_Admin( self::$instance );
228 $this->classes->ajax = new WP_To_Social_Pro_AJAX( self::$instance );
229 $this->classes->api = new WP_To_Social_Pro_Buffer_API( self::$instance );
230 $this->classes->common = new WP_To_Social_Pro_Common( self::$instance );
231 $this->classes->cron = new WP_To_Social_Pro_Cron( self::$instance );
232 $this->classes->date = new WP_To_Social_Pro_Date( self::$instance );
233 $this->classes->image = new WP_To_Social_Pro_Image( self::$instance );
234 $this->classes->install = new WP_To_Social_Pro_Install( self::$instance );
235 $this->classes->log = new WP_To_Social_Pro_Log( self::$instance );
236 $this->classes->media_library = new WP_To_Social_Pro_Media_Library( self::$instance );
237 $this->classes->notices = new WP_To_Social_Pro_Notices( self::$instance );
238 $this->classes->post = new WP_To_Social_Pro_Post( self::$instance );
239 $this->classes->publish = new WP_To_Social_Pro_Publish( self::$instance );
240 $this->classes->screen = new WP_To_Social_Pro_Screen( self::$instance );
241 $this->classes->settings = new WP_To_Social_Pro_Settings( self::$instance );
242 $this->classes->twitter_api = new WP_To_Social_Pro_Twitter_API( self::$instance );
243 $this->classes->validation = new WP_To_Social_Pro_Validation( self::$instance );
244
245 // Integrations.
246 $this->classes->aioseo = new WP_To_Social_Pro_AIOSEO( self::$instance );
247 $this->classes->rank_math = new WP_To_Social_Pro_Rank_Math( self::$instance );
248 $this->classes->seopress = new WP_To_Social_Pro_SEOPress( self::$instance );
249 $this->classes->yoast_seo = new WP_To_Social_Pro_Yoast_SEO( self::$instance );
250
251 }
252
253 /**
254 * Runs the upgrade routine once the plugin has loaded
255 *
256 * @since 3.2.5
257 */
258 public function upgrade() {
259
260 // Run upgrade routine.
261 $this->get_class( 'install' )->upgrade();
262
263 }
264
265 /**
266 * Returns the given class
267 *
268 * @since 3.4.9
269 *
270 * @param string $name Class Name.
271 */
272 public function get_class( $name ) {
273
274 // If the class hasn't been loaded, throw a WordPress die screen
275 // to avoid a PHP fatal error.
276 if ( ! isset( $this->classes->{ $name } ) ) {
277 // Define the error.
278 $error = new WP_Error(
279 'wp_to_buffer_get_class',
280 sprintf(
281 /* translators: %1$s: Plugin Name, %2$s: PHP class name */
282 __( '%1$s: Error: Could not load Plugin class %2$s', 'wp-to-buffer' ),
283 $this->plugin->displayName,
284 $name
285 )
286 );
287
288 // Depending on the request, return or display an error.
289 // Admin UI.
290 if ( is_admin() ) {
291 wp_die(
292 esc_html( $error->get_error_message() ),
293 sprintf(
294 /* translators: Plugin Name */
295 esc_html__( '%s: Error', 'wp-to-buffer' ),
296 esc_html( $this->plugin->displayName )
297 ),
298 array(
299 'back_link' => true,
300 )
301 );
302 }
303
304 // Cron / CLI.
305 return $error;
306 }
307
308 // Return the class object.
309 return $this->classes->{ $name };
310
311 }
312
313 /**
314 * Helper method to determine whether this Plugin supports a specific feature.
315 *
316 * Typically used by the lib/ classes.
317 *
318 * @since 3.5.5
319 *
320 * @param string $feature Feature.
321 * @return bool Feature Supported
322 */
323 public function supports( $feature ) {
324
325 // Define supported featured.
326 $supported_features = array(
327 'webp',
328 );
329
330 return in_array( $feature, $supported_features, true );
331
332 }
333
334 /**
335 * Returns the singleton instance of the class.
336 *
337 * @since 3.1.4
338 *
339 * @return object Class.
340 */
341 public static function get_instance() {
342
343 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
344 self::$instance = new self();
345 }
346
347 return self::$instance;
348
349 }
350
351 }
352