function wpci_activate() { WPCI::log('info', 'wpci_activate()'); if (!($slug = get_option('wpci_gateway_slug', false))) { do { $slug = md5(uniqid()); if (!get_page_by_path($slug)) { $page = wpci_create_gateway($slug); } } while (!$page); update_option('wpci_gateway_slug', $slug); } else { if (!get_page_by_path($slug)) { wpci_create_gateway($slug); } } }
function fixGateway() { global $wpdb; $query = null; $posts = $wpdb->prefix . 'posts'; $db = DB(); if ($slug = get_option('wpci_gateway_slug')) { $query = $db->query("SELECT * FROM {$posts} WHERE post_name = ?", array($slug)); if ($query->num_rows() > 0) { // obviously, the gateway page was deleted - reinstate $db->query("UPDATE {$posts} SET post_status='publish' WHERE post_name = ? LIMIT 1", array($slug)); redirect('/wp-admin'); return true; } else { // otherwise, create it! wpci_create_gateway($slug); } } else { wp_die("Can't fix gateway issue. Please click Back, then deactivate and reactivate your WP-CI or WP-CMSPLUS plugin."); } redirect('/wp-admin'); return true; }
static function activate_plugin() { if (!($slug = get_option('wpci_gateway_slug', false))) { do { $slug = md5(uniqid()); if (!get_page_by_path($slug)) { $page = wpci_create_gateway($slug); } } while (!$page); update_option('wpci_gateway_slug', $slug); } else { if (!get_page_by_path($slug)) { wpci_create_gateway($slug); } } }