Created
March 31, 2017 12:52
-
-
Save v-skochko/56296ae7302a9ed6a7987a48f3e0df88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $f_key = "course_cat_" . $cur_term->term_id; | |
| the_field( 'password_protection', $f_key ); | |
| $passwd = isset( $_REQUEST['passwd'] ) ? $_REQUEST['passwd'] : null; | |
| $admin_passwd = get_field( 'password_protection', $f_key ); | |
| $cookie = isset( $_SESSION['re_passwd'] ) ? $_SESSION['re_passwd'] : null; | |
| if ( empty( $cookie ) ) { | |
| if ( $passwd == $admin_passwd ) { | |
| $_SESSION['re_passwd'] = $passwd; | |
| echo ' | |
| <script>window.location.reload();</script>'; | |
| } | |
| } | |
| if ( empty( $cookie ) || $cookie !== $admin_passwd ) { | |
| if ( ! empty( $passwd ) && ( $passwd !== $admin_passwd ) ) { | |
| echo '<h3 class="passwd_wrong">' . __( 'Wrong password!' ) . '</h3>'; | |
| } | |
| echo ' | |
| <form action="" method="post" class="re_passwd"> | |
| <input name="passwd" type="password" placeholder="' . __( 'Enter password' ) . '"/> | |
| <input type="submit" value="' . __( 'Submit' ) . '"> | |
| </form>'; | |
| echo get_field( 'password_protection_desc' ) ? | |
| ' | |
| <article class="re_desc">' . get_field( 'password_protection_desc' ) . '</article>' | |
| : ''; | |
| } else { | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment