Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'wp_enqueue_scripts', 'arcane_enqueue_styles' );
- function arcane_enqueue_styles() {
- wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
- }
- /**
- * Shortcode [user_twitch_channel] to show the user channel.
- *
- * @param array $atts shortcode attribtes.
- * @param string $content content.
- *
- * @return false|string
- */
- function buddydev_custom_user_twitch_channel_shortcode( $atts = array(), $content = '' ) {
- $atts = shortcode_atts( array(
- 'user_id' => bp_displayed_user_id(),
- 'field' => 'Twitch Channel',
- ), $atts );
- $channel_name = xprofile_get_field_data( $atts['field'], $atts['user_id'] );
- if ( empty( $channel_name ) ) {
- return $content;
- }
- ob_start();
- ?>
- <div class="wpb_column vc_column_container vc_col-sm-6">
- <iframe src="https://player.twitch.tv/?channel=<?php echo $channel_name; ?>" height="500" width="100%"
- frameborder="0" scrolling="no" allowfullscreen></iframe>
- </div>
- <div class="wpb_column vc_column_container vc_col-sm-6">
- <iframe src="https://www.twitch.tv/embed/<?php echo $channel_name; ?>/chat" frameborder="0" scrolling="no"
- height="500" width="350"></iframe>
- </div>
- <?php
- return ob_get_clean();
- }
- add_shortcode( 'user_twitch_channel', 'buddydev_custom_user_twitch_channel_shortcode' );
- /**
- * Shortcode [user_youtube_channel] to show the user channel.
- *
- * @param array $atts shortcode attribtes.
- * @param string $content content.
- *
- * @return false|string
- */
- function buddydev_custom_user_youtube_channel_shortcode( $atts = array(), $content = '' ) {
- $atts = shortcode_atts( array(
- 'user_id' => bp_displayed_user_id(),
- 'field' => 'Youtube Username',
- ), $atts );
- $ytchannel_name = xprofile_get_field_data( $atts['field'], $atts['user_id'] );
- if ( empty( $ytchannel_name ) ) {
- return $content;
- }
- ob_start();
- ?>
- <div class="wpb_column vc_column_container vc_col-sm-6">
- <?php echo do_shortcode( '[yotuwp type="username" id="' . $ytchannel_name . '"]' ); ?>
- </div>
- <?php
- return ob_get_clean();
- }
- add_shortcode( 'user_youtube_channel', 'buddydev_custom_user_youtube_channel_shortcode' );
- add_action( 'bsfep_post_saved', 'buddydev_add_default_category_to_post' );
- function buddydev_add_default_category_to_post( $post_id ) {
- $tax = array_filter( $_POST['tax_input'] );
- if( empty( $tax ) && $post_id ) {
- //no category was set
- $term = 79;//ID
- wp_set_object_terms( $post_id, $term, 'category' );
- }
- }
- function buddyblog_show_custom_cats( $settings ) {
- $tax = array();
- $tax['category'] = array(
- 'taxonomy' => 'category',
- 'view_type' => 'dd',
- 'child_of' => 91, //CHAGE It with the correct ID,
- 'orderby' => 'slug',
- 'order' => 'ASC'
- );
- $tax['post_tag'] = array(
- 'taxonomy' => 'post_tag',
- 'view_type' => 'dd',
- 'include' => array( 83,85,88,92),// tag ids.
- 'orderby' => 'slug',
- 'order' => 'ASC',
- );
- $settings['tax'] = $tax;
- return $settings;
- }
- add_filter( 'buddyblog_post_form_settings', 'buddyblog_show_custom_cats', 100 );
- add_action( 'bsfep_post_saved', 'buddydev_add_default_category_to_post' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement