feat(02-02): create login/registration page with responsive layout

- Add create_login_page() method to DDHH_JM_Pages class
- Combined view with registration form (Formidable shortcode) and login form (wp_login_form)
- German headings: "Neu registrieren" and "Bereits registriert?"
- Responsive two-column layout (desktop) with flexbox
- Stacked layout on mobile (< 768px)
- Inline CSS styling for visual separation and consistency
- Background colors and borders for section distinction
- Page accessible at /anbieter-login/
- Duplicate prevention: checks for existing page by slug

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-14 19:25:51 +09:00
parent 5a4b877bc9
commit dcfe79a727

View File

@@ -21,6 +21,9 @@ class DDHH_JM_Pages {
public static function create_provider_pages() {
// Create Anbieter Dashboard page
self::create_dashboard_page();
// Create Anbieter Login page
self::create_login_page();
}
/**
@@ -52,4 +55,133 @@ class DDHH_JM_Pages {
update_option( 'ddhh_jm_dashboard_page_id', $page_id );
}
}
/**
* Create login/registration page
*/
private static function create_login_page() {
// Check if page already exists by slug
$existing_page = get_page_by_path( 'anbieter-login' );
if ( $existing_page ) {
// Page already exists, store ID if not stored
$stored_page_id = get_option( 'ddhh_jm_login_page_id' );
if ( ! $stored_page_id ) {
update_option( 'ddhh_jm_login_page_id', $existing_page->ID );
}
return;
}
// Get registration form ID
$registration_form_id = DDHH_JM_Formidable::get_registration_form_id();
// Build page content with inline CSS and two sections
$content = '<style>
.ddhh-auth-container {
display: flex;
gap: 2rem;
margin: 2rem 0;
}
.ddhh-register-section,
.ddhh-login-section {
flex: 1;
padding: 2rem;
background: #f9f9f9;
border-radius: 8px;
border: 1px solid #e0e0e0;
}
.ddhh-register-section h2,
.ddhh-login-section h2 {
margin-top: 0;
margin-bottom: 1.5rem;
color: #333;
font-size: 1.5rem;
}
/* Mobile responsive - stacked layout */
@media (max-width: 768px) {
.ddhh-auth-container {
flex-direction: column;
}
}
/* Form styling for consistency */
.ddhh-auth-container input[type="text"],
.ddhh-auth-container input[type="email"],
.ddhh-auth-container input[type="password"] {
width: 100%;
padding: 0.75rem;
margin-bottom: 1rem;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.ddhh-auth-container input[type="submit"],
.ddhh-auth-container button[type="submit"] {
background: #0073aa;
color: white;
padding: 0.75rem 1.5rem;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
}
.ddhh-auth-container input[type="submit"]:hover,
.ddhh-auth-container button[type="submit"]:hover {
background: #005a87;
}
</style>';
$content .= '<div class="ddhh-auth-container">';
// Registration section
$content .= '<div class="ddhh-register-section">';
$content .= '<h2>Neu registrieren</h2>';
if ( $registration_form_id ) {
$content .= '[formidable id=' . $registration_form_id . ']';
} else {
$content .= '<p>Registrierungsformular wird geladen...</p>';
}
$content .= '</div>';
// Login section
$content .= '<div class="ddhh-login-section">';
$content .= '<h2>Bereits registriert?</h2>';
// Build wp_login_form args for German labels
$login_args = array(
'echo' => false,
'redirect' => home_url( '/anbieter-dashboard/' ),
'label_username' => 'E-Mail oder Benutzername',
'label_password' => 'Passwort',
'label_remember' => 'Angemeldet bleiben',
'label_log_in' => 'Anmelden',
);
$content .= wp_login_form( $login_args );
$content .= '</div>';
$content .= '</div>'; // .ddhh-auth-container
// Create the login/registration page
$page_data = array(
'post_title' => 'Anbieter Login',
'post_name' => 'anbieter-login',
'post_content' => $content,
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1, // Admin user
);
$page_id = wp_insert_post( $page_data );
if ( $page_id && ! is_wp_error( $page_id ) ) {
// Store page ID in options
update_option( 'ddhh_jm_login_page_id', $page_id );
}
}
}