public function display_meta_box($object, $box) { $widgets = $this->_registry->get('controller.javascript-widget')->get_widgets(); // this is just for the Super Widget which doesn't fully implement Ai1ec_Embeddable $widgets = apply_filters('ai1ec_widget_creators_widgets', $widgets); $tabs = array(); foreach ($widgets as $widget_id => $widget_class) { $widget = $this->_registry->get($widget_class); $tabs[$widget_id] = array('name' => $widget->get_name(), 'icon' => $widget->get_icon(), 'requirements' => $widget->check_requirements(), 'elements' => $this->get_html_from_settings($widget->get_configurable_for_widget_creation())); } $loader = $this->_registry->get('theme.loader'); $file = $loader->get_file('widget-creator/super-widget-contents.twig', array('tabs' => $tabs, 'siteurl' => trailingslashit(preg_replace('/^.*?:/', '', ai1ec_get_site_url())), 'text_common_info' => Ai1ec_I18n::__('Use this tool to generate code snippets you can add to <strong>an external website</strong> to embed new calendars and widgets.'), 'text_alert' => Ai1ec_I18n::__('<h4>Attention!</h4><p>These widgets are designed to be embedded in <strong>external sites only</strong> and may cause conflicts if used within the same WordPress site.</p>'), 'text_alternatives' => sprintf(Ai1ec_I18n::__('<p>Use <a href="%s"><strong>Appearance</strong> > <strong>Widgets</strong></a> to add event widgets to your WordPress site as you would any other widget, or use <a href="%s" target="_blank">shortcodes</a> to embed the full calendar.</strong></p>'), admin_url('widgets.php'), 'http://time.ly/document/user-guide/using-calendar/display-multiple-calendars-site/'), 'display_alert' => apply_filters('ai1ec_display_widget_creator_warning', true), 'text_preview' => Ai1ec_I18n::__('Preview:'), 'text_paste' => Ai1ec_I18n::__('Paste this code onto your site:'), 'text_updated_code' => Ai1ec_I18n::__('This code will update to reflect changes made to the settings. Changing settings will not affect previously embedded widgets.')), true); $file->render(); }
/** * Add the link to render the javascript * * @param string $page * @param boolean $backend * * @return void */ public function add_link_to_render_js($page, $backend) { $load_backend_script = 'false'; if (true === $backend) { $load_backend_script = self::TRUE_PARAM; } $is_calendar_page = false; if (true === is_page($this->_settings->get('calendar_page_id'))) { $is_calendar_page = self::TRUE_PARAM; } $url = add_query_arg(array(self::LOAD_JS_PARAMETER => $page, self::IS_BACKEND_PARAMETER => $load_backend_script, self::IS_CALENDAR_PAGE => $is_calendar_page), trailingslashit(ai1ec_get_site_url())); if (true === $backend) { $this->_scripts_helper->enqueue_script(self::JS_HANDLE, $url, array('postbox'), true); } else { $this->_scripts_helper->enqueue_script(self::JS_HANDLE, $url, array(), true); } }
/** * _key method * * Make sure we are on the safe side - in case of multi-instances * environment some prefix is required. * * @param string $key Key to be used against APC cache * * @return string Key with prefix prepended */ protected function _key($key) { static $prefix = null; if (NULL === $prefix) { $prefix = substr(md5(ai1ec_get_site_url()), 0, 8); } if (0 !== strncmp($key, $prefix, 8)) { $key = $prefix . $key; } return $key; }
/** * Add the link to render the javascript * * @param string $page * @param boolean $backend * * @return void */ public function add_link_to_render_js($page, $backend) { $load_backend_script = 'false'; if (true === $backend) { $load_backend_script = self::TRUE_PARAM; } $is_calendar_page = false; if (true === is_page($this->_settings->get('calendar_page_id')) || self::CALENDAR_PAGE_JS === $page) { $is_calendar_page = self::TRUE_PARAM; } $url = add_query_arg(array(self::LOAD_JS_PARAMETER => $page, self::IS_BACKEND_PARAMETER => $load_backend_script, self::IS_CALENDAR_PAGE => $is_calendar_page), trailingslashit(ai1ec_get_site_url())); if ($this->_settings->get('cache_dynamic_js') && $is_calendar_page && '1' === $this->_registry->get('model.option')->get('calendarjsupdated') && $this->_registry->get('filesystem.checker')->check_file_exists(AI1EC_PATH . self::CALENDAR_JS_CACHE_FILE, true)) { $url = plugin_dir_url('all-in-one-event-calendar/public/js_cache/.') . $page; } if (true === $backend) { $this->_scripts_helper->enqueue_script(self::JS_HANDLE, $url, array('postbox'), true); } else { $this->_scripts_helper->enqueue_script(self::JS_HANDLE, $url, array(), false); } }
/** * Redirect the user either to the front page or the dashbord page * * @return void Method does not return */ protected function redirect($suggested_url = null) { $url = ai1ec_get_site_url(); if (is_admin()) { $url = null !== $suggested_url ? $suggested_url : ai1ec_get_admin_url(); } Ai1ec_Http_Response_Helper::redirect($url); }
/** * Update the less variables on the DB and recompile the CSS * * @param array $variables * @param boolean $resetting are we resetting or updating variables? */ public function update_variables_and_compile_css(array $variables, $resetting) { $no_parse_errors = $this->invalidate_cache($variables, true); $notification = $this->_registry->get('notification.admin'); if ($no_parse_errors) { $this->db_adapter->set(Ai1ec_Less_Lessphp::DB_KEY_FOR_LESS_VARIABLES, $variables); if (true === $resetting) { $message = sprintf('<p>' . Ai1ec_I18n::__("Theme options were successfully reset to their default values. <a href='%s'>Visit site</a>") . '</p>', ai1ec_get_site_url()); } else { $message = sprintf('<p>' . Ai1ec_I18n::__("Theme options were updated successfully. <a href='%s'>Visit site</a>") . '</p>', ai1ec_get_site_url()); } $notification->store($message); } }
/** * Get UID to be used for current event. * * The generated format is cached in static variable within this function * to re-use when generating UIDs for different entries. * * @return string Generated UID. * * @staticvar string $format Cached format. */ public function get_uid() { $ical_uid = $this->get('ical_uid'); if (!empty($ical_uid)) { return $ical_uid; } static $format = null; if (null === $format) { $site_url = parse_url(ai1ec_get_site_url()); $format = 'ai1ec-%d@' . $site_url['host']; if (isset($site_url['path'])) { $format .= $site_url['path']; } } return sprintf($format, $this->get('post_id')); }
public function get_uid_pattern() { static $format = null; if (null === $format) { $site_url = parse_url(ai1ec_get_site_url()); $format = 'ai1ec-%d@' . $site_url['host']; if (isset($site_url['path'])) { $format .= $site_url['path']; } } return $format; }