/** * verify_default_pages_exist * * @access public * @static * @return void */ public static function verify_default_pages_exist() { $critical_page_problem = FALSE; $critical_pages = array(array('id' => 'reg_page_id', 'name' => __('Registration Checkout', 'event_espresso'), 'post' => NULL, 'code' => 'ESPRESSO_CHECKOUT'), array('id' => 'txn_page_id', 'name' => __('Transactions', 'event_espresso'), 'post' => NULL, 'code' => 'ESPRESSO_TXN_PAGE'), array('id' => 'thank_you_page_id', 'name' => __('Thank You', 'event_espresso'), 'post' => NULL, 'code' => 'ESPRESSO_THANK_YOU'), array('id' => 'cancel_page_id', 'name' => __('Registration Cancelled', 'event_espresso'), 'post' => NULL, 'code' => 'ESPRESSO_CANCELLED')); foreach ($critical_pages as $critical_page) { // is critical page ID set in config ? if (EE_Registry::instance()->CFG->core->{$critical_page}['id'] !== FALSE) { // attempt to find post by ID $critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->{$critical_page}['id']); } // no dice? if ($critical_page['post'] == NULL) { // attempt to find post by title $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); // still nothing? if ($critical_page['post'] == NULL) { $critical_page = EEH_Activation::create_critical_page($critical_page); // REALLY? Still nothing ??!?!? if ($critical_page['post'] == NULL) { $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); break; } } } // track post_shortcodes if ($critical_page['post']) { EEH_Activation::_track_critical_page_post_shortcodes($critical_page); } // check that Post ID matches critical page ID in config if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->{$critical_page}['id']) { //update Config with post ID EE_Registry::instance()->CFG->core->{$critical_page}['id'] = $critical_page['post']->ID; if (!EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); } } $critical_page_problem = !isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem; } if ($critical_page_problem) { $msg = sprintf(__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>'); EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); } if (EE_Error::has_notices()) { EE_Error::get_notices(FALSE, TRUE, TRUE); } }