Plugin Directory

Changeset 2332611


Ignore:
Timestamp:
06/29/2020 10:29:44 PM (6 years ago)
Author:
squareoffs
Message:

Upate to version 2.0.0 add visual editor compatibility

Location:
squareoffs/trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • squareoffs/trunk/css/admin.css

    r1759645 r2332611  
    8585.squareoffs-form-image-preview img {
    8686    display: block;
    87     width: auto;
     87    width: 100%;
    8888    height: auto;
    89     max-width: 72px;
    90     max-height: 72px;
     89    /*max-width: 72px;
     90    max-height: 72px;*/
    9191}
    9292
     
    9494    display: block;
    9595    margin-bottom: 10px;
     96}
     97
     98.squareoffs-modal .squareoffs-form-image-actions .button {
     99    margin-top: 10px;
    96100}
    97101
     
    193197    text-align: left;
    194198}
     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  
    1212
    1313.squareoffs-preview-size-wide {
     14    width: 100%;
     15    margin: auto;
     16}
     17
     18.squareoffs-preview-size-medium {
    1419    width: 588px;
    1520    margin: auto;
  • squareoffs/trunk/css/modal.css

    r1759645 r2332611  
    2020    height: auto;
    2121    min-height: auto;
    22     max-height: 90vh;
     22    max-height: 96vh;
    2323    overflow: auto;
    2424}
  • squareoffs/trunk/js/media-button.js

    r1773384 r2332611  
    4242        getShortcode: function() {
    4343
    44             var allowedSizes = [ 'small', 'wide' ],
     44            var allowedSizes = [ 'small', 'medium', 'wide' ],
    4545                template     = '[squareoffs_embed id="{{ id }}" size="{{ size }}"]',
    4646                shortcode;
     
    7171         */
    7272        isReady: function() {
     73            console.log("SIZE: ",this.get('size'));
    7374            var ready         = true;
    7475            var requiredProps = [ 'question', 'side_1_title', 'side_2_title', 'category_uuid' ];
     
    133134                squareoff:        null,
    134135                // Strings.
    135                 title:            'Insert Squareoff',
     136                title:            'Insert SquareOff',
    136137                buttonCloseText:  'Close insert SquareOff modal',
    137138                buttonSubmitText: 'Insert into post',
     
    489490
    490491                    window.SO.initMediaUploader( id, function() {
     492                        window.customSOImageEditor = false;
    491493                        var attachment = this.first().get( 'selection' ).first().toJSON();
    492                         $target.val( attachment.url ).trigger( 'change' );
     494                        $preview.html( "" );
    493495                        $preview.html( $( '<img />', {
    494496                            src: attachment.url,
    495497                            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                            }
    496513                        }));
    497514                    });
     
    540557            _.each( properties, function( property ) {
    541558                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 ) {
    543562                    args[ property ] = $field.val();
    544563                }
     
    595614        events: {
    596615            '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',
    598618            'click .modal-submit':                  'submit',
    599619        },
     
    631651        updateSquareOff: function() {
    632652            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 );
    634654
    635655            if ( ! this.model.get( 'squareoff' )) {
     
    644664                this.model.get( 'squareoff' ).set( 'size', $sizeSelect.val() );
    645665            }
    646 
     666            this.updateSubmitButtonState();
    647667        },
    648668
     
    679699        updateSubmitButtonState: function() {
    680700            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                }
    682706            } else {
    683                 $( '.media-submit', this.$el ).attr( 'disabled', 'disabled' );
     707                $( '.modal-submit', this.$el ).attr( 'disabled', 'disabled' );
    684708            }
    685709        },
  • squareoffs/trunk/js/templates/modal-insert-content-existing.php

    r1759645 r2332611  
    2323<div class="squareoffs-form-row">
    2424    <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">
    2626        <select class="squareoffs-select-size regular-text" id="squareoffs-select-size-{{ data.cid }}">
    2727            <option value="small" <# if ( 'small' === data.selectedSize ) { #>selected="selected"<# } #>>Small</option>
     28            <option value="medium" <# if ( 'medium' === data.selectedSize ) { #>selected="selected"<# } #>>Medium</option>
    2829            <option value="wide" <# if ( 'wide' === data.selectedSize ) { #>selected="selected"<# } #>>Wide</option>
    2930        </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>
    3040    </div>
    31 </div>
    3241
    3342<div class="media-frame-toolbar media-toolbar">
  • squareoffs/trunk/js/templates/modal-insert-content-new.php

    r1773384 r2332611  
    1010<fieldset class="squareoffs-form-section">
    1111
    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>
    1324
    1425    <div class="squareoffs-form-row">
    1526        <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>
    1627        <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>
    1829            <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' ); ?>
    2031            </p>
    2132        </div>
     
    2536<fieldset class="squareoffs-form-section">
    2637
    27     <legend><?php esc_html_e( 'What two answers will voters pick from?' , 'squareoffs' ); ?></legend>
     38    <legend><?php esc_html_e( 'What two answers will voters choose from?' , 'squareoffs' ); ?></legend>
    2839
    2940    <div class="squareoffs-form-row">
     
    6677            <div class="squareoffs-form-image-preview"></div>
    6778            <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>
    6980                <input id="squareoffs-url-side-1-{{ data.cid }}" type="hidden" name="side_1_photo" />
    7081            </div>
     
    8596            <div class="squareoffs-form-image-preview"></div>
    8697            <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>
    8899                <input id="squareoffs-url-side-2-{{ data.cid }}" type="hidden" name="side_2_photo" />
    89100            </div>
     
    98109
    99110    <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>
    101112        <div class="squareoffs-form-row-main">
    102113            <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>
    104115                <?php squareoffs_render_date_field( 'end_date', null, 'squareoffs-new-end-date-{{ data.cid }}' ); ?>
    105116            </fieldset>
     
    127138
    128139    <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>
    137141    </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>
    138144
    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>
    147148    </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>
    148150
    149151</fieldset>
  • squareoffs/trunk/js/upload-image.js

    r1759645 r2332611  
    1515     * @type {Object}
    1616     */
    17     var mediaUploaders = {};
     17    window.mediaUploaders = {};
     18    window.customSOImageEditor = false;
    1819
    1920    window.SO = window.SO || {};
     
    3233        }
    3334
     35        window.customSOImageEditor = true;
     36
    3437        mediaUploaders[ id ] = wp.media.frames.file_frame = wp.media({
    3538            title:    squareoffs_upload_image.title,
    3639            button:   { text: squareoffs_upload_image.button },
    3740            multiple: false,
     41            type:"image"
    3842        });
    3943
     
    4347        });
    4448
     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        });
    4585        mediaUploaders[ id ].open();
    4686
  • squareoffs/trunk/php/admin/admin.php

    r1773384 r2332611  
    3333        add_submenu_page(
    3434            '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',
    4435            __( 'SquareOffs Comments Moderation', 'squareoffs' ),
    4536            __( 'Comments', 'squareoffs' ),
     
    7970 */
    8071function squareoffs_admin_scripts( $screen ) {
    81 
    8272    $allowed_screens = array(
    8373        'squareoffs_page_squareoffs-options',
    8474        'toplevel_page_squareoffs',
    85         'squareoffs_page_squareoffs-new',
    8675    );
    8776
     
    10594    wp_localize_script( 'squareoffs-upload-image', 'squareoffs_upload_image', $translation_array );
    10695
     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
    107111    if ( in_array( $screen, $allowed_screens, true ) ) {
    108112        wp_enqueue_media();
    109113        wp_enqueue_style( 'squareoffs-admin' );
     114        wp_enqueue_style( 'squareoffs-iframe' );
    110115        wp_enqueue_script( 'squareoffs-admin' );
    111116
    112117    }
    113 
    114118}
    115119
  • squareoffs/trunk/php/admin/squareoffs.php

    r1773384 r2332611  
    4747        check_admin_referer( 'update-squareoff', 'squareoff-update' );
    4848
    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'] );
    5051
    5152        if ( squareoffs_validate_new_squareoff( $squareoff ) ) {
     
    184185
    185186    if ( 'question' === $field ) {
    186         echo esc_textarea( $data );
     187        // echo esc_textarea( $data );
     188        echo $data;
    187189    } else {
    188190        echo esc_attr( $data );
  • squareoffs/trunk/php/class-squareoffs-api.php

    r1759645 r2332611  
    436436        $squareoff = array_intersect_key( $squareoff, array_flip( array_merge( $required_args, $optional_args ) ) );
    437437        $squareoff = $this->prepare_squareoff( $squareoff );
    438 
     438// file_put_contents("so.txt", print_r($squareoff, true), FILE_APPEND | LOCK_EX);
    439439        $args = array(
    440440            'method' => 'POST',
     
    531531        foreach ( $props_to_base64_encode as $prop_name ) {
    532532
    533             if ( empty( $squareoff[ $prop_name ] ) ) {
     533            if ( empty( $squareoff[ $prop_name ] ) || strpos( $squareoff[ $prop_name ], "data:") !== false ) {
    534534                continue;
    535535            }
  • squareoffs/trunk/php/shortcode.php

    r1759645 r2332611  
    2424        'size'  => 'small',
    2525        'id'    => '',
     26        'align'    => 'left',
    2627        'title' => __( 'SquareOffs Poll', 'squareoffs' ),
    2728    );
     
    3334    }
    3435
     36    $style  = '';
     37
    3538    if ( 'wide' === $atts['size'] ) {
    3639
    3740        $width  = '100%';
    3841        $height = '480px';
    39         $style  = 'min-height: 480px;';
     42        $style  = 'max-height: 700px;';
    4043
     44    } elseif('medium' == $atts["size"]) {
     45
     46        $width  = '300px';
     47        $height = '362x';
     48        $style  = 'max-height: 362px;';
    4149    } else {
    4250
    4351        $width  = '300px';
    4452        $height = '250px';
    45         $style  = 'min-height: 250px;';
     53        $style  = 'max-height: 250px;';
    4654    }
    4755
    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'] ) );
    4966
    5067    ob_start();
  • squareoffs/trunk/php/templates/admin-settings-display.php

    r1759645 r2332611  
    5050    </div>
    5151
    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 
    6852</fieldset>
  • squareoffs/trunk/php/templates/form-squareoff.php

    r1759645 r2332611  
    2121    <fieldset class="squareoffs-form-section">
    2222
    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>
    2424
    2525        <div class="squareoffs-form-row">
    2626            <label for="squareoffs-new-question" class="squareoffs-form-row-label"><?php esc_html_e( 'Your question' , 'squareoffs' ); ?> (<?php esc_html_e( 'required' , 'squareoffs' ); ?>)</label>
    2727            <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>
    2929                <p class="description" id="squareoffs-new-question-descr">
    3030                    <?php
    3131                    printf( '%s<br />%s: <br />%s<br />%s<br />%s',
    32                         esc_html__( 'Up to 65 characters' , 'squareoffs' ),
     32                        esc_html__( 'Up to 100 characters' , 'squareoffs' ),
    3333                        esc_html__( 'Examples' , 'squareoffs' ),
    3434                        esc_html__( 'Who will have more passing yards tonight?' , 'squareoffs' ),
     
    4545    <fieldset class="squareoffs-form-section">
    4646
    47         <legend><?php esc_html_e( 'What two answers will voters pick from?' , 'squareoffs' ); ?></legend>
     47        <legend><?php esc_html_e( 'What two answers will voters choose from?' , 'squareoffs' ); ?></legend>
    4848
    4949        <div class="squareoffs-form-row">
     
    7777                <div class="squareoffs-form-image-actions">
    7878                    <button class="button" id="squareoffs-image-side-1" type="button">
    79                         <?php esc_html_e( 'Add a photo for side 1 (Max 1 Mb)' , 'squareoffs' ); ?>
     79                        <?php esc_html_e( 'Add / Edit a photo for side 1 (max. 5Mb)' , 'squareoffs' ); ?>
    8080                    </button>
    8181                </div>
     
    108108                <div class="squareoffs-form-image-actions">
    109109                    <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' ); ?>
    111111                    </button>
    112112                </div>
     
    158158                <div class="squareoffs-form-image-actions">
    159159                    <button class="button" id="squareoffs-image-cover" type="button">
    160                         <?php esc_html_e( 'Add a cover photo (Max 1 Mb)' , 'squareoffs' ); ?>
     160                        <?php esc_html_e( 'Add / Edit a cover photo (max. 5Mb)' , 'squareoffs' ); ?>
    161161                    </button>
    162162                </div>
  • squareoffs/trunk/php/templates/iframe.php

    r1759645 r2332611  
    99
    1010?>
     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&lt;588){var e=i.src.split(&quot;/&quot;),t=e[5],f=e[4],r=e[2];if(&quot;?size=wide&quot;==t){var s=&quot;//&quot;+r+&quot;/square_offs/&quot;+f+&quot;?size=medium&quot;;i_f.width=300,i_f.height=362,i_f.src=s}&quot;large&quot;==f&amp;&amp;(i_f.width=340)}}var i_f=this;window.resize=resize(i_f);" style="<?php echo $style; ?>"> </iframe>
    1115
    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  
    88 * Text Domain:     squareoffs
    99 * Domain Path:     /languages
    10  * Version:         1.1.0
     10 * Version:         2.0
    1111 *
    1212 * @package         Squareoffs
     
    6767
    6868    if ( ! $user_id ) {
    69         return;
     69        return false;
    7070    }
    7171
     
    7979        $squareoffs_api = new Squareoffs_Api( $credentials['email'], $credentials['token'], $credentials['uuid'] );
    8080        return $squareoffs_api;
    81     }
     81    }else{
     82        return false;
     83    }
    8284
    8385}
     86
     87function 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}
     159add_action( 'init', 'sogutenInit' );
     160
     161function 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
     166function 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}
     180add_action('wp_ajax_soCreateSquareOffs', 'soCreateSquareOffs');
     181// add_action('wp_ajax_nopriv_soCreateSquareOffs', 'soCreateSquareOffs');
  • squareoffs/trunk/readme.txt

    r1773389 r2332611  
    104104== Changelog ==
    105105
     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
    106110= 1.1.0 =
    107111* Tested with WordPress 4.9
     
    118122== Upgrade Notice ==
    119123
     124= 2.0 =
     125* Tested with Wordpress 5.4.1
     126
    120127= 1.1.0 =
    121128* Tested with WordPress 4.9
Note: See TracChangeset for help on using the changeset viewer.