/** * Add Google Webmaster verification code to head if needed. * * @since 0.0.2 */ function vp_verify_google_webmaster() { $verify = vp_get_theme_option('google-webmaster-verify'); if (empty($verify)) { return; } echo $verify; }
/** * Load the sections from theme options. * * @since 0.0.1 * @for vp_node_navi() */ function vp_load_sections() { $sections = vp_get_theme_option('sections'); if (!$sections) { $sections = array(); } else { $sections = split(',', $sections); $sections = array_map('trim', $sections); // trim spaces $sections = array_filter($sections); // remove empty element } return $sections; }
/** * Display the feed url in head. * * You can setting feed url with feedburner or else, otherwise the WordPress default one will used. * * @since 0.0.2 */ function vp_feed_link() { $feed = vp_get_theme_option('feed_url'); if (!$feed) { $feed = get_feed_link(); } echo '<link rel="alternate" type="application/rss+xml" title="' . get_bloginfo('name') . ' Latest Topic Feed" href="' . $feed . '" />'; }
/** * Load the sections from theme options. * * @since 0.0.1 * @for vp_node_navi() */ function vp_load_sections() { $sections = vp_get_theme_option('sections'); if (!$sections) { $sections = array(); } else { $sections = split(',', $sections); $sections = array_map('trim', $sections); } return $sections; }
/** * Do signup a user. * * @since 0.0.1 */ function vp_do_signup() { if (!isset($_POST['action']) || 'vp_signup' != $_POST['action']) { return; } if (isset($_POST['vp_user_login']) && wp_verify_nonce($_POST['vp_signup_nonce'], 'vp-signup-nonce')) { $user_login = $_POST['vp_user_login']; $user_email = $_POST['vp_user_email']; $user_pwd = $_POST['vp_user_password']; $pwd_confirm = $_POST['vp_user_password_confirmation']; // Username already taken if (username_exists($user_login)) { vp_errors()->add('username_unavailable', __('Username already taken', 'v2press')); } // Username invalid if (!validate_username($user_login)) { vp_errors()->add('username_invalid', __('Invalid username', 'v2press')); } // Empty username if (empty($user_login)) { vp_errors()->add('username_empty', __('Please enter a username', 'v2press')); } // Username out range (4-12) if (!empty($user_login) && (4 > strlen($user_login) || 12 < strlen($user_login))) { vp_errors()->add('username_out_range', __('Username length must within 4-12 characters', 'v2press')); } // Empty email if (empty($user_email)) { vp_errors()->add('email_empty', __('Please enter your Email', 'v2press')); } // Invalid email if (!empty($user_email) && !is_email($user_email)) { vp_errors()->add('email_invalid', __('Invalid email', 'v2press')); } // Email address already registered if (!empty($user_email) && email_exists($user_email)) { vp_errors()->add('email_used', __('This Email already registered', 'v2press')); } // Empty password if (empty($user_pwd)) { vp_errors()->add('password_empty', __('Please enter a password', 'v2press')); } // Password not match if ($user_pwd != $pwd_confirm) { vp_errors()->add('password_mismatch', __('Passwords do not match', 'v2press')); } // reCAPTCHA error if (vp_is_recaptcha_enabled()) { require_once VP_LIBS_PATH . '/recaptchalib.php'; $privatekey = vp_get_theme_option('recaptcha_privatekey'); $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { vp_errors()->add('recaptcha-error', __('reCAPATCH is not right.', 'v2press')); } } $errors = vp_errors()->get_error_messages(); // only create the user if there are no errors if (empty($errors)) { $new_user_id = wp_insert_user(array('user_login' => $user_login, 'user_pass' => $user_pwd, 'user_email' => $user_email, 'user_registered' => date('Y-m-d H:i:s'), 'role' => 'author')); if ($new_user_id) { // send an email to the admin alerting them of the registration wp_new_user_notification($new_user_id); // log the new user in wp_set_auth_cookie($new_user_id, true); wp_set_current_user($new_user_id, $user_login); do_action('wp_login', $user_login); // send the newly created user to the home page after logging them in wp_redirect(home_url()); exit; } } // END if empty $errors } // END if isset( $_POST['vp_user_login'] }