Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cspassword_shortcode($atts, $content = null) {
- if (!isset($_SESSION)) session_start();
- extract(shortcode_atts(array(
- 'password' => ''
- ), $atts));
- $csp_text = get_option('cspassword_text', __("Content with a password", "cs-password"));
- $csp_submit = get_option('cspassword_submit', __("Access", "cs-password"));
- $csp_error = get_option('cspassword_error', __("Access Denied", "cs-password"));
- $form = '
- <form action="#csp_form" method="post" class="csp_form" id="csp_form">
- '.$csp_text.'
- <input type="password" size="20" name="csp_input">
- <input type="submit" name="csp_submit" value="'.$csp_submit.'">
- </form>
- ';
- if (isset($_POST['csp_submit'])) {
- if ($_POST['csp_input'] == $password AND $password != '') {
- $_SESSION['cclc_full_post_access_' . $post->ID] = true; //added by dbrellis
- }
- else {
- $_SESSION['cclc_full_post_access_' . $post->ID] = false; //added by dbrellis
- return '
- '.$form.'
- <strong>
- '.$csp_error.'
- </strong>
- ';
- }
- }
- if($_SESSION['cclc_full_post_access_' . $post->ID] === true)
- return '<div id="csp_form" style="display:none;"></div>'. do_shortcode($content);
- else return $form;
- }
- add_shortcode('cspasswordcode', 'cspassword_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement