public function load($action = '') { if ('setup' == $action) { if ('POST' == $_SERVER['REQUEST_METHOD']) { check_admin_referer('wpcf7-recaptcha-setup'); $sitekey = isset($_POST['sitekey']) ? trim($_POST['sitekey']) : ''; $secret = isset($_POST['secret']) ? trim($_POST['secret']) : ''; if ($sitekey && $secret) { WPCF7::update_option('recaptcha', array($sitekey => $secret)); $redirect_to = $this->menu_page_url(array('message' => 'success')); } elseif ('' === $sitekey && '' === $secret) { WPCF7::update_option('recaptcha', null); $redirect_to = $this->menu_page_url(array('message' => 'success')); } else { $redirect_to = $this->menu_page_url(array('action' => 'setup', 'message' => 'invalid')); } wp_safe_redirect($redirect_to); exit; } } }
function wpcf7_notice_bulk_validate_config() { if (!wpcf7_validate_configuration() || !current_user_can('wpcf7_edit_contact_forms')) { return; } if (isset($_GET['page']) && 'wpcf7' == $_GET['page'] && isset($_GET['action']) && 'validate' == $_GET['action']) { return; } if (WPCF7::get_option('bulk_validate')) { // already done. return; } $link = add_query_arg(array('action' => 'validate'), menu_page_url('wpcf7', false)); $link = sprintf('<a href="%s">%s</a>', $link, esc_html(__('Validate Contact Form 7 Configuration', 'contact-form-7'))); $message = __("Misconfiguration leads to mail delivery failure or other troubles. Validate your contact forms now.", 'contact-form-7'); echo sprintf('<div class="notice notice-warning"><p>%s » %s</p></div>', esc_html($message), $link); }
function wpcf7_upgrade() { $old_ver = WPCF7::get_option('version', '0'); $new_ver = WPCF7_VERSION; if ($old_ver == $new_ver) { return; } do_action('wpcf7_upgrade', $new_ver, $old_ver); WPCF7::update_option('version', $new_ver); }
function wpcf7_install() { if ($opt = get_option('wpcf7')) { return; } wpcf7_load_textdomain(); wpcf7_register_post_types(); wpcf7_upgrade(); if (get_posts(array('post_type' => 'wpcf7_contact_form'))) { return; } $contact_form = WPCF7_ContactForm::get_template(array('title' => sprintf(__('Contact form %d', 'contact-form-7'), 1))); $contact_form->save(); WPCF7::update_option('bulk_validate', array('timestamp' => current_time('timestamp'), 'version' => WPCF7_VERSION, 'count_valid' => 1, 'count_invalid' => 0)); }