Last active
December 12, 2017 20:30
-
-
Save tripflex/a71be4c627589c474ac60e9c2391427d to your computer and use it in GitHub Desktop.
Visibility integration for Field Editor placeholder output to output placeholder for custom fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ^ DISREGARD THIS, ONLY FOR SYNTAX HIGHLIGHTING ON GITHUB | |
// THIS IS ONLY REQUIRED FOR WP JOB MANAGER FIELD EDITOR VERSION 1.7.10 OR OLDER, 1.7.11+ THIS IS ALREADY INTEGRATED | |
// EDIT THE FILE LOCATED AT: | |
// wp-content/plugins/wp-job-manager-field-editor/includes/functions.php | |
// ON/AROUND LINE NUMBER 539, YOU SHOULD SEE CODE THAT LOOKS EXACTLY LIKE THIS: | |
if( $enable_vw ) { | |
echo "<{$value_wrapper} id=\"jmfe-custom-{$field_slug}\" class=\"jmfe-custom-field {$value_wrap_classes}\" {$vw_atts}>"; | |
} | |
switch( $output_as ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ^ DISREGARD THIS, ONLY FOR SYNTAX HIGHLIGHTING ON GITHUB | |
// THIS IS THE BLOCK OF CODE YOU NEED TO ADD RIGHT ABOVE THE "switch( $output_as )": | |
$post_type = get_post_type( $job_id ); | |
// Change output_as to value if we're outputting a visibility placeholder (to prevent handling custom output on placeholder value) | |
if ( $post_type && $visibility_placeholder = apply_filters( "field_editor_output_{$post_type}_visibility_placeholder", false, $field_slug, $field_value, $args, $job_id ) ) { | |
$output_as = 'value'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ^ DISREGARD THIS, ONLY FOR SYNTAX HIGHLIGHTING ON GITHUB | |
// THIS IS HOW IT SHOULD LOOK BELOW AFTER ADDING THE NEW CODE BLOCK: | |
// Output value wrapper if enabled | |
if( $enable_vw ) { | |
echo "<{$value_wrapper} id=\"jmfe-custom-{$field_slug}\" class=\"jmfe-custom-field {$value_wrap_classes}\" {$vw_atts}>"; | |
} | |
$post_type = get_post_type( $job_id ); | |
// Change output_as to value if we're outputting a visibility placeholder (to prevent handling custom output on placeholder value) | |
if ( $post_type && $visibility_placeholder = apply_filters( "field_editor_output_{$post_type}_visibility_placeholder", false, $field_slug, $field_value, $args, $job_id ) ) { | |
$output_as = 'value'; | |
} | |
switch( $output_as ){ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To explain a little more in detail, when a custom field is set with "Output As" to something other than
value
orstandard
(likegallery
,link
,image
,oembed
, etc), the placeholder value was previously used when field editor attempts to output. With this update, this tells Field Editor to output as value regardless of what the output as configuration is set as.This will allow you to customize your own placeholders to output, so for example, if a field was set to output as link ... no longer will the placeholder be set inside the link HTML, you can now output your own custom HTML or whatever you want, as only the value is output, and not the HTML markup generated by the Field Editor plugin.
This requires WP Job Manager Visibility version 1.4.7 or newer, and this update is only required for WP Job Manager Field Editor 1.7.10 or older (1.7.11+ has this integrated already)