$label ) { $modes .= ''; } $rows = array( array( 'label' => __( 'Exclusive access', 'hyperdrop' ), 'html' => '' . '

' . esc_html__( 'Products here (and in child categories) are hidden from the shop, search and home page until the visitor unlocks the category. Shop managers always see everything.', 'hyperdrop' ) . '

', ), array( 'label' => __( 'Test mode', 'hyperdrop' ), 'html' => '', ), array( 'label' => __( 'Before unlocking, visitors…', 'hyperdrop' ), 'html' => '' . '' . '' . '

' . esc_html__( 'Use preview if your theme hides empty categories (the category tile disappears for visitors in "hidden" mode).', 'hyperdrop' ) . '

', ), array( 'label' => __( 'Code requests', 'hyperdrop' ), 'html' => '', ), array( 'label' => __( 'Devices per emailed code', 'hyperdrop' ), 'html' => '' . '

' . esc_html__( 'How many times a code someone requests by email can be entered (e.g. phone + laptop). Limits sharing. 0 = unlimited.', 'hyperdrop' ) . '

', ), array( 'label' => __( 'Locked message', 'hyperdrop' ), 'html' => '', ), ); /** * Add-ons can add rows ( label + escaped html ) to the category drop settings. */ $rows = (array) apply_filters( 'hyperdrop_term_fields', $rows, $term_id, $s ); foreach ( $rows as $r ) { if ( 'table' === $wrap ) { echo '' . wp_kses( $r['html'], hyperdrop_allowed_html() ) . ''; } else { echo '
' . wp_kses( $r['html'], hyperdrop_allowed_html() ) . '
'; } } echo wp_kses( HyperDrop_Schedule::fields_html( 'hyperdrop_sch_', $term_id ? 't:' . $term_id : '', $wrap ), hyperdrop_allowed_html() ); wp_nonce_field( 'hyperdrop_term_save', 'hyperdrop_term_nonce' ); } public static function add_fields() { echo '

' . esc_html__( 'Exclusive access', 'hyperdrop' ) . '

'; self::fields( HyperDrop_Drop::term_settings( 0 ), 'div' ); } public static function edit_fields( $term ) { echo '

' . esc_html__( 'Exclusive access', 'hyperdrop' ) . '

'; self::fields( HyperDrop_Drop::term_settings( $term->term_id ), 'table', $term->term_id ); echo '' . esc_html__( 'Manage products in this drop', 'hyperdrop' ) . ' ' . esc_html__( 'Manage codes for this category', 'hyperdrop' ) . ''; } public static function save( $term_id ) { if ( ! isset( $_POST['hyperdrop_term_nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['hyperdrop_term_nonce'] ) ), 'hyperdrop_term_save' ) ) { return; } if ( ! current_user_can( 'manage_product_terms' ) ) { return; } update_term_meta( $term_id, '_hyperdrop_protected', isset( $_POST['hyperdrop_protected'] ) ? 'yes' : 'no' ); update_term_meta( $term_id, '_hyperdrop_testing', isset( $_POST['hyperdrop_testing'] ) ? 'yes' : 'no' ); update_term_meta( $term_id, '_hyperdrop_visibility', isset( $_POST['hyperdrop_visibility'] ) && 'preview' === sanitize_key( wp_unslash( $_POST['hyperdrop_visibility'] ) ) ? 'preview' : 'hidden' ); update_term_meta( $term_id, '_hyperdrop_hide_price', isset( $_POST['hyperdrop_hide_price'] ) ? 'yes' : 'no' ); $signup = isset( $_POST['hyperdrop_signup'] ) ? sanitize_key( wp_unslash( $_POST['hyperdrop_signup'] ) ) : 'auto'; update_term_meta( $term_id, '_hyperdrop_signup', array_key_exists( $signup, HyperDrop_Drop::signup_modes() ) ? $signup : 'auto' ); update_term_meta( $term_id, '_hyperdrop_activations', isset( $_POST['hyperdrop_activations'] ) ? absint( $_POST['hyperdrop_activations'] ) : 3 ); $sch = HyperDrop_Schedule::from_input( isset( $_POST['hyperdrop_sch_start'] ) ? sanitize_text_field( wp_unslash( $_POST['hyperdrop_sch_start'] ) ) : '', isset( $_POST['hyperdrop_sch_release'] ) ? sanitize_text_field( wp_unslash( $_POST['hyperdrop_sch_release'] ) ) : '', isset( $_POST['hyperdrop_sch_end'] ) ? sanitize_text_field( wp_unslash( $_POST['hyperdrop_sch_end'] ) ) : '', ! empty( $_POST['hyperdrop_sch_notify'] ) ); if ( is_array( $sch ) ) { HyperDrop_Schedule::set( 't:' . $term_id, $sch[0], $sch[1], $sch[2], $sch[3] ); } else { HyperDrop_Schedule::flash_error( $sch ); } update_term_meta( $term_id, '_hyperdrop_message', isset( $_POST['hyperdrop_message'] ) ? sanitize_textarea_field( wp_unslash( $_POST['hyperdrop_message'] ) ) : '' ); /** Add-ons save their own fields here (the nonce is already verified). */ do_action( 'hyperdrop_save_term', $term_id ); HyperDrop_Drop::flush_cache(); } public static function column( $cols ) { $cols['hyperdrop'] = __( 'Access', 'hyperdrop' ); return $cols; } public static function column_value( $out, $col, $term_id ) { if ( 'hyperdrop' !== $col ) { return $out; } $s = HyperDrop_Drop::term_settings( $term_id ); if ( ! $s['enabled'] ) { return HyperDrop_Drop::is_term_gated( $term_id ) ? 'πŸ”’β†‘' : '–'; } $ph = HyperDrop_Schedule::phase( 't:' . $term_id ); if ( 'upcoming' === $ph ) { return '⏳'; } if ( 'ended' === $ph ) { return 'β›”'; } return HyperDrop_Drop::is_term_gated( $term_id ) ? 'πŸ”’' : 'πŸ”“'; } }