Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. if(function_exists('register_sidebar')) {
  2.  
  3. register_sidebar(
  4. array(
  5. 'name' => __('Main Sidebar'),
  6. 'id' => 'main-sidebar',
  7. 'description' => __('The main sidebar area'),
  8. 'before_widget' => '<div class="widget">',
  9. 'after_widget' => '</div>',
  10. 'before_title' => '<h2>',
  11. 'after_title' => '</h2>'
  12. ));
  13.  
  14. }
  15.  
  16. /****************************************************/
  17. /* Load Custom Widgets */
  18. /***************************************************/
  19.  
  20. require_once('functions/rh_tags.php');
  21.  
  22. <?php
  23. class RH_Tags extends WP_Widget {
  24. function __construct() {
  25. $params = array(
  26. 'name' => 'Creative : Tag Cloud Widget',
  27. 'description' => 'Displays info of your blog'
  28. );
  29. parent:: __construct('RH_Tags','',$params);
  30. }
  31.  
  32. public function form($instance) {
  33. //display our form in widget page
  34. extract($instance);
  35. ?>
  36. <p>
  37. <label for="<?php echo $this->get_field_id('title') ?>">Title : </label>
  38. <input class="widefat" id="<?php echo $this->get_field_id('title') ?>" name="<?php echo $this->get_field_name('title') ?>"
  39. value="<?php if(isset($title)) echo esc_attr($title); ?>" />
  40. </p>
  41. <?php
  42. }
  43.  
  44. public function widget($args,$instance) {
  45. //displays our widget
  46. extract($args);
  47. extract($instance);
  48. echo $before_widget;
  49. echo $before_title .$title. $after_title;
  50. echo '<div class="label">';
  51. echo "<ul>";
  52. echo "<li>";
  53. echo the_tags(' ',' ');
  54. echo "</li>";
  55. echo "</ul>";
  56. echo '</div>';
  57. echo $after_widget;
  58. }
  59. }
  60.  
  61. add_action('widgets_init','rh_register_tags');
  62. function rh_register_tags() {
  63. register_widget('RH_Tags');
  64. }
  65.  
  66. function get_the_terms( $post, $taxonomy ) {
  67. if ( ! $post = get_post( $post ) )
  68. return false;
  69.  
  70. $terms = get_object_term_cache( $post->ID, $taxonomy );
  71. if ( false === $terms ) {
  72. $terms = wp_get_object_terms( $post->ID, $taxonomy );
  73. wp_cache_add($post->ID, $terms, $taxonomy . '_relationships');
  74. }
  75.  
  76. public function( Array $args )
  77. {
  78. $foo = isset( $args['foo'] )
  79. ? $args['foo']
  80. : 'my default';
  81. // work with `$foo`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement