Last active
October 20, 2020 02:01
-
-
Save KaineLabs/8950aeab22e97db385f22314d5b065c6 to your computer and use it in GitHub Desktop.
Custom Widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom Widget. | |
**/ | |
function yzc_get_ads_widget() { | |
if ( ! bp_is_single_activity() ) { | |
return; | |
} | |
if ( get_the_author_meta( 'yz_hide_open_widget', bp_displayed_user_id(), true ) != 'on' ) { | |
return; | |
} | |
?> | |
<div class="yz-widget yz-white-bg yz-wg-title-icon-bg"> | |
<div class="yz-widget-main-content"> | |
<div class="yz-widget-head"> | |
<h2 class="yz-widget-title"><i class="fas fa-fan"></i>Open Box</h2> | |
</div> | |
<div class="yz-widget-content"> | |
<a href="https://ohso.red/add-list/?sid=1/?ref=<?php echo bp_get_displayed_user_username(); ?>">Advertise here</a> | |
<?php echo do_shortcode( '[bsa_pro_ad_space id=1]' ); ?> | |
</div> | |
</div> | |
</div> | |
<?php | |
} | |
//add_action( 'yz_profile_sidebar', 'yzc_get_ads_widget', 1 ); | |
add_action( 'bp_after_single_activity_post', 'yzc_get_ads_widget', 1 ); | |
/** | |
* Add Open Box Widgets Settings. | |
*/ | |
function yzc_get_ads_widget_settings() { | |
bp_core_new_subnav_item( | |
array( | |
'slug' => 'open-box', | |
'parent_slug' => 'widgets', | |
'name' => __( 'Open Box', 'youzer' ), | |
'default_subnav_slug' => 'widgets', | |
'show_for_displayed_user' => bp_core_can_edit_settings(), | |
'parent_url' => yz_get_widgets_settings_url() . '/widgets/', | |
'screen_function' => 'yzc_get_ads_widget_template', | |
) | |
); | |
} | |
// Add Account Settings Pages. | |
add_action( 'bp_actions', 'yzc_get_ads_widget_settings', 999 ); | |
/** | |
* Setttings Template | |
*/ | |
function yzc_get_ads_widget_template() { | |
// Call Widget Content. | |
add_action( 'bp_template_content', 'yzc_get_ads_widget_template_content' ); | |
// Load Tab Template | |
bp_core_load_template( 'buddypress/members/single/plugins' ); | |
} | |
/** | |
* Setttings Template | |
*/ | |
function yzc_get_ads_widget_template_content() { | |
if ( bp_current_action() != 'open-box' ) { | |
return; | |
} | |
global $Yz_Settings; | |
$Yz_Settings->get_field( | |
array( | |
'title' => __( 'Open Box Settings', 'youzer' ), | |
'id' => 'openbox-settings', | |
'icon' => 'fas fa-fan', | |
'type' => 'open' | |
) | |
); | |
$Yz_Settings->get_field( | |
array( | |
'title' => __( 'Show Open Box', 'youzer' ), | |
'desc' => __( 'Enable/Disable Open Box', 'youzer' ), | |
'id' => 'yz_hide_open_widget', | |
'type' => 'checkbox', | |
'std' => 'off', | |
), true | |
); | |
$Yz_Settings->get_field( array( 'type' => 'close' ) ); | |
} | |
add_action( 'youzer_profile_settings', 'yzc_get_ads_widget_template_content' ); | |
/** | |
* Add Menu Icon | |
*/ | |
function yzc_add_new_menu_icon( $icon, $slug ){ | |
if ( $slug == 'open-box' ) { | |
return 'fas fa-fan'; | |
} | |
return $icon; | |
} | |
add_filter( 'yz_account_menu_icon', 'yzc_add_new_menu_icon', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment