| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Import Social Events |
| 4 |
* Plugin URI: http://xylusthemes.com/plugins/import-facebook-events/ |
| 5 |
* Description: Import Social Events allows you to import Facebook ( facebook.com ) events into your WordPress site. |
| 6 |
* Version: 1.9.1 |
| 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: import-facebook-events |
| 12 |
* Domain Path: /languages |
| 13 |
* |
| 14 |
* @package Import_Facebook_Events |
| 15 |
* @author Dharmesh Patel <dspatel44@gmail.com> |
| 16 |
*/ |
| 17 |
|
| 18 |
// If this file is called directly, abort. |
| 19 |
if ( ! defined( 'ABSPATH' ) ) { |
| 20 |
exit; |
| 21 |
} |
| 22 |
|
| 23 |
if ( ! class_exists( 'Import_Facebook_Events' ) ) : |
| 24 |
|
| 25 |
/** |
| 26 |
* Main Import Facebook Events class |
| 27 |
*/ |
| 28 |
class Import_Facebook_Events { |
| 29 |
|
| 30 |
/** Singleton *************************************************************/ |
| 31 |
/** |
| 32 |
* Import_Facebook_Events The one true Import_Facebook_Events. |
| 33 |
* |
| 34 |
* @var object Instance of Import_Facebook_Events |
| 35 |
*/ |
| 36 |
private static $instance; |
| 37 |
public $common, $cpt, $facebook, $admin, $manage_import, $ife, $tec, $em, $eventon, $event_organizer, $aioec, $my_calendar, $ee4, $ical_parser, $ical, $fb_authorize, $common_pro, $facebook_pro, $cron, $ical_parser_aioec, $eventprime, $ajax, $htmltblock; |
| 38 |
|
| 39 |
/** |
| 40 |
* Main Import Facebook Events Instance. |
| 41 |
* |
| 42 |
* Insure that only one instance of Import_Facebook_Events exists in memory at any one time. |
| 43 |
* Also prevents needing to define globals all over the place. |
| 44 |
* |
| 45 |
* @since 1.0.0 |
| 46 |
* @static object $instance |
| 47 |
* @uses Import_Facebook_Events::setup_constants() Setup the constants needed. |
| 48 |
* @uses Import_Facebook_Events::includes() Include the required files. |
| 49 |
* @uses Import_Facebook_Events::laod_textdomain() load the language files. |
| 50 |
* @see run_import_facebook_events() |
| 51 |
* @return object| Import Facebook Events the one true Import Facebook Events. |
| 52 |
*/ |
| 53 |
public static function instance() { |
| 54 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Import_Facebook_Events ) ) { |
| 55 |
self::$instance = new Import_Facebook_Events(); |
| 56 |
self::$instance->setup_constants(); |
| 57 |
|
| 58 |
add_action( 'init', array( self::$instance, 'load_textdomain' ) ); |
| 59 |
add_action( 'plugins_loaded', array( self::$instance, 'load_authorize_class' ), 20 ); |
| 60 |
add_action( 'wp_enqueue_scripts', array( self::$instance, 'ife_enqueue_style' ) ); |
| 61 |
add_action( 'wp_enqueue_scripts', array( self::$instance, 'ife_enqueue_script' ) ); |
| 62 |
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( self::$instance, 'ife_setting_doc_links' ) ); |
| 63 |
|
| 64 |
self::$instance->includes(); |
| 65 |
self::$instance->common = new Import_Facebook_Events_Common(); |
| 66 |
self::$instance->ajax = new Import_Facebook_Events_Ajax(); |
| 67 |
self::$instance->cpt = new Import_Facebook_Events_Cpt(); |
| 68 |
self::$instance->facebook = new Import_Facebook_Events_Facebook(); |
| 69 |
self::$instance->admin = new Import_Facebook_Events_Admin(); |
| 70 |
self::$instance->htmltblock = new Import_Facebook_Events_Html_To_Blocks(); |
| 71 |
|
| 72 |
self::$instance->ical_parser = new Import_Facebook_Events_Ical_Parser(); |
| 73 |
self::$instance->ical_parser_aioec = new Import_Facebook_Events_Ical_Parser_AIOEC(); |
| 74 |
self::$instance->ical = new Import_Facebook_Events_Ical(); |
| 75 |
if ( ife_is_pro() ) { |
| 76 |
self::$instance->manage_import = new Import_Facebook_Events_Pro_Manage_Import(); |
| 77 |
} else { |
| 78 |
self::$instance->manage_import = new Import_Facebook_Events_Manage_Import(); |
| 79 |
} |
| 80 |
self::$instance->ife = new Import_Facebook_Events_IFE(); |
| 81 |
self::$instance->tec = new Import_Facebook_Events_TEC(); |
| 82 |
self::$instance->em = new Import_Facebook_Events_EM(); |
| 83 |
self::$instance->eventon = new Import_Facebook_Events_EventON(); |
| 84 |
self::$instance->event_organizer = new Import_Facebook_Events_Event_Organizer(); |
| 85 |
self::$instance->aioec = new Import_Facebook_Events_Aioec(); |
| 86 |
self::$instance->my_calendar = new Import_Facebook_Events_My_Calendar(); |
| 87 |
self::$instance->ee4 = new Import_Facebook_Events_EE4(); |
| 88 |
self::$instance->eventprime = new Import_Facebook_Events_EventPrime(); |
| 89 |
} |
| 90 |
return self::$instance; |
| 91 |
} |
| 92 |
|
| 93 |
/** Magic Methods *********************************************************/ |
| 94 |
|
| 95 |
/** |
| 96 |
* A dummy constructor to prevent Import_Facebook_Events from being loaded more than once. |
| 97 |
* |
| 98 |
* @since 1.0.0 |
| 99 |
* @see Import_Facebook_Events::instance() |
| 100 |
* @see run_import_facebook_events() |
| 101 |
*/ |
| 102 |
private function __construct() { |
| 103 |
/* Do nothing here */ } |
| 104 |
|
| 105 |
/** |
| 106 |
* A dummy magic method to prevent Import_Facebook_Events from being cloned. |
| 107 |
* |
| 108 |
* @since 1.0.0 |
| 109 |
*/ |
| 110 |
public function __clone() { |
| 111 |
_doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'import-facebook-events' ), '1.9.1' ); } |
| 112 |
|
| 113 |
/** |
| 114 |
* A dummy magic method to prevent Import_Facebook_Events from being unserialized. |
| 115 |
* |
| 116 |
* @since 1.0.0 |
| 117 |
*/ |
| 118 |
public function __wakeup() { |
| 119 |
_doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'import-facebook-events' ), '1.9.1' ); } |
| 120 |
|
| 121 |
|
| 122 |
/** |
| 123 |
* Setup plugins constants. |
| 124 |
* |
| 125 |
* @access private |
| 126 |
* @since 1.0.0 |
| 127 |
* @return void |
| 128 |
*/ |
| 129 |
private function setup_constants() { |
| 130 |
|
| 131 |
// Plugin version. |
| 132 |
if ( ! defined( 'IFE_VERSION' ) ) { |
| 133 |
define( 'IFE_VERSION', '1.9.1' ); |
| 134 |
} |
| 135 |
|
| 136 |
// Minimum Pro plugin version. |
| 137 |
if ( ! defined( 'IFE_MIN_PRO_VERSION' ) ) { |
| 138 |
define( 'IFE_MIN_PRO_VERSION', '1.9.2' ); |
| 139 |
} |
| 140 |
|
| 141 |
// Plugin folder Path. |
| 142 |
if ( ! defined( 'IFE_PLUGIN_DIR' ) ) { |
| 143 |
define( 'IFE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 144 |
} |
| 145 |
|
| 146 |
// Plugin folder URL. |
| 147 |
if ( ! defined( 'IFE_PLUGIN_URL' ) ) { |
| 148 |
define( 'IFE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 149 |
} |
| 150 |
|
| 151 |
// Plugin root file. |
| 152 |
if ( ! defined( 'IFE_PLUGIN_FILE' ) ) { |
| 153 |
define( 'IFE_PLUGIN_FILE', __FILE__ ); |
| 154 |
} |
| 155 |
|
| 156 |
// Options. |
| 157 |
if ( ! defined( 'IFE_OPTIONS' ) ) { |
| 158 |
define( 'IFE_OPTIONS', 'ife_facebook_options' ); |
| 159 |
} |
| 160 |
|
| 161 |
// Pro plugin Buy now Link. |
| 162 |
if ( ! defined( 'IFE_PLUGIN_BUY_NOW_URL' ) ) { |
| 163 |
define( 'IFE_PLUGIN_BUY_NOW_URL', 'http://xylusthemes.com/plugins/import-facebook-events/?utm_source=insideplugin&utm_medium=web&utm_content=sidebar&utm_campaign=freeplugin' ); |
| 164 |
} |
| 165 |
} |
| 166 |
|
| 167 |
/** |
| 168 |
* Include required files. |
| 169 |
* |
| 170 |
* @access private |
| 171 |
* @since 1.0.0 |
| 172 |
* @return void |
| 173 |
*/ |
| 174 |
private function includes() { |
| 175 |
|
| 176 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-common.php'; |
| 177 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-ajax.php'; |
| 178 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-list-table.php'; |
| 179 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-admin.php'; |
| 180 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-html-to-blocks.php'; |
| 181 |
if ( ife_is_pro() ) { |
| 182 |
require_once IFEPRO_PLUGIN_DIR . 'includes/class-import-facebook-events-manage-import.php'; |
| 183 |
} else { |
| 184 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-manage-import.php'; |
| 185 |
} |
| 186 |
|
| 187 |
if( !class_exists( 'Kigkonsult\Icalcreator\Vcalendar' ) ){ |
| 188 |
require_once IFE_PLUGIN_DIR . 'includes/lib/icalcreator/autoload.php'; |
| 189 |
} |
| 190 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-ical_parser.php'; |
| 191 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-ical_parser_aioec.php'; |
| 192 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-ical.php'; |
| 193 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-cpt.php'; |
| 194 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-facebook.php'; |
| 195 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-ife.php'; |
| 196 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-tec.php'; |
| 197 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-em.php'; |
| 198 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-eventon.php'; |
| 199 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-event-organizer.php'; |
| 200 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-aioec.php'; |
| 201 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-my-calendar.php'; |
| 202 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-ee4.php'; |
| 203 |
require_once IFE_PLUGIN_DIR . 'includes/class-ife-plugin-deactivation.php'; |
| 204 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-eventprime.php'; |
| 205 |
// Gutenberg Block. |
| 206 |
require_once IFE_PLUGIN_DIR . 'blocks/facebook-events/index.php'; |
| 207 |
|
| 208 |
// Feed Widget Builder |
| 209 |
if ( file_exists( IFE_PLUGIN_DIR . 'ifepro-feed/feed-init.php' ) ) { |
| 210 |
require_once IFE_PLUGIN_DIR . 'ifepro-feed/feed-init.php'; |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
/** |
| 215 |
* Loads the plugin language files. |
| 216 |
* |
| 217 |
* @access public |
| 218 |
* @since 1.0.0 |
| 219 |
* @return void |
| 220 |
*/ |
| 221 |
public function load_textdomain() { |
| 222 |
|
| 223 |
// phpcs:ignore PluginCheck.CodeAnalysis.DiscouragedFunctions.load_plugin_textdomainFound |
| 224 |
load_plugin_textdomain( |
| 225 |
'import-facebook-events', |
| 226 |
false, |
| 227 |
basename( dirname( __FILE__ ) ) . '/languages' |
| 228 |
); |
| 229 |
|
| 230 |
} |
| 231 |
|
| 232 |
/** |
| 233 |
* IFE setting And docs link add in plugin page. |
| 234 |
* |
| 235 |
* @since 1.0 |
| 236 |
* @return void |
| 237 |
*/ |
| 238 |
public function ife_setting_doc_links ( $links ) { |
| 239 |
$upgrate_to_pro = ''; |
| 240 |
if( !ife_is_pro() ){ |
| 241 |
$upgrate_to_pro = sprintf( |
| 242 |
'<a href="%s" target="_blank" style="color:#1da867;font-weight: 900;">%s</a>', |
| 243 |
esc_url( 'https://xylusthemes.com/plugins/import-facebook-events/' ), |
| 244 |
esc_html__( 'Upgrade to Pro', 'import-facebook-events' ) |
| 245 |
); |
| 246 |
} |
| 247 |
|
| 248 |
$ife_setting_doc_link = array( |
| 249 |
'ife-event-setting' => sprintf( |
| 250 |
'<a href="%s">%s</a>', |
| 251 |
esc_url( admin_url( 'admin.php?page=facebook_import&tab=settings' ) ), |
| 252 |
esc_html__( 'Setting', 'import-facebook-events' ) |
| 253 |
), |
| 254 |
'ife-event-docs' => sprintf( |
| 255 |
'<a target="_blank" href="%s">%s</a>', |
| 256 |
esc_url( 'https://docs.xylusthemes.com/docs/import-facebook-events/' ), |
| 257 |
esc_html__( 'Docs', 'import-facebook-events' ) |
| 258 |
), |
| 259 |
'ife-event-pro-link' => $upgrate_to_pro, |
| 260 |
); |
| 261 |
return array_merge( $links, $ife_setting_doc_link ); |
| 262 |
} |
| 263 |
|
| 264 |
/** |
| 265 |
* Loads the facebook authorize class |
| 266 |
* |
| 267 |
* @access public |
| 268 |
* @since 1.5 |
| 269 |
* @return void |
| 270 |
*/ |
| 271 |
public function load_authorize_class() { |
| 272 |
|
| 273 |
if ( ! class_exists( 'Import_Facebook_Events_Pro_FB_Authorize', false ) ) { |
| 274 |
include_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-fb-authorize.php'; |
| 275 |
global $ife_events; |
| 276 |
if ( class_exists( 'Import_Facebook_Events_FB_Authorize', false ) && ! empty( $ife_events ) ) { |
| 277 |
$ife_events->fb_authorize = new Import_Facebook_Events_FB_Authorize(); |
| 278 |
} |
| 279 |
} |
| 280 |
} |
| 281 |
|
| 282 |
/** |
| 283 |
* Enqueue style front-end |
| 284 |
* |
| 285 |
* @access public |
| 286 |
* @since 1.0.0 |
| 287 |
* @return void |
| 288 |
*/ |
| 289 |
public function ife_enqueue_style() { |
| 290 |
|
| 291 |
$css_dir = IFE_PLUGIN_URL . 'assets/css/'; |
| 292 |
wp_enqueue_style( 'font-awesome', $css_dir . 'font-awesome.min.css', false, IFE_VERSION ); |
| 293 |
wp_enqueue_style( 'import-facebook-events-front', $css_dir . 'import-facebook-events.css', false, IFE_VERSION ); |
| 294 |
wp_enqueue_style( 'import-facebook-events-front-style2', $css_dir . 'grid-style2.css', false, IFE_VERSION ); |
| 295 |
} |
| 296 |
|
| 297 |
/** |
| 298 |
* Enqueue script front-end |
| 299 |
* |
| 300 |
* @access public |
| 301 |
* @since 1.0.0 |
| 302 |
* @return void |
| 303 |
*/ |
| 304 |
public function ife_enqueue_script() { |
| 305 |
|
| 306 |
// Enqueue script here. |
| 307 |
$js_dir = IFE_PLUGIN_URL . 'assets/js/'; |
| 308 |
wp_enqueue_script( 'ife-ajax-pagi', $js_dir . 'ife-ajax-pagi.js', array( 'jquery' ), IFE_VERSION, true ); |
| 309 |
wp_localize_script( 'ife-ajax-pagi', 'ife_ajax', array( |
| 310 |
'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 311 |
'nonce' => wp_create_nonce( 'ife_ajax_pagi_nonce_action' ), |
| 312 |
)); |
| 313 |
} |
| 314 |
|
| 315 |
} |
| 316 |
|
| 317 |
endif; // End If class exists check. |
| 318 |
|
| 319 |
/** |
| 320 |
* The main function for that returns Import_Facebook_Events |
| 321 |
* |
| 322 |
* The main function responsible for returning the one true Import_Facebook_Events |
| 323 |
* Instance to functions everywhere. |
| 324 |
* |
| 325 |
* Use this function like you would a global variable, except without needing |
| 326 |
* to declare the global. |
| 327 |
* |
| 328 |
* Example: <?php $ife_events = run_import_facebook_events(); ?> |
| 329 |
* |
| 330 |
* @since 1.0.0 |
| 331 |
* @return object|Import_Facebook_Events The one true Import_Facebook_Events Instance. |
| 332 |
*/ |
| 333 |
function run_import_facebook_events() { |
| 334 |
return Import_Facebook_Events::instance(); |
| 335 |
} |
| 336 |
|
| 337 |
/** |
| 338 |
* Get Import events setting options |
| 339 |
* |
| 340 |
* @since 1.0 |
| 341 |
* @param string $type origin for requested options. |
| 342 |
* @return array |
| 343 |
*/ |
| 344 |
function ife_get_import_options( $type = '' ) { |
| 345 |
$ife_options = get_option( IFE_OPTIONS ); |
| 346 |
return $ife_options; |
| 347 |
} |
| 348 |
|
| 349 |
// Get Import_Facebook_Events Running. |
| 350 |
global $ife_events, $ife_errors, $ife_success_msg, $ife_warnings, $ife_info_msg; |
| 351 |
$ife_errors = array(); |
| 352 |
$ife_warnings = array(); |
| 353 |
$ife_success_msg = array(); |
| 354 |
$ife_info_msg = array(); |
| 355 |
$ife_events = run_import_facebook_events(); |
| 356 |
|
| 357 |
/** |
| 358 |
* The code that runs during plugin activation. |
| 359 |
* |
| 360 |
* @since 1.0 |
| 361 |
*/ |
| 362 |
function ife_activate_import_facebook_events() { |
| 363 |
global $ife_events; |
| 364 |
$ife_events->cpt->register_event_post_type(); |
| 365 |
flush_rewrite_rules(); |
| 366 |
add_option( 'ife_plugin_activated', true ); |
| 367 |
} |
| 368 |
register_activation_hook( __FILE__, 'ife_activate_import_facebook_events' ); |
| 369 |
|