Advertisement
PhoTonFlinger

Untitled

Nov 12th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. <?php
  2. add_action( 'wp_enqueue_scripts', 'arcane_enqueue_styles' );
  3. function arcane_enqueue_styles() {
  4. wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
  5.  
  6. }
  7.  
  8. /**
  9. * Shortcode [user_twitch_channel] to show the user channel.
  10. *
  11. * @param array $atts shortcode attribtes.
  12. * @param string $content content.
  13. *
  14. * @return false|string
  15. */
  16. function buddydev_custom_user_twitch_channel_shortcode( $atts = array(), $content = '' ) {
  17.  
  18. $atts = shortcode_atts( array(
  19. 'user_id' => bp_displayed_user_id(),
  20. 'field' => 'Twitch Channel',
  21. ), $atts );
  22.  
  23. $channel_name = xprofile_get_field_data( $atts['field'], $atts['user_id'] );
  24.  
  25. if ( empty( $channel_name ) ) {
  26. return $content;
  27. }
  28. ob_start();
  29. ?>
  30. <div class="wpb_column vc_column_container vc_col-sm-6">
  31. <iframe src="https://player.twitch.tv/?channel=<?php echo $channel_name; ?>" height="500" width="100%"
  32. frameborder="0" scrolling="no" allowfullscreen></iframe>
  33.  
  34. </div>
  35.  
  36. <div class="wpb_column vc_column_container vc_col-sm-6">
  37. <iframe src="https://www.twitch.tv/embed/<?php echo $channel_name; ?>/chat" frameborder="0" scrolling="no"
  38. height="500" width="350"></iframe>
  39. </div>
  40. <?php
  41. return ob_get_clean();
  42. }
  43.  
  44. add_shortcode( 'user_twitch_channel', 'buddydev_custom_user_twitch_channel_shortcode' );
  45.  
  46.  
  47. /**
  48. * Shortcode [user_youtube_channel] to show the user channel.
  49. *
  50. * @param array $atts shortcode attribtes.
  51. * @param string $content content.
  52. *
  53. * @return false|string
  54. */
  55. function buddydev_custom_user_youtube_channel_shortcode( $atts = array(), $content = '' ) {
  56.  
  57. $atts = shortcode_atts( array(
  58. 'user_id' => bp_displayed_user_id(),
  59. 'field' => 'Youtube Username',
  60. ), $atts );
  61.  
  62. $ytchannel_name = xprofile_get_field_data( $atts['field'], $atts['user_id'] );
  63.  
  64. if ( empty( $ytchannel_name ) ) {
  65. return $content;
  66. }
  67. ob_start();
  68. ?>
  69.  
  70. <div class="wpb_column vc_column_container vc_col-sm-6">
  71. <?php echo do_shortcode( '[yotuwp type="username" id="' . $ytchannel_name . '"]' ); ?>
  72. </div>
  73. <?php
  74. return ob_get_clean();
  75. }
  76.  
  77. add_shortcode( 'user_youtube_channel', 'buddydev_custom_user_youtube_channel_shortcode' );
  78. add_action( 'bsfep_post_saved', 'buddydev_add_default_category_to_post' );
  79.  
  80. function buddydev_add_default_category_to_post( $post_id ) {
  81.  
  82. $tax = array_filter( $_POST['tax_input'] );
  83.  
  84. if( empty( $tax ) && $post_id ) {
  85. //no category was set
  86. $term = 79;//ID
  87. wp_set_object_terms( $post_id, $term, 'category' );
  88.  
  89. }
  90.  
  91.  
  92. }
  93.  
  94. function buddyblog_show_custom_cats( $settings ) {
  95. $tax = array();
  96.  
  97. $tax['category'] = array(
  98.  
  99. 'taxonomy' => 'category',
  100. 'view_type' => 'dd',
  101. 'child_of' => 91, //CHAGE It with the correct ID,
  102. 'orderby' => 'slug',
  103. 'order' => 'ASC'
  104. );
  105.  
  106. $tax['post_tag'] = array(
  107.  
  108. 'taxonomy' => 'post_tag',
  109. 'view_type' => 'dd',
  110. 'include' => array( 83,85,88,92),// tag ids.
  111. 'orderby' => 'slug',
  112. 'order' => 'ASC',
  113. );
  114.  
  115. $settings['tax'] = $tax;
  116.  
  117. return $settings;
  118. }
  119. add_filter( 'buddyblog_post_form_settings', 'buddyblog_show_custom_cats', 100 );
  120. add_action( 'bsfep_post_saved', 'buddydev_add_default_category_to_post' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement