Plugin Directory

Changeset 1450216


Ignore:
Timestamp:
07/06/2016 06:28:18 PM (10 years ago)
Author:
timmcdaniels
Message:

version 0.2

Location:
simple-require-login
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • simple-require-login/trunk/lib.php

    r1290204 r1450216  
    5656        $post_types = array_merge( get_post_types(), array( 'post', 'page' ) );
    5757        foreach ( $post_types as $post_type ) {
    58             add_meta_box( self::nspace . '-' . $post_type . '-meta-box', __( 'Require Login?', self::nspace ), array( &$this, 'meta_box_callback' ), $post_type, 'side', 'high' );
     58            if ( ! strstr( $post_type, 'nav_menu_item' ) && ! strstr( $post_type, 'acf' ) && ! strstr( $post_type, 'revision' ) ) {
     59                add_meta_box( self::nspace . '-' . $post_type . '-meta-box', __( 'Require Login?', self::nspace ), array( &$this, 'meta_box_callback' ), $post_type, 'side', 'high' );
     60            }
    5961        }
    6062    }
     
    9496        echo '</select>';
    9597        echo '<p>' . __( 'Note: Administrators will always be able to view "Simple Require Login" content.', self::nspace ) . '</p>';
     98        $value = get_post_meta( $post->ID, '_' . self::nspace . '-ssl-yesno', true );
     99        if ( ! $value ) $value = 'No';
     100        echo '<p><strong>' . __( 'Redirect to SSL?', self::nspace ) . '</strong></p>';
     101        echo '<select id="' . self::nspace . '-ssl-yesno" name="' . self::nspace . '-ssl-yesno">';
     102        foreach ( array( 'Yes', 'No' ) as $val ) {
     103            echo '<option';
     104            if ( $val == $value ) echo ' selected="selected"';
     105            echo '>' . $val . '</option>';
     106        }
     107        echo '</select>';
    96108    }
    97109
     
    118130        $require_login = sanitize_text_field( $_POST[self::nspace . '-yesno'] );
    119131        $role = sanitize_text_field( $_POST[self::nspace . '-role'] );
     132        $require_ssl = sanitize_text_field( $_POST[self::nspace . '-ssl-yesno'] );
    120133        update_post_meta( $post_id, '_' . self::nspace . '-yesno', $require_login );
    121134        update_post_meta( $post_id, '_' . self::nspace . '-role', $role );
     135        update_post_meta( $post_id, '_' . self::nspace . '-ssl-yesno', $require_ssl );
    122136    }
    123137
     
    132146        $require_login = get_post_meta( $post->ID, '_' . self::nspace . '-yesno', true );
    133147        $role = get_post_meta( $post->ID, '_' . self::nspace . '-role', true );
     148        $require_ssl = get_post_meta( $post->ID, '_' . self::nspace . '-ssl-yesno', true );
    134149        if ( $require_login === 'Yes' ) {
    135150            if ( $role === 'any' && is_user_logged_in() ) return; // allow any logged in user
     
    139154            auth_redirect(); // otherwise, redirect to login
    140155        }
     156        if ( $require_ssl === 'Yes' && ! is_ssl() ) {
     157            wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
     158            exit;
     159        }
    141160    }
    142161
  • simple-require-login/trunk/readme.txt

    r1290202 r1450216  
    44Requires at least: 3.5
    55Tested up to: 4.3.1
    6 Stable tag: 0.1
     6Stable tag: 0.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3030== Changelog ==
    3131
     32= 0.2 =
     33* Added condition so that metabox doesn't show up on ACF and menu pages. Added an option to redirect to SSL.
     34
    3235= 0.1 =
    3336* Initial Release
  • simple-require-login/trunk/simple-require-login.php

    r1290195 r1450216  
    55Description: Require login for content on a per page/post/custom post type basis. You can also select a specific role required to view the content.
    66Author: timmcdaniels
    7 Version: 0.1
     7Version: 0.2
    88Author URI: http://www.weareconvoy.com
    99Requires at least: 3.4.2
Note: See TracChangeset for help on using the changeset viewer.