- Timestamp:
- 01/04/2013 06:43:46 PM (12 years ago)
- Location:
- wpide/trunk
- Files:
- 7 added
- 5 edited
- WPide.php (modified) (18 diffs)
- images/color-wheel.png (added)
- jqueryFileTree.js (modified) (3 diffs)
- js/ImageColorPicker.js (added)
- js/autocomplete (added)
- js/autocomplete/php.js (added)
- js/autocomplete/wordpress.js (added)
- js/jquery-ui-1.9.2.custom.min.js (added)
- js/load-editor.js (modified) (6 diffs)
- readme.txt (modified) (7 diffs)
- screenshot-4.jpg (added)
- wpide.css (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
wpide/trunk/WPide.php
r549142 r647959 4 4 Plugin URI: https://.com/WPsites/WPide 5 5 Description: WordPress code editor with auto completion of both WordPress and PHP functions with reference, syntax highlighting, line numbers, tabbed editing, automatic backup. 6 Version: 2.0.1 26 Version: 2.0.13 7 7 Author: Simon Dunton 8 8 Author URI: http://www.wpsites.co.uk … … 50 50 51 51 52 //force local file method for testing - you could force other methods 'direct', 'ssh', 'ftpext' or 'ftpsockets' 52 // force local file method until I've worked out how to implement the other methods 53 // main problem being password wouldn't/isn't saved between requests 54 // you could force other methods 'direct', 'ssh', 'ftpext' or 'ftpsockets' 53 55 $this->override_fs_method('direct'); 54 56 … … 71 73 //setup ajax function for startup to get some debug info, checking permissions etc 72 74 add_action('wp_ajax_wpide_startup_check', array( $this, 'wpide_startup_check' ) ); 73 74 75 76 //add a warning when navigating away from WPide 77 //it has to go after WordPress scripts otherwise WP clears the binding 78 add_action('admin_print_footer_scripts', array( $this, 'add_admin_nav_warning' ), 99 ); 79 75 80 } 76 81 … … 100 105 } 101 106 102 public static function add_admin_ head()107 public static function add_admin_nav_warning() 103 108 { 104 109 ?> 110 <script type="text/javascript"> 111 112 jQuery(document).ready(function($) { 113 window.onbeforeunload = function() { 114 return 'You are attempting to navigate away from WPide. Make sure you have saved any changes made to your files otherwise they will be forgotten.' ; 115 } 116 }); 117 118 </script> 119 <?php 105 120 } 106 121 … … 124 139 wp_enqueue_script('ace-theme', plugins_url("ace-0.2.0/src/theme-dawn.js", __FILE__ ) );//monokai is nice 125 140 // wordpress-completion tags 126 wp_enqueue_script('wpide-wordpress-completion', plugins_url("js/autocomplete .wordpress.js", __FILE__ ) );141 wp_enqueue_script('wpide-wordpress-completion', plugins_url("js/autocomplete/wordpress.js", __FILE__ ) ); 127 142 // php-completion tags 128 wp_enqueue_script('wpide-php-completion', plugins_url("js/autocomplete .php.js", __FILE__ ) );143 wp_enqueue_script('wpide-php-completion', plugins_url("js/autocomplete/php.js", __FILE__ ) ); 129 144 // load editor 130 145 wp_enqueue_script('wpide-load-editor', plugins_url("js/load-editor.js", __FILE__ ) ); … … 133 148 134 149 // load jquery ui 135 wp_enqueue_script('jquery-ui', plugins_url("js/jquery-ui-1.8.20.custom.min.js", __FILE__ ), array('jquery'), '1.8.20'); 150 wp_enqueue_script('jquery-ui', plugins_url("js/jquery-ui-1.9.2.custom.min.js", __FILE__ ), array('jquery'), '1.9.2'); 151 152 // load color picker 153 wp_enqueue_script('ImageColorPicker', plugins_url("js/ImageColorPicker.js", __FILE__ ), array('jquery'), '0.3'); 136 154 137 138 155 139 156 … … 169 186 //setup wp_filesystem api 170 187 global $wp_filesystem; 188 $url = wp_nonce_url('admin.php?page=wpide','plugin-name-action_wpidenonce'); 189 $form_fields = null; // for now, but at some point the login info should be passed in here 190 if (false === ($creds = request_filesystem_credentials($url, FS_METHOD, false, false, $form_fields) ) ) { 191 // no credentials yet, just produced a form for the user to fill in 192 return true; // stop the normal page form from displaying 193 } 194 171 195 if ( ! WP_Filesystem($creds) ) 172 196 return false; 173 197 174 198 $_POST['dir'] = urldecode($_POST['dir']); 175 $root = WP_CONTENT_DIR; 199 $root = apply_filters( 'wpide_filesystem_root', WP_CONTENT_DIR ); 176 200 177 201 if( $wp_filesystem->exists($root . $_POST['dir']) ) { … … 215 239 //setup wp_filesystem api 216 240 global $wp_filesystem; 241 $url = wp_nonce_url('admin.php?page=wpide','plugin-name-action_wpidenonce'); 242 $form_fields = null; // for now, but at some point the login info should be passed in here 243 if (false === ($creds = request_filesystem_credentials($url, FS_METHOD, false, false, $form_fields) ) ) { 244 // no credentials yet, just produced a form for the user to fill in 245 return true; // stop the normal page form from displaying 246 } 217 247 if ( ! WP_Filesystem($creds) ) 218 248 return false; 219 249 220 250 221 $root = WP_CONTENT_DIR;251 $root = apply_filters( 'wpide_filesystem_root', WP_CONTENT_DIR ); 222 252 $file_name = $root . stripslashes($_POST['filename']); 223 253 echo $wp_filesystem->get_contents($file_name); … … 247 277 //setup wp_filesystem api 248 278 global $wp_filesystem; 279 $url = wp_nonce_url('admin.php?page=wpide','plugin-name-action_wpidenonce'); 280 $form_fields = null; // for now, but at some point the login info should be passed in here 281 if (false === ($creds = request_filesystem_credentials($url, FS_METHOD, false, false, $form_fields) ) ) { 282 // no credentials yet, just produced a form for the user to fill in 283 return true; // stop the normal page form from displaying 284 } 249 285 if ( ! WP_Filesystem($creds) ) 250 286 return false; 251 287 252 $root = WP_CONTENT_DIR;288 $root = apply_filters( 'wpide_filesystem_root', WP_CONTENT_DIR ); 253 289 254 290 //check all required vars are passed … … 303 339 //setup wp_filesystem api 304 340 global $wp_filesystem; 341 $url = wp_nonce_url('admin.php?page=wpide','plugin-name-action_wpidenonce'); 342 $form_fields = null; // for now, but at some point the login info should be passed in here 343 if (false === ($creds = request_filesystem_credentials($url, FS_METHOD, false, false, $form_fields) ) ) { 344 // no credentials yet, just produced a form for the user to fill in 345 return true; // stop the normal page form from displaying 346 } 305 347 if ( ! WP_Filesystem($creds) ) 306 348 echo "Cannot initialise the WP file system API"; 307 349 308 350 //save a copy of the file and create a backup just in case 309 $root = WP_CONTENT_DIR;351 $root = apply_filters( 'wpide_filesystem_root', WP_CONTENT_DIR ); 310 352 $file_name = $root . stripslashes($_POST['filename']); 311 353 … … 348 390 //setup wp_filesystem api 349 391 global $wp_filesystem; 350 392 $url = wp_nonce_url('admin.php?page=wpide','plugin-name-action_wpidenonce'); 393 $form_fields = null; // for now, but at some point the login info should be passed in here 394 if (false === ($creds = request_filesystem_credentials($url, FS_METHOD, false, false, $form_fields) ) ) { 395 // no credentials yet, just produced a form for the user to fill in 396 return true; // stop the normal page form from displaying 397 } 351 398 if ( ! WP_Filesystem($creds) ) 352 399 echo "Cannot initialise the WP file system API"; 353 400 354 401 //save a copy of the file and create a backup just in case 355 $root = WP_CONTENT_DIR;402 $root = apply_filters( 'wpide_filesystem_root', WP_CONTENT_DIR ); 356 403 $file_name = $root . stripslashes($_POST['filename']); 357 404 … … 386 433 global $wp_filesystem, $wp_version; 387 434 388 echo "\n\n\n\nWPIDE STAR UP CHECKS \n";435 echo "\n\n\n\nWPIDE STARTUP CHECKS \n"; 389 436 echo "___________________ \n\n"; 390 437 … … 407 454 //setup wp_filesystem api 408 455 $wpide_filesystem_before = $wp_filesystem; 456 457 $url = wp_nonce_url('admin.php?page=wpide','plugin-name-action_wpidenonce'); 458 $form_fields = null; // for now, but at some point the login info should be passed in here 459 ob_start(); 460 if (false === ($creds = request_filesystem_credentials($url, FS_METHOD, false, false, $form_fields) ) ) { 461 // if we get here, then we don't have credentials yet, 462 // but have just produced a form for the user to fill in, 463 // so stop processing for now 464 //return true; // stop the normal page form from displaying 465 } 466 ob_end_clean(); 409 467 if ( ! WP_Filesystem($creds) ) { 410 468 … … 417 475 418 476 419 $root = WP_CONTENT_DIR;420 477 $root = apply_filters( 'wpide_filesystem_root', WP_CONTENT_DIR ); 478 if ( isset($wp_filesystem) ){ 421 479 422 480 //Running webservers user and group … … 451 509 echo "The wp-content/themes folder ". ( $wp_filesystem->is_readable( $root."/themes" )==1 ? "IS":"IS NOT" ) ." readable and ". ( $wp_filesystem->is_writable( $root."/themes" )==1 ? "IS":"IS NOT" ) ." writable by this method \n"; 452 510 453 511 } 454 512 455 513 echo "___________________ \n\n\n\n"; … … 504 562 505 563 var wpide_app_path = "<?php echo plugin_dir_url( __FILE__ ); ?>"; 564 //dont think this is needed any more.. var wpide_file_root_url = "<?php echo apply_filters("wpide_file_root_url", WP_CONTENT_URL );?>"; 506 565 507 566 function the_filetree() { … … 581 640 } 582 641 642 643 583 644 jQuery(document).ready(function($) { 645 584 646 // Handler for .ready() called. 585 647 the_filetree() ; 586 648 587 588 589 590 649 //inialise the color assist 650 $("#wpide_color_assist img").ImageColorPicker({ 651 afterColorSelected: function(event, color){ 652 jQuery("#wpide_color_assist_input").val(color); 653 } 654 }); 655 $("#wpide_color_assist").hide(); //hide it until it's needed 656 657 $("#wpide_color_assist_send").click(function(e){ 658 e.preventDefault(); 659 editor.insert( jQuery("#wpide_color_assist_input").val().replace('#', '') ); 660 661 $("#wpide_color_assist").hide(); //hide it until it's needed again 662 }); 663 664 $(".close_color_picker a").click(function(e){ 665 e.preventDefault(); 666 $("#wpide_color_assist").hide(); //hide it until it's needed again 667 }); 668 669 670 591 671 592 672 }); 593 673 </script> 594 674 595 <?php 596 $url = wp_nonce_url('admin.php?page=wpide','plugin-name-action_wpidenonce'); 597 if ( ! WP_Filesystem($creds) ) { 598 request_filesystem_credentials($url, '', true, false, null); 599 return; 600 } 601 ?> 675 602 676 603 677 <div id="poststuff" class="metabox-holder has-right-sidebar"> … … 605 679 <div id="side-info-column" class="inner-sidebar"> 606 680 607 <div id="wpide_info"><div id="wpide_info_content"></div> </div> 681 <div id="wpide_info"> 682 <div id="wpide_info_content"></div> 683 </div> 684 <br style="clear:both;" /> 685 <div id="wpide_color_assist"> 686 <div class="close_color_picker"><a href="close-color-picker">x</a></div> 687 <h3>Colour Assist</h3> 688 <img src='<?php echo plugins_url("images/color-wheel.png", __FILE__ ); ?>' /> 689 <input type="button" class="button" id="wpide_color_assist_send" value="< Send to editor" /> 690 <input type="text" id="wpide_color_assist_input" name="wpide_color_assist_input" value="" /> 691 692 </div> 693 694 608 695 609 696 <div id="submitdiv" class="postbox "> wpide/trunk/jqueryFileTree.js
r548058 r647959 57 57 if( o.root == t ) $(c).find('UL:hidden').show(); else $(c).find('UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing }); 58 58 bindTree(c); 59 60 //make files draggable 61 $("li.file", $("#wpide_file_browser") ).draggable({ 62 cursor: "move", 63 handle: "a", 64 cursorAt: { top: 20, left: 20 }, 65 helper: function( event ) { 66 return $( "<div>Image Path</div>" ); 67 } 68 }); 69 59 70 }); 60 71 } … … 80 91 h($(this).parent(), $(this).attr('rel')); 81 92 } 93 94 95 82 96 return false; 83 97 }); … … 91 105 showTree( $(this), escape(o.root) ); 92 106 jQuery.ajaxSetup({async:true}); //enable async again 107 108 93 109 94 110 //if nothing returned then let user know something wrong with permissions wpide/trunk/js/load-editor.js
r549142 r647959 87 87 88 88 range.end.column = editor.getSession().getSelection().getCursor().column +1;//set end column as cursor pos 89 89 90 90 //console.log("[ \.] based: " + editor.getSession().doc.getTextRange(range)); 91 91 … … 311 311 //clear the text in the command help panel 312 312 //jQuery("#wpide_info_content").html(""); 313 } 314 315 function selectionChanged(e) { 316 var selected_text = editor.getSession().doc.getTextRange(editor.getSelectionRange()); 317 318 //check for hex colour match 319 if ( selected_text.match('^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$') != null ){ 320 321 var therange = editor.getSelectionRange(); 322 therange.end.column = therange.start.column; 323 therange.start.column = therange.start.column-1; 324 325 // only show color assist if the character before the selection indicates a hex color (#) 326 if ( editor.getSession().doc.getTextRange( therange ) == "#" ){ 327 jQuery("#wpide_color_assist").show(); 328 } 329 330 } 313 331 } 314 332 … … 472 490 editor.getSession().on('change', onSessionChange); 473 491 492 editor.getSession().selection.on('changeSelection', selectionChanged); 493 474 494 editor.resize(); 475 495 editor.focus(); … … 565 585 jQuery(document).ready(function($) { 566 586 $("#wpide_save").click(saveDocument); 567 587 588 // drag and drop colour picker image 589 $("#wpide_color_assist").on('drop', function(e) { 590 e.preventDefault(); 591 e.originalEvent.dataTransfer.items[0].getAsString(function(url){ 592 593 $(".ImageColorPickerCanvas", $("#side-info-column") ).remove(); 594 $("img", $("#wpide_color_assist")).attr('src', url ); 595 596 }); 597 }); 598 599 $("#wpide_color_assist").on('dragover', function(e) { 600 $(this).addClass("hover"); 601 }).on('dragleave', function(e) { 602 $(this).removeClass("hover"); 603 }); 568 604 569 605 570 606 //add div for ace editor to latch on to 571 //$('#template').prepend("<div style='width:80%;height:500px;margin-right:0!important;' id='fancyeditordiv'></div>");607 $('#template').prepend("<div style='width:80%;height:500px;margin-right:0!important;' id='fancyeditordiv'></div>"); 572 608 //create the editor instance 573 609 editor = ace.edit("fancyeditordiv"); … … 637 673 //show command help panel for this command 638 674 wpide_function_help(); 639 console.log("handler is visible");675 //console.log("handler is visible"); 640 676 641 677 }else if( document.getElementById('ac').style.display === 'block' ) { … … 646 682 select.selectedIndex = select.selectedIndex-1; 647 683 } 648 console.log("ac is visible");684 //console.log("ac is visible"); 649 685 } else { 650 686 var range = editor.getSelectionRange(); wpide/trunk/readme.txt
r549142 r647959 3 3 Tags: code, theme editor, plugin editor, code editor 4 4 Requires at least: 3.0 5 Tested up to: 3. 3.26 Stable tag: 2.0.1 25 Tested up to: 3.5 6 Stable tag: 2.0.13 7 7 8 8 WordPress code editor with auto completion of both WordPress and PHP functions with reference, syntax highlighting, line numbers, tabbed editing, automatic backup. … … 23 23 * Line numbers 24 24 * Code autocomplete for WordPress and PHP functions along with function description, arguments and return value where applicable 25 * Colour assist - a colour picker that only shows once you double click a hex colour code in the editor. You can also drag your own image into the colour picker to use instead of the default swatch (see other notes for info). 25 26 * Automatic backup of every file you edit. (one daily backup and one hourly backup of each file stored in plugins/WPide/backups/filepath) 26 27 * File tree allowing you to access and edit any file in your wp-content folder (plugins, themes, uploads etc) … … 31 32 * Tabbed interface for editing multiple files (editing both plugin and theme files at the same time) 32 33 * Using the WordPress filesystem API, although currently direct access is forced (edit WPide.php in the constructor to change this behaviour) ftp/ssh connections aren't setup yet, since WP will not remember a password need to work out how that will work. Maybe use modal to request password when you save but be able to click save all and save a batch with that password. Passwords defined in wp-config.php are persistent and would fix this problem but people don't generally add those details. Open to ideas here. 33 * Image editing/drawing ( requires Flash - will move over to HTML5 when there is a decent alternative)34 * Image editing/drawing (this is currently not working..) 34 35 35 36 = Feature ideas and improvements: = … … 44 45 45 46 As with most plugins this one is open source. For issue tracking, further information and anyone wishing to get involved and help contribute to this project can do so over on https://.com/WPsites/WPide 46 47 == Contributors ==48 49 Simon Dunton - http://www.wpsites.co.uk50 Thomas Wieczorek - http://www.wieczo.net51 47 52 48 … … 74 70 2. Image editor in action 75 71 3. Showing auto complete, function reference and file tree. 72 4. Default colour picker image 76 73 77 74 == Changelog == 75 76 = 2.0.13 = 77 * Added colour assist - a colour picker that displays when you double click a hex colour code in the editor (see other notes for info). 78 * Added a confirm box to stop you exiting the editor by mistake and losing unsaved chnages. 79 * Added 'wpide_filesystem_root' filter (see other notes for info). 80 * A number of bug fixes. 78 81 79 82 = 2.0.12 = … … 146 149 * Initial release. 147 150 148 == DEV NOTES == 151 == Other Feature notes == 152 153 = You can modify the filesystem root using the 'wpide_filesystem_root' filter = 154 155 So to restrict editing to the Twenty Eleven theme only you could do this: 156 157 add_filter('wpide_filesystem_root', 'wpide_filesystem_root_override'); 158 function wpide_filesystem_root_override($path){ 159 // the default path variable will be WP_CONTENT_DIR 160 return $path . "/themes/twentyeleven"; 161 } 162 163 = Colour assist = 164 165 The colour picker only shows if you double click a hex colour value in the editor (3 or 6 characters with a proceeding hash #FF0000) 166 167 The default colour picker has limited colours. You can replace this image with an image of your own by dragging and dropping a new image onto the default one (due to security reasons this can only be an image from the same domain). 168 169 Using this you can either create your own swatch of colours or just drag in your websites logo or header image. 170 171 If you close the editor any custom colour picker image will be forgotten. We maybe thing about making this persist and also make the image uploadable as well as drag+drop. 172 173 == Dev Notes == 149 174 150 175 Maybe some interesting things here we could implement to help with following the WordPress standard and more advanced code syntax checking … … 154 179 Checkout the following WordPress plugin "WP Live CSS Editor" to work out how to do LIVE css editing. Combining a LESS compiler with live CSS editing/compile would be a dream. 155 180 181 https://.com/lennie/git-webcommit/ may be a route to git functionality 182 183 == Contributors == 184 185 Simon Dunton - http://www.wpsites.co.uk 186 Thomas Wieczorek - http://www.wieczo.net wpide/trunk/wpide.css
r543896 r647959 126 126 background-color:#f4f4f4; 127 127 color:#aaa; 128 z-index:999; 128 129 } 129 130 #wpide_save_container{ … … 225 226 min-width:220px; 226 227 } 227 228 229 230 228 229 /* color assist */ 230 .ImageColorPickerWrapper{ 231 height: 300px; 232 width: 100%; 233 overflow: scroll; 234 } 235 #wpide_color_assist{ 236 position:relative; 237 width: 100%; 238 background-color: whiteSmoke; 239 margin: auto; 240 border: 1px solid #CCC; 241 padding-right: 2px; 242 margin-left: -2px; 243 height: 380px; 244 } 245 #wpide_color_assist img, #wpide_color_assist canvas{ 246 margin:auto; 247 display:block; 248 } 249 #wpide_color_assist canvas.ImageColorPickerCanvasColor{ 250 position:absolute; 251 left:0; 252 top:0; 253 } 254 #wpide_color_assist input[type=button]{ 255 float:left; 256 width:110px; 257 margin: 15px 5px; 258 font-size: 12px; 259 } 260 #wpide_color_assist_input{ 261 float:left; 262 width:100px; 263 margin: 15px 5px; 264 } 265 266 .close_color_picker{ 267 padding-bottom: 7px; 268 padding-left: 7px; 269 position: absolute; 270 right: 20px; 271 top: 5px; 272 } 273 .close_color_picker a{ 274 color: #575757; 275 font-style: normal; 276 text-decoration: none; 277 font-size: 16px; 278 } 279 280 #wpide_color_assist h3{ 281 background-color: #F1F1F1; 282 background-image: -ms-linear-gradient(top,#F9F9F9,#ECECEC); 283 background-image: -moz-linear-gradient(top,#F9F9F9,#ECECEC); 284 background-image: -o-linear-gradient(top,#F9F9F9,#ECECEC); 285 background-image: -webkit-gradient(linear,left top,left bottom,from(#F9F9F9),to(#ECECEC)); 286 background-image: -webkit-linear-gradient(top,#F9F9F9,#ECECEC); 287 background-image: linear-gradient(top,#F9F9F9,#ECECEC); 288 289 -webkit-border-top-left-radius: 3px; 290 -webkit-border-top-right-radius: 3px; 291 border-top-left-radius: 3px; 292 border-top-right-radius: 3px; 293 } 294 295 .currentColor, .selectedColor { 296 border: 1px solid #000; 297 background-color: #fff; 298 width:30px; 299 height:30px; 300 } 301 302 .ImageColorPickerCanvas { 303 cursor:crosshair; 304 } 305 306 div.ImageColorPickerWrapper{ 307 308 } 309 310 311 312 313 314
Note: See TracChangeset for help on using the changeset viewer.