Changeset 517648
- Timestamp:
- 03/11/2012 09:11:47 PM (14 years ago)
- Location:
- pretty-file-lister/trunk
- Files:
-
- 5 added
- 3 edited
-
PrettyFileList.php (modified) (10 diffs)
-
includes (added)
-
includes/button_popup.php (added)
-
includes/tinymce.css (added)
-
js/customcodes.js (added)
-
js/prettygen.js (added)
-
js/style_previewer.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pretty-file-lister/trunk/PrettyFileList.php
r514601 r517648 4 4 Plugin URI: http://www.smartredfox.com/prettylist 5 5 Description: A plugin that lists files attached to the current post/page. 6 Version: 0. 16 Version: 0.2 7 7 Author: James Botham 8 8 Author URI: http://www.smartredfox.com … … 21 21 if(!is_admin()) 22 22 { 23 add_shortcode('prettyfilelist', array($this, 'prettyfilelist_shortcode')); 23 add_shortcode('prettyfilelist', array($this, 'prettyfilelist_shortcode')); 24 24 } 25 25 } … … 51 51 //Attach save event for Settings page 52 52 add_filter( 'attachment_fields_to_save', array($this,'srf_attachment_field_prettylist_save'), 10, 2 ); 53 //Add shortcode button 54 add_action('init', array($this,'add_button')); 53 55 } 54 56 } … … 88 90 return $html; 89 91 } 90 92 91 93 //Add Stylesheet 92 94 public function prettyfilelist_stylesheets() … … 94 96 //Get user selected stylesheet if any 95 97 $options['stylesheet_to_use'] = get_option('stylesheet_to_use'); 96 97 $stylesheet_url = PRETTY_FILE_LIST_URL . '/styles/prettylist.css'; 98 98 $option = $options['stylesheet_to_use']; 99 $stylesheet_url = PRETTY_FILE_LIST_URL . 'styles/prettylinks.css'; 100 101 //Add our prettylist stylesheet 99 102 if($options['stylesheet_to_use'] != ""){ 100 //Add our prettylist stylesheet 101 $stylesheet_url = PRETTY_FILE_LIST_URL . '/styles/' . $options['stylesheet_to_use']; 102 } 103 //See if the selected style has a hash in it (this means it's an alt style) 104 if(strpos($options['stylesheet_to_use'],'#') > 0){ 105 //See if the file exists in the template directory first 106 //if(!file_exists($stylesheet_url)){ 107 $cleanOption = str_replace("#", "", $option); 108 $stylesheet_url = (get_bloginfo('template_url') . '/prettystyles/' . $cleanOption); 109 //} 110 } 111 else{ 112 //If not, fallback to plugin version 113 $stylesheet_url = (PRETTY_FILE_LIST_URL . 'styles/' . $options['stylesheet_to_use']); 114 } 115 } 116 117 //echo $stylesheet_url; 103 118 104 119 wp_register_style('srfprettylistStyleSheets', $stylesheet_url); 105 wp_enqueue_style( 'srfprettylistStyleSheets'); 120 wp_enqueue_style( 'srfprettylistStyleSheets'); 106 121 } 107 122 … … 216 231 function srf_prettylist_admin_scripts() 217 232 { 218 $params = array('pluginUrl' => PRETTY_FILE_LIST_URL );233 $params = array('pluginUrl' => PRETTY_FILE_LIST_URL,'altPluginUrl' => get_bloginfo('template_directory') . '/prettystyles/'); 219 234 wp_register_script('prettylistpreviewer', PRETTY_FILE_LIST_URL . '/js/style_previewer.js'); 220 235 wp_localize_script('prettylistpreviewer', 'prettylistScriptParams', $params ); … … 245 260 } 246 261 247 // path to directoryto scan262 //Path to directories to scan 248 263 $directory = PRETTY_FILE_LIST_PATH . '/styles/'; 264 $altDirectory = get_template_directory() . '/prettystyles/'; 249 265 250 266 //get all css files with a .css extension. 251 267 $styles = glob($directory . "*.css"); 268 $altStyles = glob($altDirectory . "*.css"); 252 269 253 270 //Get our options 254 271 $options['stylesheet_to_use'] = get_option('stylesheet_to_use'); 255 272 256 //Display options form257 echo '<div style="background-color:#eee;border:solid 1px #ccc;border-radius:3px;float:right;margin:20px;padding:10px;width:300px;">273 //Display options form 274 echo '<div style="background-color:#eee;border:solid 1px #ccc;border-radius:3px;float:right;margin:20px;padding:10px;width:300px;"> 258 275 <div style="background-color:#fff;border:solid 1px #ccc;float:right;"> 259 276 <img src="http://www.smartredfox.com/wp-content/uploads/2012/02/All_styles-150x150.png" style="margin:5px;" /> … … 265 282 <div class="wrap">'.$message. 266 283 '<div id="icon-options-general" class="icon32"><br /></div> 267 <h2> prettylist Settings</h2>284 <h2>Pretty file list Settings</h2> 268 285 269 286 <form method="post" action=""> … … 278 295 { 279 296 echo '<option value="' . basename($style) .'"' . (basename($style) == $options['stylesheet_to_use'] ? 'selected="selected"' : '') . '>' . basename($style) . '</option>'; 297 } 298 foreach($altStyles as $style) 299 { 300 echo '<option value="' . basename($style) .'#"' . (basename($style) == $options['stylesheet_to_use'] ? 'selected="selected"' : '') . '>' . basename($style) . ' (Custom)</option>'; 280 301 } 281 302 … … 301 322 return $post; 302 323 } 324 325 /********************* 326 ADD SHORTCODE BUTTON 327 **********************/ 328 329 function add_button() { 330 if ( current_user_can('edit_posts') && current_user_can('edit_pages') ) 331 { 332 add_filter('mce_external_plugins', array($this,'add_plugin')); 333 add_filter('mce_buttons', array($this,'register_button')); 334 } 335 } 336 337 function register_button($buttons) { 338 array_push($buttons, "prettylist"); 339 return $buttons; 340 } 341 342 function add_plugin($plugin_array) { 343 $plugin_array['prettylist'] = PRETTY_FILE_LIST_URL.'js/prettygen.js'; 344 return $plugin_array; 345 } 346 347 /************************* 348 UPGRADE FUNCTIONALITY TO SAVE STYLE PACK 349 **************************/ 350 function hpt_copyr($source, $dest) 351 { 352 // Check for symlinks 353 if (is_link($source)) { 354 return symlink(readlink($source), $dest); 355 } 356 357 // Simple copy for a file 358 if (is_file($source)) { 359 return copy($source, $dest); 360 } 361 362 // Make destination directory 363 if (!is_dir($dest)) { 364 mkdir($dest); 365 } 366 367 // Loop through the folder 368 $dir = dir($source); 369 while (false !== $entry = $dir->read()) { 370 // Skip pointers 371 if ($entry == '.' || $entry == '..') { 372 continue; 373 } 374 375 // Deep copy directories 376 $this->hpt_copyr("$source/$entry", "$dest/$entry"); 377 } 378 379 // Clean up 380 $dir->close(); 381 return true; 382 } 383 384 function hpt_backup() 385 { 386 $from = PRETTY_FILE_LIST_PATH."styles/"; 387 $to = WP_CONTENT_DIR."/uploads/prettystyles/"; 388 $this->hpt_copyr($from, $to); 389 } 390 function hpt_recover() 391 { 392 $from = WP_CONTENT_DIR."/uploads/prettystyles/"; 393 $to = PRETTY_FILE_LIST_PATH."styles/"; 394 $this->hpt_copyr($from, $to); 395 if (is_dir($from)) { 396 rmdir($from); 397 } 398 } 303 399 } 304 400 -
pretty-file-lister/trunk/js/style_previewer.js
r514601 r517648 4 4 { 5 5 jQuery.get(prettylistScriptParams.pluginUrl + '/styles/prettylist.css', updateImageUrls); 6 7 6 } 8 7 else 9 8 { 10 jQuery.get(prettylistScriptParams.pluginUrl + '/styles/' + jQuery('#show_pages').attr('value'), updateImageUrls); 9 //If it contains a hash it's an alt style 10 if((jQuery('#show_pages').attr('value')).indexOf('#') > 0){ 11 jQuery.get(prettylistScriptParams.altPluginUrl + jQuery('#show_pages').attr('value'), updateImageUrls); 12 } 13 else{ 14 jQuery.get(prettylistScriptParams.pluginUrl + '/styles/' + jQuery('#show_pages').attr('value'), updateImageUrls); 15 } 11 16 } 12 17 13 /*After selecting a stylesheet*/ 18 /*After selecting a stylesheet*/ 14 19 jQuery('#show_pages').change(function(){ 20 //If it contains a hash it's an alt style 21 if((jQuery('#show_pages').attr('value')).indexOf('#') > 0){ 22 jQuery.get(prettylistScriptParams.altPluginUrl + jQuery('#show_pages').attr('value'), updateImageUrls); 23 } 24 else{ 25 jQuery.get(prettylistScriptParams.pluginUrl + '/styles/' + jQuery('#show_pages').attr('value'), updateImageUrls); 26 } 27 15 28 //Load styles 16 jQuery.get(prettylistScriptParams.pluginUrl + '/styles/' + jQuery(this).attr('value'), updateImageUrls);29 //jQuery.get(prettylistScriptParams.pluginUrl + '/styles/' + jQuery(this).attr('value'), updateImageUrls); 17 30 }); 18 31 19 function updateImageUrls(data) { 20 //Make image paths work with a greedy regex 21 newData = data.replace( new RegExp( "../images/", "g" ), prettylistScriptParams.pluginUrl + '/images/' ); 32 //Make image paths work in the previewer 33 function updateImageUrls(data) { 34 //If it contains a hash it's an alt style 35 if((jQuery('#show_pages').attr('value')).indexOf('#') > 0){ 36 //Make image paths work with a greedy regex 37 //Uses "../i because we can't be sure if it will be images or img. 38 //Also uses ../../../ to fix style pack icons 39 //Also looks for a bracket or quote to stop ../../ etc from matching 40 //This will not always work. 41 newData = data.replace( new RegExp( '"../i', 'g' ), '"' + prettylistScriptParams.altPluginUrl + 'i' ); 42 newData = data.replace( new RegExp( '\\(../i', 'g' ),'(' + prettylistScriptParams.altPluginUrl + 'i' ); 43 newData = data.replace( new RegExp( '.../../../plugins/pretty-file-lister/', 'g' ),'(' + prettylistScriptParams.pluginUrl + '' ); 44 } 45 else{ 46 //Make image paths work with a greedy regex 47 newData = data.replace( new RegExp( '../images/', 'g' ), prettylistScriptParams.pluginUrl + 'images/' ); 48 } 49 22 50 //Empty and refill styles section 23 51 jQuery('#Previewer').empty().append(newData); -
pretty-file-lister/trunk/readme.txt
r515211 r517648 4 4 Requires at least: 3.0.0 5 5 Tested up to: 3.3.1 6 Stable tag: 0. 16 Stable tag: 0.2 7 7 8 8 The Pretty file list plugin lists files attached to a post, displays them, and pages them in an attractive format without you having to do any work. Its designed to be very easy to use, and even comes with built in styles for different set ups. … … 26 26 3. An example of the split Pretty File List style. 27 27 28 29 28 == Changelog == 30 29 31 30 = 0.1 = 32 31 * Initial release 32 33 = 0.2 = 34 * Fixed initial style not set (BUG) 35 * Added editor button to insert shortcode (FEATURE) 36 * Added shortcode wizard to insert shortcode (FEATURE) 37 * Now reads custom css files from a folder in your theme directory (stops files getting wiped after upgrade). 38 39 == Upgrade Notice == 40 41 = 0.2 = 42 If you are using the Style Pack you will need to [redownload it (Style Pack v0.3)](http://www.smartredfox.com/style-pack-download/) and install it into your theme directory.
Note: See TracChangeset
for help on using the changeset viewer.