Advertisement
ozh

SARL Spoiler

ozh
Feb 12th, 2014
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. Un plugin:
  2.  
  3. <?php
  4. /*
  5. Plugin Name: Tous à spoil
  6. Plugin URI: #
  7. Description: T'as des spoils qui dépassent du string
  8. Author: Ozh
  9. Version: 1.3.3.7
  10. Author URI: http://ozh.org/
  11. */
  12.  
  13. /*** [spoiler] ***/
  14. // [spoiler]ce texte est un spoiler[/spoiler]
  15. function sarl_shortcode_spoiler($attr, $content) {
  16.     $content = antispambot( $content );
  17.     return "<span class=\"spoiler\">$content</span>";
  18. }
  19. add_shortcode('spoiler', 'sarl_shortcode_spoiler');
  20.  
  21. ?>
  22.  
  23. Dans le footer.php, rajouter:
  24.  
  25. <script type="text/javascript">
  26. jQuery(document).ready(function() {
  27.  
  28.         jQuery("span.spoiler").hide();
  29.  
  30.         jQuery('<a class="reveal">Spoiler</a>').insertBefore('.spoiler');
  31.  
  32.         jQuery("a.reveal").click(function(){
  33.                 jQuery(this).parents("p").children("span.spoiler").show();
  34.                 jQuery(this).parents("p").children("a.reveal").hide();
  35.         });
  36.  
  37. });
  38. </script>
  39.  
  40. Dans le style.css du theme, rajouter:
  41.  
  42. .reveal {
  43.     font-size: 80%;
  44.     background: #990000;
  45.     color: white;
  46.     font-style: normal;
  47.     cursor: pointer;
  48.     font-weight: bold;
  49.     border: 1px solid #BB0000;
  50.     border-radius: 3px;
  51.     padding: 1px 3px;
  52. }
  53.  
  54. .reveal:hover {
  55.     text-decoration: none;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement