PluginProbe
Social Media Auto Poster – Schedule & Publish to Buffer / 3.8.6
Social Media Auto Poster – Schedule & Publish to Buffer v3.8.6
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 3.8.8 All 124 releases
wp-to-buffer / includes / class-wp-to-buffer.php

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

295 lines 9.2 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->requires = '5.0';
72 $this->plugin->tested = '6.1.1';
73 $this->plugin->folder = WP_TO_BUFFER_PLUGIN_PATH;
74 $this->plugin->url = WP_TO_BUFFER_PLUGIN_URL;
75 $this->plugin->documentation_url = 'https://www.wpzinc.com/documentation/wordpress-buffer-pro';
76 $this->plugin->support_url = 'https://www.wpzinc.com/support';
77 $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
83 );
84
85 // Default Settings.
86 $this->plugin->default_schedule = 'queue_bottom';
87
88 // Upgrade Reasons.
89 $this->plugin->upgrade_reasons = array(
90 array(
91 __( 'Post to Instagram and Pinterest', 'wp-to-buffer' ),
92 __( 'Pro supports Direct Posting to Instagram Business Profiles and Pinterest Boards', 'wp-to-buffer' ),
93 ),
94 array(
95 __( 'Multiple, Customisable Status Messages', 'wp-to-buffer' ),
96 __( 'Each Post Type and Social Network can have multiple, unique status message and settings', 'wp-to-buffer' ),
97 ),
98 array(
99 __( 'Conditionally send Status Messages', 'wp-to-buffer' ),
100 __( 'Only send status(es) to Buffer based on Post Author(s), Taxonomy Term(s) and/or Custom Field Values', 'wp-to-buffer' ),
101 ),
102 array(
103 __( 'More Scheduling Options', 'wp-to-buffer' ),
104 __( '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' ),
105 ),
106 array(
107 __( 'Dynamic Status Tags', 'wp-to-buffer' ),
108 __( 'Dynamically build status updates with data from the Post Author and Custom Fields', 'wp-to-buffer' ),
109 ),
110 array(
111 __( 'Separate Statuses per Social Network', 'wp-to-buffer' ),
112 __( 'Define different statuses for each Post Type and Social Network', 'wp-to-buffer' ),
113 ),
114 array(
115 __( 'Per-Post Settings', 'wp-to-buffer' ),
116 __( 'Override Settings on Individual Posts: Each Post can have its own Buffer settings', 'wp-to-buffer' ),
117 ),
118 array(
119 __( 'Repost Old Posts', 'wp-to-buffer' ),
120 __( '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' ),
121 ),
122 array(
123 __( 'Bulk Publish Old Posts', 'wp-to-buffer' ),
124 __( 'Manually re-share evergreen WordPress content and revive old posts with the Bulk Publish option', 'wp-to-buffer' ),
125 ),
126 array(
127 __( 'The Events Calendar, Event Manager and Modern Events Calendar Integration', 'wp-to-buffer' ),
128 __( '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' ),
129 ),
130 array(
131 __( 'SEO Integration', 'wp-to-buffer' ),
132 __( 'Display SEO-specific information in your status updates from All-In-One SEO Pack, Rank Math, SEOPress and Yoast SEO', 'wp-to-buffer' ),
133 ),
134 array(
135 __( 'WooCommerce Integration', 'wp-to-buffer' ),
136 __( 'Display Product-specific information in your status updates', 'wp-to-buffer' ),
137 ),
138 array(
139 __( 'Autoblogging and Frontend Post Submission Integration', 'wp-to-buffer' ),
140 __( 'Pro supports autoblogging and frontend post submission Plugins, including User Submitted Posts, WP Property Feed, WPeMatico and WP Job Manager', 'wp-to-buffer' ),
141 ),
142 array(
143 __( 'Shortcode Support', 'wp-to-buffer' ),
144 __( 'Use shortcodes in status updates', 'wp-to-buffer' ),
145 ),
146 array(
147 __( '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' ),
149 ),
150 array(
151 __( 'WP-Cron and WP-CLI Compatible', 'wp-to-buffer' ),
152 __( '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 ),
154 );
155
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' );
161
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
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->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 );
198
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 }
205
206 /**
207 * Runs the upgrade routine once the plugin has loaded
208 *
209 * @since 3.2.5
210 */
211 public function upgrade() {
212
213 // Run upgrade routine.
214 $this->get_class( 'install' )->upgrade();
215
216 }
217
218 /**
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 * Returns the given class
231 *
232 * @since 3.4.9
233 *
234 * @param string $name Class Name.
235 */
236 public function get_class( $name ) {
237
238 // If the class hasn't been loaded, throw a WordPress die screen
239 // to avoid a PHP fatal error.
240 if ( ! isset( $this->classes->{ $name } ) ) {
241 // Define the error.
242 $error = new WP_Error(
243 'wp_to_buffer_get_class',
244 sprintf(
245 /* translators: %1$s: Plugin Name, %2$s: PHP class name */
246 __( '%1$s: Error: Could not load Plugin class %2$s', 'wp-to-buffer' ),
247 $this->plugin->displayName,
248 $name
249 )
250 );
251
252 // Depending on the request, return or display an error.
253 // Admin UI.
254 if ( is_admin() ) {
255 wp_die(
256 esc_html( $error->get_error_message() ),
257 sprintf(
258 /* translators: Plugin Name */
259 esc_html__( '%s: Error', 'wp-to-buffer' ),
260 esc_html( $this->plugin->displayName )
261 ),
262 array(
263 'back_link' => true,
264 )
265 );
266 }
267
268 // Cron / CLI.
269 return $error;
270 }
271
272 // Return the class object.
273 return $this->classes->{ $name };
274
275 }
276
277 /**
278 * Returns the singleton instance of the class.
279 *
280 * @since 3.1.4
281 *
282 * @return object Class.
283 */
284 public static function get_instance() {
285
286 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
287 self::$instance = new self();
288 }
289
290 return self::$instance;
291
292 }
293
294 }
295