fields( 0 ); } public function edit_fields( $term ) { $this->fields( $term->term_id ); } private function fields( $term_id ) { $value = $term_id ? get_term_meta( $term_id, self::META_KEY, true ) : 'inherit'; $descendants = $term_id ? get_term_meta( $term_id, self::DESCENDANTS_KEY, true ) : ''; wp_nonce_field( 'artbees_qv_category_visibility', 'artbees_qv_category_nonce' ); echo '

' . esc_html__( 'Exclude wins conflicts. Inherit makes no category decision.', 'artbees-quick-view' ) . '

'; } public function save( $term_id ) { if ( ! current_user_can( 'manage_product_terms' ) || ! current_user_can( 'edit_term', $term_id ) || ! isset( $_POST['artbees_qv_category_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['artbees_qv_category_nonce'] ) ), 'artbees_qv_category_visibility' ) ) { return; } $value = isset( $_POST['artbees_qv_visibility'] ) ? sanitize_key( wp_unslash( $_POST['artbees_qv_visibility'] ) ) : 'inherit'; if ( 'inherit' === $value ) { delete_term_meta( $term_id, self::META_KEY ); delete_term_meta( $term_id, self::DESCENDANTS_KEY ); } elseif ( in_array( $value, array( 'include', 'exclude' ), true ) ) { update_term_meta( $term_id, self::META_KEY, $value ); update_term_meta( $term_id, self::DESCENDANTS_KEY, empty( $_POST['artbees_qv_include_descendants'] ) ? '0' : '1' ); } } }