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/clone/wp-conte.../plugins/popup-bu.../public/views
File: importConfigView.php
<?php
[0] Fix | Delete
/* Exit if accessed directly */
[1] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[2] Fix | Delete
exit;
[3] Fix | Delete
}
[4] Fix | Delete
use sgpb\AdminHelper;
[5] Fix | Delete
use sgpb\SubscriptionPopup;
[6] Fix | Delete
@ini_set('auto_detect_line_endings', '1');
[7] Fix | Delete
[8] Fix | Delete
// Check if file URL is provided
[9] Fix | Delete
if (empty($fileURL)) {
[10] Fix | Delete
// Handle the case where the file URL is not provided
[11] Fix | Delete
echo "ERROR-File URL is missing.";
[12] Fix | Delete
wp_die();
[13] Fix | Delete
}
[14] Fix | Delete
// Extract file extension from the URL
[15] Fix | Delete
$fileExtension = pathinfo($fileURL, PATHINFO_EXTENSION);
[16] Fix | Delete
[17] Fix | Delete
// Check if the file has a CSV extension
[18] Fix | Delete
if (strtolower($fileExtension) !== 'csv') {
[19] Fix | Delete
// Handle the case where the file is not a CSV file
[20] Fix | Delete
echo "ERROR-The provided file is not a CSV file.";
[21] Fix | Delete
wp_die();
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
// Download file content from the URL
[25] Fix | Delete
$fileContent = AdminHelper::getFileFromURL($fileURL);
[26] Fix | Delete
[27] Fix | Delete
// Check if file content is empty or invalid
[28] Fix | Delete
if (empty($fileContent)) {
[29] Fix | Delete
// Handle the case where the file content is empty or invalid
[30] Fix | Delete
echo "ERROR-Failed to retrieve valid file content from the URL.";
[31] Fix | Delete
wp_die();
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
// Parse CSV file content into an array
[35] Fix | Delete
$csvFileArray = array_map('str_getcsv', explode("\n", $fileContent));
[36] Fix | Delete
[37] Fix | Delete
// Check if the CSV parsing was successful
[38] Fix | Delete
if ($csvFileArray === false || count($csvFileArray) === 0) {
[39] Fix | Delete
// Handle the case where CSV parsing failed or resulted in an empty array
[40] Fix | Delete
echo "ERROR-Failed to parse CSV file content.";
[41] Fix | Delete
wp_die();
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
$ourFieldsArgs = array(
[45] Fix | Delete
'class' => 'js-sg-select2 sgpb-our-fields-keys select__select'
[46] Fix | Delete
);
[47] Fix | Delete
[48] Fix | Delete
$formData = array('' => 'Select Field') + AdminHelper::getSubscriptionColumnsById($formId);
[49] Fix | Delete
?>
[50] Fix | Delete
[51] Fix | Delete
<div id="importSubscribersSecondStep">
[52] Fix | Delete
<h1 id="importSubscriberHeader"><?php esc_html_e('Match Your Fields', 'popup-builder'); ?></h1>
[53] Fix | Delete
<div id="importSubscriberBody">
[54] Fix | Delete
<div class="formItem sgpb-justify-content-around">
[55] Fix | Delete
<div class="formItem__title">
[56] Fix | Delete
<?php esc_html_e('Available fields', 'popup-builder'); ?>
[57] Fix | Delete
</div>
[58] Fix | Delete
<div class="formItem__title">
[59] Fix | Delete
<?php esc_html_e('Our list fields', 'popup-builder'); ?>
[60] Fix | Delete
</div>
[61] Fix | Delete
</div>
[62] Fix | Delete
<?php foreach($csvFileArray[0] as $index => $current): ?>
[63] Fix | Delete
<?php if (empty($current) || $current == 'popup'): ?>
[64] Fix | Delete
<?php continue; ?>
[65] Fix | Delete
<?php endif; ?>
[66] Fix | Delete
<div class="formItem sgpb-justify-content-between">
[67] Fix | Delete
<div class="subFormItem__title">
[68] Fix | Delete
<?php echo esc_html($current); ?>
[69] Fix | Delete
</div>
[70] Fix | Delete
<div>
[71] Fix | Delete
<?php
[72] Fix | Delete
$ourFieldsArgs['data-index'] = $index;
[73] Fix | Delete
echo wp_kses(AdminHelper::createSelectBox($formData, '', $ourFieldsArgs), AdminHelper::allowed_html_tags());
[74] Fix | Delete
?>
[75] Fix | Delete
</div>
[76] Fix | Delete
</div>
[77] Fix | Delete
<?php endforeach;?>
[78] Fix | Delete
<input type="hidden" class="sgpb-to-import-popup-id" value="<?php echo esc_attr($formId)?>">
[79] Fix | Delete
<input type="hidden" class="sgpb-imported-file-url" value="<?php echo esc_attr($fileURL)?>">
[80] Fix | Delete
</div>
[81] Fix | Delete
[82] Fix | Delete
<div id="importSubscriberFooter">
[83] Fix | Delete
<input type="button" value="<?php esc_html_e('Save', 'popup-builder'); ?>" class="sgpb-btn sgpb-btn-blue sgpb-save-subscriber" data-ajaxnonce="popupBuilderAjaxNonce">
[84] Fix | Delete
</div>
[85] Fix | Delete
[86] Fix | Delete
</div>
[87] Fix | Delete
[88] Fix | Delete
[89] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function