File manager - Edit - /home/verseaumee/blueversion/wp-content/plugins/wp-freeio/includes/custom-fields/class-custom-fields-display.php
Back
<?php /** * Custom Fields Display * * @package wp-freeio * @author Habq * @license GNU General Public License, version 3 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } class WP_Freeio_Custom_Fields_Display { public static function init() { add_action('init', array(__CLASS__, 'hooks')); } public static function hooks() { $prefixs = array(WP_FREEIO_JOB_LISTING_PREFIX, WP_FREEIO_EMPLOYER_PREFIX, WP_FREEIO_FREELANCER_PREFIX, WP_FREEIO_SERVICE_PREFIX, WP_FREEIO_PROJECT_PREFIX); foreach ($prefixs as $prefix) { $hooks = WP_Freeio_Fields_Manager::get_display_hooks($prefix); foreach ($hooks as $hook => $title) { if ( !empty($hook) ) { add_action( $hook, function($post) use ( $hook, $prefix ) { self::display_hook($post, $hook, $prefix); }, 100 ); } } } } public static function display_hook($post, $current_hook, $prefix) { $custom_fields = WP_Freeio_Fields_Manager::get_custom_fields_data($prefix); if (is_array($custom_fields) && sizeof($custom_fields) > 0) { foreach ($custom_fields as $key => $custom_field) { $hook_display = !empty($custom_field['hook_display']) ? $custom_field['hook_display'] : ''; if ( !empty($hook_display) && $hook_display == $current_hook ) { echo self::display_field_data($custom_field, $post, $current_hook, $prefix); } } } } public static function display_field_data($custom_field, $post, $current_hook, $prefix) { $field_type = !empty($custom_field['type']) ? $custom_field['type'] : ''; $field_id = !empty($custom_field['id']) ? $custom_field['id'] : ''; $field_name = !empty($custom_field['name']) ? $custom_field['name'] : ''; $value = get_post_meta( $post->ID, $field_id, true ); if ( empty($value) ) { return; } $output_value = ''; switch ( $field_type ) { case 'text': case 'number': case 'email': case 'select': case 'radio': $output_value = $value; break; case 'textarea': case 'wp-editor': case 'wysiwyg': $output_value = wpautop($value); break; case 'url': $output_value = '<a href="'.esc_url($value).'">'.$value.'</a>'; break; case 'date': $output_value = strtotime($value); $output_value = date_i18n(get_option('date_format'), $output_value); break; case 'checkbox': $output_value = $value ? esc_html__('Yes', 'wp-freeio') : esc_html__('No', 'wp-freeio'); break; case 'multiselect': if ( is_array($value) ) { $output_value = implode(', ', $value); } break; case 'file': $return = ''; if ( is_array($value) ) { foreach ($value as $file) { if ( self::check_image_mime_type($file) ) { $return .= '<img src="'.esc_url($file).'">'; } else { $return .= '<a href="'.esc_url($file).'">'.esc_html__('Download file', 'wp-freeio').'</a>'; } } } elseif ( !empty($value) ) { if ( self::check_image_mime_type($value) ) { $return .= '<img src="'.esc_url($value).'">'; } else { $return .= '<a href="'.esc_url($value).'">'.esc_html__('Download file', 'wp-freeio').'</a>'; } } $output_value = $return; break; } ob_start(); ?> <div class="custom-field-data"> <?php if ( $field_name ) { ?> <h5><?php echo trim($field_name); ?></h5> <?php } ?> <div class="content"><?php echo trim($output_value); ?></div> </div> <?php $html = ob_get_clean(); return apply_filters( 'wp_freeio_display_field_data', $html, $custom_field, $post, $field_name, $output_value, $current_hook ); } public static function check_image_mime_type($image_path) { $filetype = strtolower(substr(strstr($image_path, '.'), 1)); $mimes = array( "gif", "jpg", "png", "ico"); if ( in_array($filetype, $mimes) ) { return true; } else { return false; } } } WP_Freeio_Custom_Fields_Display::init();
| ver. 1.4 |
Github
|
.
| PHP 8.5.7 | Generation time: 0 |
proxy
|
phpinfo
|
Settings