← All changes
|
includes/endpoints/class-charitable-reset-password-endpoint.php
+49
-24
1.6.6
→
1.8.13
View file →
| @@ -1,17 +1,19 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * reset_password endpoint. | |
| 3 | + * Password reset endpoint. | |
| 4 | 4 | * |
| 5 | 5 | * @package Charitable/Classes/Charitable_Reset_Password_Endpoint |
| 6 | - * @author Eric Daams | |
| 7 | - * @copyright Copyright (c) 2018, Studio 164a | |
| 6 | + * @author David Bisset | |
| 7 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 9 | * @since 1.5.0 |
| 10 | - * @version 1.5.4 | |
| 10 | + * @version 1.6.55 | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; | |
| 15 | +} | |
| 14 | 16 | |
| 15 | 17 | if ( ! class_exists( 'Charitable_Reset_Password_Endpoint' ) ) : |
| 16 | 18 | |
| 17 | 19 | /** |
| @@ -20,9 +22,9 @@ | ||
| 20 | 22 | * @since 1.5.0 |
| 21 | 23 | */ |
| 22 | 24 | class Charitable_Reset_Password_Endpoint extends Charitable_Endpoint { |
| 23 | 25 | |
| 24 | - /* @var string */ | |
| 26 | + /** Endpoint ID. */ | |
| 25 | 27 | const ID = 'reset_password'; |
| 26 | 28 | |
| 27 | 29 | /** |
| 28 | 30 | * Object instantiation. |
| @@ -90,9 +92,9 @@ | ||
| 90 | 92 | } |
| 91 | 93 | |
| 92 | 94 | /** |
| 93 | 95 | * Return whether we are currently viewing the endpoint. |
| 94 | - * | |
| 96 | + * | |
| 95 | 97 | * @since 1.5.0 |
| 96 | 98 | * |
| 97 | 99 | * @global WP_Query $wp_query |
| 98 | 100 | * @param array $args Mixed set of arguments. |
| @@ -101,9 +103,9 @@ | ||
| 101 | 103 | public function is_page( $args = array() ) { |
| 102 | 104 | global $wp_query; |
| 103 | 105 | |
| 104 | 106 | $login_page = charitable_get_option( 'login_page', 'wp' ); |
| 105 | - | |
| 107 | + | |
| 106 | 108 | if ( 'wp' == $login_page ) { |
| 107 | 109 | return false; |
| 108 | 110 | } |
| 109 | 111 | |
| @@ -111,28 +113,48 @@ | ||
| 111 | 113 | && array_key_exists( 'reset_password', $wp_query->query_vars ); |
| 112 | 114 | } |
| 113 | 115 | |
| 114 | 116 | /** |
| 117 | + * Whether the endpoint uses a custom template. | |
| 118 | + * | |
| 119 | + * @since 1.6.55 | |
| 120 | + * | |
| 121 | + * @return boolean | |
| 122 | + */ | |
| 123 | + public function uses_custom_template() { | |
| 124 | + return ! charitable_is_block_theme() && 'wp' !== charitable_get_option( 'login_page', 'wp' ); | |
| 125 | + } | |
| 126 | + | |
| 127 | + /** | |
| 128 | + * Prepare the template for the endpoint. | |
| 129 | + * | |
| 130 | + * @since 1.6.55 | |
| 131 | + * | |
| 132 | + * @return void | |
| 133 | + */ | |
| 134 | + public function setup_template() { | |
| 135 | + new Charitable_Ghost_Page( | |
| 136 | + 'reset-password-page', | |
| 137 | + array( | |
| 138 | + 'title' => __( 'Reset Password', 'charitable' ), | |
| 139 | + 'content' => '<!-- Silence is golden -->', | |
| 140 | + ) | |
| 141 | + ); | |
| 142 | + } | |
| 143 | + | |
| 144 | + /** | |
| 115 | 145 | * Return the template to display for this endpoint. |
| 116 | 146 | * |
| 117 | 147 | * @since 1.5.0 |
| 118 | 148 | * |
| 119 | 149 | * @param string $template The default template. |
| 120 | - * @return string | |
| 150 | + * @return array | |
| 121 | 151 | */ |
| 122 | 152 | public function get_template( $template ) { |
| 123 | - $login = charitable_get_option( 'login_page', 'wp' ); | |
| 124 | - | |
| 125 | - if ( 'wp' == $login ) { | |
| 126 | - return $template; | |
| 127 | - } | |
| 128 | - | |
| 129 | - new Charitable_Ghost_Page( 'reset-password-page', array( | |
| 130 | - 'title' => __( 'Reset Password', 'charitable' ), | |
| 131 | - 'content' => '<!-- Silence is golden -->', | |
| 132 | - ) ); | |
| 133 | - | |
| 134 | - return charitable_splice_template( get_page_template_slug( $login ), array( 'reset-password-page.php', 'page.php', 'index.php' ) ); | |
| 153 | + return charitable_splice_template( | |
| 154 | + get_page_template_slug( charitable_get_option( 'login_page', 'wp' ) ), | |
| 155 | + array( 'reset-password-page.php', 'page.php', 'singular.php', 'index.php' ) | |
| 156 | + ); | |
| 135 | 157 | } |
| 136 | 158 | |
| 137 | 159 | /** |
| 138 | 160 | * Get the content to display for the endpoint. |
| @@ -144,11 +166,14 @@ | ||
| 144 | 166 | */ |
| 145 | 167 | public function get_content( $content ) { |
| 146 | 168 | ob_start(); |
| 147 | 169 | |
| 148 | - charitable_template( 'account/reset-password.php', array( | |
| 149 | - 'form' => new Charitable_Reset_Password_Form(), | |
| 150 | - ) ); | |
| 170 | + charitable_template( | |
| 171 | + 'account/reset-password.php', | |
| 172 | + array( | |
| 173 | + 'form' => new Charitable_Reset_Password_Form(), | |
| 174 | + ) | |
| 175 | + ); | |
| 151 | 176 | |
| 152 | 177 | return ob_get_clean(); |
| 153 | 178 | } |
| 154 | 179 | } |