Add woocommerce form locations
Validate Build / validate-build (push) Failing after 27s

This commit is contained in:
Cooper Dalrymple
2026-06-04 17:50:11 -05:00
parent 1130a6d00f
commit edf9804cdb
6 changed files with 257 additions and 3 deletions
+49 -2
View File
@@ -28,6 +28,11 @@ final class Settings {
public const LOCATION_COMMENT_FORM = 'comment_form';
public const LOCATION_POST_PASSWORD_FORM = 'post_password_form';
public const LOCATION_WC_LOGIN = 'wc_login';
public const LOCATION_WC_LOST_PASSWORD = 'wc_lost_password';
public const LOCATION_WC_REGISTER = 'wc_register';
public const LOCATION_WC_CHECKOUT = 'wc_checkout';
protected function __construct() {
add_action('admin_menu', [$this, 'menu']);
add_action('admin_init', [$this, 'init']);
@@ -70,7 +75,14 @@ final class Settings {
}
public static function get_form_locations():array {
return (array) self::get('form_locations');
$form_locations = (array) self::get('form_locations');
if (Plugin::is_woocommerce_active()) {
$form_locations = array_merge(
$form_locations,
(array) self::get('wc_form_locations')
);
}
return $form_locations;
}
public static function is_form_location_enabled(string $name):bool {
@@ -101,6 +113,22 @@ final class Settings {
return self::is_form_location_enabled(self::LOCATION_POST_PASSWORD_FORM);
}
public static function is_wc_login_enabled():bool {
return self::is_form_location_enabled(self::LOCATION_WC_LOGIN);
}
public static function is_wc_lost_password_enabled():bool {
return self::is_form_location_enabled(self::LOCATION_WC_LOST_PASSWORD);
}
public static function is_wc_register_enabled():bool {
return self::is_form_location_enabled(self::LOCATION_WC_REGISTER);
}
public static function is_wc_checkout_enabled():bool {
return self::is_form_location_enabled(self::LOCATION_WC_CHECKOUT);
}
public function menu() {
if (!current_user_can(self::CAPABILITY)) return;
add_options_page(
@@ -176,7 +204,7 @@ final class Settings {
add_settings_field(
Plugin::get_id() . '_form_locations',
Plugin::__('Form locations'),
Plugin::__('WordPress form locations'),
[$this, 'checkbox_field'],
Plugin::get_id(),
'forms',
@@ -193,6 +221,25 @@ final class Settings {
'description' => Plugin::__('Custom login form requires login page to also be enabled.'),
]
);
if (Plugin::is_woocommerce_active()) {
add_settings_field(
Plugin::get_id() . '_wc_form_locations',
Plugin::__('WooCommerce form locations'),
[$this, 'checkbox_field'],
Plugin::get_id(),
'forms',
[
'name' => 'wc_form_locations',
'options' => [
self::LOCATION_WC_LOGIN => Plugin::__('Login form'),
self::LOCATION_WC_LOST_PASSWORD => Plugin::__('Lost password form'),
self::LOCATION_WC_REGISTER => Plugin::__('Register form'),
self::LOCATION_WC_CHECKOUT => Plugin::__('Checkout form'),
],
]
);
}
}
public function page() {