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.../com/classes/_detecti...
File: SgpbPopupVersionDetection.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace sgpb;
[2] Fix | Delete
[3] Fix | Delete
[4] Fix | Delete
class SgpbPopupVersionDetection
[5] Fix | Delete
{
[6] Fix | Delete
public static function compareVersions()
[7] Fix | Delete
{
[8] Fix | Delete
if(!self::checkIfIsOnPopupPage()) // check if user is in popup builder page (only admin pages)
[9] Fix | Delete
{
[10] Fix | Delete
return [];
[11] Fix | Delete
}
[12] Fix | Delete
wp_update_plugins(); // Check for plugin updates.
[13] Fix | Delete
$plugin_info = get_site_transient("update_plugins"); // get plugins to update
[14] Fix | Delete
$registeredPlugins = AdminHelper::getAllExtensions(); // getting active PopupBuilder plugins
[15] Fix | Delete
$hasOldPlugin = [];
[16] Fix | Delete
[17] Fix | Delete
foreach($registeredPlugins["active"] as $plugin) {
[18] Fix | Delete
$pluginData = get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin["pluginKey"]); // getting plugin registered data
[19] Fix | Delete
$plugin["name"] = $pluginData["Name"]; // setting name in plugin array! this is for frontend to show full name
[20] Fix | Delete
$plugin_slug = null;
[21] Fix | Delete
if ($plugin["pluginKey"] === 'popupbuilder-edd/PopupBuilderEdd.php') {
[22] Fix | Delete
if (empty($plugin_info->response[$plugin["pluginKey"]])) {
[23] Fix | Delete
$plugin["pluginKey"] = str_replace("\\","/",WP_PLUGIN_DIR).'/'.$plugin["pluginKey"];
[24] Fix | Delete
}
[25] Fix | Delete
}
[26] Fix | Delete
if(isset($plugin_info->response[$plugin["pluginKey"]])) {
[27] Fix | Delete
$plugin_slug = $plugin_info->response[$plugin["pluginKey"]]->slug; // getting current slug generated by wordpress without slug will not update the plugin
[28] Fix | Delete
}
[29] Fix | Delete
/* this logic will work only < stable versions */
[30] Fix | Delete
if(version_compare($plugin["stable_version"], $pluginData["Version"], ">")) {
[31] Fix | Delete
$hasLicense = self::getLicenseOfPlugin($plugin);
[32] Fix | Delete
$hasOldPlugin[] = [
[33] Fix | Delete
"plugin" => $plugin,
[34] Fix | Delete
"message" => self::pluginUpdateMessage("extensions"),
[35] Fix | Delete
"license" => $hasLicense,
[36] Fix | Delete
"slug" => $plugin_slug,
[37] Fix | Delete
];
[38] Fix | Delete
}
[39] Fix | Delete
}
[40] Fix | Delete
$filteredByLicense = self::pluginUpdateMessage(self::filterPluginsByLicense($hasOldPlugin));
[41] Fix | Delete
[42] Fix | Delete
return $filteredByLicense;
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
private static function pluginUpdateMessage($filteredByLicense)
[46] Fix | Delete
{
[47] Fix | Delete
if(empty($filteredByLicense)) {
[48] Fix | Delete
return [];
[49] Fix | Delete
}
[50] Fix | Delete
$headerMessage = empty($filteredByLicense["autoUpdate"]) ? 'You use major updated version of Popup Builder' : 'Updating active Popup Builder extensions';
[51] Fix | Delete
$adminLicenseUrl = admin_url("edit.php?post_type=".SG_POPUP_POST_TYPE."&page=".SGPB_POPUP_LICENSE);
[52] Fix | Delete
[53] Fix | Delete
$modalData = [
[54] Fix | Delete
"header" => '<h3 class="sgpb-modal-detection-header">'.$headerMessage.'</h3>',
[55] Fix | Delete
"logo" => SG_POPUP_IMG_URL.'sgpbLogo.png',
[56] Fix | Delete
"manualMessage" => '<p class="sgpb-text-center">As you don’t have updates for the extensions listed below, you will have issues using the plugin.
[57] Fix | Delete
<br>Please do the following in order to use the plugin properly:</p>
[58] Fix | Delete
<p class="sgpb-margin-top-10 sgpb-text-center" style="font-style: italic">If you don’t have an active license, purchase a new one.</p>
[59] Fix | Delete
<p class="sgpb-text-center">OR</p>
[60] Fix | Delete
<p class="sgpb-text-center" style="font-style: italic">If you have an active license, add its license code <a href="'.$adminLicenseUrl.'">here</a>.</p>',
[61] Fix | Delete
"footerMessage" => '<p class="sgpb-modal-footer-message sgpb-margin-top-30 sgpb-text-center" style="font-style: italic">You can download the previous version of Popup Builder Plugin from <a href="https://downloads.wordpress.org/plugin/popup-builder.3.83.zip">here</a>.</p>'
[62] Fix | Delete
];
[63] Fix | Delete
[64] Fix | Delete
return array(
[65] Fix | Delete
"modalData" => $modalData,
[66] Fix | Delete
"autoUpdate" => empty($filteredByLicense['autoUpdate']) ? [] : $filteredByLicense['autoUpdate'],
[67] Fix | Delete
"manualUpdate" => empty($filteredByLicense['manualUpdate']) ? [] : $filteredByLicense['manualUpdate'],
[68] Fix | Delete
);
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
private static function checkIfIsOnPopupPage()
[72] Fix | Delete
{
[73] Fix | Delete
if("popupbuilder_page_license" === get_current_screen()->id) {
[74] Fix | Delete
return false;
[75] Fix | Delete
}
[76] Fix | Delete
switch(get_current_screen()->post_type) {
[77] Fix | Delete
case SG_POPUP_POST_TYPE:
[78] Fix | Delete
case "sgpbtemplate":
[79] Fix | Delete
case "sgpbautoresponder":
[80] Fix | Delete
return true;
[81] Fix | Delete
default:
[82] Fix | Delete
return false;
[83] Fix | Delete
}
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
private static function getLicenseOfPlugin($oldPlugins)
[87] Fix | Delete
{
[88] Fix | Delete
[89] Fix | Delete
$licenseClass = new License();
[90] Fix | Delete
$licenses = $licenseClass->getLicenses();
[91] Fix | Delete
[92] Fix | Delete
foreach($licenses as $license) {
[93] Fix | Delete
if(false === array_search($license['file'], $oldPlugins) && 'POPUP_EDD' !== $license['key']) {
[94] Fix | Delete
continue;
[95] Fix | Delete
}
[96] Fix | Delete
if ('POPUP_EDD' !== $license['key'] && false === array_search(str_replace("\\","/",$license['file']), $oldPlugins)) {
[97] Fix | Delete
continue;
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
$key = isset($license["key"]) ?$license["key"] : '' ;
[101] Fix | Delete
$licenseKey = trim(get_option("sgpb-license-key-".$key));
[102] Fix | Delete
$status = get_option("sgpb-license-status-".$key);
[103] Fix | Delete
$license["option_key"] = $licenseKey;
[104] Fix | Delete
$license["option_status"] = $status;
[105] Fix | Delete
if($status == false || $status != "valid") {
[106] Fix | Delete
return false;
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
return $license;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
return false;
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
private static function filterPluginsByLicense($extensions)
[116] Fix | Delete
{
[117] Fix | Delete
if(empty($extensions)) {
[118] Fix | Delete
return [];
[119] Fix | Delete
}
[120] Fix | Delete
$extensionsToUpdateNow = array_filter($extensions, function($extension){
[121] Fix | Delete
return $extension["license"] !== false;
[122] Fix | Delete
});
[123] Fix | Delete
$extensionsToUpdate = array_filter($extensions, function($extension){
[124] Fix | Delete
return $extension["license"] == false;
[125] Fix | Delete
});
[126] Fix | Delete
[127] Fix | Delete
wp_enqueue_script("updates");
[128] Fix | Delete
[129] Fix | Delete
return [
[130] Fix | Delete
"autoUpdate" => array_values($extensionsToUpdateNow),
[131] Fix | Delete
"manualUpdate" => array_values($extensionsToUpdate)
[132] Fix | Delete
];
[133] Fix | Delete
}
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function