| 1 |
<?php |
| 2 |
// Silence is golden. |
| 3 |
|
| 4 |
/** |
| 5 |
* == How to Use ? == |
| 6 |
* |
| 7 |
* 1. Load JS: |
| 8 |
* |
| 9 |
* function wpbc_register_js__media_upload( $hook ) { |
| 10 |
* if ( wpbc_can_i_load_on_this_page__media_upload() ) { |
| 11 |
* wpbc_load_js__required_for_media_upload(); |
| 12 |
* } |
| 13 |
* } |
| 14 |
* add_action( 'admin_enqueue_scripts', 'wpbc_register_js__media_upload' ); |
| 15 |
* |
| 16 |
* |
| 17 |
* 2. Inside the page use html element with this class: "wpbc_media_upload_button" |
| 18 |
* |
| 19 |
* <a href="javascript:void(0)" |
| 20 |
* class="wpbc_media_upload_button" |
| 21 |
* data-modal_title="<?php echo esc_attr( __( 'Select Image', 'booking' ) ); ?>" |
| 22 |
* data-btn_title="<?php echo esc_attr( __( 'Select Image', 'booking' ) ); ?>" |
| 23 |
* data-url_field="MY_URL_FIELD" |
| 24 |
* ><i class="menu_icon icon-1x wpbc_icn_tune"></i></a> |
| 25 |
* |
| 26 |
* 3. 'data-url_field' attribute define TEXT field, where will be inserted URL of selected image |
| 27 |
* 'data-modal_title' - Header title in popup |
| 28 |
* 'data-btn_title' - Button title in popup |
| 29 |
* |
| 30 |
* 4. If you need to update URL somewhere else at the page, use this j JavaScript hook: |
| 31 |
* |
| 32 |
* <script type="text/javascript"> |
| 33 |
* jQuery(document).ready(function(){ |
| 34 |
* jQuery( '#MY_URL_FIELD').on( 'wpbc_media_upload_url_set', function(){ |
| 35 |
* jQuery( '#MY_URL_FIELD').parents( '.wpbc_extra__excerpt_img' ).find( '.ui_group__thumbnail .wpbc_media_upload_button' ).html( '<img src="' + jQuery( '#MY_URL_FIELD').val() + '" class="search_thumbnail_img" />' ); |
| 36 |
* }); |
| 37 |
* }); |
| 38 |
* </script> |
| 39 |
* |
| 40 |
*/ |