This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

FunctionsFile

By: a guest on Apr 11th, 2013  |  syntax: None  |  size: 3.30 KB  |  views: 51  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. //Kint::trace() ;
  3. // load theme framework
  4.  
  5. include get_template_directory() . '/framework/theme.php';
  6.  
  7. $theme = new jwTheme();
  8. $theme->init();
  9.  
  10.  
  11. register_sidebar(array(
  12.   'name' => __( 'Buddypress' ),
  13.   'id' => 'right-sidebar',
  14.   'description' => __( 'Widgets in this area will be shown on the Buddypress right-hand side.' ),
  15.   'before_title' => '<h1>',
  16.   'after_title' => '</h1>'
  17. ));
  18.                
  19.  
  20.  
  21. /* Customized the output of caption, you can remove the filter to restore back to the WP default output. Courtesy of DevPress. http://devpress.com/blog/captions-in-wordpress/ */
  22. add_filter('img_caption_shortcode', 'cleaner_caption', 10, 3);
  23.  
  24.  
  25. function cleaner_caption($output, $attr, $content) {
  26.  
  27.     /* We're not worried abut captions in feeds, so just return the output here. */
  28.     if (is_feed())
  29.         return $output;
  30.  
  31.     /* Set up the default arguments. */
  32.     $defaults = array(
  33.         'id' => '',
  34.         'align' => 'alignnone',
  35.         'width' => '',
  36.         'caption' => ''
  37.     );
  38.  
  39.     /* Merge the defaults with user input. */
  40.     $attr = shortcode_atts($defaults, $attr);
  41.  
  42.     /* If the width is less than 1 or there is no caption, return the content wrapped between the [caption]< tags. */
  43.     if (1 > $attr['width'] || empty($attr['caption']))
  44.         return $content;
  45.  
  46.     /* Set up the attributes for the caption <div>. */
  47.     $attributes = ' class="figure ' . esc_attr($attr['align']) . '"';
  48.  
  49.     /* Open the caption <div>. */
  50.     $output = '<figure' . $attributes . '>';
  51.  
  52.     /* Allow shortcodes for the content the caption was created for. */
  53.     $output .= do_shortcode($content);
  54.  
  55.     /* Append the caption text. */
  56.     $output .= '<figcaption>' . $attr['caption'] . '</figcaption>';
  57.  
  58.     /* Close the caption </div>. */
  59.     $output .= '</figure>';
  60.  
  61.     /* Return the formatted, clean caption. */
  62.     return $output;
  63. }
  64.  
  65. // Clean the output of attributes of images in editor. Courtesy of SitePoint. http://www.sitepoint.com/wordpress-change-img-tag-html/
  66. function image_tag_class($class, $id, $align, $size) {
  67.     $align = 'align' . esc_attr($align);
  68.     return $align;
  69. }
  70.  
  71. add_filter('get_image_tag_class', 'image_tag_class', 0, 4);
  72.  
  73. function image_tag($html, $id, $alt, $title) {
  74.     return preg_replace(array(
  75.                 '/\s+width="\d+"/i',
  76.                 '/\s+height="\d+"/i',
  77.                 '/alt=""/i'
  78.                     ), array(
  79.                 '',
  80.                 '',
  81.                 '',
  82.                 'alt="' . $title . '"'
  83.                     ), $html);
  84. }
  85.  
  86. add_filter('get_image_tag', 'image_tag', 0, 4);
  87.  
  88. // img unautop, Courtesy of Interconnectit http://interconnectit.com/2175/how-to-remove-p-tags-from-images-in-wordpress/
  89. function img_unautop($pee) {
  90.     $pee = preg_replace('/<p>\\s*?(<a .*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s', '<figure>$1</figure>', $pee);
  91.     return $pee;
  92. }
  93.  
  94. // BlbÄ› to zarovnava obrazek
  95. //add_filter('the_content', 'img_unautop', 30);
  96.  
  97.  
  98. function add_social_contactmethod($contactmethods)
  99. {
  100.     // Add Networks
  101.     $contactmethods['twitter'] = 'Twitter URL';
  102.     $contactmethods['facebook'] = 'Facebook URL';
  103.     $contactmethods['linkedin'] = 'Linkedin URL';
  104.     $contactmethods['youtube'] = 'YouTube URL';
  105.     $contactmethods['google'] = 'Google+ URL';
  106.     $contactmethods['vimeo'] = 'Vimeo URL';
  107.     $contactmethods['flickr'] = 'Flickr URL';
  108.  
  109.     return $contactmethods;
  110. }
  111.  
  112. add_filter('user_contactmethods', 'add_social_contactmethod', 10, 1);
  113.  
  114.  
  115.  
  116. ?>
clone this paste RAW Paste Data