コード例 #1
0
 /**
  *  Check if a cookie is set for the current page
  * 
  * @return Ai1ec_Cookie_Present_Dto
  */
 public static function is_cookie_set_for_current_page()
 {
     $cookie_dto = Ai1ec_Dto_Factory::create_cookie_present_dto_instance();
     $ai1ec_settings = Ai1ec_Settings::get_instance();
     $calendar_url = get_page_link($ai1ec_settings->calendar_page_id);
     $requested_page_url = Ai1ec_Wp_Uri_Helper::get_current_url(true);
     $cookie_set = isset($_COOKIE['ai1ec_saved_filter']);
     if (false !== $cookie_set) {
         $cookie = json_decode(stripslashes($_COOKIE['ai1ec_saved_filter']), true);
         if ($calendar_url === $requested_page_url && isset($cookie['calendar_page']) && $cookie['calendar_page'] !== $calendar_url) {
             $cookie_dto->set_calendar_cookie($cookie['calendar_page']);
             $cookie_dto->set_is_cookie_set_for_calendar_page(true);
             $cookie_dto->set_is_a_cookie_set_for_this_page(true);
         } else {
             if (isset($cookie[$requested_page_url])) {
                 $cookie_dto->set_shortcode_cookie($cookie[$requested_page_url]);
                 $cookie_dto->set_is_cookie_set_for_shortcode(true);
                 $cookie_dto->set_is_a_cookie_set_for_this_page(true);
             } else {
                 if (strpos($requested_page_url, $calendar_url) === 0 && isset($cookie['calendar_page']) && is_page($ai1ec_settings->calendar_page_id)) {
                     // This is the case after a redirect from the calendar page
                     $cookie_dto->set_is_a_cookie_set_for_this_page(true);
                     $cookie_dto->set_calendar_cookie($cookie['calendar_page']);
                 }
             }
         }
     }
     return $cookie_dto;
 }
コード例 #2
0
ファイル: utility.php プロジェクト: sedici/wpmu-istec
 /**
  *  Check if a cookie is set for the current page
  *
  * @return Ai1ec_Cookie_Present_Dto
  */
 public function is_cookie_set_for_current_page()
 {
     $cookie_dto = $this->_registry->get('cookie.dto');
     $settings = $this->_registry->get('model.settings');
     $calendar_url = get_page_link($settings->get('calendar_page_id'));
     $requested_page_url = Ai1ec_Wp_Uri_Helper::get_current_url(true);
     $cookie_set = isset($_COOKIE['ai1ec_saved_filter']);
     if (false !== $cookie_set) {
         $cookie = json_decode(stripslashes($_COOKIE['ai1ec_saved_filter']), true);
         if ($calendar_url === $requested_page_url && isset($cookie['calendar_page']) && $cookie['calendar_page'] !== $calendar_url) {
             $cookie_dto->set_calendar_cookie($cookie['calendar_page']);
             $cookie_dto->set_is_cookie_set_for_calendar_page(true);
             $cookie_dto->set_is_a_cookie_set_for_this_page(true);
         } else {
             if (isset($cookie[$requested_page_url])) {
                 $cookie_dto->set_shortcode_cookie($cookie[$requested_page_url]);
                 $cookie_dto->set_is_cookie_set_for_shortcode(true);
                 $cookie_dto->set_is_a_cookie_set_for_this_page(true);
             } else {
                 if (strpos($requested_page_url, $calendar_url) === 0 && isset($cookie['calendar_page']) && is_page($settings->get('calendar_page_id'))) {
                     // This is the case after a redirect from the calendar page
                     $cookie_dto->set_is_a_cookie_set_for_this_page(true);
                     $cookie_dto->set_calendar_cookie($cookie['calendar_page']);
                 }
             }
         }
     }
     return $cookie_dto;
 }
コード例 #3
0
ファイル: redirect.php プロジェクト: sedici/wpmu-istec
 public function render(array $params)
 {
     Ai1ec_Wp_Uri_Helper::local_redirect($params['url'], $params['query_args']);
 }
コード例 #4
0
ファイル: front.php プロジェクト: sedici/wpmu-istec
 /**
  * Initializes the URL router used by our plugin.
  *
  * @wp_hook init
  *
  * @return void
  */
 public function initialize_router()
 {
     /* @var $cal_state Ai1ec_Calendar_State */
     $cal_state = $this->_registry->get('calendar.state');
     $cal_state->set_routing_initialization(true);
     $settings = $this->_registry->get('model.settings');
     $cal_page = $settings->get('calendar_page_id');
     if (!$cal_page || $cal_page < 1) {
         // Routing may not be affected in any way if no calendar page exists.
         $cal_state->set_routing_initialization(false);
         return null;
     }
     $router = $this->_registry->get('routing.router');
     $localization_helper = $this->_registry->get('p28n.wpml');
     $page_base = '';
     $clang = '';
     if ($localization_helper->is_wpml_active()) {
         $trans = $localization_helper->get_wpml_translations_of_page($cal_page, true);
         $clang = $localization_helper->get_language();
         if (isset($trans[$clang])) {
             $cal_page = $trans[$clang];
         }
     }
     $template_link_helper = $this->_registry->get('template.link.helper');
     if (!get_post($cal_page)) {
         $cal_state->set_routing_initialization(false);
         return null;
     }
     $page_base = $template_link_helper->get_page_link($cal_page);
     $page_base = Ai1ec_Wp_Uri_Helper::get_pagebase($page_base);
     $page_link = 'index.php?page_id=' . $cal_page;
     $pagebase_for_href = Ai1ec_Wp_Uri_Helper::get_pagebase_for_links(get_page_link($cal_page), $clang);
     // save the pagebase to set up the factory later
     $application = $this->_registry->get('bootstrap.registry.application');
     $application->set('calendar_base_page', $pagebase_for_href);
     $option = $this->_registry->get('model.option');
     // If the calendar is set as the front page, disable permalinks.
     // They would not be legal under a Windows server. See:
     // https://issues.apache.org/bugzilla/show_bug.cgi?id=41441
     if ($option->get('permalink_structure') && (int) get_option('page_on_front') !== (int) $cal_page) {
         $application->set('permalinks_enabled', true);
     }
     $router->asset_base($page_base)->register_rewrite($page_link);
     $cal_state->set_routing_initialization(false);
 }
コード例 #5
0
 /**
  * Initializes the URL router used by our plugin.
  *
  * @return void Method is not intended to return anything
  */
 public function initialize_router()
 {
     global $ai1ec_settings, $ai1ec_router, $ai1ec_localization_helper;
     if (!isset($ai1ec_settings->calendar_page_id) || $ai1ec_settings->calendar_page_id < 1) {
         // Routing may not be affected in any way if no calendar page exists.
         return NULL;
     }
     $ai1ec_router = Ai1ec_Router::instance();
     $page_base = '';
     $clang = '';
     if ($ai1ec_localization_helper->is_wpml_active()) {
         $trans = $ai1ec_localization_helper->get_wpml_translations_of_page($ai1ec_settings->calendar_page_id, true);
         $clang = $ai1ec_localization_helper->get_language();
         if (isset($trans[$clang])) {
             $ai1ec_settings->calendar_page_id = $trans[$clang];
         }
     }
     $page_base = get_page_link($ai1ec_settings->calendar_page_id);
     $page_base = Ai1ec_Wp_Uri_Helper::get_pagebase($page_base);
     $page_link = 'index.php?page_id=' . $ai1ec_settings->calendar_page_id;
     $pagebase_for_href = Ai1ec_Wp_Uri_Helper::get_pagebase_for_links(get_page_link($ai1ec_settings->calendar_page_id), $clang);
     // Add a trailing slash if it is missing and we are using permalinks.
     if (Ai1ec_Meta::get_option('permalink_structure')) {
         $pagebase_for_href = trailingslashit($pagebase_for_href);
     }
     // Set up the view factory.
     Ai1ec_View_Factory::set_page($pagebase_for_href);
     // If the calendar is set as the front page, disable permalinks.
     // They would not be legal under a Windows server. See:
     // https://issues.apache.org/bugzilla/show_bug.cgi?id=41441
     if (Ai1ec_Meta::get_option('permalink_structure') && (int) get_option('page_on_front') !== (int) $ai1ec_settings->calendar_page_id) {
         Ai1ec_View_Factory::set_pretty_permalinks_enabled(true);
     }
     // If we are requesting the calendar page and we have a saved cookie,
     // redirect the user. Do not redirect if the user saved the home page,
     // otherwise we enter a loop.
     $cookie_dto = $ai1ec_router->get_cookie_set_dto();
     if (true === $cookie_dto->get_is_cookie_set_for_calendar_page()) {
         $cookie = $cookie_dto->get_calendar_cookie();
         $href = Ai1ec_View_Factory::create_href_helper_instance($cookie);
         // wp_redirect sanitizes the url which strips out the |
         header('Location: ' . $href->generate_href(), true, '302');
         exit(0);
     }
     // We need to reset the cookie, it's to early for the is_page() call
     $ai1ec_router->set_cookie_set_dto();
     // Initialize SEO helper.
     Ai1ec_Seo_Helper::get_instance();
     $ai1ec_router = Ai1ec_Router::instance()->asset_base($page_base)->register_rewrite($page_link);
 }
コード例 #6
0
 private function get_sendback_page($post_id)
 {
     $sendback = wp_get_referer();
     $page_base = Ai1ec_Wp_Uri_Helper::get_pagebase($sendback);
     //$_SERVER['REQUEST_URI'] );
     if ('post.php' === $page_base) {
         return get_edit_post_link($post_id, 'url');
     } else {
         return admin_url('edit.php?post_type=ai1ec_event');
     }
 }
コード例 #7
0
 /**
  * Save the submitted settings form.
  *
  * @param string $settings_page Which settings page is being saved.
  * @return void
  */
 function save($settings_page)
 {
     global $ai1ec_settings, $ai1ec_importer_plugin_helper;
     $ai1ec_settings->update($settings_page, $_REQUEST);
     do_action('ai1ec_save_settings', $settings_page, $_REQUEST);
     $ai1ec_settings->save();
     do_action('ai1ec-post-save-facebook-login');
     $referer = wp_get_referer();
     if (!$referer) {
         $referer = AI1EC_SETTINGS_BASE_URL;
     }
     $query_args = array('updated' => 1);
     $error_messages = $ai1ec_importer_plugin_helper->are_there_any_errors_to_show_on_calendar_settings_page();
     if (!empty($error_messages)) {
         $query_args['errors'] = $error_messages;
     }
     return Ai1ec_Wp_Uri_Helper::local_redirect($referer, $query_args);
 }
function ai1ec_initialize_router()
{
    global $ai1ec_settings, $ai1ec_router, $ai1ec_localization_helper;
    $page_base = '';
    $clang = '';
    if ($ai1ec_settings->calendar_page_id > 0) {
        if ($ai1ec_localization_helper->is_wpml_active()) {
            $trans = $ai1ec_localization_helper->get_wpml_translations_of_page($ai1ec_settings->calendar_page_id, true);
            $clang = $ai1ec_localization_helper->get_language();
            if (isset($trans[$clang])) {
                $ai1ec_settings->calendar_page_id = $trans[$clang];
            }
        }
        $page_base = get_page_link($ai1ec_settings->calendar_page_id);
    }
    $page_base = Ai1ec_Wp_Uri_Helper::get_pagebase($page_base);
    $page_link = 'index.php?page_id=' . $ai1ec_settings->calendar_page_id;
    $pagebase_for_href = Ai1ec_Wp_Uri_Helper::get_pagebase_for_links(get_page_link($ai1ec_settings->calendar_page_id), $clang);
    // add a trailing slash if it's missing and we are using permalinks
    if (get_option('permalink_structure')) {
        $pagebase_for_href = trailingslashit($pagebase_for_href);
    }
    // Set up the view factory
    Ai1ec_View_Factory::set_page($pagebase_for_href);
    // if the calendar is set as the front page, disable permalinks.
    // They would not be legal under windows
    // https://issues.apache.org/bugzilla/show_bug.cgi?id=41441
    if (get_option('permalink_structure') && (int) get_option('page_on_front') !== (int) $ai1ec_settings->calendar_page_id) {
        Ai1ec_View_Factory::set_pretty_permalinks_enabled(true);
    }
    $ai1ec_router = Ai1ec_Router::instance()->asset_base($page_base)->register_rewrite($page_link);
}