Plugin Directory

Changeset 647959 for wpide


Ignore:
Timestamp:
01/04/2013 06:43:46 PM (12 years ago)
Author:
WPsites
Message:

2.0.13

Location:
wpide/trunk
Files:
7 added
5 edited

Legend:

Unmodified
Added
Removed
  • wpide/trunk/WPide.php

    r549142r647959 
    44Plugin URI: https://.com/WPsites/WPide
    55Description: 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.12
     6Version: 2.0.13
    77Author: Simon Dunton
    88Author URI: http://www.wpsites.co.uk
     
    5050               
    5151               
    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'
    5355            $this->override_fs_method('direct');
    5456
     
    7173            //setup ajax function for startup to get some debug info, checking permissions etc
    7274            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           
    7580        }
    7681       
     
    100105    }
    101106
    102     public static function add_admin_head()
     107    public static function add_admin_nav_warning()
    103108    {
    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
    105120    }
    106121
     
    124139            wp_enqueue_script('ace-theme', plugins_url("ace-0.2.0/src/theme-dawn.js", __FILE__ ) );//monokai is nice
    125140            // 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__ ) );
    127142            // 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__ ) );
    129144            // load editor
    130145            wp_enqueue_script('wpide-load-editor', plugins_url("js/load-editor.js", __FILE__ ) );
     
    133148           
    134149             // 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');
    136154           
    137            
    138155   
    139156   
     
    169186        //setup wp_filesystem api
    170187        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       
    171195        if ( ! WP_Filesystem($creds) )
    172196            return false;
    173197       
    174198        $_POST['dir'] = urldecode($_POST['dir']);
    175         $root = WP_CONTENT_DIR;
     199        $root = apply_filters( 'wpide_filesystem_root', WP_CONTENT_DIR );
    176200       
    177201        if( $wp_filesystem->exists($root . $_POST['dir']) ) {
     
    215239        //setup wp_filesystem api
    216240        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        }
    217247        if ( ! WP_Filesystem($creds) )
    218248            return false;
    219249       
    220250         
    221         $root = WP_CONTENT_DIR;
     251        $root = apply_filters( 'wpide_filesystem_root', WP_CONTENT_DIR );
    222252        $file_name = $root . stripslashes($_POST['filename']);
    223253        echo $wp_filesystem->get_contents($file_name);
     
    247277        //setup wp_filesystem api
    248278        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        }
    249285        if ( ! WP_Filesystem($creds) )
    250286            return false;
    251287       
    252         $root = WP_CONTENT_DIR;
     288        $root = apply_filters( 'wpide_filesystem_root', WP_CONTENT_DIR );
    253289       
    254290        //check all required vars are passed
     
    303339        //setup wp_filesystem api
    304340        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        }
    305347        if ( ! WP_Filesystem($creds) )
    306348            echo "Cannot initialise the WP file system API";
    307349       
    308350        //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 );
    310352        $file_name = $root . stripslashes($_POST['filename']);
    311353       
     
    348390            //setup wp_filesystem api
    349391            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            }
    351398            if ( ! WP_Filesystem($creds) )
    352399                echo "Cannot initialise the WP file system API";
    353400           
    354401            //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 );
    356403            $file_name = $root . stripslashes($_POST['filename']);
    357404           
     
    386433        global $wp_filesystem, $wp_version;
    387434       
    388         echo "\n\n\n\nWPIDE STARUP CHECKS \n";
     435        echo "\n\n\n\nWPIDE STARTUP CHECKS \n";
    389436        echo "___________________ \n\n";
    390437       
     
    407454        //setup wp_filesystem api
    408455        $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();
    409467        if ( ! WP_Filesystem($creds) ) {
    410468           
     
    417475       
    418476
    419         $root = WP_CONTENT_DIR;
    420        
     477        $root = apply_filters( 'wpide_filesystem_root', WP_CONTENT_DIR );
     478        if ( isset($wp_filesystem) ){
    421479           
    422480        //Running webservers user and group
     
    451509        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";
    452510     
    453        
     511        }
    454512       
    455513        echo "___________________ \n\n\n\n";
     
    504562
    505563            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 );?>";
    506565           
    507566            function the_filetree() {
     
    581640            }
    582641           
     642         
     643           
    583644            jQuery(document).ready(function($) {
     645                 
    584646                // Handler for .ready() called.
    585647                the_filetree() ;
    586648               
    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               
    591671               
    592672            });
    593673        </script>
    594674       
    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
    602676       
    603677        <div id="poststuff" class="metabox-holder has-right-sidebar">
     
    605679            <div id="side-info-column" class="inner-sidebar">
    606680               
    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="&lt; Send to editor" />
     690                    <input type="text" id="wpide_color_assist_input" name="wpide_color_assist_input" value="" />
     691                   
     692                </div>
     693               
     694                 
    608695       
    609696                <div id="submitdiv" class="postbox ">
  • wpide/trunk/jqueryFileTree.js

    r548058r647959 
    5757                        if( o.root == t ) $(c).find('UL:hidden').show(); else $(c).find('UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing });
    5858                        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               
    5970                    });
    6071                }
     
    8091                            h($(this).parent(), $(this).attr('rel'));
    8192                        }
     93                       
     94 
     95       
    8296                        return false;
    8397                    });
     
    91105                showTree( $(this), escape(o.root) );
    92106                jQuery.ajaxSetup({async:true}); //enable async again
     107               
     108
    93109               
    94110                //if nothing returned then let user know something wrong with permissions
  • wpide/trunk/js/load-editor.js

    r549142r647959 
    8787   
    8888    range.end.column = editor.getSession().getSelection().getCursor().column +1;//set end column as cursor pos
    89    
     89
    9090    //console.log("[ \.] based: " + editor.getSession().doc.getTextRange(range));
    9191   
     
    311311    //clear the text in the command help panel
    312312    //jQuery("#wpide_info_content").html("");
     313}
     314
     315function 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    }
    313331}
    314332
     
    472490            editor.getSession().on('change', onSessionChange);
    473491           
     492            editor.getSession().selection.on('changeSelection', selectionChanged);
     493           
    474494            editor.resize();
    475495            editor.focus();
     
    565585jQuery(document).ready(function($) {
    566586    $("#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    });
    568604
    569605   
    570606    //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>");
    572608    //create the editor instance
    573609    editor = ace.edit("fancyeditordiv");
     
    637673                //show command help panel for this command
    638674                wpide_function_help();
    639                 console.log("handler is visible");
     675                //console.log("handler is visible");
    640676               
    641677            }else if( document.getElementById('ac').style.display === 'block'  ) {
     
    646682                    select.selectedIndex = select.selectedIndex-1;
    647683                }
    648                  console.log("ac is visible");
     684                 //console.log("ac is visible");
    649685            } else {
    650686                var range = editor.getSelectionRange();
  • wpide/trunk/readme.txt

    r549142r647959 
    33Tags: code, theme editor, plugin editor, code editor
    44Requires at least: 3.0
    5 Tested up to: 3.3.2
    6 Stable tag: 2.0.12
     5Tested up to: 3.5
     6Stable tag: 2.0.13
    77
    88WordPress code editor with auto completion of both WordPress and PHP functions with reference, syntax highlighting, line numbers, tabbed editing, automatic backup.
     
    2323*   Line numbers
    2424*   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).
    2526*   Automatic backup of every file you edit. (one daily backup and one hourly backup of each file stored in plugins/WPide/backups/filepath)
    2627*   File tree allowing you to access and edit any file in your wp-content folder (plugins, themes, uploads etc)
     
    3132*   Tabbed interface for editing multiple files (editing both plugin and theme files at the same time)
    3233*   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..)
    3435
    3536= Feature ideas and improvements: =
     
    4445
    4546As 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.uk
    50 Thomas Wieczorek - http://www.wieczo.net
    5147
    5248
     
    74702. Image editor in action
    75713. Showing auto complete, function reference and file tree.
     724. Default colour picker image
    7673
    7774== 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.
    7881
    7982= 2.0.12 =
     
    146149* Initial release.
    147150
    148 == DEV NOTES ==
     151== Other Feature notes ==
     152
     153= You can modify the filesystem root using the 'wpide_filesystem_root' filter =
     154
     155So to restrict editing to the Twenty Eleven theme only you could do this:
     156
     157add_filter('wpide_filesystem_root', 'wpide_filesystem_root_override');
     158function 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
     165The 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
     167The 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
     169Using this you can either create your own swatch of colours or just drag in your websites logo or header image.
     170
     171If 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 ==
    149174
    150175Maybe some interesting things here we could implement to help with following the WordPress standard and more advanced code syntax checking
     
    154179Checkout 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.
    155180
     181https://.com/lennie/git-webcommit/ may be a route to git functionality
     182
     183== Contributors ==
     184
     185Simon Dunton - http://www.wpsites.co.uk
     186Thomas Wieczorek - http://www.wieczo.net
  • wpide/trunk/wpide.css

    r543896r647959 
    126126            background-color:#f4f4f4;
    127127            color:#aaa;
     128            z-index:999;
    128129        }
    129130    #wpide_save_container{
     
    225226                min-width:220px;
    226227        }
    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
     306div.ImageColorPickerWrapper{
     307 
     308}
     309
     310
     311
     312
     313
     314       
Note: See TracChangeset for help on using the changeset viewer.