Deprecated

This function has been deprecated. Replaced by new form class instead.

ap_option_group_fields()

Description #

Display fields group options. Uses AnsPress_Form to renders fields.

Changelog #

VersionDescription
4.1.0Replaced by new form class.
2.0.0Introduced.

Source #

File: includes/deprecated.php

695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
function ap_option_group_fields() {
    _deprecated_function( __FUNCTION__, '4.1.0' );
 
    $groups = ap_get_option_groups();
    $active = ap_sanitize_unslash( 'option_page', 'request', 'general' );
 
    if ( empty( $groups ) && is_array( $groups ) ) {
        return;
    }
 
    $group = $groups[ $active ];
 
    foreach ( (array) $group['sections'] as $section_slug => $section ) {
        $fields = $section['fields'];
 
        if ( is_array( $fields ) ) {
            $fields[] = array(
                'name'  => 'action',
                'type'  => 'hidden',
                'value' => 'anspress_options',
            );
 
            $fields[] = array(
                'name'  => 'fields_group',
                'type'  => 'hidden',
                'value' => $active,
            );
 
            $fields[] = array(
                'name'  => 'ap_active_section',
                'type'  => 'hidden',
                'value' => $section_slug,
            );
 
            $args = array(
                'name'          => 'options_form',
                'is_ajaxified'  => false,
                'submit_button' => __( 'Save options', 'anspress-question-answer' ),
                'nonce_name'    => 'nonce_option_form',
                'fields'        => $fields,
                'action'        => admin_url( 'admin-post.php' ),
 
            );
 
            $form = new AnsPress_Form( $args );
            echo '<div class="postbox ' . esc_attr( $section_slug ) . '">';
            echo '<h3 data-index="' . esc_attr( $section_slug ) . '"><span>' . esc_html( $section['title'] ) . '</span></h3>';
            echo '<div class="inside">';
            echo $form->get_form(); // xss okay.
            echo '</div>';
            echo '</div>';
 
        } elseif ( function_exists( $fields ) ) {
            echo '<div class="postbox ' . esc_attr( $section_slug ) . '">';
            echo '<h3 data-index="' . esc_attr( $section_slug ) . '"><span>' . esc_html( $section['title'] ) . '</span></h3>';
            echo '<div class="inside">';
            call_user_func( $fields );
            echo '</div>';
            echo '</div>';
        }
    }
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment