laboratorio caffeina

in few words, just developing

 

cedmax
web developer

 
 

Remove whitespace from wordpress tagcloud

I hate whitespace in html code: if I need them I'll use css rules.

so that's a simple plugin edited from this one.
if you need both merge them

PHP:
  1. <?php
  2. /*
  3. Plugin Name: Tag Cloud noWhitespace
  4. Plugin URI: http://www.laboratoriocaffeina.it/design/2008/04/03/remove-whitespace-from-wordpress-tagcloud.html
  5. Description: Makes wordpress dump out a tag cloud without whitespace between each word in tags (edit from http://www.185vfx.com/2007/10/wordpress-tag-cloud-formatting/)
  6. Author: cedmax
  7. Version: 1.0
  8. Author URI:  http://www.dioblog.it
  9. */
  10.  
  11.  
  12. // This just echoes the chosen line, we'll position it later
  13. function tci_kill_breaks($taglist) {
  14.     return str_replace('&nbsp;',' ',$taglist);
  15. }
  16.  
  17. // Now we set that function up to execute when the tag list is generated
  18. add_filter('wp_generate_tag_cloud', 'tci_kill_breaks',50);?>

download, rename to .php, upload to plugin folder and activate

(tested on 2.5)

 
 
 

Easy Clear #4, ovvero “e mò basta però”

dopo la terza puntata di easy clear mi sono accorto che non sempre funziona su ie6.

dramma e panico.
non vi preoccupate ho la soluzione:

la 3 prevedeva di mettere nel contenitore dei float il seguente codice

CSS:
  1. #wrapper {
  2.      overflow:hidden;
  3.      height:1%;
  4.      height:auto !important;
  5. }

se non funziona su ie6 provate questo.

CSS:
  1. #wrapper {
  2.      overflow:hidden;
  3.      width:100%;
  4. }

any feedback?

 
 
 

Add TinyMCE to author description in Wordpress

Ok, second chance to me, after the Restrict authors access to edit comments plugin I did the second one.

I think that the name is quite explicative: I wanted to add the wysiwyg to the user description .

PHP:
  1. <?php
  2. /*
  3. Plugin Name: Add TinyMce to Author Profile
  4. Plugin URI: http://www.laboratoriocaffeina.it/development/2007/08/22/add-tinymce-to-author-description-in-wordpress.html
  5. Description: Adds WYSIWYG to Author profile
  6. Version: 0.1
  7. Author: cedmax
  8. Author URI: http://www.dioblog.it
  9. */
  10.  
  11. if ((strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/user-edit.php')) or (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/profile.php'))) {
  12.     add_action('admin_head', 'add_tinymce');
  13. }
  14.  
  15. remove_filter('pre_user_description', 'wp_filter_kses');
  16. add_filter('pre_user_description', 'wpautop');
  17.  
  18. function add_tinymce() {?>
  19.  
  20.     <script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20070326"></script>
  21.     <script type="text/javascript">
  22.     //<![CDATA[
  23.  
  24.     function brstonewline(element_id, html, body) {
  25.         html = html.replace(/<br\s*\/>/gi, '\n');;
  26.         return html;
  27.     }
  28.  
  29.     function insertHTML(html) {
  30.         tinyMCE.execCommand('mceInsertContent',false, html);
  31.     }
  32.  
  33.     tinyMCE.init({
  34.         mode : "exact",
  35.         elements : "description",
  36.         theme : "advanced",
  37.         theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,undo,redo,link,unlink",
  38.         force_p_newlines : false,
  39.             force_br_newlines : true,
  40.         gecko_spellcheck : true,
  41.         theme_advanced_buttons2 : "",
  42.         theme_advanced_buttons3 : "",
  43.         theme_advanced_toolbar_location : "top",
  44.         theme_advanced_toolbar_align : "left",
  45.             save_callback : "brstonewline",
  46.             height : "300",
  47.         extended_valid_elements : "a[name|href|title],font[face|size|color|style],span[class|align|style]"
  48.     });
  49.     //]]>
  50.     </script>
  51.  
  52. <?php } ?>

INSTRUCTION:
download v.0.1 and copy the file into wp-content/plugins.
activate it.
Now you should see in the edit user details the wysiwyg editor.
You can manage to modify TinyMCE script, following instruction

Hope you like it
tested on wordpress 2.2

IN ORDER TO LET IT WORK IN 2.5
replace this part of code:

PHP:
  1. function add_tinymce() {?>
  2.  
  3.     <script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20070326"></script>
  4.     <script type="text/javascript">
  5.     //<![CDATA[
  6.  
  7.     function brstonewline(element_id, html, body) {
  8.         html = html.replace(/<br\s*\/>/gi, '\n');;
  9.         return html;
  10.     }
  11.  
  12.     function insertHTML(html) {
  13.         tinyMCE.execCommand('mceInsertContent',false, html);
  14.     }
  15.  
  16.     tinyMCE.init({
  17.         mode : "exact",
  18.         elements : "description",
  19.         theme : "advanced",
  20.         theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,undo,redo,link,unlink",
  21.         force_p_newlines : false,
  22.             force_br_newlines : true,
  23.         gecko_spellcheck : true,
  24.         theme_advanced_buttons2 : "",
  25.         theme_advanced_buttons3 : "",
  26.         theme_advanced_toolbar_location : "top",
  27.         theme_advanced_toolbar_align : "left",
  28.             save_callback : "brstonewline",
  29.             height : "300",
  30.         extended_valid_elements : "a[name|href|title],font[face|size|color|style],span[class|align|style]"
  31.     });
  32.     //]]>
  33.     </script>
  34. <?php } ?>

with this:

PHP:
  1. function add_tinymce() {?>
  2.  
  3.     <script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-admin/js/editor.js?ver=20080325"></script>
  4.  
  5. <script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-includes/js/tinymce/tiny_mce_config.php?ver=20080327"></script>
  6.     <script type="text/javascript">
  7.     //<![CDATA[
  8. window.onload= function() {
  9. tinyMCE.execCommand("mceAddControl", false, "description");
  10. }
  11.  // ]]>
  12.    
  13.     </script>
  14.  
  15. <?php } ?>

 
 
 

La toolbar di Skype e un altro giro di link

La toolbar di Skype applica una propria grafica alle serie numeriche che possono sembrare numeri telefonici (garantisco per gli Stati Uniti, non so la versione nostrana).
A parte il fatto che non necessariamente si tratta di numeri telefonici, resta che lo trovo un filo invasivo a livello di look and feel del sito.
Per fortuna basta inserire questo meta tag per risolvere la cosa (però che balle!)

HTML:
  1. <meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />


le risorse di oggi
I fattori del posizionamento
un po' di SEO non fa mai male

ma si può passare la query sql in querystring????
io ancora non ci credo.. è veramente PAZZESCO!!! soprattutto se non si fa il lock sulle tabelle!!!

101 risorse essenziali per sviluppatori freelance
interessante, si possono trovare servizi utilissimi (io e diego abbiamo aperto un paio di account su remeber the milk, per dire)

How Many CSS Properties Can You Name in 7 Minutes?
How Many HTML Elements Can You Name in 5 Minutes?
che non si può sempre stare a lavorare

 
 
 

Restrict authors access to edit comments, the plugin

It's my first wordpress plugin, please be kind ;-)

I've noticed that in wordpress (surely 2.2, not tested on previous, so please tell me if it works) there's no capability separation for editing post and comments (on their post). Even using the Role Manager Plugin.

from wordpress codex:

Manage->Comments -- meaning: "show post"-link; "edit post"-, "edit comment"- and "delete comment"-links only on own posts since edit-comment.php (http://trac.wordpress.org/file/trunk/wp-admin/edit-comments.php) looks for "current_user_can('edit_post', $comment->comment_post_ID)"'

I run a lot of multiple authors blogs and sometimes I need only administrators to edit comments (and I'm not the only one).

So I developed this:

PHP:
  1. <?php
  2. /*
  3. Plugin Name: Restrict author access to edit comments
  4. Plugin URI: http://www.laboratoriocaffeina.it/development/2007/07/20/restrict-authors-access-to-edit-comments-the-plugin.html
  5. Description: Block author access to edit comments, leave it only for admin and editors
  6. Version: 0.3
  7. Author: cedmax
  8. Author URI: http://www.dioblog.it
  9. */
  10.  
  11. function check_user_capabilities() {
  12. global $user_level;
  13.  
  14.   if ( ((strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/edit-comments.php')) or (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/comment.php')))) {
  15.      
  16.      if ($user_level <9){
  17.     echo "<div class='wrap'><h2>Restricted area</h2></div>";
  18.     include('admin-footer.php');
  19.     die();
  20.    
  21.      }
  22.   }
  23. }
  24.  
  25. add_action('init', 'check_user_capabilities');
  26.  
  27. ?>

update
thanks to brad I found out that the direct edit comment link in wordpress points to comments.php and not to edit-comments.php.
so I've changed the script.

update 2
Thanks to Fred (sorry I didn't understand immediatly) and Claus I spotted out another error in version 0.2
Now I've done the v.0.3 changing the hook function: now it works not on the content but on the initialization of the page, so it is not possible for the author to work on comments at all. thanks to everyone :-)

simply download v.0.3, unzip, put the .php file under wp-contents/plugins and activate it from wordpress plugins panel.

 
 
 

chi non muore si rivede

e non siamo morti.
semplicemente fa caldo e noi developer ci si stanca facile.

per non annoiarci nell'afa delle consegne estive, comunque, allego qualche articolo e risorsa che secondo me meritano un po' d'attenzione.

X/HTML 5 vs XHTML 2
le due tecnologie a confronto

flash embed test suite
compatibilità dei browser col codice flash

sifr 3
ancora in beta, ma con risultati ottimi (soprattutto nel font-size, vera croce della versione precedente)

scalable css buttons
forse non rivoluzionario (e non crossbrowser) ma l'approccio è interessante

swfir - il sifr per le immagini
potrebbe risultare interessante

Risorse cedmax 5 July 2007 15:35 4 Commenti Popularity: 33% No related posts

 
 
 

Somnio Ergo Sum: sito online

Intanto diteci cosa ne pensate, presto (io o Diego) metteremo online maggiori informazioni su come è nato il progetto, qual'è stato il case study e come ci siamo mossi per la realizzazione.

somnio ergo sum

 
 
 
Chiudi
E-mail It