コード例 #1
0
 /**
  * Make an API Dispatcher.
  *
  * @return \ITELIC\API\Dispatch
  */
 public function make()
 {
     $dispatch = new Dispatch();
     $dispatch->set_responder(new JSON_Responder());
     /**
      * Filter the API dispatcher.
      *
      * If the filtered dispatcher is not a subclass of \ITELIC\API\Dispatch,
      * the original dispatcher will be used.
      *
      * @since 1.0
      *
      * @param \ITELIC\API\Dispatch $dispatch
      */
     $filtered = apply_filters('itelic_api_dispatcher', $dispatch);
     if ($filtered instanceof Dispatch) {
         $dispatch = $filtered;
     }
     $dispatch->setLogger(new Logger(new Table('itelic-api-logs'), new Simple_Query($GLOBALS['wpdb'], new Table('itelic-api-logs'))));
     /**
      * Fires when custom API endpoints should be registered with the dispatcher.
      *
      * @since 1.0
      *
      * @param \ITELIC\API\Dispatch $dispatch
      */
     do_action('itelic_api_register_endpoints', $dispatch);
     return $dispatch;
 }
コード例 #2
0
/**
 * Generate a download link for an activation record.
 *
 * @internal
 *
 * @since 1.0
 *
 * @param Activation $activation
 *
 * @return string
 */
function generate_download_link(Activation $activation)
{
    $now = make_date_time();
    $interval = new \DateInterval('P1D');
    /**
     * Filter the expiration interval for a download link.
     *
     * @since 1.0
     *
     * @param \DateInterval $interval
     * @param Activation    $activation
     */
    $filtered = apply_filters('itelic_download_link_expiration_interval', $interval, $activation);
    if ($filtered instanceof \DateInterval) {
        $interval = $filtered;
    }
    $expires = $now->add($interval);
    $args = generate_download_query_args($activation, $expires);
    $download_ep = Dispatch::get_url('download');
    $link = add_query_arg($args, $download_ep);
    /**
     * Filters the download link for an activation.
     *
     * Download links are specific to activations, not products.
     * This allows for pausing releases, and pre-release tracks.
     *
     * If you are going to override the download link, you need
     * to be able dynamically serve the download based on the current
     * state of the releases, and the activation track.
     *
     * @since 1.0
     *
     * @param string     $link
     * @param Activation $activation
     */
    $link = apply_filters('itelic_generate_download_link', $link, $activation);
    return $link;
}