| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Import Facebook Events |
| 4 |
* Plugin URI: http://xylusthemes.com/plugins/import-facebook-events/ |
| 5 |
* Description: Import Facebook Events allows you to import Facebook ( facebook.com ) events into your WordPress site. |
| 6 |
* Version: 1.1.2 |
| 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' ) ) exit; |
| 20 |
|
| 21 |
if( ! class_exists( 'Import_Facebook_Events' ) ): |
| 22 |
|
| 23 |
/** |
| 24 |
* Main Import Facebook Events class |
| 25 |
*/ |
| 26 |
class Import_Facebook_Events{ |
| 27 |
|
| 28 |
/** Singleton *************************************************************/ |
| 29 |
/** |
| 30 |
* Import_Facebook_Events The one true Import_Facebook_Events. |
| 31 |
*/ |
| 32 |
private static $instance; |
| 33 |
|
| 34 |
/** |
| 35 |
* Main Import Facebook Events Instance. |
| 36 |
* |
| 37 |
* Insure that only one instance of Import_Facebook_Events exists in memory at any one time. |
| 38 |
* Also prevents needing to define globals all over the place. |
| 39 |
* |
| 40 |
* @since 1.0.0 |
| 41 |
* @static object $instance |
| 42 |
* @uses Import_Facebook_Events::setup_constants() Setup the constants needed. |
| 43 |
* @uses Import_Facebook_Events::includes() Include the required files. |
| 44 |
* @uses Import_Facebook_Events::laod_textdomain() load the language files. |
| 45 |
* @see run_import_facebook_events() |
| 46 |
* @return object| Import Facebook Events the one true Import Facebook Events. |
| 47 |
*/ |
| 48 |
public static function instance() { |
| 49 |
if( ! isset( self::$instance ) && ! (self::$instance instanceof Import_Facebook_Events ) ) { |
| 50 |
self::$instance = new Import_Facebook_Events; |
| 51 |
self::$instance->setup_constants(); |
| 52 |
|
| 53 |
add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); |
| 54 |
add_action( 'wp_enqueue_scripts', array( self::$instance, 'ife_enqueue_style' ) ); |
| 55 |
add_action( 'wp_enqueue_scripts', array( self::$instance, 'ife_enqueue_script' ) ); |
| 56 |
|
| 57 |
self::$instance->includes(); |
| 58 |
self::$instance->common = new Import_Facebook_Events_Common(); |
| 59 |
self::$instance->cpt = new Import_Facebook_Events_Cpt(); |
| 60 |
self::$instance->facebook = new Import_Facebook_Events_Facebook(); |
| 61 |
self::$instance->admin = new Import_Facebook_Events_Admin(); |
| 62 |
self::$instance->manage_import = new Import_Facebook_Events_Manage_Import(); |
| 63 |
self::$instance->ife = new Import_Facebook_Events_IFE(); |
| 64 |
self::$instance->tec = new Import_Facebook_Events_TEC(); |
| 65 |
self::$instance->em = new Import_Facebook_Events_EM(); |
| 66 |
self::$instance->eventon = new Import_Facebook_Events_EventON(); |
| 67 |
self::$instance->event_organizer = new Import_Facebook_Events_Event_Organizer(); |
| 68 |
self::$instance->aioec = new Import_Facebook_Events_Aioec(); |
| 69 |
self::$instance->my_calendar = new Import_Facebook_Events_My_Calendar(); |
| 70 |
|
| 71 |
} |
| 72 |
return self::$instance; |
| 73 |
} |
| 74 |
|
| 75 |
/** Magic Methods *********************************************************/ |
| 76 |
|
| 77 |
/** |
| 78 |
* A dummy constructor to prevent Import_Facebook_Events from being loaded more than once. |
| 79 |
* |
| 80 |
* @since 1.0.0 |
| 81 |
* @see Import_Facebook_Events::instance() |
| 82 |
* @see run_import_facebook_events() |
| 83 |
*/ |
| 84 |
private function __construct() { /* Do nothing here */ } |
| 85 |
|
| 86 |
/** |
| 87 |
* A dummy magic method to prevent Import_Facebook_Events from being cloned. |
| 88 |
* |
| 89 |
* @since 1.0.0 |
| 90 |
*/ |
| 91 |
public function __clone() { _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'import-facebook-events' ), '1.0.0' ); } |
| 92 |
|
| 93 |
/** |
| 94 |
* A dummy magic method to prevent Import_Facebook_Events from being unserialized. |
| 95 |
* |
| 96 |
* @since 1.0.0 |
| 97 |
*/ |
| 98 |
public function __wakeup() { _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'import-facebook-events' ), '1.0.0' ); } |
| 99 |
|
| 100 |
|
| 101 |
/** |
| 102 |
* Setup plugins constants. |
| 103 |
* |
| 104 |
* @access private |
| 105 |
* @since 1.0.0 |
| 106 |
* @return void |
| 107 |
*/ |
| 108 |
private function setup_constants() { |
| 109 |
|
| 110 |
// Plugin version. |
| 111 |
if( ! defined( 'IFE_VERSION' ) ){ |
| 112 |
define( 'IFE_VERSION', '1.1.0' ); |
| 113 |
} |
| 114 |
|
| 115 |
// Plugin folder Path. |
| 116 |
if( ! defined( 'IFE_PLUGIN_DIR' ) ){ |
| 117 |
define( 'IFE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 118 |
} |
| 119 |
|
| 120 |
// Plugin folder URL. |
| 121 |
if( ! defined( 'IFE_PLUGIN_URL' ) ){ |
| 122 |
define( 'IFE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 123 |
} |
| 124 |
|
| 125 |
// Plugin root file. |
| 126 |
if( ! defined( 'IFE_PLUGIN_FILE' ) ){ |
| 127 |
define( 'IFE_PLUGIN_FILE', __FILE__ ); |
| 128 |
} |
| 129 |
|
| 130 |
// Options |
| 131 |
if( ! defined( 'IFE_OPTIONS' ) ){ |
| 132 |
define( 'IFE_OPTIONS', 'ife_facebook_options' ); |
| 133 |
} |
| 134 |
|
| 135 |
// Pro plugin Buy now Link. |
| 136 |
if( ! defined( 'IFE_PLUGIN_BUY_NOW_URL' ) ){ |
| 137 |
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' ); |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
/** |
| 142 |
* Include required files. |
| 143 |
* |
| 144 |
* @access private |
| 145 |
* @since 1.0.0 |
| 146 |
* @return void |
| 147 |
*/ |
| 148 |
private function includes() { |
| 149 |
|
| 150 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-common.php'; |
| 151 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-list-table.php'; |
| 152 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-admin.php'; |
| 153 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-manage-import.php'; |
| 154 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-cpt.php'; |
| 155 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-facebook.php'; |
| 156 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-ife.php'; |
| 157 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-tec.php'; |
| 158 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-em.php'; |
| 159 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-eventon.php'; |
| 160 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-event_organizer.php'; |
| 161 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-aioec.php'; |
| 162 |
require_once IFE_PLUGIN_DIR . 'includes/class-import-facebook-events-my-calendar.php'; |
| 163 |
|
| 164 |
} |
| 165 |
|
| 166 |
/** |
| 167 |
* Loads the plugin language files. |
| 168 |
* |
| 169 |
* @access public |
| 170 |
* @since 1.0.0 |
| 171 |
* @return void |
| 172 |
*/ |
| 173 |
public function load_textdomain(){ |
| 174 |
|
| 175 |
load_plugin_textdomain( |
| 176 |
'import-facebook-events', |
| 177 |
false, |
| 178 |
IFE_PLUGIN_DIR . '/languages/' |
| 179 |
); |
| 180 |
|
| 181 |
} |
| 182 |
|
| 183 |
/** |
| 184 |
* enqueue style front-end |
| 185 |
* |
| 186 |
* @access public |
| 187 |
* @since 1.0.0 |
| 188 |
* @return void |
| 189 |
*/ |
| 190 |
public function ife_enqueue_style() { |
| 191 |
|
| 192 |
$css_dir = IFE_PLUGIN_URL . 'assets/css/'; |
| 193 |
wp_enqueue_style('import-facebook-events-front', $css_dir . 'import-facebook-events.css', false, "" ); |
| 194 |
} |
| 195 |
|
| 196 |
/** |
| 197 |
* enqueue script front-end |
| 198 |
* |
| 199 |
* @access public |
| 200 |
* @since 1.0.0 |
| 201 |
* @return void |
| 202 |
*/ |
| 203 |
public function ife_enqueue_script() { |
| 204 |
|
| 205 |
// enqueue script here. |
| 206 |
} |
| 207 |
|
| 208 |
} |
| 209 |
|
| 210 |
endif; // End If class exists check. |
| 211 |
|
| 212 |
/** |
| 213 |
* The main function for that returns Import_Facebook_Events |
| 214 |
* |
| 215 |
* The main function responsible for returning the one true Import_Facebook_Events |
| 216 |
* Instance to functions everywhere. |
| 217 |
* |
| 218 |
* Use this function like you would a global variable, except without needing |
| 219 |
* to declare the global. |
| 220 |
* |
| 221 |
* Example: <?php $ife_events = run_import_facebook_events(); ?> |
| 222 |
* |
| 223 |
* @since 1.0.0 |
| 224 |
* @return object|Import_Facebook_Events The one true Import_Facebook_Events Instance. |
| 225 |
*/ |
| 226 |
function run_import_facebook_events() { |
| 227 |
return Import_Facebook_Events::instance(); |
| 228 |
} |
| 229 |
|
| 230 |
/** |
| 231 |
* Get Import events setting options |
| 232 |
* |
| 233 |
* @since 1.0 |
| 234 |
* @return array |
| 235 |
*/ |
| 236 |
function ife_get_import_options( $type = '' ) { |
| 237 |
|
| 238 |
$ife_options = get_option( IFE_OPTIONS ); |
| 239 |
if ( $type != '' && $type == 'facebook' ) { |
| 240 |
return $ife_options; |
| 241 |
//$ife_options = isset( $ife_options[ $type ] ) ? $ife_options[ $type ] : array(); |
| 242 |
} |
| 243 |
return $ife_options; |
| 244 |
} |
| 245 |
|
| 246 |
// Get Import_Facebook_Events Running. |
| 247 |
global $ife_events, $ife_errors, $ife_success_msg, $ife_warnings, $ife_info_msg; |
| 248 |
$ife_events = run_import_facebook_events(); |
| 249 |
$ife_errors = $ife_warnings = $ife_success_msg = $ife_info_msg = array(); |
| 250 |
|
| 251 |
/** |
| 252 |
* The code that runs during plugin activation. |
| 253 |
* |
| 254 |
* @since 1.0 |
| 255 |
*/ |
| 256 |
function ife_activate_import_facebook_events() { |
| 257 |
global $ife_events; |
| 258 |
$ife_events->cpt->register_event_post_type(); |
| 259 |
flush_rewrite_rules(); |
| 260 |
} |
| 261 |
register_activation_hook( __FILE__, 'ife_activate_import_facebook_events' ); |
| 262 |
|