PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.12.3
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.12.3
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / libraries / wp-session / wp-session.php

wp-session.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.12.3, at includes/libraries/wp-session/wp-session.php

166 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * WordPress session managment.
10 *
11 * Standardizes WordPress session data and uses either database transients or in-memory caching
12 * for storing user session information.
13 *
14 * @package WordPress
15 * @subpackage Session
16 * @since 3.7.0
17 */
18
19 /**
20 * Return the current cache expire setting.
21 *
22 * @return int
23 */
24 function wp_session_cache_expire() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- This is a bundled library function. Changing it would break existing functionality.
25 $wp_session = WP_Session::get_instance();
26
27 return $wp_session->cache_expiration();
28 }
29
30 /**
31 * Alias of wp_session_write_close()
32 */
33 function wp_session_commit() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- This is a bundled library function. Changing it would break existing functionality.
34 wp_session_write_close();
35 }
36
37 /**
38 * Load a JSON-encoded string into the current session.
39 *
40 * @param string $data
41 */
42 function wp_session_decode( $data ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- This is a bundled library function. Changing it would break existing functionality.
43 $wp_session = WP_Session::get_instance();
44
45 return $wp_session->json_in( $data );
46 }
47
48 /**
49 * Encode the current session's data as a JSON string.
50 *
51 * @return string
52 */
53 function wp_session_encode() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- This is a bundled library function. Changing it would break existing functionality.
54 $wp_session = WP_Session::get_instance();
55
56 return $wp_session->json_out();
57 }
58
59 /**
60 * Regenerate the session ID.
61 *
62 * @param bool $delete_old_session
63 *
64 * @return bool
65 */
66 function wp_session_regenerate_id( $delete_old_session = false ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- This is a bundled library function. Changing it would break existing functionality.
67 $wp_session = WP_Session::get_instance();
68
69 $wp_session->regenerate_id( $delete_old_session );
70
71 return true;
72 }
73
74 /**
75 * Start new or resume existing session.
76 *
77 * Resumes an existing session based on a value sent by the _wp_session cookie.
78 *
79 * @return bool
80 */
81 function wp_session_start() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- This is a bundled library function. Changing it would break existing functionality.
82 $wp_session = WP_Session::get_instance();
83 do_action( 'wp_session_start' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- This is a bundled library hook. Changing it would break existing functionality.
84
85 return $wp_session->session_started();
86 }
87 if ( ! defined( 'WP_CLI' ) || false === WP_CLI ) {
88 add_action( 'plugins_loaded', 'wp_session_start' );
89 }
90
91 /**
92 * Return the current session status.
93 *
94 * @return int
95 */
96 function wp_session_status() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- This is a bundled library function. Changing it would break existing functionality.
97 $wp_session = WP_Session::get_instance();
98
99 if ( $wp_session->session_started() ) {
100 return PHP_SESSION_ACTIVE;
101 }
102
103 return PHP_SESSION_NONE;
104 }
105
106 /**
107 * Unset all session variables.
108 */
109 function wp_session_unset() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- This is a bundled library function. Changing it would break existing functionality.
110 $wp_session = WP_Session::get_instance();
111
112 $wp_session->reset();
113 }
114
115 /**
116 * Write session data and end session
117 */
118 function wp_session_write_close() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- This is a bundled library function. Changing it would break existing functionality.
119 $wp_session = WP_Session::get_instance();
120
121 $wp_session->write_data();
122 do_action( 'wp_session_commit' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- This is a bundled library hook. Changing it would break existing functionality.
123 }
124 if ( ! defined( 'WP_CLI' ) || false === WP_CLI ) {
125 add_action( 'shutdown', 'wp_session_write_close' );
126 }
127
128 /**
129 * Clean up expired sessions by removing data and their expiration entries from
130 * the WordPress options table.
131 *
132 * This method should never be called directly and should instead be triggered as part
133 * of a scheduled task or cron job.
134 */
135 function wp_session_cleanup() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- This is a bundled library function. Changing it would break existing functionality.
136 if ( defined( 'WP_SETUP_CONFIG' ) ) {
137 return;
138 }
139
140 if ( ! defined( 'WP_INSTALLING' ) ) {
141 /**
142 * Determine the size of each batch for deletion.
143 *
144 * @param int
145 */
146 $batch_size = apply_filters( 'wp_session_delete_batch_size', 1000 ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- This is a bundled library hook. Changing it would break existing functionality.
147
148 // Delete a batch of old sessions
149 WP_Session_Utils::delete_old_sessions( $batch_size );
150 }
151
152 // Allow other plugins to hook in to the garbage collection process.
153 do_action( 'wp_session_cleanup' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- This is a bundled library hook. Changing it would break existing functionality.
154 }
155 add_action( 'wp_session_garbage_collection', 'wp_session_cleanup' );
156
157 /**
158 * Register the garbage collector as a twice daily event.
159 */
160 function wp_session_register_garbage_collection() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- This is a bundled library function. Changing it would break existing functionality.
161 if ( ! wp_next_scheduled( 'wp_session_garbage_collection' ) ) {
162 wp_schedule_event( time(), 'hourly', 'wp_session_garbage_collection' );
163 }
164 }
165 add_action( 'wp', 'wp_session_register_garbage_collection' );
166