feat(04-01): add deactivate action to provider dashboard
Add deactivate mode detection alongside existing edit mode checking for action=deactivate_job and job_id parameter. When in deactivate mode, render deactivation form section similar to edit section structure with heading "Stellenangebot deaktivieren", back link to dashboard, and form shortcode with id_param={job_id}. In job listings table, add "Deaktivieren" button in Actions column only for published jobs (status === 'publish'). Deactivate button uses warning/destructive color (red background) to differentiate from edit/view buttons. Follow same conditional rendering pattern as edit mode showing deactivation form OR listings, not both.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,9 @@ if ( ! in_array( 'ddhh_provider', $current_user->roles, true ) ) {
|
|||||||
// Check if we're in edit mode
|
// Check if we're in edit mode
|
||||||
$is_edit_mode = isset( $_GET['action'] ) && $_GET['action'] === 'edit_job' && isset( $_GET['job_id'] );
|
$is_edit_mode = isset( $_GET['action'] ) && $_GET['action'] === 'edit_job' && isset( $_GET['job_id'] );
|
||||||
|
|
||||||
|
// Check if we're in deactivate mode
|
||||||
|
$is_deactivate_mode = isset( $_GET['action'] ) && $_GET['action'] === 'deactivate_job' && isset( $_GET['job_id'] );
|
||||||
|
|
||||||
if ( $is_edit_mode ) {
|
if ( $is_edit_mode ) {
|
||||||
$job_id = absint( $_GET['job_id'] );
|
$job_id = absint( $_GET['job_id'] );
|
||||||
$form_id = DDHH_JM_Formidable::get_job_edit_form_id();
|
$form_id = DDHH_JM_Formidable::get_job_edit_form_id();
|
||||||
@@ -47,6 +50,24 @@ if ( $is_edit_mode ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $is_deactivate_mode ) {
|
||||||
|
$job_id = absint( $_GET['job_id'] );
|
||||||
|
$form_id = DDHH_JM_Formidable::get_job_deactivation_form_id();
|
||||||
|
|
||||||
|
if ( $form_id ) {
|
||||||
|
?>
|
||||||
|
<div class="ddhh-provider-dashboard">
|
||||||
|
<div class="ddhh-job-deactivate-section">
|
||||||
|
<h2>Stellenangebot deaktivieren</h2>
|
||||||
|
<p><a href="<?php echo esc_url( get_permalink() ); ?>" class="back-to-dashboard">← Zurück zur Übersicht</a></p>
|
||||||
|
<?php echo do_shortcode( "[formidable id={$form_id} id_param={$job_id}]" ); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Query current user's job_offer posts
|
// Query current user's job_offer posts
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'job_offer',
|
'post_type' => 'job_offer',
|
||||||
@@ -130,6 +151,18 @@ $job_query = new WP_Query( $args );
|
|||||||
if ( 'publish' === $post_status ) {
|
if ( 'publish' === $post_status ) {
|
||||||
echo ' <a href="' . esc_url( get_permalink( $post_id ) ) . '" class="button view-link" target="_blank">Ansehen</a>';
|
echo ' <a href="' . esc_url( get_permalink( $post_id ) ) . '" class="button view-link" target="_blank">Ansehen</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deactivate link - only for published posts
|
||||||
|
if ( 'publish' === $post_status ) {
|
||||||
|
$deactivate_url = add_query_arg(
|
||||||
|
array(
|
||||||
|
'action' => 'deactivate_job',
|
||||||
|
'job_id' => $post_id,
|
||||||
|
),
|
||||||
|
get_permalink()
|
||||||
|
);
|
||||||
|
echo ' <a href="' . esc_url( $deactivate_url ) . '" class="button deactivate-link">Deaktivieren</a>';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -167,14 +200,16 @@ $job_query = new WP_Query( $args );
|
|||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ddhh-job-edit-section {
|
.ddhh-job-edit-section,
|
||||||
|
.ddhh-job-deactivate-section {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.ddhh-job-edit-section h2 {
|
.ddhh-job-edit-section h2,
|
||||||
|
.ddhh-job-deactivate-section h2 {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
@@ -291,6 +326,15 @@ $job_query = new WP_Query( $args );
|
|||||||
background-color: #059669;
|
background-color: #059669;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.deactivate-link {
|
||||||
|
background-color: #ef4444;
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deactivate-link:hover {
|
||||||
|
background-color: #dc2626;
|
||||||
|
}
|
||||||
|
|
||||||
.ddhh-empty-state,
|
.ddhh-empty-state,
|
||||||
.ddhh-error-message {
|
.ddhh-error-message {
|
||||||
padding: 3rem;
|
padding: 3rem;
|
||||||
|
|||||||
Reference in New Issue
Block a user