PluginProbe
XT Event Widget for Social Events / 2.0.0
XT Event Widget for Social Events v2.0.0
trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0
xt-facebook-events / xt-facebook-events.php
xt-facebook-events.php
294 lines 8.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: XT Event Widget for Social Events
4 * Plugin URI: http://xylusthemes.com/plugins/xt-facebook-events/
5 * Description: Display Facebook Events into your WordPress site anywhere.
6 * Version: 2.0.0
7 * Author: Xylus Themes
8 * Author URI: http://xylusthemes.com
9 * License: GPL-2.0+
10 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11 * Text Domain: xt-facebook-events
12 * Domain Path: /languages
13 *
14 * @package XT_Facebook_Events
15 * @author Dharmesh Patel <dspatel44@gmail.com>
16 */
17
18 // If this file is called directly, abort.
19 if ( ! defined( 'ABSPATH' ) ) exit;
20
21 if( ! class_exists( 'XT_Facebook_Events' ) ):
22
23 /**
24 * Main Facebook Events class
25 */
26 class XT_Facebook_Events{
27
28 /** Singleton *************************************************************/
29 /**
30 * XT_Facebook_Events The one true XT_Facebook_Events.
31 */
32 private static $instance;
33 public $common, $facebook, $admin, $fb_authorize, $common_pro;
34
35 /**
36 * Main Facebook Events Instance.
37 *
38 * Insure that only one instance of XT_Facebook_Events exists in memory at any one time.
39 * Also prevents needing to define globals all over the place.
40 *
41 * @since 1.0.0
42 * @static object $instance
43 * @uses XT_Facebook_Events::setup_constants() Setup the constants needed.
44 * @uses XT_Facebook_Events::includes() Include the required files.
45 * @uses XT_Facebook_Events::laod_textdomain() load the language files.
46 * @see run_import_facebook_events()
47 * @return object| Facebook Events the one true Facebook Events.
48 */
49 public static function instance() {
50 if( ! isset( self::$instance ) && ! (self::$instance instanceof XT_Facebook_Events ) ) {
51 self::$instance = new XT_Facebook_Events;
52 self::$instance->setup_constants();
53
54 add_action( 'plugins_loaded', array( self::$instance, 'load_authorize_class' ), 20 );
55 add_action( 'wp_enqueue_scripts', array( self::$instance, 'xtfe_enqueue_style' ) );
56 add_action( 'wp_enqueue_scripts', array( self::$instance, 'xtfe_enqueue_script' ) );
57 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( self::$instance, 'xtfe_setting_doc_links' ) );
58
59 self::$instance->includes();
60 self::$instance->common = new XT_Facebook_Events_Common();
61 self::$instance->facebook = new XT_Facebook_Events_Facebook();
62 self::$instance->admin = new XT_Facebook_Events_Admin();
63 }
64 return self::$instance;
65 }
66
67 /** Magic Methods *********************************************************/
68
69 /**
70 * A dummy constructor to prevent XT_Facebook_Events from being loaded more than once.
71 *
72 * @since 1.0.0
73 * @see XT_Facebook_Events::instance()
74 * @see run_import_facebook_events()
75 */
76 private function __construct() { /* Do nothing here */ }
77
78 /**
79 * A dummy magic method to prevent XT_Facebook_Events from being cloned.
80 *
81 * @since 1.0.0
82 */
83 public function __clone() { _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'xt-facebook-events' ), '2.0.0' ); }
84
85 /**
86 * A dummy magic method to prevent XT_Facebook_Events from being unserialized.
87 *
88 * @since 1.0.0
89 */
90 public function __wakeup() { _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'xt-facebook-events' ), '2.0.0' ); }
91
92
93 /**
94 * Setup plugins constants.
95 *
96 * @access private
97 * @since 1.0.0
98 * @return void
99 */
100 private function setup_constants() {
101
102 // Plugin version.
103 if( ! defined( 'XTFE_VERSION' ) ){
104 define( 'XTFE_VERSION', '2.0.0' );
105 }
106
107 // Plugin folder Path.
108 if( ! defined( 'XTFE_PLUGIN_DIR' ) ){
109 define( 'XTFE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
110 }
111
112 // Plugin folder URL.
113 if( ! defined( 'XTFE_PLUGIN_URL' ) ){
114 define( 'XTFE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
115 }
116
117 // Plugin root file.
118 if( ! defined( 'XTFE_PLUGIN_FILE' ) ){
119 define( 'XTFE_PLUGIN_FILE', __FILE__ );
120 }
121
122 // Options
123 if( ! defined( 'XTFE_OPTIONS' ) ){
124 define( 'XTFE_OPTIONS', 'xtfe_options' );
125 }
126
127 // Pro plugin Buy now Link.
128 if( ! defined( 'XTFE_PLUGIN_BUY_NOW_URL' ) ){
129 define( 'XTFE_PLUGIN_BUY_NOW_URL', 'https://xylusthemes.com/plugins/xt-facebook-events/?utm_source=insideplugin&utm_medium=web&utm_content=sidebar&utm_campaign=freeplugin' );
130 }
131 }
132
133 /**
134 * Include required files.
135 *
136 * @access private
137 * @since 1.0.0
138 * @return void
139 */
140 private function includes() {
141 require_once XTFE_PLUGIN_DIR . 'includes/class-xt-facebook-events-facebook.php';
142 require_once XTFE_PLUGIN_DIR . 'includes/class-xt-facebook-events-common.php';
143 require_once XTFE_PLUGIN_DIR . 'includes/class-xt-facebook-events-admin.php';
144 require_once XTFE_PLUGIN_DIR . 'includes/class-xt-facebook-events-widget.php';
145 require_once XTFE_PLUGIN_DIR . 'includes/class-xt-facebook-events-deactivation.php';
146 require_once XTFE_PLUGIN_DIR . 'includes/class-xt-facebook-events-list-table.php';
147
148 // Gutenberg Block
149 require_once XTFE_PLUGIN_DIR . 'blocks/facebook-events/index.php';
150
151 // Feed Widget Builder
152 if ( file_exists( XTFE_PLUGIN_DIR . 'xtfepro-feed/feed-init.php' ) ) {
153 require_once XTFE_PLUGIN_DIR . 'xtfepro-feed/feed-init.php';
154 }
155 }
156
157 /**
158 * Loads the facebook authorize class
159 *
160 * @access public
161 * @since 1.1
162 * @return void
163 */
164 public function load_authorize_class(){
165 if( !class_exists( 'XT_Facebook_Events_FB_Authorize', false ) ){
166 include_once XTFE_PLUGIN_DIR . 'includes/class-xt-facebook-events-fb-authorize.php';
167 global $xtfe_events;
168 if( class_exists('XT_Facebook_Events_FB_Authorize', false ) && !empty( $xtfe_events ) ){
169 $xtfe_events->fb_authorize = new XT_Facebook_Events_FB_Authorize();
170 }
171 }
172 }
173
174 /**
175 * enqueue style front-end
176 *
177 * @access public
178 * @since 1.0.0
179 * @return void
180 */
181 public function xtfe_enqueue_style() {
182
183 $css_dir = XTFE_PLUGIN_URL . 'assets/css/';
184 wp_enqueue_style('font-awesome', $css_dir . 'font-awesome.min.css', array(), XTFE_VERSION );
185 wp_enqueue_style('xt-facebook-events-front', $css_dir . 'xt-facebook-events.css', array(), XTFE_VERSION );
186 wp_enqueue_style('xt-facebook-events-front-grid2', $css_dir . 'grid_style2.css', array(), XTFE_VERSION );
187 }
188
189 /**
190 * enqueue script front-end
191 *
192 * @access public
193 * @since 1.0.0
194 * @return void
195 */
196 public function xtfe_enqueue_script() {
197
198 // enqueue script here.
199 }
200
201 /**
202 * XTFE setting And docs link add in plugin page.
203 *
204 * @since 1.0
205 * @return void
206 */
207 public function xtfe_setting_doc_links( $links ) {
208 $xtfe_setting_doc_link = array(
209 'xtfe-event-setting' => sprintf(
210 '<a href="%s">%s</a>',
211 esc_url( admin_url( 'admin.php?page=wpfb_events&tab=settings' ) ),
212 esc_html__( 'Setting', 'xt-facebook-events' )
213 ),
214 'xtfe-event-docs' => sprintf(
215 '<a target="_blank" href="%s">%s</a>',
216 esc_url( 'https://docs.xylusthemes.com/docs/facebookevents/' ),
217 esc_html__( 'Docs', 'xt-facebook-events' )
218 ),
219 );
220
221 $upgrate_to_pro = array();
222 if( !xtfe_is_pro() ){
223 $upgrate_to_pro = array( 'xtfe-event-pro-link' => sprintf(
224 '<a href="%s" target="_blank" style="color:#1da867;font-weight: 900;">%s</a>',
225 esc_url( 'https://xylusthemes.com/plugins/xt-facebook-events/' ),
226 esc_html__( 'Upgrade to Pro', 'xt-facebook-events' )
227 ) ) ;
228 }
229
230 return array_merge( $links, $xtfe_setting_doc_link, $upgrate_to_pro );
231 }
232
233 }
234
235 endif; // End If class exists check.
236
237 /**
238 * The main function for that returns XT_Facebook_Events
239 *
240 * The main function responsible for returning the one true XT_Facebook_Events
241 * Instance to functions everywhere.
242 *
243 * Use this function like you would a global variable, except without needing
244 * to declare the global.
245 *
246 * Example: <?php $xtfe_events = run_import_facebook_events(); ?>
247 *
248 * @since 1.0.0
249 * @return object|XT_Facebook_Events The one true XT_Facebook_Events Instance.
250 */
251 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
252 function run_xt_facebook_events() {
253 return XT_Facebook_Events::instance();
254 }
255
256 /**
257 * Get Import events setting options
258 *
259 * @since 1.0
260 * @return array
261 */
262 function xtfe_get_options() {
263
264 $xtfe_options = get_option( XTFE_OPTIONS , array() );
265 return $xtfe_options;
266 }
267
268 // Get XT_Facebook_Events Running.
269 global $xtfe_events, $xtfe_errors, $xtfe_success_msg, $xtfe_warnings, $xtfe_info_msg;
270 $xtfe_events = run_xt_facebook_events();
271 $xtfe_errors = $xtfe_warnings = $xtfe_success_msg = $xtfe_info_msg = array();
272
273 /**
274 * The code that runs during plugin activation.
275 *
276 * @since 1.0.0
277 */
278 function xtfe_activate_facebook_events() {
279 add_option( 'xtfe_do_activation_redirect', true );
280 }
281 register_activation_hook( __FILE__, 'xtfe_activate_facebook_events' );
282
283 add_action( 'admin_init', 'xtfe_redirect_on_activation' );
284 function xtfe_redirect_on_activation() {
285 if ( get_option( 'xtfe_do_activation_redirect', false ) ) {
286 delete_option( 'xtfe_do_activation_redirect' );
287 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
288 if ( ! isset( $_GET['activate-multi'] ) ) {
289 wp_safe_redirect( admin_url( 'edit.php?post_type=xtfepro_live_feed' ) );
290 exit;
291 }
292 }
293 }
294