| 1 | <?php |
|---|
| 2 | namespace sgpb; |
|---|
| 3 | use \ConfigDataHelper; |
|---|
| 4 | |
|---|
| 5 | class Ajax |
|---|
| 6 | { |
|---|
| 7 | private $postData; |
|---|
| 8 | |
|---|
| 9 | public function __construct() |
|---|
| 10 | { |
|---|
| 11 | $this->actions(); |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | public function setPostData($postData) |
|---|
| 15 | { |
|---|
| 16 | $this->postData = $postData; |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | public function getPostData() |
|---|
| 20 | { |
|---|
| 21 | return $this->postData; |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | /** |
|---|
| 25 | * Return ajax param form post data by key |
|---|
| 26 | * |
|---|
| 27 | * @since 1.0.0 |
|---|
| 28 | * |
|---|
| 29 | * @param string $key |
|---|
| 30 | * |
|---|
| 31 | * @return string $value |
|---|
| 32 | */ |
|---|
| 33 | public function getValueFromPost($key) |
|---|
| 34 | { |
|---|
| 35 | $postData = $this->getPostData(); |
|---|
| 36 | $value = ''; |
|---|
| 37 | |
|---|
| 38 | if(!empty($postData[$key])) { |
|---|
| 39 | $value = $postData[$key]; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | return $value; |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | public function actions() |
|---|
| 46 | { |
|---|
| 47 | add_action('wp_ajax_sgpb_send_to_open_counter', array($this, 'addToCounter')); |
|---|
| 48 | add_action('wp_ajax_nopriv_sgpb_send_to_open_counter', array($this, 'addToCounter')); |
|---|
| 49 | |
|---|
| 50 | add_action('wp_ajax_sgpb_process_after_submission', array($this, 'sgpbSubsciptionFormSubmittedAction')); |
|---|
| 51 | add_action('wp_ajax_nopriv_sgpb_process_after_submission', array($this, 'sgpbSubsciptionFormSubmittedAction')); |
|---|
| 52 | |
|---|
| 53 | add_action('wp_ajax_sgpb_subscription_submission', array($this, 'subscriptionSubmission')); |
|---|
| 54 | add_action('wp_ajax_nopriv_sgpb_subscription_submission', array($this, 'subscriptionSubmission')); |
|---|
| 55 | |
|---|
| 56 | $allowToAction = AdminHelper::userCanAccessTo(); |
|---|
| 57 | |
|---|
| 58 | if($allowToAction) { |
|---|
| 59 | add_action('wp_ajax_add_condition_group_row', array($this, 'addConditionGroupRow')); |
|---|
| 60 | add_action('wp_ajax_add_condition_rule_row', array($this, 'addConditionRuleRow')); |
|---|
| 61 | add_action('wp_ajax_change_condition_rule_row', array($this, 'changeConditionRuleRow')); |
|---|
| 62 | add_action('wp_ajax_select2_search_data', array($this, 'select2SearchData')); |
|---|
| 63 | add_action('wp_ajax_change_popup_status', array($this, 'changePopupStatus')); |
|---|
| 64 | // proStartGold |
|---|
| 65 | add_action('wp_ajax_check_same_origin', array($this, 'checkSameOrigin')); |
|---|
| 66 | // proEndGold |
|---|
| 67 | add_action('wp_ajax_sgpb_subscribers_delete', array($this, 'deleteSubscribers')); |
|---|
| 68 | add_action('wp_ajax_sgpb_add_subscribers', array($this, 'addSubscribers')); |
|---|
| 69 | add_action('wp_ajax_sgpb_import_subscribers', array($this, 'importSubscribers')); |
|---|
| 70 | add_action('wp_ajax_sgpb_import_settings', array($this, 'importSettings')); |
|---|
| 71 | add_action('wp_ajax_sgpb_save_imported_subscribers', array($this, 'saveImportedSubscribers')); |
|---|
| 72 | add_action('wp_ajax_sgpb_send_newsletter', array($this, 'sendNewsletter')); |
|---|
| 73 | add_action('wp_ajax_sgpb_change_review_popup_show_period', array($this, 'changeReviewPopupPeriod')); |
|---|
| 74 | add_action('wp_ajax_sgpb_dont_show_review_popup', array($this, 'dontShowReviewPopup')); |
|---|
| 75 | add_action('wp_ajax_sgpb_close_banner', array($this, 'closeMainRateUsBanner')); |
|---|
| 76 | add_action('wp_ajax_sgpb_close_license_notice', array($this, 'closeLicenseNoticeBanner')); |
|---|
| 77 | add_action('wp_ajax_sgpb_hide_ask_review_popup', array($this, 'dontShowAskReviewBanner')); |
|---|
| 78 | add_action('wp_ajax_sgpb_reset_popup_opening_count', array($this, 'resetPopupOpeningCount')); |
|---|
| 79 | /*Extension notification panel*/ |
|---|
| 80 | add_action('wp_ajax_sgpb_dont_show_extension_panel', array($this, 'extensionNotificationPanel')); |
|---|
| 81 | add_action('wp_ajax_sgpb_dont_show_problem_alert', array($this, 'dontShowProblemAlert')); |
|---|
| 82 | // autosave |
|---|
| 83 | add_action('wp_ajax_sgpb_autosave', array($this, 'sgpbAutosave')); |
|---|
| 84 | } |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | public function sgpbAutosave() |
|---|
| 88 | { |
|---|
| 89 | $allowToAction = AdminHelper::userCanAccessTo(); |
|---|
| 90 | if(!$allowToAction) { |
|---|
| 91 | wp_die(''); |
|---|
| 92 | } |
|---|
| 93 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 94 | if (!isset($_POST['post_ID'])){ |
|---|
| 95 | wp_die(0); |
|---|
| 96 | } |
|---|
| 97 | $popupId = (int)sanitize_text_field($_POST['post_ID']); |
|---|
| 98 | $postStatus = get_post_status($popupId); |
|---|
| 99 | if($postStatus == 'publish') { |
|---|
| 100 | wp_die(''); |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | if(!isset($_POST['allPopupData'])) { |
|---|
| 104 | wp_die(true); |
|---|
| 105 | } |
|---|
| 106 | // we will use array_walk_recursive method for sanitizing current data because we can receive an multidimensional array! |
|---|
| 107 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|---|
| 108 | $allPopupData = $_POST['allPopupData']; // |
|---|
| 109 | array_walk_recursive($allPopupData, function(&$item){ |
|---|
| 110 | $item = sanitize_text_field($item); |
|---|
| 111 | }); |
|---|
| 112 | $popupData = SGPopup::parsePopupDataFromData($allPopupData); |
|---|
| 113 | do_action('save_post_popupbuilder'); |
|---|
| 114 | $popupType = $popupData['sgpb-type']; |
|---|
| 115 | $popupClassName = SGPopup::getPopupClassNameFormType($popupType); |
|---|
| 116 | $popupClassPath = SGPopup::getPopupTypeClassPath($popupType); |
|---|
| 117 | if(file_exists($popupClassPath.$popupClassName.'.php')) { |
|---|
| 118 | require_once($popupClassPath.$popupClassName.'.php'); |
|---|
| 119 | $popupClassName = __NAMESPACE__.'\\'.$popupClassName; |
|---|
| 120 | $popupClassName::create($popupData, '_preview', 1); |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | wp_die(); |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | public function dontShowReviewPopup() |
|---|
| 127 | { |
|---|
| 128 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 129 | update_option('SGPBCloseReviewPopup-notification', true); |
|---|
| 130 | do_action('sgpbGetNotifications'); |
|---|
| 131 | wp_die(); |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | public function changeReviewPopupPeriod() |
|---|
| 135 | { |
|---|
| 136 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 137 | $messageType = isset($_POST['messageType']) ? sanitize_text_field($_POST['messageType']) : ''; |
|---|
| 138 | |
|---|
| 139 | if($messageType == 'count') { |
|---|
| 140 | $maxPopupCount = get_option('SGPBMaxOpenCount'); |
|---|
| 141 | if(!$maxPopupCount) { |
|---|
| 142 | $maxPopupCount = SGPB_ASK_REVIEW_POPUP_COUNT; |
|---|
| 143 | } |
|---|
| 144 | $maxPopupData = AdminHelper::getMaxOpenPopupId(); |
|---|
| 145 | if(!empty($maxPopupData['maxCount'])) { |
|---|
| 146 | $maxPopupCount = $maxPopupData['maxCount']; |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | $maxPopupCount += SGPB_ASK_REVIEW_POPUP_COUNT; |
|---|
| 150 | update_option('SGPBMaxOpenCount', $maxPopupCount); |
|---|
| 151 | wp_die(); |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | $popupTimeZone = get_option('timezone_string'); |
|---|
| 155 | if(!$popupTimeZone) { |
|---|
| 156 | $popupTimeZone = SG_POPUP_DEFAULT_TIME_ZONE; |
|---|
| 157 | } |
|---|
| 158 | $timeDate = new \DateTime('now', new \DateTimeZone($popupTimeZone)); |
|---|
| 159 | $timeDate->modify('+'.SGPB_REVIEW_POPUP_PERIOD.' day'); |
|---|
| 160 | |
|---|
| 161 | $timeNow = strtotime($timeDate->format('Y-m-d H:i:s')); |
|---|
| 162 | update_option('SGPBOpenNextTime', $timeNow); |
|---|
| 163 | $usageDays = get_option('SGPBUsageDays'); |
|---|
| 164 | $usageDays += SGPB_REVIEW_POPUP_PERIOD; |
|---|
| 165 | update_option('SGPBUsageDays', $usageDays); |
|---|
| 166 | wp_die(); |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | public function resetPopupOpeningCount() |
|---|
| 170 | { |
|---|
| 171 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 172 | if (!isset($_POST['popupId'])){ |
|---|
| 173 | wp_die(0); |
|---|
| 174 | } |
|---|
| 175 | global $wpdb; |
|---|
| 176 | |
|---|
| 177 | $tableName = $wpdb->prefix.'sgpb_analytics'; |
|---|
| 178 | $popupId = (int)sanitize_text_field($_POST['popupId']); |
|---|
| 179 | $allPopupsCount = get_option('SgpbCounter'); |
|---|
| 180 | if($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) { |
|---|
| 181 | SGPopup::deleteAnalyticsDataByPopupId($popupId); |
|---|
| 182 | } |
|---|
| 183 | if(empty($allPopupsCount)) { |
|---|
| 184 | // TODO ASAP remove echo use only wp_die |
|---|
| 185 | echo esc_html(SGPB_AJAX_STATUS_FALSE); |
|---|
| 186 | wp_die(); |
|---|
| 187 | } |
|---|
| 188 | if(isset($allPopupsCount[$popupId])) { |
|---|
| 189 | $allPopupsCount[$popupId] = 0; |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | // 7, 12, 13 => exclude close, subscription success, contact success events |
|---|
| 193 | $stmt = $wpdb->prepare(' DELETE FROM '.$wpdb->prefix.'sgpb_analytics WHERE target_id = %d AND event_id NOT IN (7, 12, 13)', $popupId); |
|---|
| 194 | $popupAnalyticsData = $wpdb->get_var($stmt); |
|---|
| 195 | |
|---|
| 196 | update_option('SgpbCounter', $allPopupsCount); |
|---|
| 197 | |
|---|
| 198 | } |
|---|
| 199 | |
|---|
| 200 | public function dontShowAskReviewBanner() |
|---|
| 201 | { |
|---|
| 202 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 203 | update_option('sgpbDontShowAskReviewBanner', 1); |
|---|
| 204 | echo esc_html(SGPB_AJAX_STATUS_TRUE); |
|---|
| 205 | wp_die(); |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | public function dontShowProblemAlert() |
|---|
| 209 | { |
|---|
| 210 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 211 | update_option('sgpb_alert_problems', 1); |
|---|
| 212 | echo esc_html(SGPB_AJAX_STATUS_TRUE); |
|---|
| 213 | wp_die(); |
|---|
| 214 | } |
|---|
| 215 | |
|---|
| 216 | public function extensionNotificationPanel() |
|---|
| 217 | { |
|---|
| 218 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 219 | update_option('sgpb_extensions_updated', 1); |
|---|
| 220 | echo esc_html(SGPB_AJAX_STATUS_TRUE); |
|---|
| 221 | wp_die(); |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | public function closeMainRateUsBanner() |
|---|
| 225 | { |
|---|
| 226 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 227 | update_option('sgpb-hide-support-banner', 1); |
|---|
| 228 | do_action('sgpbGetNotifications'); |
|---|
| 229 | wp_die(); |
|---|
| 230 | } |
|---|
| 231 | |
|---|
| 232 | public function closeLicenseNoticeBanner() |
|---|
| 233 | { |
|---|
| 234 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 235 | update_option('sgpb-hide-license-notice-banner', 1); |
|---|
| 236 | wp_die(); |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | public function addToCounter() |
|---|
| 240 | { |
|---|
| 241 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 242 | |
|---|
| 243 | if(isset($_GET['sg_popup_preview_id']) && !isset($_POST['params'])) { |
|---|
| 244 | wp_die(0); |
|---|
| 245 | } |
|---|
| 246 | // we will use array_walk_recursive method for sanitizing current data because we can receive an multidimensional array! |
|---|
| 247 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|---|
| 248 | $popupParams = $_POST['params']; |
|---|
| 249 | /* Sanitizing multidimensional array */ |
|---|
| 250 | array_walk_recursive($popupParams, function(&$item){ |
|---|
| 251 | $item = sanitize_text_field($item); |
|---|
| 252 | }); |
|---|
| 253 | |
|---|
| 254 | $popupsIdCollection = is_array($popupParams['popupsIdCollection']) ? $popupParams['popupsIdCollection'] : array(); |
|---|
| 255 | $popupsCounterData = get_option('SgpbCounter'); |
|---|
| 256 | |
|---|
| 257 | if($popupsCounterData === false) { |
|---|
| 258 | $popupsCounterData = array(); |
|---|
| 259 | } |
|---|
| 260 | |
|---|
| 261 | foreach($popupsIdCollection as $popupId => $popupCount) { |
|---|
| 262 | if(empty($popupsCounterData[$popupId])) { |
|---|
| 263 | $popupsCounterData[$popupId] = 0; |
|---|
| 264 | } |
|---|
| 265 | $popupsCounterData[$popupId] += $popupCount; |
|---|
| 266 | } |
|---|
| 267 | |
|---|
| 268 | update_option('SgpbCounter', $popupsCounterData); |
|---|
| 269 | wp_die(1); |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | public function deleteSubscribers() |
|---|
| 273 | { |
|---|
| 274 | global $wpdb; |
|---|
| 275 | |
|---|
| 276 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 277 | |
|---|
| 278 | if (empty($_POST['subscribersId'])){ |
|---|
| 279 | wp_die(); |
|---|
| 280 | } |
|---|
| 281 | $subscribersId = array_map('sanitize_text_field', $_POST['subscribersId']); |
|---|
| 282 | |
|---|
| 283 | foreach($subscribersId as $subscriberId) { |
|---|
| 284 | $prepareSql = $wpdb->prepare('DELETE FROM '.$wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME.' WHERE id = %d', $subscriberId); |
|---|
| 285 | $wpdb->query($prepareSql); |
|---|
| 286 | } |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | public function addSubscribers() |
|---|
| 290 | { |
|---|
| 291 | global $wpdb; |
|---|
| 292 | |
|---|
| 293 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 294 | $status = SGPB_AJAX_STATUS_FALSE; |
|---|
| 295 | $firstName = isset($_POST['firstName']) ? sanitize_text_field($_POST['firstName']) : ''; |
|---|
| 296 | $lastName = isset($_POST['lastName']) ? sanitize_text_field($_POST['lastName']) : ''; |
|---|
| 297 | $email = isset($_POST['email']) ? sanitize_text_field($_POST['email']) : ''; |
|---|
| 298 | $date = date('Y-m-d'); |
|---|
| 299 | |
|---|
| 300 | // we will use array_walk_recursive method for sanitizing current data because we can receive an multidimensional array! |
|---|
| 301 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|---|
| 302 | $subscriptionPopupsId = !empty($_POST['popups']) ? $_POST['popups'] : []; |
|---|
| 303 | array_walk_recursive($subscriptionPopupsId, function(&$item){ |
|---|
| 304 | $item = sanitize_text_field($item); |
|---|
| 305 | }); |
|---|
| 306 | |
|---|
| 307 | foreach($subscriptionPopupsId as $subscriptionPopupId) { |
|---|
| 308 | $selectSql = $wpdb->prepare('SELECT id FROM '.$wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME.' WHERE email = %s AND subscriptionType = %d', $email, $subscriptionPopupId); |
|---|
| 309 | $res = $wpdb->get_row($selectSql, ARRAY_A); |
|---|
| 310 | // add new subscriber |
|---|
| 311 | if(empty($res)) { |
|---|
| 312 | $sql = $wpdb->prepare('INSERT INTO '.$wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME.' (firstName, lastName, email, cDate, subscriptionType) VALUES (%s, %s, %s, %s, %d) ', $firstName, $lastName, $email, $date, $subscriptionPopupId); |
|---|
| 313 | $res = $wpdb->query($sql); |
|---|
| 314 | } // edit existing |
|---|
| 315 | else { |
|---|
| 316 | $sql = $wpdb->prepare('UPDATE '.$wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME.' SET firstName = %s, lastName = %s, email = %s, cDate = %s, subscriptionType = %d, unsubscribered = 0 WHERE id = %d', $firstName, $lastName, $email, $date, $subscriptionPopupId, $res['id']); |
|---|
| 317 | $wpdb->query($sql); |
|---|
| 318 | $res = 1; |
|---|
| 319 | } |
|---|
| 320 | |
|---|
| 321 | if($res) { |
|---|
| 322 | $status = SGPB_AJAX_STATUS_TRUE; |
|---|
| 323 | } |
|---|
| 324 | } |
|---|
| 325 | |
|---|
| 326 | echo esc_html($status); |
|---|
| 327 | wp_die(); |
|---|
| 328 | } |
|---|
| 329 | |
|---|
| 330 | public function importSubscribers() |
|---|
| 331 | { |
|---|
| 332 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 333 | $formId = isset($_POST['popupSubscriptionList']) ? (int)sanitize_text_field($_POST['popupSubscriptionList']) : ''; |
|---|
| 334 | $fileURL = isset($_POST['importListURL']) ? sanitize_text_field($_POST['importListURL']) : ''; |
|---|
| 335 | ob_start(); |
|---|
| 336 | require_once SG_POPUP_VIEWS_PATH.'importConfigView.php'; |
|---|
| 337 | $content = ob_get_contents(); |
|---|
| 338 | ob_end_clean(); |
|---|
| 339 | |
|---|
| 340 | echo wp_kses($content, AdminHelper::allowed_html_tags()); |
|---|
| 341 | wp_die(); |
|---|
| 342 | } |
|---|
| 343 | |
|---|
| 344 | public function importSettings() |
|---|
| 345 | { |
|---|
| 346 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 347 | ob_start(); |
|---|
| 348 | require_once SG_POPUP_VIEWS_PATH.'importPopupsView.php'; |
|---|
| 349 | $content = ob_get_contents(); |
|---|
| 350 | ob_end_clean(); |
|---|
| 351 | |
|---|
| 352 | echo wp_kses($content, AdminHelper::allowed_html_tags()); |
|---|
| 353 | wp_die(); |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | public function saveImportedSubscribers() |
|---|
| 357 | { |
|---|
| 358 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 359 | @ini_set('auto_detect_line_endings', '1'); |
|---|
| 360 | $formId = isset($_POST['popupSubscriptionList']) ? (int)sanitize_text_field($_POST['popupSubscriptionList']) : ''; |
|---|
| 361 | $fileURL = isset($_POST['importListURL']) ? sanitize_text_field($_POST['importListURL']) : ''; |
|---|
| 362 | // we will use array_walk_recursive method for sanitizing current data because we can receive an multidimensional array! |
|---|
| 363 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|---|
| 364 | $mapping = !empty($_POST['namesMapping']) ? $_POST['namesMapping'] : []; |
|---|
| 365 | array_walk_recursive($mapping, function(&$item){ |
|---|
| 366 | $item = sanitize_text_field($item); |
|---|
| 367 | }); |
|---|
| 368 | |
|---|
| 369 | $fileContent = AdminHelper::getFileFromURL($fileURL); |
|---|
| 370 | $csvFileArray = array_map('str_getcsv', file($fileURL)); |
|---|
| 371 | |
|---|
| 372 | $header = $csvFileArray[0]; |
|---|
| 373 | unset($csvFileArray[0]); |
|---|
| 374 | $subscriptionPlusContent = apply_filters('sgpbImportToSubscriptionList', $csvFileArray, $mapping, $formId); |
|---|
| 375 | |
|---|
| 376 | // -1 it's mean saved from Subscription Plus |
|---|
| 377 | if($subscriptionPlusContent != -1) { |
|---|
| 378 | foreach($csvFileArray as $csvData) { |
|---|
| 379 | global $wpdb; |
|---|
| 380 | $subscribersTableName = $wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME; |
|---|
| 381 | $sql = $wpdb->prepare('SELECT submittedData FROM '.$subscribersTableName); |
|---|
| 382 | if(!empty($mapping['date'])) { |
|---|
| 383 | $date = $csvData[$mapping['date']]; |
|---|
| 384 | $date = date('Y-m-d', strtotime($date)); |
|---|
| 385 | } |
|---|
| 386 | if($sql) { |
|---|
| 387 | $sql = $wpdb->prepare('INSERT INTO '.$subscribersTableName.' (firstName, lastName, email, cDate, subscriptionType, status, unsubscribed) VALUES (%s, %s, %s, %s, %d, %d, %d) ', $csvData[$mapping['firstName']], $csvData[$mapping['lastName']], $csvData[$mapping['email']], $date, $formId, 0, 0); |
|---|
| 388 | } else { |
|---|
| 389 | $sql = $wpdb->prepare('INSERT INTO '.$subscribersTableName.' (firstName, lastName, email, cDate, subscriptionType, status, unsubscribed, submittedData) VALUES (%s, %s, %s, %s, %d, %d, %d, %s) ', $csvData[$mapping['firstName']], $csvData[$mapping['lastName']], $csvData[$mapping['email']], $csvData[$mapping['date']], $formId, 0, 0, ''); |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | $wpdb->query($sql); |
|---|
| 393 | } |
|---|
| 394 | } |
|---|
| 395 | |
|---|
| 396 | echo esc_html(SGPB_AJAX_STATUS_TRUE); |
|---|
| 397 | wp_die(); |
|---|
| 398 | } |
|---|
| 399 | |
|---|
| 400 | public function sendNewsletter() |
|---|
| 401 | { |
|---|
| 402 | $allowToAction = AdminHelper::userCanAccessTo(); |
|---|
| 403 | if(!$allowToAction) { |
|---|
| 404 | wp_redirect(get_home_url()); |
|---|
| 405 | exit(); |
|---|
| 406 | } |
|---|
| 407 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 408 | global $wpdb; |
|---|
| 409 | |
|---|
| 410 | // we will use array_walk_recursive method for sanitizing current data because we can receive an multidimensional array! |
|---|
| 411 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|---|
| 412 | $newsletterData = isset($_POST['newsletterData']) ? stripslashes_deep($_POST['newsletterData']) : []; |
|---|
| 413 | array_walk_recursive($newsletterData, function(&$item, $k){ |
|---|
| 414 | if ($k === 'messageBody'){ |
|---|
| 415 | $item = wp_kses($item, AdminHelper::allowed_html_tags()); |
|---|
| 416 | } else { |
|---|
| 417 | $item = sanitize_text_field($item); |
|---|
| 418 | } |
|---|
| 419 | }); |
|---|
| 420 | if(isset($newsletterData['testSendingStatus']) && $newsletterData['testSendingStatus'] == 'test') { |
|---|
| 421 | AdminHelper::sendTestNewsletter($newsletterData); |
|---|
| 422 | } |
|---|
| 423 | $subscriptionFormId = (int)$newsletterData['subscriptionFormId']; |
|---|
| 424 | |
|---|
| 425 | $updateStatusQuery = $wpdb->prepare('UPDATE '.$wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME.' SET status = 0 WHERE subscriptionType = %d', $subscriptionFormId); |
|---|
| 426 | $wpdb->query($updateStatusQuery); |
|---|
| 427 | $newsletterData['blogname'] = get_bloginfo('name'); |
|---|
| 428 | $newsletterData['username'] = wp_get_current_user()->user_login; |
|---|
| 429 | update_option('SGPB_NEWSLETTER_DATA', $newsletterData); |
|---|
| 430 | |
|---|
| 431 | wp_schedule_event(time(), 'sgpb_newsletter_send_every_minute', 'sgpb_send_newsletter'); |
|---|
| 432 | wp_die(); |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | // proStartGold |
|---|
| 436 | public function checkSameOrigin() |
|---|
| 437 | { |
|---|
| 438 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 439 | |
|---|
| 440 | $url = isset($_POST['iframeUrl']) ? esc_url_raw($_POST['iframeUrl']) : ''; |
|---|
| 441 | $status = SGPB_AJAX_STATUS_FALSE; |
|---|
| 442 | |
|---|
| 443 | $remoteGet = wp_remote_get($url); |
|---|
| 444 | |
|---|
| 445 | if(is_array($remoteGet) && !empty($remoteGet['headers']['x-frame-options'])) { |
|---|
| 446 | $siteUrl = isset($_POST['siteUrl']) ? esc_url_raw($_POST['siteUrl']) : ''; |
|---|
| 447 | $xFrameOptions = $remoteGet['headers']['x-frame-options']; |
|---|
| 448 | $mayNotShow = false; |
|---|
| 449 | |
|---|
| 450 | if($xFrameOptions == 'deny') { |
|---|
| 451 | $mayNotShow = true; |
|---|
| 452 | } else if($xFrameOptions == 'SAMEORIGIN') { |
|---|
| 453 | if(strpos($url, $siteUrl) === false) { |
|---|
| 454 | $mayNotShow = true; |
|---|
| 455 | } |
|---|
| 456 | } else { |
|---|
| 457 | if(strpos($xFrameOptions, $siteUrl) === false) { |
|---|
| 458 | $mayNotShow = true;; |
|---|
| 459 | } |
|---|
| 460 | } |
|---|
| 461 | |
|---|
| 462 | if($mayNotShow) { |
|---|
| 463 | echo esc_html($status); |
|---|
| 464 | wp_die(); |
|---|
| 465 | } |
|---|
| 466 | } |
|---|
| 467 | |
|---|
| 468 | // $remoteGet['response']['code'] < 400 it's mean correct status |
|---|
| 469 | if(is_array($remoteGet) && isset($remoteGet['response']['code']) && $remoteGet['response']['code'] < 400) { |
|---|
| 470 | $status = SGPB_AJAX_STATUS_TRUE; |
|---|
| 471 | } |
|---|
| 472 | |
|---|
| 473 | echo esc_html($status); |
|---|
| 474 | wp_die(); |
|---|
| 475 | } |
|---|
| 476 | |
|---|
| 477 | // proEndGold |
|---|
| 478 | |
|---|
| 479 | public function changePopupStatus() |
|---|
| 480 | { |
|---|
| 481 | check_ajax_referer(SG_AJAX_NONCE, 'ajaxNonce'); |
|---|
| 482 | if (!isset($_POST['popupId'])){ |
|---|
| 483 | wp_die(esc_html(SGPB_AJAX_STATUS_FALSE)); |
|---|
| 484 | } |
|---|
| 485 | $popupId = (int)sanitize_text_field($_POST['popupId']); |
|---|
| 486 | $obj = SGPopup::find($popupId); |
|---|
| 487 | $isDraft = ''; |
|---|
| 488 | $postStatus = get_post_status($popupId); |
|---|
| 489 | if($postStatus == 'draft') { |
|---|
| 490 | $isDraft = '_preview'; |
|---|
| 491 | } |
|---|
| 492 | |
|---|
| 493 | if(!$obj || !is_object($obj)) { |
|---|
| 494 | wp_die(esc_html(SGPB_AJAX_STATUS_FALSE)); |
|---|
| 495 | } |
|---|
| 496 | $options = $obj->getOptions(); |
|---|
| 497 | $options['sgpb-is-active'] = isset($_POST['popupStatus'])? sanitize_text_field($_POST['popupStatus']) : ''; |
|---|
| 498 | |
|---|
| 499 | if( isset( $options['sgpb-conditions'] ) ){ |
|---|
| 500 | unset( $options['sgpb-conditions'] ); |
|---|
| 501 | } |
|---|
| 502 | update_post_meta($popupId, 'sg_popup_options'.$isDraft, $options); |
|---|
| 503 | |
|---|
| 504 | wp_die(esc_html($popupId)); |
|---|
| 505 | } |
|---|
| 506 | |
|---|
| 507 | public function subscriptionSubmission() |
|---|
| 508 | { |
|---|
| 509 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 510 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|---|
| 511 | $submissionData = isset($_POST['formData']) ? $_POST['formData'] : "[]"; |
|---|
| 512 | parse_str($submissionData, $formData); |
|---|
| 513 | array_walk_recursive($formData, function(&$item){ |
|---|
| 514 | $item = sanitize_text_field($item); |
|---|
| 515 | }); |
|---|
| 516 | $popupPostId = isset($_POST['popupPostId']) ? (int)sanitize_text_field($_POST['popupPostId']) : ''; |
|---|
| 517 | |
|---|
| 518 | if(empty($formData)) { |
|---|
| 519 | echo SGPB_AJAX_STATUS_FALSE; |
|---|
| 520 | wp_die(); |
|---|
| 521 | } |
|---|
| 522 | |
|---|
| 523 | $hiddenChecker = sanitize_text_field($formData['sgpb-subs-hidden-checker']); |
|---|
| 524 | |
|---|
| 525 | // this check is made to protect ourselves from bot |
|---|
| 526 | if(!empty($hiddenChecker)) { |
|---|
| 527 | echo 'Bot'; |
|---|
| 528 | wp_die(); |
|---|
| 529 | } |
|---|
| 530 | global $wpdb; |
|---|
| 531 | |
|---|
| 532 | $status = SGPB_AJAX_STATUS_FALSE; |
|---|
| 533 | $date = date('Y-m-d'); |
|---|
| 534 | $email = sanitize_email($formData['sgpb-subs-email']); |
|---|
| 535 | $firstName = sanitize_text_field($formData['sgpb-subs-first-name']); |
|---|
| 536 | $lastName = sanitize_text_field($formData['sgpb-subs-last-name']); |
|---|
| 537 | |
|---|
| 538 | $subscribersTableName = $wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME; |
|---|
| 539 | |
|---|
| 540 | $getSubscriberQuery = $wpdb->prepare('SELECT id FROM '.$subscribersTableName.' WHERE email = %s AND subscriptionType = %d', $email, $popupPostId); |
|---|
| 541 | $list = $wpdb->get_row($getSubscriberQuery, ARRAY_A); |
|---|
| 542 | |
|---|
| 543 | // When subscriber does not exist we insert to subscribers table otherwise we update user info |
|---|
| 544 | if(empty($list['id'])) { |
|---|
| 545 | $sql = $wpdb->prepare('INSERT INTO '.$subscribersTableName.' (firstName, lastName, email, cDate, subscriptionType) VALUES (%s, %s, %s, %s, %d) ', $firstName, $lastName, $email, $date, $popupPostId); |
|---|
| 546 | $res = $wpdb->query($sql); |
|---|
| 547 | } else { |
|---|
| 548 | $sql = $wpdb->prepare('UPDATE '.$subscribersTableName.' SET firstName = %s, lastName = %s, email = %s, cDate = %s, subscriptionType = %d WHERE id = %d', $firstName, $lastName, $email, $date, $popupPostId, $list['id']); |
|---|
| 549 | $wpdb->query($sql); |
|---|
| 550 | $res = 1; |
|---|
| 551 | } |
|---|
| 552 | if($res) { |
|---|
| 553 | $status = SGPB_AJAX_STATUS_TRUE; |
|---|
| 554 | } |
|---|
| 555 | |
|---|
| 556 | echo $status; |
|---|
| 557 | wp_die(); |
|---|
| 558 | } |
|---|
| 559 | |
|---|
| 560 | public function sgpbSubsciptionFormSubmittedAction() |
|---|
| 561 | { |
|---|
| 562 | check_ajax_referer(SG_AJAX_NONCE, 'nonce'); |
|---|
| 563 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|---|
| 564 | $submissionData = isset($_POST['formData']) ? $_POST['formData'] : "[]"; |
|---|
| 565 | parse_str($submissionData, $formData); |
|---|
| 566 | array_walk_recursive($formData, function(&$item){ |
|---|
| 567 | $item = sanitize_text_field($item); |
|---|
| 568 | }); |
|---|
| 569 | $popupPostId = isset($_POST['popupPostId']) ? (int)sanitize_text_field($_POST['popupPostId']) : ''; |
|---|
| 570 | if(empty($_POST)) { |
|---|
| 571 | echo SGPB_AJAX_STATUS_FALSE; |
|---|
| 572 | wp_die(); |
|---|
| 573 | } |
|---|
| 574 | $email = isset($_POST['emailValue']) ? sanitize_email($_POST['emailValue']) : ''; |
|---|
| 575 | $firstName = isset($_POST['firstNameValue']) ? sanitize_text_field($_POST['firstNameValue']) : ''; |
|---|
| 576 | $lastName = isset($_POST['lastNameValue']) ? sanitize_text_field($_POST['lastNameValue']) : ''; |
|---|
| 577 | $userData = array( |
|---|
| 578 | 'email' => $email, |
|---|
| 579 | 'firstName' => $firstName, |
|---|
| 580 | 'lastName' => $lastName |
|---|
| 581 | ); |
|---|
| 582 | $this->sendSuccessEmails($popupPostId, $userData); |
|---|
| 583 | do_action('sgpbProcessAfterSuccessfulSubmission', $popupPostId, $userData); |
|---|
| 584 | } |
|---|
| 585 | |
|---|
| 586 | public function sendSuccessEmails($popupPostId, $subscriptionDetails) |
|---|
| 587 | { |
|---|
| 588 | global $wpdb; |
|---|
| 589 | $popup = SGPopup::find($popupPostId); |
|---|
| 590 | |
|---|
| 591 | if(!is_object($popup)) { |
|---|
| 592 | return false; |
|---|
| 593 | } |
|---|
| 594 | $subscribersTableName = $wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME; |
|---|
| 595 | |
|---|
| 596 | $getSubscriberCountQuery = $wpdb->prepare('SELECT COUNT(id) as countIds FROM '.$subscribersTableName.' WHERE subscriptionType = %d', $popupPostId); |
|---|
| 597 | $count = $wpdb->get_row($getSubscriberCountQuery, ARRAY_A); |
|---|
| 598 | |
|---|
| 599 | $popupOptions = $popup->getOptions(); |
|---|
| 600 | $adminUserName = 'admin'; |
|---|
| 601 | |
|---|
| 602 | $adminEmail = get_option('admin_email'); |
|---|
| 603 | $userData = @get_user_by('email', $adminEmail); |
|---|
| 604 | |
|---|
| 605 | if(!empty($userData)) { |
|---|
| 606 | $adminUserName = $userData->display_name; |
|---|
| 607 | } |
|---|
| 608 | |
|---|
| 609 | $newSubscriberEmailHeader = AdminHelper::getEmailHeader($adminEmail); |
|---|
| 610 | $takeReviewAfterFirstSubscription = get_option('sgpb-new-subscriber'); |
|---|
| 611 | |
|---|
| 612 | if($count['countIds'] == 1 && !$takeReviewAfterFirstSubscription) { |
|---|
| 613 | // take review |
|---|
| 614 | update_option('sgpb-new-subscriber', 1); |
|---|
| 615 | $newSubscriberEmailTitle = __('Congrats! You have already 1 subscriber!', SG_POPUP_TEXT_DOMAIN); |
|---|
| 616 | $reviewEmailTemplate = AdminHelper::getFileFromURL(SG_POPUP_EMAIL_TEMPLATES_URL.'takeReviewAfterSubscribe.html'); |
|---|
| 617 | $reviewEmailTemplate = preg_replace('/\[adminUserName]/', $adminUserName, $reviewEmailTemplate); |
|---|
| 618 | $sendStatus = wp_mail($adminEmail, $newSubscriberEmailTitle, $reviewEmailTemplate, $newSubscriberEmailHeader); //return true or false |
|---|
| 619 | } |
|---|
| 620 | } |
|---|
| 621 | |
|---|
| 622 | public function select2SearchData() |
|---|
| 623 | { |
|---|
| 624 | check_ajax_referer(SG_AJAX_NONCE, 'nonce_ajax'); |
|---|
| 625 | |
|---|
| 626 | $postTypeName = isset($_POST['searchKey']) ? sanitize_text_field($_POST['searchKey']) : ''; // TODO strongly validate postTypeName example: use ENUM |
|---|
| 627 | $search = isset($_POST['searchTerm']) ? sanitize_text_field($_POST['searchTerm']) : ''; |
|---|
| 628 | |
|---|
| 629 | switch($postTypeName){ |
|---|
| 630 | case 'postCategories': |
|---|
| 631 | $searchResults = ConfigDataHelper::getPostsAllCategories('post', [], $search); |
|---|
| 632 | break; |
|---|
| 633 | case 'postTags': |
|---|
| 634 | $searchResults = ConfigDataHelper::getAllTags($search); |
|---|
| 635 | break; |
|---|
| 636 | default: |
|---|
| 637 | $searchResults = $this->selectFromPost($postTypeName, $search); |
|---|
| 638 | } |
|---|
| 639 | |
|---|
| 640 | if(isset($_POST['searchCallback'])) { |
|---|
| 641 | $searchCallback = sanitize_text_field($_POST['searchCallback']); |
|---|
| 642 | $searchResults = apply_filters('sgpbSearchAdditionalData', $search, array()); |
|---|
| 643 | } |
|---|
| 644 | |
|---|
| 645 | if(empty($searchResults)) { |
|---|
| 646 | $results['items'] = array(); |
|---|
| 647 | } |
|---|
| 648 | |
|---|
| 649 | /*Selected custom post type convert for select2 format*/ |
|---|
| 650 | foreach($searchResults as $id => $name) { |
|---|
| 651 | $results['items'][] = array( |
|---|
| 652 | 'id' => $id, |
|---|
| 653 | 'text' => $name |
|---|
| 654 | ); |
|---|
| 655 | } |
|---|
| 656 | |
|---|
| 657 | wp_send_json($results); |
|---|
| 658 | } |
|---|
| 659 | |
|---|
| 660 | private function selectFromPost($postTypeName, $search) |
|---|
| 661 | { |
|---|
| 662 | $args = array( |
|---|
| 663 | 's' => $search, |
|---|
| 664 | 'post__in' => !empty($_REQUEST['include']) ? array_map('intval', $_REQUEST['include']) : null, |
|---|
| 665 | 'page' => !empty($_REQUEST['page']) ? absint($_REQUEST['page']) : null, |
|---|
| 666 | 'posts_per_page' => 100, |
|---|
| 667 | 'post_type' => $postTypeName |
|---|
| 668 | ); |
|---|
| 669 | $searchResults = ConfigDataHelper::getPostTypeData($args); |
|---|
| 670 | |
|---|
| 671 | return $searchResults; |
|---|
| 672 | } |
|---|
| 673 | |
|---|
| 674 | public function addConditionGroupRow() |
|---|
| 675 | { |
|---|
| 676 | check_ajax_referer(SG_AJAX_NONCE, 'nonce_ajax'); |
|---|
| 677 | global $SGPB_DATA_CONFIG_ARRAY; |
|---|
| 678 | |
|---|
| 679 | $groupId = isset($_POST['groupId']) ? (int)sanitize_text_field($_POST['groupId']) : ''; |
|---|
| 680 | $targetType = isset($_POST['conditionName']) ? sanitize_text_field($_POST['conditionName']) : ''; |
|---|
| 681 | $addedObj = array(); |
|---|
| 682 | |
|---|
| 683 | $builderObj = new ConditionBuilder(); |
|---|
| 684 | |
|---|
| 685 | $builderObj->setGroupId($groupId); |
|---|
| 686 | $builderObj->setRuleId(SG_CONDITION_FIRST_RULE); |
|---|
| 687 | $builderObj->setSavedData($SGPB_DATA_CONFIG_ARRAY[$targetType]['initialData'][0]); |
|---|
| 688 | $builderObj->setConditionName($targetType); |
|---|
| 689 | $addedObj[] = $builderObj; |
|---|
| 690 | |
|---|
| 691 | $creator = new ConditionCreator($addedObj); |
|---|
| 692 | echo wp_kses($creator->render(), AdminHelper::allowed_html_tags()); |
|---|
| 693 | wp_die(); |
|---|
| 694 | } |
|---|
| 695 | |
|---|
| 696 | public function addConditionRuleRow() |
|---|
| 697 | { |
|---|
| 698 | check_ajax_referer(SG_AJAX_NONCE, 'nonce_ajax'); |
|---|
| 699 | $data = ''; |
|---|
| 700 | global $SGPB_DATA_CONFIG_ARRAY; |
|---|
| 701 | $targetType = isset($_POST['conditionName']) ? sanitize_text_field($_POST['conditionName']) : ''; |
|---|
| 702 | $builderObj = new ConditionBuilder(); |
|---|
| 703 | |
|---|
| 704 | $groupId = isset($_POST['groupId']) ? (int)sanitize_text_field($_POST['groupId']) : ''; |
|---|
| 705 | $ruleId = isset($_POST['ruleId']) ? (int)sanitize_text_field($_POST['ruleId']) : ''; |
|---|
| 706 | |
|---|
| 707 | $builderObj->setGroupId($groupId); |
|---|
| 708 | $builderObj->setRuleId($ruleId); |
|---|
| 709 | $builderObj->setSavedData($SGPB_DATA_CONFIG_ARRAY[$targetType]['initialData'][0]); |
|---|
| 710 | $builderObj->setConditionName($targetType); |
|---|
| 711 | |
|---|
| 712 | $data .= ConditionCreator::createConditionRuleRow($builderObj); |
|---|
| 713 | |
|---|
| 714 | echo wp_kses($data, AdminHelper::allowed_html_tags()); |
|---|
| 715 | wp_die(); |
|---|
| 716 | } |
|---|
| 717 | |
|---|
| 718 | public function changeConditionRuleRow() |
|---|
| 719 | { |
|---|
| 720 | check_ajax_referer(SG_AJAX_NONCE, 'nonce_ajax'); |
|---|
| 721 | $data = ''; |
|---|
| 722 | global $SGPB_DATA_CONFIG_ARRAY; |
|---|
| 723 | |
|---|
| 724 | $targetType = isset($_POST['conditionName']) ? sanitize_text_field($_POST['conditionName']) : ''; |
|---|
| 725 | $builderObj = new ConditionBuilder(); |
|---|
| 726 | $conditionConfig = $SGPB_DATA_CONFIG_ARRAY[$targetType]; |
|---|
| 727 | $groupId = isset($_POST['groupId']) ? (int)sanitize_text_field($_POST['groupId']) : ''; |
|---|
| 728 | $ruleId = isset($_POST['ruleId']) ? (int)sanitize_text_field($_POST['ruleId']) : ''; |
|---|
| 729 | $popupId = isset($_POST['popupId']) ? (int)sanitize_text_field($_POST['popupId']) : ''; |
|---|
| 730 | $paramName = isset($_POST['paramName']) ? sanitize_text_field($_POST['paramName']) : ''; |
|---|
| 731 | |
|---|
| 732 | $savedData = array( |
|---|
| 733 | 'param' => $paramName |
|---|
| 734 | ); |
|---|
| 735 | |
|---|
| 736 | if($targetType == 'target' || $targetType == 'conditions') { |
|---|
| 737 | $savedData['operator'] = '=='; |
|---|
| 738 | } else if($conditionConfig['specialDefaultOperator']) { |
|---|
| 739 | $savedData['operator'] = $paramName; |
|---|
| 740 | } |
|---|
| 741 | |
|---|
| 742 | if(!empty($_POST['paramValue'])) { |
|---|
| 743 | $savedData['tempParam'] = sanitize_text_field($_POST['paramValue']); |
|---|
| 744 | $savedData['operator'] = $paramName; |
|---|
| 745 | } |
|---|
| 746 | // change operator value related to condition value |
|---|
| 747 | if(!empty($conditionConfig['operatorAllowInConditions']) && in_array($paramName, $conditionConfig['operatorAllowInConditions'])) { |
|---|
| 748 | $conditionConfig['paramsData']['operator'] = array(); |
|---|
| 749 | |
|---|
| 750 | if(!empty($conditionConfig['paramsData'][$paramName.'Operator'])) { |
|---|
| 751 | $operatorData = $conditionConfig['paramsData'][$paramName.'Operator']; |
|---|
| 752 | $SGPB_DATA_CONFIG_ARRAY[$targetType]['paramsData']['operator'] = $operatorData; |
|---|
| 753 | // change take value related to condition value |
|---|
| 754 | $operatorDataKeys = array_keys($operatorData); |
|---|
| 755 | if(!empty($operatorDataKeys[0])) { |
|---|
| 756 | $savedData['operator'] = $operatorDataKeys[0]; |
|---|
| 757 | $builderObj->setTakeValueFrom('operator'); |
|---|
| 758 | } |
|---|
| 759 | } |
|---|
| 760 | } |
|---|
| 761 | // by default set empty value for users' role (adv. tar.) |
|---|
| 762 | $savedData['value'] = array(); |
|---|
| 763 | $savedData['hiddenOption'] = isset($conditionConfig['hiddenOptionData'][$paramName]) ? $conditionConfig['hiddenOptionData'][$paramName] : ''; |
|---|
| 764 | |
|---|
| 765 | $builderObj->setPopupId($popupId); |
|---|
| 766 | $builderObj->setGroupId($groupId); |
|---|
| 767 | $builderObj->setRuleId($ruleId); |
|---|
| 768 | $builderObj->setSavedData($savedData); |
|---|
| 769 | $builderObj->setConditionName($targetType); |
|---|
| 770 | |
|---|
| 771 | $data .= ConditionCreator::createConditionRuleRow($builderObj); |
|---|
| 772 | |
|---|
| 773 | echo wp_kses($data, AdminHelper::allowed_html_tags()); |
|---|
| 774 | wp_die(); |
|---|
| 775 | } |
|---|
| 776 | } |
|---|