Skip to content

Commit

Permalink
Updated readme.txt, formatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
reneneee committed May 30, 2016
1 parent a87564f commit 8b4b55c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 51 deletions.
16 changes: 8 additions & 8 deletions badgeos-award-role.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php
/**
* Plugin Name: BadgeOS Award Role Add-On
* Plugin URI: http://www.konnektiv.de/
* Plugin URI: http://konnektiv.de/
* Description: Allows adding a role to a user who has earned a BadgeOS achievement
* Tags: buddypress
* Author: konnektiv, Christoph Herbst
* Version: 1.0.0
* Author URI: https://konnektiv.de/
* Author: Konnektiv
* Version: 1.0.1
* Author URI: http://konnektiv.de/
* License: GNU AGPL
* Text Domain: badgeos-award-role
*/

/*
* Copyright © 2016 Konnektiv
* Copyright © 2016 Konnektiv, Christoph Herbst
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License, version 3,
Expand Down Expand Up @@ -52,7 +51,7 @@ function __construct() {
/**
* Files to include for BadgeOS integration.
*
* @since 1.1.1
* @since 1.0.0
*/
public function includes() {
if ( $this->meets_requirements() ) {
Expand Down Expand Up @@ -90,7 +89,7 @@ public function activate() {
*/
public static function meets_requirements() {

if ( class_exists('BadgeOS') && version_compare( BadgeOS::$version, '1.4.0', '>=' ) ) {
if ( class_exists( 'BadgeOS' ) && version_compare( BadgeOS::$version, '1.4.0', '>=' ) ) {
return true;
} else {
return false;
Expand All @@ -116,4 +115,5 @@ public function maybe_disable_plugin() {
}

}

new BadgeOS_Award_Role();
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "konnektiv/badgeos-award-role-add-on",
"description": "Allows adding a role to a user who has earned a BadgeOS achievement.",
"type": "wordpress-plugin",
"license": "GPL-2.0+",
"license": "AGPL-3.0",
"require": {
"composer/installers": "~1.0",
"php": ">=5.2.4"
Expand Down
29 changes: 15 additions & 14 deletions includes/actions-filters.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
<?php

if ( !function_exists('get_editable_roles') ) {
if ( ! function_exists( 'get_editable_roles' ) ) {
require_once( ABSPATH . '/wp-admin/includes/user.php' );
}

add_filter('badgeos_achievement_data_meta_box_fields', function($fields) {
$prefix = "_badgeos_";
add_filter( 'badgeos_achievement_data_meta_box_fields', function ( $fields ) {
$prefix = "_badgeos_";
$options = array(
array('value' => 'none', 'name' => __('None', 'badgeos-award-role'))
array( 'value' => 'none', 'name' => __( 'None', 'badgeos-award-role' ) )
);
foreach (get_editable_roles() as $role_name => $role_info) {
$options[] = array( 'value' => $role_name, 'name' => $role_info['name']);
foreach ( get_editable_roles() as $role_name => $role_info ) {
$options[] = array( 'value' => $role_name, 'name' => $role_info['name'] );
}
$fields[] = array(
'name' => __( 'Award Role', 'badgeos-award-role' ),
'desc' => ' '.__( 'Role which should be awarded to the user when earning this achievement.', 'badgeos-award-role' ),
'id' => $prefix . 'award_role',
'type' => 'select',
'name' => __( 'Award Role', 'badgeos-award-role' ),
'desc' => ' ' . __( 'Role which should be awarded to the user when earning this achievement.', 'badgeos-award-role' ),
'id' => $prefix . 'award_role',
'type' => 'select',
'options' => $options,
'default' => 'none',
);

return $fields;
});
} );

add_action('badgeos_award_achievement', function($user_id, $achievement_id){
add_action( 'badgeos_award_achievement', function ( $user_id, $achievement_id ) {
$role = get_post_meta( $achievement_id, '_badgeos_award_role', true );

if ($role && $role != 'none' ) {
if ( $role && $role != 'none' ) {
$user = new WP_User( $user_id );

// Add role
$user->add_role( $role );
}
}, 10, 2);
}, 10, 2 );
41 changes: 13 additions & 28 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
=== BadgeOS Award Role Add-on ===
Contributors: Konnektiv, Christoph Herbst
Contributors: konnektiv, chherbst
Tags: badge, badges, openbadges, credly, role, OBI, mozilla, open badges, achievement, award, reward, engagement, submission, nomination, community, API, open credit, credit, plugin
Requires at least: WordPress 3.6.0, BadgeOS 1.4.0
Tested up to: 4.3
Stable tag: 0.0.1
Tested up to: 4.5.2
Stable tag: 1.0.1
License: GNU AGPLv3
License URI: http://www.gnu.org/licenses/agpl-3.0.html

Expand All @@ -13,41 +13,26 @@ Allows adding a role to a user who has earned a BadgeOS achievement

Allows adding a role to a user who has earned a BadgeOS achievement.

**Note:** You will need to install the free [BadgeOS plugin](http://wordpress.org/extend/plugins/badgeos/ "BadgeOS")&trade; (version 1.2 or higher) to use the BadgeOS Community Add-on.
**Note:** You will need to install the free [BadgeOS plugin](http://wordpress.org/extend/plugins/badgeos/ "BadgeOS")&trade; (version 1.4 or higher) to use the BadgeOS Community Add-on.

[Get the BadgeOS plugin](http://wordpress.org/extend/plugins/badgeos/ "BadgeOS").

[BadgeOS](http://badgeos.org "BadgeOS")&trade; turns your WordPress site into an achievement and badging system. And with BuddyPress enabled on your site, achievements are not only awarded by demonstrating skills and knowledge, but also by participating in community activities. Define the achievements, organize the badge requirements any way you like, and choose from and combine a range of assessment and community activity options to determine whether each task or requirement has been achieved.
This plugin was originally developed for the [globe - Community of Digital Learning](https://quality4digitallearning.org/) on behalf of [GIZ](https://www.giz.de/).

Earned badges are Mozilla OBI compatible and sharable via [Credly](https://credly.com/ "Credly.com"), the free web service for recognizing and displaying lifelong achievement.
= Contact =

= Extensibility and Additional BadgeOS Add-ons =

* BadgeOS is designed to be a true operating system for turning any WordPress site into an engagement management application.
* Built with expandability in mind to allow virtually anything to trigger and recognize achievement.
* BadgeOS plans to continue to release a range of Add-Ons to the plugin -- like the BadgeOS Community Add-on -- that enhance core functionality with specialized functions.
* Check out some of the [BadgeOS customizations](http://badgeos.org/services/badgeos-customization/ "We'll help you customize your BadgeOS site") we've already implemented to get a sense for what you might expect.


= Stay Connected / Helpful Links =

BadgeOS is made available by [LearningTimes, LLC](http://www.learningtimes.com/ "LearningTimes web site"). Here are some ways to stay connected and to see what else we are up to:

* [BadgeOS.org](http://badgeos.org/ "BadgeOS web site") - Contact Us, Video Tutorials, Examples, News
* [LearningTimes](http://www.learningtimes.com "LearningTimes web site") - Producers of online learning events, programs and applications
* [Credly.com](https://credly.com/ "Credly web site") - Issue, manage, share and collect lifelong credentials and digital badges
* [Credly Knowledgebase](http://support.credly.com/ "Credly FAQ and Support") - Credly FAQ
* [Facebook](https://www.facebook.com/Credly "Credly on Facebook") - Credly on Facebook
* [Twitter](https://twitter.com/credly "Credly on Facebook") - Credly Tweets
* [E-Mailing List](https://http://badgeos.org/join-list/ "BadgeOS Occasional Mailing List - No spam!") - Occasional updates via e-mail
* [GitHub](https://github.com/opencredit/badgeos "BadgeOS on GitHub") - Report issues, contribute code
* [Konnektiv](http://konnektiv.de/)
* [BadgeOS Award Role Add-on on GitHub](https://github.com/konnektiv/BadgeOS-Award-Role-Add-on) - Report issues, contribute code


== Installation ==

1. Upload, activate and configure the free [BadgeOS plugin](http://wordpress.org/extend/plugins/badgeos/ "BadgeOS") to WordPress.
3. Upload 'badgeos-award-role' to the '/wp-content/plugins/' directory
4. Activate the plugin through the 'Plugins' menu in WordPress
2. Upload 'BadgeOS-Award-Role-Add-on' to the '/wp-content/plugins/' directory
3. Activate the plugin through the 'Plugins' menu in WordPress

= 1.0.1 =
* updated readme.txt

= 1.0.0 =
* Initial release

0 comments on commit 8b4b55c

Please sign in to comment.