PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.0.10.5
Pods – Custom Content Types and Fields v3.0.10.5
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / ui / fields / currency.php
pods / ui / fields Last commit date
_comment.php 2 days ago _db.php 2 days ago _hidden.php 2 days ago _label.php 2 days ago _row.php 2 days ago attachment.php 2 days ago checkbox.php 2 days ago cleditor.php 2 days ago codemirror.php 2 days ago color.php 2 days ago currency.php 2 days ago date.php 2 days ago datetime.php 2 days ago email.php 2 days ago link.php 2 days ago number.php 2 days ago oembed.php 2 days ago password.php 2 days ago phone.php 2 days ago radio.php 2 days ago select.php 2 days ago slider.php 2 days ago slug.php 2 days ago text.php 2 days ago textarea.php 2 days ago time.php 2 days ago tinymce.php 2 days ago website.php 2 days ago
currency.php
87 lines
1 <?php
2 // Don't load directly.
3 if ( ! defined( 'ABSPATH' ) ) {
4 die( '-1' );
5 }
6
7 $field_number = PodsForm::field_loader( 'currency' );
8
9 $value = $field_number->format( $value, $name, $options, $pod, $id );
10
11 $attributes = array();
12 $attributes['type'] = 'text';
13 $attributes['value'] = $value;
14 $attributes['tabindex'] = 2;
15 $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type, $options );
16
17 global $wp_locale;
18
19 if ( '9999.99' == pods_var( 'currency_format', $options ) ) {
20 $thousands = '';
21 $dot = '.';
22 } elseif ( '9999,99' == pods_var( 'currency_format', $options ) ) {
23 $thousands = '';
24 $dot = ',';
25 } elseif ( '9.999,99' == pods_var( 'currency_format', $options ) ) {
26 $thousands = '.';
27 $dot = ',';
28 } else {
29 $thousands = $wp_locale->number_format['thousands_sep'];
30 $dot = $wp_locale->number_format['decimal_point'];
31 }
32
33 $currency = 'usd';
34
35 $currency_format_sign = pods_v( 'currency_format_sign', $options, $currency );
36
37 $currencies = PodsField_Currency::data_currencies();
38
39 if ( isset( $currencies[ $currency_format_sign ] ) ) {
40 $currency = $currency_format_sign;
41 }
42
43 $currency_sign = $currencies[ $currency ]['sign'];
44 ?>
45 <div class="pods-currency-container">
46 <code class="pods-currency-sign pods-hidden"><?php echo $currency_sign; ?></code>
47 <input<?php PodsForm::attributes( $attributes, $name, $form_field_type, $options ); ?>/>
48 </div>
49 <script>
50 jQuery( function ( $ ) {
51 var input = $( 'input#<?php echo esc_js( $attributes[ 'id' ] ); ?>' ),
52 currency_sign = input.siblings( 'code.pods-currency-sign' );
53
54 input.on( 'blur', function () {
55 if ( !/^[0-9\<?php
56 echo esc_js( implode( '\\', array_filter( array( $dot, $thousands ) ) ) );
57 ?>]$/.test( $( this ).val() ) ) {
58 var newval = $( this )
59 .val()
60 .replace( /[^0-9-\<?php
61 echo esc_js( implode( '\\', array_filter( array( $dot, $thousands ) ) ) );
62 ?>]/g, '' );
63 $( this ).val( newval );
64 }
65 } );
66
67 if ( currency_sign.length ) {
68 currency_sign.removeClass( 'pods-hidden' );
69
70 function resize_currency_sign() {
71 if ( currency_sign.width() < 1 ) {
72 return;
73 }
74
75 input.css( 'padding-left', currency_sign.width() + 12 );
76 currency_sign.css( 'line-height', parseInt( input.innerHeight(), 10 ) + 'px' );
77 }
78
79 // Cover most events we need.
80 $(window).on( 'resize load visibilitychange postbox-toggled postbox-columnchange postboxes-columnchange', resize_currency_sign );
81
82 // Gutenberg show/hide panels do not trigger any known events, this is one final hackaround for that.
83 input.on( 'hover focus', resize_currency_sign );
84 }
85 } );
86 </script>
87