AnsPress_Admin_Ajax::ap_toggle_addons()

Description #

Toggle addons.

Source #

File: admin/ajax.php

	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