WordPress.org

Plugin Directory

Changeset 606690


Ignore:
Timestamp:
10/01/12 19:49:45 (19 months ago)
Author:
husobj
Message:

Add setting to allow feeds.

Location:
password-protected/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • password-protected/trunk/admin/admin.php

    r606687 r606690  
    4646        register_setting( $this->options_group, 'password_protected_status', 'intval' ); 
    4747        register_setting( $this->options_group, 'password_protected_password', array( $this, 'sanitize_password_protected_password' ) ); 
     48        register_setting( $this->options_group, 'password_protected_feeds', 'intval' ); 
    4849    } 
    4950     
     
    8384    function password_protected_status_field() { 
    8485        echo '<input name="password_protected_status" id="password_protected_status" type="checkbox" value="1" ' . checked( 1, get_option( 'password_protected_status' ), false ) . ' /> ' . __( 'Enabled', 'password_protected' ); 
     86        echo '<input name="password_protected_feeds" id="password_protected_feeds" type="checkbox" value="1" ' . checked( 1, get_option( 'password_protected_feeds' ), false ) . ' style="margin-left: 20px;" /> ' . __( 'Allow Feeds', 'password_protected' ); 
    8587    } 
    8688     
     
    9193        echo '<input type="password" name="password_protected_password[new]" id="password_protected_password_new" size="16" value="" autocomplete="off"> <span class="description">' . __( 'If you would like to change the password type a new one. Otherwise leave this blank.', 'password_protected' ) . '</span><br> 
    9294            <input type="password" name="password_protected_password[confirm]" id="password_protected_password_confirm" size="16" value="" autocomplete="off"> <span class="description">' . __( 'Type your new password again.', 'password_protected' ) . '</span>'; 
     95    } 
     96     
     97    /** 
     98     * Allow Feeds Field 
     99     */ 
     100    function password_protected_feeds_field() { 
     101        echo '<input name="password_protected_feeds" id="password_protected_feeds" type="checkbox" value="1" ' . checked( 1, get_option( 'password_protected_feeds' ), false ) . ' /> ' . __( 'Allow Feeds', 'password_protected' ); 
    93102    } 
    94103     
  • password-protected/trunk/password-protected.php

    r606683 r606690  
    4545        register_activation_hook( __FILE__, array( &$this, 'install' ) ); 
    4646        add_action( 'init', array( $this, 'maybe_process_login' ), 1 ); 
     47        add_action( 'wp', array( $this, 'disable_feeds' ) ); 
    4748        add_action( 'template_redirect', array( $this, 'maybe_show_login' ), 1 ); 
    48         $this->disable_feeds(); 
     49        add_filter( 'pre_option_password_protected_status', array( $this, 'allow_feeds' ) ); 
    4950        if ( is_admin() ) { 
    5051            include_once( dirname( __FILE__ ) . '/admin/admin.php' ); 
     
    8283     */ 
    8384    function disable_feed() { 
    84         wp_die( __( 'Feeds are not available for this site. Please visit the <a href="'. get_bloginfo( 'url' ) .'">website</a>.' ) ); 
     85        wp_die( sprintf( __( 'Feeds are not available for this site. Please visit the <a href="%s">website</a>.', 'password_protected' ), get_bloginfo( 'url' ) ) ); 
     86    } 
     87     
     88    /** 
     89     * Allow Feeds 
     90     */ 
     91    function allow_feeds( $bool ) { 
     92        if ( is_feed() && (bool) get_option( 'password_protected_feeds' ) ) 
     93            return 0; 
     94        return 1; 
    8595    } 
    8696     
Note: See TracChangeset for help on using the changeset viewer.