Changeset 1608393
- Timestamp:
- 03/06/2017 05:30:30 AM (7 years ago)
- Location:
- gltf-media-type/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
gltf-media-type/trunk/README.txt
r1608389 r1608393 1 1 === Plugin Name === 2 2 Contributors: goldsounds 3 Tags: comments, spam3 Tags: 4 4 Requires at least: 4.7 5 5 Tested up to: 4.7 -
gltf-media-type/trunk/admin/js/gltf-admin-select-model-metabox.js
r1563556 r1608393 9 9 delModelLink = metaBox.find( '.delete-main-model'), 10 10 modelContainer = metaBox.find( '.gltf-main-model-container'), 11 modelIdInput = metaBox.find( '.main-model-id' ); 11 modelIdInput = metaBox.find( '.main-model-id' ), 12 modelScaleInput = metaBox.find( '.main-model-scale' ); 12 13 13 14 // ADD IMAGE LINK 14 15 addModelLink.on( 'click', function( event ){ 15 16 event.preventDefault();17 18 // If the media frame already exists, reopen it.19 if ( frame ) {20 frame.open();21 return;22 }23 24 // Create a new media frame25 frame = wp.media({26 title: 'Select a GLTF model file',27 button: {28 text: 'Use this model'29 },30 multiple: false, // Set to true to allow multiple files to be selected31 library : { type: 'model/gltf+json' }32 });33 16 34 35 // When an image is selected in the media frame... 36 frame.on( 'select', function() { 37 // Get media attachment details from the frame state 38 var attachment = frame.state().get('selection').first().toJSON(); 17 event.preventDefault(); 39 18 40 // Send the attachment URL to our custom image input field. 41 modelContainer.append( '<div class="gltf-model" data-model="'+attachment.url+'" data-scale="1.0" style="width: 300px; height: 300px;"></div>' ); 19 // If the media frame already exists, reopen it. 20 if ( frame ) { 21 frame.open(); 22 return; 23 } 42 24 43 // Send the attachment id to our hidden input 44 modelIdInput.val( attachment.id ); 25 // Create a new media frame 26 frame = wp.media({ 27 title: 'Select a GLTF model file', 28 button: { 29 text: 'Use this model' 30 }, 31 multiple: false, // Set to true to allow multiple files to be selected 32 library : { type: 'model/gltf+json' } 33 }); 45 34 46 // Hide the add image link 47 addModelLink.addClass( 'hidden' ); 35 // When an image is selected in the media frame... 36 frame.on( 'select', function() { 37 // Get media attachment details from the frame state 38 var attachment = frame.state().get('selection').first().toJSON(); 48 39 49 // Unhide the remove image link 50 delModelLink.removeClass( 'hidden' ); 40 var scale = modelScaleInput.val(); 51 41 52 jQuery( '.gltf-model' ).each( initializeGltfElement ); 53 }); 42 if ( '' == scale ) { 43 scale = '1.0'; 44 } 54 45 55 // Finally, open the modal on click 56 frame.open(); 46 // Send the attachment URL to our custom image input field. 47 modelContainer.append( '<div class="gltf-model" data-model="'+attachment.url+'" data-scale="'+scale+'" style="width: 300px; height: 300px;"></div>' ); 48 49 // Send the attachment id to our hidden input 50 modelIdInput.val( attachment.id ); 51 52 // Hide the add image link 53 addModelLink.addClass( 'hidden' ); 54 55 // Unhide the remove image link 56 delModelLink.removeClass( 'hidden' ); 57 58 jQuery( '.gltf-model' ).each( initializeGltfElement ); 59 }); 60 61 // Finally, open the modal on click 62 frame.open(); 57 63 }); 58 64 … … 60 66 // DELETE IMAGE LINK 61 67 delModelLink.on( 'click', function( event ){ 68 62 69 63 event.preventDefault(); 70 // Clear out the preview image 71 modelContainer.html( '' ); 64 72 65 // Clear out the preview image66 modelContainer.html( '' );73 74 ' ); 67 75 68 // Un-hide the addimage link69 addModelLink.removeClass( 'hidden' );76 image link 77 Class( 'hidden' ); 70 78 71 // Hide the delete image link 72 delModelLink.addClass( 'hidden' ); 73 74 // Delete the image id from the hidden input 75 modelIdInput.val( '' ); 76 79 // Delete the image id from the hidden input 80 modelIdInput.val( '' ); 77 81 }); 78 82 -
gltf-media-type/trunk/includes/class-gltf.php
r1608389 r1608393 208 208 wp_nonce_field( basename( __FILE__ ), 'gltf_nonce' ); 209 209 210 // global $post;211 210 // Get WordPress' media upload URL 212 211 $upload_link = esc_url( get_upload_iframe_src( 'image', $post->ID ) ); … … 215 214 $main_model_id = get_post_meta( $post->ID, '_gltf_main_model', true ); 216 215 $main_model_scale = get_post_meta( $post->ID, '_gltf_main_model_scale', true ); 216 217 217 218 218 // Get the image src … … 223 223 ?> 224 224 225 <!-- Your image container, which can be manipulated with js-->225 <!-- --> 226 226 <div class="gltf-main-model-container"> 227 227 <?php if ( $main_model_is_set ) : ?> 228 <div class="gltf-model" data-model="<?php echo $main_model_url ?>" data-scale="1.0" style="width: 300px; height: 300px;"></div>228 <div class="gltf-model" data-model="<?php echo $main_model_url" style="width: 300px; height: 300px;"></div> 229 229 <?php endif; ?> 230 230 </div> 231 231 232 <!-- Your add & remove image links -->232 <!-- e links --> 233 233 <p class="hide-if-no-js"> 234 234 <a class="upload-main-model <?php if ( $main_model_is_set ) { echo 'hidden'; } ?>" … … 242 242 </p> 243 243 244 <!-- A hidden input to set and post the chosen imageid -->244 <!-- A hidden input to set and post the chosen id --> 245 245 <input class="main-model-id" name="main-model-id" type="hidden" value="<?php echo esc_attr( $main_model_id ); ?>" /> 246 246 … … 248 248 <label for="main-model-scale"> 249 249 <?php _e( 'Model Scale', 'gltf-media-type '); ?> 250 <input class="main-model-scale" name="main-model-scale" value="<?php echo esc_attr( $main_model_scale ? $main_model_scale : 1.0); ?>" />250 <input class="main-model-scale" name="main-model-scale" value="<?php echo esc_attr( $main_model_scale ); ?>" /> 251 251 </label> 252 252 </p> 253 253 <?php 254 /*255 256 $gltf_stored_meta = get_post_meta( $post->ID );257 ?>258 <p>259 <span class="gltf-row-title"><?php _e( 'Example Radio Buttons', 'gltf-media-type' )?></span>260 <div class="gltf-row-content">261 <label for="meta-radio-one">262 <input type="radio" name="meta-radio" id="meta-radio-one" value="radio-one" <?php if ( isset ( $gltf_stored_meta['meta-radio'] ) ) checked( $gltf_stored_meta['meta-radio'][0], 'radio-one' ); ?>>263 <?php _e( 'Radio Option #1', 'gltf-media-type' )?>264 </label>265 <label for="meta-radio-two">266 <input type="radio" name="meta-radio" id="meta-radio-two" value="radio-two" <?php if ( isset ( $gltf_stored_meta['meta-radio'] ) ) checked( $gltf_stored_meta['meta-radio'][0], 'radio-two' ); ?>>267 <?php _e( 'Radio Option #2', 'gltf-media-type' )?>268 </label>269 </div>270 </p><?php271 */272 254 } 273 255 … … 281 263 return; 282 264 } 283 284 // Checks for input and sanitizes/saves if needed 285 // if( isset( $_POST[ 'meta-text' ] ) ) { 286 // update_post_meta( $post_id, 'meta-text', sanitize_text_field( $_POST[ 'meta-text' ] ) ); 287 // } 265 288 266 if( isset( $_POST[ 'main-model-id' ] ) ) { 289 267 update_post_meta( $post_id, '_gltf_main_model', $_POST[ 'main-model-id' ] ); -
gltf-media-type/trunk/js/public.js
r1608389 r1608393 48925 48925 48926 48926 // necessary for the enter VR button to appear in the right position 48927 $el.css( {'position':'relative'});;48927 $el.css(; 48928 48928 48929 48929 scene = new __WEBPACK_IMPORTED_MODULE_0_three__["g" /* Scene */](); -
gltf-media-type/trunk/jssrc/public.js
r1608389 r1608393 137 137 138 138 // necessary for the enter VR button to appear in the right position 139 $el.css( {'position':'relative'});;139 $el.css(; 140 140 141 141 scene = new THREE.Scene();
Note: See TracChangeset
for help on using the changeset viewer.