Changeset 689595
- Timestamp:
- 03/31/2013 08:36:26 PM (13 years ago)
- Location:
- solid-code-theme-editor
- Files:
-
- 1 added
- 5 edited
-
tags/1.0.4 (added)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/sc-theme-backup.php (modified) (1 diff)
-
trunk/sc-theme-downloader.php (modified) (2 diffs)
-
trunk/sc-theme-editor.php (modified) (12 diffs)
-
trunk/scte-script.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
solid-code-theme-editor/trunk/readme.txt
r656736 r689595 16 16 17 17 Changing Theme files may harm your WordPress Site installation, please do not install this plugin unless you know exactly what you are doing. 18 Make sure you backup all your files before installing this plugin 18 Make sure you backup all your files before installing this plugin. 19 19 20 20 #### Features and highlights: … … 26 26 * Download a ZIP backup of the whole theme 27 27 * Download individual files 28 * Create and Delete files 28 29 29 30 == Installation == … … 53 54 * added support for less files 54 55 56 = 1.0.4 = 57 * added support for https 58 * added abilities to add new files 59 * added abilities to delete old files 60 55 61 == Upgrade Notice == 56 62 -
solid-code-theme-editor/trunk/sc-theme-backup.php
r428363 r689595 4 4 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>'); 5 5 6 $themes = get_themes();7 8 6 $theme = ''; 9 7 10 8 if(!isset($_GET['theme'])){ 11 $theme = get_current_theme();9 $theme = wp_get_theme(); 12 10 }else{ 13 $theme = $_GET['theme'];11 $theme = wp_get_theme(urldecode($_GET['theme'])); 14 12 } 15 13 16 14 //Get the directory to zip 17 $directory = $theme s[$theme]['Template Dir']. '/';15 $directory = $theme->get_stylesheet_directory() . '/'; 18 16 19 17 // create object -
solid-code-theme-editor/trunk/sc-theme-downloader.php
r501834 r689595 4 4 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>'); 5 5 6 $themes = get_themes();7 8 6 $file = ''; 9 7 $theme = ''; 10 8 11 9 if(!isset($_GET['theme'])){ 12 $theme = get_current_theme();10 $theme = wp_get_theme(); 13 11 }else{ 14 $theme = $_GET['theme'];12 $theme = wp_get_theme(urldecode($_GET['theme'])); 15 13 } 16 14 //default file to style.css … … 18 16 $file = '/style.css'; 19 17 }else{ 20 $file = $_GET['file'];18 $file = str_ireplace("../","",$_GET['file']); 21 19 } 22 20 23 21 $content = ''; 24 22 $urlFile = $file; 25 $file = $theme s[$theme]['Template Dir']. '/' . $file;23 $file = $theme->get_stylesheet_directory() . '/' . $file; 26 24 if(file_exists($file)){ 27 25 $content = file_get_contents($file); -
solid-code-theme-editor/trunk/sc-theme-editor.php
r656736 r689595 4 4 Plugin URI: http://solid-code.co.uk/2011/08/solid-code-theme-editor/ 5 5 Description: Adds a special editor to the theme editor with more functionality 6 Version: 1.0. 36 Version: 1.0.4 7 7 Author: Dagan Lev 8 8 Author URI: http://solid-code.co.uk … … 48 48 49 49 function scte_styles(){ 50 if($_GET['page']=='scte-theme-editor'){ 51 wp_register_style('scte-style', WP_PLUGIN_URL.'/solid-code-theme-editor/scte-style.css'); 50 if(isset($_GET['page']) && $_GET['page']=='scte-theme-editor'){ 51 $pluginURL = WP_PLUGIN_URL; 52 if(is_ssl()){ 53 $pluginURL = str_ireplace("http://","https://",$pluginURL); 54 } 55 wp_register_style('scte-style', $pluginURL.'/solid-code-theme-editor/scte-style.css'); 52 56 wp_enqueue_style('scte-style'); 53 57 } 54 58 } 55 59 function scte_scripts(){ 56 if($_GET['page']=='scte-theme-editor'){ 57 wp_register_script('scte_script', WP_PLUGIN_URL.'/solid-code-theme-editor/scte-script.js', array('jquery')); 60 if(isset($_GET['page']) && $_GET['page']=='scte-theme-editor'){ 61 $pluginURL = WP_PLUGIN_URL; 62 if(is_ssl()){ 63 $pluginURL = str_ireplace("http://","https://",$pluginURL); 64 } 65 wp_register_script('scte_script', $pluginURL.'/solid-code-theme-editor/scte-script.js', array('jquery')); 58 66 wp_enqueue_script('scte_script'); 59 67 } … … 64 72 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>'); 65 73 66 $themes = get_themes(); 74 $pluginURL = WP_PLUGIN_URL; 75 if(is_ssl()){ 76 $pluginURL = str_ireplace("http://","https://",$pluginURL); 77 } 78 79 $allowedFileExt = array('less','php','css','js','xml','html','htm','txt','sql'); 80 $themes = wp_get_themes(); 67 81 68 82 $file = ''; … … 70 84 71 85 if(!isset($_GET['theme'])){ 72 $theme = get_current_theme();86 $theme = wp_get_theme(); 73 87 }else{ 74 $theme = $_GET['theme'];88 $theme = wp_get_theme(urldecode($_GET['theme'])); 75 89 } 76 90 //default file to style.css … … 78 92 $file = '/style.css'; 79 93 }else{ 80 $file = $_GET['file']; 81 } 82 94 $file = str_ireplace("../","",$_GET['file']); 95 } 96 97 //delete file 98 if(isset($_GET['delfile'])){ 99 $delfile = $theme->get_stylesheet_directory() . $file; 100 if(file_exists($delfile)){ 101 unlink($delfile); 102 echo '<script type="text/javascript"> 103 <!-- 104 window.location = \'themes.php?page=scte-theme-editor&theme=' . urlencode($theme->template) . '\'; 105 //--> 106 </script>'; 107 exit(); 108 } 109 } 110 111 //create new file in current directory 112 $chkfrm = ''; 113 if(isset($_POST['newfilename'])){ 114 if(preg_match('/^([\w\-]*)\.([\w\-]*)$/',$_POST['newfilename'],$filematches)){ 115 if(in_array($filematches[2],$allowedFileExt)){ 116 $newfile = $theme->get_stylesheet_directory() . str_ireplace(end(explode("/",$file)),"",$file) . $_POST['newfilename']; 117 if(!file_exists($newfile)){ 118 $ourFileHandle = fopen($newfile, 'w') or $chkfrm = 'Error creating file...'; 119 fclose($ourFileHandle); 120 echo '<script type="text/javascript"> 121 <!-- 122 window.location = \'themes.php?page=scte-theme-editor&theme=' . urlencode($theme->template) . '&file=' . urlencode(str_ireplace(end(explode("/",$file)),"",$file) . $_POST['newfilename']) . '&created=1\'; 123 //--> 124 </script>'; 125 exit(); 126 }else{ 127 $chkfrm = 'File Already Exists...'; 128 } 129 }else{ 130 $chkfrm = 'Invalid file name, please enter file with valid extension (no spaces or wierd characters)<br />(valid extensions: '. implode(", ",$allowedFileExt) .')'; 131 } 132 }else{ 133 $chkfrm = 'Invalid file name, please enter file with valid extension (no spaces or wierd characters)<br />(valid extensions: '. implode(", ",$allowedFileExt) .')'; 134 } 135 } 136 137 //save file content 83 138 if(isset($_POST['newcontent'])){ 84 139 $newcontent = stripslashes($_POST['newcontent']); 85 if (is_writeable($theme s[$theme]['Template Dir']. '/' . $file)) {140 if (is_writeable($theme->get_stylesheet_directory() . '/' . $file)) { 86 141 //is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable 87 $f = fopen($theme s[$theme]['Template Dir']. '/' . $file, 'w+');142 $f = fopen($theme->get_stylesheet_directory() . '/' . $file, 'w+'); 88 143 if ($f !== FALSE) { 89 144 fwrite($f, $newcontent); … … 91 146 echo '<script type="text/javascript"> 92 147 <!-- 93 window.location = \'themes.php?page=scte-theme-editor&theme=' . urlencode($theme ) . '&file=' . urlencode($file) . '&saved=1\';148 window.location = \'themes.php?page=scte-theme-editor&theme=' . urlencode($theme->template) . '&file=' . urlencode($file) . '&saved=1\'; 94 149 //--> 95 150 </script>'; … … 106 161 echo '<div id="message" class="updated"><p>File edited successfully.</p></div>'; 107 162 } 163 if(isset($_GET['created'])){ 164 echo '<div id="message" class="updated"><p>File created successfully.</p></div>'; 165 } 166 if($chkfrm!=''){ 167 echo '<div id="message" class="error"><p>'.$chkfrm.'</p></div>'; 168 } 108 169 ?> 109 170 <div class="fileedit-sub"> 110 171 <div class="alignleft"> 111 <h3 style="margin-top:0px;"><?php echo $theme ; ?> - <span style="font-weight:normal;"><?php echo $file; ?></span></h3>172 <h3 style="margin-top:0px;"><?php echo $theme->Name; ?> - <span style="font-weight:normal;"><?php echo $file; ?></span></h3> 112 173 </div> 113 174 <div class="alignright"> … … 118 179 <?php 119 180 foreach($themes as $stheme){ 120 if($theme ==$stheme['Name']){121 echo '<option selected="selected" value="'. $stheme ['Name'].'">'. $stheme['Name'] .'</option>';181 if($theme->Name==$stheme['Name']){ 182 echo '<option selected="selected" value="'. $stheme->template .'">'. $stheme['Name'] .'</option>'; 122 183 }else{ 123 echo '<option value="'. $stheme ['Name'].'">'. $stheme['Name'] .'</option>';184 echo '<option value="'. $stheme->template .'">'. $stheme['Name'] .'</option>'; 124 185 } 125 186 } … … 134 195 <?php 135 196 $content = ''; 136 $allowedFileExt = array('less','php','css','js','xml','html','htm','txt','sql');137 197 $urlFile = $file; 138 $file = $theme s[$theme]['Template Dir']. '/' . $file;198 $file = $theme->get_stylesheet_directory() . '/' . $file; 139 199 if(file_exists($file)){ 140 200 //check valid ext … … 149 209 <div class="scte_content_left"> 150 210 <ul> 151 <li style="float:left;"><a href="<?php echo WP_PLUGIN_URL; ?>/solid-code-theme-editor/downloadfile/?theme=<?php echo urlencode($theme); ?>&file=<?php echo urlencode($urlFile); ?>">Download File</a></li>152 <li style="float:left;margin-left:20px;"><a href="<?php echo WP_PLUGIN_URL; ?>/solid-code-theme-editor/downloadbackup/?theme=<?php echo urlencode($theme); ?>">Download Whole Theme</a> (ZIP)</li>211 <li style="float:left;"><a href="<?php echo $pluginURL; ?>/solid-code-theme-editor/downloadfile/?theme=<?php echo urlencode($theme->template); ?>&file=<?php echo urlencode($urlFile); ?>">Download File</a></li> 212 <li style="float:left;margin-left:20px;"><a href="<?php echo $pluginURL; ?>/solid-code-theme-editor/downloadbackup/?theme=<?php echo urlencode($theme->template); ?>">Download Whole Theme</a> (ZIP)</li> 153 213 </ul> 154 214 <div style="clear:both;"><!-- EMPTY --></div> 155 <form name="textarea_form" id="textarea_form" method="post" action="themes.php?page=scte-theme-editor&theme=<?php echo urlencode($theme); ?>&file=<?php echo urlencode($urlFile); ?>"> 215 <form id="newfile" name="newfile" method="post" action="themes.php?page=scte-theme-editor&theme=<?php echo urlencode($theme->template); ?>&file=<?php echo urlencode($urlFile); ?>"> 216 <input type="text" size="50" id="newfilename" name="newfilename" value="Enter file name" /> <input type="submit" value="Create File in current directory" class="button" /> 217 <p> </p> 218 </form> 219 <div style="clear:both;"><!-- EMPTY --></div> 220 <form name="textarea_form" id="textarea_form" method="post" action="themes.php?page=scte-theme-editor&theme=<?php echo urlencode($theme->template); ?>&file=<?php echo urlencode($urlFile); ?>"> 156 221 <?php if(in_array($fxt[count($fxt)-1],$allowedFileExt)){ ?> 157 222 <textarea style="display:none;" wrap="off" cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content; ?></textarea> 158 <div id="editor" style="z-index:100 0;position: relative;width: 758px;height: 600px;"><?php echo $content; ?></div>159 <script src="<?php echo WP_PLUGIN_URL; ?>/solid-code-theme-editor/ace/ace.js" type="text/javascript" charset="utf-8"></script>160 <script src="<?php echo WP_PLUGIN_URL; ?>/solid-code-theme-editor/ace/mode-javascript.js" type="text/javascript" charset="utf-8"></script>161 <script src="<?php echo WP_PLUGIN_URL; ?>/solid-code-theme-editor/ace/mode-css.js" type="text/javascript" charset="utf-8"></script>162 <script src="<?php echo WP_PLUGIN_URL; ?>/solid-code-theme-editor/ace/mode-html.js" type="text/javascript" charset="utf-8"></script>163 <script src="<?php echo WP_PLUGIN_URL; ?>/solid-code-theme-editor/ace/mode-php.js" type="text/javascript" charset="utf-8"></script>164 <script src="<?php echo WP_PLUGIN_URL; ?>/solid-code-theme-editor/ace/mode-sql.js" type="text/javascript" charset="utf-8"></script>165 <script src="<?php echo WP_PLUGIN_URL; ?>/solid-code-theme-editor/ace/mode-text.js" type="text/javascript" charset="utf-8"></script>166 <script src="<?php echo WP_PLUGIN_URL; ?>/solid-code-theme-editor/ace/mode-xml.js" type="text/javascript" charset="utf-8"></script>167 <script src="<?php echo WP_PLUGIN_URL; ?>/solid-code-theme-editor/ace/theme-chrome.js" type="text/javascript" charset="utf-8"></script>223 <div id="editor" style="z-index:100;position: relative;width: 700px;height: 600px;"><?php echo $content; ?></div> 224 <script src="<?php echo $pluginURL; ?>/solid-code-theme-editor/ace/ace.js" type="text/javascript" charset="utf-8"></script> 225 <script src="<?php echo $pluginURL; ?>/solid-code-theme-editor/ace/mode-javascript.js" type="text/javascript" charset="utf-8"></script> 226 <script src="<?php echo $pluginURL; ?>/solid-code-theme-editor/ace/mode-css.js" type="text/javascript" charset="utf-8"></script> 227 <script src="<?php echo $pluginURL; ?>/solid-code-theme-editor/ace/mode-html.js" type="text/javascript" charset="utf-8"></script> 228 <script src="<?php echo $pluginURL; ?>/solid-code-theme-editor/ace/mode-php.js" type="text/javascript" charset="utf-8"></script> 229 <script src="<?php echo $pluginURL; ?>/solid-code-theme-editor/ace/mode-sql.js" type="text/javascript" charset="utf-8"></script> 230 <script src="<?php echo $pluginURL; ?>/solid-code-theme-editor/ace/mode-text.js" type="text/javascript" charset="utf-8"></script> 231 <script src="<?php echo $pluginURL; ?>/solid-code-theme-editor/ace/mode-xml.js" type="text/javascript" charset="utf-8"></script> 232 <script src="<?php echo $pluginURL; ?>/solid-code-theme-editor/ace/theme-chrome.js" type="text/javascript" charset="utf-8"></script> 168 233 <script type="text/javascript"> 169 234 <!-- … … 229 294 <?php 230 295 //loop through all theme files 231 echo scte_loopThroughFiles($theme s[$theme]['Template Dir'],$themes[$theme]['Template Dir'],$theme,$urlFile);296 echo scte_loopThroughFiles($theme->get_stylesheet_directory(),$theme->get_stylesheet_directory(),$theme->template,$urlFile); 232 297 ?> 233 298 </div> … … 253 318 }else{ 254 319 if($sfile==(str_ireplace($maindir,'',$dir . '/') . $file)){ 255 $strtmp .= '<li><a class="scte_selected_file" href="themes.php?page=scte-theme-editor&theme='.urlencode($theme).'&file='.urlencode(str_ireplace($maindir,'',$dir . '/') . $file).'">' .$file. '</a></li>';320 $strtmp .= '<li><a href="JavaScript:SCTE_delFile(\''.urlencode($theme).'\',\''.urlencode(str_ireplace($maindir,'',$dir . '/') . $file).'\');">Delete</a> | <a class="scte_selected_file" href="themes.php?page=scte-theme-editor&theme='.urlencode($theme).'&file='.urlencode(str_ireplace($maindir,'',$dir . '/') . $file).'">' .$file. '</a></li>'; 256 321 }else{ 257 $strtmp .= '<li><a href=" themes.php?page=scte-theme-editor&theme='.urlencode($theme).'&file='.urlencode(str_ireplace($maindir,'',$dir . '/') . $file).'">' .$file. '</a></li>';322 $strtmp .= '<li><a href="JavaScript:SCTE_delFile(\''.urlencode($theme).'\',\''.urlencode(str_ireplace($maindir,'',$dir . '/') . $file).'\');">Delete</a> | <a href="themes.php?page=scte-theme-editor&theme='.urlencode($theme).'&file='.urlencode(str_ireplace($maindir,'',$dir . '/') . $file).'">' .$file. '</a></li>'; 258 323 } 259 324 } -
solid-code-theme-editor/trunk/scte-script.js
r428278 r689595 6 6 jQuery(this).parent('li').prepend('<a class="scte_nav" id="scte_a_' + itm + '" href="JavaScript:scte_expand(' + itm + ');">+</a> '); 7 7 } 8 }); 9 10 //form fous on new file name 11 jQuery('#newfilename').focus(function(){ 12 if(jQuery(this).val()=='Enter file name') jQuery(this).val(''); 13 }); 14 jQuery('#newfilename').blur(function(){ 15 if(jQuery(this).val()=='') jQuery(this).val('Enter file name'); 8 16 }); 9 17 }); … … 19 27 } 20 28 } 29 30 function SCTE_delFile(urltheme,file){ 31 if(confirm('Are you sure you want to delete ' + file + '?')){ 32 window.location = 'themes.php?page=scte-theme-editor&theme='+ urltheme +'&delfile=1&file=' + file; 33 } 34 }
Note: See TracChangeset
for help on using the changeset viewer.