PATH:
home
/
fengshp
/
www
/
wp-content
/
plugins
/
themify-builder-pro
/
includes
/
dynamic-content
<?php /** * @package Themify Builder Pro * @link https://themify.me/ */ class Tbp_Dynamic_Item_CustomField extends Tbp_Dynamic_Item { public static function get_category():string { return 'advanced'; } public static function get_type():array { return array( 'text', 'textarea', 'image', 'wp_editor', 'url', 'custom_css', 'address', 'audio', 'video','slider_range', 'range' ); } public static function get_label():string { return __( 'Custom Field', 'tbp' ); } public static function get_value(array $args = array()):?string { $value = ''; if ( ! empty( $args['custom_field'] ) ) { $value = get_post_meta( $args['post_id']??get_the_ID(), $args['custom_field'], true ); if($value!==''){ if ( is_array( $value ) ) { $value = current_user_can( 'manage_options' )?__( 'The data in this custom field is probably serialized and thus cannot be displayed directly.', 'tbp' ):''; } else { $type = isset( $args['type'] ) ? $args['type'] : 's'; if ( $type === 's' && is_string( $value ) && isset( $args['custom_field_shortcode'] ) && $args['custom_field_shortcode'] === 'yes') { $value = do_shortcode( $value ); } elseif ( $type === 'n' && isset( $args['decimals'] ) ) { $value = number_format( (float)$value, (int) $args['decimals'], $args['dec_point']?? '.', $args['thousands_sep']?? '' ); } elseif ( $type === 'd' && isset( $args['date_format'] ) && $args['date_format'] !== 'default' ) { if ( $args['date_format'] === 'custom' ) { $date_format = $args['custom_date_format']??''; } else { $date_format = $args['date_format']; } $value = wp_date( $date_format, strtotime( get_gmt_from_date( $value ) ) ); } else if ( $type === 'a' ) { $value = (string) wp_get_attachment_url( $value ); } } } } return $value; } public static function get_options():array { return array_merge( [ array( 'label' => 'cfield', 'id' => 'custom_field', 'type' => 'autocomplete', 'dataset' => 'custom_fields', ), array( 'label' => __('Data Type', 'tbp'), 'id' => 'type', 'type' => 'select', 'options' => [ 's' => __( 'Text', 'tbp' ), 'n' => __( 'Number', 'tbp' ), 'd' => __( 'Date', 'tbp' ), 'a' => __( 'Attachment ID', 'tbp' ), ], 'binding' => [ 's' => [ 'show' => [ 'custom_field_shortcode' ], 'hide' => [ 'date_format', 'custom_date_format', 'decimals', 'dec_point', 'thousands_sep', 'tbp_attach_help' ] ], 'n' => [ 'show' => [ 'decimals', 'dec_point', 'thousands_sep' ], 'hide' => [ 'custom_field_shortcode', 'date_format', 'custom_date_format', 'tbp_attach_help' ] ], 'd' => [ 'show' => [ 'date_format', 'custom_date_format' ], 'hide' => [ 'custom_field_shortcode', 'decimals', 'dec_point', 'thousands_sep', 'tbp_attach_help' ] ], 'a' => [ 'show' => [ 'tbp_attach_help' ], 'hide' => [ 'date_format', 'custom_date_format', 'custom_field_shortcode', 'decimals', 'dec_point', 'thousands_sep' ] ] ], 'bindingContext' => '.tb_field_group', 'default' => 's' ), [ 'type' => 'separator', 'label' => '', 'html' => '<div class="tbp_attach_help">' . __( 'Use this if your custom field contains the ID to an item in your Media Library, this will convert it to its URL.', 'tbp' ) . '</div>' ], array( 'label' => __( 'Enable Shortcodes', 'tbp' ), 'id' => 'custom_field_shortcode', 'type' => 'select', 'choose' => true, 'help' => __( 'Enable parsing shortcodes on the custom field value.', 'tbp' ), ) ], Tbp_Dynamic_Item_PostDate::get_options(), [ array( 'label' => __( 'Decimals', 'tbp' ), 'id' => 'decimals', 'type' => 'number', 'binding' => [ 'empty' => [ 'hide' => [ 'dec_point', 'thousands_sep' ] ], 'not_empty' => [ 'show' => [ 'dec_point', 'thousands_sep' ] ] ], 'bindingContext' => '.tb_field_group', 'help' => __( 'Sets the number of decimal digits.', 'tbp' ) ), array( 'label' => __( 'Decimal Point', 'tbp' ), 'id' => 'dec_point', 'type' => 'text', 'help' => __( 'Sets the separator for the decimal point.', 'tbp' ) ), array( 'label' => __( 'Thousands Separator', 'tbp' ), 'id' => 'thousands_sep', 'type' => 'text', ), array( 'label' => 'pstid', 'id' => 'post_id', 'type' => 'number', 'help' => 'tbp_pstidh' ) ] ); } }
[+]
..
[-] ProductSalePrice.php
[edit]
[-] PTBGallery.php
[edit]
[-] WCCheckoutURL.php
[edit]
[-] PostDate.php
[edit]
[-] ACFURL.php
[edit]
[-] PostTermsClass.php
[edit]
[-] PostAuthorURL.php
[edit]
[-] ACFWysiwyg.php
[edit]
[-] PostAuthorEmail.php
[edit]
[-] PTBGalleryAsText.php
[edit]
[-] PTBAudioPlaylist.php
[edit]
[-] ProductTitle.php
[edit]
[-] PTBIconAsIcon.php
[edit]
[-] PTBTelephone.php
[edit]
[-] PTBSelectClass.php
[edit]
[-] ProductCartUrl.php
[edit]
[-] PostAuthorMeta.php
[edit]
[-] tbpTermCover.php
[edit]
[-] PTBEmail.php
[edit]
[-] ArchiveTitle.php
[edit]
[-] SiteURL.php
[edit]
[-] PostAuthorBio.php
[edit]
[-] ACFChoice.php
[edit]
[-] PTBDateAsText.php
[edit]
[-] ACFGallery.php
[edit]
[-] PTBRatingAsText.php
[edit]
[-] ACFEmail.php
[edit]
[-] Option.php
[edit]
[-] PostAuthorClass.php
[edit]
[-] PostCommentCount.php
[edit]
[-] ProductAttributes.php
[edit]
[-] PTBRadioButtonClass.php
[edit]
[-] ACFNumber.php
[edit]
[-] PTBAudio.php
[edit]
[-] PTBTextarea.php
[edit]
[-] PostTerms.php
[edit]
[-] ACFDate.php
[edit]
[-] PTBText.php
[edit]
[-] PostFeaturedImage.php
[edit]
[-] PTBAccordion.php
[edit]
[-] ACFoEmbed.php
[edit]
[-] ProductSKU.php
[edit]
[-] Shortcode.php
[edit]
[-] CurrentDate.php
[edit]
[-] PTBFile.php
[edit]
[-] PTBLinkButton.php
[edit]
[-] PTBMap.php
[edit]
[-] PTBRadioButton.php
[edit]
[-] CustomField.php
[edit]
[-] PTBRating.php
[edit]
[-] ACFFile.php
[edit]
[-] PTBCheckboxClass.php
[edit]
[-] FileContent.php
[edit]
[-] PTBVideoPlaylist.php
[edit]
[-] PTBRepeatableText.php
[edit]
[-] ProductDescription.php
[edit]
[-] PTBIcon.php
[edit]
[-] ArchiveDescription.php
[edit]
[-] PostImageAttachments.php
[edit]
[-] ACFMap.php
[edit]
[-] PTBRelations.php
[edit]
[-] PostAuthorName.php
[edit]
[-] PostAuthorAvatar.php
[edit]
[-] PTBVideo.php
[edit]
[-] ACFText.php
[edit]
[-] PTBDate.php
[edit]
[-] ACFImage.php
[edit]
[-] ACFTextarea.php
[edit]
[-] ProductImage.php
[edit]
[-] PTBNumber.php
[edit]
[-] ProductRating.php
[edit]
[-] ProductStock.php
[edit]
[-] PTBImage.php
[edit]
[-] ProductPrice.php
[edit]
[-] SiteDescription.php
[edit]
[-] EventPostDate.php
[edit]
[-] SiteTitle.php
[edit]
[-] ProductGallery.php
[edit]
[-] MediaLibrary.php
[edit]
[-] RandomNumber.php
[edit]
[-] PostExcerpt.php
[edit]
[-] PTBCheckbox.php
[edit]
[-] ProductCatImage.php
[edit]
[-] PostTitle.php
[edit]
[-] PostClass.php
[edit]
[-] PTBProgressBar.php
[edit]
[-] PTBIconAsText.php
[edit]
[-] ACFPageLink.php
[edit]
[-] PostPermalink.php
[edit]
[-] SiteIcon.php
[edit]
[-] PTBAcc.php
[edit]
[-] PTBSelect.php
[edit]