Select Git revision
RatingPetitionNotice.php
-
Grzegorz Rola authoredGrzegorz Rola authored
RatingPetitionNotice.php 5.60 KiB
<?php
/**
* Repository rating.
*
* @package Flexible Shipping Fedex
*/
namespace WPDesk\RepositoryRating;
use WPDesk\PluginBuilder\Plugin\Hookable;
/**
* Can display rating notices based on watcher time time.
*/
class RatingPetitionNotice implements Hookable {
const CLOSE_TEMPORARY_NOTICE = 'close-temporary-notice';
const NOTICES_OFFSET = 1209600; // Two weeks in seconds.
/**
* First notice start time.
*
* @var string
*/
private $first_notice_start_time;
/**
* Second notice start time.
*
* @var string
*/
private $second_notice_start_time;
/**
* Unique namespace for id/option generation
*
* @var string
*/
private $namespace;
/**
* Plugin name in notice content.
*
* @var string
*/
private $plugin_name;
/**
* Url to redirect when user wants to send a rate.
*
* @var string
*/
private $rate_url;
/**
* RatingPetitionNotice constructor.
*
* @param TimeWatcher $method_watcher Watcher to decide when should first notice be displayed.
* @param string $namespace Unique namespace for id/option generation.
* @param string $plugin_name Plugin name in notice content.
* @param string $rate_url Url to redirect when user wants to send a rate.
*/
public function __construct( TimeWatcher $method_watcher, $namespace, $plugin_name, $rate_url = '' ) {
$this->namespace = $namespace;
$this->plugin_name = $plugin_name;
$this->rate_url = $rate_url;
$this->second_notice_start_time = get_option( $this->prepare_notice_start_time_option_name(), '' );
$this->first_notice_start_time = '';