File Editor
Directories:
.. (Back)
3rd-party
_inc
css
extensions
images
jetpack_vendor
json-endpoints
modules
sal
src
vendor
views
Files:
LICENSE.txt
class-jetpack-connection-status.php
class-jetpack-connection-widget.php
class-jetpack-gallery-settings.php
class-jetpack-pre-connection-jitms.php
class-jetpack-recommendations-banner.php
class-jetpack-stats-dashboard-widget.php
class-jetpack-wizard-banner.php
class-jetpack-xmlrpc-methods.php
class.frame-nonce-preview.php
class.jetpack-admin.php
class.jetpack-affiliate.php
class.jetpack-autoupdate.php
class.jetpack-bbpress-json-api.compat.php
class.jetpack-boost-modules.php
class.jetpack-cli.php
class.jetpack-client-server.php
class.jetpack-connection-banner.php
class.jetpack-data.php
class.jetpack-gutenberg.php
class.jetpack-heartbeat.php
class.jetpack-idc.php
class.jetpack-modules-list-table.php
class.jetpack-network-sites-list-table.php
class.jetpack-network.php
class.jetpack-plan.php
class.jetpack-post-images.php
class.jetpack-twitter-cards.php
class.jetpack-user-agent.php
class.jetpack.php
class.json-api-endpoints.php
class.json-api.php
class.photon.php
enhanced-open-graph.php
functions.compat.php
functions.cookies.php
functions.global.php
functions.is-mobile.php
functions.opengraph.php
functions.photon.php
jetpack.php
json-api-config.php
json-endpoints.php
load-jetpack.php
locales.php
readme.txt
uninstall.php
Create New File
Create
Edit File: functions.cookies.php
<?php // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase /** * This file is meant to be the home for any function handling cookies that can * be accessed anywhere within Jetpack. * * This file is loaded whether or not Jetpack is connected to WP.com. * * @package automattic/jetpack */ /** * A PHP 5.X compatible version of the array argument version of PHP 7.3's setcookie(). * * Useful for setting SameSite cookies in PHP 7.2 or earlier. * * @param string $name Name of the cookie. * @param string $value Value of the cookie. * @param array $options Options to include with the cookie. * @return bool False when error happens, other wise true. */ function jetpack_shim_setcookie( $name, $value, $options ) { $not_allowed_chars = ",; \t\r\n\013\014"; if ( false !== strpbrk( $name, $not_allowed_chars ) ) { return false; } if ( headers_sent() ) { return false; } $cookie = 'Set-Cookie: ' . $name . '=' . rawurlencode( $value ) . '; '; if ( ! empty( $options['expires'] ) ) { $cookie_date = gmdate( 'D, d M Y H:i:s \G\M\T', $options['expires'] ); $cookie .= sprintf( 'expires=%s', $cookie_date ) . ';'; } if ( ! empty( $options['secure'] ) && true === $options['secure'] ) { $cookie .= 'secure; '; } if ( ! empty( $options['httponly'] ) && true === $options['httponly'] ) { $cookie .= 'HttpOnly; '; } if ( ! empty( $options['domain'] ) && is_string( $options['domain'] ) ) { if ( false !== strpbrk( $options['domain'], $not_allowed_chars ) ) { return false; } $cookie .= sprintf( 'domain=%s', $options['domain'] . '; ' ); } if ( ! empty( $options['path'] ) && is_string( $options['path'] ) ) { if ( false !== strpbrk( $options['path'], $not_allowed_chars ) ) { return false; } $cookie .= sprintf( 'path=%s', $options['path'] . '; ' ); } if ( ! empty( $options['samesite'] ) && is_string( $options['samesite'] ) ) { $cookie .= sprintf( 'SameSite=%s', $options['samesite'] . '; ' ); } $cookie = trim( $cookie ); $cookie = trim( $cookie, ';' ); header( $cookie, false ); return true; }
Save Changes
Rename File
Rename