feat(01-03): register ACF field group for job_offer metadata
- Add DDHH_JM_ACF_Fields class with register_fields() method - Field group 'Job Details' for post_type job_offer - 6 fields: job_location (text, required), job_type (select, required), job_deadline (date_picker), job_contact_email (email, required), job_logo (image), job_deactivation_reason (textarea, conditional) - German labels: Standort, Art, Bewerbungsfrist, Kontakt-E-Mail, Logo - Logo returns ID for media library integration - Deactivation reason field shows only when status != publish - Hooked to 'acf/init' action
This commit is contained in:
115
includes/class-acf-fields.php
Normal file
115
includes/class-acf-fields.php
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ACF field groups handler
|
||||||
|
*
|
||||||
|
* @package DDHH_Job_Manager
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles ACF field group registration
|
||||||
|
*/
|
||||||
|
class DDHH_JM_ACF_Fields {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register ACF field groups
|
||||||
|
* Hooked to 'acf/init'
|
||||||
|
*/
|
||||||
|
public static function register_fields() {
|
||||||
|
// Check if ACF Pro is available
|
||||||
|
if ( ! function_exists( 'acf_add_local_field_group' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register Job Details field group
|
||||||
|
acf_add_local_field_group(
|
||||||
|
array(
|
||||||
|
'key' => 'group_job_details',
|
||||||
|
'title' => __( 'Job Details', 'ddhh-job-manager' ),
|
||||||
|
'fields' => array(
|
||||||
|
// Job Location
|
||||||
|
array(
|
||||||
|
'key' => 'field_job_location',
|
||||||
|
'label' => __( 'Standort', 'ddhh-job-manager' ),
|
||||||
|
'name' => 'job_location',
|
||||||
|
'type' => 'text',
|
||||||
|
'required' => 1,
|
||||||
|
),
|
||||||
|
// Job Type
|
||||||
|
array(
|
||||||
|
'key' => 'field_job_type',
|
||||||
|
'label' => __( 'Art', 'ddhh-job-manager' ),
|
||||||
|
'name' => 'job_type',
|
||||||
|
'type' => 'select',
|
||||||
|
'required' => 1,
|
||||||
|
'choices' => array(
|
||||||
|
'vollzeit' => __( 'Vollzeit', 'ddhh-job-manager' ),
|
||||||
|
'teilzeit' => __( 'Teilzeit', 'ddhh-job-manager' ),
|
||||||
|
'ehrenamt' => __( 'Ehrenamt', 'ddhh-job-manager' ),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Job Deadline
|
||||||
|
array(
|
||||||
|
'key' => 'field_job_deadline',
|
||||||
|
'label' => __( 'Bewerbungsfrist', 'ddhh-job-manager' ),
|
||||||
|
'name' => 'job_deadline',
|
||||||
|
'type' => 'date_picker',
|
||||||
|
'required' => 0,
|
||||||
|
'return_format' => 'Y-m-d',
|
||||||
|
'display_format' => 'd.m.Y',
|
||||||
|
),
|
||||||
|
// Job Contact Email
|
||||||
|
array(
|
||||||
|
'key' => 'field_job_contact_email',
|
||||||
|
'label' => __( 'Kontakt-E-Mail', 'ddhh-job-manager' ),
|
||||||
|
'name' => 'job_contact_email',
|
||||||
|
'type' => 'email',
|
||||||
|
'required' => 1,
|
||||||
|
),
|
||||||
|
// Job Logo
|
||||||
|
array(
|
||||||
|
'key' => 'field_job_logo',
|
||||||
|
'label' => __( 'Logo', 'ddhh-job-manager' ),
|
||||||
|
'name' => 'job_logo',
|
||||||
|
'type' => 'image',
|
||||||
|
'required' => 0,
|
||||||
|
'return_format' => 'id',
|
||||||
|
'preview_size' => 'thumbnail',
|
||||||
|
'library' => 'all',
|
||||||
|
),
|
||||||
|
// Job Deactivation Reason (internal, admin-only)
|
||||||
|
array(
|
||||||
|
'key' => 'field_job_deactivation_reason',
|
||||||
|
'label' => __( 'Deaktivierungsgrund (intern)', 'ddhh-job-manager' ),
|
||||||
|
'name' => 'job_deactivation_reason',
|
||||||
|
'type' => 'textarea',
|
||||||
|
'required' => 0,
|
||||||
|
'rows' => 3,
|
||||||
|
'conditional_logic' => array(
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'field' => 'post_status',
|
||||||
|
'operator' => '!=',
|
||||||
|
'value' => 'publish',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'location' => array(
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'param' => 'post_type',
|
||||||
|
'operator' => '==',
|
||||||
|
'value' => 'job_offer',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'position' => 'normal',
|
||||||
|
'style' => 'default',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,5 +49,8 @@ class DDHH_JM_Job_Manager {
|
|||||||
|
|
||||||
// Initialize post types
|
// Initialize post types
|
||||||
add_action( 'init', array( 'DDHH_JM_Post_Types', 'register' ) );
|
add_action( 'init', array( 'DDHH_JM_Post_Types', 'register' ) );
|
||||||
|
|
||||||
|
// Initialize ACF fields
|
||||||
|
add_action( 'acf/init', array( 'DDHH_JM_ACF_Fields', 'register_fields' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user