AnsPress_Admin_Ajax::ap_toggle_addons()

Description #

Toggle addons.

Source #

File: admin/ajax.php

243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
public static function ap_toggle_addons() {
    check_ajax_referer( 'ap-toggle-addons', '__nonce' );
 
    if ( ! is_super_admin( ) ) {
        wp_die( '' );
    }
 
    $_REQUEST['option_page'] = 'addons';
    $previous_addons = get_option( 'anspress_addons', [] );
    $new_addons = array_flip( ap_isset_post_value( 'addon', [] ) );
 
    if ( empty( $new_addons ) ) {
        update_option( 'anspress_addons', [] );
    }
 
    $addons = $previous_addons + $new_addons;
 
    foreach ( (array) $addons as $file => $status ) {
        if ( ! isset( $new_addons[ $file ] ) ) {
            ap_deactivate_addon( $file );
        } else {
            ap_activate_addon( $file );
        }
    }
 
    wp_die( );
}

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