Changeset 1280474
- Timestamp:
- 11/05/2015 04:07:16 PM (10 years ago)
- Location:
- my-custom-css
- Files:
-
- 2 deleted
- 4 edited
- 1 copied
-
tags/2.2 (copied) (copied from my-custom-css/tags/2.1)
-
tags/2.2/css-icon.png (deleted)
-
tags/2.2/my-custom-css.php (modified) (8 diffs)
-
tags/2.2/readme.txt (modified) (3 diffs)
-
trunk/css-icon.png (deleted)
-
trunk/my-custom-css.php (modified) (8 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
my-custom-css/tags/2.2/my-custom-css.php
r1278942 r1280474 7 7 You can see in action (source code) here: http://vegamami.altervista.org/ :) 8 8 Author: Salvatore Noschese - DarkWolf 9 Version: 2. 19 Version: 2.2 10 10 Author URI: https://laltroweb.it/ 11 11 Text Domain: my-custom-css … … 18 18 } 19 19 20 // Fix first upgrade from old release or manual my_style.css deletion! 21 $mycustomcss = mycustomcss(); 22 if (!empty($mycustomcss) && (!file_exists(css_path()))) 23 { 24 makecss(); 20 function mystylecss_basedir() 21 { 22 $upload_dir = wp_upload_dir(); 23 $mystylecss_basedir = $upload_dir['basedir']; 24 return $mystylecss_basedir; 25 } 26 27 function mystylecss_url() 28 { 29 $upload_dir = wp_upload_dir(); 30 $mystylecss_url = $upload_dir['baseurl']; 31 return $mystylecss_url; 25 32 } 26 33 27 34 // Fix old backup folder or no exist 28 $dirpath = WP_CONTENT_DIR.'/my_custom_css/bkk'; 29 if (!is_dir($dirpath)) 30 { 31 wp_mkdir_p($dirpath); 32 } 33 34 // Make backup when save! 35 if(isset($_POST['save']) || (isset($_POST['save2']))) 36 { 37 35 if (!is_dir(mystylecss_basedir().'/my_custom_css/bkk')) 36 { 37 wp_mkdir_p(mystylecss_basedir().'/my_custom_css/bkk'); 38 } 39 40 // Generate my_style_id url: 41 function my_style_id() 42 { 38 43 $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null; 39 $directory = WP_CONTENT_DIR."/my_custom_css/bkk/*.css"; 40 if (glob($directory) != false) 41 { 42 $filecount = count(glob($directory))+1; 43 } 44 else 45 { 46 $filecount = 1; 47 } 48 $oldname = WP_CONTENT_DIR."/my_custom_css/my_style".$cssid.".css"; 49 $newname = WP_CONTENT_DIR.'/my_custom_css/bkk/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css'; 50 rename($oldname, $newname); 51 } 52 53 // View backup (view only css) 54 if(isset($_POST['viewbackup'])) 55 { 56 $directory = WP_CONTENT_DIR."/my_custom_css/bkk/"; 57 $files=array(); 58 if ($dh=opendir($directory)) 59 { 60 while (($file=readdir($dh))!==false) 61 if ($file!="." && $file!=".." && preg_match("/\.(css)$/", $file)) 62 $files[filemtime($directory.$file)]=$file; 63 closedir($dh); 64 } 65 66 krsort($files); 67 reset($files); 68 $href = WP_CONTENT_URL."/my_custom_css/bkk/"; 69 date_default_timezone_set(ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC'); 70 71 echo " 72 <!DOCTYPE html> 73 <html> 74 <head> 75 <title>My custom CSS - Backup</title> 76 </head> 77 <body style=\"background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray\">"; 78 if (glob($directory."*.css") == false) 79 { 80 echo " 81 <input type=\"button\" value=\"Close now!\" onclick=\"self.close()\" style=\"margin: 0px 20px; float: right\" /> 82 <br /> 83 <div style=\"border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff\"> 84 I can't list any *.css: \"No file found\"... 85 </div>"; 86 } 87 else 88 { 89 echo " 90 <form method=\"post\" action=\"". admin_url( 'admin.php' ) ."?action=my_custom_css?erase_backup\" style=\"margin-right: 20px; float: right\"> 91 <input type=\"button\" value=\"Close now!\" onclick=\"self.close()\" style=\"padding: 2px 5px\" /> 92 | 93 <input type=\"submit\" name=\"erasebackup\" class=\"button\" value=\"Erase backup\" style=\"color: red; padding: 2px 5px\" onclick=\"return confirm('Do you want really delete all backup?');\" /> 94 </form> 95 <br />"; 96 while (list($date,$file)=each($files)) 97 echo " 98 <div style=\"border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff\"> 99 <p><b>File:</b> <a href=\"{$href}{$file}\">{$href}{$file}</a></p> 100 <p><b>Path:</b> {$directory}{$file}</p> 101 <p><b>Saved:</b> ".date('M d Y | h:i:s (a)',current_time( $date ))."</p> 102 <p><b>Size:</b> ".(round(filesize($directory.$file). ' bytes'))." bytes</p> 103 </div>"; 104 } 105 echo " 106 </body> 107 </html>"; 108 } 109 110 111 // Erase backup: 112 if(isset($_POST['erasebackup'])) 113 { 114 echo " 115 <!DOCTYPE html> 116 <html> 117 <head> 118 <title>My custom CSS - Erase Backup</title> 119 </head> 120 <body style=\"background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray\">"; 121 $glob = glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css"); 122 if ($glob == false) 123 { 124 echo " 125 <input type=\"button\" value=\"Close now!\" onclick=\"self.close()\" style=\"margin: 0px 20px; float: right\" /> 126 <br /> 127 <div style=\"border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff\"> 128 I can't delete any *.css: \"No file found\"... 129 </div>"; 130 } 131 else 132 { 133 echo " 134 <input type=\"button\" value=\"Close now!\" onclick=\"self.close()\" style=\"margin: 0px 20px; float: right\" /> 135 <br />"; 136 foreach (glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css") as $filename) 137 { 138 echo " 139 <div style=\"border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff\"> 140 $filename - " . filesize($filename) . "bytes was successfully deleted!!! 141 </div>"; 142 unlink($filename); 143 } 144 } 145 echo " 146 </body> 147 </html>"; 148 } 149 44 $my_style_id = "/my_custom_css/my_style".$cssid.".css"; 45 return $my_style_id; 46 } 47 48 // Generate css url: 49 function css_url() 50 { 51 $css_url = mystylecss_url().my_style_id(); 52 return $css_url; 53 } 54 55 56 // Generate css path: 150 57 function css_path() 151 58 { 152 $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null; 153 $css_path = WP_CONTENT_DIR."/my_custom_css/my_style".$cssid.".css"; 59 $css_path = mystylecss_basedir().my_style_id(); 154 60 return $css_path; 155 61 } 156 62 157 function css_url() 158 { 159 $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null; 160 $css_url = WP_CONTENT_URL."/my_custom_css/my_style".$cssid.".css"; 161 return $css_url; 162 } 163 164 function icon_link() 165 { 166 $icon_link = plugin_dir_url(__FILE__)."css-icon.png"; 167 return $icon_link; 168 } 169 63 // make my_style.css and write write css code! 170 64 function mycustomcss() 171 65 { … … 174 68 return $mycustomcss; 175 69 } 176 70 function mycustomcss_head() 71 { 72 $mycustomcss = mycustomcss(); 73 if (!empty($mycustomcss)) 74 { 75 // Write in source! 76 echo "\n<!-- My Custom CSS -->\n<link rel='stylesheet' id='my-custom-css' href='".css_url()."?".filemtime(css_path())."' type='text/css' media='all' />\n<!-- My Custom CSS -->\n"; 77 } 78 } 177 79 function makecss() 178 80 { 179 // make my_style.css and write write css code!180 $mycustomcss = mycustomcss();181 81 global $wp_filesystem; 182 82 if (empty($wp_filesystem)) … … 185 85 WP_Filesystem(); 186 86 } 187 $makecss = $wp_filesystem->put_contents(css_path(), "/********* Do not edit this file *********/\n/*\nMy Custom CSS - Maked by Salvatore Noschese\na.k.a. DarkWolf - http://www://darkwolf.it/\n*/\n \n".mycustomcss(), 0644);87 $makecss = $wp_filesystem->put_contents(css_path(), "/********* Do not edit this file *********/\n/*\nMy Custom CSS - Maked by Salvatore Noschese\na.k.a. DarkWolf - http://www://darkwolf.it/\n*/\n/********* Do not edit this file *********/\n\n".mycustomcss(), 0644); 188 88 return $makecss; 189 89 } 190 191 192 function mycustomcss_head() 193 { 194 $mycustomcss = mycustomcss(); 195 if (!empty($mycustomcss)) 196 { 197 // Write in source! 198 echo "\n<!-- My Custom CSS -->\n"; 199 echo "<link rel='stylesheet' id='my-custom-css' href='".css_url()."?".filemtime(css_path())."' type='text/css' media='all' />"; 200 echo "\n<!-- My Custom CSS -->\n"; 201 } 202 } 203 90 // Fix first upgrade from old release or manual my_style.css deletion! 91 if (!file_exists(css_path())) 92 { 93 makecss(); 94 } 204 95 205 96 // Start Add link on plugins page … … 226 117 227 118 119 // Icon in base 64 120 function mycustomcss_data_icon() 121 { 122 $mycustomcss_data_icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnNJREFUeNqUU01IVFEU/u77m7/GRqqhbbUpnVAYIULIRoMwmjApaNGiVgViJErUolpE2KKFEIGGi4JK0wpjtCCKqChQxmYKiwojaSW0GJkabGbevNe59zxRalPvvfPuPeee853fK6YubM85FSfiOi7+5xGagKZrC4Y03nY4CdgOoDAEfWJZ03WVyPsR7/DW0DB5MxUxlOfiIvD+CisrAAPQiBybZBXpjsikvc0kPdV2Qtoaysj+ATTdB6It7OX7S+BFuydrYtm9KLBjBf+uSzk0FJpdYOO7a8gzeWqfJw2NlUerKdwQsRbzIxHADAKbDqhUNc6rxKjWasC/DpiooX2YZTsfADr50S3mEykC9HmpLAHA5kUeKPIzwMRm0tGBfXMsf7iFVvKe/EryCiyqjaaKJiurCk3pOL+A3W8oZDI0A8DU0WVwXxWQOYGa8wJ1qWsIw5I1ENyWXBpo/cjKOQLQqRbNaeYXMpx34jVqzwpc79kPQ/hxZGCIAGSLZI4zp2mlYpXzXLBAFLFzQtV4Zg/NiX89YmR8o+cQMq+GEWvcy4HJiYKPQNxqnoPAWtXzrakhDHaTIWUX70upKAe725DNDkOnRnT2j+NOsRmGK5CfHJmtWhplQa+fApMRF908Zj89x+WOhDr78HkMJjXq6mPgNhnnRTkvs687ldxYX7LlyHkD68ApLrqlbOvc6LE26lGZS2FSZgNjQP2jDQfDYS14afzLW6QvNsozSh7BP4h6iXhLL9xb35h29arbEvfOQtLWkNa0Kay8aRrFEXJNHF/1bPrpSTRYOlQ7npxBQ6IP0/0/EyiIMgX67zc47tFfz28BBgBxJMx44bFMEAAAAABJRU5ErkJggg=='; 123 return $mycustomcss_data_icon; 124 } 125 228 126 // Change the CSS for this plugin on admin plugins page 229 127 function mycustomcss_admin_style() … … 232 130 if ($pagenow == "plugins.php") 233 131 { 234 echo "<style type=\"text/css\">\n#my-custom-css td.plugin-title strong {\n\tbackground: url(\"".icon_link()."\") no-repeat 112px 1px;\n}\n#my-custom-css div.row-actions-visible {\n\tpadding-top: 15px;\n}\n#my-custom-css div.plugin-version-author-uri {\n\tbackground-color: #EAEAEA;\n\tborder-radius: 5px;\n\tbox-shadow: 0 8px 6px -6px gray; \n\tfont-weight: bold; \n\tpadding: 7px; \n\tmargin-bottom: 12px;\n}\n</style>\n"; 235 } 236 } 237 238 132 echo "<style type='text/css'>\n#my-custom-css td.plugin-title strong {\n\tbackground: url(".mycustomcss_data_icon().") no-repeat scroll 115px 2px;\n}\n#my-custom-css div.row-actions-visible {\n\tpadding-top: 15px;\n}\n#my-custom-css div.plugin-version-author-uri {\n\tbackground-color: #EAEAEA;\n\tborder-radius: 5px;\n\tbox-shadow: 0 8px 6px -6px gray; \n\tfont-weight: bold; \n\tpadding: 7px; \n\tmargin-bottom: 12px;\n}\n</style>\n"; 133 } 134 } 135 136 137 // Blank index.html to prevent listing directory 138 if(!file_exists(mystylecss_basedir()."/my_custom_css/index.html") || !file_exists(mystylecss_basedir()."/my_custom_css/bkk/index.html")) 139 { 140 global $wp_filesystem; 141 if (empty($wp_filesystem)) 142 { 143 require_once (ABSPATH . '/wp-admin/includes/file.php'); 144 WP_Filesystem(); 145 } 146 $wp_filesystem->put_contents(mystylecss_basedir()."/my_custom_css/index.html", "<!-- Blank index.html to prevent listing directory -->", 0644); 147 $wp_filesystem->put_contents(mystylecss_basedir()."/my_custom_css/bkk/index.html", "<!-- Blank index.html to prevent listing directory -->", 0644); 148 } 149 150 151 // Make backup when save! 152 if(isset($_POST['save'])) 153 { 154 $directory = mystylecss_basedir()."/my_custom_css/bkk/*.css"; 155 if (glob($directory) != false) 156 { 157 $filecount = count(glob($directory))+1; 158 } 159 else 160 { 161 $filecount = 1; 162 } 163 $oldname = css_path(); 164 $newname = mystylecss_basedir().'/my_custom_css/bkk/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css'; 165 rename($oldname, $newname); 166 } 167 168 // View backup (view only css) 169 if(isset($_POST['viewbackup'])) 170 { 171 $directory = mystylecss_basedir()."/my_custom_css/bkk/"; 172 $files=array(); 173 if ($dh=opendir($directory)) 174 { 175 while (($file=readdir($dh))!==false) 176 if ($file!="." && $file!=".." && preg_match("/\.(css)$/", $file)) 177 $files[filemtime($directory.$file)]=$file; 178 closedir($dh); 179 } 180 181 krsort($files); 182 reset($files); 183 $href = mystylecss_url()."/my_custom_css/bkk/"; 184 date_default_timezone_set(ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC'); 185 186 echo ' 187 <!DOCTYPE html> 188 <html> 189 <head> 190 <title>My custom CSS - Backup</title> 191 </head> 192 <body style="background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray">'; 193 if (glob($directory."*.css") == false) 194 { 195 echo ' 196 <input type="button" value="Close now!" onclick="self.close()" style="margin: 0px 20px; float: right" /> 197 <br /> 198 <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff"> 199 I can\'t list any *.css: "No file found"... 200 </div>'; 201 } 202 else 203 { 204 echo ' 205 <form method="post" action="'. admin_url( 'admin.php' ) .'?action=my_custom_css?erase_backup" style="margin-right: 20px; float: right"> 206 <input type="button" value="Close now!" onclick="self.close()" style="padding: 2px 5px" /> 207 | 208 <input type="submit" name="erasebackup" class="button" value="Erase backup" style="color: red; padding: 2px 5px" onclick="return confirm(\'Do you want really delete all backup?\');" /> 209 </form> 210 <br />'; 211 while (list($date,$file)=each($files)) 212 echo ' 213 <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff"> 214 <p><b>File:</b> <a href="'.$href.$file.'">'.$href.$file.'</a></p> 215 <p><b>Path:</b> '.$directory.$file.'</p> 216 <p><b>Saved:</b> '.date("M d Y | h:i:s (a)",current_time($date)).'</p> 217 <p><b>Size:</b> '.(round(filesize($directory.$file). " bytes")).' bytes</p> 218 </div>'; 219 } 220 echo ' 221 </body> 222 </html>'; 223 } 224 225 226 // Erase backup: 227 if(isset($_POST['erasebackup'])) 228 { 229 echo ' 230 <!DOCTYPE html> 231 <html> 232 <head> 233 <title>My custom CSS - Erase Backup</title> 234 </head> 235 <body style="background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray">'; 236 $glob = glob(mystylecss_basedir()."/my_custom_css/bkk/*.css"); 237 if ($glob == false) 238 { 239 echo ' 240 <input type="button" value="Close now!" onclick="self.close()" style="margin: 0px 20px; float: right" /> 241 <br /> 242 <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff"> 243 I can\'t delete any *.css: "No file found"... 244 </div>'; 245 } 246 else 247 { 248 echo ' 249 <input type="button" value="Close now!" onclick="self.close()" style="margin: 0px 20px; float: right" /> 250 <br />'; 251 foreach (glob(mystylecss_basedir()."/my_custom_css/bkk/*.css") as $filename) 252 { 253 echo ' 254 <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff"> 255 '.$filename.' - ' . filesize($filename) . 'bytes was successfully deleted!!! 256 </div>'; 257 unlink($filename); 258 } 259 } 260 echo ' 261 </body> 262 </html>'; 263 } 264 265 266 267 // Admin section: 239 268 function mycustomcss_admin() 240 269 { 241 $plugin_page = add_menu_page(__('My Custom CSS Panel','my-custom-css'),__('My Custom CSS','my-custom-css'), 'manage_options', 'my_custom_css', 'mccss_options', icon_link(), 61);270 $plugin_page = add_menu_page(__('My Custom CSS Panel','my-custom-css'),__('My Custom CSS','my-custom-css'), 'manage_options', 'my_custom_css', 'mccss_options', mycustomcss_data_icon(), 61); 242 271 add_action('admin_init', 'mycustomcss_registersetting'); 243 272 add_action('admin_head-'. $plugin_page, 'mycustomcss_syntax'); … … 272 301 } 273 302 274 303 // Check if is mobile!!! 304 function check_mobile() 305 { 306 $useragent = $_SERVER['HTTP_USER_AGENT']; 307 if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))) 308 { 309 $mobile = "Yes"; 310 } 311 return $mobile; 312 } 313 314 // Option page code: 275 315 function mycustomcss_syntax() 276 316 { 277 ?> 317 $mobile = check_mobile(); 318 if ($mobile != "Yes") 319 { 320 // Function Load jQuery 321 function mycustomcss_scrool_jquery() 322 { 323 wp_enqueue_script('jquery'); 324 } 325 echo ' 326 <script type="text/javascript"> 327 jQuery(document).ready(function($) 328 { 329 $(window).scroll(function() 330 { 331 if ($(this).scrollTop() > 100) 332 { 333 $(\'.scrollup\').fadeIn(); 334 } 335 else 336 { 337 $(\'.scrollup\').fadeOut(); 338 } 339 }); 340 $(\'.scrollup\').click(function() 341 { 342 $("html, body").animate({ scrollTop: 0 }, 600); 343 return false; 344 }); 345 }); 346 </script> 347 <style type="text/css"> 348 .scrollup 349 { 350 width:40px; 351 height:40px; 352 opacity:0.3; 353 position:fixed; 354 bottom:20px; 355 right:25px; 356 display:none; 357 z-index: 10000; 358 text-indent:-9999px; 359 background-image: url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQL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LRz/y7pbUBjGuAS2Ns3lk6c3XCZSFLZbL/B3DZcheq+4dwaXSLetw8AMD5sl45CAAujUEebgdYBAS4MEw0DOAJ0CQcNQ3Td1t5DSh7abymbecwQLg0DhvAkY+aSCmJ4xitNUopoijyMewRwLDql0opdZIkOqvpdKqjKKqawSHAk284j5BPVGnORXCeIOe49r8ycB4gF06ANnAVIRfWJRZCLIVTShXCj0YjpxJbTZJer7cUrkyGXSbJnc1DnU6nEK4IMo5jW8A7gFPbf1ApVQj3E2SSJFpKaQt4CtBymcVCCC2EKHVvu912bTOt4BcLDWNTXBOebgxb2AvWlVnyr8SmKfhtZwilHvwL6yM1jyY1wk1szKNsJq9qgLtysd9WwsDMW8DnHi3gc58WcFbbxgh32Wg9A5dmjNJaqwC798MxRFYz4AV4MMcQsctLvgYA2It91Klq2nkAAAAASUVORK5CYII=\'); 360 outline: none !important; 361 } 362 </style>'; 363 add_action('init', 'mycustomcss_scrool_jquery'); 364 } 365 echo ' 278 366 <!-- Syntax Support Start --> 279 <link type="text/css" rel="stylesheet" href=" <?php echo plugin_dir_url(__FILE__); ?>syntax/codemirror.css" />280 <script language="javascript" src=" <?php echo plugin_dir_url(__FILE__); ?>syntax/codemirror.js"></script>281 <script language="javascript" src=" <?php echo plugin_dir_url(__FILE__); ?>syntax/css.js"></script>367 <link type="text/css" rel="stylesheet" href="'.plugin_dir_url(__FILE__).'syntax/codemirror.css" /> 368 <script language="javascript" src="'.plugin_dir_url(__FILE__).'syntax/codemirror.js"></script> 369 <script language="javascript" src="'.plugin_dir_url(__FILE__).'syntax/css.js"></script> 282 370 <!-- Syntax Support End --> 283 <?php 371 <style type="text/css"> 372 p#footer-upgrade 373 { 374 float: left; 375 padding-left: 5px; 376 font-style: italic; 377 } 378 </style>'; 284 379 } 285 380 … … 292 387 293 388 389 // Textarea/Form: 294 390 function mccss_options() 295 391 { 296 ?> 297 <?php 392 298 393 // Get plugin version: 299 394 $plugin_data = get_plugin_data(__FILE__); 300 395 $plugin_version = $plugin_data['Version']; 301 396 302 $glob = glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css"); 397 // If no backup exist, disable button! 398 $glob = glob(mystylecss_basedir()."/my_custom_css/bkk/*.css"); 303 399 if ($glob == false) 304 400 { 305 $disabled = " title=\"No backup found...\" disabled"; 306 } 307 ?> 401 $submit_backup = " value=\"No backup here...\" title=\"No backup found...\" disabled"; 402 } 403 else 404 $submit_backup = " value=\"View backup :)\" title=\"Click to view all backup!\" "; 405 406 $mobile = check_mobile(); if ($mobile != "Yes") { $no_mobile = '<a href="#" class="scrollup">^Top</a>'; } // Totop only if Not mobile! 407 echo ' 308 408 <div class="wrap"> 309 <h2><?php _e('My Custom CSS Panel','my-custom-css'); echo " - v".$plugin_version ?></h2> 310 <?php 311 // Disable view/erase button for blog id > 1 (security fix in multisite) 409 <h2>' . __('My Custom CSS Panel','my-custom-css') . ' - v'.$plugin_version.'</h2> 410 <form method="post" action="options.php">'; 411 settings_fields( 'mccss_settings' ); 412 echo ' 413 <p>' . __('Custom CSS Code:','my-custom-css') . ' 414 <input type="submit" name="save" class="button-primary" value="' . __('Save','my-custom-css') . '" style="height: 50px; width: 150px; position: fixed; right: 25px; z-index: 5; font-size: 30px; top: 45px;" /> 415 </p> 416 <textarea name="my_custom_css" id="my_custom_css" dir="ltr" style="width:100%;height:350px;">'.get_option('my_custom_css').'</textarea> 417 <script language="javascript">var editor = CodeMirror.fromTextArea(document.getElementById("my_custom_css"), { lineNumbers: true });</script> 418 <p><!-- Smooth Scroll by DarkWolf -->'.$no_mobile.'<!-- Smooth Scroll by DarkWolf --></p> 419 </form>'; 420 421 // Hidden view/erase button for blog id > 1 (security fix in multisite) 312 422 $blog_id = get_current_blog_id(); 313 423 if($blog_id == 1) 314 424 { 315 ?> 316 <form method="post" action="<?php echo admin_url( 'admin.php' ); ?>?action=my_custom_css?show_backup" target="_blank"> 317 <input type="submit" name="viewbackup" class="button-secondary" value="View backup" style="float: right;"<?php echo $disabled; ?> /> 318 </form> 319 <?php 320 } 321 ?> 322 <form method="post" action="options.php"> 323 <?php settings_fields( 'mccss_settings' ); ?> 324 <p><?php _e('Custom CSS Code:','my-custom-css'); ?> 325 <input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-custom-css'); ?>" style="font-size: 20px; height: 35px; position: fixed; top: 35px; right: 25px; z-index: 5;" /> 326 </p> 327 <textarea name="my_custom_css" id="my_custom_css" dir="ltr" style="width:100%;height:350px;"><?php echo get_option('my_custom_css'); ?></textarea> 328 <script language="javascript">var editor = CodeMirror.fromTextArea(document.getElementById("my_custom_css"), { lineNumbers: true });</script> 329 <p> 330 <input type="submit" name="save2" class="button-primary" value="<?php _e('Save','my-custom-css'); ?>" /> 331 <input type="button" class="button-secondary" value="Top^" onclick="self.scrollTo(0, 0); return false;" style="float:right;" /> 332 </p> 333 </form> 334 </div> 335 <?php 336 337 if (!empty($mycustomcss)) 338 { 339 makecss(); 340 } 425 echo ' 426 <form method="post" action="'.admin_url( 'admin.php' ).'?action=my_custom_css?show_backup" target="_blank"> 427 <input type="submit" name="viewbackup" class="button-secondary" style="float: left;"'.$submit_backup.' /> 428 </form>'; 429 } 430 echo ' 431 </div>'; 432 433 // Ok, save css!!! 434 makecss(); 435 341 436 } 342 437 -
my-custom-css/tags/2.2/readme.txt
r1278942 r1280474 5 5 Requires at least: 3.0 6 6 Tested up to: 4.3.1 7 Stable tag: 2. 17 Stable tag: 2.2 8 8 9 9 Enable to add Custom CSS Code via admin panel (with syntax and tab support by CodeMirror) … … 36 36 37 37 1. Custom Menu in Admin Panel + Box 38 2. Source code: <a href="http://vegamami.altervista.org/">Vegamami</a> | Stylesheet: <a href="http:// vegamami.altervista.org/wp-content/plugins/my-custom-css/my_style.css">./my-custom-css/my_style.css</a>38 2. Source code: <a href="http://vegamami.altervista.org/">Vegamami</a> | Stylesheet: <a href="http://www.vegamami.it/wp-content/uploads/my_custom_css/my_style.css">.wp-content/uploads/my_custom_css/my_style.css</a> 39 39 3. Backup List (New Feature)! 40 40 4. Confirm when delete backup! … … 47 47 == Upgrade Notice == 48 48 49 = 2. 1=49 = 2.2 = 50 50 51 * Now my_style.css and backup will be saved in content directory! (no more delete on upgrade)! 52 * More other change in code... 51 * More code clean/rewrite/optimization! 52 * my_style.css no more deleted if blank (but still no show in output)... 53 * Now script generate blank index.html page for prevent directory listing 54 * File now in "wp-content/uploads/" directory (i hope this can fix some issue with some server - sorry, i prefer to don't touch/old user file via script - so, move yourself if u glad)! 55 * Top button improved with code of another my plugin: smooth-page-scroll-to-top (some little code only for this page - a good jquery effect)! 56 * Now only one (big) Saved button on top-right (fixed)! 57 * Now backup button is on bottom/left. 53 58 54 59 == Changelog == 60 61 = 2.2 = 62 63 * More code clean/rewrite/optimization! 64 * my_style.css no more deleted if blank (but still no show in output)... 65 * Now script generate blank index.html page for prevent directory listing 66 * File now in "wp-content/uploads/" directory (i hope this can fix some issue with some server - sorry, i prefer to don't touch/old user file via script - so, move yourself if u glad)! 67 * Top button improved with code of another my plugin: smooth-page-scroll-to-top (some little code only for this page - a good jquery effect)! 68 * Now only one (big) Saved button on top-right (fixed)! 69 * Now backup button is on bottom/left. 55 70 56 71 = 2.1 = -
my-custom-css/trunk/my-custom-css.php
r1278942 r1280474 7 7 You can see in action (source code) here: http://vegamami.altervista.org/ :) 8 8 Author: Salvatore Noschese - DarkWolf 9 Version: 2. 19 Version: 2.2 10 10 Author URI: https://laltroweb.it/ 11 11 Text Domain: my-custom-css … … 18 18 } 19 19 20 // Fix first upgrade from old release or manual my_style.css deletion! 21 $mycustomcss = mycustomcss(); 22 if (!empty($mycustomcss) && (!file_exists(css_path()))) 23 { 24 makecss(); 20 function mystylecss_basedir() 21 { 22 $upload_dir = wp_upload_dir(); 23 $mystylecss_basedir = $upload_dir['basedir']; 24 return $mystylecss_basedir; 25 } 26 27 function mystylecss_url() 28 { 29 $upload_dir = wp_upload_dir(); 30 $mystylecss_url = $upload_dir['baseurl']; 31 return $mystylecss_url; 25 32 } 26 33 27 34 // Fix old backup folder or no exist 28 $dirpath = WP_CONTENT_DIR.'/my_custom_css/bkk'; 29 if (!is_dir($dirpath)) 30 { 31 wp_mkdir_p($dirpath); 32 } 33 34 // Make backup when save! 35 if(isset($_POST['save']) || (isset($_POST['save2']))) 36 { 37 35 if (!is_dir(mystylecss_basedir().'/my_custom_css/bkk')) 36 { 37 wp_mkdir_p(mystylecss_basedir().'/my_custom_css/bkk'); 38 } 39 40 // Generate my_style_id url: 41 function my_style_id() 42 { 38 43 $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null; 39 $directory = WP_CONTENT_DIR."/my_custom_css/bkk/*.css"; 40 if (glob($directory) != false) 41 { 42 $filecount = count(glob($directory))+1; 43 } 44 else 45 { 46 $filecount = 1; 47 } 48 $oldname = WP_CONTENT_DIR."/my_custom_css/my_style".$cssid.".css"; 49 $newname = WP_CONTENT_DIR.'/my_custom_css/bkk/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css'; 50 rename($oldname, $newname); 51 } 52 53 // View backup (view only css) 54 if(isset($_POST['viewbackup'])) 55 { 56 $directory = WP_CONTENT_DIR."/my_custom_css/bkk/"; 57 $files=array(); 58 if ($dh=opendir($directory)) 59 { 60 while (($file=readdir($dh))!==false) 61 if ($file!="." && $file!=".." && preg_match("/\.(css)$/", $file)) 62 $files[filemtime($directory.$file)]=$file; 63 closedir($dh); 64 } 65 66 krsort($files); 67 reset($files); 68 $href = WP_CONTENT_URL."/my_custom_css/bkk/"; 69 date_default_timezone_set(ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC'); 70 71 echo " 72 <!DOCTYPE html> 73 <html> 74 <head> 75 <title>My custom CSS - Backup</title> 76 </head> 77 <body style=\"background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray\">"; 78 if (glob($directory."*.css") == false) 79 { 80 echo " 81 <input type=\"button\" value=\"Close now!\" onclick=\"self.close()\" style=\"margin: 0px 20px; float: right\" /> 82 <br /> 83 <div style=\"border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff\"> 84 I can't list any *.css: \"No file found\"... 85 </div>"; 86 } 87 else 88 { 89 echo " 90 <form method=\"post\" action=\"". admin_url( 'admin.php' ) ."?action=my_custom_css?erase_backup\" style=\"margin-right: 20px; float: right\"> 91 <input type=\"button\" value=\"Close now!\" onclick=\"self.close()\" style=\"padding: 2px 5px\" /> 92 | 93 <input type=\"submit\" name=\"erasebackup\" class=\"button\" value=\"Erase backup\" style=\"color: red; padding: 2px 5px\" onclick=\"return confirm('Do you want really delete all backup?');\" /> 94 </form> 95 <br />"; 96 while (list($date,$file)=each($files)) 97 echo " 98 <div style=\"border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff\"> 99 <p><b>File:</b> <a href=\"{$href}{$file}\">{$href}{$file}</a></p> 100 <p><b>Path:</b> {$directory}{$file}</p> 101 <p><b>Saved:</b> ".date('M d Y | h:i:s (a)',current_time( $date ))."</p> 102 <p><b>Size:</b> ".(round(filesize($directory.$file). ' bytes'))." bytes</p> 103 </div>"; 104 } 105 echo " 106 </body> 107 </html>"; 108 } 109 110 111 // Erase backup: 112 if(isset($_POST['erasebackup'])) 113 { 114 echo " 115 <!DOCTYPE html> 116 <html> 117 <head> 118 <title>My custom CSS - Erase Backup</title> 119 </head> 120 <body style=\"background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray\">"; 121 $glob = glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css"); 122 if ($glob == false) 123 { 124 echo " 125 <input type=\"button\" value=\"Close now!\" onclick=\"self.close()\" style=\"margin: 0px 20px; float: right\" /> 126 <br /> 127 <div style=\"border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff\"> 128 I can't delete any *.css: \"No file found\"... 129 </div>"; 130 } 131 else 132 { 133 echo " 134 <input type=\"button\" value=\"Close now!\" onclick=\"self.close()\" style=\"margin: 0px 20px; float: right\" /> 135 <br />"; 136 foreach (glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css") as $filename) 137 { 138 echo " 139 <div style=\"border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff\"> 140 $filename - " . filesize($filename) . "bytes was successfully deleted!!! 141 </div>"; 142 unlink($filename); 143 } 144 } 145 echo " 146 </body> 147 </html>"; 148 } 149 44 $my_style_id = "/my_custom_css/my_style".$cssid.".css"; 45 return $my_style_id; 46 } 47 48 // Generate css url: 49 function css_url() 50 { 51 $css_url = mystylecss_url().my_style_id(); 52 return $css_url; 53 } 54 55 56 // Generate css path: 150 57 function css_path() 151 58 { 152 $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null; 153 $css_path = WP_CONTENT_DIR."/my_custom_css/my_style".$cssid.".css"; 59 $css_path = mystylecss_basedir().my_style_id(); 154 60 return $css_path; 155 61 } 156 62 157 function css_url() 158 { 159 $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null; 160 $css_url = WP_CONTENT_URL."/my_custom_css/my_style".$cssid.".css"; 161 return $css_url; 162 } 163 164 function icon_link() 165 { 166 $icon_link = plugin_dir_url(__FILE__)."css-icon.png"; 167 return $icon_link; 168 } 169 63 // make my_style.css and write write css code! 170 64 function mycustomcss() 171 65 { … … 174 68 return $mycustomcss; 175 69 } 176 70 function mycustomcss_head() 71 { 72 $mycustomcss = mycustomcss(); 73 if (!empty($mycustomcss)) 74 { 75 // Write in source! 76 echo "\n<!-- My Custom CSS -->\n<link rel='stylesheet' id='my-custom-css' href='".css_url()."?".filemtime(css_path())."' type='text/css' media='all' />\n<!-- My Custom CSS -->\n"; 77 } 78 } 177 79 function makecss() 178 80 { 179 // make my_style.css and write write css code!180 $mycustomcss = mycustomcss();181 81 global $wp_filesystem; 182 82 if (empty($wp_filesystem)) … … 185 85 WP_Filesystem(); 186 86 } 187 $makecss = $wp_filesystem->put_contents(css_path(), "/********* Do not edit this file *********/\n/*\nMy Custom CSS - Maked by Salvatore Noschese\na.k.a. DarkWolf - http://www://darkwolf.it/\n*/\n \n".mycustomcss(), 0644);87 $makecss = $wp_filesystem->put_contents(css_path(), "/********* Do not edit this file *********/\n/*\nMy Custom CSS - Maked by Salvatore Noschese\na.k.a. DarkWolf - http://www://darkwolf.it/\n*/\n/********* Do not edit this file *********/\n\n".mycustomcss(), 0644); 188 88 return $makecss; 189 89 } 190 191 192 function mycustomcss_head() 193 { 194 $mycustomcss = mycustomcss(); 195 if (!empty($mycustomcss)) 196 { 197 // Write in source! 198 echo "\n<!-- My Custom CSS -->\n"; 199 echo "<link rel='stylesheet' id='my-custom-css' href='".css_url()."?".filemtime(css_path())."' type='text/css' media='all' />"; 200 echo "\n<!-- My Custom CSS -->\n"; 201 } 202 } 203 90 // Fix first upgrade from old release or manual my_style.css deletion! 91 if (!file_exists(css_path())) 92 { 93 makecss(); 94 } 204 95 205 96 // Start Add link on plugins page … … 226 117 227 118 119 // Icon in base 64 120 function mycustomcss_data_icon() 121 { 122 $mycustomcss_data_icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnNJREFUeNqUU01IVFEU/u77m7/GRqqhbbUpnVAYIULIRoMwmjApaNGiVgViJErUolpE2KKFEIGGi4JK0wpjtCCKqChQxmYKiwojaSW0GJkabGbevNe59zxRalPvvfPuPeee853fK6YubM85FSfiOi7+5xGagKZrC4Y03nY4CdgOoDAEfWJZ03WVyPsR7/DW0DB5MxUxlOfiIvD+CisrAAPQiBybZBXpjsikvc0kPdV2Qtoaysj+ATTdB6It7OX7S+BFuydrYtm9KLBjBf+uSzk0FJpdYOO7a8gzeWqfJw2NlUerKdwQsRbzIxHADAKbDqhUNc6rxKjWasC/DpiooX2YZTsfADr50S3mEykC9HmpLAHA5kUeKPIzwMRm0tGBfXMsf7iFVvKe/EryCiyqjaaKJiurCk3pOL+A3W8oZDI0A8DU0WVwXxWQOYGa8wJ1qWsIw5I1ENyWXBpo/cjKOQLQqRbNaeYXMpx34jVqzwpc79kPQ/hxZGCIAGSLZI4zp2mlYpXzXLBAFLFzQtV4Zg/NiX89YmR8o+cQMq+GEWvcy4HJiYKPQNxqnoPAWtXzrakhDHaTIWUX70upKAe725DNDkOnRnT2j+NOsRmGK5CfHJmtWhplQa+fApMRF908Zj89x+WOhDr78HkMJjXq6mPgNhnnRTkvs687ldxYX7LlyHkD68ApLrqlbOvc6LE26lGZS2FSZgNjQP2jDQfDYS14afzLW6QvNsozSh7BP4h6iXhLL9xb35h29arbEvfOQtLWkNa0Kay8aRrFEXJNHF/1bPrpSTRYOlQ7npxBQ6IP0/0/EyiIMgX67zc47tFfz28BBgBxJMx44bFMEAAAAABJRU5ErkJggg=='; 123 return $mycustomcss_data_icon; 124 } 125 228 126 // Change the CSS for this plugin on admin plugins page 229 127 function mycustomcss_admin_style() … … 232 130 if ($pagenow == "plugins.php") 233 131 { 234 echo "<style type=\"text/css\">\n#my-custom-css td.plugin-title strong {\n\tbackground: url(\"".icon_link()."\") no-repeat 112px 1px;\n}\n#my-custom-css div.row-actions-visible {\n\tpadding-top: 15px;\n}\n#my-custom-css div.plugin-version-author-uri {\n\tbackground-color: #EAEAEA;\n\tborder-radius: 5px;\n\tbox-shadow: 0 8px 6px -6px gray; \n\tfont-weight: bold; \n\tpadding: 7px; \n\tmargin-bottom: 12px;\n}\n</style>\n"; 235 } 236 } 237 238 132 echo "<style type='text/css'>\n#my-custom-css td.plugin-title strong {\n\tbackground: url(".mycustomcss_data_icon().") no-repeat scroll 115px 2px;\n}\n#my-custom-css div.row-actions-visible {\n\tpadding-top: 15px;\n}\n#my-custom-css div.plugin-version-author-uri {\n\tbackground-color: #EAEAEA;\n\tborder-radius: 5px;\n\tbox-shadow: 0 8px 6px -6px gray; \n\tfont-weight: bold; \n\tpadding: 7px; \n\tmargin-bottom: 12px;\n}\n</style>\n"; 133 } 134 } 135 136 137 // Blank index.html to prevent listing directory 138 if(!file_exists(mystylecss_basedir()."/my_custom_css/index.html") || !file_exists(mystylecss_basedir()."/my_custom_css/bkk/index.html")) 139 { 140 global $wp_filesystem; 141 if (empty($wp_filesystem)) 142 { 143 require_once (ABSPATH . '/wp-admin/includes/file.php'); 144 WP_Filesystem(); 145 } 146 $wp_filesystem->put_contents(mystylecss_basedir()."/my_custom_css/index.html", "<!-- Blank index.html to prevent listing directory -->", 0644); 147 $wp_filesystem->put_contents(mystylecss_basedir()."/my_custom_css/bkk/index.html", "<!-- Blank index.html to prevent listing directory -->", 0644); 148 } 149 150 151 // Make backup when save! 152 if(isset($_POST['save'])) 153 { 154 $directory = mystylecss_basedir()."/my_custom_css/bkk/*.css"; 155 if (glob($directory) != false) 156 { 157 $filecount = count(glob($directory))+1; 158 } 159 else 160 { 161 $filecount = 1; 162 } 163 $oldname = css_path(); 164 $newname = mystylecss_basedir().'/my_custom_css/bkk/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css'; 165 rename($oldname, $newname); 166 } 167 168 // View backup (view only css) 169 if(isset($_POST['viewbackup'])) 170 { 171 $directory = mystylecss_basedir()."/my_custom_css/bkk/"; 172 $files=array(); 173 if ($dh=opendir($directory)) 174 { 175 while (($file=readdir($dh))!==false) 176 if ($file!="." && $file!=".." && preg_match("/\.(css)$/", $file)) 177 $files[filemtime($directory.$file)]=$file; 178 closedir($dh); 179 } 180 181 krsort($files); 182 reset($files); 183 $href = mystylecss_url()."/my_custom_css/bkk/"; 184 date_default_timezone_set(ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC'); 185 186 echo ' 187 <!DOCTYPE html> 188 <html> 189 <head> 190 <title>My custom CSS - Backup</title> 191 </head> 192 <body style="background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray">'; 193 if (glob($directory."*.css") == false) 194 { 195 echo ' 196 <input type="button" value="Close now!" onclick="self.close()" style="margin: 0px 20px; float: right" /> 197 <br /> 198 <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff"> 199 I can\'t list any *.css: "No file found"... 200 </div>'; 201 } 202 else 203 { 204 echo ' 205 <form method="post" action="'. admin_url( 'admin.php' ) .'?action=my_custom_css?erase_backup" style="margin-right: 20px; float: right"> 206 <input type="button" value="Close now!" onclick="self.close()" style="padding: 2px 5px" /> 207 | 208 <input type="submit" name="erasebackup" class="button" value="Erase backup" style="color: red; padding: 2px 5px" onclick="return confirm(\'Do you want really delete all backup?\');" /> 209 </form> 210 <br />'; 211 while (list($date,$file)=each($files)) 212 echo ' 213 <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff"> 214 <p><b>File:</b> <a href="'.$href.$file.'">'.$href.$file.'</a></p> 215 <p><b>Path:</b> '.$directory.$file.'</p> 216 <p><b>Saved:</b> '.date("M d Y | h:i:s (a)",current_time($date)).'</p> 217 <p><b>Size:</b> '.(round(filesize($directory.$file). " bytes")).' bytes</p> 218 </div>'; 219 } 220 echo ' 221 </body> 222 </html>'; 223 } 224 225 226 // Erase backup: 227 if(isset($_POST['erasebackup'])) 228 { 229 echo ' 230 <!DOCTYPE html> 231 <html> 232 <head> 233 <title>My custom CSS - Erase Backup</title> 234 </head> 235 <body style="background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray">'; 236 $glob = glob(mystylecss_basedir()."/my_custom_css/bkk/*.css"); 237 if ($glob == false) 238 { 239 echo ' 240 <input type="button" value="Close now!" onclick="self.close()" style="margin: 0px 20px; float: right" /> 241 <br /> 242 <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff"> 243 I can\'t delete any *.css: "No file found"... 244 </div>'; 245 } 246 else 247 { 248 echo ' 249 <input type="button" value="Close now!" onclick="self.close()" style="margin: 0px 20px; float: right" /> 250 <br />'; 251 foreach (glob(mystylecss_basedir()."/my_custom_css/bkk/*.css") as $filename) 252 { 253 echo ' 254 <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff"> 255 '.$filename.' - ' . filesize($filename) . 'bytes was successfully deleted!!! 256 </div>'; 257 unlink($filename); 258 } 259 } 260 echo ' 261 </body> 262 </html>'; 263 } 264 265 266 267 // Admin section: 239 268 function mycustomcss_admin() 240 269 { 241 $plugin_page = add_menu_page(__('My Custom CSS Panel','my-custom-css'),__('My Custom CSS','my-custom-css'), 'manage_options', 'my_custom_css', 'mccss_options', icon_link(), 61);270 $plugin_page = add_menu_page(__('My Custom CSS Panel','my-custom-css'),__('My Custom CSS','my-custom-css'), 'manage_options', 'my_custom_css', 'mccss_options', mycustomcss_data_icon(), 61); 242 271 add_action('admin_init', 'mycustomcss_registersetting'); 243 272 add_action('admin_head-'. $plugin_page, 'mycustomcss_syntax'); … … 272 301 } 273 302 274 303 // Check if is mobile!!! 304 function check_mobile() 305 { 306 $useragent = $_SERVER['HTTP_USER_AGENT']; 307 if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))) 308 { 309 $mobile = "Yes"; 310 } 311 return $mobile; 312 } 313 314 // Option page code: 275 315 function mycustomcss_syntax() 276 316 { 277 ?> 317 $mobile = check_mobile(); 318 if ($mobile != "Yes") 319 { 320 // Function Load jQuery 321 function mycustomcss_scrool_jquery() 322 { 323 wp_enqueue_script('jquery'); 324 } 325 echo ' 326 <script type="text/javascript"> 327 jQuery(document).ready(function($) 328 { 329 $(window).scroll(function() 330 { 331 if ($(this).scrollTop() > 100) 332 { 333 $(\'.scrollup\').fadeIn(); 334 } 335 else 336 { 337 $(\'.scrollup\').fadeOut(); 338 } 339 }); 340 $(\'.scrollup\').click(function() 341 { 342 $("html, body").animate({ scrollTop: 0 }, 600); 343 return false; 344 }); 345 }); 346 </script> 347 <style type="text/css"> 348 .scrollup 349 { 350 width:40px; 351 height:40px; 352 opacity:0.3; 353 position:fixed; 354 bottom:20px; 355 right:25px; 356 display:none; 357 z-index: 10000; 358 text-indent:-9999px; 359 background-image: url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2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y2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAepJREFUeNrcmbFKw0AYx39WKAgOQXAS5AQf4EAQuhWfoIPQZ/ANBEEq+ACFTk43CFJxKIU+hSAtguAgBF2cSganDnIuFwnBhtzljFf/8E1JLr98X+7j7n9ruGsX6AIHwD4ggXVz7ROYATFwD9wCb9SgLeACeAS0ZTyaZ7d+A2wTOAM+HMDy8WHG2vQFdwy8ewDLx7sZ21nrQP8XwPLRz/y7pbUBjGuAS2Ns3lk6c3XCZSFLZbL/B3DZcheq+4dwaXSLetw8AMD5sl45CAAujUEebgdYBAS4MEw0DOAJ0CQcNQ3Td1t5DSh7abymbecwQLg0DhvAkY+aSCmJ4xitNUopoijyMewRwLDql0opdZIkOqvpdKqjKKqawSHAk284j5BPVGnORXCeIOe49r8ycB4gF06ANnAVIRfWJRZCLIVTShXCj0YjpxJbTZJer7cUrkyGXSbJnc1DnU6nEK4IMo5jW8A7gFPbf1ApVQj3E2SSJFpKaQt4CtBymcVCCC2EKHVvu912bTOt4BcLDWNTXBOebgxb2AvWlVnyr8SmKfhtZwilHvwL6yM1jyY1wk1szKNsJq9qgLtysd9WwsDMW8DnHi3gc58WcFbbxgh32Wg9A5dmjNJaqwC798MxRFYz4AV4MMcQsctLvgYA2It91Klq2nkAAAAASUVORK5CYII=\'); 360 outline: none !important; 361 } 362 </style>'; 363 add_action('init', 'mycustomcss_scrool_jquery'); 364 } 365 echo ' 278 366 <!-- Syntax Support Start --> 279 <link type="text/css" rel="stylesheet" href=" <?php echo plugin_dir_url(__FILE__); ?>syntax/codemirror.css" />280 <script language="javascript" src=" <?php echo plugin_dir_url(__FILE__); ?>syntax/codemirror.js"></script>281 <script language="javascript" src=" <?php echo plugin_dir_url(__FILE__); ?>syntax/css.js"></script>367 <link type="text/css" rel="stylesheet" href="'.plugin_dir_url(__FILE__).'syntax/codemirror.css" /> 368 <script language="javascript" src="'.plugin_dir_url(__FILE__).'syntax/codemirror.js"></script> 369 <script language="javascript" src="'.plugin_dir_url(__FILE__).'syntax/css.js"></script> 282 370 <!-- Syntax Support End --> 283 <?php 371 <style type="text/css"> 372 p#footer-upgrade 373 { 374 float: left; 375 padding-left: 5px; 376 font-style: italic; 377 } 378 </style>'; 284 379 } 285 380 … … 292 387 293 388 389 // Textarea/Form: 294 390 function mccss_options() 295 391 { 296 ?> 297 <?php 392 298 393 // Get plugin version: 299 394 $plugin_data = get_plugin_data(__FILE__); 300 395 $plugin_version = $plugin_data['Version']; 301 396 302 $glob = glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css"); 397 // If no backup exist, disable button! 398 $glob = glob(mystylecss_basedir()."/my_custom_css/bkk/*.css"); 303 399 if ($glob == false) 304 400 { 305 $disabled = " title=\"No backup found...\" disabled"; 306 } 307 ?> 401 $submit_backup = " value=\"No backup here...\" title=\"No backup found...\" disabled"; 402 } 403 else 404 $submit_backup = " value=\"View backup :)\" title=\"Click to view all backup!\" "; 405 406 $mobile = check_mobile(); if ($mobile != "Yes") { $no_mobile = '<a href="#" class="scrollup">^Top</a>'; } // Totop only if Not mobile! 407 echo ' 308 408 <div class="wrap"> 309 <h2><?php _e('My Custom CSS Panel','my-custom-css'); echo " - v".$plugin_version ?></h2> 310 <?php 311 // Disable view/erase button for blog id > 1 (security fix in multisite) 409 <h2>' . __('My Custom CSS Panel','my-custom-css') . ' - v'.$plugin_version.'</h2> 410 <form method="post" action="options.php">'; 411 settings_fields( 'mccss_settings' ); 412 echo ' 413 <p>' . __('Custom CSS Code:','my-custom-css') . ' 414 <input type="submit" name="save" class="button-primary" value="' . __('Save','my-custom-css') . '" style="height: 50px; width: 150px; position: fixed; right: 25px; z-index: 5; font-size: 30px; top: 45px;" /> 415 </p> 416 <textarea name="my_custom_css" id="my_custom_css" dir="ltr" style="width:100%;height:350px;">'.get_option('my_custom_css').'</textarea> 417 <script language="javascript">var editor = CodeMirror.fromTextArea(document.getElementById("my_custom_css"), { lineNumbers: true });</script> 418 <p><!-- Smooth Scroll by DarkWolf -->'.$no_mobile.'<!-- Smooth Scroll by DarkWolf --></p> 419 </form>'; 420 421 // Hidden view/erase button for blog id > 1 (security fix in multisite) 312 422 $blog_id = get_current_blog_id(); 313 423 if($blog_id == 1) 314 424 { 315 ?> 316 <form method="post" action="<?php echo admin_url( 'admin.php' ); ?>?action=my_custom_css?show_backup" target="_blank"> 317 <input type="submit" name="viewbackup" class="button-secondary" value="View backup" style="float: right;"<?php echo $disabled; ?> /> 318 </form> 319 <?php 320 } 321 ?> 322 <form method="post" action="options.php"> 323 <?php settings_fields( 'mccss_settings' ); ?> 324 <p><?php _e('Custom CSS Code:','my-custom-css'); ?> 325 <input type="submit" name="save" class="button-primary" value="<?php _e('Save','my-custom-css'); ?>" style="font-size: 20px; height: 35px; position: fixed; top: 35px; right: 25px; z-index: 5;" /> 326 </p> 327 <textarea name="my_custom_css" id="my_custom_css" dir="ltr" style="width:100%;height:350px;"><?php echo get_option('my_custom_css'); ?></textarea> 328 <script language="javascript">var editor = CodeMirror.fromTextArea(document.getElementById("my_custom_css"), { lineNumbers: true });</script> 329 <p> 330 <input type="submit" name="save2" class="button-primary" value="<?php _e('Save','my-custom-css'); ?>" /> 331 <input type="button" class="button-secondary" value="Top^" onclick="self.scrollTo(0, 0); return false;" style="float:right;" /> 332 </p> 333 </form> 334 </div> 335 <?php 336 337 if (!empty($mycustomcss)) 338 { 339 makecss(); 340 } 425 echo ' 426 <form method="post" action="'.admin_url( 'admin.php' ).'?action=my_custom_css?show_backup" target="_blank"> 427 <input type="submit" name="viewbackup" class="button-secondary" style="float: left;"'.$submit_backup.' /> 428 </form>'; 429 } 430 echo ' 431 </div>'; 432 433 // Ok, save css!!! 434 makecss(); 435 341 436 } 342 437 -
my-custom-css/trunk/readme.txt
r1278942 r1280474 5 5 Requires at least: 3.0 6 6 Tested up to: 4.3.1 7 Stable tag: 2. 17 Stable tag: 2.2 8 8 9 9 Enable to add Custom CSS Code via admin panel (with syntax and tab support by CodeMirror) … … 36 36 37 37 1. Custom Menu in Admin Panel + Box 38 2. Source code: <a href="http://vegamami.altervista.org/">Vegamami</a> | Stylesheet: <a href="http:// vegamami.altervista.org/wp-content/plugins/my-custom-css/my_style.css">./my-custom-css/my_style.css</a>38 2. Source code: <a href="http://vegamami.altervista.org/">Vegamami</a> | Stylesheet: <a href="http://www.vegamami.it/wp-content/uploads/my_custom_css/my_style.css">.wp-content/uploads/my_custom_css/my_style.css</a> 39 39 3. Backup List (New Feature)! 40 40 4. Confirm when delete backup! … … 47 47 == Upgrade Notice == 48 48 49 = 2. 1=49 = 2.2 = 50 50 51 * Now my_style.css and backup will be saved in content directory! (no more delete on upgrade)! 52 * More other change in code... 51 * More code clean/rewrite/optimization! 52 * my_style.css no more deleted if blank (but still no show in output)... 53 * Now script generate blank index.html page for prevent directory listing 54 * File now in "wp-content/uploads/" directory (i hope this can fix some issue with some server - sorry, i prefer to don't touch/old user file via script - so, move yourself if u glad)! 55 * Top button improved with code of another my plugin: smooth-page-scroll-to-top (some little code only for this page - a good jquery effect)! 56 * Now only one (big) Saved button on top-right (fixed)! 57 * Now backup button is on bottom/left. 53 58 54 59 == Changelog == 60 61 = 2.2 = 62 63 * More code clean/rewrite/optimization! 64 * my_style.css no more deleted if blank (but still no show in output)... 65 * Now script generate blank index.html page for prevent directory listing 66 * File now in "wp-content/uploads/" directory (i hope this can fix some issue with some server - sorry, i prefer to don't touch/old user file via script - so, move yourself if u glad)! 67 * Top button improved with code of another my plugin: smooth-page-scroll-to-top (some little code only for this page - a good jquery effect)! 68 * Now only one (big) Saved button on top-right (fixed)! 69 * Now backup button is on bottom/left. 55 70 56 71 = 2.1 =
Note: See TracChangeset
for help on using the changeset viewer.