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/popup-bu.../com/classes
File: ConvertToNewVersion.php
<?php
[0] Fix | Delete
namespace sgpb;
[1] Fix | Delete
use sgpb\AdminHelper;
[2] Fix | Delete
use \SGPBConfigDataHelper;
[3] Fix | Delete
[4] Fix | Delete
class ConvertToNewVersion
[5] Fix | Delete
{
[6] Fix | Delete
private $id;
[7] Fix | Delete
private $content = '';
[8] Fix | Delete
private $type;
[9] Fix | Delete
private $title;
[10] Fix | Delete
private $options;
[11] Fix | Delete
private $customOptions = array();
[12] Fix | Delete
[13] Fix | Delete
public function setContent($content)
[14] Fix | Delete
{
[15] Fix | Delete
$this->content = $content;
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
public function getContent()
[19] Fix | Delete
{
[20] Fix | Delete
return $this->content;
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
public function setType($type)
[24] Fix | Delete
{
[25] Fix | Delete
if ($type == 'shortcode') {
[26] Fix | Delete
$type = 'html';
[27] Fix | Delete
}
[28] Fix | Delete
$this->type = $type;
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
public function getType()
[32] Fix | Delete
{
[33] Fix | Delete
return $this->type;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
public function setTitle($title)
[37] Fix | Delete
{
[38] Fix | Delete
$this->title = $title;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
public function getTitle()
[42] Fix | Delete
{
[43] Fix | Delete
return $this->title;
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
public function setId($id)
[47] Fix | Delete
{
[48] Fix | Delete
$this->id = (int)$id;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
public function getId()
[52] Fix | Delete
{
[53] Fix | Delete
return $this->id;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
public function setOptions($options)
[57] Fix | Delete
{
[58] Fix | Delete
$this->options = $options;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
public function getOptions()
[62] Fix | Delete
{
[63] Fix | Delete
return $this->options;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
public function setCustomOptions($customOptions)
[67] Fix | Delete
{
[68] Fix | Delete
$this->customOptions = $customOptions;
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
public function getCustomOptions()
[72] Fix | Delete
{
[73] Fix | Delete
return $this->customOptions;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
public static function convert()
[77] Fix | Delete
{
[78] Fix | Delete
$obj = new self();
[79] Fix | Delete
$obj->insertDataToNew();
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
public function insertDataToNew()
[83] Fix | Delete
{
[84] Fix | Delete
$idsMapping = array();
[85] Fix | Delete
Installer::install();
[86] Fix | Delete
Installer::registerPlugin();
[87] Fix | Delete
$popups = $this->getAllSavedPopups();
[88] Fix | Delete
$this->convertSettings();
[89] Fix | Delete
[90] Fix | Delete
$arr = array();
[91] Fix | Delete
$popupPreviewId = get_option('popupPreviewId');
[92] Fix | Delete
foreach ($popups as $popup) {
[93] Fix | Delete
if (empty($popup)) {
[94] Fix | Delete
continue;
[95] Fix | Delete
}
[96] Fix | Delete
// we should not convert preview popup
[97] Fix | Delete
if ($popup['id'] == $popupPreviewId) {
[98] Fix | Delete
continue;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
$popupObj = $this->popupObjectFromArray($popup);
[102] Fix | Delete
$arr[] = $popupObj;
[103] Fix | Delete
$args = array(
[104] Fix | Delete
'post_title' => $popupObj->getTitle(),
[105] Fix | Delete
'post_content' => $popupObj->getContent(),
[106] Fix | Delete
'post_status' => 'publish',
[107] Fix | Delete
'post_type' => SG_POPUP_POST_TYPE
[108] Fix | Delete
);
[109] Fix | Delete
$id = $popupObj->getId();
[110] Fix | Delete
$newOptions = $this->getNewOptionsFormSavedData($popupObj);
[111] Fix | Delete
$newPopupId = @wp_insert_post($args);
[112] Fix | Delete
$newOptions['sgpb-post-id'] = $newPopupId;
[113] Fix | Delete
$this->saveOtherOptions($newOptions);
[114] Fix | Delete
[115] Fix | Delete
update_post_meta($newPopupId, 'sg_popup_options', $newOptions);
[116] Fix | Delete
$idsMapping[$id] = $newPopupId;
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
$this->convertCounter($idsMapping);
[120] Fix | Delete
$this->convertSubscribers();
[121] Fix | Delete
[122] Fix | Delete
update_option('sgpbConvertedIds', $idsMapping);
[123] Fix | Delete
[124] Fix | Delete
return $arr;
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
public function convertSubscribers()
[128] Fix | Delete
{
[129] Fix | Delete
global $wpdb;
[130] Fix | Delete
$oldsubscribersTableName = $wpdb->prefix.'sg_subscribers';
[131] Fix | Delete
$subscribersTableName = $wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME;
[132] Fix | Delete
$subscribers = $wpdb->get_results( $wpdb->prepare( "SELECT `id`, `firstName`, `lastName`, `email`, `subscriptionType`, `status` from $oldsubscribersTableName" ), ARRAY_A);
[133] Fix | Delete
[134] Fix | Delete
if (empty($subscribers)) {
[135] Fix | Delete
return false;
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
foreach ($subscribers as $subscriber) {
[139] Fix | Delete
$subscriber['subscriptionType'] = $this->getPostByTitle($subscriber['subscriptionType']);
[140] Fix | Delete
$date = gmdate('Y-m-d');
[141] Fix | Delete
$wpdb->query( $wpdb->prepare("INSERT INTO $subscribersTableName (`firstName`, `lastName`, `email`, `cDate`, `subscriptionType`, `unsubscribed`) VALUES (%s, %s, %s, %s, %d, %d) ", $subscriber['firstName'], $subscriber['lastName'], $subscriber['email'], $date, $subscriber['subscriptionType'], 0) );
[142] Fix | Delete
}
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
private function getPostByTitle($pageTitle, $output = OBJECT)
[146] Fix | Delete
{
[147] Fix | Delete
global $wpdb;
[148] Fix | Delete
$post = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type='popupbuilder'", $pageTitle));
[149] Fix | Delete
if (!empty($post)) {
[150] Fix | Delete
return get_post($post, $output)->ID;
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
return null;
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
/**
[157] Fix | Delete
* Convert settings section saved options to new version
[158] Fix | Delete
*
[159] Fix | Delete
* @since 2.6.7.6
[160] Fix | Delete
*
[161] Fix | Delete
* @return bool
[162] Fix | Delete
*/
[163] Fix | Delete
private function convertSettings()
[164] Fix | Delete
{
[165] Fix | Delete
global $wpdb;
[166] Fix | Delete
$settings = $wpdb->get_row('SELECT options FROM '.$wpdb->prefix .'sg_popup_settings WHERE id = 1', ARRAY_A);
[167] Fix | Delete
[168] Fix | Delete
if (empty($settings['options'])) {
[169] Fix | Delete
return false;
[170] Fix | Delete
}
[171] Fix | Delete
$settings = json_decode($settings['options'], true);
[172] Fix | Delete
[173] Fix | Delete
$deleteData = 0;
[174] Fix | Delete
[175] Fix | Delete
if (!empty($settings['tables-delete-status'])) {
[176] Fix | Delete
$deleteData = 1;
[177] Fix | Delete
}
[178] Fix | Delete
$userRoles = $settings['plugin_users_role'];
[179] Fix | Delete
[180] Fix | Delete
if (empty($userRoles) || !is_array($userRoles)) {
[181] Fix | Delete
$userRoles = array();
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
$userRoles = array_map(function($role) {
[185] Fix | Delete
// it's remove sgpb_ keyword from selected values
[186] Fix | Delete
$role = substr($role, 5, strlen($role)-1);
[187] Fix | Delete
[188] Fix | Delete
return $role;
[189] Fix | Delete
}, $userRoles);
[190] Fix | Delete
[191] Fix | Delete
update_option('sgpb-user-roles', $userRoles);
[192] Fix | Delete
update_option('sgpb-dont-delete-data', $deleteData);
[193] Fix | Delete
[194] Fix | Delete
return true;
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
private function convertCounter($idsMapping)
[198] Fix | Delete
{
[199] Fix | Delete
$oldCounter = get_option('SgpbCounter');
[200] Fix | Delete
[201] Fix | Delete
if (!$oldCounter) {
[202] Fix | Delete
return false;
[203] Fix | Delete
}
[204] Fix | Delete
$newCounter = array();
[205] Fix | Delete
foreach ($oldCounter as $key => $value) {
[206] Fix | Delete
if (isset($idsMapping[$key])){
[207] Fix | Delete
$newId = $idsMapping[$key];
[208] Fix | Delete
$newCounter[$newId] = $value;
[209] Fix | Delete
}
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
update_option('SgpbCounter', $newCounter);
[213] Fix | Delete
[214] Fix | Delete
return true;
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
[218] Fix | Delete
private function getAllSavedPopups()
[219] Fix | Delete
{
[220] Fix | Delete
global $wpdb;
[221] Fix | Delete
$oldsg_popupsTableName = $wpdb->prefix.'sg_popup';
[222] Fix | Delete
$popups = $wpdb->get_results( $wpdb->prepare("SELECT `id`, `type`, `title`, `options` from $oldsg_popupsTableName ORDER BY id" ), ARRAY_A);
[223] Fix | Delete
[224] Fix | Delete
return $popups;
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
public function getNewOptionsFormSavedData($popup)
[228] Fix | Delete
{
[229] Fix | Delete
$options = $popup->getOptions();
[230] Fix | Delete
$customOptions = $popup->getCustomOptions();
[231] Fix | Delete
$options = array_merge($options, $customOptions);
[232] Fix | Delete
// return addons event from add_connections data
[233] Fix | Delete
$addonsEvent = $this->getAddonsEventFromPopup($popup);
[234] Fix | Delete
if ($addonsEvent) {
[235] Fix | Delete
$options = array_merge($options, $addonsEvent);
[236] Fix | Delete
}
[237] Fix | Delete
$options = $this->filterOptions($options);
[238] Fix | Delete
[239] Fix | Delete
$names = $this->getNamesMapping();
[240] Fix | Delete
$newData = array();
[241] Fix | Delete
$type = $popup->getType();
[242] Fix | Delete
[243] Fix | Delete
if (empty($names)) {
[244] Fix | Delete
return $newData;
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
$newData['sgpb-type'] = $type;
[248] Fix | Delete
[249] Fix | Delete
foreach ($names as $oldName => $newName) {
[250] Fix | Delete
if (isset($options[$oldName])) {
[251] Fix | Delete
$optionName = $this->changeOldValues($oldName, $options[$oldName]);
[252] Fix | Delete
$newData[$newName] = $optionName;
[253] Fix | Delete
}
[254] Fix | Delete
}
[255] Fix | Delete
$newData['sgpb-enable-popup-overlay'] = 'on';
[256] Fix | Delete
$newData['sgpb-show-background'] = 'on';
[257] Fix | Delete
[258] Fix | Delete
return $newData;
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
private function saveOtherOptions($options)
[262] Fix | Delete
{
[263] Fix | Delete
$popupId = (int)$options['sgpb-post-id'];
[264] Fix | Delete
$mobileOperator = '';
[265] Fix | Delete
$conditions = array();
[266] Fix | Delete
$conditions['sgpb-target'] = array(array(array('param' => 'not_rule')));
[267] Fix | Delete
$conditions['sgpb-conditions'] = array(array());
[268] Fix | Delete
[269] Fix | Delete
$eventsInitialData = array(
[270] Fix | Delete
array(
[271] Fix | Delete
)
[272] Fix | Delete
);
[273] Fix | Delete
[274] Fix | Delete
if (!empty($options['sgpb-option-exit-intent-enable'])) {
[275] Fix | Delete
$eventsInitialData[0][] = array(
[276] Fix | Delete
'param' => 'exitIntent',
[277] Fix | Delete
'value' => isset($options['sgpb-option-exit-intent-type']) ? $options['sgpb-option-exit-intent-type'] : '',
[278] Fix | Delete
'hiddenOption' => array(
[279] Fix | Delete
'sgpb-exit-intent-expire-time' => isset($options['sgpb-exit-intent-expire-time']) ? $options['sgpb-exit-intent-expire-time'] : '',
[280] Fix | Delete
'sgpb-exit-intent-cookie-level' => isset($options['sgpb-exit-intent-cookie-level']) ? $options['sgpb-exit-intent-cookie-level'] : '',
[281] Fix | Delete
'sgpb-exit-intent-soft-from-top' => isset($options['sgpb-exit-intent-soft-from-top']) ? $options['sgpb-exit-intent-soft-from-top'] : ''
[282] Fix | Delete
)
[283] Fix | Delete
);
[284] Fix | Delete
}
[285] Fix | Delete
else if (!empty($options['sgpb-option-enable-ad-block'])) {
[286] Fix | Delete
$eventsInitialData[0][] = array(
[287] Fix | Delete
'param' => 'AdBlock',
[288] Fix | Delete
'value' => $options['sgpb-popup-delay'],
[289] Fix | Delete
'hiddenOption' => array()
[290] Fix | Delete
);
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
// after inactivity
[294] Fix | Delete
if (!empty($options['sgpb-inactivity-status'])) {
[295] Fix | Delete
$eventsInitialData[0][] = array(
[296] Fix | Delete
'param' => 'inactivity',
[297] Fix | Delete
'value' => isset($options['sgpb-inactivity-timer']) ? $options['sgpb-inactivity-timer'] : '',
[298] Fix | Delete
'hiddenOption' => array()
[299] Fix | Delete
);
[300] Fix | Delete
}
[301] Fix | Delete
[302] Fix | Delete
// after scroll
[303] Fix | Delete
if (!empty($options['sgpb-onscroll-status'])) {
[304] Fix | Delete
$eventsInitialData[0][] = array(
[305] Fix | Delete
'param' => 'onScroll',
[306] Fix | Delete
'value' => isset($options['sgpb-onscroll-percentage']) ? $options['sgpb-onscroll-percentage'] : '',
[307] Fix | Delete
'hiddenOption' => array()
[308] Fix | Delete
);
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
if (empty($eventsInitialData[0])) {
[312] Fix | Delete
$eventsInitialData[0][] = array('param' => 'load', 'value' => '');
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
update_post_meta($popupId, 'sg_popup_events', $eventsInitialData);
[316] Fix | Delete
[317] Fix | Delete
// by user status (logged in/out)
[318] Fix | Delete
if (!empty($options['sgpb-by-user-status'])) {
[319] Fix | Delete
$operator = '==';
[320] Fix | Delete
if (isset($options['sgpb-for-logged-in-user']) && $options['sgpb-for-logged-in-user'] === 'false') {
[321] Fix | Delete
$operator = '!=';
[322] Fix | Delete
}
[323] Fix | Delete
$conditions['sgpb-conditions'][0][] = array(
[324] Fix | Delete
'param' => 'groups_user_role',
[325] Fix | Delete
'operator' => $operator,
[326] Fix | Delete
'value' => 'loggedIn'
[327] Fix | Delete
);
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
// hide or show on mobile
[331] Fix | Delete
if (isset($options['sgpb-hide-on-mobile']) && $options['sgpb-hide-on-mobile'] == 'on') {
[332] Fix | Delete
$conditions['sgpb-conditions'][0][] = array(
[333] Fix | Delete
'param' => 'groups_devices',
[334] Fix | Delete
'operator' => '!=',
[335] Fix | Delete
'value' => array(
[336] Fix | Delete
'is_mobile'
[337] Fix | Delete
)
[338] Fix | Delete
);
[339] Fix | Delete
}
[340] Fix | Delete
if (isset($options['sgpb-only-on-mobile']) && $options['sgpb-only-on-mobile'] == 'on') {
[341] Fix | Delete
$conditions['sgpb-conditions'][0][] = array(
[342] Fix | Delete
'param' => 'groups_devices',
[343] Fix | Delete
'operator' => '==',
[344] Fix | Delete
'value' => array(
[345] Fix | Delete
'is_mobile'
[346] Fix | Delete
)
[347] Fix | Delete
);
[348] Fix | Delete
}
[349] Fix | Delete
[350] Fix | Delete
// detect by country
[351] Fix | Delete
if (isset($options['sgpb-by-country']) && $options['sgpb-by-country'] == 'on') {
[352] Fix | Delete
if (isset($options['sgpb-allow-countries'])) {
[353] Fix | Delete
$options['sgpb-allow-countries'] = '!=';
[354] Fix | Delete
if ($options['sgpb-allow-countries'] == 'allow') {
[355] Fix | Delete
$options['sgpb-allow-countries'] = '==';
[356] Fix | Delete
}
[357] Fix | Delete
}
[358] Fix | Delete
$conditions['sgpb-conditions'][0][] = array(
[359] Fix | Delete
'param' => 'groups_countries',
[360] Fix | Delete
'operator' => isset($options['sgpb-allow-countries']) ? $options['sgpb-allow-countries'] : '',
[361] Fix | Delete
'value' => explode(',', (isset($options['sgpb-countries-iso']) ? $options['sgpb-countries-iso'] : ''))
[362] Fix | Delete
);
[363] Fix | Delete
}
[364] Fix | Delete
[365] Fix | Delete
update_post_meta($popupId, 'sg_popup_target', $conditions);
[366] Fix | Delete
[367] Fix | Delete
// random popup
[368] Fix | Delete
if (isset($options['sgpb-random-popup']) && $options['sgpb-random-popup'] == 'on') {
[369] Fix | Delete
$randomPopupCategory = AdminHelper::getTaxonomyBySlug(SG_RANDOM_TAXONOMY_SLUG);
[370] Fix | Delete
wp_set_object_terms($popupId, SG_RANDOM_TAXONOMY_SLUG, SG_POPUP_CATEGORY_TAXONOMY, true);
[371] Fix | Delete
}
[372] Fix | Delete
[373] Fix | Delete
$this->saveProTarget($options);
[374] Fix | Delete
[375] Fix | Delete
// MailChimp
[376] Fix | Delete
$mailchimpApiKey = get_option("SG_MAILCHIMP_API_KEY");
[377] Fix | Delete
[378] Fix | Delete
if ($mailchimpApiKey) {
[379] Fix | Delete
update_option('SGPB_MAILCHIMP_API_KEY', $mailchimpApiKey);
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
// AWeber
[383] Fix | Delete
$aweberAccessToken = get_option('sgAccessToken');
[384] Fix | Delete
if ($aweberAccessToken) {
[385] Fix | Delete
$requestTokenSecret = get_option('requestTokenSecret');
[386] Fix | Delete
$accessTokenSecret = get_option('sgAccessTokenSecret');
[387] Fix | Delete
[388] Fix | Delete
update_option('sgpbRequestTokenSecret', $requestTokenSecret);
[389] Fix | Delete
update_option('sgpbAccessTokenSecret', $accessTokenSecret);
[390] Fix | Delete
update_option('sgpbAccessToken', $aweberAccessToken);
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
return $options;
[394] Fix | Delete
}
[395] Fix | Delete
[396] Fix | Delete
public function saveProTarget($options)
[397] Fix | Delete
{
[398] Fix | Delete
if (empty($options)) {
[399] Fix | Delete
return;
[400] Fix | Delete
}
[401] Fix | Delete
$popupId = (int)$options['sgpb-post-id'];
[402] Fix | Delete
// It's got already saved targets for do not override already saved data
[403] Fix | Delete
$popupSavedTarget = get_post_meta($popupId, 'sg_popup_target');
[404] Fix | Delete
$target = array();
[405] Fix | Delete
$target['sgpb-target'] = array();
[406] Fix | Delete
$target['sgpb-conditions'] = array();
[407] Fix | Delete
[408] Fix | Delete
if (!empty($popupSavedTarget[0]['sgpb-conditions'])) {
[409] Fix | Delete
$target['sgpb-conditions'] = $popupSavedTarget[0]['sgpb-conditions'];
[410] Fix | Delete
}
[411] Fix | Delete
$isSavedToHome = false;
[412] Fix | Delete
[413] Fix | Delete
if (!empty($options['allPagesStatus'])) {
[414] Fix | Delete
[415] Fix | Delete
if ($options['allPages'] == 'selected') {
[416] Fix | Delete
$savedPages = isset($options['allSelectedPages']) ? (array)$options['allSelectedPages'] : array();
[417] Fix | Delete
$savedPagesValues = array_values($savedPages);
[418] Fix | Delete
[419] Fix | Delete
// -1 mean saved for home page
[420] Fix | Delete
if (in_array('-1', $savedPagesValues)) {
[421] Fix | Delete
$isSavedToHome = true;
[422] Fix | Delete
}
[423] Fix | Delete
$args = array(
[424] Fix | Delete
'post__in' => $savedPagesValues,
[425] Fix | Delete
'posts_per_page' => 10,
[426] Fix | Delete
'post_type' => 'page'
[427] Fix | Delete
);
[428] Fix | Delete
[429] Fix | Delete
$searchResults = SGPBConfigDataHelper::getPostTypeData($args);
[430] Fix | Delete
if (!empty($searchResults)) {
[431] Fix | Delete
$target['sgpb-target'][0][] = array('param' => 'page_selected', 'operator' => '==', 'value' => $searchResults);
[432] Fix | Delete
}
[433] Fix | Delete
}
[434] Fix | Delete
else {
[435] Fix | Delete
$target['sgpb-target'][0][] = array('param' => 'page_all', 'operator' => '==');
[436] Fix | Delete
}
[437] Fix | Delete
}
[438] Fix | Delete
[439] Fix | Delete
if (!empty($options['allPostsStatus'])) {
[440] Fix | Delete
$allPosts = $options['allPosts'];
[441] Fix | Delete
if ($allPosts == 'selected') {
[442] Fix | Delete
$savedPosts = (array)$options['allSelectedPosts'];
[443] Fix | Delete
$savedPostsValues = array_values($savedPosts);
[444] Fix | Delete
// -1 mean saved for home page
[445] Fix | Delete
if (in_array('-1', $savedPostsValues)) {
[446] Fix | Delete
$isSavedToHome = true;
[447] Fix | Delete
}
[448] Fix | Delete
$args = array(
[449] Fix | Delete
'post__in' => $savedPostsValues,
[450] Fix | Delete
'posts_per_page' => 10,
[451] Fix | Delete
'post_type' => 'post'
[452] Fix | Delete
);
[453] Fix | Delete
[454] Fix | Delete
$searchResults = SGPBConfigDataHelper::getPostTypeData($args);
[455] Fix | Delete
if (!empty($searchResults)) {
[456] Fix | Delete
$target['sgpb-target'][0][] = array('param' => 'post_selected', 'operator' => '==', 'value' => $searchResults);
[457] Fix | Delete
}
[458] Fix | Delete
}
[459] Fix | Delete
else if ($allPosts == 'all') {
[460] Fix | Delete
$target['sgpb-target'][0][] = array('param' => 'post_all', 'operator' => '==');
[461] Fix | Delete
}
[462] Fix | Delete
else {
[463] Fix | Delete
$selectedPostCategories = array_values($options['posts-all-categories']);
[464] Fix | Delete
$target['sgpb-target'][0][] = array('param' => 'post_category', 'operator' => '==', 'value' => $selectedPostCategories);
[465] Fix | Delete
}
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
if ($isSavedToHome) {
[469] Fix | Delete
$target['sgpb-target'][0][] = array('param' => 'page_type', 'operator' => '==', 'value' => array('is_home_page', 'is_home'));
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
if (!empty($options['allCustomPostsStatus'])) {
[473] Fix | Delete
$customPostTypes = $options['all-custom-posts'];
[474] Fix | Delete
if (!empty($customPostTypes)) {
[475] Fix | Delete
$selectedCustomPosts = $options['allSelectedCustomPosts'];
[476] Fix | Delete
if ($options['showAllCustomPosts'] == 'selected') {
[477] Fix | Delete
foreach ($customPostTypes as $customPostType) {
[478] Fix | Delete
$args = array(
[479] Fix | Delete
'post__in' => array_values($selectedCustomPosts),
[480] Fix | Delete
'posts_per_page' => 10,
[481] Fix | Delete
'post_type' => $customPostType
[482] Fix | Delete
);
[483] Fix | Delete
[484] Fix | Delete
$searchResults = SGPBConfigDataHelper::getPostTypeData($args);
[485] Fix | Delete
if (!empty($searchResults)) {
[486] Fix | Delete
$target['sgpb-target'][0][] = array('param' => $customPostType.'_selected', 'operator' => '==', 'value' => $searchResults);
[487] Fix | Delete
}
[488] Fix | Delete
}
[489] Fix | Delete
}
[490] Fix | Delete
[491] Fix | Delete
else {
[492] Fix | Delete
$target['sgpb-target'][0][] = array('param' => 'post_type', 'operator' => '==', 'value' => array_values($customPostTypes));
[493] Fix | Delete
[494] Fix | Delete
}
[495] Fix | Delete
}
[496] Fix | Delete
}
[497] Fix | Delete
[498] Fix | Delete
update_post_meta($popupId, 'sg_popup_target', $target);
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function