Advertisement
Guest User

New Functions

a guest
Apr 11th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  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. define( ‘BP_USE_WP_ADMIN_BAR’, false );
  12.  
  13. register_sidebar(array(
  14. 'name' => __( 'Buddypress' ),
  15. 'id' => 'right-sidebar',
  16. 'description' => __( 'Widgets in this area will be shown on the Buddypress right-hand side.' ),
  17. 'before_title' => '<h1>',
  18. 'after_title' => '</h1>'
  19. ));
  20.  
  21.  
  22.  
  23. /* 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/ */
  24. add_filter('img_caption_shortcode', 'cleaner_caption', 10, 3);
  25.  
  26.  
  27. function cleaner_caption($output, $attr, $content) {
  28.  
  29. /* We're not worried abut captions in feeds, so just return the output here. */
  30. if (is_feed())
  31. return $output;
  32.  
  33. /* Set up the default arguments. */
  34. $defaults = array(
  35. 'id' => '',
  36. 'align' => 'alignnone',
  37. 'width' => '',
  38. 'caption' => ''
  39. );
  40.  
  41. /* Merge the defaults with user input. */
  42. $attr = shortcode_atts($defaults, $attr);
  43.  
  44. /* If the width is less than 1 or there is no caption, return the content wrapped between the [caption]< tags. */
  45. if (1 > $attr['width'] || empty($attr['caption']))
  46. return $content;
  47.  
  48. /* Set up the attributes for the caption <div>. */
  49. $attributes = ' class="figure ' . esc_attr($attr['align']) . '"';
  50.  
  51. /* Open the caption <div>. */
  52. $output = '<figure' . $attributes . '>';
  53.  
  54. /* Allow shortcodes for the content the caption was created for. */
  55. $output .= do_shortcode($content);
  56.  
  57. /* Append the caption text. */
  58. $output .= '<figcaption>' . $attr['caption'] . '</figcaption>';
  59.  
  60. /* Close the caption </div>. */
  61. $output .= '</figure>';
  62.  
  63. /* Return the formatted, clean caption. */
  64. return $output;
  65. }
  66.  
  67. // Clean the output of attributes of images in editor. Courtesy of SitePoint. http://www.sitepoint.com/wordpress-change-img-tag-html/
  68. function image_tag_class($class, $id, $align, $size) {
  69. $align = 'align' . esc_attr($align);
  70. return $align;
  71. }
  72.  
  73. add_filter('get_image_tag_class', 'image_tag_class', 0, 4);
  74.  
  75. function image_tag($html, $id, $alt, $title) {
  76. return preg_replace(array(
  77. '/\s+width="\d+"/i',
  78. '/\s+height="\d+"/i',
  79. '/alt=""/i'
  80. ), array(
  81. '',
  82. '',
  83. '',
  84. 'alt="' . $title . '"'
  85. ), $html);
  86. }
  87.  
  88. add_filter('get_image_tag', 'image_tag', 0, 4);
  89.  
  90. // img unautop, Courtesy of Interconnectit http://interconnectit.com/2175/how-to-remove-p-tags-from-images-in-wordpress/
  91. function img_unautop($pee) {
  92. $pee = preg_replace('/<p>\\s*?(<a .*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s', '<figure>$1</figure>', $pee);
  93. return $pee;
  94. }
  95.  
  96. // Blbě to zarovnava obrazek
  97. //add_filter('the_content', 'img_unautop', 30);
  98.  
  99.  
  100. function add_social_contactmethod($contactmethods)
  101. {
  102. // Add Networks
  103. $contactmethods['twitter'] = 'Twitter URL';
  104. $contactmethods['facebook'] = 'Facebook URL';
  105. $contactmethods['linkedin'] = 'Linkedin URL';
  106. $contactmethods['youtube'] = 'YouTube URL';
  107. $contactmethods['google'] = 'Google+ URL';
  108. $contactmethods['vimeo'] = 'Vimeo URL';
  109. $contactmethods['flickr'] = 'Flickr URL';
  110.  
  111. return $contactmethods;
  112. }
  113.  
  114. add_filter('user_contactmethods', 'add_social_contactmethod', 10, 1);
  115.  
  116.  
  117.  
  118. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement