Commit 1a71c82d authored by Kevin Stover's avatar Kevin Stover

Merge branch 'develop' into paqu83-issue#2031

parents 27f15f84 71302762
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -80,6 +80,7 @@ gulp.task('js:frontend', function(){
gulp.src([
'assets/js/lib/bootstrap.min.js',
'assets/js/lib/modernizr.min.js',
'assets/js/lib/codemirror.min.js',
'assets/js/lib/codemirror-xml.min.js',
'assets/js/lib/codemirror-formatting.min.js',
......@@ -104,7 +105,6 @@ gulp.task('js:frontend', function(){
'assets/js/lib/backbone.marionette.min.js',
'assets/js/lib/backbone.radio.min.js',
'assets/js/lib/math.min.js',
'assets/js/lib/modernizr.min.js',
'assets/js/min/global.js',
])
.pipe(concat('front-end-deps.js'))
......
......@@ -331,8 +331,10 @@ class NF_Abstracts_Model
*/
public function update_settings( $data )
{
foreach( $data as $key => $value ){
$this->update_setting( $key, $value );
if( is_array( $data ) ) {
foreach ($data as $key => $value) {
$this->update_setting($key, $value);
}
}
return $this;
......
......@@ -234,8 +234,9 @@ final class NF_Display_Render
$settings[ 'options' ] = apply_filters( 'ninja_forms_render_options_' . $field_type, $settings[ 'options' ], $settings );
}
if (isset($settings['default'])) {
$default_value = apply_filters('ninja_forms_render_default_value', $settings['default'], $field_type, $settings);
$default_value = ( isset( $settings[ 'default' ] ) ) ? $settings[ 'default' ] : null;
$default_value = apply_filters('ninja_forms_render_default_value', $default_value, $field_type, $settings);
if ( $default_value ) {
$default_value = preg_replace( '/{.*}/', '', $default_value );
......@@ -428,8 +429,9 @@ final class NF_Display_Render
$field['settings'][ 'options' ] = apply_filters( 'ninja_forms_render_options_' . $field['settings'][ 'type' ], $field['settings'][ 'options' ], $field['settings'] );
}
if (isset($field['settings']['default'])) {
$default_value = apply_filters('ninja_forms_render_default_value', $field['settings']['default'], $field_type, $field['settings']);
$default_value = ( isset( $field[ 'settings' ][ 'default' ] ) ) ? $field[ 'settings' ][ 'default' ] : null;
$default_value = apply_filters( 'ninja_forms_render_default_value', $default_value, $field_type, $field[ 'settings' ]);
if( $default_value ){
$default_value = preg_replace( '/{.*}/', '', $default_value );
......
......@@ -33,7 +33,7 @@ class NF_Fields_ListSelect extends NF_Abstracts_List
if( isset( $field[ 'options' ] ) ) {
foreach ($field['options'] as $option ) {
if( ! isset( $option[ 'value' ] ) || $value != $option[ 'value' ] || ! isset( $option[ 'calc' ] ) ) continue;
$value = $option[ 'calc' ];
return $option[ 'calc' ];
}
}
return $value;
......
......@@ -17,6 +17,8 @@ class NF_Fields_Recaptcha extends NF_Abstracts_Field
protected $_test_value = '';
protected $_settings = array( 'label' );
public function __construct()
{
parent::__construct();
......@@ -27,7 +29,7 @@ class NF_Fields_Recaptcha extends NF_Abstracts_Field
'name' => 'wrapper_class',
'type' => 'textbox',
'placeholder' => '',
'label' => __( 'Wrapper', 'ninja-forms' ),
'label' => __( 'Wrapper Class', 'ninja-forms' ),
'width' => 'full',
'value' => '',
'group' => 'primary',
......@@ -36,8 +38,6 @@ class NF_Fields_Recaptcha extends NF_Abstracts_Field
);
add_filter( 'nf_sub_hidden_field_types', array( $this, 'hide_field_type' ) );
// add_filter( 'script_loader_tag', array( $this, 'add_script_attributes' ), 10, 2);
}
public function localize_settings( $settings, $form ) {
......@@ -75,10 +75,4 @@ class NF_Fields_Recaptcha extends NF_Abstracts_Field
$field_types[] = $this->_name;
return $field_types;
}
function add_script_attributes( $tag, $handle )
{
if ( 'google-recaptcha' !== $handle ) return $tag;
return str_replace( ' src', ' async="async" defer="defer" src', $tag );
}
}
......@@ -106,10 +106,10 @@ final class NF_Tracking
/**
* Check if a site is opted in
*
* @access private
* @access public
* @return bool
*/
private function is_opted_in()
public function is_opted_in()
{
return (bool) get_option( 'ninja_forms_allow_tracking', $this->is_freemius_opted_in() );
}
......@@ -150,10 +150,10 @@ final class NF_Tracking
/**
* Check if a site is opted out
*
* @access private
* @access public
* @return bool
*/
private function is_opted_out()
public function is_opted_out()
{
return (bool) get_option( 'ninja_forms_do_not_allow_tracking', $this->is_freemius_opted_out() );
}
......@@ -192,5 +192,3 @@ final class NF_Tracking
}
} // END CLASS NF_Tracking
new NF_Tracking();
\ No newline at end of file
......@@ -134,6 +134,11 @@ if( get_option( 'ninja_forms_load_deprecated', FALSE ) && ! ( isset( $_POST[ 'nf
*/
protected $session = '';
/**
* @var NF_Tracking
*/
public $tracking;
/**
* Plugin Settings
*
......@@ -281,6 +286,11 @@ if( get_option( 'ninja_forms_load_deprecated', FALSE ) && ! ( isset( $_POST[ 'nf
self::$instance->widgets[] = new NF_Widget();
/*
* Opt-In Tracking
*/
self::$instance->tracking = new NF_Tracking();
/*
* Activation Hook
* TODO: Move to a permanent home.
......@@ -692,3 +702,63 @@ if( get_option( 'ninja_forms_load_deprecated', FALSE ) && ! ( isset( $_POST[ 'nf
}
}
}
// Scheduled Action Hook
function nf_optin_send_admin_email( ) {
/*
* If we aren't opted in, or we've specifically opted out, then return false.
*/
if ( ! Ninja_Forms()->tracking->is_opted_in() || Ninja_Forms()->tracking->is_opted_out() ) {
return false;
}
/*
* If we haven't already submitted our email to api.ninjaforms.com, submit it and set an option saying we have.
*/
if ( get_option ( 'ninja_forms_optin_admin_email', false ) ) {
return false;
}
/*
* Ping api.ninjaforms.com
*/
$admin_email = get_option('admin_email');
$url = home_url();
$response = wp_remote_post(
'http://api.ninjaforms.com',
array(
'body' => array( 'admin_email' => $admin_email, 'url' => $url ),
)
);
if( is_array($response) ) {
$header = $response['headers']; // array of http header lines
$body = $response['body']; // use the content
}
update_option( 'ninja_forms_optin_admin_email', true );
}
add_action( 'nf_optin_cron', 'nf_optin_send_admin_email' );
// Custom Cron Recurrences
function nf_custom_cron_job_recurrence( $schedules ) {
$schedules['nf-monthly'] = array(
'display' => __( 'Once per month', 'textdomain' ),
'interval' => 2678400,
);
return $schedules;
}
add_filter( 'cron_schedules', 'nf_custom_cron_job_recurrence' );
// Schedule Cron Job Event
function nf_optin_send_admin_email_cron_job() {
wp_clear_scheduled_hook( 'nf_optin_cron' );
if ( ! wp_next_scheduled( 'nf_optin_cron' ) ) {
nf_optin_send_admin_email();
wp_schedule_event( current_time( 'timestamp' ), 'nf-monthly', 'nf_optin_cron' );
}
}
add_action( 'wp', 'nf_optin_send_admin_email_cron_job' );
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