61 } |
61 } |
62 |
62 |
63 /** |
63 /** |
64 * Checks whether HTTPS is supported for the server and domain. |
64 * Checks whether HTTPS is supported for the server and domain. |
65 * |
65 * |
|
66 * This function makes an HTTP request through `wp_get_https_detection_errors()` |
|
67 * to check for HTTPS support. As this process can be resource-intensive, |
|
68 * it should be used cautiously, especially in performance-sensitive environments, |
|
69 * to avoid potential latency issues. |
|
70 * |
66 * @since 5.7.0 |
71 * @since 5.7.0 |
67 * |
72 * |
68 * @return bool True if HTTPS is supported, false otherwise. |
73 * @return bool True if HTTPS is supported, false otherwise. |
69 */ |
74 */ |
70 function wp_is_https_supported() { |
75 function wp_is_https_supported() { |
71 $https_detection_errors = get_option( 'https_detection_errors' ); |
76 $https_detection_errors = wp_get_https_detection_errors(); |
72 |
77 |
73 // If option has never been set by the Cron hook before, run it on-the-fly as fallback. |
78 // If there are errors, HTTPS is not supported. |
74 if ( false === $https_detection_errors ) { |
|
75 wp_update_https_detection_errors(); |
|
76 |
|
77 $https_detection_errors = get_option( 'https_detection_errors' ); |
|
78 } |
|
79 |
|
80 // If there are no detection errors, HTTPS is supported. |
|
81 return empty( $https_detection_errors ); |
79 return empty( $https_detection_errors ); |
82 } |
80 } |
83 |
81 |
84 /** |
82 /** |
85 * Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors. |
83 * Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors. |
86 * |
84 * |
87 * This internal function is called by a regular Cron hook to ensure HTTPS support is detected and maintained. |
85 * This function checks for HTTPS support by making an HTTP request. As this process can be resource-intensive, |
|
86 * it should be used cautiously, especially in performance-sensitive environments. |
|
87 * It is called when HTTPS support needs to be validated. |
88 * |
88 * |
89 * @since 6.4.0 |
89 * @since 6.4.0 |
90 * @access private |
90 * @access private |
|
91 * |
|
92 * @return array An array containing potential detection errors related to HTTPS, or an empty array if no errors are found. |
91 */ |
93 */ |
92 function wp_get_https_detection_errors() { |
94 function wp_get_https_detection_errors() { |
93 /** |
95 /** |
94 * Short-circuits the process of detecting errors related to HTTPS support. |
96 * Short-circuits the process of detecting errors related to HTTPS support. |
95 * |
97 * |
98 * |
100 * |
99 * @since 6.4.0 |
101 * @since 6.4.0 |
100 * |
102 * |
101 * @param null|WP_Error $pre Error object to short-circuit detection, |
103 * @param null|WP_Error $pre Error object to short-circuit detection, |
102 * or null to continue with the default behavior. |
104 * or null to continue with the default behavior. |
103 * @return null|WP_Error Error object if HTTPS detection errors are found, null otherwise. |
|
104 */ |
105 */ |
105 $support_errors = apply_filters( 'pre_wp_get_https_detection_errors', null ); |
106 $support_errors = apply_filters( 'pre_wp_get_https_detection_errors', null ); |
106 if ( is_wp_error( $support_errors ) ) { |
107 if ( is_wp_error( $support_errors ) ) { |
107 return $support_errors->errors; |
108 return $support_errors->errors; |
108 } |
109 } |