| @@ -96,9 +96,8 @@ | ||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | return [ |
| 99 | 99 | 'id' => $this->campaign->get_id(), |
| 100 | - 'product_ids'=> $this->campaign->getWcProductsSelection(), | |
| 101 | 100 | 'actions' => $actions, |
| 102 | 101 | 'template' => $this->timer(), |
| 103 | 102 | 'methods' => $this->campaign->detectionMethods, |
| 104 | 103 | 'mode' => $this->campaign->get_mode_slug(), |
| @@ -106,13 +105,8 @@ | ||
| 106 | 105 | intval( $this->campaign->stickyBarDismissTimeout ), $this->campaign->get_id() ), |
| 107 | 106 | ]; |
| 108 | 107 | } |
| 109 | 108 | |
| 110 | - /** | |
| 111 | - * Returns client config for evergreen mode. | |
| 112 | - * | |
| 113 | - * @return array | |
| 114 | - */ | |
| 115 | 109 | private function evergreenClientConfig() |
| 116 | 110 | { |
| 117 | 111 | $evergreenCompaign = new EvergreenCampaign( $this->campaign->get_id() ); |
| 118 | 112 | $evergreenCompaign->loadSettings(); |
| @@ -119,11 +113,8 @@ | ||
| 119 | 113 | return [ |
| 120 | 114 | 'isRegular' => false, |
| 121 | 115 | 'restart_duration'=> $this->campaign->getRestartDuration(true), |
| 122 | 116 | 'duration' => $this->campaign->durationInSeconds(), |
| 123 | - 'evergreenEndType' => $this->campaign->getEvergreenEndType(), | |
| 124 | - 'evergreenEndTime' => $this->campaign->getEvergreenEndTime(), | |
| 125 | - 'evergreenEndDay' => $this->campaign->getEvergreenEndDay(), | |
| 126 | 117 | 'should_reset' => $evergreenCompaign->shouldResetTimer(), |
| 127 | 118 | 'reset_token' => $evergreenCompaign->getInitiatedResetToken(), |
| 128 | 119 | 'restart' => apply_filters( 'hurryt_evergreen_restart', $this->campaign->getRestart() ), |
| 129 | 120 | 'endDate' => $evergreenCompaign->getEndDate(), |
| @@ -130,9 +121,8 @@ | ||
| 130 | 121 | 'cookieName' => Cookie_Detection::cookieName( $this->campaign->get_id() ), |
| 131 | 122 | 'reload_reset' => $evergreenCompaign->reloadReset, |
| 132 | 123 | ]; |
| 133 | 124 | |
| 134 | - return $config; | |
| 135 | 125 | } |
| 136 | 126 | |
| 137 | 127 | /** |
| 138 | 128 | * Returns regular config. |
| @@ -141,9 +131,9 @@ | ||
| 141 | 131 | */ |
| 142 | 132 | private function regularClientConfig() |
| 143 | 133 | { |
| 144 | 134 | try { |
| 145 | - $endDate = Carbon::parse( $this->campaign->getEndDatetime(), hurryt_tz($this->campaign->timezone) )->getBrowserTimestamp(); | |
| 135 | + $endDate = Carbon::parse( $this->campaign->getEndDatetime(), hurryt_tz() )->getBrowserTimestamp(); | |
| 146 | 136 | if ( $this->campaign->is_recurring() ) { |
| 147 | 137 | $endDate = $this->campaign->getRecurrenceEndDate(); |
| 148 | 138 | if ( $endDate ) { |
| 149 | 139 | $endDate = $endDate->getBrowserTimestamp(); |
| @@ -153,9 +143,9 @@ | ||
| 153 | 143 | } |
| 154 | 144 | |
| 155 | 145 | $timeToNextRecurrence = $this->campaign->is_recurring() ? $this->campaign->timeToNextRecurrence() : 0; |
| 156 | 146 | |
| 157 | - $config = [ | |
| 147 | + return [ | |
| 158 | 148 | 'recurr' => $this->campaign->is_recurring(), |
| 159 | 149 | 'timeToNextRecurrence' => $timeToNextRecurrence, |
| 160 | 150 | 'isRegular' => true, |
| 161 | 151 | 'endDate' => $endDate, |
| @@ -160,13 +150,11 @@ | ||
| 160 | 150 | 'isRegular' => true, |
| 161 | 151 | 'endDate' => $endDate, |
| 162 | 152 | ]; |
| 163 | 153 | |
| 164 | - return $config; | |
| 165 | - | |
| 166 | 154 | } catch ( Exception $e ) { |
| 167 | - error_log($e->getMessage()); | |
| 168 | - throw new Exception($e->getMessage()); | |
| 155 | + echo __( sprintf( 'HurryTimer Error: Invalid campaign (ID: %d). Please double check your settings.', | |
| 156 | + $this->campaign->get_id() ), 'hurrytimer' ); | |
| 169 | 157 | } |
| 170 | 158 | } |
| 171 | 159 | |
| 172 | 160 | /** |
| @@ -177,10 +165,12 @@ | ||
| 177 | 165 | */ |
| 178 | 166 | public function getClientConfig( $options = [] ) |
| 179 | 167 | { |
| 180 | 168 | $config = $options; |
| 169 | + | |
| 181 | 170 | if ( $this->campaign->is_evergreen() ) { |
| 182 | 171 | $config = array_merge( $config, $this->commonClientConfig(), $this->evergreenClientConfig() ); |
| 172 | + | |
| 183 | 173 | } else { |
| 184 | 174 | $config = array_merge( $config, $this->commonClientConfig(), $this->regularClientConfig() ); |
| 185 | 175 | } |
| 186 | 176 | |
| @@ -235,19 +225,11 @@ | ||
| 235 | 225 | * @return string |
| 236 | 226 | */ |
| 237 | 227 | public function monthsBlock() |
| 238 | 228 | { |
| 239 | - $label = $this->campaign->labels[ 'months' ]; | |
| 229 | + $label = __( $this->campaign->labels[ 'months' ], 'hurrytimer' ); | |
| 240 | 230 | $label = apply_filters( 'hurryt_months_label', $label, $this->campaign->get_id() ); |
| 241 | - | |
| 242 | - $zero_padded = (bool)apply_filters('hurrytimer_zero_padded_digits', true, $this->campaign->get_id()); | |
| 243 | - | |
| 244 | - if( apply_filters('hurrytimer_auto_pluralize', false ) ){ | |
| 245 | - $label.='%!m'; | |
| 246 | - } | |
| 247 | - | |
| 248 | - $directive = $zero_padded ? "%m": "%-m"; | |
| 249 | - return $this->campaign->monthsVisibility === C::YES ? $this->block($directive , $label ) : ''; | |
| 231 | + return $this->campaign->monthsVisibility === C::YES ? $this->block( "%m", $label ) : ''; | |
| 250 | 232 | } |
| 251 | 233 | |
| 252 | 234 | |
| 253 | 235 | /** |
| @@ -256,9 +238,9 @@ | ||
| 256 | 238 | * @return string |
| 257 | 239 | */ |
| 258 | 240 | public function daysBlock() |
| 259 | 241 | { |
| 260 | - $label = $this->campaign->labels[ 'days' ]; | |
| 242 | + $label = __( $this->campaign->labels[ 'days' ], 'hurrytimer' ); | |
| 261 | 243 | |
| 262 | 244 | /** |
| 263 | 245 | * @deprecated Use `hurryt_days_label` instead. |
| 264 | 246 | */ |
| @@ -264,19 +246,15 @@ | ||
| 264 | 246 | */ |
| 265 | 247 | $label = apply_filters( "hurryt_{$this->campaign->get_id()}_campaign_timer_days_label", |
| 266 | 248 | $label, $this->campaign ); |
| 267 | 249 | |
| 268 | - $zero_padded = (bool)apply_filters('hurrytimer_zero_padded_digits', true, $this->campaign->get_id()); | |
| 250 | + $directive = '%D'; | |
| 269 | 251 | |
| 270 | - $directive = $zero_padded ? '%D' : '%-D'; | |
| 271 | 252 | if ( $this->campaign->monthsVisibility == C::YES ) { |
| 272 | - $directive = $zero_padded ? '%n' : '%-n'; | |
| 253 | + $directive = '%n'; | |
| 273 | 254 | } |
| 274 | 255 | |
| 275 | 256 | $directive = apply_filters( 'hurryt_days_directive', $directive, $this->campaign->get_id() ); |
| 276 | - if( apply_filters('hurrytimer_auto_pluralize', false ) ){ | |
| 277 | - $label.='%!D'; | |
| 278 | - } | |
| 279 | 257 | $label = apply_filters( 'hurryt_days_label', $label, $this->campaign->get_id() ); |
| 280 | 258 | return $this->campaign->daysVisibility === C::YES ? $this->block( $directive, $label ) : ''; |
| 281 | 259 | |
| 282 | 260 | |
| @@ -288,9 +266,9 @@ | ||
| 288 | 266 | * @return string |
| 289 | 267 | */ |
| 290 | 268 | public function hoursBlock() |
| 291 | 269 | { |
| 292 | - $label = $this->campaign->labels[ 'hours' ]; | |
| 270 | + $label = __( $this->campaign->labels[ 'hours' ], 'hurrytimer' ); | |
| 293 | 271 | |
| 294 | 272 | /** |
| 295 | 273 | * @deprecated Use `hurryt_hours_label` instead. |
| 296 | 274 | */ |
| @@ -297,24 +275,11 @@ | ||
| 297 | 275 | |
| 298 | 276 | $label = apply_filters( "hurryt_{$this->campaign->get_id()}_campaign_timer_hours_label", |
| 299 | 277 | $label, $this->campaign ); |
| 300 | 278 | |
| 301 | - | |
| 302 | - $zero_padded = (bool)apply_filters('hurrytimer_zero_padded_digits', true, $this->campaign->get_id()); | |
| 303 | - | |
| 304 | - $directive = $zero_padded ? '%H' : '%-H'; | |
| 305 | - | |
| 306 | - if ( $this->campaign->daysVisibility == C::NO ) { | |
| 307 | - $directive = $zero_padded ? '%I': '%-I'; | |
| 308 | - } | |
| 309 | - | |
| 310 | - if( apply_filters('hurrytimer_auto_pluralize', false ) ){ | |
| 311 | - $label.='%!H'; | |
| 312 | - } | |
| 313 | - | |
| 314 | 279 | $label = apply_filters( 'hurryt_hours_label', $label, $this->campaign->get_id() ); |
| 315 | 280 | |
| 316 | - return $this->campaign->hoursVisibility === C::YES ? $this->block($directive, $label ) : ''; | |
| 281 | + return $this->campaign->hoursVisibility === C::YES ? $this->block( "%H", $label ) : ''; | |
| 317 | 282 | |
| 318 | 283 | |
| 319 | 284 | } |
| 320 | 285 | |
| @@ -324,31 +289,18 @@ | ||
| 324 | 289 | * @return string |
| 325 | 290 | */ |
| 326 | 291 | public function minutesBlock() |
| 327 | 292 | { |
| 328 | - $label = $this->campaign->labels[ 'minutes' ]; | |
| 293 | + $label = __( $this->campaign->labels[ 'minutes' ], 'hurrytimer' ); | |
| 329 | 294 | |
| 330 | 295 | /** @deprecated Use `hurryt_minutes_label` instead. */ |
| 331 | 296 | $label = apply_filters( "hurryt_{$this->campaign->get_id()}_campaign_timer_minutes_label", |
| 332 | 297 | $label, $this->campaign ); |
| 333 | 298 | |
| 334 | - | |
| 335 | - $zero_padded = (bool)apply_filters('hurrytimer_zero_padded_digits', true, $this->campaign->get_id()); | |
| 336 | - | |
| 337 | - $directive = $zero_padded ?'%M': '%-M'; | |
| 338 | - | |
| 339 | - if ( $this->campaign->hoursVisibility == C::NO ) { | |
| 340 | - $directive = $zero_padded ? '%N': '%-N'; | |
| 341 | - } | |
| 342 | - | |
| 343 | - if( apply_filters('hurrytimer_auto_pluralize', false ) ){ | |
| 344 | - $label.='%!M'; | |
| 345 | - } | |
| 346 | - | |
| 347 | 299 | $label = apply_filters( 'hurryt_minutes_label', $label, $this->campaign->get_id() ); |
| 348 | 300 | |
| 349 | 301 | return $this->campaign->minutesVisibility === C::YES |
| 350 | - ? $this->block( $directive, $label ) | |
| 302 | + ? $this->block( "%M", $label ) | |
| 351 | 303 | : ''; |
| 352 | 304 | |
| 353 | 305 | } |
| 354 | 306 | |
| @@ -359,31 +311,19 @@ | ||
| 359 | 311 | */ |
| 360 | 312 | public function secondsBlock() |
| 361 | 313 | { |
| 362 | 314 | |
| 363 | - $label = $this->campaign->labels[ 'seconds' ]; | |
| 315 | + $label = __( $this->campaign->labels[ 'seconds' ], 'hurrytimer' ); | |
| 316 | + | |
| 364 | 317 | |
| 365 | 318 | /** @deprecated Use `hurryt_seconds_label` instead. */ |
| 366 | 319 | $label = apply_filters( "hurryt_{$this->campaign->get_id()}_campaign_timer_seconds_label", |
| 367 | 320 | $label, $this->campaign ); |
| 368 | 321 | |
| 369 | - | |
| 370 | - $zero_padded = (bool)apply_filters('hurrytimer_zero_padded_digits', true, $this->campaign->get_id()); | |
| 371 | - | |
| 372 | - $directive = $zero_padded ?'%S': '%-S'; | |
| 373 | - | |
| 374 | - if ( $this->campaign->minutesVisibility == C::NO ) { | |
| 375 | - $directive = $zero_padded ? '%T': '%-T'; | |
| 376 | - } | |
| 377 | - | |
| 378 | - if( apply_filters('hurrytimer_auto_pluralize', false ) ){ | |
| 379 | - $label.='%!S'; | |
| 380 | - } | |
| 381 | - | |
| 382 | 322 | $label = apply_filters( 'hurryt_seconds_label', $label, $this->campaign->get_id() ); |
| 383 | 323 | |
| 384 | 324 | return $this->campaign->secondsVisibility === C::YES |
| 385 | - ? $this->block( $directive, $label ) | |
| 325 | + ? $this->block( "%S", $label ) | |
| 386 | 326 | : ''; |
| 387 | 327 | |
| 388 | 328 | } |
| 389 | 329 | |
| @@ -415,23 +355,24 @@ | ||
| 415 | 355 | return ''; |
| 416 | 356 | } |
| 417 | 357 | |
| 418 | 358 | return '<div class="hurrytimer-timer-label ' . $this->legacyLabelClass() . '" >' |
| 419 | - . $text . '</div>'; | |
| 359 | + . __( $text, 'hurrytimer' ) . '</div>'; | |
| 420 | 360 | |
| 421 | 361 | } |
| 422 | 362 | |
| 423 | 363 | public function headline() |
| 424 | 364 | { |
| 425 | - $headline = $this->campaign->headline; | |
| 365 | + $headline = __( $this->campaign->headline, 'hurrytimer' ); | |
| 426 | 366 | |
| 427 | 367 | /** |
| 428 | 368 | * @deprecated Use `hurryt_campaign_headline` instead. |
| 429 | 369 | */ |
| 430 | - $headline = apply_filters( "hurryt_{$this->campaign->get_id()}_campaign_headline", | |
| 431 | - $headline, $this->campaign); | |
| 370 | + $headline = __( apply_filters( "hurryt_{$this->campaign->get_id()}_campaign_headline", | |
| 371 | + $headline, $this->campaign ), 'hurrytimer' ); | |
| 432 | 372 | |
| 433 | - $headline = apply_filters( "hurryt_campaign_headline", $headline, $this->campaign->get_id()); | |
| 373 | + $headline = __( apply_filters( "hurryt_campaign_headline", $headline, $this->campaign->get_id() ), | |
| 374 | + 'hurrytimer' ); | |
| 434 | 375 | |
| 435 | 376 | $headline = nl2br( Placeholder_Factory::parse( $headline, $this->campaign ) ); |
| 436 | 377 | |
| 437 | 378 | $headline = do_shortcode($headline); |
| @@ -453,10 +394,10 @@ | ||
| 453 | 394 | |
| 454 | 395 | $cta_url = $this->campaign->callToAction[ 'url' ]; |
| 455 | 396 | |
| 456 | 397 | /** @deprecated Use `hurryt_cta_text` instead. */ |
| 457 | - $cta_text = apply_filters( "hurryt_{$this->campaign->get_id()}_campaign_cta_text", | |
| 458 | - $cta_text, $this->campaign ); | |
| 398 | + $cta_text = __( apply_filters( "hurryt_{$this->campaign->get_id()}_campaign_cta_text", | |
| 399 | + $cta_text, $this->campaign ), 'hurrytimer' ); | |
| 459 | 400 | |
| 460 | 401 | $cta_text = apply_filters('hurryt_cta_text', $cta_text, $this->campaign->get_id()); |
| 461 | 402 | |
| 462 | 403 | /** @deprecated Use `hurryt_cta_url` instead. */ |
| @@ -466,10 +407,10 @@ | ||
| 466 | 407 | $cta_url = apply_filters('hurryt_cta_url', $cta_url, $this->campaign->get_id()); |
| 467 | 408 | |
| 468 | 409 | |
| 469 | 410 | $target = $this->campaign->callToAction[ 'new_tab' ] === C::YES ? '_blank' : '_self'; |
| 470 | - $template = "<a class='hurrytimer-button' target='" . esc_attr($target) . "' href='" . esc_url($cta_url) | |
| 471 | - . "' >" . wp_kses_post($cta_text) . "</a>"; | |
| 411 | + $template = "<a class='hurrytimer-button' target='" . $target . "' href='" . $cta_url | |
| 412 | + . "' >" . $cta_text . "</a>"; | |
| 472 | 413 | |
| 473 | 414 | /** @deprecated Use `hurryt_cta_template` instead. */ |
| 474 | 415 | $template = apply_filters( "hurryt_{$this->campaign->get_id()}_campaign_cta_template", |
| 475 | 416 | $template, $this->campaign ); |