PluginProbe
Redirection / 5.0.1
Redirection v5.0.1
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / models / redirect / redirect-options.php

redirect-options.php in Redirection 5.0.1, at models/redirect/redirect-options.php

63 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Options for a redirect source URL
5 */
6 class Red_Source_Options {
7 /**
8 * Exclude this from logging.
9 *
10 * @var boolean
11 */
12 private $log_exclude = false;
13
14 /**
15 * Constructor
16 *
17 * @param array|null $options Options.
18 */
19 public function __construct( $options = null ) {
20 if ( $options ) {
21 $this->set_options( $options );
22 }
23 }
24
25 /**
26 * Set options
27 *
28 * @param array $options Options.
29 * @return void
30 */
31 public function set_options( $options ) {
32 if ( isset( $options['log_exclude'] ) && $options['log_exclude'] === true ) {
33 $this->log_exclude = true;
34 }
35 }
36
37 /**
38 * Can this source be logged?
39 *
40 * @return boolean
41 */
42 public function can_log() {
43 $options = red_get_options();
44
45 if ( isset( $options['expire_redirect'] ) && $options['expire_redirect'] !== -1 ) {
46 return ! $this->log_exclude;
47 }
48
49 return false;
50 }
51
52 /**
53 * Get options as JSON
54 *
55 * @return array
56 */
57 public function get_json() {
58 return array_filter( [
59 'log_exclude' => $this->log_exclude,
60 ] );
61 }
62 }
63