Edit File by line
/home/barbar84/www/wp-conte.../plugins/ninja-fo.../deprecat.../upgrade
File: class-submenu.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
class NF_THREE_Submenu
[2] Fix | Delete
{
[3] Fix | Delete
/**
[4] Fix | Delete
* (required) The slug name for the parent menu (or the file name of a standard WordPress admin page)
[5] Fix | Delete
*
[6] Fix | Delete
* @var string
[7] Fix | Delete
*/
[8] Fix | Delete
public $parent_slug = '';
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* (required) The text to be displayed in the title tags of the page when the menu is selected
[12] Fix | Delete
*
[13] Fix | Delete
* @var string
[14] Fix | Delete
*/
[15] Fix | Delete
public $page_title = 'Ninja Forms THREE';
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* (required) The on-screen name text for the menu
[19] Fix | Delete
*
[20] Fix | Delete
* @var string
[21] Fix | Delete
*/
[22] Fix | Delete
public $menu_title = 'Ninja Forms THREE';
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* (required) The capability required for this menu to be displayed to the user.
[26] Fix | Delete
*
[27] Fix | Delete
* @var string
[28] Fix | Delete
*/
[29] Fix | Delete
public $capability = 'manage_options';
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* (required) The slug name to refer to this menu by (should be unique for this menu).
[33] Fix | Delete
*
[34] Fix | Delete
* @var string
[35] Fix | Delete
*/
[36] Fix | Delete
public $menu_slug = 'ninja-forms-three';
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* (optional) The function that displays the page content for the menu page.
[40] Fix | Delete
*
[41] Fix | Delete
* @var string
[42] Fix | Delete
*/
[43] Fix | Delete
public $function = 'display';
[44] Fix | Delete
[45] Fix | Delete
public $priority = 9001;
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Constructor
[49] Fix | Delete
*
[50] Fix | Delete
* Translate text and add the 'admin_menu' action.
[51] Fix | Delete
*/
[52] Fix | Delete
public function __construct()
[53] Fix | Delete
{
[54] Fix | Delete
$this->menu_title = __( 'Update', 'ninja-forms' );
[55] Fix | Delete
$this->page_title = __( 'Update to Ninja Forms THREE', 'ninja-forms' );
[56] Fix | Delete
[57] Fix | Delete
$this->capability = apply_filters( 'submenu_' . $this->menu_slug . '_capability', $this->capability );
[58] Fix | Delete
[59] Fix | Delete
add_action( 'admin_menu', array( $this, 'register' ), $this->priority );
[60] Fix | Delete
[61] Fix | Delete
add_action( 'wp_ajax_ninja_forms_upgrade_check', array( $this, 'upgrade_check' ) );
[62] Fix | Delete
[63] Fix | Delete
add_filter( 'nf_general_settings_advanced', array( $this, 'settings_upgrade_button' ) );
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Register the menu page.
[68] Fix | Delete
*/
[69] Fix | Delete
public function register()
[70] Fix | Delete
{
[71] Fix | Delete
if( ! ninja_forms_three_addons_version_check() ) return;
[72] Fix | Delete
[73] Fix | Delete
if( ! ninja_forms_three_addons_check() ){
[74] Fix | Delete
// Hide the submenu
[75] Fix | Delete
$this->parent_slug = '';
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
$function = ( $this->function ) ? array( $this, $this->function ) : NULL;
[79] Fix | Delete
[80] Fix | Delete
add_submenu_page(
[81] Fix | Delete
$this->parent_slug,
[82] Fix | Delete
$this->page_title,
[83] Fix | Delete
$this->menu_title,
[84] Fix | Delete
$this->capability,
[85] Fix | Delete
$this->menu_slug,
[86] Fix | Delete
$function
[87] Fix | Delete
);
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* Display the menu page.
[92] Fix | Delete
*/
[93] Fix | Delete
public function display()
[94] Fix | Delete
{
[95] Fix | Delete
global $ninja_forms_tabs_metaboxes;
[96] Fix | Delete
[97] Fix | Delete
$addon_installed = false;
[98] Fix | Delete
if ( isset ( $ninja_forms_tabs_metaboxes['ninja-forms-settings']['license_settings']['license_settings']['settings'] ) ) {
[99] Fix | Delete
if ( 0 < count( $ninja_forms_tabs_metaboxes['ninja-forms-settings']['license_settings']['license_settings']['settings'] ) ) {
[100] Fix | Delete
$addon_installed = true;
[101] Fix | Delete
}
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
$is_opted_in = get_option( 'ninja_forms_allow_tracking', false );
[105] Fix | Delete
$is_opted_out = get_option( 'ninja_forms_do_not_allow_tracking', false );
[106] Fix | Delete
if ( ! $addon_installed && ( ! $is_opted_in || $is_opted_out ) ) {
[107] Fix | Delete
$opted_in = 0;
[108] Fix | Delete
} else {
[109] Fix | Delete
$opted_in = 1;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
$all_forms = Ninja_Forms()->forms()->get_all();
[113] Fix | Delete
[114] Fix | Delete
wp_enqueue_style( 'ninja-forms-three-upgrade-styles', plugin_dir_url(__FILE__) . 'upgrade.css' );
[115] Fix | Delete
wp_enqueue_style( 'ninja-forms-three-upgrade-jbox', plugin_dir_url(__FILE__) . 'jBox.css' );
[116] Fix | Delete
[117] Fix | Delete
wp_enqueue_script( 'ninja-forms-three-upgrade', plugin_dir_url(__FILE__) . 'upgrade.js', array( 'jquery', 'wp-util' ), '', TRUE );
[118] Fix | Delete
wp_enqueue_script( 'ninja-forms-three-upgrade-jbox', plugin_dir_url(__FILE__) . 'jBox.min.js', array( 'jquery', 'wp-util' ), '', TRUE );
[119] Fix | Delete
$nonce = wp_create_nonce( 'ninja_forms_upgrade_nonce' );
[120] Fix | Delete
wp_localize_script( 'ninja-forms-three-upgrade', 'nfThreeUpgrade', array(
[121] Fix | Delete
'forms' => $all_forms,
[122] Fix | Delete
'redirectURL' => admin_url( 'admin.php?page=ninja-forms&nf-switcher=upgrade&security=' . $nonce ),
[123] Fix | Delete
'optedIn' => $opted_in,
[124] Fix | Delete
'nonce' => $nonce,
[125] Fix | Delete
) );
[126] Fix | Delete
[127] Fix | Delete
include plugin_dir_path( __FILE__ ) . 'tmpl-submenu.html.php';
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
public function upgrade_check()
[131] Fix | Delete
{
[132] Fix | Delete
if( ! isset( $_POST[ 'formID' ] ) ) $this->respond( array( 'error' => 'Form ID not found.' ) );
[133] Fix | Delete
[134] Fix | Delete
$form_id = absint( $_POST[ 'formID' ] );
[135] Fix | Delete
[136] Fix | Delete
$can_upgrade = TRUE;
[137] Fix | Delete
[138] Fix | Delete
$fields = Ninja_Forms()->form( $form_id )->fields;
[139] Fix | Delete
$settings = Ninja_Forms()->form( $form_id )->get_all_settings();
[140] Fix | Delete
[141] Fix | Delete
foreach( $fields as $field ){
[142] Fix | Delete
if( '_calc' == $field[ 'type' ] ){
[143] Fix | Delete
// $can_upgrade = FALSE;
[144] Fix | Delete
}
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
$this->respond( array(
[148] Fix | Delete
'id' => $form_id,
[149] Fix | Delete
'title' => $settings[ 'form_title' ],
[150] Fix | Delete
'canUpgrade' => $can_upgrade
[151] Fix | Delete
) );
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
private function respond( $response = array() )
[155] Fix | Delete
{
[156] Fix | Delete
echo wp_json_encode( $response );
[157] Fix | Delete
wp_die(); // this is required to terminate immediately and return a proper response
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
public function settings_upgrade_button( $settings )
[161] Fix | Delete
{
[162] Fix | Delete
$settings['update_to_three'] = array(
[163] Fix | Delete
'name' => 'update_to_three',
[164] Fix | Delete
'type' => '',
[165] Fix | Delete
'label' => __('Ninja Forms THREE', 'ninja-forms'),
[166] Fix | Delete
'display_function' => array($this, 'settings_upgrade_button_display'),
[167] Fix | Delete
'desc' => __('Upgrade to the Ninja Forms THREE.', 'ninja-forms')
[168] Fix | Delete
);
[169] Fix | Delete
[170] Fix | Delete
return $settings;
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
public function settings_upgrade_button_display()
[174] Fix | Delete
{
[175] Fix | Delete
include plugin_dir_path( __FILE__ ) . 'tmpl-settings-upgrade-button.html.php';
[176] Fix | Delete
}
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
new NF_THREE_Submenu();
[180] Fix | Delete
[181] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function