Changeset 1829594
- Timestamp:
- 02/26/2018 09:08:07 PM (8 years ago)
- Location:
- visual-text-editor
- Files:
-
- 7 edited
-
assets/banner-772x250.png (modified) (previous)
-
trunk/includes/class-admin.php (modified) (7 diffs)
-
trunk/includes/class-visual-editor.php (modified) (4 diffs)
-
trunk/includes/class-widget.php (modified) (3 diffs)
-
trunk/js/wp-color-picker-alpha.js (modified) (8 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/visual-text-editor.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
visual-text-editor/trunk/includes/class-admin.php
r1584270 r1829594 18 18 add_action( 'admin_init', array( $this, 'registerPluginSetting' ) ); 19 19 add_action( 'admin_head', array( $this, 'veChangeStyle' ) ); 20 add_shortcode( 'addcode',array( $this, 'addcode_callback' ) ); 20 21 21 22 if ( get_option( 'autop' ) == 'on' ) { … … 32 33 } 33 34 35 public function addcode_callback( $atts ) { 36 echo 'fdsfdsf'; 37 } 34 38 35 39 public function veChangeStyle() { … … 46 50 public function registerJSCSS() { 47 51 wp_enqueue_style( 'wp-color-picker' ); 48 wp_enqueue_style( 'wp-color-picker' );49 52 wp_enqueue_script( 'wp-color-picker-alpha', WPVE_URL . '/js/wp-color-picker-alpha.js', array( 'wp-color-picker' ), '1.2.2' ); 50 53 } … … 56 59 register_setting( 'wpvisualsettings', 'mediabuttons' ); 57 60 register_setting( 'wpvisualsettings', 'dragndrop' ); 58 register_setting( 'wpvisualsettings', 'visual_editor_mce' );59 61 60 62 add_action( 'admin_enqueue_scripts', array( $this, 'registerJSCSS' ) ); … … 64 66 add_menu_page( 'WP Text Widget Settings', 'WP Visual Text ', 'manage_options', 'wptextwidgetsettings', array( $this, 'veTextWidgetSetting' ), WPVE_URL . 'img/wpve-icon.png' ); 65 67 } 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 }77 68 78 69 public function veTextWidgetSetting() { 79 80 81 70 ?> 82 71 <h2><?php echo __('General Options','visual-text-editor');?></h2> 83 72 <hr/> 84 <?php85 86 if( $this->getnoticeboard() ){87 88 echo $this->getnoticeboard();89 }90 91 ?>92 73 <form action="options.php" method="post"> 93 74 <?php … … 102 83 <tr> 103 84 <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> 105 86 </tr> 106 87 <tr> … … 129 110 </td> 130 111 </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>139 112 </table> 140 113 <?php submit_button( 'Save Settings' );?> -
visual-text-editor/trunk/includes/class-visual-editor.php
r1584270 r1829594 17 17 private $mediabutton = false; 18 18 private $draganddrop = false; 19 20 /* 21 * @since 1.2 22 */ 23 private $visual_editor_mce = true; 19 private $editorheight ; 24 20 25 21 /* … … 44 40 if ( get_option( 'mediabuttons' ) == 'on' ) { 45 41 $this->mediabutton = true; 46 }47 48 if ( get_option( 'visual_editor_mce' ) == 'on' ) {49 $this->visual_editor_mce = false;50 42 } 51 43 … … 88 80 'wpautop' => $this->autop, 89 81 'media_buttons' => $this->mediabutton, 90 'tinymce' => $this->visual_editor_mce91 82 ); 92 83 … … 112 103 public function visualtext_phpgenerate( $atts, $content ){ 113 104 114 ob_start(); 115 echo eval( strip_tags( $content ) ); 116 $phpcontent = ob_get_clean(); 117 105 $phpcontent = eval( $content ); 118 106 return $phpcontent; 119 107 } -
visual-text-editor/trunk/includes/class-widget.php
r1584270 r1829594 36 36 echo $before_widget; 37 37 echo $before_title . $title . $after_title; 38 38 39 39 /** 40 40 * Fixed Shortcode issue … … 42 42 * since (may be since v4.4.0) the widget content is wrapped in a div with a "textwidget" class 43 43 */ 44 echo '<div class="textwidget">'; 44 45 $final_content = $this->generate_phpcode( do_shortcode($content) ); 45 46 echo '<div class="textwidget">';47 echo $final_content;48 46 echo '</div>'; 49 47 … … 83 81 public function generate_phpcode( $content ){ 84 82 85 ob_start();86 83 // Generate php code 87 echo eval('?> ' . $content . '<?php '); 88 89 $data = ob_get_clean(); 90 91 return $data; 84 return eval('?> ' . $content . '<?php '); 92 85 } 93 86 -
visual-text-editor/trunk/js/wp-color-picker-alpha.js
r1533908 r1829594 5 5 * Only run in input and is defined data alpha in true 6 6 * 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 10 9 * Licensed under the GPLv2 license. 11 10 */ 12 11 ( 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 ) 14 18 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 } 21 33 /** 22 34 * Overwrite Color … … 42 54 */ 43 55 $.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 */ 44 68 _create: function() { 45 // bail early for unsupported Iris.46 if ( ! $.support.iris ) 69 // Return early if Iris support is missing. 70 if ( ! $.support.iris ) { 47 71 return; 72 } 48 73 49 74 var self = this, 50 el = self.element; 51 75 el = self.element; 76 77 // Override default options with options bound to the element. 52 78 $.extend( self.options, el.data() ); 53 79 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. 55 86 self.close = $.proxy( self.close, self ); 56 87 57 88 self.initialValue = el.val(); 58 89 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. 66 140 if ( self.options.defaultColor ) { 67 141 self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString ); 142 if ( ! _deprecated ) { 143 self.button.attr( 'aria-label', wpColorPickerL10n.defaultAriaLabel ); 144 } 68 145 } else { 69 146 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 } 73 167 74 168 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 ) { 81 188 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', 86 204 'position' : 'absolute', 87 205 'top' : 0, 88 206 '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', 91 209 'background' : ui.color.toString() 92 210 } ); … … 95 213 } 96 214 97 // Check for a custom cb 98 if ( $.isFunction( self.options.change ) ) 215 if ( $.isFunction( self.options.change ) ) { 99 216 self.options.change.call( this, event, ui ); 217 } 100 218 } 101 219 } ); … … 104 222 self._addListeners(); 105 223 224 // Force the color picker to always be closed on initial load. 106 225 if ( ! self.options.hide ) { 107 226 self.toggler.click(); 108 227 } 109 228 }, 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 */ 110 238 _addListeners: function() { 111 239 var self = this; 112 240 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 */ 114 250 self.wrap.on( 'click.wpcolorpicker', function( event ) { 115 251 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(){ 119 260 if ( self.toggler.hasClass( 'wp-picker-open' ) ) { 120 261 self.close(); … … 124 265 }); 125 266 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 */ 126 279 self.element.on( 'change', function( event ) { 127 280 // Empty or Error = clear 128 281 if ( $( this ).val() === '' || self.element.hasClass( 'iris-error' ) ) { 129 282 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', '' ); 132 287 } else { 133 288 self.toggler.css( 'backgroundColor', '' ); … … 140 295 } ); 141 296 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 */ 150 308 self.button.on( 'click', function( event ) { 151 309 if ( $( this ).hasClass( 'wp-picker-clear' ) ) { 152 310 self.element.val( '' ); 153 311 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', '' ); 156 316 } else { 157 317 self.toggler.css( 'backgroundColor', '' ); … … 165 325 } 166 326 }); 167 } 327 }, 168 328 }); 169 329 … … 333 493 // Auto Call plugin is class is color-picker 334 494 jQuery( document ).ready( function( $ ) { 335 $( ' #overlaycolor' ).wpColorPicker();495 $( '.color-picker' ).wpColorPicker(); 336 496 } ); -
visual-text-editor/trunk/readme.txt
r1584270 r1829594 3 3 Tags: 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 4 4 Requires at least: 3.0.1 5 Stable tag: 1.2 6 Tested up to: 4. 75 Stable tag: 1.2.1 6 Tested up to: 4.9.* 7 7 8 8 License: GPLv2 or later … … 43 43 == Changelog == 44 44 45 = 1.2.1 = 46 * Fixed WP 4.9 Compatibility issue [Fixed]. [bug #6](https://github.com/emgk/visual-text-editor/issues/6) 47 45 48 46 49 = 1.2 = -
visual-text-editor/trunk/visual-text-editor.php
r1585244 r1829594 5 5 Author URI: http://emgk.github.io 6 6 Description: 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 7 Version: 1.2.1 8 8 Text Domain: visual-text-editor 9 9 Domain Path: /languages
Note: See TracChangeset
for help on using the changeset viewer.