Skip to content
Snippets Groups Projects
Select Git revision
  • 0e1cb196ced822fa390fe15ca293feac0ceeeda7
  • master default protected
  • 1.6.4
  • 1.6.3
  • 1.6.2
  • 1.6.1
  • 1.6.0
  • 1.5.0
  • 1.4.0
  • 1.3.1
  • 1.3.0
  • 1.3.0-beta1
  • 1.2.1
  • 1.2.0
  • 1.2.0-beta5
  • 1.2.0-beta4
  • 1.2.0-beta3
  • 1.2.0-beta2
  • 1.2.0-beta1
  • 1.1.0
  • 1.0.0
21 results

RatingPetitionNotice.php

Blame
  • 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  = '';