/deprecated/ninja-forms.php

  1. <?php 
  2. // Exit if accessed directly 
  3. if ( ! defined( 'ABSPATH' ) ) 
  4. exit; 
  5.  
  6. class Ninja_Forms { 
  7.  
  8.  
  9. /** 
  10. * @var Ninja_Forms 
  11. * @since 2.7 
  12. */ 
  13. private static $instance; 
  14.  
  15. /** 
  16. * @var registered_notification_types 
  17. */ 
  18. var $notification_types = array(); 
  19.  
  20. /** 
  21. * Main Ninja_Forms Instance 
  22. * 
  23. * Insures that only one instance of Ninja_Forms exists in memory at any one 
  24. * time. Also prevents needing to define globals all over the place. 
  25. * 
  26. * @since 2.7 
  27. * @static 
  28. * @staticvar array $instance 
  29. * @return The highlander Ninja_Forms 
  30. */ 
  31. public static function instance() { 
  32. if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Ninja_Forms ) ) { 
  33. self::$instance = new Ninja_Forms; 
  34. self::$instance->setup_constants(); 
  35. self::$instance->includes(); 
  36.  
  37. // Start our submissions custom post type class 
  38. self::$instance->subs_cpt = new NF_Subs_CPT(); 
  39.  
  40. // Add our registration class object 
  41. self::$instance->register = new NF_Register(); 
  42.  
  43. // The forms variable won't be interacted with directly. 
  44. // Instead, the forms() methods will act as wrappers for it. 
  45. self::$instance->forms = new NF_Forms(); 
  46.  
  47. // Our session manager wrapper class 
  48. self::$instance->session = new NF_Session(); 
  49.  
  50. register_activation_hook( __FILE__, 'ninja_forms_activation' ); 
  51. add_action( 'plugins_loaded', array( self::$instance, 'load_lang' ) ); 
  52. add_action( 'init', array( self::$instance, 'init' ), 5 ); 
  53. add_action( 'admin_init', array( self::$instance, 'admin_init' ), 5 ); 
  54. add_action( 'update_option_ninja_forms_settings', array( self::$instance, 'refresh_plugin_settings' ), 10 ); 
  55. // add_action( 'admin_head', array( self::$instance, 'admin_head' ) ); 
  56. add_action( 'admin_notices', array( self::$instance, 'admin_notice' ) ); 
  57.  
  58. return self::$instance; 
  59.  
  60. /** 
  61. * Run all of our plugin stuff on init. 
  62. * This allows filters and actions to be used by third-party classes. 
  63. * 
  64. * @since 2.7 
  65. * @return void 
  66. */ 
  67. public function init() { 
  68. // The settings variable will hold our plugin settings. 
  69. self::$instance->plugin_settings = self::$instance->get_plugin_settings(); 
  70.  
  71. // The subs variable won't be interacted with directly. 
  72. // Instead, the subs() methods will act as wrappers for it. 
  73. self::$instance->subs = new NF_Subs(); 
  74.  
  75. // Get our notifications up and running. 
  76. self::$instance->notifications = new NF_Notifications(); 
  77.  
  78. // Get our step processor up and running. 
  79. // We only need this in the admin. 
  80. if ( is_admin() ) { 
  81. self::$instance->step_processing = new NF_Step_Processing(); 
  82. self::$instance->download_all_subs = new NF_Download_All_Subs(); 
  83.  
  84. // Fire our Ninja Forms init action. 
  85. // This will allow other plugins to register items to the instance. 
  86. do_action( 'nf_init', self::$instance ); 
  87.  
  88. /** 
  89. * Run all of our plugin stuff on admin init. 
  90. * 
  91. * @since 2.7.4 
  92. * @return void 
  93. */ 
  94. public function admin_init() { 
  95. // Check and update our version number. 
  96. self::$instance->update_version_number(); 
  97.  
  98. // Add our "Add Form" button and modal to the tinyMCE editor 
  99. self::$instance->add_form_button = new NF_Admin_AddFormModal(); 
  100.  
  101. // Get our admin notices up and running. 
  102. self::$instance->notices = new NF_Notices(); 
  103.  
  104. // Register our admin scripts 
  105. self::$instance->register_admin_scripts(); 
  106.  
  107. // Fire our Ninja Forms init action. 
  108. do_action( 'nf_admin_init', self::$instance ); 
  109.  
  110. /** 
  111. * Run some admin stuff on admin_notices hook. 
  112. * 
  113. * @since 2.9 
  114. * @return void 
  115. */ 
  116. public function admin_notice() { 
  117. // Notices filter and run the notices function. 
  118. $admin_notices = apply_filters( 'nf_admin_notices', array() ); 
  119. self::$instance->notices->admin_notice( $admin_notices ); 
  120.  
  121. /** 
  122. * Throw error on object clone 
  123. * 
  124. * The whole idea of the singleton design pattern is that there is a single 
  125. * object therefore, we don't want the object to be cloned. 
  126. * 
  127. * @since 2.7 
  128. * @access protected 
  129. * @return void 
  130. */ 
  131. public function __clone() { 
  132. // Cloning instances of the class is forbidden 
  133. _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'ninja-forms' ), '2.8' ); 
  134.  
  135. /** 
  136. * Disable unserializing of the class 
  137. * 
  138. * @since 2.7 
  139. * @access protected 
  140. * @return void 
  141. */ 
  142. public function __wakeup() { 
  143. // Unserializing instances of the class is forbidden 
  144. _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'ninja-forms' ), '2.8' ); 
  145.  
  146. /** 
  147. * Function that acts as a wrapper for our individual notification objects. 
  148. * It checks to see if an object exists for this notification id. 
  149. * If it does, it returns that object. Otherwise, it creates a new one and returns it. 
  150. * 
  151. * @access public 
  152. * @param int $n_id 
  153. * @since 2.8 
  154. * @return object self::$instance->$n_var 
  155. */ 
  156. public function notification( $n_id = '' ) { 
  157. // Bail if we don't get a notification id. 
  158. if ( '' == $n_id ) 
  159. return false; 
  160.  
  161. $n_var = 'notification_' . $n_id; 
  162. // Check to see if an object for this notification already exists. 
  163. // Create one if it doesn't exist. 
  164. if ( ! isset ( self::$instance->$n_var ) ) 
  165. self::$instance->$n_var = new NF_Notification( $n_id ); 
  166.  
  167. return self::$instance->$n_var; 
  168.  
  169. /** 
  170. * Function that acts as a wrapper for our individual sub objects. 
  171. * It checks to see if an object exists for this sub id. 
  172. * If it does, it returns that object. Otherwise, it creates a new one and returns it. 
  173. * 
  174. * @access public 
  175. * @param int $sub_id 
  176. * @since 2.7 
  177. * @return object self::$instance->$sub_var 
  178. */ 
  179. public function sub( $sub_id = '' ) { 
  180. // Bail if we don't get a sub id. 
  181. if ( $sub_id == '' ) 
  182. return false; 
  183.  
  184. $sub_var = 'sub_' . $sub_id; 
  185. // Check to see if an object for this sub already exists. 
  186. // Create one if it doesn't exist. 
  187. if ( ! isset( self::$instance->$sub_var ) ) 
  188. self::$instance->$sub_var = new NF_Sub( $sub_id ); 
  189.  
  190. return self::$instance->$sub_var; 
  191.  
  192. /** 
  193. * Function that acts as a wrapper for our subs_var - NF_Subs() class. 
  194. * It doesn't set a sub_id and can be used to interact with methods that affect mulitple submissions 
  195. * 
  196. * @access public 
  197. * @since 2.7 
  198. * @return object self::$instance->subs_var 
  199. */ 
  200. public function subs() { 
  201. return self::$instance->subs; 
  202.  
  203. /** 
  204. * Function that acts as a wrapper for our form_var - NF_Form() class. 
  205. * It sets the form_id and then returns the instance, which is now using the 
  206. * proper form id 
  207. * 
  208. * @access public 
  209. * @param int $form_id 
  210. * @since 2.9.11 
  211. * @return object self::$instance->form_var 
  212. */ 
  213. public function form( $form_id = '' ) { 
  214. // Bail if we don't get a form id. 
  215.  
  216. $form_var = 'form_' . $form_id; 
  217. // Check to see if an object for this form already exists in memory. If it does, return it. 
  218. if ( isset( self::$instance->$form_var ) ) 
  219. return self::$instance->$form_var; 
  220.  
  221. // Check to see if we have a transient object stored for this form. 
  222. if ( is_object ( ( $form_obj = get_transient( 'nf_form_' . $form_id ) ) ) ) { 
  223. self::$instance->$form_var = $form_obj; 
  224. } else { 
  225. // Create a new form object for this form. 
  226. self::$instance->$form_var = new NF_Form( $form_id ); 
  227. // Save it into a transient. 
  228. set_transient( 'nf_form_' . $form_id, self::$instance->$form_var, DAY_IN_SECONDS ); 
  229.  
  230. return self::$instance->$form_var; 
  231.  
  232. /** 
  233. * Function that acts as a wrapper for our forms_var - NF_Form() class. 
  234. * 
  235. * @access public 
  236. * @since 2.9 
  237. * @return object self::$instance->forms_var 
  238. */ 
  239. public function forms( $form_id = '' ) { 
  240. return self::$instance->forms; 
  241.  
  242. /** 
  243. * Setup plugin constants 
  244. * 
  245. * @access private 
  246. * @since 2.7 
  247. * @return void 
  248. */ 
  249. private function setup_constants() { 
  250. global $wpdb; 
  251.  
  252. // Plugin version 
  253. if ( ! defined( 'NF_PLUGIN_VERSION' ) ) 
  254. define( 'NF_PLUGIN_VERSION', '3.1.1' ); 
  255.  
  256. // Plugin Folder Path 
  257. if ( ! defined( 'NF_PLUGIN_DIR' ) ) 
  258. define( 'NF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 
  259.  
  260. // Plugin Folder URL 
  261. if ( ! defined( 'NF_PLUGIN_URL' ) ) 
  262. define( 'NF_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 
  263.  
  264. // Plugin Root File 
  265. if ( ! defined( 'NF_PLUGIN_FILE' ) ) 
  266. define( 'NF_PLUGIN_FILE', __FILE__ ); 
  267.  
  268. // Objects table name 
  269. if ( ! defined( 'NF_OBJECTS_TABLE_NAME') ) 
  270. define( 'NF_OBJECTS_TABLE_NAME', $wpdb->prefix . 'nf_objects' ); 
  271.  
  272. // Meta table name 
  273. if ( ! defined( 'NF_OBJECT_META_TABLE_NAME' ) ) 
  274. define( 'NF_OBJECT_META_TABLE_NAME', $wpdb->prefix . 'nf_objectmeta' ); 
  275.  
  276. // Relationships table name 
  277. if ( ! defined( 'NF_OBJECT_RELATIONSHIPS_TABLE_NAME' ) ) 
  278. define( 'NF_OBJECT_RELATIONSHIPS_TABLE_NAME', $wpdb->prefix . 'nf_relationships' ); 
  279.  
  280. /** Legacy Definitions */ 
  281.  
  282. // Ninja Forms debug mode 
  283. if ( ! defined( 'NINJA_FORMS_JS_DEBUG' ) ) 
  284. define( 'NINJA_FORMS_JS_DEBUG', false ); 
  285.  
  286. // Ninja Forms plugin directory 
  287. if ( ! defined( 'NINJA_FORMS_DIR' ) ) 
  288. define( 'NINJA_FORMS_DIR', NF_PLUGIN_DIR ); 
  289.  
  290. // Ninja Forms plugin url 
  291. if ( ! defined( 'NINJA_FORMS_URL' ) ) 
  292. define( 'NINJA_FORMS_URL', NF_PLUGIN_URL ); 
  293.  
  294. // Ninja Forms Version 
  295. if ( ! defined( 'NINJA_FORMS_VERSION' ) ) 
  296. define( 'NINJA_FORMS_VERSION', NF_PLUGIN_VERSION ); 
  297.  
  298. // Ninja Forms table name 
  299. if ( ! defined( 'NINJA_FORMS_TABLE_NAME' ) ) 
  300. define( 'NINJA_FORMS_TABLE_NAME', $wpdb->prefix . 'ninja_forms' ); 
  301.  
  302. // Fields table name 
  303. if ( ! defined( 'NINJA_FORMS_FIELDS_TABLE_NAME' ) ) 
  304. define( 'NINJA_FORMS_FIELDS_TABLE_NAME', $wpdb->prefix . 'ninja_forms_fields' ); 
  305.  
  306. // Fav fields table name 
  307. if ( ! defined( 'NINJA_FORMS_FAV_FIELDS_TABLE_NAME' ) ) 
  308. define( 'NINJA_FORMS_FAV_FIELDS_TABLE_NAME', $wpdb->prefix . 'ninja_forms_fav_fields' ); 
  309.  
  310. // Subs table name 
  311. if ( ! defined( 'NINJA_FORMS_SUBS_TABLE_NAME' ) ) 
  312. define( 'NINJA_FORMS_SUBS_TABLE_NAME', $wpdb->prefix . 'ninja_forms_subs' ); 
  313.  
  314. /** 
  315. * Include our Class files 
  316. * 
  317. * @access private 
  318. * @since 2.7 
  319. * @return void 
  320. */ 
  321. private function includes() { 
  322. // Include our session manager 
  323. require_once( NF_PLUGIN_DIR . 'classes/session.php' ); 
  324. // Include our sub object. 
  325. require_once( NF_PLUGIN_DIR . 'classes/sub.php' ); 
  326. // Include our subs object. 
  327. require_once( NF_PLUGIN_DIR . 'classes/subs.php' ); 
  328. // Include our subs CPT. 
  329. require_once( NF_PLUGIN_DIR . 'classes/subs-cpt.php' ); 
  330. // Include our form object. 
  331. require_once( NF_PLUGIN_DIR . 'classes/form.php' ); 
  332. // Include our form sobject. 
  333. require_once( NF_PLUGIN_DIR . 'classes/forms.php' ); 
  334. // Include our field, notification, and sidebar registration class. 
  335. require_once( NF_PLUGIN_DIR . 'classes/register.php' ); 
  336. // Include our 'nf_action' watcher. 
  337. require_once( NF_PLUGIN_DIR . 'includes/actions.php' ); 
  338. // Include our single notification object 
  339. require_once( NF_PLUGIN_DIR . 'classes/notification.php' ); 
  340. // Include our notifications object 
  341. require_once( NF_PLUGIN_DIR . 'classes/notifications.php' ); 
  342. // Include our notification table object 
  343. require_once( NF_PLUGIN_DIR . 'classes/notifications-table.php' ); 
  344. // Include our base notification type 
  345. require_once( NF_PLUGIN_DIR . 'classes/notification-base-type.php' ); 
  346. // Include add form button and modal 
  347. require_once( NF_PLUGIN_DIR . 'classes/add-form-modal.php' ); 
  348.  
  349. if ( is_admin () ) { 
  350. // Include our step processing stuff if we're in the admin. 
  351. require_once( NF_PLUGIN_DIR . 'includes/admin/step-processing.php' ); 
  352. require_once( NF_PLUGIN_DIR . 'classes/step-processing.php' ); 
  353.  
  354. // Include our download all submissions php files 
  355. require_once( NF_PLUGIN_DIR . 'classes/download-all-subs.php' ); 
  356.  
  357.  
  358. $upgraded_from = get_option( 'nf_version_upgraded_from', FALSE ); 
  359. if( $upgraded_from && version_compare( $upgraded_from, '2.9', '<=') ) { 
  360.  
  361. // Include Upgrade Base Class 
  362. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/class-upgrade.php'); 
  363.  
  364. // Include Upgrades 
  365. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php' ); 
  366. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php' ); 
  367. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/convert-forms-reset.php' ); 
  368.  
  369. // Include Upgrade Handler 
  370. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-handler-page.php'); 
  371. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/class-upgrade-handler.php'); 
  372.  
  373. // Include our upgrade files. 
  374. require_once( NF_PLUGIN_DIR . 'includes/admin/welcome.php' ); 
  375.  
  376. // Include deprecated functions and filters. 
  377. require_once( NF_PLUGIN_DIR . 'includes/deprecated.php' ); 
  378.  
  379. /** Legacy includes */ 
  380.  
  381. /** Require Core Files */ 
  382. require_once( NINJA_FORMS_DIR . "/includes/ninja-settings.php" ); 
  383. require_once( NINJA_FORMS_DIR . "/includes/database.php" ); 
  384. require_once( NINJA_FORMS_DIR . "/includes/functions.php" ); 
  385. require_once( NINJA_FORMS_DIR . "/includes/activation.php" ); 
  386. require_once( NINJA_FORMS_DIR . "/includes/register.php" ); 
  387. require_once( NINJA_FORMS_DIR . "/includes/shortcode.php" ); 
  388. require_once( NINJA_FORMS_DIR . "/includes/widget.php" ); 
  389. require_once( NINJA_FORMS_DIR . "/includes/field-type-groups.php" ); 
  390. require_once( NINJA_FORMS_DIR . "/includes/eos.class.php" ); 
  391. require_once( NINJA_FORMS_DIR . "/includes/from-setting-check.php" ); 
  392. require_once( NINJA_FORMS_DIR . "/includes/reply-to-check.php" ); 
  393. require_once( NINJA_FORMS_DIR . "/includes/import-export.php" ); 
  394.  
  395. require_once( NINJA_FORMS_DIR . "/includes/display/scripts.php" ); 
  396. require_once( NINJA_FORMS_DIR . "/includes/display/upgrade-functions.php" ); 
  397.  
  398. // Include Processing Functions if a form has been submitted. 
  399. require_once( NINJA_FORMS_DIR . "/includes/display/processing/class-ninja-forms-processing.php" ); 
  400. require_once( NINJA_FORMS_DIR . "/includes/display/processing/class-display-loading.php" ); 
  401. require_once( NINJA_FORMS_DIR . "/includes/display/processing/pre-process.php" ); 
  402. require_once( NINJA_FORMS_DIR . "/includes/display/processing/process.php" ); 
  403. require_once( NINJA_FORMS_DIR . "/includes/display/processing/post-process.php" ); 
  404. require_once( NINJA_FORMS_DIR . "/includes/display/processing/save-sub.php" ); 
  405. require_once( NINJA_FORMS_DIR . "/includes/display/processing/filter-msgs.php" ); 
  406. require_once( NINJA_FORMS_DIR . "/includes/display/processing/fields-pre-process.php" ); 
  407. require_once( NINJA_FORMS_DIR . "/includes/display/processing/fields-process.php" ); 
  408. require_once( NINJA_FORMS_DIR . "/includes/display/processing/fields-post-process.php" ); 
  409. require_once( NINJA_FORMS_DIR . "/includes/display/processing/req-fields-pre-process.php" ); 
  410. require_once( NINJA_FORMS_DIR . "/includes/display/processing/honeypot.php" ); 
  411.  
  412. //Display Form Functions 
  413. require_once( NINJA_FORMS_DIR . "/includes/display/form/display-form.php" ); 
  414. require_once( NINJA_FORMS_DIR . "/includes/display/form/not-logged-in.php" ); 
  415. require_once( NINJA_FORMS_DIR . "/includes/display/fields/display-fields.php" ); 
  416. require_once( NINJA_FORMS_DIR . "/includes/display/form/response-message.php" ); 
  417. require_once( NINJA_FORMS_DIR . "/includes/display/fields/label.php" ); 
  418. require_once( NINJA_FORMS_DIR . "/includes/display/fields/help.php" ); 
  419. require_once( NINJA_FORMS_DIR . "/includes/display/fields/desc.php" ); 
  420. require_once( NINJA_FORMS_DIR . "/includes/display/form/form-title.php" ); 
  421. require_once( NINJA_FORMS_DIR . "/includes/display/fields/field-error-message.php" ); 
  422. require_once( NINJA_FORMS_DIR . "/includes/display/form/form-wrap.php" ); 
  423. require_once( NINJA_FORMS_DIR . "/includes/display/form/form-cont.php" ); 
  424. require_once( NINJA_FORMS_DIR . "/includes/display/form/fields-wrap.php" ); 
  425. require_once( NINJA_FORMS_DIR . "/includes/display/form/required-label.php" ); 
  426. require_once( NINJA_FORMS_DIR . "/includes/display/form/open-form-tag.php" ); 
  427. require_once( NINJA_FORMS_DIR . "/includes/display/form/close-form-tag.php" ); 
  428. require_once( NINJA_FORMS_DIR . "/includes/display/form/hidden-fields.php" ); 
  429. require_once( NINJA_FORMS_DIR . "/includes/display/form/form-visibility.php" ); 
  430. require_once( NINJA_FORMS_DIR . "/includes/display/form/sub-limit.php" ); 
  431. require_once( NINJA_FORMS_DIR . "/includes/display/form/nonce.php" ); 
  432. require_once( NINJA_FORMS_DIR . "/includes/display/form/honeypot.php" ); 
  433. require_once( NINJA_FORMS_DIR . "/includes/display/fields/restore-progress.php" ); 
  434. require_once( NINJA_FORMS_DIR . "/includes/display/fields/inside-label-hidden.php" ); 
  435. require_once( NINJA_FORMS_DIR . "/includes/display/fields/field-type.php" ); 
  436. require_once( NINJA_FORMS_DIR . "/includes/display/fields/default-value-filter.php" ); 
  437. require_once( NINJA_FORMS_DIR . "/includes/display/fields/calc-field-class.php" ); 
  438. require_once( NINJA_FORMS_DIR . "/includes/display/fields/clear-complete.php" ); 
  439.  
  440.  
  441. //Require EDD autoupdate file 
  442. if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) { 
  443. // load our custom updater if it doesn't already exist 
  444. require_once(NINJA_FORMS_DIR."/includes/EDD_SL_Plugin_Updater.php"); 
  445.  
  446. require_once( NINJA_FORMS_DIR . "/includes/class-extension-updater.php" ); 
  447.  
  448. require_once( NINJA_FORMS_DIR . "/includes/admin/scripts.php" ); 
  449. require_once( NINJA_FORMS_DIR . "/includes/admin/sidebar.php" ); 
  450. require_once( NINJA_FORMS_DIR . "/includes/admin/tabs.php" ); 
  451. require_once( NINJA_FORMS_DIR . "/includes/admin/post-metabox.php" ); 
  452.  
  453. require_once( NINJA_FORMS_DIR . "/includes/admin/ajax.php" ); 
  454. require_once( NINJA_FORMS_DIR . "/includes/admin/admin.php" ); 
  455. require_once( NINJA_FORMS_DIR . "/includes/admin/sidebar-fields.php" ); 
  456. require_once( NINJA_FORMS_DIR . "/includes/admin/display-screen-options.php" ); 
  457. require_once( NINJA_FORMS_DIR . "/includes/admin/register-screen-options.php" ); 
  458. require_once( NINJA_FORMS_DIR . "/includes/admin/register-screen-help.php" ); 
  459. require_once( NINJA_FORMS_DIR . "/includes/admin/output-tab-metabox.php" ); 
  460. require_once( NINJA_FORMS_DIR . "/includes/admin/form-preview.php" ); 
  461. require_once( NINJA_FORMS_DIR . "/classes/notices-class.php" ); 
  462. require_once( NINJA_FORMS_DIR . "/includes/admin/notices.php" ); 
  463.  
  464. //Edit Field Functions 
  465. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/edit-field.php" ); 
  466. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/label.php" ); 
  467. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/placeholder.php" ); 
  468. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/hr.php" ); 
  469. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/req.php" ); 
  470. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/custom-class.php" ); 
  471. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/help.php" ); 
  472. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/desc.php" ); 
  473. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/li.php" ); 
  474. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/remove-button.php" ); 
  475. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/save-button.php" ); 
  476. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/calc.php" ); 
  477. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/user-info-fields.php" ); 
  478. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/post-meta-values.php" ); 
  479. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/input-limit.php" ); 
  480. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/sub-settings.php" ); 
  481. require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/autocomplete-off.php" ); 
  482.  
  483. /** * * * ninja-forms - Main Form Editing Page 
  484.   
  485. /** Tabs */ 
  486.  
  487. /** Form List */ 
  488. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/form-list/form-list.php" ); 
  489.  
  490. /** Form Settings */ 
  491. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/form-settings/form-settings.php" ); 
  492. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/form-settings/help.php" ); 
  493.  
  494. /** Field Settings */ 
  495. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/field-settings.php" ); 
  496. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/empty-rte.php" ); 
  497. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/edit-field-ul.php" ); 
  498. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/help.php" ); 
  499. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/def-fields.php" ); 
  500. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/fav-fields.php" ); 
  501. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/template-fields.php" ); 
  502. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/layout-fields.php" ); 
  503. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/user-info.php" ); 
  504. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/payment-fields.php" ); 
  505.  
  506. /** Form Preview */ 
  507. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/form-preview/form-preview.php" ); 
  508.  
  509.  
  510. /** * * * ninja-forms-settings - Settings Page 
  511.   
  512. /** Tabs */ 
  513.  
  514. /** General Settings */ 
  515. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-settings/tabs/general-settings/general-settings.php" ); 
  516.  
  517. /** Label Settings */ 
  518. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-settings/tabs/label-settings/label-settings.php" ); 
  519.  
  520. /** License Settings */ 
  521. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-settings/tabs/license-settings/license-settings.php" ); 
  522.  
  523.  
  524. /** * * * ninja-forms-impexp - Import / Export Page 
  525.   
  526. /** Tabs */ 
  527.  
  528. /** Import / Export Forms */ 
  529. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-impexp/tabs/impexp-forms/impexp-forms.php" ); 
  530.  
  531. /** Import / Export Fields */ 
  532. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-impexp/tabs/impexp-fields/impexp-fields.php" ); 
  533.  
  534. /** Import / Export Submissions */ 
  535. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-impexp/tabs/impexp-subs/impexp-subs.php" ); 
  536.  
  537. /** Backup / Restore */ 
  538. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-impexp/tabs/impexp-backup/impexp-backup.php" ); 
  539.  
  540. /** * * * ninja-forms-subs - Submissions Review Page 
  541.   
  542. /** Tabs */ 
  543.  
  544. /** * * ninja-forms-addons - Addons Manager Page 
  545.   
  546. /** Tabs */ 
  547.  
  548. /** Manage Addons */ 
  549. require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-addons/tabs/addons/addons.php" ); 
  550.  
  551. /** System Status */ 
  552. require_once( NINJA_FORMS_DIR . "/includes/classes/class-nf-system-status.php" ); 
  553.  
  554. /** Require Pre-Registered Fields */ 
  555. require_once( NINJA_FORMS_DIR . "/includes/fields/textbox.php" ); 
  556. require_once( NINJA_FORMS_DIR . "/includes/fields/checkbox.php" ); 
  557. require_once( NINJA_FORMS_DIR . "/includes/fields/list.php" ); 
  558. require_once( NINJA_FORMS_DIR . "/includes/fields/hidden.php" ); 
  559. require_once( NINJA_FORMS_DIR . "/includes/fields/organizer.php" ); 
  560. require_once( NINJA_FORMS_DIR . "/includes/fields/submit.php" ); 
  561. require_once( NINJA_FORMS_DIR . "/includes/fields/spam.php" ); 
  562. require_once( NINJA_FORMS_DIR . "/includes/fields/timed-submit.php" ); 
  563. require_once( NINJA_FORMS_DIR . "/includes/fields/hr.php" ); 
  564. require_once( NINJA_FORMS_DIR . "/includes/fields/desc.php" ); 
  565. require_once( NINJA_FORMS_DIR . "/includes/fields/textarea.php" ); 
  566. require_once( NINJA_FORMS_DIR . "/includes/fields/password.php" ); 
  567. require_once( NINJA_FORMS_DIR . "/includes/fields/rating.php" ); 
  568. require_once( NINJA_FORMS_DIR . "/includes/fields/calc.php" ); 
  569. require_once( NINJA_FORMS_DIR . "/includes/fields/country.php" ); 
  570. require_once( NINJA_FORMS_DIR . "/includes/fields/tax.php" ); 
  571. require_once( NINJA_FORMS_DIR . "/includes/fields/credit-card.php" ); 
  572. require_once( NINJA_FORMS_DIR . "/includes/fields/number.php" ); 
  573. require_once( NINJA_FORMS_DIR . "/includes/fields/recaptcha.php" ); 
  574.  
  575. require_once( NINJA_FORMS_DIR . "/includes/admin/save.php" ); 
  576.  
  577. /** 
  578. * Load our language files 
  579. * 
  580. * @access public 
  581. * @since 2.7 
  582. * @return void 
  583. */ 
  584. public function load_lang() { 
  585. /** Set our unique textdomain string */ 
  586. $textdomain = 'ninja-forms'; 
  587.  
  588. /** The 'plugin_locale' filter is also used by default in load_plugin_textdomain() */ 
  589. $locale = apply_filters( 'plugin_locale', get_locale(), $textdomain ); 
  590.  
  591. /** Set filter for WordPress languages directory */ 
  592. $wp_lang_dir = apply_filters( 
  593. 'ninja_forms_wp_lang_dir',  
  594. WP_LANG_DIR . '/ninja-forms/' . $textdomain . '-' . $locale . '.mo' 
  595. ); 
  596.  
  597. /** Translations: First, look in WordPress' "languages" folder = custom & update-secure! */ 
  598. load_textdomain( $textdomain, $wp_lang_dir ); 
  599.  
  600. /** Translations: Secondly, look in plugin's "lang" folder = default */ 
  601. $plugin_dir = trailingslashit( basename( dirname( dirname( __FILE__ ) ) ) ) . basename( dirname( __FILE__ ) ); 
  602. $lang_dir = apply_filters( 'ninja_forms_lang_dir', $plugin_dir . '/lang/' ); 
  603. load_plugin_textdomain( $textdomain, FALSE, $lang_dir ); 
  604.  
  605. /** 
  606. * Update our version number if necessary 
  607. * 
  608. * @access public 
  609. * @since 2.7 
  610. * @return void 
  611. */ 
  612. public function update_version_number() { 
  613. $plugin_settings = nf_get_settings(); 
  614.  
  615. if ( !isset ( $plugin_settings['version'] ) OR ( NF_PLUGIN_VERSION != $plugin_settings['version'] ) ) { 
  616. $plugin_settings['version'] = NF_PLUGIN_VERSION; 
  617. update_option( 'ninja_forms_settings', $plugin_settings ); 
  618.  
  619. /** 
  620. * Set Ninja_Forms()->session variable used for storing items in transient variables 
  621. * 
  622. * @access public 
  623. * @since 2.7 
  624. * @return string $t_id; 
  625. */ 
  626. public function set_transient_id() { 
  627. $transient_id = $this->session->get( 'nf_transient_id' ); 
  628. if ( ! $transient_id && ! is_admin() ) { 
  629. $transient_id = ninja_forms_random_string(); 
  630. // Make sure that our transient ID isn't currently in use. 
  631. while ( get_transient( $transient_id ) !== false ) { 
  632. $_id = ninja_forms_random_string(); 
  633. $this->session->set( 'nf_transient_id', $transient_id ); 
  634. return $transient_id; 
  635.  
  636. /** 
  637. * Get our plugin settings. 
  638. * 
  639. * @access public 
  640. * @since 2.9 
  641. * @return array $settings 
  642. */ 
  643. public function get_plugin_settings() { 
  644. $settings = apply_filters( "ninja_forms_settings", get_option( "ninja_forms_settings" ) ); 
  645.  
  646. $settings['date_format'] = isset ( $settings['date_format'] ) ? $settings['date_format'] : 'd/m/Y'; 
  647. $settings['currency_symbol'] = isset ( $settings['currency_symbol'] ) ? $settings['currency_symbol'] : '$'; 
  648. $settings['recaptcha_lang'] = isset ( $settings['recaptcha_lang'] ) ? $settings['recaptcha_lang'] : 'en'; 
  649. $settings['req_div_label'] = isset ( $settings['req_div_label'] ) ? $settings['req_div_label'] : sprintf( __( 'Fields marked with an %s*%s are required', 'ninja-forms' ), '<span class="ninja-forms-req-symbol">', '</span>' ); 
  650. $settings['req_field_symbol'] = isset ( $settings['req_field_symbol'] ) ? $settings['req_field_symbol'] : '<strong>*</strong>'; 
  651. $settings['req_error_label'] = isset ( $settings['req_error_label'] ) ? $settings['req_error_label'] : __( 'Please ensure all required fields are completed.', 'ninja-forms' ); 
  652. $settings['req_field_error'] = isset ( $settings['req_field_error'] ) ? $settings['req_field_error'] : __( 'This is a required field', 'ninja-forms' ); 
  653. $settings['spam_error'] = isset ( $settings['spam_error'] ) ? $settings['spam_error'] : __( 'Please answer the anti-spam question correctly.', 'ninja-forms' ); 
  654. $settings['honeypot_error'] = isset ( $settings['honeypot_error'] ) ? $settings['honeypot_error'] : __( 'Please leave the spam field blank.', 'ninja-forms' ); 
  655. $settings['timed_submit_error'] = isset ( $settings['timed_submit_error'] ) ? $settings['timed_submit_error'] : __( 'Please wait to submit the form.', 'ninja-forms' ); 
  656. $settings['javascript_error'] = isset ( $settings['javascript_error'] ) ? $settings['javascript_error'] : __( 'You cannot submit the form without Javascript enabled.', 'ninja-forms' ); 
  657. $settings['invalid_email'] = isset ( $settings['invalid_email'] ) ? $settings['invalid_email'] : __( 'Please enter a valid email address.', 'ninja-forms' ); 
  658. $settings['process_label'] = isset ( $settings['process_label'] ) ? $settings['process_label'] : __( 'Processing', 'ninja-forms' ); 
  659. $settings['password_mismatch'] = isset ( $settings['password_mismatch'] ) ? $settings['password_mismatch'] : __( 'The passwords provided do not match.', 'ninja-forms' ); 
  660.  
  661. $settings['date_format'] = apply_filters( 'ninja_forms_labels/date_format' , $settings['date_format'] ); 
  662. $settings['currency_symbol'] = apply_filters( 'ninja_forms_labels/currency_symbol' , $settings['currency_symbol'] ); 
  663. $settings['req_div_label'] = apply_filters( 'ninja_forms_labels/req_div_label' , $settings['req_div_label'] ); 
  664. $settings['req_field_symbol'] = apply_filters( 'ninja_forms_labels/req_field_symbol' , $settings['req_field_symbol'] ); 
  665. $settings['req_error_label'] = apply_filters( 'ninja_forms_labels/req_error_label' , $settings['req_error_label'] ); 
  666. $settings['req_field_error'] = apply_filters( 'ninja_forms_labels/req_field_error' , $settings['req_field_error'] ); 
  667. $settings['spam_error'] = apply_filters( 'ninja_forms_labels/spam_error' , $settings['spam_error'] ); 
  668. $settings['honeypot_error'] = apply_filters( 'ninja_forms_labels/honeypot_error' , $settings['honeypot_error'] ); 
  669. $settings['timed_submit_error'] = apply_filters( 'ninja_forms_labels/timed_submit_error' , $settings['timed_submit_error'] ); 
  670. $settings['javascript_error'] = apply_filters( 'ninja_forms_labels/javascript_error' , $settings['javascript_error'] ); 
  671. $settings['invalid_email'] = apply_filters( 'ninja_forms_labels/invalid_email' , $settings['invalid_email'] ); 
  672. $settings['process_label'] = apply_filters( 'ninja_forms_labels/process_label' , $settings['process_label'] ); 
  673. $settings['password_mismatch'] = apply_filters( 'ninja_forms_labels/password_mismatch' , $settings['password_mismatch'] ); 
  674.  
  675. return $settings; 
  676.  
  677. /** 
  678. * Refresh our plugin settings if we update the ninja_forms_settings option 
  679. * 
  680. * @access public 
  681. * @since 2.9 
  682. * @return void 
  683. */ 
  684. public function refresh_plugin_settings() { 
  685. self::$instance->plugin_settings = self::$instance->get_plugin_settings(); 
  686.  
  687. /** 
  688. * Register our admin scripts so that they can be enqueued later. 
  689. * @since 2.9.25 
  690. * @return void 
  691. */ 
  692. public function register_admin_scripts() { 
  693. if ( defined( 'NINJA_FORMS_JS_DEBUG' ) && NINJA_FORMS_JS_DEBUG ) { 
  694. $suffix = ''; 
  695. $src = 'dev'; 
  696. } else { 
  697. $suffix = '.min'; 
  698. $src = 'min'; 
  699.  
  700. wp_register_script( 'nf-admin-modal',  
  701. NF_PLUGIN_URL . 'assets/js/' . $src . '/admin-modal' . $suffix . '.js',  
  702. array( 'jquery', 'jquery-ui-core' ) ); 
  703.  
  704.  
  705. } // End Class 
  706.  
  707. /** 
  708. * The main function responsible for returning The Highlander Ninja_Forms 
  709. * Instance to functions everywhere. 
  710. * 
  711. * Use this function like you would a global variable, except without needing 
  712. * to declare the global. 
  713. * 
  714. * Example: <?php $nf = Ninja_Forms(); ?> 
  715. * 
  716. * @since 2.7 
  717. * @return object The Highlander Ninja_Forms Instance 
  718. */ 
  719. function Ninja_Forms() { 
  720. return Ninja_Forms::instance(); 
  721.  
  722. Ninja_Forms(); 
  723.  
  724. function nf_aff_link( $link ) { 
  725. $u_id = apply_filters( 'ninja_forms_affiliate_id', false ); 
  726. $u_id = get_option( 'nf_aff', $u_id ); 
  727. if ( $u_id ) { 
  728. $link = 'http://www.shareasale.com/r.cfm?u=' . $u_id . '&b=812237&m=63061&afftrack=&urllink=' . urlencode( $link ); 
  729. return $link; 
  730.  
  731. /** 
  732. |-------------------------------------------------------------------------- 
  733. | Ninja Forms THREE Upgrade 
  734. |-------------------------------------------------------------------------- 
  735. */ 
  736.  
  737. add_action( 'wp_ajax_nfThreeUpgrade_GetSerializedForm', 'nfThreeUpgrade_GetSerializedForm' ); 
  738. function nfThreeUpgrade_GetSerializedForm() { 
  739. $id = absint( $_POST[ 'formID' ] ); 
  740. $form_row = ninja_forms_serialize_form( $id ); 
  741. echo json_encode( array( 'id' => $id, 'serialized' => $form_row ) ); 
  742. wp_die(); 
  743.  
  744. add_action( 'wp_ajax_nfThreeUpgrade_GetSerializedFields', 'nfThreeUpgrade_GetSerializedFields' ); 
  745. function nfThreeUpgrade_GetSerializedFields() { 
  746. $fields = ninja_forms_get_all_favs(); 
  747.  
  748. echo json_encode( array( 'serialized' => maybe_serialize( $fields ) ) ) ; 
  749. wp_die(); 
  750.  
  751. add_action( 'init', 'ninja_forms_three_submenu', 9 ); // Register before general settings. 
  752. function ninja_forms_three_submenu() { 
  753. include plugin_dir_path( __FILE__ ) . 'upgrade/class-submenu.php'; 
  754.  
  755. add_action( 'admin_notices', 'ninja_forms_three_admin_notice' ); 
  756. function ninja_forms_three_admin_notice() { 
  757.  
  758. $settings = Ninja_Forms()->get_plugin_settings(); 
  759. if( isset( $settings[ 'disable_admin_notices' ] ) && $settings[ 'disable_admin_notices' ] ) return; 
  760.  
  761. $currentScreen = get_current_screen(); 
  762. if( ! in_array( $currentScreen->id, array( 'toplevel_page_ninja-forms' ) ) ) return; 
  763. wp_enqueue_style( 'nf-admin-notices', NINJA_FORMS_URL .'assets/css/admin-notices.css?nf_ver=' . NF_PLUGIN_VERSION ); 
  764.  
  765. if( ! isset( $_GET[ 'nf-rollback' ] ) ) { 
  766. if( ninja_forms_three_calc_check() && ninja_forms_three_addons_version_check() && ninja_forms_three_addons_check() ) { 
  767. ?> 
  768. <div id="nf-admin-notice-upgrade" class="update-nag nf-admin-notice"> 
  769. <div class="nf-notice-logo"></div> 
  770. <p class="nf-notice-title">Achievement Unlocked</p> 
  771. <p class="nf-notice-body"> 
  772. Cowabunga! You just unlocked Ninja Forms THREE. 
  773. </p> 
  774. <ul class="nf-notice-body nf-red"> 
  775. <li><span class="dashicons dashicons-awards"></span><a href="<?php echo admin_url( 'admin.php?page=ninja-forms-three' ); ?>">Upgrade to THREE</a></li> 
  776. </ul> 
  777. </div> 
  778. <?php 
  779. } else { 
  780. include plugin_dir_path( __FILE__ ) . 'upgrade/tmpl-notice.html.php'; 
  781. $three_link = nf_aff_link( 'https://ninjaforms.com/three/?utm_medium=plugin&utm_source=admin-notice&utm_campaign=Ninja+Forms+THREE&utm_content=Learn+More' ); 
  782. ?> 
  783. <div id="nf-admin-notice-three-is-coming" class="update-nag nf-admin-notice"> 
  784. <div class="nf-notice-logo"></div> 
  785. <p class="nf-notice-title">THREE is coming! </p> 
  786. <p class="nf-notice-body">A major update is coming to Ninja Forms. <a target="_blank" 
  787. href="<?php echo $three_link; ?>">Learn 
  788. more about new features, backwards compatibility, and more Frequently Asked Questions.</a></p> 
  789. </div> 
  790. <?php 
  791. } else { 
  792. ?> 
  793. <div id="nf-admin-notice-upgrade" class="update-nag nf-admin-notice"> 
  794. <div class="nf-notice-logo"></div> 
  795. <p class="nf-notice-title">Rollback Restored</p> 
  796. <p class="nf-notice-body"> 
  797. Your forms have been restored to the state prior to the upgrade. 
  798. </p> 
  799. <ul class="nf-notice-body nf-red"> 
  800. <li><span class="dashicons dashicons-sos"></span><a href="https://ninjaforms.com/contact/?utm_medium=plugin&utm_source=admin-notice&utm_campaign=Ninja+Forms+Rollback&utm_content=Ninja+Forms+Support" target="_blank">Contact Support</a></li> 
  801. </ul> 
  802. </div> 
  803. <?php 
  804.  
  805. add_action( 'nf_admin_before_form_list', 'ninja_forms_konami' ); 
  806. function ninja_forms_konami() { 
  807.  
  808. if( ! ninja_forms_three_calc_check() ) return; 
  809. if( ! ninja_forms_three_addons_version_check() ) return; 
  810.  
  811. wp_enqueue_script( 'cheet', NINJA_FORMS_URL . 'assets/js/lib/cheet.min.js', array( 'jquery' ) ); 
  812. wp_enqueue_script( 'howler', NINJA_FORMS_URL . 'assets/js/lib/howler.core.min.js', array( 'jquery' ) ); 
  813. wp_localize_script( 'howler', 'nfUnlock', array( 'audioUrl' => NINJA_FORMS_URL . 'assets/audio/smw_power_up.wav', 'aboutPage' => menu_page_url( 'ninja-forms-three', false ) ) ); 
  814. ?> 
  815. <script type="text/javascript"> 
  816.  
  817. jQuery( document ).ready( function() { 
  818. var sound = new Howl({ 
  819. src: [ nfUnlock.audioUrl ],  
  820. onend: function() { 
  821. window.scrollTo( 0, 0 ); 
  822. jQuery( '#nf-admin-notice-three-is-coming' ).fadeOut( 'slow', function() { 
  823. jQuery( '#nf-admin-notice-upgrade' ).fadeIn( 'slow', function() { 
  824. window.location = nfUnlock.aboutPage; 
  825. }); 
  826. }); 
  827. }); 
  828.  
  829. cheet('* * * * * * * * b a', function () { 
  830. sound.play(); 
  831. }); 
  832. } ); 
  833. </script> 
  834. <?php 
  835.  
  836. function ninja_forms_three_calc_check() 
  837. return true; 
  838.  
  839. function ninja_forms_three_addons_version_check() { 
  840. // $items = wp_remote_get( 'https://ninjaforms.com/?extend_feed=jlhrbgf89734go7387o4g3h' ); 
  841. // $items = wp_remote_retrieve_body( $items ); 
  842. $items = file_get_contents( dirname( __FILE__ ) . '/addons-feed.json' ); 
  843. $items = json_decode( $items, true ); 
  844.  
  845. if( is_array( $items ) ) { 
  846. foreach ($items as $item) { 
  847.  
  848. if (empty($item['plugin'])) continue; 
  849. if (!file_exists(WP_PLUGIN_DIR . '/' . $item['plugin'])) continue; 
  850.  
  851. $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $item['plugin'], false, true); 
  852.  
  853. if (!$plugin_data['Version']) continue; 
  854. if (version_compare($plugin_data['Version'], '3', '>=')) continue; 
  855.  
  856. /** 
  857. * There are non-compatible add-ons installed. 
  858. */ 
  859.  
  860. return FALSE; 
  861.  
  862. return TRUE; 
  863.  
  864. function ninja_forms_three_addons_check() { 
  865. $items = file_get_contents( dirname( __FILE__ ) . '/addons-feed.json' ); 
  866. $items = json_decode($items, true); 
  867.  
  868. $has_addons = FALSE; 
  869. if( is_array( $items ) ) { 
  870. foreach ($items as $item) { 
  871. if (empty($item['plugin'])) continue; 
  872. if (!file_exists(WP_PLUGIN_DIR . '/' . $item['plugin'])) continue; 
  873. $has_addons = TRUE; 
  874. $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $item['plugin'], false, true); 
  875. if (!$plugin_data['Version']) continue; 
  876. if (version_compare($plugin_data['Version'], '3', '>=')) continue; 
  877. /** 
  878. * There are non-compatible add-ons installed. 
  879. */ 
  880. return FALSE; 
  881. return $has_addons; 
  882.  
  883. /** 
  884. |-------------------------------------------------------------------------- 
  885. | Uninstall Hook 
  886. |-------------------------------------------------------------------------- 
  887. */ 
  888.  
  889. register_uninstall_hook( __FILE__, 'ninja_forms_uninstall' ); 
  890.  
  891. function ninja_forms_uninstall() { 
  892. global $wpdb; 
  893.  
  894. $settings = Ninja_Forms()->get_plugin_settings(); 
  895.  
  896. // Bail if we haven't checked the "delete on uninstall" box. 
  897. if (isset ($settings['delete_on_uninstall']) && 1 == $settings['delete_on_uninstall']) { 
  898.  
  899. // Remove our options. 
  900. delete_option('ninja_forms_settings'); 
  901. delete_option('nf_version_upgraded_from'); 
  902. delete_option('nf_upgrade_notice'); 
  903.  
  904. delete_option('nf_database_migrations'); 
  905.  
  906. delete_option('nf_convert_notifications_forms'); 
  907. delete_option('nf_convert_notifications_complete'); 
  908.  
  909. delete_option('nf_convert_subs_step'); 
  910.  
  911. delete_option('nf_email_fav_updated'); 
  912. delete_option('nf_update_email_settings_complete'); 
  913.  
  914. delete_option('nf_converted_subs'); 
  915. delete_option('nf_convert_subs_num'); 
  916. delete_option('nf_convert_subs_step'); 
  917.  
  918. delete_option('nf_converted_forms'); 
  919. delete_option('nf_converted_form_reset'); 
  920. delete_option('nf_convert_forms_complete'); 
  921.  
  922.  
  923. // Remove upgrade last step options 
  924. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/class-upgrade.php'); 
  925. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php' ); 
  926. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php' ); 
  927. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/convert-forms-reset.php' ); 
  928. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-handler-page.php'); 
  929. require_once( NF_PLUGIN_DIR . 'includes/admin/upgrades/class-upgrade-handler.php'); 
  930. $upgrades = NF_UpgradeHandler()->upgrades; 
  931.  
  932. if ($upgrades AND is_array($upgrades)) { 
  933. foreach ($upgrades as $upgrade) { 
  934. delete_option('nf_upgrade_' . $upgrade->name . '_last_step'); 
  935.  
  936. // Remove all of our submissions 
  937. $items = get_posts(array('post_type' => 'nf_sub', 'post_status' => 'any', 'numberposts' => -1, 'fields' => 'ids')); 
  938.  
  939. if ($items) { 
  940. foreach ($items as $item) { 
  941. wp_delete_post($item, true); 
  942.  
  943. // Remove all of our custom tables 
  944.  
  945. $wpdb->query('DROP TABLE ' . NF_OBJECTS_TABLE_NAME); 
  946. $wpdb->query('DROP TABLE ' . NF_OBJECT_META_TABLE_NAME); 
  947. $wpdb->query('DROP TABLE ' . NF_OBJECT_RELATIONSHIPS_TABLE_NAME); 
  948.  
  949. $wpdb->query('DROP TABLE ' . NINJA_FORMS_TABLE_NAME); 
  950. $wpdb->query('DROP TABLE ' . NINJA_FORMS_FIELDS_TABLE_NAME); 
  951. $wpdb->query('DROP TABLE ' . NINJA_FORMS_FAV_FIELDS_TABLE_NAME); 
  952. $wpdb->query('DROP TABLE ' . NINJA_FORMS_SUBS_TABLE_NAME); 
  953.  
  954. // Remove our daily cron job 
  955. $timestamp = wp_next_scheduled('ninja_forms_daily_action'); 
  956. wp_unschedule_event($timestamp, 'ninja_forms_daily_action'); 
.