/** * Main Ninja_Forms Instance * * Insures that only one instance of Ninja_Forms exists in memory at any one * time. Also prevents needing to define globals all over the place. * * @since 2.7 * @static * @staticvar array $instance * @return The highlander Ninja_Forms */ public static function instance() { if (!isset(self::$instance) && !self::$instance instanceof Ninja_Forms) { self::$instance = new Ninja_Forms(); self::$instance->setup_constants(); self::$instance->includes(); // Start our submissions custom post type class self::$instance->subs_cpt = new NF_Subs_CPT(); // Add our registration class object self::$instance->register = new NF_Register(); // The forms variable won't be interacted with directly. // Instead, the forms() methods will act as wrappers for it. self::$instance->forms = new NF_Forms(); // Our session manager wrapper class self::$instance->session = new NF_Session(); register_activation_hook(__FILE__, 'ninja_forms_activation'); add_action('plugins_loaded', array(self::$instance, 'load_lang')); add_action('init', array(self::$instance, 'init'), 5); add_action('admin_init', array(self::$instance, 'admin_init'), 5); add_action('update_option_ninja_forms_settings', array(self::$instance, 'refresh_plugin_settings'), 10); // add_action( 'admin_head', array( self::$instance, 'admin_head' ) ); add_action('admin_notices', array(self::$instance, 'admin_notice')); } return self::$instance; }
/** * Main Ninja_Forms Instance * * Insures that only one instance of Ninja_Forms exists in memory at any one * time. Also prevents needing to define globals all over the place. * * @since 2.7 * @static * @staticvar array $instance * @return The highlander Ninja_Forms */ public static function instance() { if (!isset(self::$instance) && !self::$instance instanceof Ninja_Forms) { self::$instance = new Ninja_Forms(); self::$instance->setup_constants(); self::$instance->includes(); // Start our submissions custom post type class self::$instance->subs_cpt = new NF_Subs_CPT(); register_activation_hook(__FILE__, 'ninja_forms_activation'); add_action('plugins_loaded', array(self::$instance, 'load_lang')); add_action('init', array(self::$instance, 'set_transient_id'), 1); add_action('init', array(self::$instance, 'init'), 5); add_action('admin_init', array(self::$instance, 'admin_init'), 5); } return self::$instance; }
<?php /** NINJA FORMS **/ add_action('after_setup_theme', function () { if (class_exists('Ninja_Forms')) { //notices in admin from incorrect post message filterng - remove it $nf = Ninja_Forms::instance(); remove_filter('post_updated_messages', array($nf->subs_cpt, 'post_updated_messages')); //remove CSS remove_action('ninja_forms_display_css', 'ninja_forms_display_css', 10, 2); //remove unsupported fields remove_action('init', 'ninja_forms_register_field_calc'); remove_action('init', 'ninja_forms_register_field_credit_card'); remove_action('init', 'ninja_forms_register_field_number'); remove_action('init', 'ninja_forms_register_field_hr'); remove_action('init', 'ninja_forms_register_field_profile_pass'); remove_action('init', 'ninja_forms_register_field_rating'); remove_action('init', 'ninja_forms_register_field_tax'); remove_action('init', 'ninja_forms_register_field_timed_submit'); remove_action('init', 'ninja_forms_register_field_spam'); remove_action('admin_init', 'ninja_forms_register_sidebar_payment_fields'); remove_action('admin_init', 'ninja_forms_register_sidebar_user_info_fields'); add_action('admin_init', 'tst_nf_register_sidebar_user_info_fields'); } }); //to-do deregister unused fields //wrapper class add_filter('ninja_forms_display_field_wrap_class', 'tst_nf_field_wrap_class', 2, 3); function tst_nf_field_wrap_class($field_wrap_class, $field_id, $field_row) { if ($field_row['type'] == '_text') {
/** * Main Ninja_Forms Instance * * Insures that only one instance of Ninja_Forms exists in memory at any one * time. Also prevents needing to define globals all over the place. * * @since 2.7 * @static * @staticvar array $instance * @return Ninja_Forms Highlander Instance */ public static function instance() { if (!isset(self::$instance) && !self::$instance instanceof Ninja_Forms) { self::$instance = new Ninja_Forms(); self::$dir = plugin_dir_path(__FILE__); if (!defined('NF_PLUGIN_DIR')) { define('NF_PLUGIN_DIR', self::$dir); } self::$url = plugin_dir_url(__FILE__); if (!defined('NF_PLUGIN_URL')) { define('NF_PLUGIN_URL', self::$url); } update_option('ninja_forms_version', self::VERSION); /* * Register our autoloader */ spl_autoload_register(array(self::$instance, 'autoloader')); /* * Admin Menus */ self::$instance->menus['forms'] = new NF_Admin_Menus_Forms(); self::$instance->menus['all-forms'] = new NF_Admin_Menus_AllForms(); self::$instance->menus['add-new'] = new NF_Admin_Menus_AddNew(); self::$instance->menus['settings'] = new NF_Admin_Menus_Settings(); self::$instance->menus['add-ons'] = new NF_Admin_Menus_Addons(); self::$instance->menus['system_status'] = new NF_Admin_Menus_SystemStatus(); self::$instance->menus['submissions'] = new NF_Admin_Menus_Submissions(); self::$instance->menus['import-export'] = new NF_Admin_Menus_ImportExport(); self::$instance->menus['licenses'] = new NF_Admin_Menus_Licenses(); /* * Admin menus used for building out the admin UI * * TODO: removed once building is complete */ // self::$instance->menus[ 'add-field'] = new NF_Admin_Menus_AddField(); // self::$instance->menus[ 'edit-field'] = new NF_Admin_Menus_EditField(); // self::$instance->menus[ 'add-action'] = new NF_Admin_Menus_AddAction(); // self::$instance->menus[ 'edit-action'] = new NF_Admin_Menus_EditAction(); // self::$instance->menus[ 'edit-settings'] = new NF_Admin_Menus_EditSettings(); // self::$instance->menus[ 'fields-layout'] = new NF_Admin_Menus_FieldsLayout(); self::$instance->menus['mock-data'] = new NF_Admin_Menus_MockData(); // self::$instance->menus[ 'preview'] = new NF_Admin_Menus_Preview(); /* * AJAX Controllers */ self::$instance->controllers['form'] = new NF_AJAX_Controllers_Form(); self::$instance->controllers['preview'] = new NF_AJAX_Controllers_Preview(); self::$instance->controllers['uploads'] = new NF_AJAX_Controllers_Uploads(); self::$instance->controllers['submission'] = new NF_AJAX_Controllers_Submission(); self::$instance->controllers['savedfields'] = new NF_AJAX_Controllers_SavedFields(); /* * WP-CLI Commands */ if (class_exists('WP_CLI_Command')) { WP_CLI::add_command('ninja-forms', 'NF_WPCLI_NinjaFormsCommand'); } /* * Preview Page */ self::$instance->preview = new NF_Display_Preview(); /* * Shortcodes */ self::$instance->shortcodes = new NF_Display_Shortcodes(); /* * Temporary Shortcodes * * TODO: removed once building is complete */ require_once self::$dir . 'includes/Display/Shortcodes/tmp-frontend.php'; require_once self::$dir . 'includes/Display/Shortcodes/tmp-preview.php'; require_once self::$dir . 'includes/Display/Shortcodes/tmp-frontendform.php'; require_once self::$dir . 'includes/Display/Shortcodes/tmp-file-upload.php'; /* * Submission CPT */ new NF_Admin_CPT_Submission(); /* * Logger */ self::$instance->_logger = new NF_Database_Logger(); /* * Merge Tags */ self::$instance->merge_tags['user'] = new NF_MergeTags_User(); self::$instance->merge_tags['post'] = new NF_MergeTags_Post(); self::$instance->merge_tags['system'] = new NF_MergeTags_System(); self::$instance->merge_tags['fields'] = new NF_MergeTags_Fields(); self::$instance->merge_tags['calcs'] = new NF_MergeTags_Calcs(); self::$instance->merge_tags['querystrings'] = new NF_MergeTags_QueryStrings(); /* * Add Form Modal */ self::$instance->add_form_modal = new NF_Admin_AddFormModal(); /* * EOS Parser */ self::$instance->_eos['parser'] = (require_once 'includes/Libraries/EOS/Parser.php'); self::$instance->session = new NF_Session(); /* * Plugin Settings */ self::$instance->settings = get_option('ninja_forms_settings'); /* * Admin Notices System */ self::$instance->notices = new NF_Admin_Notices(); /* * Activation Hook * TODO: Move to a permanent home. */ register_activation_hook(__FILE__, array(self::$instance, 'activation')); new NF_Admin_Metaboxes_AppendAForm(); /* * Require EDD auto-update file */ if (!class_exists('EDD_SL_Plugin_Updater')) { // Load our custom updater if it doesn't already exist require_once self::$dir . 'includes/Integrations/EDD/EDD_SL_Plugin_Updater.php'; } require_once self::$dir . 'includes/Integrations/EDD/class-extension-updater.php'; } add_action('admin_notices', array(self::$instance, 'admin_notices')); add_action('plugins_loaded', array(self::$instance, 'plugins_loaded')); return self::$instance; }
/** * Main Ninja_Forms Instance * * Insures that only one instance of Ninja_Forms exists in memory at any one * time. Also prevents needing to define globals all over the place. * * @since 2.7 * @static * @staticvar array $instance * @return Ninja_Forms Highlander Instance */ public static function instance() { if (!isset(self::$instance) && !self::$instance instanceof Ninja_Forms) { self::$instance = new Ninja_Forms(); self::$dir = plugin_dir_path(__FILE__); // Define old constants for backwards compatibility. if (!defined('NF_PLUGIN_DIR')) { define('NF_PLUGIN_DIR', self::$dir); define('NINJA_FORMS_DIR', self::$dir . 'deprecated'); } self::$url = plugin_dir_url(__FILE__); if (!defined('NF_PLUGIN_URL')) { define('NF_PLUGIN_URL', self::$url); } update_option('ninja_forms_version', self::VERSION); /* * Register our autoloader */ spl_autoload_register(array(self::$instance, 'autoloader')); /* * Admin Menus */ self::$instance->menus['forms'] = new NF_Admin_Menus_Forms(); self::$instance->menus['all-forms'] = new NF_Admin_Menus_AllForms(); self::$instance->menus['add-new'] = new NF_Admin_Menus_AddNew(); self::$instance->menus['submissions'] = new NF_Admin_Menus_Submissions(); self::$instance->menus['import-export'] = new NF_Admin_Menus_ImportExport(); self::$instance->menus['settings'] = new NF_Admin_Menus_Settings(); self::$instance->menus['licenses'] = new NF_Admin_Menus_Licenses(); self::$instance->menus['system_status'] = new NF_Admin_Menus_SystemStatus(); self::$instance->menus['add-ons'] = new NF_Admin_Menus_Addons(); self::$instance->menus['divider'] = new NF_Admin_Menus_Divider(); self::$instance->menus['mock-data'] = new NF_Admin_Menus_MockData(); /* * AJAX Controllers */ self::$instance->controllers['form'] = new NF_AJAX_Controllers_Form(); self::$instance->controllers['preview'] = new NF_AJAX_Controllers_Preview(); self::$instance->controllers['submission'] = new NF_AJAX_Controllers_Submission(); self::$instance->controllers['savedfields'] = new NF_AJAX_Controllers_SavedFields(); /* * Async Requests */ require_once Ninja_Forms::$dir . 'includes/Libraries/BackgroundProcessing/classes/wp-async-request.php'; self::$instance->requests['delete-field'] = new NF_AJAX_Requests_DeleteField(); /* * WP-CLI Commands */ if (class_exists('WP_CLI_Command')) { WP_CLI::add_command('ninja-forms', 'NF_WPCLI_NinjaFormsCommand'); } /* * Preview Page */ self::$instance->preview = new NF_Display_Preview(); /* * Shortcodes */ self::$instance->shortcodes = new NF_Display_Shortcodes(); /* * Submission CPT */ new NF_Admin_CPT_Submission(); new NF_Admin_CPT_DownloadAllSubmissions(); require_once Ninja_Forms::$dir . 'lib/StepProcessing/menu.php'; /* * Logger */ self::$instance->_logger = new NF_Database_Logger(); /* * Merge Tags */ self::$instance->merge_tags['user'] = new NF_MergeTags_User(); self::$instance->merge_tags['post'] = new NF_MergeTags_Post(); self::$instance->merge_tags['system'] = new NF_MergeTags_System(); self::$instance->merge_tags['fields'] = new NF_MergeTags_Fields(); self::$instance->merge_tags['calcs'] = new NF_MergeTags_Calcs(); self::$instance->merge_tags['querystrings'] = new NF_MergeTags_QueryStrings(); self::$instance->merge_tags['form'] = new NF_MergeTags_Form(); /* * Add Form Modal */ self::$instance->add_form_modal = new NF_Admin_AddFormModal(); /* * EOS Parser */ self::$instance->_eos['parser'] = (require_once 'includes/Libraries/EOS/Parser.php'); self::$instance->session = new NF_Session(); /* * Plugin Settings */ self::$instance->settings = apply_filters('ninja_forms_settings', get_option('ninja_forms_settings')); /* * Admin Notices System */ self::$instance->notices = new NF_Admin_Notices(); self::$instance->widgets[] = new NF_Widget(); /* * Activation Hook * TODO: Move to a permanent home. */ register_activation_hook(__FILE__, array(self::$instance, 'activation')); new NF_Admin_Metaboxes_AppendAForm(); /* * Require EDD auto-update file */ if (!class_exists('EDD_SL_Plugin_Updater')) { // Load our custom updater if it doesn't already exist require_once self::$dir . 'includes/Integrations/EDD/EDD_SL_Plugin_Updater.php'; } require_once self::$dir . 'includes/Integrations/EDD/class-extension-updater.php'; } add_action('admin_notices', array(self::$instance, 'admin_notices')); add_action('plugins_loaded', array(self::$instance, 'plugins_loaded')); add_action('ninja_forms_available_actions', array(self::$instance, 'scrub_available_actions')); add_action('init', array(self::$instance, 'init'), 5); add_action('admin_init', array(self::$instance, 'admin_init'), 5); return self::$instance; }