true, 'exclude_from_search' => false, ), 'names' ); unset( $post_types['protected_areas'] ); add_meta_box( 'shortcode', __( 'Shortcode Configuration', 'content-protector' ), array( $this, 'render_shortcode_configuration' ), 'protected_areas', 'side', 'high' ); add_meta_box( 'copy_shortcode', __( 'Shortcode', 'content-protector' ), array( $this, 'render_copy_shortcode' ), 'protected_areas', 'normal', 'default' ); add_meta_box( 'passster_global', __( 'Passster (Global Protection)', 'content-protector' ), array( $this, 'render_passster_global' ), apply_filters( 'passster_post_types', $post_types ), 'side', 'default' ); add_meta_box( 'passster', __( 'Passster (Page Protection)', 'content-protector' ), array( $this, 'render_passster' ), apply_filters( 'passster_post_types', $post_types ), 'side', 'default' ); add_meta_box( 'passster_link', __( 'Passster (Link Protection)', 'content-protector' ), array( $this, 'render_passster_link' ), apply_filters( 'passster_post_types', $post_types ), 'side', 'default' ); } /** * Render copy shortcode metabox. * * @param WP_Post $post The post object. */ public function render_copy_shortcode( $post ) { $shortcode = ''; // user restriction. $user_restriction_type = get_post_meta( $post->ID, 'passster_user_restriction_type', true ); $user_restriction = get_post_meta( $post->ID, 'passster_user_restriction', true ); // texts. $headline = get_post_meta( $post->ID, 'passster_headline', true ); $instruction = get_post_meta( $post->ID, 'passster_instruction', true ); $placeholder = get_post_meta( $post->ID, 'passster_placeholder', true ); $button = get_post_meta( $post->ID, 'passster_button', true ); $id = get_post_meta( $post->ID, 'passster_id', true ); $hide = get_post_meta( $post->ID, 'passster_hide', true ); // build atts array to validate. $atts = array(); // Add protection based on type. $protection_type = get_post_meta( $post->ID, 'passster_protection_type', true ); switch ( $protection_type ) { case 'password': $password = get_post_meta( $post->ID, 'passster_password', true ); $shortcode = '[passster password="' . $password . '" '; break; case 'captcha': $shortcode = '[passster captcha="true" '; break; } // Add area. $shortcode .= 'area="' . $post->ID . '" '; // Add user restriction. if ( !empty($user_restriction_type) && !empty($user_restriction) ) { if ( 'user-role' === $user_restriction_type ) { $shortcode .= 'role="' . $user_restriction . '" '; } else { $shortcode .= 'user="' . $user_restriction . '" '; } } if ( !empty($headline) ) { $shortcode .= 'headline="' . $headline . '" '; } if ( !empty($instruction) ) { $shortcode .= 'instruction="' . $instruction . '" '; } if ( !empty($placeholder) ) { $shortcode .= 'placeholder="' . $placeholder . '" '; } if ( !empty($button) ) { $shortcode .= 'button="' . $button . '" '; } if ( !empty($hide) && 'yes' === $hide ) { $shortcode .= 'hide="true" '; } if ( !empty($id) ) { $shortcode .= 'id="' . $id . '" '; } $shortcode .= ']'; // Check for space before closing shortcode. $shortcode = str_replace( ' ]', ']', $shortcode ); update_post_meta( $post->ID, 'passster_area_shortcode', $shortcode ); ?>
ID, 'passster_activate_global_protection', true ); // check if protection active. if ( true == $activate_global_protection ) { $activate_global_protection = 'checked="checked"'; } else { $activate_global_protection = ''; } ?> ID, 'passster_activate_protection', true ); $protection_type = get_post_meta( $post->ID, 'passster_protection_type', true ); $password = get_post_meta( $post->ID, 'passster_password', true ); // check if protection active. if ( true == $activate_protection ) { $activate_protection = 'checked="checked"'; } else { $activate_protection = ''; } $protection_types = array( 'password' => __( 'Password', 'content-protector' ), 'captcha' => __( 'Captcha', 'content-protector' ), ); ?> ID, 'passster_protection_type', true ); $password = get_post_meta( $post->ID, 'passster_password', true ); $protection_types = array( 'password' => __( 'Password', 'content-protector' ), 'captcha' => __( 'Captcha', 'content-protector' ), ); ?> ID, 'passster_link', true ); $bitly_on = ''; ?>