From f0de02ca94217b7265dea7173ce4d3dd5951dee8 Mon Sep 17 00:00:00 2001 From: Viktor Miller Date: Wed, 4 Feb 2026 12:46:44 +0900 Subject: [PATCH] feat: register custom Elementor dynamic tags for job offer fields Adds a "Stellenangebot" group to Elementor's dynamic tags dropdown with tags for Standort, Art, Bewerbungsfrist, Kontakt-E-Mail (text), and Logo (image). This removes the dependency on Elementor Pro's ACF module for displaying job offer fields in templates and loop items. Co-Authored-By: Claude Opus 4.5 --- ddhh-job-manager.php | 9 +++ includes/class-elementor-tags.php | 58 +++++++++++++++++ .../class-tag-job-contact-email.php | 38 +++++++++++ .../elementor-tags/class-tag-job-deadline.php | 44 +++++++++++++ .../elementor-tags/class-tag-job-location.php | 32 ++++++++++ .../elementor-tags/class-tag-job-logo.php | 64 +++++++++++++++++++ .../elementor-tags/class-tag-job-type.php | 41 ++++++++++++ 7 files changed, 286 insertions(+) create mode 100644 includes/class-elementor-tags.php create mode 100644 includes/elementor-tags/class-tag-job-contact-email.php create mode 100644 includes/elementor-tags/class-tag-job-deadline.php create mode 100644 includes/elementor-tags/class-tag-job-location.php create mode 100644 includes/elementor-tags/class-tag-job-logo.php create mode 100644 includes/elementor-tags/class-tag-job-type.php diff --git a/ddhh-job-manager.php b/ddhh-job-manager.php index 7e73a63..9dd40d5 100644 --- a/ddhh-job-manager.php +++ b/ddhh-job-manager.php @@ -45,6 +45,7 @@ require_once DDHH_JM_PLUGIN_DIR . 'includes/class-template.php'; require_once DDHH_JM_PLUGIN_DIR . 'includes/class-admin-ui.php'; require_once DDHH_JM_PLUGIN_DIR . 'includes/class-user-preferences.php'; require_once DDHH_JM_PLUGIN_DIR . 'includes/class-scheduler.php'; +require_once DDHH_JM_PLUGIN_DIR . 'includes/class-elementor-tags.php'; require_once DDHH_JM_PLUGIN_DIR . 'includes/class-ddhh-job-manager.php'; // Register activation and deactivation hooks (must be at top level). @@ -58,3 +59,11 @@ function ddhh_jm_init() { DDHH_JM_Job_Manager::get_instance(); } add_action( 'plugins_loaded', 'ddhh_jm_init', 10 ); + +/** + * Initialize Elementor dynamic tags when Elementor is loaded. + */ +function ddhh_jm_elementor_init() { + DDHH_JM_Elementor_Tags::init(); +} +add_action( 'elementor/init', 'ddhh_jm_elementor_init' ); diff --git a/includes/class-elementor-tags.php b/includes/class-elementor-tags.php new file mode 100644 index 0000000..c6b07d1 --- /dev/null +++ b/includes/class-elementor-tags.php @@ -0,0 +1,58 @@ +register_group( + self::GROUP_SLUG, + array( + 'title' => 'Stellenangebot', + ) + ); + + $tag_dir = DDHH_JM_PLUGIN_DIR . 'includes/elementor-tags/'; + + require_once $tag_dir . 'class-tag-job-location.php'; + require_once $tag_dir . 'class-tag-job-type.php'; + require_once $tag_dir . 'class-tag-job-deadline.php'; + require_once $tag_dir . 'class-tag-job-contact-email.php'; + require_once $tag_dir . 'class-tag-job-logo.php'; + + $manager->register( new DDHH_JM_Tag_Job_Location() ); + $manager->register( new DDHH_JM_Tag_Job_Type() ); + $manager->register( new DDHH_JM_Tag_Job_Deadline() ); + $manager->register( new DDHH_JM_Tag_Job_Contact_Email() ); + $manager->register( new DDHH_JM_Tag_Job_Logo() ); + } +} diff --git a/includes/elementor-tags/class-tag-job-contact-email.php b/includes/elementor-tags/class-tag-job-contact-email.php new file mode 100644 index 0000000..05f3437 --- /dev/null +++ b/includes/elementor-tags/class-tag-job-contact-email.php @@ -0,0 +1,38 @@ +add_control( + 'fallback', + array( + 'label' => 'Fallback', + 'type' => \Elementor\Controls_Manager::MEDIA, + ) + ); + } + + public function get_value( array $options = array() ): array { + $image_id = get_post_meta( get_the_ID(), 'job_logo', true ); + + if ( $image_id ) { + $url = wp_get_attachment_image_url( $image_id, 'full' ); + if ( $url ) { + return array( + 'id' => (int) $image_id, + 'url' => $url, + ); + } + } + + $fallback = $this->get_settings( 'fallback' ); + if ( ! empty( $fallback['id'] ) ) { + return $fallback; + } + + return array( + 'id' => 0, + 'url' => '', + ); + } +} diff --git a/includes/elementor-tags/class-tag-job-type.php b/includes/elementor-tags/class-tag-job-type.php new file mode 100644 index 0000000..1ae86c1 --- /dev/null +++ b/includes/elementor-tags/class-tag-job-type.php @@ -0,0 +1,41 @@ + 'Vollzeit', + 'teilzeit' => 'Teilzeit', + 'ehrenamt' => 'Ehrenamt', + ); + + public function get_name(): string { + return 'ddhh-job-type'; + } + + public function get_title(): string { + return 'Art'; + } + + public function get_group(): array { + return array( DDHH_JM_Elementor_Tags::GROUP_SLUG ); + } + + public function get_categories(): array { + return array( \Elementor\Modules\DynamicTags\Module::TEXT_CATEGORY ); + } + + public function render(): void { + $raw = get_post_meta( get_the_ID(), 'job_type', true ); + $label = self::LABELS[ $raw ] ?? $raw; + echo esc_html( $label ); + } +}