Changeset 1450216
- Timestamp:
- 07/06/2016 06:28:18 PM (10 years ago)
- Location:
- simple-require-login
- Files:
-
- 6 added
- 3 edited
-
tags/0.1 (added)
-
tags/0.1/lib.php (added)
-
tags/0.1/readme.txt (added)
-
tags/0.1/screenshot-1.png (added)
-
tags/0.1/simple-require-login.php (added)
-
tags/0.1/srl.js (added)
-
trunk/lib.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/simple-require-login.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
simple-require-login/trunk/lib.php
r1290204 r1450216 56 56 $post_types = array_merge( get_post_types(), array( 'post', 'page' ) ); 57 57 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 } 59 61 } 60 62 } … … 94 96 echo '</select>'; 95 97 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>'; 96 108 } 97 109 … … 118 130 $require_login = sanitize_text_field( $_POST[self::nspace . '-yesno'] ); 119 131 $role = sanitize_text_field( $_POST[self::nspace . '-role'] ); 132 $require_ssl = sanitize_text_field( $_POST[self::nspace . '-ssl-yesno'] ); 120 133 update_post_meta( $post_id, '_' . self::nspace . '-yesno', $require_login ); 121 134 update_post_meta( $post_id, '_' . self::nspace . '-role', $role ); 135 update_post_meta( $post_id, '_' . self::nspace . '-ssl-yesno', $require_ssl ); 122 136 } 123 137 … … 132 146 $require_login = get_post_meta( $post->ID, '_' . self::nspace . '-yesno', true ); 133 147 $role = get_post_meta( $post->ID, '_' . self::nspace . '-role', true ); 148 $require_ssl = get_post_meta( $post->ID, '_' . self::nspace . '-ssl-yesno', true ); 134 149 if ( $require_login === 'Yes' ) { 135 150 if ( $role === 'any' && is_user_logged_in() ) return; // allow any logged in user … … 139 154 auth_redirect(); // otherwise, redirect to login 140 155 } 156 if ( $require_ssl === 'Yes' && ! is_ssl() ) { 157 wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 158 exit; 159 } 141 160 } 142 161 -
simple-require-login/trunk/readme.txt
r1290202 r1450216 4 4 Requires at least: 3.5 5 5 Tested up to: 4.3.1 6 Stable tag: 0. 16 Stable tag: 0.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 30 30 == Changelog == 31 31 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 32 35 = 0.1 = 33 36 * Initial Release -
simple-require-login/trunk/simple-require-login.php
r1290195 r1450216 5 5 Description: 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. 6 6 Author: timmcdaniels 7 Version: 0. 17 Version: 0.2 8 8 Author URI: http://www.weareconvoy.com 9 9 Requires at least: 3.4.2
Note: See TracChangeset
for help on using the changeset viewer.