AP_Activate::reactivate_addons()

Description #

As of version 4.1.8 addons names are changed hence make sure to reactivate previously active addons.

Changelog #

VersionDescription
4.1.8Introduced.

Source #

File: activate.php

	public function reactivate_addons() {
		$active_addons = get_option( 'anspress_addons', array() );

		foreach ( $active_addons as $file => $active ) {
			if ( false !== strpos( $file, 'free/' ) ) {
				// Get current addons from database.
				$addons = get_option( 'anspress_addons', array() );

				// Delete old addon name from option and update.
				unset( $addons[ $file ] );
				update_option( 'anspress_addons', $addons );

				// Try to activate by new name.
				$new_addon_name = str_replace( 'free/', '', $file );

				// New names of addon.
				$new_name = array(
					'category'     => 'categories',
					'tag'          => 'tags',
					'notification' => 'notifications',
				);

				// Replace old name by new name.
				if ( isset( $new_name[ $new_addon_name ] ) ) {
					$new_addon_name = $new_name[ $new_addon_name ];
				}

				ap_activate_addon( $new_addon_name );
			}
		}
	}

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