true ) ); if( ! empty( $post_types ) ) { foreach( $post_types as $post_type ) { if( apply_filters( 'wppb_content_restriction_enabled_for_post_type', true, $post_type ) ){ add_meta_box( 'wppb_post_content_restriction', __( 'Profile Builder Content Restriction', 'profile-builder' ), 'wppb_content_restriction_meta_box_output', $post_type, 'normal' ); } } } } function wppb_content_restriction_get_supported_taxonomies() { $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' ); if ( empty( $taxonomies ) ) { return array(); } $disabled_taxonomies = array( 'nav_menu', 'link_category', 'post_format', 'product_visibility', 'product_shipping_class', 'action-group', 'product_type', 'wp_theme', 'wp_template_part_area', ); foreach ( $taxonomies as $taxonomy => $taxonomy_object ) { if ( in_array( $taxonomy, $disabled_taxonomies, true ) ) { unset( $taxonomies[ $taxonomy ] ); continue; } if ( ! apply_filters( 'wppb_content_restriction_enabled_for_taxonomy', true, $taxonomy, $taxonomy_object ) ) { unset( $taxonomies[ $taxonomy ] ); } } return $taxonomies; } function wppb_content_restriction_initialize_taxonomy_fields() { $taxonomies = wppb_content_restriction_get_supported_taxonomies(); foreach ( $taxonomies as $taxonomy => $taxonomy_object ) { add_action( $taxonomy . '_add_form_fields', 'wppb_content_restriction_taxonomy_add_form_fields' ); add_action( $taxonomy . '_edit_form_fields', 'wppb_content_restriction_taxonomy_edit_form_fields', 10, 2 ); } add_action( 'create_term', 'wppb_content_restriction_save_term_data', 10, 3 ); add_action( 'edit_term', 'wppb_content_restriction_save_term_data', 10, 3 ); } add_action( 'init', 'wppb_content_restriction_initialize_taxonomy_fields', 1000 ); function wppb_content_restriction_taxonomy_add_form_fields( $taxonomy ) { wppb_content_restriction_taxonomy_fields_output( null, $taxonomy ); } function wppb_content_restriction_taxonomy_edit_form_fields( $term, $taxonomy ) { wppb_content_restriction_taxonomy_fields_output( $term, $taxonomy ); } function wppb_content_restriction_taxonomy_fields_output( $term = null, $taxonomy = '' ) { $term_id = ! empty( $term->term_id ) ? (int) $term->term_id : 0; $wppb_content_restrict_types = apply_filters( 'wppb_single_post_content_restrict_types', array( 'message' => __( 'Message', 'profile-builder' ), 'redirect' => __( 'Redirect', 'profile-builder' ) ) ); $wppb_content_restrict_type = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-type', true ) : ''; $wppb_user_status = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-user-status', true ) : ''; $wppb_selected_roles = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-user-role' ) : array(); $wppb_custom_redirect_url_enabled = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-custom-redirect-url-enabled', true ) : ''; $wppb_custom_redirect_url = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-custom-redirect-url', true ) : ''; $wppb_custom_messages_enabled = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-messages-enabled', true ) : ''; $wppb_roles = get_editable_roles(); $object = get_taxonomy( $taxonomy ); $description_label = ! empty( $object->labels->singular_name ) ? $object->labels->singular_name : __( 'term', 'profile-builder' ); if ( empty( $wppb_selected_roles ) || ! is_array( $wppb_selected_roles ) ) { $wppb_selected_roles = array(); } ob_start(); ?>

$type_label ) : ?>
name="wppb-content-restrict-user-status" id="wppb-content-restrict-user-status">
$wppb_role_details ) : ?>
name="wppb-content-restrict-user-role[]" id="wppb-content-restrict-user-role-">

name="wppb-content-restrict-custom-redirect-url-enabled" id="wppb-content-restrict-custom-redirect-url-enabled">

name="wppb-content-restrict-messages-enabled" id="wppb-content-restrict-messages-enabled">
'wppb-content-restrict-message-logged_out', 'editor_height' => 180 ) ); ?>
'wppb-content-restrict-message-logged_in', 'editor_height' => 180 ) ); ?>

__( 'Message', 'profile-builder' ), 'redirect' => __( 'Redirect', 'profile-builder' ) ) ); $wppb_content_restrict_type = get_post_meta( $post->ID, 'wppb-content-restrict-type', true ); ?>
$type_label ) { ?>
ID, 'wppb-content-restrict-user-status', true ); $wppb_selected_roles = get_post_meta( $post->ID, 'wppb-content-restrict-user-role' ); ?>
name="wppb-content-restrict-user-status" id="wppb-content-restrict-user-status">
$wppb_role_details ) { ?>
name="wppb-content-restrict-user-role[]" id="wppb-content-restrict-user-role-">

post_type ) ) ); ?>

post_type ) ) ); ?>

post_type ) && $post->post_type == 'product' ) : ?>

ID, 'wppb-purchase-restrict-user-status', true ); $wppb_selected_purchase_roles = get_post_meta( $post->ID, 'wppb-purchase-restrict-user-role' ); ?>
name="wppb-purchase-restrict-user-status" id="wppb-purchase-restrict-user-status">
$wppb_role_details ): ?>
name="wppb-purchase-restrict-user-role[]" id="wppb-purchase-restrict-user-role-">

ID, 'wppb-content-restrict-custom-redirect-url-enabled', true ); ?>
name="wppb-content-restrict-custom-redirect-url-enabled" id="wppb-content-restrict-custom-redirect-url-enabled">
ID, 'wppb-content-restrict-custom-redirect-url', true ); ?>

post_type ) ) ); ?>

ID, 'wppb-content-restrict-messages-enabled', true ); ?>
name="wppb-content-restrict-messages-enabled" id="wppb-content-restrict-messages-enabled">
ID ); ?>
ID, 'wppb-content-restrict-message-logged_out', true ), 'wppb-content-restrict-message-logged_out', array( 'textarea_name' => 'wppb-content-restrict-message-logged_out', 'editor_height' => 180 ) ); ?>
ID, 'wppb-content-restrict-message-logged_in', true ), 'wppb-content-restrict-message-logged_in', array( 'textarea_name' => 'wppb-content-restrict-message-logged_in', 'editor_height' => 180 ) ); ?>
post_type ) && $post->post_type == 'product' ) : ?>
ID, 'wppb-content-restrict-message-purchasing_restricted', true ) ), 'wppb-content-restrict-message-purchasing_restricted', array( 'textarea_name' => 'wppb-content-restrict-message-purchasing_restricted', 'editor_height' => 180 ) ); ?>

', '' ) ); ?>