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(); ?>
', '' ) ); ?>