diff --git a/bp-compliments-core.php b/bp-compliments-core.php
index f46696f..ddbc3b7 100644
--- a/bp-compliments-core.php
+++ b/bp-compliments-core.php
@@ -178,6 +178,12 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
$bp_compliment_can_see_others_comp_value = esc_attr( get_option('bp_compliment_can_see_others_comp'));
$bp_compliment_can_see_others_comp = $bp_compliment_can_see_others_comp_value ? $bp_compliment_can_see_others_comp_value : 'yes';
+
+ if ($bp_compliment_can_see_others_comp == 'members_choice') {
+ $bp_compliment_can_see_your_comp_value = esc_attr( get_user_meta(bp_displayed_user_id(), 'bp_compliment_can_see_your_comp', true));
+ $bp_compliment_can_see_others_comp = $bp_compliment_can_see_your_comp_value ? $bp_compliment_can_see_your_comp_value : 'yes';
+ }
+
if ($bp_compliment_can_see_others_comp == 'yes') {
$show_for_displayed_user = true;
} elseif ($bp_compliment_can_see_others_comp == 'members_only') {
diff --git a/bp-compliments.php b/bp-compliments.php
index 70f5d28..2461cbe 100644
--- a/bp-compliments.php
+++ b/bp-compliments.php
@@ -144,3 +144,13 @@ function bp_compliments_localization() {
}
add_action( 'plugins_loaded', 'bp_compliments_localization' );
+add_action( 'admin_notices', 'bp_compliments_required_plugins_nag' );
+function bp_compliments_required_plugins_nag() {
+ // Check for BuddyPress
+ $class = "update-nag";
+ $url = 'https://wordpress.org/plugins/buddypress/';
+ $message = sprintf( wp_kses( __( 'BuddyPress Compliments requires BuddyPress plugin.', 'bp-compliments' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( $url ) );
+ if(!class_exists('BuddyPress')){
+ echo"
-
@@ -94,7 +158,14 @@ function bp_compliments_modal_form($pid = 0, $receiver_id = 0) {
function bp_compliments_modal_ajax()
{
check_ajax_referer('bp-compliments-nonce', 'bp_compliments_nonce');
- bp_compliments_modal_form();
+
+ if (isset($_POST['category_id'])) {
+ $category_id = (int) strip_tags(esc_sql($_POST['category_id']));
+ bp_compliments_modal_form(0, 0, $category_id);
+ } else {
+ bp_compliments_modal_form();
+ }
+
wp_die();
}
diff --git a/includes/bp-compliments-settings.php b/includes/bp-compliments-settings.php
index cfebbf1..907c2a7 100644
--- a/includes/bp-compliments-settings.php
+++ b/includes/bp-compliments-settings.php
@@ -28,6 +28,7 @@ function bp_compliments_register_settings() {
register_setting( 'bp-compliment-settings', 'bp_compliment_can_delete' );
register_setting( 'bp-compliment-settings', 'bp_compliment_enable_activity' );
register_setting( 'bp-compliment-settings', 'bp_compliment_enable_notifications' );
+ register_setting( 'bp-compliment-settings', 'bp_compliment_enable_categories' );
register_setting( 'bp-compliment-settings', 'bp_comp_per_page' );
register_setting( 'bp-compliment-settings', 'bp_comp_custom_css' );
}
@@ -52,6 +53,9 @@ function bp_compliments_settings_page() {
$bp_compliment_enable_notifications_value = esc_attr( get_option('bp_compliment_enable_notifications'));
$bp_compliment_enable_notifications = $bp_compliment_enable_notifications_value ? $bp_compliment_enable_notifications_value : 'yes';
+ $bp_compliment_enable_categories_value = esc_attr( get_option('bp_compliment_enable_categories'));
+ $bp_compliment_enable_categories = $bp_compliment_enable_categories_value ? $bp_compliment_enable_categories_value : 'no';
+
$comp_per_page_value = esc_attr( get_option('bp_comp_per_page'));
$comp_per_page = $comp_per_page_value ? (int) $comp_per_page_value : 5;
@@ -78,6 +82,7 @@ function bp_compliments_settings_page() {
+
@@ -108,6 +113,15 @@ function bp_compliments_settings_page() {
+
+ |
+
+
+ |
+
|
|
@@ -124,4 +138,115 @@ function bp_compliments_settings_page() {
- __('Compliments', 'bp-compliments'),
+ 'slug' => 'compliments',
+ 'parent_url' => trailingslashit($user_domain . $settings_slug),
+ 'parent_slug' => $settings_slug,
+ 'screen_function' => 'bp_comp_settings_submenu_page_content',
+ 'position' => 20,
+ 'user_has_access' => bp_core_can_edit_settings()
+ ));
+ }
+
+}
+add_action('bp_setup_nav', 'bp_comp_settings_submenu', 16);
+
+function bp_comp_settings_submenu_page_content() {
+ //add title and content here - last is to call the members plugin.php template
+ //add_action( 'bp_template_title', 'bp_comp_settings_submenu_page_show_screen_title' );
+ add_action( 'bp_template_content', 'bp_comp_settings_submenu_page_show_screen_content' );
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
+}
+
+//function bp_comp_settings_submenu_page_show_screen_title() {
+// echo __('Compliments Settings');
+//}
+
+function bp_comp_settings_submenu_page_show_screen_content() {
+ if (bp_displayed_user_id()) {
+ $user_id = bp_displayed_user_id();
+ } elseif (bp_loggedin_user_id()) {
+ $user_id = bp_loggedin_user_id();
+ } else {
+ $user_id = null;
+ }
+
+ if (isset( $_POST['bp-comp-settings-submit'] )) {
+ if (! isset( $_POST['bp-compl-settings-field'] ) || ! wp_verify_nonce( $_POST['bp-compl-settings-field'], 'bp_compl_settings_action' )) {
+ ?>
+
+
+
+
+
+ 'Categories',
+ 'singular_name' => 'Category',
+ 'search_items' => __( 'Search Categories', 'bp-compliments' ),
+ 'all_items' => __( 'All Categories', 'bp-compliments' ),
+ 'parent_item' => __( 'Parent Category', 'bp-compliments' ),
+ 'parent_item_colon' => __( 'Parent Category:', 'bp-compliments' ),
+ 'edit_item' => __( 'Edit Category', 'bp-compliments' ),
+ 'update_item' => __( 'Update Category', 'bp-compliments' ),
+ 'add_new_item' => __( 'Add New Category', 'bp-compliments' ),
+ 'new_item_name' => __( 'New Category Name', 'bp-compliments' ),
+ 'menu_name' => 'Category',
+ );
+
+ $cat_args = array(
+ 'hierarchical' => true,
+ 'labels' => $cat_labels,
+ 'show_ui' => true,
+ 'show_admin_column' => true,
+ 'query_var' => true,
+ 'rewrite' => array( 'slug' => 'compliment_category' ),
+ );
+
+ $bp_compliment_enable_categories_value = esc_attr( get_option('bp_compliment_enable_categories'));
+ $bp_compliment_enable_categories = $bp_compliment_enable_categories_value ? $bp_compliment_enable_categories_value : 'no';
+
+ if ($bp_compliment_enable_categories == 'yes') {
+ register_taxonomy( 'compliment_category', array(), $cat_args );
+ }
}
//compliment icons
@@ -83,6 +128,34 @@ function compliments_enqueue_admin_js( $hook_suffix ) {
*/
function compliments_taxonomy_add_new_meta_field() {
?>
+
+
+ 'name',
+ 'hide_empty' => 0,
+ );
+ $terms = get_terms( 'compliment_category', $cat_args );
+ ?>
+
+ ";
+ $output .= "";
+ foreach($terms as $term){
+ $term_id = $term->term_id;
+ $term_name =$term->name;
+ $output .= "";
+ }
+ $output .= "";
+ echo $output;
+ ?>
+
+