Version Description
- Tidy and comment code
- Added message when backup file is generated
- Adjust code complete dropdown position
- Improved editor responsiveness when using delete or enter keys
Download this release
Release Info
Developer | WPsites |
Plugin | WPide |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
- WPide.php +244 -1170
- readme.txt +67 -61
WPide.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: WPide
|
5 |
Plugin URI: https://github.com/WPsites/WPide
|
6 |
Description: Replace the default WordPress code editor for plugins and themes. Adding syntax highlighting, autocomplete of WordPress functions + PHP, line numbers, auto backup of files before editing.
|
7 |
-
Version: 1.0.
|
8 |
Author: Simon Dunton
|
9 |
Author URI: http://www.wpsites.co.uk
|
10 |
|
@@ -19,184 +19,34 @@ class WPide
|
|
19 |
|
20 |
function __construct() {
|
21 |
|
22 |
-
|
23 |
-
|
24 |
// Uncomment any of these calls to add the functionality that you need.
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
add_action('admin_head', 'WPide::add_admin_head');
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
add_action('admin_head', 'WPide::load_editor');
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
add_action('admin_init', 'WPide::add_admin_js');
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
//setup ajax function to save a backup
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
add_action('wp_ajax_ace_backup_call', 'WPide::ace_backup_call');
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
}
|
65 |
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
public static function add_admin_head()
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
{
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
?>
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
<style type="text/css">
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
#quicktags, #post-status-info, #editor-toolbar, #newcontent, .ace_print_margin { display: none; }
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
#fancyeditordiv {
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
position: relative;
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
width: 500px;
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
height: 400px;
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
}
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
#template div{margin-right:0 !important;}
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
</style>
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
|
192 |
<?php
|
193 |
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
}
|
201 |
|
202 |
|
@@ -214,21 +64,7 @@ class WPide
|
|
214 |
|
215 |
|
216 |
public static function load_editor()
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
{
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
?>
|
233 |
|
234 |
|
@@ -238,29 +74,10 @@ class WPide
|
|
238 |
|
239 |
|
240 |
<script>
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
var autocompleting = false;
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
var autocompletelength = 2;
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
var editor = '';
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
var html_tags = ("_() __() __checked_selected_helper() __construct() __destruct() __get_option() " +
|
265 |
|
266 |
"__ngettext() __ngettext_noop() __set() __tostring() _add_themes_utility_last() _added() " +
|
@@ -1641,1146 +1458,403 @@ var html_tags = ("_() __() __checked_selected_helper() __construct() __destruct(
|
|
1641 |
|
1642 |
jQuery(document).ready(function($) {
|
1643 |
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
//quit if editing this plugin since it will spaz out!!
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
if ( $('input[name=file]').val() == 'ace/ace.php' ){
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
$('#newcontent').css({'display': 'inline', 'width': '70%'}); //unhide the usual textarea
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
return;
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
}
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
$('#template').prepend("<div style='width:80%;height:500px;margin-right:0!important;' id='fancyeditordiv'></div>");
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
editor = ace.edit("fancyeditordiv");
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
editor.setTheme("ace/theme/dawn");
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
var intialData = $('#newcontent').val()
|
|
|
|
|
1695 |
|
1696 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1697 |
|
1698 |
-
editor.getSession().setValue( intialData );
|
1699 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1700 |
|
|
|
|
|
|
|
1701 |
|
1702 |
|
|
|
|
|
|
|
|
|
|
|
1703 |
|
|
|
1704 |
|
|
|
|
|
1705 |
|
|
|
1706 |
|
|
|
1707 |
|
|
|
1708 |
|
|
|
1709 |
|
1710 |
-
|
1711 |
|
|
|
1712 |
|
|
|
1713 |
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
<?php }elseif($_SERVER['PHP_SELF'] === '/wp-admin/theme-editor.php'){?>
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
var aceedittype = 'theme';
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
<?php }//end ?>
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
//ajax call to generate a backup of this file we are about to edit
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
var data = { action: 'ace_backup_call', filename: $('input[name=file]').val(), edittype: aceedittype };
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
jQuery.post(ajaxurl, data, function(response) {
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
//alert('Got this from the server: ' + response);
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
});
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
var phpMode = require("ace/mode/php").Mode;
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
editor.getSession().setMode(new phpMode());
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
$('#submit, #publish, #save-post, #post-preview').click(function(event){
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
var sumink = editor.getSession().getValue();
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
$('textarea#newcontent').text( sumink ); //.html does some dodgy things with certain php files
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
})
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
//START WP AUTOCOMPLETE
|
1819 |
-
|
1820 |
-
//create the autocomplete dropdown
|
1821 |
-
|
1822 |
-
ac = document.createElement('select');
|
1823 |
-
|
1824 |
-
ac.id = 'ac';
|
1825 |
-
|
1826 |
-
ac.namme = 'ac';
|
1827 |
-
|
1828 |
-
ac.style.position='absolute';
|
1829 |
-
|
1830 |
-
ac.style.zIndex=100;
|
1831 |
-
|
1832 |
-
ac.style.width='auto';
|
1833 |
-
|
1834 |
-
ac.style.display='none';
|
1835 |
-
|
1836 |
-
ac.style.height='auto';
|
1837 |
-
|
1838 |
-
ac.size=10;
|
1839 |
-
|
1840 |
-
editor.container.appendChild(ac);
|
1841 |
|
|
|
1842 |
|
1843 |
|
1844 |
|
1845 |
|
|
|
1846 |
editor.getSession().on('change', function(e) {
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
var range = editor.getSelectionRange();
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1874 |
if (autocompleting){
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
autocompletelength = autocompletelength + 1;
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
}else{
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
autocompletelength = 2;
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
}
|
1891 |
|
1892 |
-
|
1893 |
-
|
1894 |
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
range.start.column = range.start.column - autocompletelength;
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
if (range.start.column < 1) range.start.column = 0;
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
range.end.column = range.end.column + 1;
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
//console.log( '"' + editor.getSession().doc.getTextRange(range) + '"' );
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
var text = editor.getSession().doc.getTextRange(range);
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
//dont show if no text passed
|
1927 |
-
|
1928 |
try{
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
}catch(e){ }
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
|
1939 |
|
1940 |
//create the dropdown for autocomplete
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
var sel = editor.getSelection();
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
var session = editor.getSession();
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
var lead = sel.getSelectionLead();
|
1969 |
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
var pos = editor.renderer.textToScreenCoordinates(lead.row, lead.column);
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
var ac;
|
1985 |
|
1986 |
|
1987 |
|
1988 |
if( document.getElementById('ac') ){
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
ac=document.getElementById('ac');
|
1993 |
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
//editor clicks should hide the autocomplete dropdown
|
2001 |
-
|
2002 |
editor.container.addEventListener('click',function(e){
|
2003 |
-
|
2004 |
ac.style.display='none';
|
|
|
2005 |
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
//START CANNON COMMANDS
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
var canon = require('pilot/canon')
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
canon.addCommand({
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
name: "up",
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
bindKey: {
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
win: "Up",
|
2035 |
-
|
2036 |
-
mac: "Up",
|
2037 |
-
|
2038 |
-
sender: "editor"
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
},
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
exec: function(env, args, request) {
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
if( document.getElementById('ac').style.display === 'block' ){
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
var select=document.getElementById('ac');
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
if( select.selectedIndex==0 ){
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
select.selectedIndex=select.options.length-1;
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
}else{
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
select.selectedIndex=select.selectedIndex-1;
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
}
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
}else{
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
var range = editor.getSelectionRange();
|
2087 |
-
|
2088 |
-
editor.clearSelection();
|
2089 |
-
|
2090 |
-
editor.moveCursorTo(range.end.row -1, range.end.column);
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
}
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
}
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
});
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
canon.addCommand({
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
name: "down",
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
bindKey: {
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
win: "Down",
|
2127 |
-
|
2128 |
-
mac: "Down",
|
2129 |
-
|
2130 |
-
sender: "editor"
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
},
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
exec: function(env, args, request) {
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
if( document.getElementById('ac').style.display === 'block' ){
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
var select=document.getElementById('ac');
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
if( select.selectedIndex==select.options.length-1 ){
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
select.selectedIndex=0;
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
}else{
|
2161 |
-
|
2162 |
-
select.selectedIndex=select.selectedIndex+1;
|
2163 |
-
|
2164 |
-
}
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
}else{
|
2169 |
-
|
2170 |
-
var range = editor.getSelectionRange();
|
2171 |
-
|
2172 |
-
editor.clearSelection();
|
2173 |
-
|
2174 |
-
editor.moveCursorTo(range.end.row +1, range.end.column);
|
2175 |
-
|
2176 |
-
}
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
}
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
});
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
canon.addCommand({
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
name: "enter",
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
bindKey: {
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
win: "Return",
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
mac: "Return",
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
sender: "editor"
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
},
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
exec: function(env, args, request) {
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
if( document.getElementById('ac').style.display === 'block' ){
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
var select=document.getElementById('ac');
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
var tag=select.options[select.selectedIndex].value;
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
var sel=editor.selection.getRange();
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
var line=editor.getSession().getLine(sel.start.row);
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
sel.start.column=sel.start.column-(autocompletelength+1);
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
editor.selection.setSelectionRange(sel);
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
editor.insert(tag);
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
autocompleting=false;
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
}else{
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
editor.insert('\n');
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
}
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
}
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
});
|
2281 |
-
|
2282 |
-
//END CANNON COMMANDS
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
} //end - create initial autocomplete dropdown and related actions
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
//calulate the container offset
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
var obj=editor.container;
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
var curleft = 0;
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
var curtop = 0;
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
if (obj.offsetParent) {
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
do {
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
curleft += obj.offsetLeft;
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
curtop += obj.offsetTop;
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
} while (obj = obj.offsetParent);
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
}
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
//position autocomplete
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
ac.style.top=pos.pageY - curtop + 20 + "px";
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
ac.style.left=pos.pageX - curleft + "px";
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
ac.style.display='block';
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
ac.style.background='white';
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
//remove all options, starting a fresh list
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
ac.options.length = 0
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
//loop through tags and check for a match
|
2385 |
-
|
2386 |
-
//console.log(text);
|
2387 |
-
|
2388 |
-
var tag;
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
for(i in html_tags){
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
if(!html_tags.hasOwnProperty(i) ){
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
continue;
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
}
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
tag=html_tags[i];
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
if( text ){
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
if( text!=tag.substr(0,text.length) ){
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
continue;
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
}
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
}
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
var option = document.createElement('option');
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
option.text = tag;
|
2449 |
-
|
2450 |
-
|
2451 |
-
|
2452 |
-
option.value = tag;
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
try {
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
ac.add(option, null); // standards compliant; doesn't work in IE
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
}
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
catch(ex) {
|
2473 |
-
|
2474 |
-
|
2475 |
-
|
2476 |
-
ac.add(option); // IE only
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
}
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
};
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
//if the return list contains everything then don't display it
|
2489 |
-
|
2490 |
-
if (html_tags.length == ac.options.length){
|
2491 |
-
|
2492 |
-
ac.options.length =0;
|
2493 |
-
|
2494 |
-
}
|
2495 |
-
|
2496 |
-
//console.log(html_tags.length + " = " + ac.options.length);
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
//check for matches
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
if( ac.length==0 ){
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
ac.style.display='none';
|
2509 |
-
|
2510 |
-
autocompleting=false;
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
}else{
|
2515 |
-
|
2516 |
-
|
2517 |
-
|
2518 |
-
//console.log('match');
|
2519 |
-
|
2520 |
-
ac.selectedIndex=0;
|
2521 |
-
|
2522 |
-
autocompleting=true;
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
}
|
2527 |
-
|
2528 |
-
|
2529 |
-
});
|
2530 |
-
|
2531 |
-
|
2532 |
-
});
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
</script>
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
<?php
|
2543 |
-
|
2544 |
-
}
|
2545 |
-
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
public static function add_admin_js()
|
2550 |
-
{
|
2551 |
-
|
2552 |
-
|
2553 |
|
2554 |
|
|
|
|
|
2555 |
|
|
|
|
|
2556 |
|
|
|
2557 |
|
2558 |
-
|
|
|
|
|
|
|
2559 |
|
|
|
2560 |
|
2561 |
|
|
|
|
|
|
|
|
|
|
|
2562 |
|
2563 |
|
|
|
|
|
2564 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2565 |
|
2566 |
-
|
|
|
|
|
|
|
|
|
|
|
2567 |
|
|
|
|
|
|
|
2568 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2569 |
|
|
|
2570 |
|
2571 |
|
2572 |
|
|
|
|
|
|
|
|
|
2573 |
|
2574 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2575 |
|
|
|
2576 |
|
2577 |
|
2578 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2579 |
|
|
|
|
|
2580 |
|
|
|
2581 |
|
2582 |
-
|
|
|
|
|
|
|
|
|
2583 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2584 |
|
2585 |
-
|
|
|
|
|
2586 |
|
|
|
2587 |
|
|
|
|
|
|
|
|
|
|
|
2588 |
|
|
|
|
|
2589 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2590 |
|
|
|
|
|
|
|
2591 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2592 |
|
2593 |
|
|
|
2594 |
|
2595 |
-
public static function ace_backup_call() {
|
2596 |
|
|
|
2597 |
|
2598 |
|
2599 |
-
$backup_path = get_bloginfo('url').'/wp-content/plugins/' . basename(dirname(__FILE__)) .'/backups/';
|
2600 |
|
|
|
|
|
|
|
2601 |
|
2602 |
|
2603 |
-
$file_name = $_POST['filename'];
|
2604 |
|
2605 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2606 |
|
2607 |
-
$edit_type = $_POST['edittype'];
|
2608 |
|
|
|
2609 |
|
|
|
|
|
|
|
2610 |
|
2611 |
if ($edit_type==='theme'){
|
2612 |
-
|
2613 |
-
|
2614 |
-
$theme_root = get_theme_root();
|
2615 |
-
|
2616 |
-
|
2617 |
$short_path = str_replace($theme_root, '', $file_name);
|
2618 |
|
2619 |
-
|
2620 |
-
|
2621 |
$new_file_path_daily = WP_PLUGIN_DIR.'/wpide/backups/themes'.$short_path.'.'.date("Ymd");
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
$new_file_path_hourly = WP_PLUGIN_DIR.'/wpide/backups/themes'.$short_path.'.'.date("YmdH");
|
2626 |
|
2627 |
-
|
2628 |
-
|
2629 |
$new_file_info = pathinfo($new_file_path_daily);
|
2630 |
|
2631 |
-
|
2632 |
-
|
2633 |
if (!is_dir($new_file_info['dirname'])) mkdir($new_file_info['dirname'], 0777, true); //make directory if not exist
|
2634 |
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
//check for todays backup if non existant then create
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
if (!file_exists($new_file_path_daily)){
|
2646 |
-
|
2647 |
-
|
2648 |
-
|
2649 |
-
copy($file_name, $new_file_path_daily); //make a copy of the file
|
2650 |
-
|
2651 |
-
|
2652 |
|
2653 |
//check for a backup this hour if doesn't exist then create
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
}else if(!file_exists($new_file_path_hourly)){
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
copy($file_name, $new_file_path_hourly); //make a copy of the file
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
}
|
2666 |
|
2667 |
-
|
2668 |
-
|
2669 |
//do no further backups since one intial backup for today and an hourly one is plenty!
|
2670 |
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
}else if ($edit_type==='plugin'){
|
2678 |
|
2679 |
-
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
$plugin_root = WP_PLUGIN_DIR;
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
$short_path = str_replace($plugin_root, '', $file_name);
|
2690 |
|
|
|
|
|
2691 |
|
|
|
2692 |
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
$new_file_path_hourly = WP_PLUGIN_DIR.'/wpide/backups/plugins/'.$short_path.'.'.date("YmdH");
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
$new_file_info = pathinfo($new_file_path_daily);
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
if (!is_dir($new_file_info['dirname'])) mkdir($new_file_info['dirname'], 0777, true); //make directory if not exist
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
//check for todays backup if non existant then create
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
if (!file_exists($new_file_path_daily)){
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
copy($plugin_root.'/'.$file_name, $new_file_path_daily); //make a copy of the file
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
//check for a backup this hour if doesn't exist then create
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
}else if(!file_exists($new_file_path_hourly)){
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
copy($plugin_root.'/'.$file_name, $new_file_path_hourly); //make a copy of the file
|
2734 |
-
|
2735 |
-
|
2736 |
-
|
2737 |
-
}
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
//do no further backups since one intial backup for today and an hourly one is plenty!
|
2742 |
-
|
2743 |
-
|
2744 |
|
2745 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2746 |
|
|
|
2747 |
|
|
|
2748 |
|
2749 |
}
|
2750 |
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
|
2757 |
//echo "final debug info : " . WP_PLUGIN_DIR.'/wpide/backups/'.$short_path.'.backup';
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
die(); // this is required to return a proper result
|
2762 |
|
2763 |
}
|
2764 |
|
2765 |
}
|
2766 |
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
//only include this plugin if on theme editor or plugin editor
|
2774 |
-
|
2775 |
if ( $_SERVER['PHP_SELF'] === '/wp-admin/plugin-editor.php' ||
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
|
2780 |
add_action("init", create_function('', 'new WPide();'));
|
2781 |
|
2782 |
}
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
?>
|
4 |
Plugin Name: WPide
|
5 |
Plugin URI: https://github.com/WPsites/WPide
|
6 |
Description: Replace the default WordPress code editor for plugins and themes. Adding syntax highlighting, autocomplete of WordPress functions + PHP, line numbers, auto backup of files before editing.
|
7 |
+
Version: 1.0.2
|
8 |
Author: Simon Dunton
|
9 |
Author URI: http://www.wpsites.co.uk
|
10 |
|
19 |
|
20 |
function __construct() {
|
21 |
|
|
|
|
|
22 |
// Uncomment any of these calls to add the functionality that you need.
|
|
|
|
|
|
|
23 |
add_action('admin_head', 'WPide::add_admin_head');
|
|
|
|
|
|
|
24 |
add_action('admin_head', 'WPide::load_editor');
|
|
|
|
|
|
|
25 |
add_action('admin_init', 'WPide::add_admin_js');
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
//setup ajax function to save a backup
|
|
|
|
|
|
|
28 |
add_action('wp_ajax_ace_backup_call', 'WPide::ace_backup_call');
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
public static function add_admin_head()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
{
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
?>
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
<style type="text/css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
#quicktags, #post-status-info, #editor-toolbar, #newcontent, .ace_print_margin { display: none; }
|
40 |
+
#fancyeditordiv {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
position: relative;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
width: 500px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
height: 400px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
#template div{margin-right:0 !important;}
|
46 |
+
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
<?php
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
|
52 |
|
64 |
|
65 |
|
66 |
public static function load_editor()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
?>
|
69 |
|
70 |
|
74 |
|
75 |
|
76 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
var autocompleting = false;
|
|
|
|
|
|
|
78 |
var autocompletelength = 2;
|
|
|
|
|
|
|
79 |
var editor = '';
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
var html_tags = ("_() __() __checked_selected_helper() __construct() __destruct() __get_option() " +
|
82 |
|
83 |
"__ngettext() __ngettext_noop() __set() __tostring() _add_themes_utility_last() _added() " +
|
1458 |
|
1459 |
jQuery(document).ready(function($) {
|
1460 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1461 |
//quit if editing this plugin since it will spaz out!!
|
|
|
|
|
|
|
1462 |
if ( $('input[name=file]').val() == 'ace/ace.php' ){
|
|
|
|
|
|
|
1463 |
$('#newcontent').css({'display': 'inline', 'width': '70%'}); //unhide the usual textarea
|
|
|
|
|
|
|
1464 |
return;
|
|
|
|
|
|
|
1465 |
}
|
1466 |
+
|
1467 |
+
//add div for ace editor to latch on to
|
|
|
|
|
|
|
|
|
|
|
1468 |
$('#template').prepend("<div style='width:80%;height:500px;margin-right:0!important;' id='fancyeditordiv'></div>");
|
1469 |
+
//create the editor instance
|
|
|
|
|
|
|
|
|
|
|
|
|
1470 |
editor = ace.edit("fancyeditordiv");
|
1471 |
+
//set the editor theme
|
|
|
|
|
|
|
|
|
|
|
|
|
1472 |
editor.setTheme("ace/theme/dawn");
|
1473 |
+
//get a copy of the initial file contents (the file being edited)
|
|
|
|
|
1474 |
var intialData = $('#newcontent').val()
|
1475 |
+
//add the file contents to our new editor instance
|
1476 |
+
editor.getSession().setValue( intialData );
|
1477 |
|
1478 |
|
1479 |
+
//are we editing a theme or plugin?
|
1480 |
+
<?php if($_SERVER['PHP_SELF'] === '/wp-admin/plugin-editor.php'){ ?>
|
1481 |
+
var aceedittype = 'plugin';
|
1482 |
+
<?php }elseif($_SERVER['PHP_SELF'] === '/wp-admin/theme-editor.php'){?>
|
1483 |
+
var aceedittype = 'theme';
|
1484 |
+
<?php }//end ?>
|
1485 |
|
|
|
1486 |
|
1487 |
+
//ajax call to generate a backup of this file we are about to edit
|
1488 |
+
var data = { action: 'ace_backup_call', filename: $('input[name=file]').val(), edittype: aceedittype };
|
1489 |
+
jQuery.post(ajaxurl, data, function(response) {
|
1490 |
+
if (response === 'success'){
|
1491 |
+
alert("A backup copy of this file has been generated.");
|
1492 |
+
}
|
1493 |
+
});
|
1494 |
|
1495 |
+
//use editors php mode
|
1496 |
+
var phpMode = require("ace/mode/php").Mode;
|
1497 |
+
editor.getSession().setMode(new phpMode());
|
1498 |
|
1499 |
|
1500 |
+
$('#submit').click(function(event){
|
1501 |
+
var use_val = editor.getSession().getValue();
|
1502 |
+
$('textarea#newcontent').text( use_val ); //.html does some dodgy things with certain php files
|
1503 |
+
})
|
1504 |
+
|
1505 |
|
1506 |
+
//START WP AUTOCOMPLETE
|
1507 |
|
1508 |
+
//create the autocomplete dropdown
|
1509 |
+
ac = document.createElement('select');
|
1510 |
|
1511 |
+
ac.id = 'ac';
|
1512 |
|
1513 |
+
ac.namme = 'ac';
|
1514 |
|
1515 |
+
ac.style.position='absolute';
|
1516 |
|
1517 |
+
ac.style.zIndex=100;
|
1518 |
|
1519 |
+
ac.style.width='auto';
|
1520 |
|
1521 |
+
ac.style.display='none';
|
1522 |
|
1523 |
+
ac.style.height='auto';
|
1524 |
|
1525 |
+
ac.size=10;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1526 |
|
1527 |
+
editor.container.appendChild(ac);
|
1528 |
|
1529 |
|
1530 |
|
1531 |
|
1532 |
+
//hook onto any change in editor contents
|
1533 |
editor.getSession().on('change', function(e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1534 |
|
1535 |
+
//don't continue with autocomplete if /n entered
|
1536 |
+
try{
|
1537 |
+
if ( e.data.text.charCodeAt(0) == 10 ){
|
1538 |
+
return;
|
1539 |
+
}
|
1540 |
+
}catch(e){}
|
1541 |
+
|
1542 |
+
//get cursor/selection
|
1543 |
+
var range = editor.getSelectionRange();
|
1544 |
+
|
1545 |
+
//do we need to extend the length of the autocomplete string
|
1546 |
if (autocompleting){
|
|
|
|
|
|
|
1547 |
autocompletelength = autocompletelength + 1;
|
|
|
|
|
|
|
1548 |
}else{
|
|
|
|
|
|
|
1549 |
autocompletelength = 2;
|
|
|
|
|
|
|
1550 |
}
|
1551 |
|
|
|
|
|
1552 |
|
1553 |
+
//modify the cursor/selection data we have to get text from the editor to check for matching function/method
|
1554 |
+
//set start column
|
|
|
1555 |
range.start.column = range.start.column - autocompletelength;
|
1556 |
+
//no column lower than 1 thanks
|
1557 |
+
if (range.start.column < 1) range.start.column = 0;
|
1558 |
+
//set end column
|
|
|
|
|
|
|
|
|
1559 |
range.end.column = range.end.column + 1;
|
1560 |
+
//get the editor text based on that range
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1561 |
var text = editor.getSession().doc.getTextRange(range);
|
1562 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
1563 |
//dont show if no text passed
|
1564 |
+
$quit_onchange = false;
|
1565 |
try{
|
1566 |
+
if (text==="") {
|
1567 |
+
ac.style.display='none';
|
1568 |
+
}
|
1569 |
+
}catch(e){ }//catch end
|
1570 |
+
// if string length less than 3 then quit this
|
1571 |
+
if (text.length < 3){
|
1572 |
+
return;
|
1573 |
+
}
|
|
|
1574 |
|
1575 |
|
1576 |
//create the dropdown for autocomplete
|
|
|
|
|
|
|
1577 |
var sel = editor.getSelection();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1578 |
var session = editor.getSession();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1579 |
var lead = sel.getSelectionLead();
|
1580 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1581 |
var pos = editor.renderer.textToScreenCoordinates(lead.row, lead.column);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1582 |
var ac;
|
1583 |
|
1584 |
|
1585 |
|
1586 |
if( document.getElementById('ac') ){
|
|
|
|
|
|
|
1587 |
ac=document.getElementById('ac');
|
1588 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1589 |
//editor clicks should hide the autocomplete dropdown
|
|
|
1590 |
editor.container.addEventListener('click',function(e){
|
|
|
1591 |
ac.style.display='none';
|
1592 |
+
})
|
1593 |
|
1594 |
+
} //end - create initial autocomplete dropdown and related actions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1595 |
|
1596 |
|
1597 |
+
//calulate the editor container offset
|
1598 |
+
var obj=editor.container;
|
1599 |
|
1600 |
+
var curleft = 0;
|
1601 |
+
var curtop = 0;
|
1602 |
|
1603 |
+
if (obj.offsetParent) {
|
1604 |
|
1605 |
+
do {
|
1606 |
+
curleft += obj.offsetLeft;
|
1607 |
+
curtop += obj.offsetTop;
|
1608 |
+
} while (obj = obj.offsetParent);
|
1609 |
|
1610 |
+
}
|
1611 |
|
1612 |
|
1613 |
+
//position autocomplete
|
1614 |
+
ac.style.top=pos.pageY - curtop + 40 + "px";
|
1615 |
+
ac.style.left=pos.pageX - curleft + 20 + "px";
|
1616 |
+
ac.style.display='block';
|
1617 |
+
ac.style.background='white';
|
1618 |
|
1619 |
|
1620 |
+
//remove all options, starting a fresh list
|
1621 |
+
ac.options.length = 0
|
1622 |
|
1623 |
+
//loop through tags and check for a match
|
1624 |
+
var tag;
|
1625 |
+
for(i in html_tags){
|
1626 |
+
if(!html_tags.hasOwnProperty(i) ){
|
1627 |
+
continue;
|
1628 |
+
}
|
1629 |
|
1630 |
+
tag=html_tags[i];
|
1631 |
+
if( text ){
|
1632 |
+
if( text!=tag.substr(0,text.length) ){
|
1633 |
+
continue;
|
1634 |
+
}
|
1635 |
+
}
|
1636 |
|
1637 |
+
var option = document.createElement('option');
|
1638 |
+
option.text = tag;
|
1639 |
+
option.value = tag;
|
1640 |
|
1641 |
+
try {
|
1642 |
+
ac.add(option, null); // standards compliant; doesn't work in IE
|
1643 |
+
}
|
1644 |
+
catch(ex) {
|
1645 |
+
ac.add(option); // IE only
|
1646 |
+
}
|
1647 |
|
1648 |
+
};//end for
|
1649 |
|
1650 |
|
1651 |
|
1652 |
+
//if the return list contains everything then don't display it
|
1653 |
+
if (html_tags.length == ac.options.length){
|
1654 |
+
ac.options.length =0;
|
1655 |
+
}
|
1656 |
|
1657 |
+
//check for matches
|
1658 |
+
if( ac.length==0 ){
|
1659 |
+
ac.style.display='none';
|
1660 |
+
autocompleting=false;
|
1661 |
+
}else{
|
1662 |
+
ac.selectedIndex=0;
|
1663 |
+
autocompleting=true;
|
1664 |
+
}
|
1665 |
|
1666 |
+
});//end editor change event
|
1667 |
|
1668 |
|
1669 |
|
1670 |
+
//START COMMANDS
|
1671 |
+
var canon = require('pilot/canon')
|
1672 |
+
|
1673 |
+
//Key up command
|
1674 |
+
canon.addCommand({
|
1675 |
+
name: "up",
|
1676 |
+
bindKey: {
|
1677 |
+
win: "Up",
|
1678 |
+
mac: "Up",
|
1679 |
+
sender: "editor"
|
1680 |
+
},
|
1681 |
|
1682 |
+
exec: function(env, args, request) {
|
1683 |
+
if( document.getElementById('ac').style.display === 'block' ){
|
1684 |
|
1685 |
+
var select=document.getElementById('ac');
|
1686 |
|
1687 |
+
if( select.selectedIndex==0 ){
|
1688 |
+
select.selectedIndex=select.options.length-1;
|
1689 |
+
}else{
|
1690 |
+
select.selectedIndex=select.selectedIndex-1;
|
1691 |
+
}
|
1692 |
|
1693 |
+
}else{
|
1694 |
+
var range = editor.getSelectionRange();
|
1695 |
+
editor.clearSelection();
|
1696 |
+
editor.moveCursorTo(range.end.row -1, range.end.column);
|
1697 |
+
}
|
1698 |
+
}
|
1699 |
+
});
|
1700 |
|
1701 |
+
|
1702 |
+
//key down command
|
1703 |
+
canon.addCommand({
|
1704 |
|
1705 |
+
name: "down",
|
1706 |
|
1707 |
+
bindKey: {
|
1708 |
+
win: "Down",
|
1709 |
+
mac: "Down",
|
1710 |
+
sender: "editor"
|
1711 |
+
},
|
1712 |
|
1713 |
+
exec: function(env, args, request) {
|
1714 |
+
if( document.getElementById('ac').style.display === 'block' ){
|
1715 |
|
1716 |
+
var select=document.getElementById('ac');
|
1717 |
+
|
1718 |
+
if( select.selectedIndex==select.options.length-1 ){
|
1719 |
+
select.selectedIndex=0;
|
1720 |
+
}else{
|
1721 |
+
select.selectedIndex=select.selectedIndex+1;
|
1722 |
+
}
|
1723 |
+
}else{
|
1724 |
+
var range = editor.getSelectionRange();
|
1725 |
+
editor.clearSelection();
|
1726 |
+
editor.moveCursorTo(range.end.row +1, range.end.column);
|
1727 |
+
}
|
1728 |
+
}
|
1729 |
+
});
|
1730 |
|
1731 |
+
|
1732 |
+
//enter/return command
|
1733 |
+
function trythis () {
|
1734 |
|
1735 |
+
if( document.getElementById('ac').style.display === 'block' ){
|
1736 |
+
|
1737 |
+
var ac_dropdwn =document.getElementById('ac');
|
1738 |
+
var tag=ac_dropdwn.options[ac_dropdwn.selectedIndex].value;
|
1739 |
+
var sel=editor.selection.getRange();
|
1740 |
+
var line=editor.getSession().getLine(sel.start.row);
|
1741 |
+
sel.start.column=sel.start.column-(autocompletelength+1);
|
1742 |
+
editor.selection.setSelectionRange(sel);
|
1743 |
+
editor.insert(tag);
|
1744 |
+
autocompleting=false;
|
1745 |
+
|
1746 |
+
}else{
|
1747 |
+
editor.insert('\n');
|
1748 |
+
}
|
1749 |
+
}
|
1750 |
+
canon.addCommand({
|
1751 |
+
name: "enter",
|
1752 |
+
bindKey: {
|
1753 |
+
win: "Return",
|
1754 |
+
mac: "Return",
|
1755 |
+
sender: "editor"
|
1756 |
+
},
|
1757 |
+
exec: trythis
|
1758 |
+
});
|
1759 |
|
1760 |
|
1761 |
+
//END COMMANDS
|
1762 |
|
|
|
1763 |
|
1764 |
+
});//end jquery load
|
1765 |
|
1766 |
|
|
|
1767 |
|
1768 |
+
</script>
|
1769 |
+
<?php
|
1770 |
+
}
|
1771 |
|
1772 |
|
|
|
1773 |
|
1774 |
|
1775 |
+
public static function add_admin_js()
|
1776 |
+
{
|
1777 |
+
$plugin_path = get_bloginfo('url').'/wp-content/plugins/' . basename(dirname(__FILE__)) .'/';
|
1778 |
+
//include ace
|
1779 |
+
wp_enqueue_script('ace', $plugin_path . 'ace-0.2.0/src/ace.js');
|
1780 |
+
//include ace mode
|
1781 |
+
wp_enqueue_script('ace-mode', $plugin_path . 'ace-0.2.0/src/mode-php.js');
|
1782 |
+
//include ace theme
|
1783 |
+
wp_enqueue_script('ace-theme', $plugin_path . 'ace-0.2.0/src/theme-dawn.js');//monokai is nice
|
1784 |
+
}
|
1785 |
|
|
|
1786 |
|
1787 |
+
public static function ace_backup_call() {
|
1788 |
|
1789 |
+
$backup_path = get_bloginfo('url').'/wp-content/plugins/' . basename(dirname(__FILE__)) .'/backups/';
|
1790 |
+
$file_name = $_POST['filename'];
|
1791 |
+
$edit_type = $_POST['edittype'];
|
1792 |
|
1793 |
if ($edit_type==='theme'){
|
1794 |
+
$theme_root = get_theme_root();
|
|
|
|
|
|
|
|
|
1795 |
$short_path = str_replace($theme_root, '', $file_name);
|
1796 |
|
|
|
|
|
1797 |
$new_file_path_daily = WP_PLUGIN_DIR.'/wpide/backups/themes'.$short_path.'.'.date("Ymd");
|
|
|
|
|
|
|
1798 |
$new_file_path_hourly = WP_PLUGIN_DIR.'/wpide/backups/themes'.$short_path.'.'.date("YmdH");
|
1799 |
|
|
|
|
|
1800 |
$new_file_info = pathinfo($new_file_path_daily);
|
1801 |
|
|
|
|
|
1802 |
if (!is_dir($new_file_info['dirname'])) mkdir($new_file_info['dirname'], 0777, true); //make directory if not exist
|
1803 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1804 |
//check for todays backup if non existant then create
|
|
|
|
|
|
|
1805 |
if (!file_exists($new_file_path_daily)){
|
1806 |
+
$backup_result = copy($file_name, $new_file_path_daily); //make a copy of the file
|
|
|
|
|
|
|
|
|
|
|
1807 |
|
1808 |
//check for a backup this hour if doesn't exist then create
|
|
|
|
|
|
|
1809 |
}else if(!file_exists($new_file_path_hourly)){
|
1810 |
+
$backup_result = copy($file_name, $new_file_path_hourly); //make a copy of the file
|
|
|
|
|
|
|
|
|
|
|
|
|
1811 |
}
|
1812 |
|
|
|
|
|
1813 |
//do no further backups since one intial backup for today and an hourly one is plenty!
|
1814 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1815 |
}else if ($edit_type==='plugin'){
|
1816 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1817 |
$plugin_root = WP_PLUGIN_DIR;
|
|
|
|
|
|
|
1818 |
$short_path = str_replace($plugin_root, '', $file_name);
|
1819 |
|
1820 |
+
$new_file_path_daily = WP_PLUGIN_DIR.'/wpide/backups/plugins/'.$short_path.'.'.date("Ymd");
|
1821 |
+
$new_file_path_hourly = WP_PLUGIN_DIR.'/wpide/backups/plugins/'.$short_path.'.'.date("YmdH");
|
1822 |
|
1823 |
+
$new_file_info = pathinfo($new_file_path_daily);
|
1824 |
|
1825 |
+
if (!is_dir($new_file_info['dirname'])) mkdir($new_file_info['dirname'], 0777, true); //make directory if not exist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1826 |
|
1827 |
+
//check for todays backup if non existant then create
|
1828 |
+
if (!file_exists($new_file_path_daily)){
|
1829 |
+
$backup_result = copy($plugin_root.'/'.$file_name, $new_file_path_daily); //make a copy of the file
|
1830 |
+
|
1831 |
+
//check for a backup this hour if doesn't exist then create
|
1832 |
+
}else if(!file_exists($new_file_path_hourly)){
|
1833 |
+
$backup_result = copy($plugin_root.'/'.$file_name, $new_file_path_hourly); //make a copy of the file
|
1834 |
|
1835 |
+
}
|
1836 |
|
1837 |
+
//do no further backups since one intial backup for today and an hourly one is plenty!
|
1838 |
|
1839 |
}
|
1840 |
|
1841 |
+
if ($backup_result){
|
1842 |
+
echo "success";
|
1843 |
+
}
|
|
|
|
|
1844 |
|
1845 |
//echo "final debug info : " . WP_PLUGIN_DIR.'/wpide/backups/'.$short_path.'.backup';
|
|
|
|
|
|
|
1846 |
die(); // this is required to return a proper result
|
1847 |
|
1848 |
}
|
1849 |
|
1850 |
}
|
1851 |
|
1852 |
+
//only include this plugin if on theme editor, plugin editor or an ajax call
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1853 |
if ( $_SERVER['PHP_SELF'] === '/wp-admin/plugin-editor.php' ||
|
1854 |
+
$_SERVER['PHP_SELF'] === '/wp-admin/theme-editor.php' ||
|
1855 |
+
$_SERVER['PHP_SELF'] === '/wp-admin/admin-ajax.php' ){
|
|
|
1856 |
|
1857 |
add_action("init", create_function('', 'new WPide();'));
|
1858 |
|
1859 |
}
|
|
|
|
|
|
|
1860 |
?>
|
readme.txt
CHANGED
@@ -1,62 +1,68 @@
|
|
1 |
-
=== WPide ===
|
2 |
-
Contributors: WPsites
|
3 |
-
Tags: code, theme editor, plugin editor, code editor
|
4 |
-
Requires at least: 3.0
|
5 |
-
Tested up to: 3.3
|
6 |
-
Stable tag: 1.0.
|
7 |
-
|
8 |
-
Replace the default WordPress code editor for plugins and themes. Adding syntax highlighting, autocomplete of WordPress functions + PHP, line numbers, auto backup of files before editing.
|
9 |
-
|
10 |
-
== Description ==
|
11 |
-
|
12 |
-
Out of frustration of unsatisfactory experiences with desktop based IDE's and code editors we (WPsites) decided to make use of the Ajax.org Cloud9 Editor (http://ace.ajax.org/) and embed it in place of the default WordPress file editor.
|
13 |
-
|
14 |
-
= This plugin does not currently work on Internet Explorer! =
|
15 |
-
|
16 |
-
= Current Features: =
|
17 |
-
|
18 |
-
* Syntax highlighting
|
19 |
-
* Line numbers
|
20 |
-
* Autocomplete of WordPress functions and PHP
|
21 |
-
* Automatic backup of every file you edit. (one daily backup and one hourly backup of each file stored in plugins/WPide/backups)
|
22 |
-
* Highlight matching parentheses
|
23 |
-
* Auto indentation
|
24 |
-
|
25 |
-
= Planned Features: =
|
26 |
-
|
27 |
-
* Tabbed document interface for editing multiple files
|
28 |
-
* Ajax Save
|
29 |
-
* Create and edit directories and files
|
30 |
-
* ctrl + s saving
|
31 |
-
* Improve the code auto complete so that it shows command arguments rather than just commands, possibly with links through to the WordPress codex for further info
|
32 |
-
* Create an admin panel to choose between syntax highlighting themes and turn on/off other Ajax.org Cloud9 functionality
|
33 |
-
* Better automated file backup process
|
34 |
-
* Integration with git for version control
|
35 |
-
|
36 |
-
|
37 |
-
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 github https://github.com/WPsites/WPide
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
== Installation ==
|
42 |
-
|
43 |
-
1. Upload the WPide folder to the `/wp-content/plugins/` directory
|
44 |
-
1. Activate the plugin through the 'Plugins' menu in WordPress
|
45 |
-
|
46 |
-
== Frequently Asked Questions ==
|
47 |
-
|
48 |
-
= Does this plugin work on Internet Explorer =
|
49 |
-
|
50 |
-
No support for Internet Explorer right now
|
51 |
-
|
52 |
-
== Screenshots ==
|
53 |
-
|
54 |
-
1. Editor view, showing line numbers and syntax highlighting.
|
55 |
-
|
56 |
-
== Changelog ==
|
57 |
-
|
58 |
-
= 1.0.
|
59 |
-
*
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
* Initial release.
|
1 |
+
=== WPide ===
|
2 |
+
Contributors: WPsites
|
3 |
+
Tags: code, theme editor, plugin editor, code editor
|
4 |
+
Requires at least: 3.0
|
5 |
+
Tested up to: 3.3
|
6 |
+
Stable tag: 1.0.2
|
7 |
+
|
8 |
+
Replace the default WordPress code editor for plugins and themes. Adding syntax highlighting, autocomplete of WordPress functions + PHP, line numbers, auto backup of files before editing.
|
9 |
+
|
10 |
+
== Description ==
|
11 |
+
|
12 |
+
Out of frustration of unsatisfactory experiences with desktop based IDE's and code editors we (WPsites) decided to make use of the Ajax.org Cloud9 Editor (http://ace.ajax.org/) and embed it in place of the default WordPress file editor.
|
13 |
+
|
14 |
+
= This plugin does not currently work on Internet Explorer! =
|
15 |
+
|
16 |
+
= Current Features: =
|
17 |
+
|
18 |
+
* Syntax highlighting
|
19 |
+
* Line numbers
|
20 |
+
* Autocomplete of WordPress functions and PHP
|
21 |
+
* Automatic backup of every file you edit. (one daily backup and one hourly backup of each file stored in plugins/WPide/backups)
|
22 |
+
* Highlight matching parentheses
|
23 |
+
* Auto indentation
|
24 |
+
|
25 |
+
= Planned Features: =
|
26 |
+
|
27 |
+
* Tabbed document interface for editing multiple files
|
28 |
+
* Ajax Save
|
29 |
+
* Create and edit directories and files
|
30 |
+
* ctrl + s saving
|
31 |
+
* Improve the code auto complete so that it shows command arguments rather than just commands, possibly with links through to the WordPress codex for further info
|
32 |
+
* Create an admin panel to choose between syntax highlighting themes and turn on/off other Ajax.org Cloud9 functionality
|
33 |
+
* Better automated file backup process
|
34 |
+
* Integration with git for version control
|
35 |
+
|
36 |
+
|
37 |
+
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 github https://github.com/WPsites/WPide
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
== Installation ==
|
42 |
+
|
43 |
+
1. Upload the WPide folder to the `/wp-content/plugins/` directory
|
44 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
45 |
+
|
46 |
+
== Frequently Asked Questions ==
|
47 |
+
|
48 |
+
= Does this plugin work on Internet Explorer =
|
49 |
+
|
50 |
+
No support for Internet Explorer right now
|
51 |
+
|
52 |
+
== Screenshots ==
|
53 |
+
|
54 |
+
1. Editor view, showing line numbers and syntax highlighting.
|
55 |
+
|
56 |
+
== Changelog ==
|
57 |
+
|
58 |
+
= 1.0.2 =
|
59 |
+
* Tidy and comment code
|
60 |
+
* Added message when backup file is generated
|
61 |
+
* Adjust code complete dropdown position
|
62 |
+
* Improved editor responsiveness when using delete or enter keys
|
63 |
+
|
64 |
+
= 1.0.1 =
|
65 |
+
* Fixed "Folder name case" issue.
|
66 |
+
|
67 |
+
= 1.0 =
|
68 |
* Initial release.
|