| Server IP : 118.139.160.155 / Your IP : 216.73.217.153 Web Server : Apache System : Linux sg2plmcpnl504228.prod.sin2.secureserver.net 4.18.0-553.124.4.lve.el8.x86_64 #1 SMP Fri May 15 13:02:13 UTC 2026 x86_64 User : twll3xqyaqrh ( 9725459) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/twll3xqyaqrh/public_html/Site WP/wp-content/plugins/meta-box/inc/ |
Upload File : |
<?php
class RWMB_Shortcode {
public function init() {
add_shortcode( 'rwmb_meta', [ $this, 'register_shortcode' ] );
}
public function register_shortcode( $atts ) {
$atts = wp_parse_args( $atts, [
'id' => '',
'object_id' => null,
'attribute' => '',
'render_shortcodes' => 'true',
] );
RWMB_Helpers_Array::change_key( $atts, 'post_id', 'object_id' );
RWMB_Helpers_Array::change_key( $atts, 'meta_key', 'id' );
if ( empty( $atts['id'] ) ) {
return '';
}
$field_id = $atts['id'];
$object_id = $atts['object_id'];
unset( $atts['id'], $atts['object_id'] );
$value = $this->get_value( $field_id, $object_id, $atts );
$value = 'true' === $atts['render_shortcodes'] ? do_shortcode( $value ) : $value;
return $value;
}
private function get_value( $field_id, $object_id, $atts ) {
$attribute = $atts['attribute'];
if ( ! $attribute ) {
return rwmb_the_value( $field_id, $atts, $object_id, false );
}
$value = rwmb_get_value( $field_id, $atts, $object_id );
if ( ! is_array( $value ) && ! is_object( $value ) ) {
return $value;
}
if ( is_object( $value ) ) {
return $value->$attribute;
}
if ( isset( $value[ $attribute ] ) ) {
return $value[ $attribute ];
}
$value = wp_list_pluck( $value, $attribute );
$value = implode( ',', array_filter( $value ) );
return $value;
}
}