Skip to content
Snippets Groups Projects
Select Git revision
  • e5a8505c41ee49cf4da2031a8e460dff7b004aa4
  • 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.41 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;
    
    	/**
    	 * 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.
    	 */
    	public function __construct( TimeWatcher $method_watcher, $namespace, $plugin_name ) {
    		$this->namespace   = $namespace;
    		$this->plugin_name = $plugin_name;
    
    		$this->second_notice_start_time = get_option( $this->prepare_notice_start_time_option_name(), '' );
    		$this->first_notice_start_time  = '';
    
    		if ( '' === $this->second_notice_start_time && '' !== $method_watcher->get_creation_time() ) {
    			$this->first_notice_start_time = gmdate( 'Y-m-d H:i:s', strtotime( $method_watcher->get_creation_time() ) + self::NOTICES_OFFSET );
    		}
    	}
    
    	/**
    	 * Return option name for second notice timer.
    	 *