Edit File by line
/home/barbar84/www/wp-conte.../plugins/ninja-fo.../deprecat.../classes
File: notices-multipart.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* NF_Notices_MP Class
[3] Fix | Delete
*
[4] Fix | Delete
* Extends NF_Notices to check for 20 or more fields in a single form and if multi-part forms is not installed before throwing an admin notice.
[5] Fix | Delete
*
[6] Fix | Delete
* @since 2.9
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
class NF_Notices_MP extends NF_Notices
[10] Fix | Delete
{
[11] Fix | Delete
// Basic actions to run
[12] Fix | Delete
public function __construct(){
[13] Fix | Delete
[14] Fix | Delete
// Runs the admin notice ignore function incase a dismiss button has been clicked
[15] Fix | Delete
add_action( 'admin_init', array( $this, 'admin_notice_ignore' ) );
[16] Fix | Delete
[17] Fix | Delete
// Runs the visibility checks for admin notices after all needed core files are loaded
[18] Fix | Delete
add_filter( 'nf_admin_notices', array( $this, 'special_parameters' ) );
[19] Fix | Delete
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
// Function to do all the special checks before running the notice
[23] Fix | Delete
public function special_parameters( $admin_notices ){
[24] Fix | Delete
[25] Fix | Delete
// Check if on builder
[26] Fix | Delete
if ( ! $this->admin_notice_pages( array( array( 'ninja-forms', 'builder' ) ) ) ) {
[27] Fix | Delete
return $admin_notices;
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
// Check for 20 fields in one form
[31] Fix | Delete
$field_check = 0;
[32] Fix | Delete
$all_fields = ninja_forms_get_all_fields();
[33] Fix | Delete
[34] Fix | Delete
if ( is_array( $all_fields ) ) {
[35] Fix | Delete
$count = array();
[36] Fix | Delete
[37] Fix | Delete
foreach ( $all_fields as $key => $val ) {
[38] Fix | Delete
$form_id = $all_fields[ $key ][ 'form_id' ];
[39] Fix | Delete
if ( ! isset( $count[ $form_id ] ) ) {
[40] Fix | Delete
$count[ $form_id ] = 1;
[41] Fix | Delete
} else {
[42] Fix | Delete
$count[ $form_id ]++;
[43] Fix | Delete
}
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
foreach ( $count as $form_id => $field_count ) {
[47] Fix | Delete
if ( $field_count >=20 ) {
[48] Fix | Delete
$field_check = 1;
[49] Fix | Delete
}
[50] Fix | Delete
}
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
// Check for multi-part forms installed and if the above passes
[54] Fix | Delete
if ( ! is_plugin_active( 'ninja-forms-multi-part/multi-part.php' ) && $field_check == 1 ) {
[55] Fix | Delete
// Add notice
[56] Fix | Delete
$tags = '?utm_medium=plugin&utm_source=admin-notice&utm_campaign=Ninja+Forms+Upsell&utm_content=Mult-Part+Forms';
[57] Fix | Delete
$multi_part_ignore = add_query_arg( array( 'nf_admin_notice_ignore' => 'multi_part' ) );
[58] Fix | Delete
$multi_part_temp = add_query_arg( array( 'nf_admin_notice_temp_ignore' => 'multi_part', 'int' => 14) );
[59] Fix | Delete
$admin_notices['multi_part'] = array(
[60] Fix | Delete
'title' => __( 'Increase Conversions', 'ninja-forms' ),
[61] Fix | Delete
'msg' => __( 'Did you know that you can increase form conversion by breaking larger forms into smaller, more easily digested parts?<p>The Multi-Part Forms extension for Ninja Forms makes this quick and easy.</p>', 'ninja-forms' ),
[62] Fix | Delete
'link' => '<li> <span class="dashicons dashicons-external"></span><a target="_blank" href="https://ninjaforms.com/extensions/multi-part-forms/' . $tags . '"> ' . __( 'Learn More About Multi-Part Forms', 'ninja-forms' ) . '</a></li>
[63] Fix | Delete
<li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $multi_part_temp . '">' . __( 'Maybe Later' ,'ninja-forms' ) . '</a></li>
[64] Fix | Delete
<li><span class="dashicons dashicons-dismiss"></span><a href="' . $multi_part_ignore . '">' . __( 'Dismiss', 'ninja-forms' ) . '</a></li>',
[65] Fix | Delete
'int' => 0
[66] Fix | Delete
);
[67] Fix | Delete
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
return $admin_notices;
[71] Fix | Delete
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
// Ignore function that gets ran at admin init to ensure any messages that were dismissed get marked
[75] Fix | Delete
public function admin_notice_ignore() {
[76] Fix | Delete
[77] Fix | Delete
$slug = ( isset( $_GET[ 'nf_admin_notice_ignore' ] ) ) ? sanitize_text_field($_GET[ 'nf_admin_notice_ignore' ]) : '';
[78] Fix | Delete
// If user clicks to ignore the notice, run this action
[79] Fix | Delete
if ( $slug == 'multi-part19' && current_user_can( apply_filters( 'ninja_forms_admin_parent_menu_capabilities', 'manage_options' ) ) ) {
[80] Fix | Delete
[81] Fix | Delete
$admin_notices_extra_option = get_option( 'nf_admin_notice_extra', array() );
[82] Fix | Delete
$admin_notices_extra_option[ sanitize_text_field($_GET[ 'nf_admin_notice_ignore' ]) ][ 'test19' ] = 1;
[83] Fix | Delete
update_option( 'nf_admin_notice_extra', $admin_notices_extra_option );
[84] Fix | Delete
[85] Fix | Delete
}
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
return new NF_Notices_MP();
[91] Fix | Delete
[92] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function