: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$return[ strtolower( $filename ) ] = new $class_name;
* @param string $file_name
public static function template( $file_name = '', array $data = array(), $return = FALSE )
if( ! $file_name ) return FALSE;
$path = self::$dir . 'includes/Templates/' . $file_name;
if( ! file_exists( $path ) ) return FALSE;
if( $return ) return file_get_contents( $path );
public static function config( $file_name )
return include self::$dir . 'includes/Config/' . $file_name . '.php';
public function activation() {
$migrations = new NF_Database_Migrations();
if( Ninja_Forms()->form()->get_forms() ) return;
// Go ahead and create our randomn number for gated releases in the future
$zuul = WPN_Helper::get_zuul();
$form = Ninja_Forms::template( 'formtemplate-contactform.nff', array(), TRUE );
Ninja_Forms()->form()->import_form( $form );
Ninja_Forms()->flush_rewrite_rules();
// Enable "Light" Opinionated Styles for new installtion.
Ninja_Forms()->update_setting('opinionated_styles', 'light');
// Disable "Dev Mode" for new installation.
Ninja_Forms()->update_setting('builder_dev_mode', 0);
// Grab our initial add-on feed from api.ninjaforms.com
nf_update_marketing_feed();
// Setup our add-on feed wp cron so that our add-on list is up to date on a weekly basis.
nf_marketing_feed_cron_job();
// Disable the survey promo for 7 days on new installations.
set_transient('ninja_forms_disable_survey_promo', 1, DAY_IN_SECONDS * 7);
* Example: Ninja_Forms::deprecated_hook( 'ninja_forms_old', '3.0', 'ninja_forms_new', debug_backtrace() );
* @param null $replacement
public static function deprecated_notice( $deprecated, $version, $replacement = null, $backtrace = null )
do_action( 'ninja_forms_deprecated_call', $deprecated, $replacement, $version );
$show_errors = current_user_can( 'manage_options' );
// Allow plugin to filter the output error trigger
if ( WP_DEBUG && apply_filters( 'ninja_forms_deprecated_function_trigger_error', $show_errors ) ) {
if ( ! is_null( $replacement ) ) {
trigger_error( sprintf( esc_html__( '%1$s is <strong>deprecated</strong> since Ninja Forms version %2$s! Use %3$s instead.', 'ninja-forms' ), $deprecated, $version, $replacement ) );
// trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
// Alternatively we could dump this to a file.
trigger_error( sprintf( esc_html__( '%1$s is <strong>deprecated</strong> since Ninja Forms version %2$s.', 'ninja-forms' ), $deprecated, $version ) );
// trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
// Alternatively we could dump this to a file.
* Function to deregister already completed updates from the list of required updates.
* @codeCoverageIgnore WP hook only; tests in called class
* @param $updates (Array) Our array of required updates.
* @return $updates (Array) Our array of required updates.
public function remove_completed_updates($updates)
$manageUpdates = new ManageUpdates();
$return = $manageUpdates->removeCompletedUpdates($updates);
* Function to deregister updates that have required updates that either
* don't exist, or are malformed
* @since UPDATE_TO_LATEST version
* @codeCoverageIgnore WP hook only; tests in called class
* @param $updates (Array) Our array of required updates.
* @return $updates (Array) Our array of required updates.
public function remove_bad_updates( $updates ) {
$manageUpdates = new ManageUpdates();
$return = $manageUpdates->removeBadUpdates($updates);
} // End Class Ninja_Forms
* The main function responsible for returning The Highlander Ninja_Forms
* Instance to functions everywhere.
* Use this function like you would a global variable, except without needing
* Example: <?php $nf = Ninja_Forms(); ?>
* @return Ninja_Forms Highlander Instance
return Ninja_Forms::instance();
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
register_uninstall_hook( __FILE__, 'ninja_forms_uninstall' );
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);
$migrations->nuke_settings(TRUE, TRUE);
$migrations->nuke_deprecated(TRUE, TRUE);
function nf_optin_update_environment_vars() {
* Send updated environment variables.
Ninja_Forms()->dispatcher()->update_environment_vars();
* Make sure that we've reported our opt-in.
if( get_option( 'ninja_forms_optin_reported', 0 ) ) return;
Ninja_Forms()->dispatcher()->send( 'optin', array( 'send_email' => 1 ) );
// Debounce opt-in dispatch.
update_option( 'ninja_forms_optin_reported', 1 );
add_action( 'nf_optin_cron', 'nf_optin_update_environment_vars' );
* Function to register our Custom Cron Recurrences.
* @param $schedules (Array) The available cron recurrences.
* @return (Array) The filtered cron recurrences.
function nf_custom_cron_job_recurrence( $schedules ) {
$schedules[ 'nf-monthly' ] = array(
'display' => esc_html__( 'Once per month', 'ninja-forms' ),
$schedules[ 'nf-weekly' ] = array(
'display' => esc_html__( 'Once per week', 'ninja-forms' ),
add_filter( 'cron_schedules', 'nf_custom_cron_job_recurrence' );
// Schedule Cron Job Event
function nf_optin_send_admin_email_cron_job() {
if ( ! wp_next_scheduled( 'nf_optin_cron' ) ) {
wp_schedule_event( current_time( 'timestamp' ), 'nf-monthly', 'nf_optin_cron' );
add_action( 'wp', 'nf_optin_send_admin_email_cron_job' );
* Function called via weekly wp_cron to update our marketing feeds.
function nf_update_marketing_feed() {
$data = wp_remote_get( 'http://api.ninjaforms.com/feeds/?fetch=addons' );
// If we got a valid response...
if ( is_array($data) && 200 == $data[ 'response' ][ 'code' ] ) {
// Save the data to our option.
$data = wp_remote_retrieve_body( $data );
update_option( 'ninja_forms_addons_feed', $data, false );
add_action( 'nf_marketing_feed_cron', 'nf_update_marketing_feed' );
* Function called by our marketing feed cron.
function nf_marketing_feed_cron_job() {
if ( ! wp_next_scheduled( 'nf_marketing_feed_cron' ) ) {
wp_schedule_event( current_time( 'timestamp' ), 'nf-weekly', 'nf_marketing_feed_cron' );
* Make sure the marketing feed is updated after an update
add_action("upgrader_process_complete", function($upgrader_object, $options){
$options["type"] === "plugin" &&
$options["action"] === "update" &&
$upgrader_object->result["destination_name"] === "ninja-forms" &&
function_exists("nf_update_marketing_feed")
nf_update_marketing_feed();
* Call our survey promo on relevant pages.
add_action( 'in_admin_header', function() {
$surveyPromo = new NF_Admin_SurveyPromo();