WordPress.org

Plugin Directory

Changeset 620540


Ignore:
Timestamp:
11/02/12 23:19:50 (18 months ago)
Author:
johnbillion
Message:
Location:
global-post-password
Files:
2 added
2 edited
2 moved

Legend:

Unmodified
Added
Removed
  • global-post-password/trunk/global-post-password.php

    r461248 r620540  
    22/* 
    33Plugin Name: Global Post Password 
    4 Description: Enables you to define a global password for all password-protected posts. <a href="options-privacy.php">Click here to change the password</a>. 
     4Description: Define a global password for all your password-protected posts. <a href="options-general.php?page=globalpostpassword">Set the password here</a>. 
    55Plugin URI:  http://lud.icro.us/wordpress-plugin-global-post-password/ 
    6 Version:     1.4.2 
     6Version:     1.5 
    77Author:      John Blackbourn 
    88Author URI:  http://johnblackbourn.com/ 
     9 
     10Copyright © 2012 John Blackbourn 
    911 
    1012This program is free software; you can redistribute it and/or modify 
     
    2224class GlobalPostPassword { 
    2325 
    24     function GlobalPostPassword() { 
    25         $settings = (array) get_option( 'globalpostpassword_settings' ); 
    26         if ( $this->is_edit_screen() ) { 
    27             add_action( 'admin_menu',        array( &$this, 'start_buffer' ) ); 
    28             add_action( 'admin_footer',      array( &$this, 'end_buffer' ) ); 
    29         } else if ( $this->is_manage_screen() ) { 
    30             add_action( 'admin_footer',      array( &$this, 'js_manage' ) ); 
    31         } else if ( $this->is_privacy_screen() ) { 
    32             add_action( 'admin_head',        array( &$this, 'js_privacy' ) ); 
    33         } else if ( $this->is_wp_pass() ) { 
    34             add_action( 'init',              array( &$this, 'set_password' ) ); 
    35         } 
    36         if ( isset( $_GET['pass'] ) and $this->check_password( $_GET['pass'] ) ) { 
    37             if ( $settings['in_permalinks'] ) { 
    38                 add_action( 'template_redirect', array( &$this, 'redirect' ) ); 
     26    public $has_buffer = false; 
     27    public $wp_hasher  = null; 
     28 
     29    function __construct() { 
     30 
     31        $this->settings = (array) get_option( 'globalpostpassword_settings' ); 
     32        $this->passes   = (array) get_option( 'globalpostpassword' ); 
     33 
     34        add_action( 'init', array( $this, 'init' ) ); 
     35 
     36        if ( is_admin() ) { 
     37 
     38            add_action( 'admin_init',        array( $this, 'register' ) ); 
     39            add_action( 'admin_menu',        array( $this, 'admin_menu' ) ); 
     40            add_action( 'admin_footer',      array( $this, 'end_buffer' ) ); 
     41            add_action( 'load-post.php',     array( $this, 'start_buffer' ) ); 
     42            add_action( 'load-post-new.php', array( $this, 'start_buffer' ) ); 
     43            add_action( 'load-edit.php',     array( $this, 'assets' ) ); 
     44            add_action( 'load-settings_page_globalpostpassword', array( $this, 'assets' ) ); 
     45 
     46        } else { 
     47 
     48            add_action( 'body_class', array( $this, 'body_class' ) ); 
     49 
     50            if ( isset( $_GET['pass'] ) and $this->check_password( stripslashes( $_GET['pass'] ) ) ) { 
     51                if ( $this->settings['in_permalinks'] ) { 
     52                    add_action( 'template_redirect', array( $this, 'redirect' ) ); 
     53                    add_filter( 'the_permalink_rss', array( $this, 'permalink_rss' ) ); 
     54                } 
     55                if ( $this->settings['in_feed'] ) { 
     56                    add_filter( 'the_content_feed',  array( $this, 'content_rss' ) ); 
     57                    add_filter( 'the_excerpt_rss',   array( $this, 'excerpt_rss' ) ); 
     58                } 
    3959            } 
    40             if ( $settings['in_permalinks'] ) { 
    41                 add_filter( 'the_permalink_rss', array( &$this, 'permalink_rss' ) ); 
    42             } 
    43             if ( $settings['in_feed'] ) { 
    44                 add_filter( 'the_content_feed',  array( &$this, 'content_rss' ) ); 
    45                 add_filter( 'the_excerpt_rss',   array( &$this, 'excerpt_rss' ) ); 
    46             } 
    47         } 
    48         add_filter( 'whitelist_options',     array( &$this, 'whitelist_options' ) ); 
    49         add_action( 'blog_privacy_selector', array( &$this, 'settings' ) ); 
    50         add_action( 'admin_init',            array( &$this, 'register' ) ); 
    51         add_action( 'body_class',            array( &$this, 'body_class' ) ); 
     60 
     61        } 
     62 
     63    } 
     64 
     65    function admin_menu() { 
     66        add_options_page( 
     67            __( 'Global Post Password', 'globalpostpassword' ), 
     68            __( 'Global Post Password', 'globalpostpassword' ), 
     69            'manage_options', 
     70            'globalpostpassword', 
     71            array( $this, 'settings' ) 
     72        ); 
    5273    } 
    5374 
    5475    function redirect() { 
    55         if ( !is_single() ) 
     76        if ( !is_singular() ) 
    5677            return; 
    57         $password = $this->check_password( $_GET['pass'] ); 
    58         if ( get_magic_quotes_gpc() ) 
    59             $password = stripslashes( $password ); 
    60  
    61         setcookie( 'wp-postpass_' . COOKIEHASH, $password, time() + 864000, COOKIEPATH ); 
     78        $password = $this->check_password( stripslashes( $_GET['pass'] ) ); 
     79 
     80        if ( empty( $this->wp_hasher ) ) { 
     81            require_once( ABSPATH . 'wp-includes/class-phpass.php' ); 
     82            $this->wp_hasher = new PasswordHash( 8, true ); 
     83        } 
     84 
     85        setcookie( 'wp-postpass_' . COOKIEHASH, $this->wp_hasher->HashPassword( $password ), time() + 864000, COOKIEPATH ); 
    6286 
    6387        wp_safe_redirect( remove_query_arg( 'pass' ) ); 
     
    83107        if ( !$post->post_password ) 
    84108            return $permalink; 
    85         $permalink = add_query_arg( 'pass', esc_attr( stripslashes( $_GET['pass'] ) ), $permalink ); 
    86         return str_replace( '&', '&amp;', $permalink ); 
     109        return add_query_arg( 'pass', stripslashes( $_GET['pass'] ), $permalink ); 
    87110    } 
    88111 
    89112    function register() { 
     113 
    90114        register_setting( 'globalpostpassword', 'globalpostpassword', array( $this, 'update' ) ); 
    91         register_setting( 'globalpostpassword_settings', 'globalpostpassword_settings' ); 
    92     } 
    93  
    94     function whitelist_options( $list ) { 
    95         $list['privacy'][] = 'globalpostpassword'; 
    96         $list['privacy'][] = 'globalpostpassword_settings'; 
    97         return $list; 
     115        register_setting( 'globalpostpassword', 'globalpostpassword_settings' ); 
     116 
     117        add_settings_section( 
     118            'default', 
     119            '', 
     120            '__return_false', 
     121            'globalpostpassword' 
     122        ); 
     123        add_settings_field( 
     124            'globalpostpassword_global', 
     125            __( 'Global Post Password', 'globalpostpassword' ), 
     126            array( $this, 'settings_global' ), 
     127            'globalpostpassword' 
     128        ); 
     129        add_settings_field( 
     130            'globalpostpassword_additional', 
     131            __( 'Additional Global Post Passwords', 'globalpostpassword' ), 
     132            array( $this, 'settings_additional' ), 
     133            'globalpostpassword' 
     134        ); 
     135        add_settings_field( 
     136            'globalpostpassword_urls', 
     137            __( 'Passwords in URLs', 'globalpostpassword' ), 
     138            array( $this, 'settings_urls' ), 
     139            'globalpostpassword' 
     140        ); 
     141 
    98142    } 
    99143 
    100144    function buffer_edit( $content ) { 
    101145 
    102         $passes  = (array) get_option( 'globalpostpassword' ); 
    103146        $search  = '|<span id="password-span">.*?</span>|i'; 
    104         $replace = '<input type="hidden" name="post_password" value="' . esc_attr( $passes[0] ) . '" />'; 
    105  
    106         if ( !$passes[0] ) { 
     147        $replace = '<input type="hidden" name="post_password" value="' . esc_attr( $this->passes[0] ) . '" />'; 
     148 
     149        if ( !$this->passes[0] ) { 
    107150            $replace .= '<div style="background:#FFFFE0;padding:5px;border:1px solid #E6DB55;-moz-border-radius:3px">'; 
    108             $replace .= __( '<strong>Warning:</strong> No global post password set.<br /><a href="options-privacy.php">Set one here &raquo;</a>', 'g_p_p' ); 
     151            $replace .= __( '<strong>Warning:</strong> No global post password set.<br /><a href="options-general.php?page=globalpostpassword">Set one here &raquo;</a>', 'globalpostpassword' ); 
    109152            $replace .= '</div>'; 
    110153        } 
     
    116159    } 
    117160 
    118     function js_manage() { 
    119         $passes = (array) get_option( 'globalpostpassword' ); 
    120         ?> 
    121         <script type="text/javascript"> 
    122  
    123         function set_password_switch() { 
    124             $ = window.jQuery; 
    125             $('.inline-edit-password-switch').attr('checked',function(){ 
    126                 return $('.inline-edit-password-input').val() ? 'checked' : ''; 
    127             }); 
    128         } 
    129  
    130         jQuery(document).ready(function($) { 
    131             $('.editinline').click(function() { 
    132                 setTimeout( 'set_password_switch()', 1 ); // hacky 
    133             }); 
    134             $('<label><input type="checkbox" class="inline-edit-password-switch" /> <span class="checkbox-title"><?php _e('Password protected', 'g_p_p' ); ?></span></label>').insertAfter('.inline-edit-password-input').click(function(){ 
    135                 val = $('input',this).attr('checked') ? '<?php echo esc_attr( $passes[0] ); ?>' : ''; 
    136                 $('.inline-edit-password-input').val(val); 
    137             }); 
    138             $('.inline-edit-password-input').hide(); 
    139         }); 
    140  
    141         </script> 
    142         <?php 
    143     } 
    144  
    145     function js_privacy() { 
    146         ?> 
    147         <script type="text/javascript"> 
    148  
    149         jQuery(function($) { 
    150  
    151             $('#g_p_p h4').show(); 
    152             if ( $('#g_p_p input').length > 1 ) 
    153                 $('#g_p_p input:last, #g_p_p br:last').hide(); 
    154             $('#g_p_p h4 a').click(function(){ 
    155                 $('#g_p_p input:last').after($('#g_p_p input:last').clone().val('').show()).after('<br />'); 
    156                 return false; 
    157             }); 
    158  
    159             $('#globalpostpassword').change(function(){ 
    160                 if ( '' == $(this).val() ) 
    161                     $(this).parents('tr').addClass('form-invalid'); 
    162                 else 
    163                     $(this).parents('tr').removeClass('form-invalid'); 
    164             }); 
    165  
    166             $('form[action="options.php"]').submit(function(){ 
    167                 if ( '' != $('#globalpostpassword').val() ) 
    168                     return true; 
    169                 alert( '<?php _e('The global post password cannot be blank. If you wish to return to per-post passwords, just deactivate or uninstall the Global Post Password plugin.', 'g_p_p' ); ?>' ); 
    170                 return false; 
    171             }); 
    172  
    173         }); 
    174  
    175         </script> 
    176         <?php 
    177     } 
    178  
    179     function set_password() { 
    180         if ( !isset( $_POST['post_password'] ) or empty( $_POST['post_password'] ) ) 
    181             return; 
    182         if ( $password = $this->check_password( $_POST['post_password'] ) ) 
    183             $_POST['post_password'] = $password; 
    184     } 
    185  
    186     function check_password( $password, $handleslashes = true ) { 
    187         if ( $handleslashes and get_magic_quotes_gpc() ) 
    188             $password = stripslashes( $password ); 
    189         if ( in_array( $password, $passes = (array) get_option( 'globalpostpassword' ) ) ) 
    190             $password = $passes[0]; 
     161    function assets() { 
     162 
     163        wp_enqueue_script( 
     164            'globalpostpassword', 
     165            $this->plugin_url( 'admin.js' ), 
     166            array( 'jquery' ), 
     167            $this->plugin_ver( 'admin.js' ) 
     168        ); 
     169 
     170        wp_localize_script( 
     171            'globalpostpassword', 
     172            'gpp', 
     173            array( 
     174                'password'           => $this->passes[0], 
     175                'password_protected' => __( 'Password protected', 'globalpostpassword' ), 
     176                'not_blank'          => __( 'The global post password cannot be blank. If you wish to return to per-post passwords, you should deactivate or uninstall the Global Post Password plugin.', 'globalpostpassword' ) 
     177            ) 
     178        ); 
     179 
     180    } 
     181 
     182    function init() { 
     183 
     184        load_plugin_textdomain( 
     185            'globalpostpassword', 
     186            false, 
     187            dirname( $this->plugin_base() ) . '/languages' 
     188        ); 
     189 
     190        if ( isset( $_POST['post_password'] ) and isset( $_GET['action'] ) and ( 'postpass' == $_GET['action'] ) ) { 
     191            if ( $password = $this->check_password( stripslashes( $_POST['post_password'] ) ) ) 
     192                $_POST['post_password'] = addslashes( $password ); 
     193        } 
     194 
     195    } 
     196 
     197    function check_password( $password ) { 
     198 
     199        if ( in_array( $password, $this->passes ) ) 
     200            return $this->passes[0]; 
    191201        else 
    192202            return false; 
    193         if ( $handleslashes and get_magic_quotes_gpc() ) 
    194             $password = addslashes( $password ); 
    195         return $password; 
     203 
     204    } 
     205 
     206    function check_hashed_password( $hash ) { 
     207 
     208        if ( empty( $this->wp_hasher ) ) { 
     209            require_once( ABSPATH . 'wp-includes/class-phpass.php'); 
     210            $this->wp_hasher = new PasswordHash( 8, true ); 
     211        } 
     212 
     213        foreach ( $this->passes as $pass ) { 
     214            if ( $this->wp_hasher->CheckPassword( $pass, $hash ) ) 
     215                return $this->passes[0]; 
     216        } 
     217 
     218        return false; 
     219 
    196220    } 
    197221 
    198222    function settings() { 
    199         $passes   = (array) get_option( 'globalpostpassword' ); 
    200         $settings = (array) get_option( 'globalpostpassword_settings' ); 
     223 
    201224        ?> 
    202             </td> 
    203         </tr> 
    204         <tr valign="top"> 
    205             <th scope="row"><?php _e('Global Post Password', 'g_p_p'); ?></th> 
    206             <td><input name="globalpostpassword[0]" id="globalpostpassword" type="text" value="<?php echo esc_attr( $passes[0] ); ?>" class="regular-text" maxlength="20" /> 
    207                 <p><?php _e('All posts which are password-protected will use this password.', 'g_p_p'); ?></p> 
    208             </td> 
    209         </tr> 
    210         <tr valign="top"> 
    211             <th scope="row"><?php _e('Additional Global Post Passwords', 'g_p_p'); ?></th> 
    212             <td id="g_p_p"><?php 
    213  
    214             foreach ( $passes as $key => $pass ) { 
    215                 if ( !$key ) 
    216                     continue; 
    217                 echo '<input name="globalpostpassword[]" type="text" value="' . esc_attr( $pass ) . '" class="regular-text" maxlength="20" /><br />'; 
    218             } 
    219  
     225        <div class="wrap"> 
     226            <?php screen_icon(); ?> 
     227            <h2><?php _e( 'Global Post Password', 'globalpostpassword' ); ?></h2> 
     228 
     229            <form method="post" action="options.php" id="globalpostpassword_form"> 
     230            <?php 
     231                settings_fields( 'globalpostpassword' ); 
     232                do_settings_sections( 'globalpostpassword' ); 
     233                submit_button(); 
    220234            ?> 
    221             <input name="globalpostpassword[]" type="text" value="" class="regular-text" maxlength="20" /> 
    222             <h4 style="display:none"><a href="#"><?php _e('+ Add', 'g_p_p'); ?></a></h4> 
    223             <p><?php _e('Optionally, any number of additional global post passwords can be set here.', 'g_p_p'); ?></p> 
    224             <p class="setting-description description"><?php _e( 'These work just like the main global post password, but can be removed at any time. Users can enter any of the global post passwords to gain access to any password protected post. This gives you the ability to have temporary passwords which can be revoked.', 'g_p_p'); ?></p> 
    225             </td> 
    226         </tr> 
    227         <tr valign="top"> 
    228             <th scope="row"><?php _e('Passwords in URLs', 'g_p_p'); ?></th> 
    229             <td> 
    230                 <p><label><input name="globalpostpassword_settings[in_permalinks]" value="1" type="checkbox" <?php checked( @$settings['in_permalinks'] ); ?> /> <?php _e('Allow post password in permalinks', 'g_p_p'); ?></label><br /> 
    231                 <span class="setting-description description"><?php printf( __( 'With this setting enabled, appending <code>?pass=%s</code> to a post permalink will display the post without asking for the password.', 'g_p_p' ), esc_attr( $passes[0] ) ); ?></span></p> 
    232                 <p><label><input name="globalpostpassword_settings[in_feed]" value="1" type="checkbox" <?php checked( @$settings['in_feed'] ); ?> /> <?php _e('Allow post password in your feed URL', 'g_p_p'); ?></label><br /> 
    233                 <span class="setting-description description"><?php printf( __( 'With this setting enabled, appending <code>?pass=%s</code> to your blog&rsquo;s feed URL will display password protected posts in your feed without asking for passwords.', 'g_p_p' ), esc_attr( $passes[0] ) ); ?></span></p> 
    234                 <p class="setting-description description"><?php _e( '<strong>Tip:</strong> With either of these settings enabled, you can use any of your global post passwords in the URL.', 'g_p_p' ); ?></p> 
    235                 <p class="setting-description description"><?php _e( '<strong>Tip:</strong> If you enable both these options, permalinks in your feed will automatically have the password appended so users can click through to the post without needing to enter the password.', 'g_p_p' ); ?></p> 
     235            </form> 
     236 
     237        </div> 
    236238        <?php 
     239 
     240    } 
     241 
     242    function settings_global() { 
     243        ?> 
     244        <input name="globalpostpassword[0]" id="globalpostpassword" type="text" value="<?php echo esc_attr( $this->passes[0] ); ?>" class="regular-text" maxlength="20" /> 
     245        <p><?php _e( 'All posts which are password-protected will use this password.', 'globalpostpassword' ); ?></p> 
     246        <?php 
     247    } 
     248 
     249    function settings_additional() { 
     250 
     251        foreach ( $this->passes as $key => $pass ) { 
     252            if ( !$key ) 
     253                continue; 
     254            echo '<div><input name="globalpostpassword[]" type="text" value="' . esc_attr( $pass ) . '" class="regular-text" maxlength="20" /></div>'; 
     255        } 
     256 
     257        ?> 
     258        <div class="hide-if-js globalpostpassword"><input name="globalpostpassword[]" type="text" value="" class="regular-text" maxlength="20" /></div> 
     259        <strong class="hide-if-no-js"><a href="#" id="add_gpp"><?php _e( '+ Add', 'globalpostpassword' ); ?></a></strong> 
     260        <p> 
     261            <?php _e( 'Optionally, any number of additional global post passwords can be set here.', 'globalpostpassword' ); ?> 
     262        </p> 
     263        <p class="description"> 
     264            <?php _e( 'These work just like the main global post password, but can be removed at any time. Users can enter any of the global post passwords to gain access to any password protected post. This gives you the ability to have temporary passwords which can be revoked.', 'globalpostpassword'); ?> 
     265        </p> 
     266        <?php 
     267    } 
     268 
     269    function settings_urls() { 
     270        ?> 
     271        <p> 
     272            <label> 
     273                <input name="globalpostpassword_settings[in_permalinks]" value="1" type="checkbox" <?php checked( @$this->settings['in_permalinks'] ); ?> /> 
     274                <?php _e( 'Allow post password in permalinks', 'globalpostpassword' ); ?> 
     275            </label><br /> 
     276            <span class="description"><?php printf( __( 'With this setting enabled, appending <code>?pass=%s</code> to a post permalink will display the post without asking for the password.', 'globalpostpassword' ), esc_html( $this->passes[0] ) ); ?></span> 
     277        </p> 
     278        <p> 
     279            <label> 
     280                <input name="globalpostpassword_settings[in_feed]" value="1" type="checkbox" <?php checked( @$this->settings['in_feed'] ); ?> /> 
     281                <?php _e( 'Allow post password in your feed URL', 'globalpostpassword' ); ?> 
     282            </label><br /> 
     283            <span class="description"><?php printf( __( 'With this setting enabled, appending <code>?pass=%s</code> to your blog&rsquo;s feed URL will display password protected posts in your feed without asking for passwords.', 'globalpostpassword' ), esc_html( $this->passes[0] ) ); ?></span> 
     284        </p> 
     285        <p class="description"> 
     286            <?php _e( '<strong>Tip:</strong> With either of these settings enabled, you can use any of your global post passwords in the URL.', 'globalpostpassword' ); ?> 
     287        </p> 
     288        <?php 
    237289    } 
    238290 
     
    243295        $cookie = 'wp-postpass_' . COOKIEHASH; 
    244296 
    245         if ( is_singular() and !empty( $post->post_password ) ) { 
    246             if ( isset( $_COOKIE[$cookie] ) and $this->check_password( $_COOKIE[$cookie] ) ) 
    247                 $classes[] = 'has-post-password'; 
    248         } 
     297        if ( !is_singular() ) 
     298            return $classes; 
     299        if ( !$post->post_password ) 
     300            return $classes; 
     301        if ( !isset( $_COOKIE[$cookie] ) ) 
     302            return $classes; 
     303 
     304        if ( $this->check_hashed_password( stripslashes( $_COOKIE[$cookie] ) ) ) 
     305            $classes[] = 'has-post-password'; 
    249306 
    250307        return $classes; 
     
    255312        global $wpdb; 
    256313        $passes = (array) $passes; 
    257         if ( '' == trim( $passes[0] ) ) 
    258             return get_option('globalpostpassword'); 
     314        if ( '' === trim( $passes[0] ) ) 
     315            return $this->passes; 
    259316        foreach ( $passes as $key => $pass ) { 
    260317            if ( !trim( $pass ) ) 
     
    270327 
    271328    function start_buffer() { 
    272         ob_start( array( &$this, 'buffer_edit' ) ); 
     329        $this->has_buffer = ob_start( array( $this, 'buffer_edit' ) ); 
    273330    } 
    274331 
    275332    function end_buffer() { 
    276         ob_end_flush(); 
    277     } 
    278  
    279     function is_edit_screen() { 
    280         if ( strpos( $_SERVER['REQUEST_URI'], 'post-new.php' ) 
    281           or strpos( $_SERVER['REQUEST_URI'], 'page-new.php') 
    282           or strpos( $_SERVER['REQUEST_URI'], 'post.php' ) 
    283           or strpos( $_SERVER['REQUEST_URI'], 'page.php' ) ) 
    284             return true; 
    285         return false; 
    286     } 
    287  
    288     function is_manage_screen() { 
    289         if ( strpos( $_SERVER['REQUEST_URI'], 'edit.php' ) 
    290           or strpos( $_SERVER['REQUEST_URI'], 'edit-pages.php' ) ) 
    291             return true; 
    292         return false; 
    293     } 
    294  
    295     function is_privacy_screen() { 
    296         if ( strpos( $_SERVER['REQUEST_URI'], 'options-privacy.php' ) ) 
    297             return true; 
    298         return false; 
    299     } 
    300  
    301     function is_wp_pass() { 
    302         if ( strpos( $_SERVER['REQUEST_URI'], 'wp-pass.php' ) ) 
    303             return true; 
    304         return false; 
     333        if ( $this->has_buffer ) 
     334            ob_end_flush(); 
     335    } 
     336 
     337    function plugin_url( $file = '' ) { 
     338        return $this->plugin( 'url', $file ); 
     339    } 
     340 
     341    function plugin_path( $file = '' ) { 
     342        return $this->plugin( 'path', $file ); 
     343    } 
     344 
     345    function plugin_ver( $file ) { 
     346        return filemtime( $this->plugin_path( $file ) ); 
     347    } 
     348 
     349    function plugin_base() { 
     350        return $this->plugin( 'base' ); 
     351    } 
     352 
     353    function plugin( $item, $file = '' ) { 
     354        if ( !isset( $this->plugin ) ) { 
     355            $this->plugin = array( 
     356                'url'  => plugin_dir_url( __FILE__ ), 
     357                'path' => plugin_dir_path( __FILE__ ), 
     358                'base' => plugin_basename( __FILE__ ) 
     359            ); 
     360        } 
     361        return $this->plugin[$item] . ltrim( $file, '/' ); 
    305362    } 
    306363 
    307364} 
    308365 
    309 load_plugin_textdomain( 
    310     'g_p_p', 
    311     PLUGINDIR . '/' . dirname( plugin_basename( __FILE__ ) ), 
    312     dirname( plugin_basename( __FILE__ ) ) 
    313 ); 
    314  
    315 $g_p_p = new GlobalPostPassword(); 
    316  
    317 ?> 
     366global $globalpostpassword; 
     367 
     368$globalpostpassword = new GlobalPostPassword; 
  • global-post-password/trunk/readme.txt

    r461251 r620540  
    33Donate link: http://lud.icro.us/donations/ 
    44Tags: post, password, privacy 
    5 Requires at least: 2.8 
    6 Tested up to: 3.2 
     5Requires at least: 3.4 
     6Tested up to: 3.5 
    77Stable tag: trunk 
    88 
    9 Enables you to globally set a password for all password protected posts (and pages). 
     9Globally set a password for all password protected posts and pages. 
    1010 
    1111== Description == 
    1212 
    13 If you publish a lot of password protected posts (or even if you don't), you may end up using the same password for every post. With this plugin you can define a global post password from your 'Settings -> Privacy' menu, and switch password protection on or off from the writing screen with just one click. When you change the global password, all password protected posts are automatically updated with the new password. 
     13If you publish many password protected posts (or even if you don't), you may end up using the same password for every post. With this plugin you can define a global post password from your 'Settings -> Global Post Password' menu, and switch password protection on or off from the writing screen with just one click. When you change the global password, all password protected posts are automatically updated with the new password. 
    1414 
    1515Note that this plugin **does not** automatically enable password protection on every post. It allows you to use a global password for every post that you choose to password protect. 
     
    1717== Installation == 
    1818 
    19 This plugin works with WordPress version 2.8 or later. 
     19You can install this plugin directly from your WordPress dashboard: 
    2020 
    21 1. Unzip the ZIP file and drop the folder straight into your `wp-content/plugins/` directory. 
    22 2. Activate the plugin through the 'Plugins' menu in WordPress. 
    23 3. Visit the 'Settings -> Privacy' menu in WordPress and set a global post password. 
     21 1. Go to the *Plugins* menu and click *Add New*. 
     22 2. Search for *Global Post Password*. 
     23 3. Click *Install Now* next to the Global Post Password plugin. 
     24 4. Activate the plugin. 
     25 5. Visit the 'Settings -> Global Post Password' menu and set a global post password. 
    2426 
    25 Now whenever you write or edit a post (or page) you'll be able to switch password protection on or off with one click, instead of having to manually type in a password for each post. You can change the password whenever you like from the 'Settings -> Privacy' menu. 
     27Now whenever you write or edit a post or page you'll be able to switch password protection on or off with one click, instead of having to manually type in a password for each post. You can change the password whenever you like from the 'Settings -> Global Post Password' menu. 
     28 
     29For manual installation, see the guide to [Manually Installing Plugins](http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation). 
    2630 
    2731== Frequently Asked Questions == 
     
    3337= Is the global password just for posts? = 
    3438 
    35 Despite the name of the plugin, anything that is password protected on your blog will use the global password - this includes pages and custom post types as well as regular posts. 
     39Despite the name of the plugin, anything that is password protected on your blog will use the global password - this includes posts, pages and custom post types. 
    3640 
    3741= How do I change the global post password? = 
    3842 
    39 Visit the 'Settings -> Privacy' menu in WordPress and you'll see the option to change the password there. 
     43Visit the 'Settings -> Global Post Password' menu in WordPress. 
    4044 
    4145= Do I have to have administrator privileges to change the global post password? = 
     
    4549= What if I forget the password? = 
    4650 
    47 Visit the 'Settings -> Privacy' menu in WordPress and the password will be displayed there. And don't forget it again. 
     51Visit the 'Settings -> Global Post Password' menu in WordPress and the password will be displayed there. And don't forget it again. 
    4852 
    4953= What's the correct way to remove the global post password? = 
    5054 
    51 If you want to remove the global post password functionality and return to per-post passwords, just disable or uninstall the plugin and normal password protection will return. Password protected posts will remain protected with the password you last set under 'Settings -> Privacy'. 
     55If you want to remove the global post password functionality and return to per-post passwords, just disable or uninstall the plugin and normal password protection will return. Password protected posts will remain protected with the password you last set under 'Settings -> Global Post Password'. 
    5256 
    5357= How secure are password protected posts? = 
     
    6569 
    6670== Changelog == 
     71 
     72= 1.5 = 
     73* WordPress 3.4 and 3.5 compatibility. 
     74* WordPress 3.4 or later is now a requirement. 
    6775 
    6876= 1.4.2 = 
     
    94102== Upgrade Notice == 
    95103 
    96 = 1.4.2 = 
    97 Add a body class of 'has-post-password' to individual posts when a user has entered the correct password. 
     104= 1.5 = 
     105WordPress 3.4 and 3.5 compatibility. 
Note: See TracChangeset for help on using the changeset viewer.