Plugin Directory

Changeset 2030979


Ignore:
Timestamp:
02/15/2019 02:00:00 AM (7 years ago)
Author:
nikolam
Message:

Add conditional fields in settings + Ajax option retrieval

Location:
sermon-manager-for-wordpress/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • sermon-manager-for-wordpress/trunk/includes/admin/class-sm-admin-settings.php

    r2030899 r2030979  
    204204     */
    205205    public static function output_fields( $options, $values = array() ) {
     206        $display_conditions = array();
     207
    206208        foreach ( $options as $value ) {
    207209            if ( ! isset( $value['type'] ) ) {
     
    221223                'size'        => '',
    222224                'disabled'    => false,
     225                'display_if'  => array(),
    223226            );
     227
     228            // Get conditional display.
     229            if ( ! empty( $value['display_if'] ) ) {
     230                $display_conditions[ $value['id'] ]   = isset( $display_conditions[ $value['id'] ] ) ? $display_conditions[ $value['id'] ] : array();
     231                $display_conditions[ $value['id'] ][] = $value['display_if'];
     232            }
    224233
    225234            // Custom attribute handling.
     
    615624            }
    616625        }
     626
     627        // Load conditionals script.
     628        wp_register_script( 'sm_settings_conditionals', SM_URL . 'assets/js/admin/settings/conditionals' . ( ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) ? '' : '.min' ) . '.js', 'sm_settings', SM_VERSION, true );
     629        wp_localize_script( 'sm_settings_conditionals', 'sm_conditionals', $display_conditions );
     630        wp_enqueue_script( 'sm_settings_conditionals' );
    617631    }
    618632
  • sermon-manager-for-wordpress/trunk/readme.txt

    r2030899 r2030979  
    129129* Fix: Improve [latest_series] shortcode
    130130* Fix: Service Type filter in backend not working when slug is different from default
    131 * Dev: Fix select field returning error when only one option is defined for it
     131* Dev: Add conditional fields in settings
     132* Dev: Add dynamic option retrieval in settings
     133* Dev: Fix select field in settings returning error when only one option is defined for it
    132134
    133135### 2.15.13 ###
  • sermon-manager-for-wordpress/trunk/sermons.php

    r2028461 r2030979  
    866866            }
    867867        );
     868
     869        add_action( 'wp_ajax_sm_settings_get_select_data', function () {
     870            echo json_encode( apply_filters( 'sm_settings_get_select_data', array(), $_POST['id'] ) );
     871
     872            wp_die();
     873        } );
    868874    }
    869875}
Note: See TracChangeset for help on using the changeset viewer.