Commit f5d6eead authored by KR Moorhouse's avatar KR Moorhouse

Added a helper method for deleting the cache from our new table.

parent 8809cdee
......@@ -60,7 +60,7 @@ final class NF_Database_Models_Form extends NF_Abstracts_Model
$this->delete_submissions();
delete_option( 'nf_form_' . $this->_id );
WPN_Helper::delete_nf_cache( $this->_id );
}
private function delete_submissions( ) {
......
......@@ -265,6 +265,8 @@ final class WPN_Helper
* Function to fetch our cache from the upgrades table (if it exists there).
*
* @param $id (int) The form ID.
*
* @since 3.3.7
*/
public static function get_nf_cache( $id ) {
// See if we have the data in our table already.
......@@ -289,6 +291,8 @@ final class WPN_Helper
*
* @param $id (int) The form ID.
* @param $data (string) The form cache.
*
* @since 3.3.7
*/
public static function update_nf_cache( $id, $data ) {
// Define our current stage here for use as we run various upgrades.
......@@ -310,6 +314,20 @@ final class WPN_Helper
}
$wpdb->query( $sql );
}
/**
* Function to delete our cache.
*
* @param $id (int) The form ID.
*
* @since 3.3.7
*/
public static function delete_nf_cache( $id ) {
global $wpdb;
$sql = "DELETE FROM `{$wpdb->prefix}nf3_upgrades WHERE id = " . intval( $id );
$wpdb->query( $sql );
delete_option( 'nf_form_' . intval( $id ) );
}
private static function parse_utf8_serialized( $matches )
{
......
......@@ -18,7 +18,7 @@ function ninja_forms_ajax_import_form(){
$form_id = ( isset( $_POST[ 'formID' ] ) ) ? absint( $_POST[ 'formID' ] ) : '';
delete_option( 'nf_form_' . $form_id ); // Bust the cache.
WPN_Helper::delete_nf_cache( $form_id ); // Bust the cache.
Ninja_Forms()->form()->import_form( $import, TRUE, $form_id, TRUE );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment