| 1 |
<?php |
| 2 |
/** |
| 3 |
* Uninstall Cooked |
| 4 |
* |
| 5 |
* @package Cooked |
| 6 |
* @since 1.14.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
// Delete all plugin options. |
| 14 |
$options = [ |
| 15 |
'cooked_settings', |
| 16 |
'cooked_settings_saved', |
| 17 |
'cooked_version', |
| 18 |
'cooked_settings_version', |
| 19 |
'cooked_pro_settings_version', |
| 20 |
'cooked_delicious_recipes_imported', |
| 21 |
'cooked_wp_recipe_maker_imported', |
| 22 |
'cooked_related_version', |
| 23 |
'cooked_related_calculation_last', |
| 24 |
]; |
| 25 |
|
| 26 |
foreach ( $options as $option ) { |
| 27 |
delete_option( $option ); |
| 28 |
} |
| 29 |
|
| 30 |
// Delete transients. |
| 31 |
delete_transient( 'cooked_classic_recipes' ); |
| 32 |
delete_transient( 'cooked_widget_recipes_list' ); |
| 33 |
|
| 34 |
// Clean up legacy related-recipes transients. |
| 35 |
global $wpdb; |
| 36 |
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_cooked_%' OR option_name LIKE '_transient_timeout_cooked_%'" ); |
| 37 |
|
| 38 |
// Remove custom role and capabilities. |
| 39 |
if ( class_exists( 'WP_Roles' ) ) { |
| 40 |
$wp_roles = new WP_Roles(); |
| 41 |
|
| 42 |
$roles = [ 'subscriber', 'contributor', 'author', 'editor', 'cooked_recipe_editor', 'administrator' ]; |
| 43 |
$caps = [ |
| 44 |
'edit_cooked_recipes', |
| 45 |
'edit_cooked_settings', |
| 46 |
'approve_cooked_recipes', |
| 47 |
'delete_cooked_recipes', |
| 48 |
'edit_cooked_default_template', |
| 49 |
]; |
| 50 |
|
| 51 |
foreach ( $roles as $role ) { |
| 52 |
foreach ( $caps as $cap ) { |
| 53 |
$wp_roles->remove_cap( $role, $cap ); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
remove_role( 'cooked_recipe_editor' ); |
| 58 |
} |
| 59 |
|
| 60 |
flush_rewrite_rules(); |
| 61 |
|