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