esc_html__( 'Select File', 'meta-box' ), ] ); } /** * Get field HTML. * * @param mixed $meta Meta value. * @param array $field Field parameters. * * @return string */ public static function html( $meta, $field ) { $attributes = self::get_attributes( $field, $meta ); $meta_array = explode( '.', $meta ); $file_ext = strtolower( end( $meta_array ) ); $extensions = [ 'jpeg', 'jpg', 'png', 'gif' ]; return sprintf( '
%s %s
', in_array( $file_ext, $extensions, true ) ? '' : 'rwmb-file-input-hidden', $meta, self::render_attributes( $attributes ), esc_html__( 'Select', 'meta-box' ), $meta ? '' : 'hidden', esc_html__( 'Remove', 'meta-box' ) ); } /** * Get the attributes for a field. * * @param array $field Field parameters. * @param mixed $value Meta value. * @return array */ public static function get_attributes( $field, $value = null ) { $attributes = parent::get_attributes( $field, $value ); $attributes['type'] = 'text'; return $attributes; } }