_comment.php
2 years ago
_db.php
2 years ago
_hidden.php
2 years ago
_label.php
2 years ago
_row.php
2 years ago
attachment.php
2 years ago
checkbox.php
2 years ago
cleditor.php
2 years ago
codemirror.php
2 years ago
color.php
2 years ago
currency.php
2 years ago
date.php
2 years ago
datetime.php
2 years ago
email.php
2 years ago
link.php
2 years ago
number.php
2 years ago
oembed.php
2 years ago
password.php
2 years ago
phone.php
2 years ago
radio.php
2 years ago
select.php
2 years ago
slider.php
2 years ago
slug.php
2 years ago
text.php
2 years ago
textarea.php
2 years ago
time.php
2 years ago
tinymce.php
2 years ago
website.php
2 years ago
oembed.php
83 lines
| 1 | <?php |
| 2 | // Don't load directly. |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | die( '-1' ); |
| 5 | } |
| 6 | |
| 7 | $attributes = array(); |
| 8 | $attributes['type'] = 'text'; |
| 9 | $attributes['value'] = $value; |
| 10 | $attributes['tabindex'] = 2; |
| 11 | $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type, $options ); |
| 12 | |
| 13 | if ( pods_var( 'readonly', $options, false ) ) { |
| 14 | $attributes['readonly'] = 'READONLY'; |
| 15 | |
| 16 | $attributes['class'] .= ' pods-form-ui-read-only'; |
| 17 | } |
| 18 | |
| 19 | $show_preview = (int) pods_v( $form_field_type . '_show_preview', $options, 0 ); |
| 20 | ?> |
| 21 | <input<?php PodsForm::attributes( $attributes, $name, $form_field_type, $options ); ?> /> |
| 22 | |
| 23 | <?php |
| 24 | if ( 1 === $show_preview ) { |
| 25 | $oembed_width = ( isset( $options['oembed_width'] ) ) ? (int) $options['oembed_width'] : 0; |
| 26 | $oembed_height = ( isset( $options['oembed_height'] ) ) ? (int) $options['oembed_height'] : 0; |
| 27 | ?> |
| 28 | <p class="howto"> |
| 29 | <?php _e( 'Preview', 'pods' ); ?> |
| 30 | </p> |
| 31 | <input type="hidden" id="<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>_preview_nonce" name="_nonce_pods_oembed" value="<?php echo wp_create_nonce( 'pods_field_oembed_preview' ); ?>" /> |
| 32 | <div id="<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>_preview" class="pods-oembed-preview"> |
| 33 | <?php echo PodsForm::field_method( $form_field_type, 'display', $value, $name, $options ); ?> |
| 34 | </div> |
| 35 | <script type="text/javascript"> |
| 36 | jQuery( function ( $ ) { |
| 37 | var pods_ajaxurl = ajaxurl + '?pods_ajax=1'; |
| 38 | |
| 39 | $( document ).on( 'keyup', '#<?php echo esc_js( $attributes['id'] ); ?>', function () { |
| 40 | var value = $( this ).val(); |
| 41 | var name = '<?php echo $name; ?>'; |
| 42 | var options = { |
| 43 | id : <?php echo $options['id']; ?>, |
| 44 | oembed_width : '<?php echo $oembed_width; ?>', |
| 45 | oembed_height : '<?php echo $oembed_height; ?>' |
| 46 | }; |
| 47 | var nonce = $( this ).parent().find( '#<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>_preview_nonce' ).val(); |
| 48 | delay( function () { |
| 49 | var postdata = { |
| 50 | 'action' : 'oembed_update_preview', |
| 51 | '_nonce_pods_oembed' : nonce, |
| 52 | 'pods_field_oembed_value' : value, |
| 53 | 'pods_field_oembed_name' : name, |
| 54 | 'pods_field_oembed_options' : options |
| 55 | }; |
| 56 | $.ajax( { |
| 57 | type : 'POST', |
| 58 | url : pods_ajaxurl, |
| 59 | cache : false, |
| 60 | data : postdata, |
| 61 | success : function ( response ) { |
| 62 | if ( typeof response.data == 'string' ) { |
| 63 | $( '#<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>_preview' ).html( response.data ); |
| 64 | } |
| 65 | } |
| 66 | } ); |
| 67 | }, 500 ); |
| 68 | } ); |
| 69 | |
| 70 | var delay = (function () { |
| 71 | var timer = 0; |
| 72 | return function ( callback, ms ) { |
| 73 | clearTimeout( timer ); |
| 74 | timer = setTimeout( callback, ms ); |
| 75 | }; |
| 76 | })(); |
| 77 | |
| 78 | } ); |
| 79 | </script> |
| 80 | <?php |
| 81 | }//end if |
| 82 | PodsForm::regex( $form_field_type, $options ); |
| 83 |