PageRenderTime 42ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/all-in-one-event-calendar/all-in-one-event-calendar.php

https://gitlab.com/Blueprint-Marketing/interoccupy.net
PHP | 260 lines | 158 code | 23 blank | 79 comment | 16 complexity | b0a59f96a8eb83834c290b5f234c7886 MD5 | raw file
  1. <?php
  2. /**
  3. * Plugin Name: All-in-One Event Calendar by Timely
  4. * Plugin URI: http://time.ly/
  5. * Description: A calendar system with posterboard, stream, month, week, day, agenda views, upcoming events widget, color-coded categories, recurrence, and import/export of .ics feeds.
  6. * Author: Timely Network Inc
  7. * Author URI: http://time.ly/
  8. * Version: 1.9-pro
  9. */
  10. @set_time_limit( 0 );
  11. @ini_set( 'memory_limit', '256M' );
  12. @ini_set( 'max_input_time', '-1' );
  13. // Disable fopen (streams) transport if no cUrl is present to allow CRON
  14. if( ! function_exists( 'curl_init' ) ) {
  15. add_filter( 'use_streams_transport', '__return_false' );
  16. }
  17. // Define AI1EC_EVENT_PLATFORM as TRUE to turn WordPress into an events-only
  18. // platform. For a multi-site install, setting this to TRUE is equivalent to a
  19. // super-administrator selecting the
  20. // "Turn this blog into an events-only platform" checkbox
  21. // on the Calendar Settings page of every blog on the network.
  22. // This mode, when enabled on blogs where this plugin is active, hides all
  23. // administrative functions unrelated to events and the calendar (except to
  24. // super-administrators), and sets default WordPress settings appropriate for
  25. // pure event management.
  26. if( isset( $_GET['ai1ec_doing_ajax'] ) ) {
  27. // Stop the cron ( or at least try )
  28. if( ! defined( 'DOING_AJAX' ) ) {
  29. define( 'DOING_AJAX', true );
  30. }
  31. }
  32. /**
  33. * Include configuration files and define constants
  34. */
  35. $ai1ec_base_path = dirname( __FILE__ );
  36. foreach ( array( 'constants-local.php', 'constants.php' ) as $file ) {
  37. if ( file_exists( $ai1ec_base_path . DIRECTORY_SEPARATOR . $file ) ) {
  38. include_once $ai1ec_base_path . DIRECTORY_SEPARATOR . $file;
  39. }
  40. }
  41. if ( ! function_exists( 'ai1ec_initiate_constants' ) ) {
  42. return trigger_error(
  43. 'File \'constants.php\' defining \'ai1ec_initiate_constants\' function must be present.',
  44. E_USER_WARNING
  45. );
  46. }
  47. ai1ec_initiate_constants();
  48. require_once AI1EC_LIB_PATH . DIRECTORY_SEPARATOR . 'global-functions.php';
  49. require_once AI1EC_LIB_PATH . DIRECTORY_SEPARATOR . 'class-ai1ec-loader.php' ;
  50. spl_autoload_register( array( 'Ai1ec_Loader', 'autoload' ) );
  51. global $ai1ec_themes_controller;
  52. $ai1ec_themes_controller = Ai1ec_Themes_Controller::get_instance();
  53. // get the active theme from the the theme controllor
  54. $active_theme = $ai1ec_themes_controller->active_template_path();
  55. // Are we in preview_mode?
  56. $preview_mode = false;
  57. // If we are previewing the theme, use the theme passed in the url
  58. if( isset( $_GET['preview'] ) && isset( $_GET['ai1ec_stylesheet'] ) ) {
  59. Ai1ec_Less_Factory::set_preview_mode( true );
  60. $active_theme = $_GET['ai1ec_stylesheet'];
  61. $preview_mode = true;
  62. }
  63. // Start_up the factories
  64. Ai1ec_Less_Factory::set_active_theme_path( AI1EC_THEMES_ROOT . DIRECTORY_SEPARATOR . $active_theme );
  65. Ai1ec_Less_Factory::set_default_theme_path( AI1EC_DEFAULT_THEME_PATH );
  66. Ai1ec_Less_Factory::set_default_theme_url( AI1EC_DEFAULT_THEME_URL );
  67. // ==================================
  68. // = Add the hook to render the css =
  69. // ==================================
  70. if( isset( $_GET[Ai1ec_Css_Controller::GET_VARIBALE_NAME] ) ) {
  71. $css_controller = Ai1ec_Less_Factory::create_css_controller_instance();
  72. $css_controller->render_css();
  73. exit;
  74. }
  75. // ================================================
  76. // = Disable updates checking for premium version =
  77. // ================================================
  78. function ai1ec_disable_updates( $r, $url ) {
  79. if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) )
  80. return $r; // Not a plugin update request.
  81. $plugins = unserialize( $r['body']['plugins'] );
  82. unset( $plugins->plugins[ plugin_basename( __FILE__ ) ] );
  83. unset( $plugins->active[ array_search( plugin_basename( __FILE__ ), $plugins->active ) ] );
  84. $r['body']['plugins'] = serialize( $plugins );
  85. return $r;
  86. }
  87. add_filter( 'http_request_args', 'ai1ec_disable_updates', 5, 2 );
  88. // ===============================
  89. // = Initialize and setup MODELS =
  90. // ===============================
  91. global $ai1ec_settings;
  92. $ai1ec_settings = Ai1ec_Settings::get_instance();
  93. // This is a fix for AIOEC-73. I need to set those values as soon as possible so that
  94. // the platofrom controller has the fresh data and can act accordingly
  95. // I do not trigger the save action at this point because there are too many things going on
  96. // there and i might break things
  97. if( isset( $_POST['ai1ec_save_settings'] ) ) {
  98. $ai1ec_settings->event_platform = isset( $_POST['event_platform'] );
  99. $ai1ec_settings->event_platform_strict = isset( $_POST['event_platform_strict'] );
  100. }
  101. // Set up the Routing Factory
  102. Ai1ec_Routing_Factory::set_ai1ec_settings( $ai1ec_settings );
  103. // ========================================================
  104. // = Delay router initialization until permalinks are set =
  105. // ========================================================
  106. global $ai1ec_router;
  107. function ai1ec_initialize_router() {
  108. global $ai1ec_settings, $ai1ec_router, $ai1ec_localization_helper;
  109. $page_base = '';
  110. $clang = '';
  111. if ( $ai1ec_settings->calendar_page_id > 0 ) {
  112. if ( $ai1ec_localization_helper->is_wpml_active() ) {
  113. $trans = $ai1ec_localization_helper->get_wpml_translations_of_page(
  114. $ai1ec_settings->calendar_page_id,
  115. true
  116. );
  117. $clang = $ai1ec_localization_helper->get_language();
  118. if ( isset( $trans[$clang] ) ) {
  119. $ai1ec_settings->calendar_page_id = $trans[$clang];
  120. }
  121. }
  122. $page_base = get_page_link( $ai1ec_settings->calendar_page_id );
  123. }
  124. $page_base = Ai1ec_Wp_Uri_Helper::get_pagebase( $page_base );
  125. $page_link = 'index.php?pagename=' . $page_base;
  126. $pagebase_for_href = Ai1ec_Wp_Uri_Helper::get_pagebase_for_links(
  127. get_page_link( $ai1ec_settings->calendar_page_id ),
  128. $clang
  129. );
  130. // Set up the view factory
  131. Ai1ec_View_Factory::set_page( $pagebase_for_href );
  132. // if the calendar is set as the front page, disable permalinks.
  133. // They would not be legal under windows
  134. // https://issues.apache.org/bugzilla/show_bug.cgi?id=41441
  135. if ( get_option( 'permalink_structure' ) &&
  136. (int) get_option( 'page_on_front' ) !== (int) $ai1ec_settings->calendar_page_id ) {
  137. Ai1ec_View_Factory::set_pretty_permalinks_enabled( true );
  138. }
  139. $ai1ec_router = Ai1ec_Router::instance()
  140. ->asset_base( $page_base )
  141. ->register_rewrite( $page_link );
  142. }
  143. add_filter( 'init', 'ai1ec_initialize_router', 11 );
  144. // ================================
  145. // = Initialize and setup HELPERS =
  146. // ================================
  147. global $ai1ec_view_helper,
  148. $ai1ec_settings_helper,
  149. $ai1ec_calendar_helper,
  150. $ai1ec_app_helper,
  151. $ai1ec_events_helper,
  152. $ai1ec_importer_helper,
  153. $ai1ec_exporter_helper,
  154. $ai1ec_platform_helper,
  155. $ai1ec_localization_helper,
  156. $ai1ec_importer_plugin_helper;
  157. $ai1ec_view_helper = Ai1ec_View_Helper::get_instance();
  158. $ai1ec_settings_helper = Ai1ec_Settings_Helper::get_instance();
  159. $ai1ec_calendar_helper = Ai1ec_Calendar_Helper::get_instance();
  160. $ai1ec_app_helper = Ai1ec_App_Helper::get_instance();
  161. $ai1ec_events_helper = Ai1ec_Events_Helper::get_instance();
  162. $ai1ec_importer_helper = Ai1ec_Importer_Helper::get_instance();
  163. $ai1ec_exporter_helper = Ai1ec_Exporter_Helper::get_instance();
  164. $ai1ec_platform_helper = Ai1ec_Platform_Helper::get_instance();
  165. $ai1ec_localization_helper = Ai1ec_Localization_Helper::get_instance();
  166. $ai1ec_importer_plugin_helper = Ai1ec_Importer_Plugin_Helper::get_instance();
  167. if (
  168. 'admin-ajax.php' === basename( $_SERVER['SCRIPT_NAME'] ) &&
  169. isset( $_REQUEST['lang'] )
  170. ) {
  171. $ai1ec_localization_helper->set_language( $_REQUEST['lang'] );
  172. }
  173. // ====================================
  174. // = Initialize and setup CONTROLLERS =
  175. // ====================================
  176. global $ai1ec_app_controller,
  177. $ai1ec_settings_controller,
  178. $ai1ec_events_controller,
  179. $ai1ec_calendar_controller,
  180. $ai1ec_importer_controller,
  181. $ai1ec_exporter_controller,
  182. $ai1ec_platform_controller,
  183. $ai1ec_duplicate_controller;
  184. $ai1ec_settings_controller = Ai1ec_Settings_Controller::get_instance();
  185. $ai1ec_events_controller = Ai1ec_Events_Controller::get_instance();
  186. $ai1ec_calendar_controller = Ai1ec_Calendar_Controller::get_instance();
  187. $ai1ec_importer_controller = Ai1ec_Importer_Controller::get_instance();
  188. $ai1ec_exporter_controller = Ai1ec_Exporter_Controller::get_instance();
  189. $ai1ec_platform_controller = Ai1ec_Platform_Controller::get_instance();
  190. $ai1ec_duplicate_controller = Ai1ec_Duplicate_Controller::get_instance();
  191. // Initialize other global classes
  192. global $ai1ec_requirejs_controller,
  193. $ai1ec_rss_feed,
  194. $ai1ec_tax_meta_class;
  195. // Create the instance of the class that handles javascript loading
  196. $ai1ec_requirejs_controller = new Ai1ec_Requirejs_Controller();
  197. // Inject settings
  198. $ai1ec_requirejs_controller->set_settings( $ai1ec_settings );
  199. // Inject calendar controller
  200. $ai1ec_requirejs_controller->set_events_helper( $ai1ec_events_helper );
  201. // Se the themes controller
  202. $ai1ec_requirejs_controller->set_ai1ec_themes_controller( $ai1ec_themes_controller );
  203. // ==================================
  204. // = Add the hook to render the js =
  205. // ==================================
  206. if( isset( $_GET[Ai1ec_Requirejs_Controller::WEB_WIDGET_GET_PARAMETER] ) ) {
  207. add_action( 'template_redirect' , array( $ai1ec_requirejs_controller, 'render_web_widget' ), 20 );
  208. }
  209. /**
  210. * Configure your meta box
  211. */
  212. $config = array(
  213. // meta box id, unique per meta box
  214. 'id' => 'demo_meta_box',
  215. // meta box title
  216. 'title' => 'Demo Meta Box',
  217. // taxonomy name, accept categories, post_tag and custom taxonomies
  218. 'pages' => array( 'events_categories' ),
  219. // where the meta box appear: normal (default), advanced, side; optional
  220. 'context' => 'normal',
  221. // list of meta fields (can be added by field arrays)
  222. 'fields' => array(),
  223. // Use local or hosted images (meta box images for add/remove)
  224. // 'local_images' => false,
  225. // change path if used with theme set to true, false for a plugin or anything
  226. // else for a custom path(default false).
  227. 'use_with_theme' => false
  228. );
  229. /*
  230. * Initiate your meta box
  231. */
  232. $ai1ec_tax_meta_class = new Ai1ec_Tax_Meta_Class( $config );
  233. $ai1ec_rss_feed = new Ai1ec_Rss_Feed_Controller();
  234. // ==========================================================================
  235. // = All app initialization is done in Ai1ec_App_Controller::__construct(). =
  236. // ==========================================================================
  237. $ai1ec_app_controller = Ai1ec_App_Controller::get_instance( $preview_mode );