/deprecated/includes/admin/upgrades/upgrade-functions.php

  1. <?php if ( ! defined( 'ABSPATH' ) ) exit; 
  2.  
  3. if( ! function_exists( 'nf_is_func_disabled' ) ) { 
  4. function nf_is_func_disabled($function) 
  5. $disabled = explode(', ', ini_get('disable_functions')); 
  6.  
  7. return in_array($function, $disabled); 
  8.  
  9. /** 
  10. * Upgrade Functions 
  11. * 
  12. * @package Ninja Forms 
  13. * @subpackage Admin/Upgrades 
  14. * @copyright Copyright (c) 2014, WP Ninjas 
  15. * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License 
  16. * @since 2.7 
  17. */ 
  18.  
  19. // Exit if accessed directly 
  20. if ( ! defined( 'ABSPATH' ) ) exit; 
  21.  
  22. /** 
  23. * DEPRECATED - Display Upgrade Notices 
  24. * 
  25. * @since 2.7 
  26. * @return void 
  27. */ 
  28. function nf_show_upgrade_notices() { 
  29.  
  30. // Convert notifications 
  31. if ( isset ( $_GET['page'] ) && $_GET['page'] == 'nf-processing' ) 
  32. return; // Don't show notices on the processing page. 
  33.  
  34. $n_conversion_complete = get_option( 'nf_convert_notifications_complete', false ); 
  35.  
  36. if ( ! $n_conversion_complete ) { 
  37. printf( 
  38. '<div class="update-nag"><p>' . __( 'Ninja Forms needs to upgrade your form notifications, click %shere%s to start the upgrade.', 'ninja-forms' ) . '</p></div>',  
  39. '<a href="' . admin_url( 'index.php?page=nf-processing&action=convert_notifications' ) . '">', '</a>' 
  40. ); 
  41.  
  42. $update_email_settings_complete = get_option( 'nf_update_email_settings_complete', false ); 
  43.  
  44. if ( $n_conversion_complete && ! $update_email_settings_complete ) { 
  45. printf( 
  46. '<div class="update-nag"><p>' . __( 'Ninja Forms needs to update your email settings, click %shere%s to start the upgrade.', 'ninja-forms' ) . '</p></div>',  
  47. '<a href="' . admin_url( 'index.php?page=nf-processing&action=update_email_settings' ) . '">', '</a>' 
  48. ); 
  49.  
  50. if ( isset( $_GET['page'] ) && $_GET['page'] == 'nf-upgrades' ) 
  51. return; // Don't show notices on the upgrades page 
  52.  
  53. $step = get_option( 'nf_convert_subs_step' ); 
  54.  
  55. if ( $step != 'complete' ) { 
  56. if ( empty( $step ) ) { 
  57. $step = 1; 
  58. printf( 
  59. '<div class="update-nag"><p>' . __( 'Ninja Forms needs to upgrade the submissions table, click %shere%s to start the upgrade.', 'ninja-forms' ) . '</p></div>',  
  60. '<a href="' . admin_url( 'index.php?page=nf-upgrades&nf-upgrade=upgrade_subs_to_cpt&step=' . $step ) . '">', '</a>' 
  61. ); 
  62.  
  63. $upgrade_notice = get_option( 'nf_upgrade_notice' ); 
  64.  
  65. if ( $upgrade_notice != 'closed' ) { 
  66. printf( 
  67. '<div class="update-nag"><p>' . __( 'Thank you for updating to version 2.7 of Ninja Forms. Please update any Ninja Forms extensions from ', 'ninja-forms' ) . '<a href="http://ninjaforms.com/your-account/purchases/"</a>ninjaforms.com</a>. <a href="%s">Dismiss this notice</a></p></div>',  
  68. esc_url( add_query_arg( array( 'nf_action' => 'dismiss_upgrade_notice' ) ) ) 
  69. ); 
  70.  
  71. if ( defined( 'NINJA_FORMS_UPLOADS_VERSION' ) && version_compare( NINJA_FORMS_UPLOADS_VERSION, '1.3.5' ) == -1 ) { 
  72. echo '<div class="error"><p>' . __( 'Your version of the Ninja Forms File Upload extension isn\'t compatible with version 2.7 of Ninja Forms. It needs to be at least version 1.3.5. Please update this extension at ', 'ninja-forms' ) . '<a href="http://ninjaforms.com/your-account/purchases/"</a>ninjaforms.com</a></p></div>'; 
  73.  
  74. if ( defined( 'NINJA_FORMS_SAVE_PROGRESS_VERSION' ) && version_compare( NINJA_FORMS_SAVE_PROGRESS_VERSION, '1.1.3' ) == -1 ) { 
  75. echo '<div class="error"><p>' . __( 'Your version of the Ninja Forms Save Progress extension isn\'t compatible with version 2.7 of Ninja Forms. It needs to be at least version 1.1.3. Please update this extension at ', 'ninja-forms' ) . '<a href="http://ninjaforms.com/your-account/purchases/"</a>ninjaforms.com</a></p></div>'; 
  76.  
  77. $forms_conversion_complete = get_option( 'nf_convert_forms_complete', false ); 
  78.  
  79. if ( ! $forms_conversion_complete ) { 
  80. $title = urlencode( __( 'Updating Form Database', 'ninja-forms' ) ); 
  81. printf( 
  82. '<div class="update-nag">' . __( 'Ninja Forms needs to upgrade your form settings, click %shere%s to start the upgrade.', 'ninja-forms' ) . '</div>',  
  83. '<a href="' . admin_url( 'index.php?page=nf-processing&action=convert_forms&title=' . $title ) . '">', '</a>' 
  84. ); 
  85.  
  86. //add_action( 'admin_notices', 'nf_show_upgrade_notices' ); 
  87.  
  88. /** 
  89. * Triggers all upgrade functions 
  90. * 
  91. * This function is usually triggered via AJAX 
  92. * 
  93. * @since 2.7 
  94. * @return void 
  95. */ 
  96. function nf_trigger_upgrades() { 
  97. if ( DOING_AJAX ) 
  98. die( 'complete' ); // Let AJAX know that the upgrade is complete 
  99. add_action( 'wp_ajax_edd_trigger_upgrades', 'nf_trigger_upgrades' ); 
  100.  
  101. /** 
  102. * Upgrades for Ninja Forms v2.7 and Submission Custom Post Type. 
  103. * 
  104. * @since 2.7 
  105. * @return void 
  106. */ 
  107. function nf_v27_upgrade_subs_to_cpt() { 
  108. //Bail if we aren't in the admin. 
  109. if ( ! is_admin() ) 
  110. return false; 
  111.  
  112. // Bail if we don't have the appropriate permissions. 
  113. if ( is_multisite() ) { 
  114. if ( ! is_super_admin() ) 
  115. return false; 
  116. } else { 
  117. if ( ! current_user_can( 'install_plugins' ) ) 
  118. return false; 
  119.  
  120. if ( function_exists( 'ignore_user_abort' ) && ! nf_is_func_disabled( 'ignore_user_abort' ) ) { 
  121. ignore_user_abort( true ); 
  122.  
  123. if ( ! nf_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { 
  124. //set_time_limit( 0 ); 
  125.  
  126. $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; 
  127. $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; 
  128. $number = isset( $_GET['custom'] ) ? absint( $_GET['custom'] ) : 1; 
  129.  
  130. if ( get_option( 'nf_convert_subs_num' ) ) { 
  131. $number = get_option( 'nf_convert_subs_num' ); 
  132.  
  133. $form_id = isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0; 
  134.  
  135. update_option( 'nf_convert_subs_step', $step ); 
  136.  
  137. $convert_subs = new NF_Convert_Subs(); 
  138. $old_sub_count = $convert_subs->count_old_subs(); 
  139.  
  140. if( empty( $total ) || $total <= 1 ) { 
  141. $total = round( ( $old_sub_count / 100 ), 0 ) + 2; 
  142.  
  143. if ( $step <= $total ) { 
  144. if ( $step == 1 ) { 
  145. $begin = 0; 
  146. } else { 
  147. $begin = ( $step - 1 ) * 100; 
  148.  
  149. $subs_results = $convert_subs->get_old_subs( $begin, 100 ); 
  150.  
  151. if ( is_array( $subs_results ) && ! empty( $subs_results ) ) { 
  152.  
  153. foreach ( $subs_results as $sub ) { 
  154. if ( $form_id != $sub['form_id'] ) { 
  155. $form_id = $sub['form_id']; 
  156. $number = 1; 
  157. $converted = get_option( 'nf_converted_subs' ); 
  158. if ( empty( $converted ) ) 
  159. $converted = array(); 
  160.  
  161. if ( ! in_array( $sub['id'], $converted ) ) { 
  162. $convert_subs->convert( $sub, $number ); 
  163.  
  164. $converted[] = $sub['id']; 
  165. update_option( 'nf_converted_subs', $converted ); 
  166. $number++; 
  167. update_option( 'nf_convert_subs_num', $number ); 
  168.  
  169. $step++; 
  170.  
  171. $redirect = add_query_arg( array( 
  172. 'page' => 'nf-upgrades',  
  173. 'nf-upgrade' => 'upgrade_subs_to_cpt',  
  174. 'step' => $step,  
  175. 'custom' => $number,  
  176. 'total' => $total,  
  177. 'form_id' => $form_id 
  178. ), admin_url( 'index.php' ) ); 
  179. wp_redirect( $redirect ); exit; 
  180.  
  181. } else { 
  182. update_option( 'nf_convert_subs_step', 'complete' ); 
  183. delete_option( 'nf_convert_subs_num' ); 
  184. wp_redirect( admin_url( 'index.php?page=nf-about' ) ); exit; 
  185. add_action( 'nf_upgrade_subs_to_cpt', 'nf_v27_upgrade_subs_to_cpt' ); 
  186.  
  187. /** 
  188. * Keep our upgrade notice closed. 
  189. * 
  190. * @since 2.7 
  191. * @return void 
  192. */ 
  193. function nf_dismiss_upgrade_notice() { 
  194. update_option( 'nf_upgrade_notice', 'closed' ); 
  195. wp_redirect( esc_url_raw( remove_query_arg( 'nf_action' ) ) ); 
  196. exit; 
  197.  
  198. add_action( 'nf_dismiss_upgrade_notice', 'nf_dismiss_upgrade_notice' ); 
  199.  
  200.  
  201. /** 
  202. * Clearing out the old email favourite field and replacing it with the new version. 
  203. * 
  204. * @since 2.8.4 
  205. * @return void 
  206. */ 
  207. function nf_clear_old_favs() { 
  208. global $wpdb; 
  209.  
  210. $email_fav_updated = get_option( 'nf_email_fav_updated', false ); 
  211.  
  212. if ( $email_fav_updated ) 
  213. return false; 
  214.  
  215. nf_change_email_fav(); 
  216. nf_remove_old_email_settings(); 
  217. nf_change_state_dropdown_fav(); 
  218.  
  219. update_option( 'nf_email_fav_updated', true ); 
  220.  
  221. add_action( 'admin_init', 'nf_clear_old_favs' ); 
  222.  
  223. /** 
  224. * Remove old email "send to" settings from form fiels. 
  225. * 
  226. * @since 2.8.4 
  227. * @return void 
  228. */ 
  229. function nf_remove_old_email_settings( $form_id = '' ) { 
  230.  
  231. if ( '' == $form_id ) { 
  232. $forms = ninja_forms_get_all_forms( true ); 
  233.  
  234. if ( is_array( $forms ) ) { 
  235. foreach ( $forms as $form ) { 
  236. nf_remove_old_email_send_to( $form['id'] ); 
  237. } else { 
  238. nf_remove_old_email_send_to( $form_id ); 
  239.  
  240. /** 
  241. * Removes old email settings form a single form. 
  242. * 
  243. * @since 2.8.4 
  244. * @return void 
  245. */ 
  246. function nf_remove_old_email_send_to( $form_id ) { 
  247. if ( empty ( $form_id ) ) 
  248. return false; 
  249.  
  250. // Remove any "Admin mailto" settings we might have. 
  251. $form_row = ninja_forms_get_form_by_id( $form_id ); 
  252.  
  253. if ( isset ( $form_row['data']['admin_mailto'] ) ) { 
  254. unset ( $form_row['data']['admin_mailto'] ); 
  255.  
  256. $args = array( 
  257. 'update_array' => array( 
  258. 'data' => serialize( $form_row['data'] ),  
  259. ),  
  260. 'where' => array( 
  261. 'id' => $form_id,  
  262. ),  
  263. ); 
  264.  
  265. ninja_forms_update_form( $args ); 
  266.  
  267.  
  268. // Update any old email settings we have. 
  269. $fields = Ninja_Forms()->form( $form_id )->fields; 
  270.  
  271. // Create a notification for our user email 
  272. if ( ! empty ( $fields ) ) { 
  273. foreach ( $fields as $field_id => $field ) { 
  274. if ( isset ( $field['data']['send_email'] ) && $field['data']['send_email'] == 1 ) { 
  275. // Add this field to our $addresses variable. 
  276. unset( $field['data']['send_email'] ); 
  277. unset( $field['data']['replyto_email'] ); 
  278. unset( $field['data']['from_name'] ); 
  279.  
  280. $args = array( 
  281. 'update_array' => array( 
  282. 'data' => serialize( $field['data'] ),  
  283. ),  
  284. 'where' => array( 
  285. 'id' => $field_id,  
  286. ),  
  287. ); 
  288.  
  289. ninja_forms_update_field( $args ); 
  290.  
  291. /** 
  292. * Remove the old copy of our email defined field and replace it. 
  293. * 
  294. * @since 2.8.4 
  295. * @return void 
  296. */ 
  297. function nf_change_email_fav() { 
  298. global $wpdb; 
  299.  
  300. $email_address = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ".NINJA_FORMS_FAV_FIELDS_TABLE_NAME." WHERE name = %s AND row_type = 0", 'Email' ), ARRAY_A ); 
  301.  
  302. $sql = 'DELETE FROM `' . NINJA_FORMS_FAV_FIELDS_TABLE_NAME . '` WHERE name = "Email Address"'; 
  303.  
  304. $wpdb->query( $sql ); 
  305.  
  306. $sql = 'DELETE FROM `' . NINJA_FORMS_FAV_FIELDS_TABLE_NAME . '` WHERE name = "Email"'; 
  307.  
  308. $wpdb->query( $sql ); 
  309.  
  310. if ( isset ( $email_address['id'] ) && ! empty ( $email_address['id'] ) ) { 
  311. $sql = 'INSERT INTO `'.NINJA_FORMS_FAV_FIELDS_TABLE_NAME.'` (`id`, `row_type`, `type`, `order`, `data`, `name`) VALUES 
  312. (' . $email_address['id'] . ', 0, \'_text\', 0, \'a:25:{s:5:"label";s:5:"Email";s:9:"label_pos";s:5:"above";s:13:"default_value";s:0:"";s:4:"mask";s:0:"";s:10:"datepicker";s:1:"0";s:5:"email";s:1:"1";s:10:"send_email";s:1:"0";s:10:"from_email";s:1:"0";s:10:"first_name";s:1:"0";s:9:"last_name";s:1:"0";s:9:"from_name";s:1:"0";s:14:"user_address_1";s:1:"0";s:14:"user_address_2";s:1:"0";s:9:"user_city";s:1:"0";s:8:"user_zip";s:1:"0";s:10:"user_phone";s:1:"0";s:10:"user_email";s:1:"1";s:21:"user_info_field_group";s:1:"1";s:3:"req";s:1:"0";s:5:"class";s:0:"";s:9:"show_help";s:1:"0";s:9:"help_text";s:0:"";s:17:"calc_auto_include";s:1:"0";s:11:"calc_option";s:1:"0";s:11:"conditional";s:0:"";}\', \'Email\')'; 
  313. $wpdb->query($sql);  
  314.  
  315.  
  316. /** 
  317. * Fix a serialized array error with the state dropdown favourite field 
  318. *  
  319. * @since 2.8.4 
  320. * @return void 
  321. */ 
  322. function nf_change_state_dropdown_fav() { 
  323. global $wpdb; 
  324.  
  325. $state_dropdown = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ".NINJA_FORMS_FAV_FIELDS_TABLE_NAME." WHERE name = %s AND row_type = 0", 'State Dropdown' ), ARRAY_A ); 
  326.  
  327. $sql = 'DELETE FROM `' . NINJA_FORMS_FAV_FIELDS_TABLE_NAME . '` WHERE name = "State Dropdown"'; 
  328.  
  329. $wpdb->query( $sql ); 
  330.  
  331. $sql = 'INSERT INTO `'.NINJA_FORMS_FAV_FIELDS_TABLE_NAME.'` (`id`, `row_type`, `type`, `order`, `data`, `name`) VALUES 
  332. (' . $state_dropdown['id'] . ', 0, \'_list\', 0, \'a:10:{s:5:\"label\";s:14:\"State Dropdown\";s:9:\"label_pos\";s:4:\"left\";s:9:\"list_type\";s:8:\"dropdown\";s:10:\"multi_size\";s:1:\"5\";s:15:\"list_show_value\";s:1:\"1\";s:4:\"list\";a:1:{s:7:\"options\";a:51:{i:0;a:3:{s:5:\"label\";s:7:\"Alabama\";s:5:\"value\";s:2:\"AL\";s:8:\"selected\";s:1:\"0\";}i:1;a:3:{s:5:\"label\";s:6:\"Alaska\";s:5:\"value\";s:2:\"AK\";s:8:\"selected\";s:1:\"0\";}i:2;a:3:{s:5:\"label\";s:7:\"Arizona\";s:5:\"value\";s:2:\"AZ\";s:8:\"selected\";s:1:\"0\";}i:3;a:3:{s:5:\"label\";s:8:\"Arkansas\";s:5:\"value\";s:2:\"AR\";s:8:\"selected\";s:1:\"0\";}i:4;a:3:{s:5:\"label\";s:10:\"California\";s:5:\"value\";s:2:\"CA\";s:8:\"selected\";s:1:\"0\";}i:5;a:3:{s:5:\"label\";s:8:\"Colorado\";s:5:\"value\";s:2:\"CO\";s:8:\"selected\";s:1:\"0\";}i:6;a:3:{s:5:\"label\";s:11:\"Connecticut\";s:5:\"value\";s:2:\"CT\";s:8:\"selected\";s:1:\"0\";}i:7;a:3:{s:5:\"label\";s:8:\"Delaware\";s:5:\"value\";s:2:\"DE\";s:8:\"selected\";s:1:\"0\";}i:8;a:3:{s:5:\"label\";s:20:\"District of Columbia\";s:5:\"value\";s:2:\"DC\";s:8:\"selected\";s:1:\"0\";}i:9;a:3:{s:5:\"label\";s:7:\"Florida\";s:5:\"value\";s:2:\"FL\";s:8:\"selected\";s:1:\"0\";}i:10;a:3:{s:5:\"label\";s:7:\"Georgia\";s:5:\"value\";s:2:\"GA\";s:8:\"selected\";s:1:\"0\";}i:11;a:3:{s:5:\"label\";s:6:\"Hawaii\";s:5:\"value\";s:2:\"HI\";s:8:\"selected\";s:1:\"0\";}i:12;a:3:{s:5:\"label\";s:5:\"Idaho\";s:5:\"value\";s:2:\"ID\";s:8:\"selected\";s:1:\"0\";}i:13;a:3:{s:5:\"label\";s:8:\"Illinois\";s:5:\"value\";s:2:\"IL\";s:8:\"selected\";s:1:\"0\";}i:14;a:3:{s:5:\"label\";s:7:\"Indiana\";s:5:\"value\";s:2:\"IN\";s:8:\"selected\";s:1:\"0\";}i:15;a:3:{s:5:\"label\";s:4:\"Iowa\";s:5:\"value\";s:2:\"IA\";s:8:\"selected\";s:1:\"0\";}i:16;a:3:{s:5:\"label\";s:6:\"Kansas\";s:5:\"value\";s:2:\"KS\";s:8:\"selected\";s:1:\"0\";}i:17;a:3:{s:5:\"label\";s:8:\"Kentucky\";s:5:\"value\";s:2:\"KY\";s:8:\"selected\";s:1:\"0\";}i:18;a:3:{s:5:\"label\";s:9:\"Louisiana\";s:5:\"value\";s:2:\"LA\";s:8:\"selected\";s:1:\"0\";}i:19;a:3:{s:5:\"label\";s:5:\"Maine\";s:5:\"value\";s:2:\"ME\";s:8:\"selected\";s:1:\"0\";}i:20;a:3:{s:5:\"label\";s:8:\"Maryland\";s:5:\"value\";s:2:\"MD\";s:8:\"selected\";s:1:\"0\";}i:21;a:3:{s:5:\"label\";s:13:\"Massachusetts\";s:5:\"value\";s:2:\"MA\";s:8:\"selected\";s:1:\"0\";}i:22;a:3:{s:5:\"label\";s:8:\"Michigan\";s:5:\"value\";s:2:\"MI\";s:8:\"selected\";s:1:\"0\";}i:23;a:3:{s:5:\"label\";s:9:\"Minnesota\";s:5:\"value\";s:2:\"MN\";s:8:\"selected\";s:1:\"0\";}i:24;a:3:{s:5:\"label\";s:11:\"Mississippi\";s:5:\"value\";s:2:\"MS\";s:8:\"selected\";s:1:\"0\";}i:25;a:3:{s:5:\"label\";s:8:\"Missouri\";s:5:\"value\";s:2:\"MO\";s:8:\"selected\";s:1:\"0\";}i:26;a:3:{s:5:\"label\";s:7:\"Montana\";s:5:\"value\";s:2:\"MT\";s:8:\"selected\";s:1:\"0\";}i:27;a:3:{s:5:\"label\";s:8:\"Nebraska\";s:5:\"value\";s:2:\"NE\";s:8:\"selected\";s:1:\"0\";}i:28;a:3:{s:5:\"label\";s:6:\"Nevada\";s:5:\"value\";s:2:\"NV\";s:8:\"selected\";s:1:\"0\";}i:29;a:3:{s:5:\"label\"3s:13:\"New Hampshire\";s:5:\"value\";s:2:\"NH\";s:8:\"selected\";s:1:\"0\";}i:30;a:3:{s:5:\"label\";s:10:\"New Jersey\";s:5:\"value\";s:2:\"NJ\";s:8:\"selected\";s:1:\"0\";}i:31;a:3:{s:5:\"label\";s:10:\"New Mexico\";s:5:\"value\";s:2:\"NM\";s:8:\"selected\";s:1:\"0\";}i:32;a:3:{s:5:\"label\";s:8:\"New York\";s:5:\"value\";s:2:\"NY\";s:8:\"selected\";s:1:\"0\";}i:33;a:3:{s:5:\"label\";s:14:\"North Carolina\";s:5:\"value\";s:2:\"NC\";s:8:\"selected\";s:1:\"0\";}i:34;a:3:{s:5:\"label\";s:12:\"North Dakota\";s:5:\"value\";s:2:\"ND\";s:8:\"selected\";s:1:\"0\";}i:35;a:3:{s:5:\"label\";s:4:\"Ohio\";s:5:\"value\";s:2:\"OH\";s:8:\"selected\";s:1:\"0\";}i:36;a:3:{s:5:\"label\";s:8:\"Oklahoma\";s:5:\"value\";s:2:\"OK\";s:8:\"selected\";s:1:\"0\";}i:37;a:3:{s:5:\"label\";s:6:\"Oregon\";s:5:\"value\";s:2:\"OR\";s:8:\"selected\";s:1:\"0\";}i:38;a:3:{s:5:\"label\";s:12:\"Pennsylvania\";s:5:\"value\";s:2:\"PA\";s:8:\"selected\";s:1:\"0\";}i:39;a:3:{s:5:\"label\";s:12:\"Rhode Island\";s:5:\"value\";s:2:\"RI\";s:8:\"selected\";s:1:\"0\";}i:40;a:3:{s:5:\"label\";s:14:\"South Carolina\";s:5:\"value\";s:2:\"SC\";s:8:\"selected\";s:1:\"0\";}i:41;a:3:{s:5:\"label\";s:12:\"South Dakota\";s:5:\"value\";s:2:\"SD\";s:8:\"selected\";s:1:\"0\";}i:42;a:3:{s:5:\"label\";s:9:\"Tennessee\";s:5:\"value\";s:2:\"TN\";s:8:\"selected\";s:1:\"0\";}i:43;a:3:{s:5:\"label\";s:5:\"Texas\";s:5:\"value\";s:2:\"TX\";s:8:\"selected\";s:1:\"0\";}i:44;a:3:{s:5:\"label\";s:4:\"Utah\";s:5:\"value\";s:2:\"UT\";s:8:\"selected\";s:1:\"0\";}i:45;a:3:{s:5:\"label\";s:7:\"Vermont\";s:5:\"value\";s:2:\"VT\";s:8:\"selected\";s:1:\"0\";}i:46;a:3:{s:5:\"label\";s:8:\"Virginia\";s:5:\"value\";s:2:\"VA\";s:8:\"selected\";s:1:\"0\";}i:47;a:3:{s:5:\"label\";s:10:\"Washington\";s:5:\"value\";s:2:\"WA\";s:8:\"selected\";s:1:\"0\";}i:48;a:3:{s:5:\"label\";s:13:\"West Virginia\";s:5:\"value\";s:2:\"WV\";s:8:\"selected\";s:1:\"0\";}i:49;a:3:{s:5:\"label\";s:9:\"Wisconsin\";s:5:\"value\";s:2:\"WI\";s:8:\"selected\";s:1:\"0\";}i:50;a:3:{s:5:\"label\";s:7:\"Wyoming\";s:5:\"value\";s:2:\"WY\";s:8:\"selected\";s:1:\"0\";}}}s:3:\"req\";s:1:\"0\";s:5:\"class\";s:0:\"\";s:9:\"show_help\";s:1:\"0\";s:9:\"help_text\";s:0:\"\";}\', \'State Dropdown\')'; 
  333.  
  334. $wpdb->query( $sql ); 
  335.  
  336. /** 
  337. * Check our option to see if we've updated all of our forms. 
  338. * If we haven't, loop through all of our forms and see if any need to be updated. 
  339. * 
  340. * @since 2.9 
  341. * @return void 
  342. */ 
  343. function nf_29_update_all_form_settings_check() { 
  344.  
  345. $forms_conversion_complete = get_option( 'nf_convert_forms_complete', false ); 
  346.  
  347. if ( $forms_conversion_complete ) 
  348. return false; 
  349.  
  350. $url = admin_url( 'index.php?page=nf-upgrade-handler' ); 
  351.  
  352. ?> 
  353. <script type="text/javascript"> 
  354. jQuery(document).ready(function() { 
  355. window.location.href = "<?php echo $url; ?>"; 
  356. } ); 
  357. </script> 
  358. <?php 
  359.  
  360. add_action( 'nf_admin_before_form_list', 'nf_29_update_all_form_settings_check' ); 
.