Guest User

Untitled

a guest
Jan 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. /*
  2. inc/shortcodes.php
  3. ------------------
  4. */
  5. <?php
  6.  
  7. /*
  8.  
  9. @package journal
  10.  
  11. =============================
  12. SHORTCODE OPTIONS
  13. =============================
  14. */
  15. function myjournal_tooltip( $atts, $content = null ){ // $atts can be $args etc
  16.  
  17. // get the attributes
  18. $atts = shortcode_atts( // this $atts = $args
  19. array(
  20. 'placement' => 'top',
  21. 'title' => ''
  22. ),
  23. $atts, // not $args
  24. 'tooltip'
  25. );
  26.  
  27. $title = ($atts['title'] == '' ? $content : $atts['title']);
  28.  
  29. // return HTML
  30. return '<span class="myjournal-tooltip" data-toggle="tooltip" data-placement="' . $atts['placement'] . '" title="' . $title . '">' . $content . '</span>';
  31.  
  32. }
  33.  
  34. add_shortcode( 'tooltip', 'myjournal_tooltip' )
  35.  
  36. /*
  37. ~How To Use~
  38. [tooltip placement="top" title="This is the title"]This is the content[/tooltip]
  39. */
  40. /* ===================================================================================== */
  41.  
  42.  
  43.  
  44. /*
  45. js/theme-js-file.js
  46. -------------------
  47. */
  48. $(function(){
  49. $('[data-toggle="tooltip"]').tooltip();
  50. })
  51. /* ===================================================================================== */
  52. /*
  53. sass/styles.sass
  54. */
  55. .myjournal-tooltip
  56. cursor: pointer
  57. color: #ff9d1d
  58. &:hover,
  59. &:focus
  60. color: #F56B08
Add Comment
Please, Sign In to add comment