Skip to content

Commit

Permalink
Merge pull request #7 from mistergiri/master
Browse files Browse the repository at this point in the history
added settings page
  • Loading branch information
NomadDevs authored and NomadDevs committed Jul 13, 2015
2 parents f7edd16 + 74debc3 commit 7759c74
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 53 deletions.
1 change: 1 addition & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ v0.0.3
Validation added when adding compliment, icon required - FIXED
Some strings are not translatable - FIXED
Docblocks added to all functions, filters and actions - ADDED
Setting added for Members can delete compliments received? - ADDED

v0.0.2
BP compliments now supports notification component - ADDED
Expand Down
Binary file added images/smiley-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions includes/bp-compliments-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ function delete_single_complement() {
return;
}

$bp_compliment_can_delete_value = esc_attr( get_option('bp_compliment_can_delete'));
$bp_compliment_can_delete = $bp_compliment_can_delete_value ? $bp_compliment_can_delete_value : 'yes';

if ($bp_compliment_can_delete == 'no') {
return;
}

$c_id = (int) strip_tags(esc_sql($_GET['c_id']));

if (!$c_id) {
Expand Down
71 changes: 69 additions & 2 deletions includes/bp-compliments-taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@
* @package BuddyPress_Compliments
*/
function register_compliments_submenu_page() {
add_submenu_page(
'options-general.php',
add_menu_page(
__( 'Compliments', BP_COMP_TEXTDOMAIN ),
__( 'Compliments', BP_COMP_TEXTDOMAIN ),
'manage_options',
'bp-compliment-settings',
'bp_compliments_settings_page',
plugins_url( 'buddypress-compliments/images/smiley-icon.png' ),
85
);
add_submenu_page(
'bp-compliment-settings',
__( 'Compliment Types', BP_COMP_TEXTDOMAIN ),
__( 'Compliment Types', BP_COMP_TEXTDOMAIN ),
'manage_options',
'edit-tags.php?taxonomy=compliment'
);
}
Expand Down Expand Up @@ -93,6 +102,7 @@ function compliments_taxonomy_add_new_meta_field() {
<p><?php echo __( 'Recommended icon size: 20px x 20px' , BP_COMP_TEXTDOMAIN ); ?></p>
</div>
<?php
bp_compliments_taxonomy_highlight_js();
}
add_action( 'compliment_add_form_fields', 'compliments_taxonomy_add_new_meta_field', 10, 2 );
/**
Expand Down Expand Up @@ -120,6 +130,7 @@ function compliments_taxonomy_edit_meta_field($term) {
</td>
</tr>
<?php
bp_compliments_taxonomy_highlight_js();
}
add_action( 'compliment_edit_form_fields', 'compliments_taxonomy_edit_meta_field', 10, 2 );
/**
Expand Down Expand Up @@ -221,4 +232,60 @@ function compliment_remove_parent_dropdown()
});
</script>
<?php
}

add_action( 'admin_init', 'bp_compliments_register_settings' );
function bp_compliments_register_settings() {
register_setting( 'bp-compliment-settings', 'bp_compliment_can_delete' );
}

function bp_compliments_settings_page() {
?>
<div class="wrap">
<h2><?php echo __( 'BuddyPress Compliments - Settings', BP_COMP_TEXTDOMAIN ); ?></h2>

<form method="post" action="options.php">
<?php settings_fields( 'bp-compliment-settings' ); ?>
<?php do_settings_sections( 'bp-compliment-settings' );
$bp_compliment_can_delete_value = esc_attr( get_option('bp_compliment_can_delete'));
$bp_compliment_can_delete = $bp_compliment_can_delete_value ? $bp_compliment_can_delete_value : 'yes';
?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php echo __( 'Members can delete compliments received?', BP_COMP_TEXTDOMAIN ); ?></th>
<td>
<select id="bp_compliment_can_delete" name="bp_compliment_can_delete">
<option value="yes" <?php selected( $bp_compliment_can_delete, 'yes' ); ?>><?php echo __( 'Yes', BP_COMP_TEXTDOMAIN ); ?></option>
<option value="no" <?php selected( $bp_compliment_can_delete, 'no' ); ?>><?php echo __( 'No', BP_COMP_TEXTDOMAIN ); ?></option>
</select>
</tr>
</table>

<?php submit_button(); ?>

</form>
</div>
<?php }

function bp_compliments_taxonomy_highlight_js() {
?>
<script type="text/javascript">
jQuery(document).ready( function($)
{
//remove higlighting from the posts menu
var posts_menu = $('#menu-posts');
posts_menu.removeClass('wp-has-current-submenu wp-menu-open');
posts_menu.addClass('wp-not-current-submenu');
posts_menu.children('a').removeClass('wp-has-current-submenu');

// add highlighting to our compliments menu
var comp_menu = $('#toplevel_page_bp-compliment-settings');
comp_menu.removeClass('wp-not-current-submenu');
comp_menu.children('a').removeClass('wp-not-current-submenu');
comp_menu.addClass('wp-has-current-submenu wp-menu-open');
comp_menu.children('a').addClass('wp-has-current-submenu');

});
</script>
<?php
}
4 changes: 3 additions & 1 deletion includes/templates/buddypress/members/single/compliments.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class='preview-upload'/>
</em>
<?php
global $bp;
if (is_user_logged_in() && ($bp->loggedin_user->id == $bp->displayed_user->id)) {
$bp_compliment_can_delete_value = esc_attr( get_option('bp_compliment_can_delete'));
$bp_compliment_can_delete = $bp_compliment_can_delete_value ? $bp_compliment_can_delete_value : 'yes';
if (is_user_logged_in() && ($bp->loggedin_user->id == $bp->displayed_user->id) && ($bp_compliment_can_delete != 'no')) {
$receiver_url = bp_core_get_userlink( $comp->receiver_id, false, true );
$compliment_url = $receiver_url . $bp->compliments->id . '/?c_id='.$comp->id.'&action=delete';
?>
Expand Down
Binary file modified languages/bp-compliments-en_US.mo
Binary file not shown.
115 changes: 65 additions & 50 deletions languages/bp-compliments-en_US.po
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: BuddyPress Compliments 0.0.2\n"
"POT-Creation-Date: 2015-06-27 20:19+0530\n"
"PO-Revision-Date: 2015-06-27 20:19+0530\n"
"POT-Creation-Date: 2015-07-13 16:54+0530\n"
"PO-Revision-Date: 2015-07-13 16:54+0530\n"
"Last-Translator: \n"
"Language-Team: GeoDirectory <[email protected]>\n"
"Language: en_US\n"
Expand All @@ -15,32 +15,32 @@ msgstr ""
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x\n"
"X-Poedit-SearchPath-0: .\n"

#: bp-compliments-core.php:39 includes/bp-compliments-activity.php:108
#: bp-compliments-core.php:44 includes/bp-compliments-activity.php:108
#: includes/bp-compliments-activity.php:117
#: includes/bp-compliments-notifications.php:202
#: includes/bp-compliments-notifications.php:277
#: includes/bp-compliments-taxonomies.php:19
#: includes/bp-compliments-taxonomies.php:20
#: includes/bp-compliments-taxonomies.php:21
#: includes/bp-compliments-taxonomies.php:38
#: includes/bp-compliments-taxonomies.php:47
msgid "Compliments"
msgstr ""

#: bp-compliments-core.php:151
#: bp-compliments-core.php:171
#, php-format
msgid "Compliments <span>%d</span>"
msgstr ""

#: bp-compliments.php:51
#: bp-compliments.php:64
msgid "Hey! BP Compliments requires BuddyPress 1.5 or higher."
msgstr ""

#: includes/bp-compliments-actions.php:45
#: includes/bp-compliments-actions.php:50
#, php-format
msgid ""
"There was a problem when trying to send compliment to %s, please contact "
"administrator."
msgstr ""

#: includes/bp-compliments-actions.php:47
#: includes/bp-compliments-actions.php:52
#, php-format
msgid "Your compliment sent to %s."
msgstr ""
Expand All @@ -53,17 +53,17 @@ msgstr ""
msgid "Compliment Sent"
msgstr ""

#: includes/bp-compliments-activity.php:141
#: includes/bp-compliments-activity.php:174
#: includes/bp-compliments-activity.php:147
#: includes/bp-compliments-activity.php:180
msgid "compliment"
msgstr ""

#: includes/bp-compliments-activity.php:143
#: includes/bp-compliments-activity.php:149
#, php-format
msgid "%1$s has received a %2$s from %3$s"
msgstr ""

#: includes/bp-compliments-activity.php:176
#: includes/bp-compliments-activity.php:182
#, php-format
msgid "%1$s has sent a %2$s to %3$s"
msgstr ""
Expand All @@ -80,21 +80,21 @@ msgstr ""
msgid "Cancel"
msgstr ""

#: includes/bp-compliments-notifications.php:37
#: includes/bp-compliments-notifications.php:139
#: includes/bp-compliments-notifications.php:49
#: includes/bp-compliments-notifications.php:185
#, php-format
msgid "%s has sent you a compliment"
msgstr ""

#: includes/bp-compliments-notifications.php:142
#: includes/bp-compliments-notifications.php:188
#, php-format
msgid ""
"%s has sent you a compliment.\n"
"\n"
"To view %s's compliment: %s"
msgstr ""

#: includes/bp-compliments-notifications.php:149
#: includes/bp-compliments-notifications.php:195
#, php-format
msgid ""
"\n"
Expand All @@ -104,118 +104,133 @@ msgid ""
"%s"
msgstr ""

#: includes/bp-compliments-notifications.php:203
#: includes/bp-compliments-notifications.php:278
#: includes/bp-compliments-taxonomies.php:258
msgid "Yes"
msgstr ""

#: includes/bp-compliments-notifications.php:204
#: includes/bp-compliments-notifications.php:279
#: includes/bp-compliments-taxonomies.php:259
msgid "No"
msgstr ""

#: includes/bp-compliments-notifications.php:211
#: includes/bp-compliments-notifications.php:286
msgid "A member sends you a compliment"
msgstr ""

#: includes/bp-compliments-taxonomies.php:39
#: includes/bp-compliments-taxonomies.php:29
#: includes/bp-compliments-taxonomies.php:30
msgid "Compliment Types"
msgstr ""

#: includes/bp-compliments-taxonomies.php:48
#: includes/bp-compliments-taxonomies.php:57
msgid "Compliment"
msgstr ""

#: includes/bp-compliments-taxonomies.php:40
#: includes/bp-compliments-taxonomies.php:49
msgid "Search Compliments"
msgstr ""

#: includes/bp-compliments-taxonomies.php:41
#: includes/bp-compliments-taxonomies.php:50
msgid "All Compliments"
msgstr ""

#: includes/bp-compliments-taxonomies.php:42
#: includes/bp-compliments-taxonomies.php:51
msgid "Parent Compliment"
msgstr ""

#: includes/bp-compliments-taxonomies.php:43
#: includes/bp-compliments-taxonomies.php:52
msgid "Parent Compliment:"
msgstr ""

#: includes/bp-compliments-taxonomies.php:44
#: includes/bp-compliments-taxonomies.php:53
msgid "Edit Compliment"
msgstr ""

#: includes/bp-compliments-taxonomies.php:45
#: includes/bp-compliments-taxonomies.php:54
msgid "Update Compliment"
msgstr ""

#: includes/bp-compliments-taxonomies.php:46
#: includes/bp-compliments-taxonomies.php:55
msgid "Add New Compliment"
msgstr ""

#: includes/bp-compliments-taxonomies.php:47
#: includes/bp-compliments-taxonomies.php:56
msgid "New Compliment Name"
msgstr ""

#: includes/bp-compliments-taxonomies.php:87
#: includes/bp-compliments-taxonomies.php:110
#: includes/bp-compliments-taxonomies.php:96
#: includes/bp-compliments-taxonomies.php:120
msgid "Compliment Icon"
msgstr ""

#: includes/bp-compliments-taxonomies.php:90
#: includes/bp-compliments-taxonomies.php:115
#: includes/bp-compliments-taxonomies.php:99
#: includes/bp-compliments-taxonomies.php:125
msgid "Upload Icon"
msgstr ""

#: includes/bp-compliments-taxonomies.php:90
#: includes/bp-compliments-taxonomies.php:115
#: includes/bp-compliments-taxonomies.php:99
#: includes/bp-compliments-taxonomies.php:125
msgid "Use Icon"
msgstr ""

#: includes/bp-compliments-taxonomies.php:90
#: includes/bp-compliments-taxonomies.php:115
#: includes/bp-compliments-taxonomies.php:99
#: includes/bp-compliments-taxonomies.php:125
msgid "Upload new Icon"
msgstr ""

#: includes/bp-compliments-taxonomies.php:91
#: includes/bp-compliments-taxonomies.php:116
#: includes/bp-compliments-taxonomies.php:100
#: includes/bp-compliments-taxonomies.php:126
msgid "Remove Icon"
msgstr ""

#: includes/bp-compliments-taxonomies.php:93
#: includes/bp-compliments-taxonomies.php:118
#: includes/bp-compliments-taxonomies.php:102
#: includes/bp-compliments-taxonomies.php:128
msgid "Recommended icon size: 20px x 20px"
msgstr ""

#: includes/bp-compliments-taxonomies.php:163
#: includes/bp-compliments-taxonomies.php:174
msgid "Name"
msgstr ""

#: includes/bp-compliments-taxonomies.php:164
#: includes/bp-compliments-taxonomies.php:175
msgid "Icon"
msgstr ""

#: includes/bp-compliments-templatetags.php:73
#: includes/bp-compliments-taxonomies.php:245
msgid "BuddyPress Compliments - Settings"
msgstr ""

#: includes/bp-compliments-taxonomies.php:255
msgid "Members can delete compliments received?"
msgstr ""

#: includes/bp-compliments-templatetags.php:83
msgid "Send Compliment"
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:57
#: includes/templates/buddypress/members/single/compliments.php:67
msgid "Delete"
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:89
#: includes/templates/buddypress/members/single/compliments.php:99
#, php-format
msgid "1 of 1"
msgid_plural "%1$s to %2$s of %3$s"
msgstr[0] ""
msgstr[1] ""

#: includes/templates/buddypress/members/single/compliments.php:92
#: includes/templates/buddypress/members/single/compliments.php:102
msgid "Go to Page"
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:109
#: includes/templates/buddypress/members/single/compliments.php:119
msgid ""
"Aw, you have no compliments yet. To get some try sending compliments to "
"others."
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:115
#: includes/templates/buddypress/members/single/compliments.php:125
msgid "Sorry, no compliments just yet."
msgstr ""

0 comments on commit 7759c74

Please sign in to comment.