Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../includes/Integrat...
File: sendwp.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// Ajax called handled just below
[2] Fix | Delete
add_action( 'wp_ajax_ninja_forms_sendwp_remote_install', 'wp_ajax_ninja_forms_sendwp_remote_install_handler' );
[3] Fix | Delete
[4] Fix | Delete
function wp_ajax_ninja_forms_sendwp_remote_install_handler () {
[5] Fix | Delete
[6] Fix | Delete
$all_plugins = get_plugins();
[7] Fix | Delete
$is_sendwp_installed = false;
[8] Fix | Delete
foreach(get_plugins() as $path => $details ) {
[9] Fix | Delete
if(false === strpos($path, '/sendwp.php')) continue;
[10] Fix | Delete
$is_sendwp_installed = true;
[11] Fix | Delete
activate_plugin( $path );
[12] Fix | Delete
break;
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
if( ! $is_sendwp_installed ) {
[16] Fix | Delete
[17] Fix | Delete
$plugin_slug = 'sendwp';
[18] Fix | Delete
[19] Fix | Delete
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
[20] Fix | Delete
include_once ABSPATH . 'wp-admin/includes/file.php';
[21] Fix | Delete
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
[22] Fix | Delete
[23] Fix | Delete
/*
[24] Fix | Delete
* Use the WordPress Plugins API to get the plugin download link.
[25] Fix | Delete
*/
[26] Fix | Delete
$api = plugins_api( 'plugin_information', array(
[27] Fix | Delete
'slug' => $plugin_slug,
[28] Fix | Delete
) );
[29] Fix | Delete
if ( is_wp_error( $api ) ) {
[30] Fix | Delete
ob_end_clean();
[31] Fix | Delete
echo json_encode( array( 'error' => $api->get_error_message(), 'debug' => $api ) );
[32] Fix | Delete
exit;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
/*
[36] Fix | Delete
* Use the AJAX Upgrader skin to quietly install the plugin.
[37] Fix | Delete
*/
[38] Fix | Delete
$upgrader = new Plugin_Upgrader( new WP_Ajax_Upgrader_Skin() );
[39] Fix | Delete
$install = $upgrader->install( $api->download_link );
[40] Fix | Delete
if ( is_wp_error( $install ) ) {
[41] Fix | Delete
ob_end_clean();
[42] Fix | Delete
echo json_encode( array( 'error' => $install->get_error_message(), 'debug' => $api ) );
[43] Fix | Delete
exit;
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/*
[47] Fix | Delete
* Activate the plugin based on the results of the upgrader.
[48] Fix | Delete
* @NOTE Assume this works, if the download works - otherwise there is a false positive if the plugin is already installed.
[49] Fix | Delete
*/
[50] Fix | Delete
$activated = activate_plugin( $upgrader->plugin_info() );
[51] Fix | Delete
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/*
[55] Fix | Delete
* Final check to see if SendWP is available.
[56] Fix | Delete
*/
[57] Fix | Delete
if( ! function_exists('sendwp_get_server_url') ) {
[58] Fix | Delete
ob_end_clean();
[59] Fix | Delete
echo json_encode( array(
[60] Fix | Delete
'error' => esc_html__( 'Something went wrong. SendWP was not installed correctly.' ),
[61] Fix | Delete
'install' => $install,
[62] Fix | Delete
) );
[63] Fix | Delete
exit;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
echo json_encode( array(
[67] Fix | Delete
'partner_id' => 16,
[68] Fix | Delete
'register_url' => esc_url(sendwp_get_server_url() . '_/signup'),
[69] Fix | Delete
'client_name' => esc_attr( sendwp_get_client_name() ),
[70] Fix | Delete
'client_secret' => esc_attr( sendwp_get_client_secret() ),
[71] Fix | Delete
'client_redirect' => esc_url(sendwp_get_client_redirect()),
[72] Fix | Delete
) );
[73] Fix | Delete
exit;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function