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