Пример #1
0
function ninja_forms_ajax_migrate_database()
{
    if (!current_user_can(apply_filters('ninja_forms_admin_upgrade_migrate_database_capabilities', 'manage_options'))) {
        return;
    }
    $migrations = new NF_Database_Migrations();
    $migrations->nuke(true, true);
    $migrations->migrate();
    echo json_encode(array('migrate' => 'true'));
    wp_die();
}
Пример #2
0
 function ninja_forms_uninstall()
 {
     if (Ninja_Forms()->get_setting('delete_on_uninstall ')) {
         require_once plugin_dir_path(__FILE__) . '/includes/Database/Migrations.php';
         $migrations = new NF_Database_Migrations();
         $migrations->nuke(TRUE, TRUE);
     }
 }
Пример #3
0
 private function _migrate()
 {
     $migrations = new NF_Database_Migrations();
     $migrations->nuke(TRUE, TRUE);
     $posts = get_posts('post_type=nf_sub&numberposts=-1');
     foreach ($posts as $post) {
         wp_delete_post($post->ID, TRUE);
     }
     $migrations->migrate();
 }
Пример #4
0
        // Remove upgrade last step options
        $upgrades = NF_UpgradeHandler()->upgrades;
        if ($upgrades and is_array($upgrades)) {
            foreach ($upgrades as $upgrade) {
                delete_option('nf_upgrade_' . $upgrade->name . '_last_step');
            }
        }
        // Remove all of our submissions
        $items = get_posts(array('post_type' => 'nf_sub', 'post_status' => 'any', 'numberposts' => -1, 'fields' => 'ids'));
        if ($items) {
            foreach ($items as $item) {
                wp_delete_post($item, true);
            }
        }
        // Remove all of our custom tables
        $wpdb->query('DROP TABLE ' . NF_OBJECTS_TABLE_NAME);
        $wpdb->query('DROP TABLE ' . NF_OBJECT_META_TABLE_NAME);
        $wpdb->query('DROP TABLE ' . NF_OBJECT_RELATIONSHIPS_TABLE_NAME);
        $wpdb->query('DROP TABLE ' . NINJA_FORMS_TABLE_NAME);
        $wpdb->query('DROP TABLE ' . NINJA_FORMS_FIELDS_TABLE_NAME);
        $wpdb->query('DROP TABLE ' . NINJA_FORMS_FAV_FIELDS_TABLE_NAME);
        $wpdb->query('DROP TABLE ' . NINJA_FORMS_SUBS_TABLE_NAME);
        // Remove our daily cron job
        $timestamp = wp_next_scheduled('ninja_forms_daily_action');
        wp_unschedule_event($timestamp, 'ninja_forms_daily_action');
    }
} else {
    require_once plugin_dir_path(__FILE__) . '/includes/Database/Migrations.php';
    $migrations = new NF_Database_Migrations();
    $migrations->nuke(TRUE, TRUE);
}