Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/custom-t.../inc/Admin
File: addon-functions.php
<?php
[0] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* Deactivate addon.
[4] Fix | Delete
*
[5] Fix | Delete
* @since 1.0.0
[6] Fix | Delete
*/
[7] Fix | Delete
function ctf_deactivate_addon() {
[8] Fix | Delete
require_once trailingslashit( CTF_PLUGIN_DIR ) . 'inc/Admin/PluginSilentUpgrader.php';
[9] Fix | Delete
require_once trailingslashit( CTF_PLUGIN_DIR ) . 'inc/Admin/PluginSilentUpgraderSkin.php';
[10] Fix | Delete
require_once trailingslashit( CTF_PLUGIN_DIR ) . 'inc/Admin/class-install-skin.php';
[11] Fix | Delete
// Run a security check.
[12] Fix | Delete
check_ajax_referer( 'ctf-admin', 'nonce' );
[13] Fix | Delete
[14] Fix | Delete
// Check for permissions.
[15] Fix | Delete
if ( ! current_user_can( 'manage_options' ) ) {
[16] Fix | Delete
wp_send_json_error();
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
$type = 'addon';
[20] Fix | Delete
if ( ! empty( $_POST['type'] ) ) {
[21] Fix | Delete
$type = sanitize_key( $_POST['type'] );
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
if ( isset( $_POST['plugin'] ) ) {
[25] Fix | Delete
deactivate_plugins( $_POST['plugin'] );
[26] Fix | Delete
[27] Fix | Delete
if ( 'plugin' === $type ) {
[28] Fix | Delete
wp_send_json_success( esc_html__( 'Plugin deactivated.', 'custom-twitter-feeds' ) );
[29] Fix | Delete
} else {
[30] Fix | Delete
wp_send_json_success( esc_html__( 'Addon deactivated.', 'custom-twitter-feeds' ) );
[31] Fix | Delete
}
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
wp_send_json_error( esc_html__( 'Could not deactivate the addon. Please deactivate from the Plugins page.', 'custom-twitter-feeds' ) );
[35] Fix | Delete
}
[36] Fix | Delete
add_action( 'wp_ajax_ctf_deactivate_addon', 'ctf_deactivate_addon' );
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Activate addon.
[40] Fix | Delete
*
[41] Fix | Delete
* @since 1.0.0
[42] Fix | Delete
*/
[43] Fix | Delete
function ctf_activate_addon() {
[44] Fix | Delete
[45] Fix | Delete
require_once trailingslashit( CTF_PLUGIN_DIR ) . 'inc/Admin/PluginSilentUpgrader.php';
[46] Fix | Delete
require_once trailingslashit( CTF_PLUGIN_DIR ) . 'inc/Admin/PluginSilentUpgraderSkin.php';
[47] Fix | Delete
require_once trailingslashit( CTF_PLUGIN_DIR ) . 'inc/Admin/class-install-skin.php';
[48] Fix | Delete
// Run a security check.
[49] Fix | Delete
check_ajax_referer( 'ctf-admin', 'nonce' );
[50] Fix | Delete
// Check for permissions.
[51] Fix | Delete
if ( ! current_user_can( 'manage_options' ) ) {
[52] Fix | Delete
wp_send_json_error();
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
if ( isset( $_POST['plugin'] ) ) {
[56] Fix | Delete
[57] Fix | Delete
$type = 'addon';
[58] Fix | Delete
if ( ! empty( $_POST['type'] ) ) {
[59] Fix | Delete
$type = sanitize_key( $_POST['type'] );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
$activate = activate_plugins( $_POST['plugin'] );
[63] Fix | Delete
[64] Fix | Delete
if ( ! is_wp_error( $activate ) ) {
[65] Fix | Delete
if ( 'plugin' === $type ) {
[66] Fix | Delete
wp_send_json_success( esc_html__( 'Plugin activated.', 'custom-twitter-feeds' ) );
[67] Fix | Delete
} else {
[68] Fix | Delete
wp_send_json_success( esc_html__( 'Addon activated.', 'custom-twitter-feeds' ) );
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
wp_send_json_error( esc_html__( 'Could not activate addon. Please activate from the Plugins page.', 'custom-twitter-feeds' ) );
[74] Fix | Delete
}
[75] Fix | Delete
add_action( 'wp_ajax_ctf_activate_addon', 'ctf_activate_addon' );
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* Install addon.
[79] Fix | Delete
*
[80] Fix | Delete
* @since 2.0.0
[81] Fix | Delete
*/
[82] Fix | Delete
function ctf_install_addon() {
[83] Fix | Delete
require_once trailingslashit( CTF_PLUGIN_DIR ) . 'inc/Admin/PluginSilentUpgrader.php';
[84] Fix | Delete
require_once trailingslashit( CTF_PLUGIN_DIR ) . 'inc/Admin/PluginSilentUpgraderSkin.php';
[85] Fix | Delete
// Run a security check.
[86] Fix | Delete
check_ajax_referer( 'ctf-admin', 'nonce' );
[87] Fix | Delete
[88] Fix | Delete
// Check for permissions.
[89] Fix | Delete
if ( ! current_user_can( 'manage_options' ) ) {
[90] Fix | Delete
wp_send_json_error();
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
$error = esc_html__( 'Could not install addon. Please download from wpforms.com and install manually.', 'custom-twitter-feeds' );
[94] Fix | Delete
[95] Fix | Delete
if ( empty( $_POST['plugin'] ) ) {
[96] Fix | Delete
wp_send_json_error( $error );
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
// Set the current screen to avoid undefined notices.
[100] Fix | Delete
set_current_screen( 'custom-twitter-feeds' );
[101] Fix | Delete
[102] Fix | Delete
// Prepare variables.
[103] Fix | Delete
$url = esc_url_raw(
[104] Fix | Delete
add_query_arg(
[105] Fix | Delete
array(
[106] Fix | Delete
'page' => 'custom-twitter-feeds',
[107] Fix | Delete
),
[108] Fix | Delete
admin_url( 'admin.php' )
[109] Fix | Delete
)
[110] Fix | Delete
);
[111] Fix | Delete
[112] Fix | Delete
$creds = request_filesystem_credentials( $url, '', false, false, null );
[113] Fix | Delete
[114] Fix | Delete
// Check for file system permissions.
[115] Fix | Delete
if ( false === $creds ) {
[116] Fix | Delete
wp_send_json_error( $error );
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
if ( ! WP_Filesystem( $creds ) ) {
[120] Fix | Delete
wp_send_json_error( $error );
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/*
[124] Fix | Delete
* We do not need any extra credentials if we have gotten this far, so let's install the plugin.
[125] Fix | Delete
*/
[126] Fix | Delete
[127] Fix | Delete
require_once CTF_PLUGIN_DIR . 'inc/Admin/class-install-skin.php';
[128] Fix | Delete
[129] Fix | Delete
// Do not allow WordPress to search/download translations, as this will break JS output.
[130] Fix | Delete
remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
[131] Fix | Delete
[132] Fix | Delete
// Create the plugin upgrader with our custom skin.
[133] Fix | Delete
$installer = new CTF\Helpers\PluginSilentUpgrader( new CTF_Install_Skin() );
[134] Fix | Delete
[135] Fix | Delete
// Error check.
[136] Fix | Delete
if ( ! method_exists( $installer, 'install' ) || empty( $_POST['plugin'] ) ) {
[137] Fix | Delete
wp_send_json_error( $error );
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
$installer->install( $_POST['plugin'] ); // phpcs:ignore
[141] Fix | Delete
[142] Fix | Delete
// Flush the cache and return the newly installed plugin basename.
[143] Fix | Delete
wp_cache_flush();
[144] Fix | Delete
[145] Fix | Delete
$plugin_basename = $installer->plugin_info();
[146] Fix | Delete
[147] Fix | Delete
if ( $plugin_basename ) {
[148] Fix | Delete
[149] Fix | Delete
$type = 'addon';
[150] Fix | Delete
if ( ! empty( $_POST['type'] ) ) {
[151] Fix | Delete
$type = sanitize_key( $_POST['type'] );
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
// Activate the plugin silently.
[155] Fix | Delete
$activated = activate_plugin( $plugin_basename );
[156] Fix | Delete
[157] Fix | Delete
if ( ! is_wp_error( $activated ) ) {
[158] Fix | Delete
wp_send_json_success(
[159] Fix | Delete
array(
[160] Fix | Delete
'msg' => 'plugin' === $type ? esc_html__( 'Plugin installed & activated.', 'custom-twitter-feeds' ) : esc_html__( 'Addon installed & activated.', 'custom-twitter-feeds' ),
[161] Fix | Delete
'is_activated' => true,
[162] Fix | Delete
'basename' => $plugin_basename,
[163] Fix | Delete
)
[164] Fix | Delete
);
[165] Fix | Delete
} else {
[166] Fix | Delete
wp_send_json_success(
[167] Fix | Delete
array(
[168] Fix | Delete
'msg' => 'plugin' === $type ? esc_html__( 'Plugin installed.', 'custom-twitter-feeds' ) : esc_html__( 'Addon installed.', 'custom-twitter-feeds' ),
[169] Fix | Delete
'is_activated' => false,
[170] Fix | Delete
'basename' => $plugin_basename,
[171] Fix | Delete
)
[172] Fix | Delete
);
[173] Fix | Delete
}
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
wp_send_json_error( $error );
[177] Fix | Delete
}
[178] Fix | Delete
add_action( 'wp_ajax_ctf_install_addon', 'ctf_install_addon' );
[179] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function