minimum_age ); } /** * Returns cookie duration. This lets us know how long to keep a * visitor's verified cookie. You can filter this if you like. * * @since 0.1 * @return int */ function av_get_cookie_duration() { global $age_verify; return (int) apply_filters( 'av_cookie_duration', $age_verify->cookie_duration ); } /** * This is the very important function that determines if a given visitor * needs to be verified before viewing the site. You can filter this if you like. * * @since 0.1 * @return bool */ function av_needs_verification() { // Assume the visitor needs to be verified $return = true; if ( isset( $_GET['verified'] ) && $_GET['verified'] == 'yes' ) $return = false; // If logged in users are exempt, and the visitor is logged in, let 'em through if ( get_option( '_av_always_verify', 'guests' ) == 'guests' && is_user_logged_in() ) $return = false; // Or, if there is a valid cookie let 'em through if ( isset( $_COOKIE['av_old_enough'] ) ) $return = false; return (bool) apply_filters( 'av_needs_verification', $return ); } /***********************************************************/ /******************** Display Functions ********************/ /***********************************************************/ /** * Echoes the overlay heading * * @since 0.1 * @echo string */ function av_the_heading() { echo av_get_the_heading(); } /** * Returns the overlay heading. You can filter this if you like. * * @since 0.1 * @return string */ function av_get_the_heading() { return sprintf( apply_filters( 'av_heading', get_option( '_av_heading', __( 'You must be %s years old to visit this site.', 'age_verify' ) ) ), av_get_minimum_age() ); } /** * Echoes the overlay description, which lives below the heading and above the form. * * @since 0.1 * @echo string */ function av_the_desc() { echo av_get_the_desc(); } /** * Returns the overlay description, which lives below the heading and above the form. * You can filter this if you like. * * @since 0.1 * @return string|false */ function av_get_the_desc() { $desc = apply_filters( 'av_description', get_option( '_av_description', __( 'Please verify your age', 'age_verify' ) ) ); if ( ! empty( $desc ) ) return $desc; else return false; } /** * Returns the form's input type, based on the settings. * You can filter this if you like. * * @since 0.1 * @return string */ function av_get_input_type() { return apply_filters( 'av_input_type', get_option( '_av_input_type', 'dropdowns' ) ); } /** * Returns the overlay box's background color * You can filter this if you like. * * @since 0.1 * @return string */ function av_get_overlay_color() { if ( get_option( '_av_overlay_color' ) ) $color = get_option( '_av_overlay_color' ); else $color = 'fff'; return apply_filters( 'av_overlay_color', $color ); } /** * Returns the overlay's background color * You can filter this if you like. * * @since 0.1 * @return string */ function av_get_background_color() { if ( current_theme_supports( 'custom-background' ) ) $default = get_background_color(); else $default = 'e6e6e6'; if ( get_option( '_av_bgcolor' ) ) $color = get_option( '_av_bgcolor' ); else $color = $default; return apply_filters( 'av_background_color', $color ); } /** * Echoes the actual form * * @since 0.1 * @echo string */ function av_verify_form() { echo av_get_verify_form(); } /** * Returns the all-important verification form. * You can filter this if you like. * * @since 0.1 * @return string */ function av_get_verify_form() { $input_type = av_get_input_type(); $submit_button_label = apply_filters( 'av_form_submit_label', __( 'Enter Site »', 'age_verify' ) ); $form = ''; $form .= '
'; return apply_filters( 'av_verify_form', $form ); } /***********************************************************/ /*************** User Registration Functions ***************/ /***********************************************************/ /** * Determines whether or not users need to verify their age before * registering for the site. You can filter this if you like. * * @since 0.1 * @return bool */ function av_confirmation_required() { if ( get_option( '_av_membership', 1 ) == 1 ) $return = true; else $return = false; return (bool) apply_filters( 'av_confirmation_required', $return ); } /** * Adds a checkbox to the default WordPress registration form for * users to verify their ages. You can filter the text if you like. * * @since 0.1 * @echo string */ function av_register_form() { $text = '