- Timestamp:
- 04/15/2019 10:43:57 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-recovery-mode-cookie-service.php
r44973 r45205 15 15 16 16 /** 17 * The cookie name to use.18 *19 * @since 5.2.020 * @var string21 */22 private $name;23 24 /**25 * The domain the cookie should be set on, {@see setcookie()}.26 *27 * @since 5.2.028 * @var string29 */30 private $domain;31 32 /**33 * The path to limit the cookie to, {@see setcookie()}.34 *35 * @since 5.2.036 * @var string37 */38 private $path;39 40 /**41 * The path to use when the home_url and site_url are different.42 *43 * @since 5.2.044 * @var string45 */46 private $site_path;47 48 /**49 * WP_Recovery_Mode_Cookie_Service constructor.50 *51 * @since 5.2.052 *53 * @param array $opts {54 * Recovery mode cookie options.55 *56 * @type string $name Cookie name.57 * @type string $domain Cookie domain.58 * @type string $path Cookie path.59 * @type string $site_path Site cookie path.60 * }61 */62 public function __construct( array $opts = array() ) {63 $opts = wp_parse_args(64 $opts,65 array(66 'name' => RECOVERY_MODE_COOKIE,67 'domain' => COOKIE_DOMAIN,68 'path' => COOKIEPATH,69 'site_path' => SITECOOKIEPATH,70 )71 );72 73 $this->name = $opts['name'];74 $this->domain = $opts['domain'];75 $this->path = $opts['path'];76 $this->site_path = $opts['site_path'];77 }78 79 /**80 17 * Checks whether the recovery mode cookie is set. 81 18 * … … 85 22 */ 86 23 public function is_cookie_set() { 87 return ! empty( $_COOKIE[ $this->name] );24 return ! empty( $_COOKIE[ RECOVERY_MODE_COOKIE ] ); 88 25 } 89 26 … … 99 36 $value = $this->generate_cookie(); 100 37 101 setcookie( $this->name, $value, 0, $this->path, $this->domain, is_ssl(), true );102 103 if ( $this->path !== $this->site_path) {104 setcookie( $this->name, $value, 0, $this->site_path, $this->domain, is_ssl(), true );38 setcookie( RECOVERY_MODE_COOKIE, $value, 0, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true ); 39 40 if ( COOKIEPATH !== SITECOOKIEPATH ) { 41 setcookie( RECOVERY_MODE_COOKIE, $value, 0, SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl(), true ); 105 42 } 106 43 } … … 112 49 */ 113 50 public function clear_cookie() { 114 setcookie( $this->name, ' ', time() - YEAR_IN_SECONDS, $this->path, $this->domain);115 setcookie( $this->name, ' ', time() - YEAR_IN_SECONDS, $this->site_path, $this->domain);51 setcookie( RECOVERY_MODE_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); 52 setcookie( RECOVERY_MODE_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); 116 53 } 117 54 … … 128 65 129 66 if ( ! $cookie ) { 130 if ( empty( $_COOKIE[ $this->name] ) ) {67 if ( empty( $_COOKIE[ RECOVERY_MODE_COOKIE ] ) ) { 131 68 return new WP_Error( 'no_cookie', __( 'No cookie present.' ) ); 132 69 } 133 70 134 $cookie = $_COOKIE[ $this->name];71 $cookie = $_COOKIE[ RECOVERY_MODE_COOKIE ]; 135 72 } 136 73 … … 183 120 public function get_session_id_from_cookie( $cookie = '' ) { 184 121 if ( ! $cookie ) { 185 if ( empty( $_COOKIE[ $this->name] ) ) {122 if ( empty( $_COOKIE[ RECOVERY_MODE_COOKIE ] ) ) { 186 123 return new WP_Error( 'no_cookie', __( 'No cookie present.' ) ); 187 124 } 188 125 189 $cookie = $_COOKIE[ $this->name];126 $cookie = $_COOKIE[ RECOVERY_MODE_COOKIE ]; 190 127 } 191 128
Note: See TracChangeset
for help on using the changeset viewer.