Plugin Directory

Changeset 1829594


Ignore:
Timestamp:
02/26/2018 09:08:07 PM (8 years ago)
Author:
gk.loveweb
Message:

Fix WP compatibility issue.

Location:
visual-text-editor
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • visual-text-editor/trunk/includes/class-admin.php

    r1584270 r1829594  
    1818        add_action( 'admin_init', array( $this, 'registerPluginSetting' ) );
    1919        add_action( 'admin_head', array( $this, 'veChangeStyle' ) );
     20        add_shortcode( 'addcode',array( $this, 'addcode_callback' ) );
    2021
    2122        if ( get_option( 'autop' ) == 'on' ) {
     
    3233    }
    3334
     35    public function addcode_callback( $atts ) {
     36        echo 'fdsfdsf';
     37    }
    3438
    3539    public function veChangeStyle() {
     
    4650    public function registerJSCSS() {
    4751        wp_enqueue_style( 'wp-color-picker' );
    48         wp_enqueue_style( 'wp-color-picker' );
    4952        wp_enqueue_script( 'wp-color-picker-alpha', WPVE_URL . '/js/wp-color-picker-alpha.js', array( 'wp-color-picker' ), '1.2.2' );
    5053    }
     
    5659        register_setting( 'wpvisualsettings', 'mediabuttons' );
    5760        register_setting( 'wpvisualsettings', 'dragndrop' );
    58         register_setting( 'wpvisualsettings', 'visual_editor_mce' );
    5961
    6062        add_action( 'admin_enqueue_scripts', array( $this, 'registerJSCSS' ) );
     
    6466        add_menu_page( 'WP Text Widget Settings', 'WP Visual Text ', 'manage_options', 'wptextwidgetsettings', array( $this, 'veTextWidgetSetting' ), WPVE_URL . 'img/wpve-icon.png' );
    6567    }
    66    
    67     public function getnoticeboard(){
    68 
    69         $remote_content = file_get_contents('https://raw.githubusercontent.com/emgk/emgk.github.io/master/etc/info.txt?'.mt_rand());
    70 
    71         if( !empty( $remote_content ) ) {
    72             return $remote_content;
    73         }
    74 
    75         return false;
    76     }
    7768
    7869    public function veTextWidgetSetting() {
    79        
    80 
    8170        ?>
    8271        <h2><?php echo __('General Options','visual-text-editor');?></h2>
    8372        <hr/>
    84         <?php
    85 
    86         if( $this->getnoticeboard() ){
    87 
    88             echo $this->getnoticeboard();
    89         }
    90 
    91         ?>
    9273        <form action="options.php" method="post">
    9374        <?php
     
    10283        <tr>
    10384        <th scope="row"><?php echo __( 'Overlay Color','visual-text-editor' );?> </th>
    104         <td><input type="text"  name="overlaycolor" data-alpha="true" id="overlaycolor" value="<?php echo esc_attr( get_option( 'overlaycolor' ) );?>"/><br/><span class="description"><?php echo __( 'Lightbox overlay color','visual-text-editor' );?> </span></td>
     85        <td><input type="text"  name="overlaycolor" data-alpha="true" class="color-picker" id="overlaycolor" value="<?php echo esc_attr( get_option( 'overlaycolor' ) );?>"/><br/><span class="description"><?php echo __( 'Lightbox overlay color','visual-text-editor' );?> </span></td>
    10586        </tr>   
    10687        <tr>
     
    129110        </td>
    130111        </tr>
    131         <tr>
    132         <th scope="row">   
    133             <?php echo __( 'Only Text Editor','visual-text-editor' );?>
    134         </th>
    135         <td>
    136             <label for="visual_editor_mce"><input type="checkbox" id="visual_editor_mce"  name="visual_editor_mce" <?php checked( esc_attr( get_option( 'visual_editor_mce' ) ), 'on', true );?> /><?php echo __( 'Enable','visual-text-editor' );?></label><Br/><span class="description"><?php echo __( 'Disable Visual Text Editor <br/><b>Recommended for PHP code</b>','visual-text-editor' );?></span>
    137         </td>
    138         </tr>
    139112        </table>
    140113        <?php submit_button( 'Save Settings' );?>
  • visual-text-editor/trunk/includes/class-visual-editor.php

    r1584270 r1829594  
    1717    private $mediabutton = false;
    1818    private $draganddrop = false;
    19 
    20     /*
    21     * @since 1.2
    22     */
    23     private $visual_editor_mce = true;
     19    private $editorheight ;
    2420
    2521    /*
     
    4440        if ( get_option( 'mediabuttons' ) == 'on' ) {
    4541            $this->mediabutton = true;
    46         }
    47 
    48         if ( get_option( 'visual_editor_mce' ) == 'on' ) {
    49             $this->visual_editor_mce = false;
    5042        }
    5143
     
    8880                                'wpautop' => $this->autop,
    8981                                'media_buttons' => $this->mediabutton,
    90                                 'tinymce' => $this->visual_editor_mce
    9182                            );
    9283
     
    112103    public function visualtext_phpgenerate( $atts, $content ){
    113104
    114         ob_start();
    115         echo eval( strip_tags( $content ) );
    116         $phpcontent = ob_get_clean();
    117        
     105        $phpcontent = eval( $content );
    118106        return $phpcontent;
    119107    }
  • visual-text-editor/trunk/includes/class-widget.php

    r1584270 r1829594  
    3636        echo $before_widget;
    3737        echo $before_title . $title . $after_title;
    38                
     38       
    3939        /**
    4040        * Fixed Shortcode issue
     
    4242        * since (may be since v4.4.0) the widget content is wrapped in a div with a "textwidget" class
    4343        */
     44        echo '<div class="textwidget">';
    4445        $final_content = $this->generate_phpcode( do_shortcode($content) );
    45 
    46         echo '<div class="textwidget">';
    47         echo $final_content;
    4846        echo '</div>';
    4947
     
    8381    public function generate_phpcode( $content ){
    8482
    85         ob_start();
    8683        // Generate php code
    87         echo eval('?> ' . $content . '<?php ');
    88 
    89         $data = ob_get_clean();
    90 
    91         return $data;
     84        return  eval('?> ' . $content . '<?php ');
    9285    }
    9386
  • visual-text-editor/trunk/js/wp-color-picker-alpha.js

    r1533908 r1829594  
    55 * Only run in input and is defined data alpha in true
    66 *
    7  * Version: 1.2.2
    8  * https://github.com/23r9i0/wp-color-picker-alpha
    9  * Copyright (c) 2015 Sergio P.A. (23r9i0).
     7 * Version: 2.1.3
     8 * https://github.com/kallookoo/wp-color-picker-alpha
    109 * Licensed under the GPLv2 license.
    1110 */
    1211( function( $ ) {
    13     // Variable for some backgrounds ( grid )
     12    // Prevent double-init.
     13    if ( $.wp.wpColorPicker.prototype._hasAlpha ) {
     14        return;
     15    }
     16
     17        // Variable for some backgrounds ( grid )
    1418    var image   = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==',
    15     // html stuff for wpColorPicker copy of the original color-picker.js
    16         _before = '<a tabindex="0" class="wp-color-result" />',
    17         _after  = '<div class="wp-picker-holder" />',
    18         _wrap   = '<div class="wp-picker-container" />',
    19         _button = '<input type="button" class="button button-small hidden" />';
    20 
     19        // html stuff for wpColorPicker copy of the original color-picker.js
     20        _after = '<div class="wp-picker-holder" />',
     21        _wrap = '<div class="wp-picker-container" />',
     22        _button = '<input type="button" class="button button-small" />',
     23        // Prevent CSS issues in < WordPress 4.9
     24        _deprecated = ( wpColorPickerL10n.current !== undefined );
     25        // Declare some global variables when is deprecated or not
     26        if ( _deprecated ) {
     27            var _before = '<a tabindex="0" class="wp-color-result" />';
     28        } else {
     29            var _before = '<button type="button" class="button wp-color-result" aria-expanded="false"><span class="wp-color-result-text"></span></button>',
     30                _wrappingLabel = '<label></label>',
     31                _wrappingLabelText = '<span class="screen-reader-text"></span>';
     32        }
    2133    /**
    2234     * Overwrite Color
     
    4254     */
    4355    $.widget( 'wp.wpColorPicker', $.wp.wpColorPicker, {
     56        _hasAlpha: true,
     57        /**
     58         * @summary Creates the color picker.
     59         *
     60         * Creates the color picker, sets default values, css classes and wraps it all in HTML.
     61         *
     62         * @since 3.5.0
     63         *
     64         * @access private
     65         *
     66         * @returns {void}
     67         */
    4468        _create: function() {
    45             // bail early for unsupported Iris.
    46             if ( ! $.support.iris )
     69            // Return early if Iris support is missing.
     70            if ( ! $.support.iris ) {
    4771                return;
     72            }
    4873
    4974            var self = this,
    50                     el   = self.element;
    51 
     75                el = self.element;
     76
     77            // Override default options with options bound to the element.
    5278            $.extend( self.options, el.data() );
    5379
    54             // keep close bound so it can be attached to a body listener
     80            // Create a color picker which only allows adjustments to the hue.
     81            if ( self.options.type === 'hue' ) {
     82                return self._createHueOnly();
     83            }
     84
     85            // Bind the close event.
    5586            self.close = $.proxy( self.close, self );
    5687
    5788            self.initialValue = el.val();
    5889
    59             // Set up HTML structure, hide things
    60             el.addClass( 'wp-color-picker' ).hide().wrap( _wrap );
    61             self.wrap            = el.parent();
    62             self.toggler         = $( _before ).insertBefore( el ).css( { backgroundColor : self.initialValue } ).attr( 'title', wpColorPickerL10n.pick ).attr( 'data-current', wpColorPickerL10n.current );
    63             self.pickerContainer = $( _after ).insertAfter( el );
    64             self.button          = $( _button );
    65 
     90            // Add a CSS class to the input field.
     91            el.addClass( 'wp-color-picker' );
     92
     93            if ( _deprecated ) {
     94                el.hide().wrap( _wrap );
     95                self.wrap            = el.parent();
     96                self.toggler         = $( _before )
     97                    .insertBefore( el )
     98                    .css( { backgroundColor : self.initialValue } )
     99                    .attr( 'title', wpColorPickerL10n.pick )
     100                    .attr( 'data-current', wpColorPickerL10n.current );
     101                self.pickerContainer = $( _after ).insertAfter( el );
     102                self.button          = $( _button ).addClass('hidden');
     103            } else {
     104                /*
     105                 * Check if there's already a wrapping label, e.g. in the Customizer.
     106                 * If there's no label, add a default one to match the Customizer template.
     107                 */
     108                if ( ! el.parent( 'label' ).length ) {
     109                    // Wrap the input field in the default label.
     110                    el.wrap( _wrappingLabel );
     111                    // Insert the default label text.
     112                    self.wrappingLabelText = $( _wrappingLabelText )
     113                        .insertBefore( el )
     114                        .text( wpColorPickerL10n.defaultLabel );
     115                }
     116
     117                /*
     118                 * At this point, either it's the standalone version or the Customizer
     119                 * one, we have a wrapping label to use as hook in the DOM, let's store it.
     120                 */
     121                self.wrappingLabel = el.parent();
     122
     123                // Wrap the label in the main wrapper.
     124                self.wrappingLabel.wrap( _wrap );
     125                // Store a reference to the main wrapper.
     126                self.wrap = self.wrappingLabel.parent();
     127                // Set up the toggle button and insert it before the wrapping label.
     128                self.toggler = $( _before )
     129                    .insertBefore( self.wrappingLabel )
     130                    .css( { backgroundColor: self.initialValue } );
     131                // Set the toggle button span element text.
     132                self.toggler.find( '.wp-color-result-text' ).text( wpColorPickerL10n.pick );
     133                // Set up the Iris container and insert it after the wrapping label.
     134                self.pickerContainer = $( _after ).insertAfter( self.wrappingLabel );
     135                // Store a reference to the Clear/Default button.
     136                self.button = $( _button );
     137            }
     138
     139            // Set up the Clear/Default button.
    66140            if ( self.options.defaultColor ) {
    67141                self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString );
     142                if ( ! _deprecated ) {
     143                    self.button.attr( 'aria-label', wpColorPickerL10n.defaultAriaLabel );
     144                }
    68145            } else {
    69146                self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear );
    70             }
    71 
    72             el.wrap( '<span class="wp-picker-input-wrap" />' ).after( self.button );
     147                if ( ! _deprecated ) {
     148                    self.button.attr( 'aria-label', wpColorPickerL10n.clearAriaLabel );
     149                }
     150            }
     151
     152            if ( _deprecated ) {
     153                el.wrap( '<span class="wp-picker-input-wrap" />' ).after( self.button );
     154            } else {
     155                // Wrap the wrapping label in its wrapper and append the Clear/Default button.
     156                self.wrappingLabel
     157                    .wrap( '<span class="wp-picker-input-wrap hidden" />' )
     158                    .after( self.button );
     159
     160                /*
     161                 * The input wrapper now contains the label+input+Clear/Default button.
     162                 * Store a reference to the input wrapper: we'll use this to toggle
     163                 * the controls visibility.
     164                 */
     165                self.inputWrapper = el.closest( '.wp-picker-input-wrap' );
     166            }
    73167
    74168            el.iris( {
    75                 target   : self.pickerContainer,
    76                 hide     : self.options.hide,
    77                 width    : self.options.width,
    78                 mode     : self.options.mode,
    79                 palettes : self.options.palettes,
    80                 change   : function( event, ui ) {
     169                target: self.pickerContainer,
     170                hide: self.options.hide,
     171                width: self.options.width,
     172                mode: self.options.mode,
     173                palettes: self.options.palettes,
     174                /**
     175                 * @summary Handles the onChange event if one has been defined in the options.
     176                 *
     177                 * Handles the onChange event if one has been defined in the options and additionally
     178                 * sets the background color for the toggler element.
     179                 *
     180                 * @since 3.5.0
     181                 *
     182                 * @param {Event} event    The event that's being called.
     183                 * @param {HTMLElement} ui The HTMLElement containing the color picker.
     184                 *
     185                 * @returns {void}
     186                 */
     187                change: function( event, ui ) {
    81188                    if ( self.options.alpha ) {
    82                         self.toggler.css( { 'background-image' : 'url(' + image + ')' } ).html( '<span />' );
    83                         self.toggler.find( 'span' ).css( {
    84                             'width'                     : '100%',
    85                             'height'                    : '100%',
     189                        self.toggler.css( { 'background-image' : 'url(' + image + ')' } );
     190                        if ( _deprecated ) {
     191                            self.toggler.html( '<span class="color-alpha" />' );
     192                        } else {
     193                            self.toggler.css( {
     194                                'position' : 'relative'
     195                            } );
     196                            if ( self.toggler.find('span.color-alpha').length == 0 ) {
     197                                self.toggler.append('<span class="color-alpha" />');
     198                            }
     199                        }
     200
     201                        self.toggler.find( 'span.color-alpha' ).css( {
     202                            'width'                     : '30px',
     203                            'height'                    : '24px',
    86204                            'position'                  : 'absolute',
    87205                            'top'                       : 0,
    88206                            'left'                      : 0,
    89                             'border-top-left-radius'    : '3px',
    90                             'border-bottom-left-radius' : '3px',
     207                            'border-top-left-radius'    : '2px',
     208                            'border-bottom-left-radius' : '2px',
    91209                            'background'                : ui.color.toString()
    92210                        } );
     
    95213                    }
    96214
    97                     // Check for a custom cb
    98                     if ( $.isFunction( self.options.change ) )
     215                    if ( $.isFunction( self.options.change ) ) {
    99216                        self.options.change.call( this, event, ui );
     217                    }
    100218                }
    101219            } );
     
    104222            self._addListeners();
    105223
     224            // Force the color picker to always be closed on initial load.
    106225            if ( ! self.options.hide ) {
    107226                self.toggler.click();
    108227            }
    109228        },
     229        /**
     230         * @summary Binds event listeners to the color picker.
     231         *
     232         * @since 3.5.0
     233         *
     234         * @access private
     235         *
     236         * @returns {void}
     237         */
    110238        _addListeners: function() {
    111239            var self = this;
    112240
    113             // prevent any clicks inside this widget from leaking to the top and closing it
     241            /**
     242             * @summary Prevent any clicks inside this widget from leaking to the top and closing it.
     243             *
     244             * @since 3.5.0
     245             *
     246             * @param {Event} event The event that's being called.
     247             *
     248             * @returs {void}
     249             */
    114250            self.wrap.on( 'click.wpcolorpicker', function( event ) {
    115251                event.stopPropagation();
    116             } );
    117 
    118             self.toggler.on( 'click', function() {
     252            });
     253
     254            /**
     255             * @summary Open or close the color picker depending on the class.
     256             *
     257             * @since 3.5
     258             */
     259            self.toggler.click( function(){
    119260                if ( self.toggler.hasClass( 'wp-picker-open' ) ) {
    120261                    self.close();
     
    124265            });
    125266
     267            /**
     268             * @summary Checks if value is empty when changing the color in the color picker.
     269             *
     270             * Checks if value is empty when changing the color in the color picker.
     271             * If so, the background color is cleared.
     272             *
     273             * @since 3.5.0
     274             *
     275             * @param {Event} event The event that's being called.
     276             *
     277             * @returns {void}
     278             */
    126279            self.element.on( 'change', function( event ) {
    127280                // Empty or Error = clear
    128281                if ( $( this ).val() === '' || self.element.hasClass( 'iris-error' ) ) {
    129282                    if ( self.options.alpha ) {
    130                         self.toggler.removeAttr( 'style' );
    131                         self.toggler.find( 'span' ).css( 'backgroundColor', '' );
     283                        if ( _deprecated ) {
     284                            self.toggler.removeAttr( 'style' );
     285                        }
     286                        self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
    132287                    } else {
    133288                        self.toggler.css( 'backgroundColor', '' );
     
    140295            } );
    141296
    142             // open a keyboard-focused closed picker with space or enter
    143             self.toggler.on( 'keyup', function( event ) {
    144                 if ( event.keyCode === 13 || event.keyCode === 32 ) {
    145                     event.preventDefault();
    146                     self.toggler.trigger( 'click' ).next().focus();
    147                 }
    148             });
    149 
     297            /**
     298             * @summary Enables the user to clear or revert the color in the color picker.
     299             *
     300             * Enables the user to either clear the color in the color picker or revert back to the default color.
     301             *
     302             * @since 3.5.0
     303             *
     304             * @param {Event} event The event that's being called.
     305             *
     306             * @returns {void}
     307             */
    150308            self.button.on( 'click', function( event ) {
    151309                if ( $( this ).hasClass( 'wp-picker-clear' ) ) {
    152310                    self.element.val( '' );
    153311                    if ( self.options.alpha ) {
    154                         self.toggler.removeAttr( 'style' );
    155                         self.toggler.find( 'span' ).css( 'backgroundColor', '' );
     312                        if ( _deprecated ) {
     313                            self.toggler.removeAttr( 'style' );
     314                        }
     315                        self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
    156316                    } else {
    157317                        self.toggler.css( 'backgroundColor', '' );
     
    165325                }
    166326            });
    167         }
     327        },
    168328    });
    169329
     
    333493// Auto Call plugin is class is color-picker
    334494jQuery( document ).ready( function( $ ) {
    335     $( '#overlaycolor' ).wpColorPicker();
     495    $( '.color-picker' ).wpColorPicker();
    336496} );
  • visual-text-editor/trunk/readme.txt

    r1584270 r1829594  
    33Tags: visual,editor,wp, text, widget,content,admin, Bootstrap, builder, composer, CSS, drag, drop, edit, editor, file manager, fontawesome, Formatting, foundation, front end, front-end editor, frontend, icon, image, images, inline, inline editing, link, Live, page, plugin, Post, posts, TinyMCE, tinymce plugins, tinymceplugins, tool, visual, visual editor, visualeditor, wysiwyg, black, studio
    44Requires at least: 3.0.1
    5 Stable tag: 1.2
    6 Tested up to: 4.7
     5Stable tag: 1.2.1
     6Tested up to: 4.9.*
    77
    88License: GPLv2 or later
     
    4343== Changelog ==
    4444
     45= 1.2.1 =
     46* Fixed WP 4.9 Compatibility issue [Fixed]. [bug #6](https://github.com/emgk/visual-text-editor/issues/6)
     47 
    4548
    4649= 1.2 =
  • visual-text-editor/trunk/visual-text-editor.php

    r1585244 r1829594  
    55Author URI: http://emgk.github.io
    66Description: Replaces the default functionality of Text Widget editor with the WordPress visual editor, allowing you to use HTML in Widget and write them in rich text.
    7 Version: 1.2
     7Version: 1.2.1
    88Text Domain: visual-text-editor
    99Domain Path: /languages
Note: See TracChangeset for help on using the changeset viewer.