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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/popup-bu.../com/classes
File: Actions.php
[500] Fix | Delete
public function popupMediaButton()
[501] Fix | Delete
{
[502] Fix | Delete
if (!$this->mediaButton) {
[503] Fix | Delete
$this->mediaButton = true;
[504] Fix | Delete
self::enqueueScriptsForPageBuilders();
[505] Fix | Delete
if (function_exists('get_current_screen')) {
[506] Fix | Delete
$screen = get_current_screen();
[507] Fix | Delete
if (!empty($screen)) {
[508] Fix | Delete
echo wp_kses(new MediaButton(), AdminHelper::allowed_html_tags());
[509] Fix | Delete
}
[510] Fix | Delete
}
[511] Fix | Delete
}
[512] Fix | Delete
}
[513] Fix | Delete
[514] Fix | Delete
public function editorButton($plugins)
[515] Fix | Delete
{
[516] Fix | Delete
if (empty($this->mediaButton)) {
[517] Fix | Delete
$this->mediaButton = true;
[518] Fix | Delete
$currentPostType = AdminHelper::getCurrentPostType();
[519] Fix | Delete
add_action('admin_footer', function() use ($currentPostType) {
[520] Fix | Delete
self::enqueueScriptsForPageBuilders();
[521] Fix | Delete
if (!empty($currentPostType) && $currentPostType == SG_POPUP_POST_TYPE) {
[522] Fix | Delete
require_once(SG_POPUP_VIEWS_PATH.'htmlCustomButtonElement.php');
[523] Fix | Delete
}
[524] Fix | Delete
});
[525] Fix | Delete
}
[526] Fix | Delete
[527] Fix | Delete
return $plugins;
[528] Fix | Delete
}
[529] Fix | Delete
[530] Fix | Delete
public static function enqueueScriptsForPageBuilders()
[531] Fix | Delete
{
[532] Fix | Delete
require_once(ABSPATH.'wp-admin/includes/screen.php');
[533] Fix | Delete
global $post;
[534] Fix | Delete
if (function_exists('get_current_screen')) {
[535] Fix | Delete
$screen = get_current_screen();
[536] Fix | Delete
if ((!empty($screen->id) && $screen->id == SG_POPUP_POST_TYPE) || !empty($post)) {
[537] Fix | Delete
if (!isset($_GET['fl_builder'])) {
[538] Fix | Delete
Javascript::enqueueScripts('post-new.php');
[539] Fix | Delete
Style::enqueueStyles('post-new.php');
[540] Fix | Delete
}
[541] Fix | Delete
}
[542] Fix | Delete
}
[543] Fix | Delete
else if (isset($_GET['fl_builder'])) {
[544] Fix | Delete
Javascript::enqueueScripts('post-new.php');
[545] Fix | Delete
Style::enqueueStyles('post-new.php');
[546] Fix | Delete
}
[547] Fix | Delete
}
[548] Fix | Delete
[549] Fix | Delete
public function userRolesCaps()
[550] Fix | Delete
{
[551] Fix | Delete
$userSavedRoles = get_option('sgpb-user-roles');
[552] Fix | Delete
[553] Fix | Delete
if (!$userSavedRoles) {
[554] Fix | Delete
$userSavedRoles = array('administrator');
[555] Fix | Delete
}
[556] Fix | Delete
else {
[557] Fix | Delete
array_push($userSavedRoles, 'administrator');
[558] Fix | Delete
}
[559] Fix | Delete
[560] Fix | Delete
foreach ($userSavedRoles as $theRole) {
[561] Fix | Delete
$role = get_role($theRole);
[562] Fix | Delete
if (empty($role)) {
[563] Fix | Delete
continue;
[564] Fix | Delete
}
[565] Fix | Delete
[566] Fix | Delete
$role->add_cap('read');
[567] Fix | Delete
$role->add_cap('read_post');
[568] Fix | Delete
$role->add_cap('read_private_sgpb_popups');
[569] Fix | Delete
$role->add_cap('edit_sgpb_popup');
[570] Fix | Delete
$role->add_cap('edit_sgpb_popups');
[571] Fix | Delete
$role->add_cap('edit_others_sgpb_popups');
[572] Fix | Delete
$role->add_cap('edit_published_sgpb_popups');
[573] Fix | Delete
$role->add_cap('publish_sgpb_popups');
[574] Fix | Delete
$role->add_cap('delete_sgpb_popups');
[575] Fix | Delete
$role->add_cap('delete_published_posts');
[576] Fix | Delete
$role->add_cap('delete_others_sgpb_popups');
[577] Fix | Delete
$role->add_cap('delete_private_sgpb_popups');
[578] Fix | Delete
$role->add_cap('delete_private_sgpb_popup');
[579] Fix | Delete
$role->add_cap('delete_published_sgpb_popups');
[580] Fix | Delete
[581] Fix | Delete
// For popup builder sub-menus and terms
[582] Fix | Delete
$role->add_cap('sgpb_manage_options');
[583] Fix | Delete
$role->add_cap('manage_popup_terms');
[584] Fix | Delete
$role->add_cap('manage_popup_categories_terms');
[585] Fix | Delete
$role = apply_filters('sgpbUserRoleCap', $role);
[586] Fix | Delete
}
[587] Fix | Delete
[588] Fix | Delete
return true;
[589] Fix | Delete
}
[590] Fix | Delete
[591] Fix | Delete
public function pluginActivated()
[592] Fix | Delete
{
[593] Fix | Delete
if (!get_option('sgpbActivateExtensions') && SGPB_POPUP_PKG != SGPB_POPUP_PKG_FREE) {
[594] Fix | Delete
$obj = new PopupExtensionActivator();
[595] Fix | Delete
$obj->activate();
[596] Fix | Delete
update_option('sgpbActivateExtensions', 1);
[597] Fix | Delete
}
[598] Fix | Delete
}
[599] Fix | Delete
[600] Fix | Delete
public function sgpbPopupShortcode($args, $content)
[601] Fix | Delete
{
[602] Fix | Delete
if (empty($args) || empty($args['id'])) {
[603] Fix | Delete
return $content;
[604] Fix | Delete
}
[605] Fix | Delete
[606] Fix | Delete
$oldShortcode = isset($args['event']) && $args['event'] === 'onload';
[607] Fix | Delete
$isInherit = isset($args['event']) && $args['event'] == 'inherit';
[608] Fix | Delete
$event = '';
[609] Fix | Delete
[610] Fix | Delete
$shortcodeContent = '';
[611] Fix | Delete
$argsId = $popupId = (int)$args['id'];
[612] Fix | Delete
[613] Fix | Delete
// for old popups
[614] Fix | Delete
if (function_exists('sgpb\sgpGetCorrectPopupId')) {
[615] Fix | Delete
$popupId = sgpGetCorrectPopupId($popupId);
[616] Fix | Delete
}
[617] Fix | Delete
[618] Fix | Delete
$popup = SGPopup::find($popupId);
[619] Fix | Delete
$popup = apply_filters('sgpbShortCodePopupObj', $popup);
[620] Fix | Delete
[621] Fix | Delete
$event = preg_replace('/on/', '', (isset($args['event']) ? $args['event'] : ''));
[622] Fix | Delete
// when popup does not exists or popup post status it's not publish ex when popup in trash
[623] Fix | Delete
if (empty($popup) || (!is_object($popup) && $popup != 'publish')) {
[624] Fix | Delete
return $content;
[625] Fix | Delete
}
[626] Fix | Delete
[627] Fix | Delete
$isActive = $popup->isActive();
[628] Fix | Delete
if (!$isActive) {
[629] Fix | Delete
return $content;
[630] Fix | Delete
}
[631] Fix | Delete
[632] Fix | Delete
$alreadySavedEvents = $popup->getEvents();
[633] Fix | Delete
$loadableMode = $popup->getLoadableModes();
[634] Fix | Delete
[635] Fix | Delete
if (!isset($args['event']) && isset($args['insidepopup'])) {
[636] Fix | Delete
unset($args['insidepopup']);
[637] Fix | Delete
$event = 'insideclick';
[638] Fix | Delete
$insideShortcodeKey = $popupId.$event;
[639] Fix | Delete
[640] Fix | Delete
// for prevent infinity chain
[641] Fix | Delete
if (is_array($this->insideShortcodes) && in_array($insideShortcodeKey, $this->insideShortcodes)) {
[642] Fix | Delete
$shortcodeContent = SGPopup::renderPopupContentShortcode($content, $argsId, $event, $args);
[643] Fix | Delete
[644] Fix | Delete
return $shortcodeContent;
[645] Fix | Delete
}
[646] Fix | Delete
$this->insideShortcodes[] = $insideShortcodeKey;
[647] Fix | Delete
}
[648] Fix | Delete
// if no event attribute is set, or old shortcode
[649] Fix | Delete
if (!isset($args['event']) || $oldShortcode || $isInherit) {
[650] Fix | Delete
$loadableMode = $popup->getLoadableModes();
[651] Fix | Delete
if (!empty($content)) {
[652] Fix | Delete
$alreadySavedEvents = false;
[653] Fix | Delete
}
[654] Fix | Delete
// for old popup, after the update, there aren't any events
[655] Fix | Delete
if (empty($alreadySavedEvents)) {
[656] Fix | Delete
$event = '';
[657] Fix | Delete
if (!empty($content)) {
[658] Fix | Delete
$event = 'click';
[659] Fix | Delete
}
[660] Fix | Delete
if (!empty($args['event'])) {
[661] Fix | Delete
$event = $args['event'];
[662] Fix | Delete
}
[663] Fix | Delete
$event = preg_replace('/on/', '', $event);
[664] Fix | Delete
$popup->setEvents(array($event));
[665] Fix | Delete
}
[666] Fix | Delete
if (empty($loadableMode)) {
[667] Fix | Delete
$loadableMode = array();
[668] Fix | Delete
}
[669] Fix | Delete
$loadableMode['option_event'] = true;
[670] Fix | Delete
}
[671] Fix | Delete
else {
[672] Fix | Delete
$event = $args['event'];
[673] Fix | Delete
$event = preg_replace('/on/', '', $event);
[674] Fix | Delete
$popup->setEvents(array($event));
[675] Fix | Delete
}
[676] Fix | Delete
[677] Fix | Delete
$popup->setLoadableModes($loadableMode);
[678] Fix | Delete
[679] Fix | Delete
$groupObj = new PopupGroupFilter();
[680] Fix | Delete
$groupObj->setPopups(array($popup));
[681] Fix | Delete
$loadablePopups = $groupObj->filter();
[682] Fix | Delete
$scriptsLoader = new ScriptsLoader();
[683] Fix | Delete
$scriptsLoader->setLoadablePopups($loadablePopups);
[684] Fix | Delete
$scriptsLoader->loadToFooter();
[685] Fix | Delete
[686] Fix | Delete
if (!empty($content)) {
[687] Fix | Delete
$matches = SGPopup::getPopupShortcodeMatchesFromContent($content);
[688] Fix | Delete
if (!empty($matches)) {
[689] Fix | Delete
foreach ($matches[0] as $key => $value) {
[690] Fix | Delete
$attrs = shortcode_parse_atts($matches[3][$key]);
[691] Fix | Delete
if (empty($attrs['id'])) {
[692] Fix | Delete
continue;
[693] Fix | Delete
}
[694] Fix | Delete
$shortcodeContent = SGPopup::renderPopupContentShortcode($content, $attrs['id'], $attrs['event'], $attrs);
[695] Fix | Delete
break;
[696] Fix | Delete
}
[697] Fix | Delete
}
[698] Fix | Delete
}
[699] Fix | Delete
[700] Fix | Delete
if (isset($event) && $event != 'onload' && !empty($content)) {
[701] Fix | Delete
$shortcodeContent = SGPopup::renderPopupContentShortcode($content, $argsId, $event, $args);
[702] Fix | Delete
}
[703] Fix | Delete
$shortcodeContent = apply_filters('sgpbPopupShortCodeContent', $shortcodeContent);
[704] Fix | Delete
[705] Fix | Delete
return do_shortcode($shortcodeContent);
[706] Fix | Delete
}
[707] Fix | Delete
[708] Fix | Delete
public function deleteSubscribersWithPopup($postId)
[709] Fix | Delete
{
[710] Fix | Delete
global $post_type;
[711] Fix | Delete
[712] Fix | Delete
if ($post_type == SG_POPUP_POST_TYPE) {
[713] Fix | Delete
AdminHelper::deleteSubscriptionPopupSubscribers($postId);
[714] Fix | Delete
}
[715] Fix | Delete
}
[716] Fix | Delete
[717] Fix | Delete
public function cronAddMinutes($schedules)
[718] Fix | Delete
{
[719] Fix | Delete
$schedules['sgpb_newsletter_send_every_minute'] = array(
[720] Fix | Delete
'interval' => SGPB_CRON_REPEAT_INTERVAL * 60,
[721] Fix | Delete
'display' => __('Once Every Minute', 'popup-builder')
[722] Fix | Delete
);
[723] Fix | Delete
[724] Fix | Delete
$schedules['sgpb_banners'] = array(
[725] Fix | Delete
'interval' => SGPB_TRANSIENT_TIMEOUT_WEEK,
[726] Fix | Delete
'display' => __('Once Every Week', 'popup-builder')
[727] Fix | Delete
);
[728] Fix | Delete
[729] Fix | Delete
$schedules = apply_filters('sgpbCronTimeoutSettings', $schedules);
[730] Fix | Delete
[731] Fix | Delete
return $schedules;
[732] Fix | Delete
}
[733] Fix | Delete
[734] Fix | Delete
public function newsletterSendEmail()
[735] Fix | Delete
{
[736] Fix | Delete
global $wpdb;
[737] Fix | Delete
$newsletterOptions = get_option('SGPB_NEWSLETTER_DATA');
[738] Fix | Delete
[739] Fix | Delete
if (empty($newsletterOptions)) {
[740] Fix | Delete
wp_clear_scheduled_hook('sgpb_send_newsletter');
[741] Fix | Delete
}
[742] Fix | Delete
$subscriptionFormId = (int)$newsletterOptions['subscriptionFormId'];
[743] Fix | Delete
$subscriptionFormTitle = get_the_title($subscriptionFormId);
[744] Fix | Delete
$emailsInFlow = (int)$newsletterOptions['emailsInFlow'];
[745] Fix | Delete
$mailSubject = $newsletterOptions['newsletterSubject'];
[746] Fix | Delete
$fromEmail = $newsletterOptions['fromEmail'];
[747] Fix | Delete
$emailMessage = $newsletterOptions['messageBody'];
[748] Fix | Delete
[749] Fix | Delete
$allAvailableShortcodes = array();
[750] Fix | Delete
$allAvailableShortcodes['patternFirstName'] = '/\[First name]/';
[751] Fix | Delete
$allAvailableShortcodes['patternLastName'] = '/\[Last name]/';
[752] Fix | Delete
$allAvailableShortcodes['patternBlogName'] = '/\[Blog name]/';
[753] Fix | Delete
$allAvailableShortcodes['patternUserName'] = '/\[User name]/';
[754] Fix | Delete
$allAvailableShortcodes['patternUnsubscribe'] = '';
[755] Fix | Delete
[756] Fix | Delete
$pattern = "/\[(\[?)(Unsubscribe)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]\*+(?:\[(?!\/\2\])[^\[]\*+)\*+)\[\/\2\])?)(\]?)/";
[757] Fix | Delete
preg_match($pattern, $emailMessage, $matches);
[758] Fix | Delete
$title = __('Unsubscribe', 'popup-builder');
[759] Fix | Delete
if ($matches) {
[760] Fix | Delete
$patternUnsubscribe = $matches[0];
[761] Fix | Delete
// If user didn't change anything inside the [unsubscribe] shortcode $matches[2] will be equal to 'Unsubscribe'
[762] Fix | Delete
if ($matches[2] == 'Unsubscribe') {
[763] Fix | Delete
$pattern = '/\s(\w+?)="(.+?)"]/';
[764] Fix | Delete
preg_match($pattern, $matches[0], $matchesTitle);
[765] Fix | Delete
if (!empty($matchesTitle[2])) {
[766] Fix | Delete
$title = AdminHelper::removeAllNonPrintableCharacters($matchesTitle[2], 'Unsubscribe');
[767] Fix | Delete
}
[768] Fix | Delete
}
[769] Fix | Delete
$allAvailableShortcodes['patternUnsubscribe'] = $patternUnsubscribe;
[770] Fix | Delete
}
[771] Fix | Delete
[772] Fix | Delete
// When email is not valid we don't continue
[773] Fix | Delete
if (!preg_match('/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$/', $fromEmail)) {
[774] Fix | Delete
wp_clear_scheduled_hook('sgpb_send_newsletter');
[775] Fix | Delete
return false;
[776] Fix | Delete
}
[777] Fix | Delete
$table_subscription = $wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME;
[778] Fix | Delete
$selectionQuery = "SELECT id FROM $table_subscription WHERE";
[779] Fix | Delete
$selectionQuery = apply_filters('sgpbUserSelectionQuery', $selectionQuery);
[780] Fix | Delete
[781] Fix | Delete
$result = $wpdb->get_row( $wpdb->prepare("$selectionQuery and subscriptionType = %d limit 1", $subscriptionFormId), ARRAY_A);//db call ok
[782] Fix | Delete
$currentStateEmailId = (int)$result['id'];
[783] Fix | Delete
$table_subscription = $wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME;
[784] Fix | Delete
$totalSubscribers = $wpdb->get_var( $wpdb->prepare("SELECT count(*) FROM $table_subscription WHERE unsubscribed = 0 and subscriptionType = %d", $subscriptionFormId) );
[785] Fix | Delete
[786] Fix | Delete
// $currentStateEmailId == 0 when all emails status = 1
[787] Fix | Delete
if ($currentStateEmailId == 0) {
[788] Fix | Delete
// Clear schedule hook
[789] Fix | Delete
$headers = 'MIME-Version: 1.0'."\r\n";
[790] Fix | Delete
$headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";
[791] Fix | Delete
$successTotal = get_option('SGPB_NEWSLETTER_'.$subscriptionFormId);
[792] Fix | Delete
if (!$successTotal) {
[793] Fix | Delete
$successTotal = 0;
[794] Fix | Delete
}
[795] Fix | Delete
$failedTotal = $totalSubscribers - $successTotal;
[796] Fix | Delete
/* translators: subscription Form Title, success Total ,total Subscribers, failed Total . */
[797] Fix | Delete
$emailMessageCustom = __('Your mail list %1$s delivered successfully!
[798] Fix | Delete
%2$d of the %3$d emails succeeded, %4$d failed.
[799] Fix | Delete
For more details, please download log file inside the plugin.
[800] Fix | Delete
This email was generated via Popup Builder plugin.', 'popup-builder');
[801] Fix | Delete
$emailMessageCustom = sprintf($emailMessageCustom, $subscriptionFormTitle, $successTotal, $totalSubscribers, $failedTotal);
[802] Fix | Delete
[803] Fix | Delete
wp_mail($fromEmail, $subscriptionFormTitle.' list has been successfully delivered!', $emailMessageCustom, $headers);
[804] Fix | Delete
delete_option('SGPB_NEWSLETTER_'.$subscriptionFormId);
[805] Fix | Delete
wp_clear_scheduled_hook('sgpb_send_newsletter');
[806] Fix | Delete
return;
[807] Fix | Delete
}
[808] Fix | Delete
[809] Fix | Delete
$getAllDataSql = 'SELECT id, firstName, lastName, email FROM '.$wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME.' WHERE';
[810] Fix | Delete
$getAllDataSql = apply_filters('sgpbUserSelectionQuery', $getAllDataSql);
[811] Fix | Delete
$subscribers = $wpdb->get_results( $wpdb->prepare( "$getAllDataSql and id >= %d and subscriptionType = %s limit %d", $currentStateEmailId, $subscriptionFormId, $emailsInFlow), ARRAY_A);
[812] Fix | Delete
[813] Fix | Delete
$subscribers = apply_filters('sgpNewsletterSendingSubscribers', $subscribers);
[814] Fix | Delete
[815] Fix | Delete
$blogInfo = wp_specialchars_decode( get_bloginfo() );
[816] Fix | Delete
$headers = array(
[817] Fix | Delete
'From: "'.$blogInfo.'" <'.$fromEmail.'>' ,
[818] Fix | Delete
'MIME-Version: 1.0' ,
[819] Fix | Delete
'Content-type: text/html; charset=UTF-8'
[820] Fix | Delete
);
[821] Fix | Delete
[822] Fix | Delete
foreach ($subscribers as $subscriber) {
[823] Fix | Delete
$replacementId = $subscriber['id'];
[824] Fix | Delete
$allAvailableShortcodes = apply_filters('sgpbNewsletterShortcodes', $allAvailableShortcodes, $subscriptionFormId, $replacementId);
[825] Fix | Delete
$replacementFirstName = $subscriber['firstName'];
[826] Fix | Delete
$replacementLastName = $subscriber['lastName'];
[827] Fix | Delete
$replacementBlogName = $newsletterOptions['blogname'];
[828] Fix | Delete
$replacementUserName = $newsletterOptions['username'];
[829] Fix | Delete
$replacementEmail = $subscriber['email'];
[830] Fix | Delete
$replacementUnsubscribe = get_home_url();
[831] Fix | Delete
$replacementUnsubscribe .= '?sgpbUnsubscribe='.md5($replacementId.$replacementEmail);
[832] Fix | Delete
$replacementUnsubscribe .= '&email='.$subscriber['email'];
[833] Fix | Delete
$replacementUnsubscribe .= '&popup='.$subscriptionFormId;
[834] Fix | Delete
$replacementUnsubscribe = '<br><a href="'.$replacementUnsubscribe.'">'.$title.'</a>';
[835] Fix | Delete
[836] Fix | Delete
// Replace First name and Last name from email message
[837] Fix | Delete
$emailMessageCustom = preg_replace($allAvailableShortcodes['patternFirstName'], $replacementFirstName, $emailMessage);
[838] Fix | Delete
$emailMessageCustom = preg_replace($allAvailableShortcodes['patternLastName'], $replacementLastName, $emailMessageCustom);
[839] Fix | Delete
$emailMessageCustom = preg_replace($allAvailableShortcodes['patternBlogName'], $replacementBlogName, $emailMessageCustom);
[840] Fix | Delete
$emailMessageCustom = preg_replace($allAvailableShortcodes['patternUserName'], $replacementUserName, $emailMessageCustom);
[841] Fix | Delete
$emailMessageCustom = str_replace($allAvailableShortcodes['patternUnsubscribe'], $replacementUnsubscribe, $emailMessageCustom);
[842] Fix | Delete
if (!empty($allAvailableShortcodes['extraShortcodesWithValues'])) {
[843] Fix | Delete
$customFields = $allAvailableShortcodes['extraShortcodesWithValues'];
[844] Fix | Delete
foreach ($customFields as $customFieldKey => $customFieldValue) {
[845] Fix | Delete
$finalShortcode = '/\['.$customFieldKey.']/';
[846] Fix | Delete
$emailMessageCustom = preg_replace($finalShortcode, $customFieldValue, $emailMessageCustom);
[847] Fix | Delete
}
[848] Fix | Delete
}
[849] Fix | Delete
$emailMessageCustom = stripslashes($emailMessageCustom);
[850] Fix | Delete
[851] Fix | Delete
$emailMessageCustom = apply_filters('sgpNewsletterSendingMessage', $emailMessageCustom);
[852] Fix | Delete
$mailStatus = wp_mail($subscriber['email'], $mailSubject, $emailMessageCustom, $headers);
[853] Fix | Delete
if (!$mailStatus) {
[854] Fix | Delete
$table_sgpb_subscription_error_log = $wpdb->prefix.SGPB_SUBSCRIBERS_ERROR_TABLE_NAME;
[855] Fix | Delete
$wpdb->query( $wpdb->prepare("INSERT INTO $table_sgpb_subscription_error_log (`popupType`, `email`, `date`) VALUES (%s, %s, %s)", $subscriptionFormId, $subscriber['email'], gmdate('Y-m-d H:i')) );continue;
[856] Fix | Delete
}
[857] Fix | Delete
[858] Fix | Delete
$successCount = get_option('SGPB_NEWSLETTER_'.$subscriptionFormId);
[859] Fix | Delete
if (!$successCount) {
[860] Fix | Delete
update_option('SGPB_NEWSLETTER_'.$subscriptionFormId, 1);
[861] Fix | Delete
}
[862] Fix | Delete
else {
[863] Fix | Delete
update_option('SGPB_NEWSLETTER_'.$subscriptionFormId, ++$successCount);
[864] Fix | Delete
}
[865] Fix | Delete
}
[866] Fix | Delete
// Update the status of all the sent mails
[867] Fix | Delete
$table_sgpb_subscription = $wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME;
[868] Fix | Delete
$wpdb->query( $wpdb->prepare("UPDATE $table_sgpb_subscription SET status = 1 where id >= %d and subscriptionType = %d limit %d", $currentStateEmailId, $subscriptionFormId, $emailsInFlow) );
[869] Fix | Delete
}
[870] Fix | Delete
[871] Fix | Delete
private function unsubscribe($params = array())
[872] Fix | Delete
{
[873] Fix | Delete
AdminHelper::deleteUserFromSubscribers($params);
[874] Fix | Delete
}
[875] Fix | Delete
[876] Fix | Delete
public function enqueuePopupBuilderScripts()
[877] Fix | Delete
{
[878] Fix | Delete
// for old popups
[879] Fix | Delete
if (get_option('SGPB_POPUP_VERSION')) {
[880] Fix | Delete
ConvertToNewVersion::saveCustomInserted();
[881] Fix | Delete
}
[882] Fix | Delete
[883] Fix | Delete
$popupLoaderObj = PopupLoader::instance();
[884] Fix | Delete
if (is_object($popupLoaderObj)) {
[885] Fix | Delete
$popupLoaderObj->loadPopups();
[886] Fix | Delete
}
[887] Fix | Delete
}
[888] Fix | Delete
[889] Fix | Delete
public function adminLoadPopups($hook)
[890] Fix | Delete
{
[891] Fix | Delete
$allowedPages = array();
[892] Fix | Delete
$allowedPages = apply_filters('sgpbAdminLoadedPages', $allowedPages);
[893] Fix | Delete
[894] Fix | Delete
if (!empty($allowedPages) && is_array($allowedPages) && in_array($hook, $allowedPages)) {
[895] Fix | Delete
$scriptsLoader = new ScriptsLoader();
[896] Fix | Delete
$scriptsLoader->setIsAdmin(true);
[897] Fix | Delete
$scriptsLoader->loadToFooter();
[898] Fix | Delete
}
[899] Fix | Delete
}
[900] Fix | Delete
[901] Fix | Delete
public function postTypeInit()
[902] Fix | Delete
{
[903] Fix | Delete
/**
[904] Fix | Delete
* We only allow administrator to do this action
[905] Fix | Delete
*/
[906] Fix | Delete
if ( ! current_user_can( 'manage_options' ) ) {
[907] Fix | Delete
[908] Fix | Delete
return;
[909] Fix | Delete
}
[910] Fix | Delete
[911] Fix | Delete
$adminUrl = admin_url();
[912] Fix | Delete
[913] Fix | Delete
if (isset($_GET['page']) && sanitize_text_field($_GET['page']) == 'PopupBuilder') {
[914] Fix | Delete
echo '<span>';
[915] Fix | Delete
printf(
[916] Fix | Delete
/* translators: Link to edit Popup item, location. */
[917] Fix | Delete
esc_html__('Popup Builder plugin has been successfully updated. Please %1$s to go to the new Dashboard of the plugin.', 'popup-builder'),
[918] Fix | Delete
sprintf(
[919] Fix | Delete
/* translators: admin Url, Popup Post type. */
[920] Fix | Delete
'<a href="%1$sedit.php?post_type=%2$s">click here</a>',
[921] Fix | Delete
esc_url($adminUrl),
[922] Fix | Delete
esc_html__( 'popupbuilder', 'text-domain' )
[923] Fix | Delete
)
[924] Fix | Delete
);
[925] Fix | Delete
echo '</span>';
[926] Fix | Delete
wp_die();
[927] Fix | Delete
}
[928] Fix | Delete
[929] Fix | Delete
[930] Fix | Delete
AdminHelper::removeUnnecessaryCodeFromPopups();
[931] Fix | Delete
[932] Fix | Delete
/**
[933] Fix | Delete
* We only allow administrator to do this action
[934] Fix | Delete
*/
[935] Fix | Delete
if (isset($_POST['sgpb-is-preview']) && $_POST['sgpb-is-preview'] == 1 && isset($_POST['post_ID'])) {
[936] Fix | Delete
[937] Fix | Delete
/* Validate nonce */
[938] Fix | Delete
$nonce = isset( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
[939] Fix | Delete
$postId = sanitize_text_field($_POST['post_ID']);
[940] Fix | Delete
[941] Fix | Delete
if ( empty( $nonce ) || !wp_verify_nonce( $nonce, 'update-post_'.$postId ) ) {
[942] Fix | Delete
return;
[943] Fix | Delete
}
[944] Fix | Delete
[945] Fix | Delete
$post = get_post($postId);
[946] Fix | Delete
[947] Fix | Delete
/**
[948] Fix | Delete
* We only allow administrator to do this action
[949] Fix | Delete
*/
[950] Fix | Delete
[951] Fix | Delete
$this->savePost($postId, $post, false);
[952] Fix | Delete
}
[953] Fix | Delete
[954] Fix | Delete
}
[955] Fix | Delete
[956] Fix | Delete
public function callUnsubcribeUserByEmail()
[957] Fix | Delete
{
[958] Fix | Delete
/**
[959] Fix | Delete
* We collect GET parameters for Unsubscriber such as 'sgpbUnsubscribe', 'email', 'popup ID'.
[960] Fix | Delete
* This happens when User wants to unsubcibe on the Subscription Popup through Link in email.
[961] Fix | Delete
*/
[962] Fix | Delete
$unsubscribeArgs = $this->collectUnsubscriberArgs();
[963] Fix | Delete
[964] Fix | Delete
if (!empty($unsubscribeArgs)) {
[965] Fix | Delete
$this->unsubscribe($unsubscribeArgs);
[966] Fix | Delete
}
[967] Fix | Delete
[968] Fix | Delete
// This should call with init hook to register new post type popup
[969] Fix | Delete
$this->customPostTypeObj = new RegisterPostType();
[970] Fix | Delete
[971] Fix | Delete
}
[972] Fix | Delete
[973] Fix | Delete
public function collectUnsubscriberArgs()
[974] Fix | Delete
{
[975] Fix | Delete
if (!isset($_GET['sgpbUnsubscribe'])) {
[976] Fix | Delete
return false;
[977] Fix | Delete
}
[978] Fix | Delete
$args = array();
[979] Fix | Delete
if (isset($_GET['sgpbUnsubscribe'])) {
[980] Fix | Delete
$args['token'] = sanitize_text_field($_GET['sgpbUnsubscribe']);
[981] Fix | Delete
}
[982] Fix | Delete
if (isset($_GET['email'])) {
[983] Fix | Delete
$args['email'] = sanitize_email($_GET['email']);
[984] Fix | Delete
}
[985] Fix | Delete
if (isset($_GET['popup'])) {
[986] Fix | Delete
$args['popup'] = sanitize_text_field($_GET['popup']);
[987] Fix | Delete
}
[988] Fix | Delete
[989] Fix | Delete
return $args;
[990] Fix | Delete
}
[991] Fix | Delete
[992] Fix | Delete
public function addSubMenu()
[993] Fix | Delete
{
[994] Fix | Delete
// We need to check license keys and statuses before adding new menu "License" item
[995] Fix | Delete
new Updates();
[996] Fix | Delete
[997] Fix | Delete
$this->customPostTypeObj->addSubMenu();
[998] Fix | Delete
}
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function