Last active
April 1, 2019 12:09
-
-
Save fergbrain/9b2c79aeedece87be75437048bb2b410 to your computer and use it in GitHub Desktop.
Default restrict data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Add to /profile-builder-hobbyist/features/content-restriction/content-restriction-meta-box.php starting after line 62 (" $wppb_selected_roles = get_post_meta( $post->ID, 'wppb-content-restrict-user-role' );" ) | |
//Note that this only applies to posts created directly using the WordPress site, not using the API (e.g. using the WordPress App) | |
// https://wordpress.stackexchange.com/questions/50043/how-to-determine-whether-we-are-in-add-new-page-post-cpt-or-in-edit-page-post-cp | |
/** | |
* is_edit_page | |
* function to check if the current page is a post edit page | |
* | |
* @author Ohad Raz <[email protected]> | |
* | |
* @param string $new_edit what page to check for accepts new - new post page ,edit - edit post page, null for either | |
* @return boolean | |
*/ | |
function is_edit_page($new_edit = null){ | |
global $pagenow; | |
//make sure we are on the backend | |
if (!is_admin()) return false; | |
if($new_edit == "edit") | |
return in_array( $pagenow, array( 'post.php', ) ); | |
elseif($new_edit == "new") //check for new post page | |
return in_array( $pagenow, array( 'post-new.php' ) ); | |
else //check for either new or edit | |
return in_array( $pagenow, array( 'post.php', 'post-new.php' ) ); | |
} | |
?> | |
<?php //and then replace this line: ?> | |
<input type="checkbox" value="loggedin" <?php if( ! empty( $wppb_user_status ) && $wppb_user_status == 'loggedin' ) echo 'checked="checked"'; ?> name="wppb-content-restrict-user-status" id="wppb-content-restrict-user-status"> | |
<?php //with this line: ?> | |
<input type="checkbox" value="loggedin" <?php if( (! empty( $wppb_user_status ) && $wppb_user_status == 'loggedin' ) || ( empty( $wppb_user_status ) && empty( $wppb_content_restrict_type ) && is_edit_page("new") ) ) echo 'checked="checked"'; ?> name="wppb-content-restrict-user-status" id="wppb-content-restrict-user-status"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment