// Don't allow this file to be accessed directly.
if ( ! defined( 'WPINC' ) ) {
die();
}
/**
* Prints the minimum age.
*
* @since 0.1.0
* @see av_get_minimum_age();
*
* @return void
*/
function av_minimum_age() {
echo av_get_minimum_age();
}
/**
* Get the minimum age to view restricted content.
*
* @since 0.1.0
*
* @return int $minimum_age The minimum age to view restricted content.
*/
function av_get_minimum_age() {
/**
* Filter the minimum age.
*
* @since 0.1.0
*
* @param int $minimum_age The minimum age to view restricted content.
*/
$minimum_age = apply_filters( 'av_minimum_age', $minimum_age );
return (int) $minimum_age;
}
/**
* Get the visitor's age based on input.
*
* @since 0.1.5
*
* @param string $year The visitor's birth year.
* @param string $month The visitor's birth month.
* @param $day $day The visitor's birth day.
* @return int $age The calculated age.
*/
function av_get_visitor_age( $year, $month, $day ) {
/**
* Get the cookie duration.
*
* This lets us know how long to keep a visitor's
* verified cookie.
*
* @since 0.1.0
*
* @return int $cookie_duration The cookie duration.
*/
function av_get_cookie_duration() {
/**
* Filter the cookie duration.
*
* @since 0.1.0
*
* @param int $cookie_duration The cookie duration.
*/
$cookie_duration = (int) apply_filters( 'av_cookie_duration', $cookie_duration );
return $cookie_duration;
}
/**
* Determines whether only certain content should be restricted.
*
* @since 0.2.0
*
* @return bool $only_content_restricted Whether the restriction is content-specific or site-wide.
*/
function av_only_content_restricted() {
/**
* Filter whether the restriction is content-specific or site-wide.
*
* @since 0.2.0
*
* @param bool $only_content_restricted
*/
$only_content_restricted = apply_filters( 'av_only_content_restricted', $only_content_restricted );
return (bool) $only_content_restricted;
}
/**
* Determines if a certain piece of content is restricted.
*
* @since 0.2.0
*
* @return bool $is_restricted Whether a certain piece of content is restricted.
*/
function av_content_is_restricted( $id = null ) {
/**
* Filter whether this content should be restricted.
*
* @since 0.2.6
*
* @param bool $is_restricted Whether this content should be restricted.
* @param int $id The content's ID.
*/
$is_restricted = apply_filters( 'av_is_restricted', $is_restricted, $id );
return $is_restricted;
}
/**
* 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 the site is restricted on a per-content basis, let 'em through
if ( av_only_content_restricted() ) :
$return = false;
// If the content being viewed is restricted, throw up the form
if ( is_singular() && av_content_is_restricted() )
$return = true;
endif;
// Check that the form was at least submitted. This lets visitors through that have cookies disabled.
$nonce = ( isset( $_REQUEST['age-verified'] ) ) ? $_REQUEST['age-verified'] : '';
if ( wp_verify_nonce( $nonce, 'age-verified' ) )
$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['age-verified'] ) )
$return = false;
/**
* 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', __( 'Bu siteyi ziyaret etmek için %s yaşında olmalısınız.', '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() {
/**
* 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() {
/**
* Returns the overlay box's background color
* You can filter this if you like.
*
* @since 0.1
* @return string
*/
function av_get_overlay_color() {
/**
* Returns the overlay's background color
* You can filter this if you like.
*
* @since 0.1
* @return string
*/
function av_get_background_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() {
/***********************************************************/
/*************** 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() {
/**
* 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 = ' ';
echo $text;
}
/**
* Make sure the user checked the box when registering.
* If not, print an error. You can filter the error's text if you like.
*
* @since 0.1
* @return bool
*/
function av_register_check( $login, $email, $errors ) {