Changeset 2332611
- Timestamp:
- 06/29/2020 10:29:44 PM (6 years ago)
- Location:
- squareoffs/trunk
- Files:
-
- 16 edited
-
css/admin.css (modified) (3 diffs)
-
css/editor.css (modified) (1 diff)
-
css/modal.css (modified) (1 diff)
-
js/media-button.js (modified) (9 diffs)
-
js/templates/modal-insert-content-existing.php (modified) (1 diff)
-
js/templates/modal-insert-content-new.php (modified) (6 diffs)
-
js/upload-image.js (modified) (3 diffs)
-
php/admin/admin.php (modified) (3 diffs)
-
php/admin/squareoffs.php (modified) (2 diffs)
-
php/class-squareoffs-api.php (modified) (2 diffs)
-
php/shortcode.php (modified) (2 diffs)
-
php/templates/admin-settings-display.php (modified) (1 diff)
-
php/templates/form-squareoff.php (modified) (5 diffs)
-
php/templates/iframe.php (modified) (1 diff)
-
plugin.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
squareoffs/trunk/css/admin.css
r1759645 r2332611 85 85 .squareoffs-form-image-preview img { 86 86 display: block; 87 width: auto;87 width: 100%; 88 88 height: auto; 89 max-width: 72px;90 max-height: 72px; 89 /*max-width: 72px; 90 max-height: 72px;*/ 91 91 } 92 92 … … 94 94 display: block; 95 95 margin-bottom: 10px; 96 } 97 98 .squareoffs-modal .squareoffs-form-image-actions .button { 99 margin-top: 10px; 96 100 } 97 101 … … 193 197 text-align: left; 194 198 } 199 200 .squareoffs-cols{ 201 width:100%; 202 display: inline-flex; 203 } 204 .squareoffs-cols > div{ 205 text-align: center; 206 flex-grow: 1; 207 } 208 209 .squareoffs-cols > div label{ 210 display: block; 211 } 212 213 .regular-form-label{ 214 font-weight: normal; 215 font-style: italic; 216 font-size: 12px; 217 } -
squareoffs/trunk/css/editor.css
r1759645 r2332611 12 12 13 13 .squareoffs-preview-size-wide { 14 width: 100%; 15 margin: auto; 16 } 17 18 .squareoffs-preview-size-medium { 14 19 width: 588px; 15 20 margin: auto; -
squareoffs/trunk/css/modal.css
r1759645 r2332611 20 20 height: auto; 21 21 min-height: auto; 22 max-height: 9 0vh;22 max-height: 96vh; 23 23 overflow: auto; 24 24 } -
squareoffs/trunk/js/media-button.js
r1773384 r2332611 42 42 getShortcode: function() { 43 43 44 var allowedSizes = [ 'small', ' wide' ],44 var allowedSizes = [ 'small', 'medium', 'wide' ], 45 45 template = '[squareoffs_embed id="{{ id }}" size="{{ size }}"]', 46 46 shortcode; … … 71 71 */ 72 72 isReady: function() { 73 console.log("SIZE: ",this.get('size')); 73 74 var ready = true; 74 75 var requiredProps = [ 'question', 'side_1_title', 'side_2_title', 'category_uuid' ]; … … 133 134 squareoff: null, 134 135 // Strings. 135 title: 'Insert Square off',136 title: 'Insert SquareOff', 136 137 buttonCloseText: 'Close insert SquareOff modal', 137 138 buttonSubmitText: 'Insert into post', … … 489 490 490 491 window.SO.initMediaUploader( id, function() { 492 window.customSOImageEditor = false; 491 493 var attachment = this.first().get( 'selection' ).first().toJSON(); 492 $ target.val( attachment.url ).trigger( 'change');494 $preview.html( "" ); 493 495 $preview.html( $( '<img />', { 494 496 src: attachment.url, 495 497 alt: '', 498 load : function(){ 499 var requiredratio = (16/9).toFixed(2); 500 var imgratio = (this.width/this.height).toFixed(2); 501 console.log("R: ",requiredratio," I: ",imgratio); 502 console.log("W: ",this.width," H: ",this.height); 503 if(requiredratio != imgratio) { 504 $preview.html(""); 505 $target.val( "" ).trigger( 'change' ); 506 // jQuery(".edit-attachment").click(); 507 alert("Please Crop this image with an ascpect ratio of 16:9."); 508 $el.click(); 509 }else{ 510 $target.val( attachment.url ).trigger( 'change' ); 511 } 512 } 496 513 })); 497 514 }); … … 540 557 _.each( properties, function( property ) { 541 558 var $field = this.$el.find( '[name="' + property + '"]' ); 542 if ( $field && $field.length ) { 559 if ( property == 'size' ) { 560 args[ property ] = this.$el.find( '[name="' + property + '"]:checked' ).val(); 561 }else if ( $field && $field.length ) { 543 562 args[ property ] = $field.val(); 544 563 } … … 595 614 events: { 596 615 'keyup input.squareoffs-input-id': 'updateSquareOff', 597 'change select.squareoffs-select-size': 'updateSquareOff', 616 // 'change select.squareoffs-select-size': 'updateSquareOff', 617 'change input[name="size"]': 'updateSquareOff', 598 618 'click .modal-submit': 'submit', 599 619 }, … … 631 651 updateSquareOff: function() { 632 652 var $soInput = this.$( 'input.squareoffs-input-id', this.$el ), 633 $sizeSelect = this.$( ' select.squareoffs-select-size', this.$el );653 $sizeSelect = this.$( 'input[name="size"]:checked', this.$el ); 634 654 635 655 if ( ! this.model.get( 'squareoff' )) { … … 644 664 this.model.get( 'squareoff' ).set( 'size', $sizeSelect.val() ); 645 665 } 646 666 this.updateSubmitButtonState(); 647 667 }, 648 668 … … 679 699 updateSubmitButtonState: function() { 680 700 if ( this.model.get( 'squareoff' )) { 681 $( '.modal-submit', this.$el ).removeAttr( 'disabled' ); 701 if(this.model.get( 'squareoff' ).get('external_id') && this.model.get( 'squareoff' ).get('size')){ 702 $( '.modal-submit', this.$el ).removeAttr( 'disabled' ); 703 }else{ 704 $( '.modal-submit', this.$el ).attr( 'disabled', 'disabled' ); 705 } 682 706 } else { 683 $( '.m edia-submit', this.$el ).attr( 'disabled', 'disabled' );707 $( '.modal-submit', this.$el ).attr( 'disabled', 'disabled' ); 684 708 } 685 709 }, -
squareoffs/trunk/js/templates/modal-insert-content-existing.php
r1759645 r2332611 23 23 <div class="squareoffs-form-row"> 24 24 <label class="squareoffs-form-row-label" for="squareoffs-select-size-{{ data.cid }}">Size</label> 25 < div class="squareoffs-form-row-main">25 <!-- div class="squareoffs-form-row-main"> 26 26 <select class="squareoffs-select-size regular-text" id="squareoffs-select-size-{{ data.cid }}"> 27 27 <option value="small" <# if ( 'small' === data.selectedSize ) { #>selected="selected"<# } #>>Small</option> 28 <option value="medium" <# if ( 'medium' === data.selectedSize ) { #>selected="selected"<# } #>>Medium</option> 28 29 <option value="wide" <# if ( 'wide' === data.selectedSize ) { #>selected="selected"<# } #>>Wide</option> 29 30 </select> 31 </div --> 32 </div> 33 34 <div class="squareoffs-form-row squareoffs-cols"> 35 <div><label for="squareoffs-new-size-small-{{ data.cid }}"><img src="<?php echo plugin_dir_url( __FILE__ ).'../../assets/small.jpg'; ?>"/></label><label for="squareoffs-new-size-small-{{ data.cid }}"><input id="squareoffs-new-size-small-{{ data.cid }}" type="radio" name="size" value="small" <# if ( 'small' === data.selectedSize ) { #>checked="checked"<# } #>/><?php esc_html_e( 'Small' , 'squareoffs' ); ?></label></div> 36 37 <div><label for="squareoffs-new-size-medium-{{ data.cid }}"><img src="<?php echo plugin_dir_url( __FILE__ ).'../../assets/medium.jpg'; ?>"/></label><label for="squareoffs-new-size-medium-{{ data.cid }}"><input id="squareoffs-new-size-medium-{{ data.cid }}" type="radio" name="size" value="medium" <# if ( 'medium' === data.selectedSize ) { #>checked="checked"<# } #>/><?php esc_html_e( 'Medium' , 'squareoffs' ); ?></label></div> 38 39 <div><label for="squareoffs-new-size-wide-{{ data.cid }}"><img src="<?php echo plugin_dir_url( __FILE__ ).'../../assets/wide.jpg'; ?>"/></label><label for="squareoffs-new-size-wide-{{ data.cid }}"><input id="squareoffs-new-size-wide-{{ data.cid }}" type="radio" name="size" value="wide" <# if ( 'wide' === data.selectedSize ) { #>checked="checked"<# } #>/><?php esc_html_e( 'Wide' , 'squareoffs' ); ?></label></div> 30 40 </div> 31 </div>32 41 33 42 <div class="media-frame-toolbar media-toolbar"> -
squareoffs/trunk/js/templates/modal-insert-content-new.php
r1773384 r2332611 10 10 <fieldset class="squareoffs-form-section"> 11 11 12 <legend><?php esc_html_e( 'What do you want to debate?' , 'squareoffs' ); ?></legend> 12 <legend><?php esc_html_e( 'What is your question?' , 'squareoffs' ); ?></legend> 13 14 <div class="squareoffs-form-row"> 15 <label for="squareoffs-new-question-{{ data.cid }}" class="squareoffs-form-row-label"><?php esc_html_e( 'Cover Photo' , 'squareoffs' ); ?> (<?php esc_html_e( 'required' , 'squareoffs' ); ?>)</label> 16 <div class="squareoffs-form-row-main"> 17 <div class="squareoffs-form-image-preview"></div> 18 <div class="squareoffs-form-image-actions"> 19 <button class="button squareoffs-image" id="squareoffs-image-cover-{{ data.cid }}" type="button"><?php esc_html_e( 'Add / Edit a photo (max. 5Mb)' , 'squareoffs' ); ?></button> 20 <input id="squareoffs-image-cover-{{ data.cid }}" type="hidden" name="cover_photo" /> 21 </div> 22 </div> 23 </div> 13 24 14 25 <div class="squareoffs-form-row"> 15 26 <label for="squareoffs-new-question-{{ data.cid }}" class="squareoffs-form-row-label"><?php esc_html_e( 'Your question' , 'squareoffs' ); ?> (<?php esc_html_e( 'required' , 'squareoffs' ); ?>)</label> 16 27 <div class="squareoffs-form-row-main"> 17 <textarea maxlength=" 65" id="squareoffs-new-question-{{ data.cid }}" name="question" class="regular-text" aria-describedby="squareoffs-new-question-descr-{{ data.cid }}" required="required"></textarea>28 <textarea maxlength="100" id="squareoffs-new-question-{{ data.cid }}" name="question" class="regular-text" aria-describedby="squareoffs-new-question-descr-{{ data.cid }}" required="required"></textarea> 18 29 <p class="description" id="squareoffs-new-question-descr-{{ data.cid }}"> 19 <?php printf( 'Up to 65 characters<br />Examples: What will be the largest effect of Obamacare?<br />Who will have more passing yards tonight?<br />Who\'s in the right?' , 'squareoffs' ); ?>30 <?php printf( 'Up to 100 characters<br />Examples: Which style is better for spring?<br />Who will have more passing yards tonight?<br />Who\'s in the right?' , 'squareoffs' ); ?> 20 31 </p> 21 32 </div> … … 25 36 <fieldset class="squareoffs-form-section"> 26 37 27 <legend><?php esc_html_e( 'What two answers will voters pickfrom?' , 'squareoffs' ); ?></legend>38 <legend><?php esc_html_e( 'What two answers will voters choose from?' , 'squareoffs' ); ?></legend> 28 39 29 40 <div class="squareoffs-form-row"> … … 66 77 <div class="squareoffs-form-image-preview"></div> 67 78 <div class="squareoffs-form-image-actions"> 68 <button class="button squareoffs-image" id="squareoffs-image-side-1-{{ data.cid }}" type="button"><?php esc_html_e( 'Add a photo for side 1 (Max 1Mb)' , 'squareoffs' ); ?></button>79 <button class="button squareoffs-image" id="squareoffs-image-side-1-{{ data.cid }}" type="button"><?php esc_html_e( 'Add / Edit a photo for side 1 (max. 5Mb)' , 'squareoffs' ); ?></button> 69 80 <input id="squareoffs-url-side-1-{{ data.cid }}" type="hidden" name="side_1_photo" /> 70 81 </div> … … 85 96 <div class="squareoffs-form-image-preview"></div> 86 97 <div class="squareoffs-form-image-actions"> 87 <button class="button squareoffs-image" id="squareoffs-image-side-2-{{ data.cid }}" type="button"><?php esc_html_e( 'Add a photo for side 2 (Max 1Mb)' , 'squareoffs' ); ?></button>98 <button class="button squareoffs-image" id="squareoffs-image-side-2-{{ data.cid }}" type="button"><?php esc_html_e( 'Add / Edit a photo for side 2 (max. 5MB)' , 'squareoffs' ); ?></button> 88 99 <input id="squareoffs-url-side-2-{{ data.cid }}" type="hidden" name="side_2_photo" /> 89 100 </div> … … 98 109 99 110 <div class="squareoffs-form-row"> 100 <div class="squareoffs-form-row-label"><?php esc_html_e( 'End date SquareOff' , 'squareoffs' ); ?></div>111 <div class="squareoffs-form-row-label"><?php esc_html_e( 'End Date' , 'squareoffs' ); ?></div> 101 112 <div class="squareoffs-form-row-main"> 102 113 <fieldset> 103 <legend class="screen-reader-text"><?php esc_html_e( 'End date SquareOff' , 'squareoffs' ); ?></legend>114 <legend class="screen-reader-text"><?php esc_html_e( 'End Date' , 'squareoffs' ); ?></legend> 104 115 <?php squareoffs_render_date_field( 'end_date', null, 'squareoffs-new-end-date-{{ data.cid }}' ); ?> 105 116 </fieldset> … … 127 138 128 139 <div class="squareoffs-form-row"> 129 <div class="squareoffs-form-row-label"></div> 130 <div class="squareoffs-form-row-main"> 131 <div class="squareoffs-form-image-preview"></div> 132 <div class="squareoffs-form-image-actions"> 133 <button class="button squareoffs-image" id="squareoffs-image-cover-{{ data.cid }}" type="button"><?php esc_html_e( 'Add a cover photo (Max 1 Mb)' , 'squareoffs' ); ?></button> 134 <input id="squareoffs-image-cover-{{ data.cid }}" type="hidden" name="cover_photo" /> 135 </div> 136 </div> 140 <label for="squareoffs-new-size-{{ data.cid }}" class="squareoffs-form-row-label"><?php esc_html_e( 'Size to insert' , 'squareoffs' ); ?></label> 137 141 </div> 142 <div class="squareoffs-form-row squareoffs-cols"> 143 <div><label for="squareoffs-new-size-small-{{ data.cid }}"><img src="<?php echo plugin_dir_url( __FILE__ ).'../../assets/small.jpg'; ?>"/></label><label for="squareoffs-new-size-small-{{ data.cid }}"><input id="squareoffs-new-size-small-{{ data.cid }}" type="radio" name="size" value="small" <# if ( 'small' === data.selectedSize ) { #>checked="checked"<# } #>/><?php esc_html_e( 'Small' , 'squareoffs' ); ?></label></div> 138 144 139 <div class="squareoffs-form-row"> 140 <label for="squareoffs-new-size-{{ data.cid }}" class="squareoffs-form-row-label"><?php esc_html_e( 'Size to insert' , 'squareoffs' ); ?></label> 141 <div class="squareoffs-form-row-main"> 142 <select id="squareoffs-new-size-{{ data.cid }}" name="size" class="regular-text"> 143 <option value="small"><?php esc_html_e( 'Small' , 'squareoffs' ); ?></option> 144 <option value="wide" selected><?php esc_html_e( 'Wide' , 'squareoffs' ); ?></option> 145 </select> 146 </div> 145 <div><label for="squareoffs-new-size-medium-{{ data.cid }}"><img src="<?php echo plugin_dir_url( __FILE__ ).'../../assets/medium.jpg'; ?>"/></label><label for="squareoffs-new-size-medium-{{ data.cid }}"><input id="squareoffs-new-size-medium-{{ data.cid }}" type="radio" name="size" value="medium" <# if ( 'medium' === data.selectedSize ) { #>checked="checked"<# } #>/><?php esc_html_e( 'Medium' , 'squareoffs' ); ?></label></div> 146 147 <div><label for="squareoffs-new-size-wide-{{ data.cid }}"><img src="<?php echo plugin_dir_url( __FILE__ ).'../../assets/wide.jpg'; ?>"/></label><label for="squareoffs-new-size-wide-{{ data.cid }}"><input id="squareoffs-new-size-wide-{{ data.cid }}" type="radio" name="size" value="wide" <# if ( 'wide' === data.selectedSize ) { #>checked="checked"<# } #>/><?php esc_html_e( 'Wide' , 'squareoffs' ); ?></label></div> 147 148 </div> 149 <p><i>Small embed does not display the cover photo. By default, the cover photo will be displayed in all other embed sizes, Feeds, and SquareOffs.com.</i></p> 148 150 149 151 </fieldset> -
squareoffs/trunk/js/upload-image.js
r1759645 r2332611 15 15 * @type {Object} 16 16 */ 17 var mediaUploaders = {}; 17 window.mediaUploaders = {}; 18 window.customSOImageEditor = false; 18 19 19 20 window.SO = window.SO || {}; … … 32 33 } 33 34 35 window.customSOImageEditor = true; 36 34 37 mediaUploaders[ id ] = wp.media.frames.file_frame = wp.media({ 35 38 title: squareoffs_upload_image.title, 36 39 button: { text: squareoffs_upload_image.button }, 37 40 multiple: false, 41 type:"image" 38 42 }); 39 43 … … 43 47 }); 44 48 49 mediaUploaders[ id ].on( 'activate', function(){ 50 window.customSOImageEditor = true; 51 window.imageEdit.handleCropToolClick= function( postid, nonce, cropButton ) { 52 var img = $( '#image-preview-' + postid ), 53 selection = this.iasapi.getSelection(); 54 55 // Ensure selection is available, otherwise reset to full image. 56 if ( isNaN( selection.x1 ) ) { 57 this.setCropSelection( postid, { 'x1': 0, 'y1': 0, 'x2': img.innerWidth(), 'y2': img.innerHeight(), 'width': img.innerWidth(), 'height': img.innerHeight() } ); 58 selection = this.iasapi.getSelection(); 59 } 60 61 // If we don't already have a selection, select the entire image. 62 if ( 0 === selection.x1 && 0 === selection.y1 && 0 === selection.x2 && 0 === selection.y2 ) { 63 this.iasapi.setSelection( 0, 0, img.innerWidth(), img.innerHeight(), true ); 64 this.iasapi.setOptions( { show: true } ); 65 this.iasapi.update(); 66 } else { 67 68 // Otherwise, perform the crop. 69 imageEdit.crop( postid, nonce , cropButton ); 70 } 71 72 if(window.customSOImageEditor == true){ 73 try{ 74 console.log("Setting Default Aspect Ratio."); 75 $("#imgedit-crop-width-"+postid).val(16); 76 $("#imgedit-crop-height-"+postid).val(9).keyup(); 77 }catch(err){} 78 } 79 } 80 81 } ); 82 mediaUploaders[ id ].on( 'router:render', function(){ 83 $(".media-button").text(squareoffs_upload_image.button).addClass("button-primary"); 84 }); 45 85 mediaUploaders[ id ].open(); 46 86 -
squareoffs/trunk/php/admin/admin.php
r1773384 r2332611 33 33 add_submenu_page( 34 34 'squareoffs', 35 __( 'Add New SquareOff', 'squareoffs' ),36 __( 'Add New', 'squareoffs' ),37 'edit_posts',38 'squareoffs-new',39 'squareoffs_render_new_squareoffs'40 );41 42 add_submenu_page(43 'squareoffs',44 35 __( 'SquareOffs Comments Moderation', 'squareoffs' ), 45 36 __( 'Comments', 'squareoffs' ), … … 79 70 */ 80 71 function squareoffs_admin_scripts( $screen ) { 81 82 72 $allowed_screens = array( 83 73 'squareoffs_page_squareoffs-options', 84 74 'toplevel_page_squareoffs', 85 'squareoffs_page_squareoffs-new',86 75 ); 87 76 … … 105 94 wp_localize_script( 'squareoffs-upload-image', 'squareoffs_upload_image', $translation_array ); 106 95 96 wp_register_script( 97 'soguten', 98 plugins_url( SQUAREOFFS_PLUGIN_URL.'js/soguten.js', __FILE__ ), 99 array( 100 'wp-components', 101 'wp-blocks', 102 'wp-element', 103 'wp-data', 104 'wp-date', 105 'wp-utils', 106 'wp-i18n', 107 ), 108 SQUAREOFFS_PLUGIN_VERSION, true 109 ); 110 107 111 if ( in_array( $screen, $allowed_screens, true ) ) { 108 112 wp_enqueue_media(); 109 113 wp_enqueue_style( 'squareoffs-admin' ); 114 wp_enqueue_style( 'squareoffs-iframe' ); 110 115 wp_enqueue_script( 'squareoffs-admin' ); 111 116 112 117 } 113 114 118 } 115 119 -
squareoffs/trunk/php/admin/squareoffs.php
r1773384 r2332611 47 47 check_admin_referer( 'update-squareoff', 'squareoff-update' ); 48 48 49 $squareoff = squareoffs_sanitize_squareoff( wp_unslash( $_POST['squareoffs-new'] ) ); // WPCS: sanitization ok. 49 // $squareoff = squareoffs_sanitize_squareoff( wp_unslash( $_POST['squareoffs-new'] ) ); // WPCS: sanitization ok. 50 $squareoff = wp_unslash( $_POST['squareoffs-new'] ); 50 51 51 52 if ( squareoffs_validate_new_squareoff( $squareoff ) ) { … … 184 185 185 186 if ( 'question' === $field ) { 186 echo esc_textarea( $data ); 187 // echo esc_textarea( $data ); 188 echo $data; 187 189 } else { 188 190 echo esc_attr( $data ); -
squareoffs/trunk/php/class-squareoffs-api.php
r1759645 r2332611 436 436 $squareoff = array_intersect_key( $squareoff, array_flip( array_merge( $required_args, $optional_args ) ) ); 437 437 $squareoff = $this->prepare_squareoff( $squareoff ); 438 438 // file_put_contents("so.txt", print_r($squareoff, true), FILE_APPEND | LOCK_EX); 439 439 $args = array( 440 440 'method' => 'POST', … … 531 531 foreach ( $props_to_base64_encode as $prop_name ) { 532 532 533 if ( empty( $squareoff[ $prop_name ] ) ) {533 if ( empty( $squareoff[ $prop_name ] ) || strpos( $squareoff[ $prop_name ], "data:") !== false ) { 534 534 continue; 535 535 } -
squareoffs/trunk/php/shortcode.php
r1759645 r2332611 24 24 'size' => 'small', 25 25 'id' => '', 26 'align' => 'left', 26 27 'title' => __( 'SquareOffs Poll', 'squareoffs' ), 27 28 ); … … 33 34 } 34 35 36 $style = ''; 37 35 38 if ( 'wide' === $atts['size'] ) { 36 39 37 40 $width = '100%'; 38 41 $height = '480px'; 39 $style = 'm in-height: 480px;';42 $style = 'max-height: 700px;'; 40 43 44 } elseif('medium' == $atts["size"]) { 45 46 $width = '300px'; 47 $height = '362x'; 48 $style = 'max-height: 362px;'; 41 49 } else { 42 50 43 51 $width = '300px'; 44 52 $height = '250px'; 45 $style = 'm in-height: 250px;';53 $style = 'max-height: 250px;'; 46 54 } 47 55 48 $src = sprintf( '//www.squareoffs.com/embed/%s/%d/single', esc_html( $atts['size'] ), (int) $atts['id'] ); 56 if ( 'left' == $atts['align'] ) { 57 $style .= 'float: left; margin: 0px 0px 0px 0px;'; 58 }elseif ( 'center' == $atts['align'] ) { 59 $style .= 'margin: 0 auto; display: block;'; 60 }elseif ( 'right' == $atts['align'] ) { 61 $style .= 'float: right; margin: 0px 0px 0px 0px;'; 62 } 63 64 // $src = sprintf( '//www.squareoffs.com/embed/%s/%d/single', esc_html( $atts['size'] ), (int) $atts['id'] ); 65 $src = sprintf( '//squareoffs.com/square_offs/%d/?size=%s', (int) $atts['id'], esc_html($atts['size'] ) ); 49 66 50 67 ob_start(); -
squareoffs/trunk/php/templates/admin-settings-display.php
r1759645 r2332611 50 50 </div> 51 51 52 <div class="squareoffs-form-row">53 54 <label for="squareoffs-settings-display-font" class="squareoffs-form-row-label">55 <?php esc_html_e( 'Font', 'squareoffs' ); ?>56 </label>57 58 <div class="squareoffs-form-row-main">59 <select id="squareoffs-settings-display-font" name="squareoffs-settings[display][font]" class="regular-text">60 <option <?php selected( 'proxima_nova_regular', $data['display']['font'] ); ?> value="proxima_nova_regular">Proxima Nova</option>61 <option <?php selected( 'NewsCycleRegular', $data['display']['font'] ); ?> value="NewsCycleRegular">News Cycle</option>62 <option <?php selected( 'Times New Roman', $data['display']['font'] ); ?> value="Times New Roman">Times New Roman</option>63 </select>64 </div>65 66 </div>67 68 52 </fieldset> -
squareoffs/trunk/php/templates/form-squareoff.php
r1759645 r2332611 21 21 <fieldset class="squareoffs-form-section"> 22 22 23 <legend><?php esc_html_e( 'What do you want to debate?' , 'squareoffs' ); ?></legend>23 <legend><?php esc_html_e( 'What is your question?' , 'squareoffs' ); ?></legend> 24 24 25 25 <div class="squareoffs-form-row"> 26 26 <label for="squareoffs-new-question" class="squareoffs-form-row-label"><?php esc_html_e( 'Your question' , 'squareoffs' ); ?> (<?php esc_html_e( 'required' , 'squareoffs' ); ?>)</label> 27 27 <div class="squareoffs-form-row-main"> 28 <textarea maxlength=" 65" id="squareoffs-new-question" name="squareoffs-new[question]" class="regular-text" aria-describedby="squareoffs-new-question-descr" required="required"><?php squareoffs_render_form_data( 'question' ); ?></textarea>28 <textarea maxlength="100" id="squareoffs-new-question" name="squareoffs-new[question]" class="regular-text" aria-describedby="squareoffs-new-question-descr" required="required"><?php squareoffs_render_form_data( 'question' ); ?></textarea> 29 29 <p class="description" id="squareoffs-new-question-descr"> 30 30 <?php 31 31 printf( '%s<br />%s: <br />%s<br />%s<br />%s', 32 esc_html__( 'Up to 65characters' , 'squareoffs' ),32 esc_html__( 'Up to 100 characters' , 'squareoffs' ), 33 33 esc_html__( 'Examples' , 'squareoffs' ), 34 34 esc_html__( 'Who will have more passing yards tonight?' , 'squareoffs' ), … … 45 45 <fieldset class="squareoffs-form-section"> 46 46 47 <legend><?php esc_html_e( 'What two answers will voters pickfrom?' , 'squareoffs' ); ?></legend>47 <legend><?php esc_html_e( 'What two answers will voters choose from?' , 'squareoffs' ); ?></legend> 48 48 49 49 <div class="squareoffs-form-row"> … … 77 77 <div class="squareoffs-form-image-actions"> 78 78 <button class="button" id="squareoffs-image-side-1" type="button"> 79 <?php esc_html_e( 'Add a photo for side 1 (Max 1Mb)' , 'squareoffs' ); ?>79 <?php esc_html_e( 'Add / Edit a photo for side 1 (max. 5Mb)' , 'squareoffs' ); ?> 80 80 </button> 81 81 </div> … … 108 108 <div class="squareoffs-form-image-actions"> 109 109 <button class="button" id="squareoffs-image-side-2" type="button"> 110 <?php esc_html_e( 'Add a photo for side 2 (Max 1 Mb)' , 'squareoffs' ); ?>110 <?php esc_html_e( 'Add / Edit a photo for side 2 (max. 5MB)' , 'squareoffs' ); ?> 111 111 </button> 112 112 </div> … … 158 158 <div class="squareoffs-form-image-actions"> 159 159 <button class="button" id="squareoffs-image-cover" type="button"> 160 <?php esc_html_e( 'Add a cover photo (Max 1Mb)' , 'squareoffs' ); ?>160 <?php esc_html_e( 'Add / Edit a cover photo (max. 5Mb)' , 'squareoffs' ); ?> 161 161 </button> 162 162 </div> -
squareoffs/trunk/php/templates/iframe.php
r1759645 r2332611 9 9 10 10 ?> 11 <!-- script type="text/javascript" src="https://squareoffs.com/assets/embed.js"></script --> 12 <p> 13 <?php if($atts["size"] == "wide"){ ?> 14 <iframe id="embed_square_off_<?php echo (int) $atts['id']; ?>" class="squareoffs-single-wide align-<?php echo $atts['align']; ?>" src="https://squareoffs.com/square_offs/<?php echo (int) $atts['id']; ?>/?size=wide" width="100%" height="700" frameborder="0" scrolling="no" onload="function resize(i){if(document.documentElement.clientWidth<588){var e=i.src.split("/"),t=e[5],f=e[4],r=e[2];if("?size=wide"==t){var s="//"+r+"/square_offs/"+f+"?size=medium";i_f.width=300,i_f.height=362,i_f.src=s}"large"==f&&(i_f.width=340)}}var i_f=this;window.resize=resize(i_f);" style="<?php echo $style; ?>"> </iframe> 11 15 12 <iframe 13 id="embed_square_off_<?php echo (int) $atts['id']; ?>" 14 title="<?php echo esc_html( $atts['title'] ); ?>" 15 src="<?php echo esc_url( $src ); ?>" 16 frameborder="0" 17 scrolling="no" 18 width="<?php echo esc_attr( $width ); ?>" 19 height="<?php echo esc_attr( $height ); ?>" 20 style="<?php echo esc_attr( $style ); ?>" 21 onload='function 22 resize(){ 23 p_w.postMessage( {state:"reloaded"},"*" ) 24 } 25 var i_f = this; 26 window.addEventListener( "message", 27 function(e){ 28 var i=e.origin||e.originalEvent.origin,t=document.createElement("a"); 29 t.href=i_f.src, 30 i_u=t.protocol+"//"+t.host, 31 i===i_u&&(i_f.width=e.data.width,i_f.height=e.data.height) 32 },!1); 33 var p_w=i_f.contentWindow;p_w.postMessage({state:"loaded"},"*"), 34 window.onresize=resize;' 35 > 36 </iframe> 16 <?php }elseif($atts["size"]=="medium"){ ?> 17 <iframe id="embed_square_off_<?php echo (int) $atts['id']; ?>" class="squareoffs-single-medium align-<?php echo $atts['align']; ?>" src="https://squareoffs.com/square_offs/<?php echo (int) $atts['id']; ?>/?size=medium" width="300" height="362" frameborder="0" scrolling="no" style="<?php echo $style; ?>"> </iframe> 18 <?php }elseif($atts["size"] == "small"){ ?> 19 <iframe id="embed_square_off_<?php echo (int) $atts['id']; ?>" class="squareoffs-single-small align-<?php echo $atts['align']; ?>" src="https://squareoffs.com/square_offs/<?php echo (int) $atts['id']; ?>/?size=small" width="300" height="250" frameborder="0" scrolling="no" style="<?php echo $style; ?>"> </iframe> 20 <?php } ?> 21 </p> -
squareoffs/trunk/plugin.php
r1773384 r2332611 8 8 * Text Domain: squareoffs 9 9 * Domain Path: /languages 10 * Version: 1.1.010 * Version: 2.0 11 11 * 12 12 * @package Squareoffs … … 67 67 68 68 if ( ! $user_id ) { 69 return ;69 return false; 70 70 } 71 71 … … 79 79 $squareoffs_api = new Squareoffs_Api( $credentials['email'], $credentials['token'], $credentials['uuid'] ); 80 80 return $squareoffs_api; 81 } 81 }else{ 82 return false; 83 } 82 84 83 85 } 86 87 function sogutenInit() { 88 if(!squareoffs_get_api())return; 89 // automatically load dependencies and version 90 $asset_file = include( plugin_dir_path( __FILE__ ) . 'build/index.asset.php'); 91 wp_enqueue_script( 'quareoffs-js', '//squareoffs.com/assets/embed.js', array(), SQUAREOFFS_PLUGIN_VERSION, true ); 92 wp_enqueue_style( 'squareoffs-iframe', SQUAREOFFS_PLUGIN_URL . 'css/iframe.css' ); 93 wp_enqueue_style( 'squareoffs-cropper', SQUAREOFFS_PLUGIN_URL . 'css/cropper.css' ); 94 wp_register_script( 95 'soguten', 96 plugins_url( 'build/index.js', __FILE__ ), 97 $asset_file['dependencies'], 98 $asset_file['version'] 99 ); 100 101 wp_localize_script( 'soguten', 'soVars', array("soURL" => SQUAREOFFS_PLUGIN_URL) ); 102 103 register_block_type( 'squareoffs/blocks', array( 104 'editor_script' => 'soguten', 105 'render_callback' => 'squareoffs_render_callback', 106 'attributes' => [ 107 'soID' => [ 108 'type' => 'string', 109 'default' => 0 110 ], 111 'soSize' => [ 112 'type' => 'string', 113 'default' => "wide" 114 ], 115 'soAlignment' => [ 116 'type' => 'string', 117 'default' => "left" 118 ] 119 // Below is for creating new SquareOffs 120 // Required 121 /* 'question' => [ 122 'default' => "" 123 ], 124 'side_1_title' => [ 125 'default' => "" 126 ], 127 'side_2_title' => [ 128 'default' => "" 129 ], 130 'category_uuid' => [ 131 'default' => "" 132 ], 133 // Optional 134 'side_1_defense' => [ 135 'default' => "" 136 ], 137 'side_2_defense' => [ 138 'default' => "" 139 ], 140 'side_1_photo' => [ 141 'default' => "" 142 ], 143 'side_2_photo' => [ 144 'default' => "" 145 ], 146 'tag_list' => [ 147 'default' => "" 148 ], 149 'end_date' => [ 150 'default' => "" 151 ], 152 'cover_photo' => [ 153 'default' => "" 154 ]*/ 155 ] 156 ) ); 157 158 } 159 add_action( 'init', 'sogutenInit' ); 160 161 function squareoffs_render_callback($atts){ 162 if($atts["soID"]) return squareoffs_iframe_shortcode(array("id" => $atts["soID"], "size" => $atts["soSize"], "align" => $atts["soAlignment"])); 163 else return ""; 164 } 165 166 function soCreateSquareOffs(){ 167 global $squareoffs_api; 168 $atts = wp_unslash($_POST); 169 170 $squareoffs_api = squareoffs_get_api(); 171 172 if ( $squareoffs_api && ! is_wp_error( $squareoffs_api ) ) { 173 $response = $squareoffs_api->create_squareoff( $atts ); 174 echo json_encode($response); 175 }else{ 176 echo "[]"; 177 } 178 die(); 179 } 180 add_action('wp_ajax_soCreateSquareOffs', 'soCreateSquareOffs'); 181 // add_action('wp_ajax_nopriv_soCreateSquareOffs', 'soCreateSquareOffs'); -
squareoffs/trunk/readme.txt
r1773389 r2332611 104 104 == Changelog == 105 105 106 = 2.0 = 107 * Tested with Wordpress 5.4.1 108 * Updated to enable SquareOffs for the new Block Editor and support SquareOff cover photos. 109 106 110 = 1.1.0 = 107 111 * Tested with WordPress 4.9 … … 118 122 == Upgrade Notice == 119 123 124 = 2.0 = 125 * Tested with Wordpress 5.4.1 126 120 127 = 1.1.0 = 121 128 * Tested with WordPress 4.9
Note: See TracChangeset
for help on using the changeset viewer.