function dfrps_unregister_cpt($post_type = false) { if (!$post_type) { return; } /** * Reset updates to prevent an importer from appearing not to finish * (ie. displaying progress bar) on the Products Sets page. */ dfrps_reset_update(); $cpts = get_option('dfrps_registered_cpts', array()); unset($cpts[$post_type]); // Update default_cpt if there are other CPTs available. // Otherwise the user will see the "install importer plugin" nag. if (!empty($cpts)) { $configuration = get_option('dfrps_configuration', array()); $default_cpt = $configuration['default_cpt']; // The CPT being unregistered is the default CPT. So update the default CPT with another arbitrary CPT. if ($default_cpt == $post_type) { foreach ($cpts as $type => $values) { $configuration['default_cpt'] = $type; update_option('dfrps_configuration', $configuration); break; } } } update_option('dfrps_registered_cpts', $cpts); }
if (!defined('ABSPATH')) { exit; } // Exit if accessed directly /** * BEGIN UPGRADE. */ /** * Get current version of plugin. */ $current_version = get_option('dfrps_version', DFRPS_VERSION); /** * If previous version does not match current version. */ if (version_compare($current_version, DFRPS_VERSION, '!=')) { dfrps_reset_update(); } /** * Stop & reset any Product Set updates. */ function dfrps_reset_update() { global $wpdb; // Get currently updating product set ID. $set_id = $wpdb->get_var("\n\t\tSELECT post_id \n\t\tFROM {$wpdb->postmeta}\n\t\tWHERE meta_key = '_dfrps_cpt_update_phase'\n\t\tAND meta_value > '0'\n\t"); if (!is_null($set_id)) { dfrps_reset_product_set_update($set_id); } } /** * Now that any upgrade functions are performed, update version in database.