Ejemplo n.º 1
0
function wpProQuiz_achievementsV3()
{
    if (function_exists('achievements')) {
        achievements()->extensions->wp_pro_quiz = new WpProQuiz_Plugin_BpAchievementsV3();
        do_action('wpProQuiz_achievementsV3');
    }
}
 /**
  * Integrate Achievements into the BuddyPress Activity component.
  *
  * @since Achievements (3.2)
  */
 public function init_components()
 {
     if (!bp_is_active('activity')) {
         return;
     }
     require achievements()->includes_dir . 'class-dpa-buddypress-activity.php';
     achievements()->extensions->buddypress_activity = new DPA_BuddyPress_Activity();
 }
Ejemplo n.º 3
0
/**
 * Filter default options and allow them to be overloaded from inside the
 * achievements()->options array.
 *
 * @param string $value
 * @return mixed
 * @since Achievements (3.0)
 */
function dpa_pre_get_option($value = '')
{
    // Get the name of the current filter so we can manipulate it, and remove the filter prefix
    $option = str_replace('pre_option_', '', current_filter());
    // Check the options global for preset value
    if (isset(achievements()->options[$option])) {
        $value = achievements()->options[$option];
    }
    return $value;
}
Ejemplo n.º 4
0
 /**
  * Constructor
  *
  * Sets up extension properties. See class phpdoc for details.
  *
  * @since Achievements (3.4)
  */
 public function __construct()
 {
     $this->actions = array('rate_post' => __('The user rates a post.', 'achievements'));
     $this->contributors = array(array('name' => 'Lester Chan', 'gravatar_url' => 'http://gravatar.com/avatar/8fdd1c4a03682246e45b8b15cd08b854', 'profile_url' => 'http://profiles.wordpress.org/gamerz/'));
     $this->description = __("WP-PostRatings adds an AJAX rating system for your WordPress blogs&#8217 posts and pages.", 'achievements');
     $this->id = 'wp-postratings';
     $this->image_url = trailingslashit(achievements()->includes_url) . 'admin/images/wp-postratings.jpg';
     $this->name = __('WP-PostRatings', 'achievements');
     $this->rss_url = 'http://lesterchan.net/wordpress/feed/';
     $this->small_image_url = trailingslashit(achievements()->includes_url) . 'admin/images/wp-postratings-small.jpg';
     $this->version = 1;
     $this->wporg_url = 'https://wordpress.org/plugins/wp-postratings/';
 }
Ejemplo n.º 5
0
 /**
  * Constructor
  *
  * Sets up extension properties. See class phpdoc for details.
  *
  * @since Achievements (3.0)
  */
 public function __construct()
 {
     $this->actions = array('buddystream_facebook_activated' => __('The user connects their Facebook account to BuddyStream.', 'achievements'), 'buddystream_flickr_activated' => __('The user connects their Flickr account to BuddyStream.', 'achievements'), 'buddystream_lastfm_activated' => __('The user connects their Last.fm account to BuddyStream.', 'achievements'), 'buddystream_twitter_activated' => __('The user connects their Twitter account to BuddyStream.', 'achievements'), 'buddystream_youtube_activated' => __('The user connects their YouTube account to BuddyStream.', 'achievements'));
     $this->contributors = array(array('name' => 'Peter Hofman', 'gravatar_url' => 'http://www.gravatar.com/avatar/fa62da3fa8b3997be04448e7280dad29', 'profile_url' => 'http://profiles.wordpress.org/blackphantom/'));
     $this->description = __('BuddyStream is a BuddyPress plugin that will synchronize all of your favorite Social Networks to the BuddyPress activity stream.', 'achievements');
     $this->id = 'buddystream';
     $this->image_url = trailingslashit(achievements()->includes_url) . 'admin/images/buddystream.jpg';
     $this->name = __('BuddyStream', 'achievements');
     $this->rss_url = 'http://buddystream.net/feed/';
     $this->small_image_url = trailingslashit(achievements()->includes_url) . 'admin/images/buddystream-small.jpg';
     $this->version = 1;
     $this->wporg_url = 'https://wordpress.org/plugins/buddystream/';
 }
Ejemplo n.º 6
0
/**
 * Sets up metaboxes for the achievement post type admin screen.
 * This is a callback function which is invoked by register_post_type().
 *
 * Also enqueues required JavaScript and CSS.
 *
 * @since Achievements (3.0)
 */
function dpa_admin_setup_metaboxes()
{
    // Load metaboxes and on-save handler
    add_meta_box('dpa-mb', __('Achievements', 'achievements'), 'dpa_achievement_metabox', dpa_get_achievement_post_type(), 'side', 'high');
    remove_meta_box('tagsdiv-dpa_event', dpa_get_achievement_post_type(), 'side');
    // Chosen is a JavaScript plugin that makes long, unwieldy select boxes much more user-friendly.
    wp_enqueue_style('dpa_chosen_css', trailingslashit(achievements()->admin->css_url) . 'chosen.css', array(), dpa_get_version());
    wp_enqueue_script('dpa_chosen_js', trailingslashit(achievements()->admin->javascript_url) . 'chosen-jquery-min.js', array('jquery'), dpa_get_version());
    // General styles for the post type admin screen.
    $rtl = is_rtl() ? '-rtl' : '';
    wp_enqueue_script('dpa_admin_js', trailingslashit(achievements()->admin->javascript_url) . 'achievements.js', array('jquery', 'dpa_chosen_js'), dpa_get_version());
    wp_enqueue_style('dpa_admin_css', trailingslashit(achievements()->admin->css_url) . "achievements{$rtl}.css", array(), dpa_get_version());
}
Ejemplo n.º 7
0
/**
 * When a new site is created in a multisite installation, run the activation routine on that site.
 *
 * @param int $blog_id
 * @param int $user_id
 * @param string $domain
 * @param string $path
 * @param int $site_id
 * @param array() $meta
 * @since Achievements (3.0)
 */
function dpa_new_site($blog_id, $user_id, $domain, $path, $site_id, $meta)
{
    // Bail if plugin has not been network activated
    if (!is_plugin_active_for_network(achievements()->basename)) {
        return;
    }
    // Switch to the new blog
    switch_to_blog($blog_id);
    // Do the Achievements activation routine
    do_action('dpa_new_site');
    // restore original blog
    restore_current_blog();
}
Ejemplo n.º 8
0
 /**
  * Constructor
  *
  * Sets up extension properties. See class phpdoc for details.
  *
  * @since Achievements (3.0)
  */
 public function __construct()
 {
     $this->actions = array('wpsc_activate_subscription' => __('The user sets up a PayPal Subscription', 'achievements'), 'wpsc_payment_successful' => __('The user completes checkout', 'achievements'));
     $this->contributors = array(array('name' => 'Dan Milward', 'gravatar_url' => 'http://www.gravatar.com/avatar/5ba89a2ce585864ce73cafa7e79d114c', 'profile_url' => 'http://profiles.wordpress.org/mufasa/'), array('name' => 'Gary Cao', 'gravatar_url' => 'http://www.gravatar.com/avatar/aea5ee57d1e882ad17e95c99265784d1', 'profile_url' => 'http://profiles.wordpress.org/garyc40/'), array('name' => 'Justin Sainton', 'gravatar_url' => 'http://www.gravatar.com/avatar/02fbf19ad633e203e3bc571b80ca3f66', 'profile_url' => 'http://profiles.wordpress.org/justinsainton/'));
     $this->description = __('WP e-Commerce is a free WordPress Shopping Cart Plugin that lets customers buy your products, services and digital downloads online.', 'achievements');
     $this->id = 'wp-e-commerce';
     $this->image_url = trailingslashit(achievements()->includes_url) . 'admin/images/wp-e-commerce.jpg';
     $this->name = __('WP e-Commerce', 'achievements');
     $this->rss_url = 'http://getshopped.org/blog/feed/';
     $this->small_image_url = trailingslashit(achievements()->includes_url) . 'admin/images/wp-e-commerce.jpg';
     $this->version = 1;
     $this->wporg_url = 'https://wordpress.org/plugins/wp-e-commerce/';
 }
Ejemplo n.º 9
0
 /**
  * Constructor
  *
  * Sets up extension properties. See class phpdoc for details.
  *
  * @since Achievements (3.0)
  */
 public function __construct()
 {
     $this->actions = array('accepted_email_invite' => __('A new user activates their account.', 'achievements'), 'sent_email_invite' => __('The user invites someone else to join the site.', 'achievements'));
     $this->contributors = array(array('name' => 'Boone Gorges', 'gravatar_url' => 'http://www.gravatar.com/avatar/9cf7c4541a582729a5fc7ae484786c0c', 'profile_url' => 'http://profiles.wordpress.org/blackphantom/'), array('name' => 'CUNY Academic Commons', 'gravatar_url' => 'http://www.gravatar.com/avatar/80c3fc801559bbc7111d5e3f56ac6a4c', 'profile_url' => 'http://profiles.wordpress.org/cuny-academic-commons/'));
     $this->description = __("Makes BuddyPress’s invitation features more powerful.", 'achievements');
     $this->id = 'invite-anyone';
     $this->image_url = trailingslashit(achievements()->includes_url) . 'admin/images/invite-anyone.jpg';
     $this->name = __('Invite Anyone', 'achievements');
     $this->rss_url = 'http://teleogistic.net/feed/';
     $this->small_image_url = trailingslashit(achievements()->includes_url) . 'admin/images/invite-anyone-small.jpg';
     $this->version = 1;
     $this->wporg_url = 'https://wordpress.org/plugins/invite-anyone/';
     add_filter('dpa_handle_event_user_id', array($this, 'event_user_id'), 10, 3);
 }
Ejemplo n.º 10
0
 /**
  * Constructor
  *
  * Sets up extension properties. See class phpdoc for details.
  *
  * @since Achievements (3.0)
  */
 public function __construct()
 {
     $this->actions = array('bp_activity_add_user_favorite' => __('The user marks an item in an activity stream as a favourite.', 'achievements'), 'bp_activity_comment_posted' => __('The user replies to an item in an activity stream.', 'achievements'), 'bp_activity_posted_update' => __('The user writes an activity update message.', 'achievements'), 'bp_activity_remove_user_favorite' => __('The user un-favourites an item in their activity stream.', 'achievements'), 'bp_core_activated_user' => __('A new user activates their account on your website.', 'achievements'), 'bp_groups_posted_update' => __("The user writes a message in a group’s activity stream.", 'achievements'), 'friends_friendship_accepted' => __('The user accepts a friendship request from someone.', 'achievements'), 'friends_friendship_deleted' => __('The user cancels a friendship.', 'achievements'), 'friends_friendship_rejected' => __('The user rejects a friendship request from someone.', 'achievements'), 'friends_friendship_requested' => __('The user sends a friendship request to someone.', 'achievements'), 'groups_banned_member' => __('The user bans a member from a group.', 'achievements'), 'groups_group_create_complete' => __('The user creates a group.', 'achievements'), 'groups_delete_group' => __('The user deletes a group.', 'achievements'), 'groups_demoted_member' => __('The user demotes a group member from moderator or administrator status.', 'achievements'), 'groups_invite_user' => __('The user invites someone to join a group.', 'achievements'), 'groups_join_group' => __('The user joins a group.', 'achievements'), 'groups_leave_group' => __('The user leaves a group.', 'achievements'), 'groups_promote_member' => __('The user is promoted to a moderator or an administrator in a group.', 'achievements'), 'groups_promoted_member' => __('The user promotes a group member to moderator or administrator status.', 'achievements'), 'groups_unbanned_member' => __('The user unbans a member from a group.', 'achievements'), 'messages_delete_thread' => __('The user deletes a private message.', 'achievements'), 'messages_message_sent' => __('The user sends a new private message or replies to an existing one.', 'achievements'), 'xprofile_avatar_uploaded' => __("The user changes their profile’s avatar.", 'achievements'), 'xprofile_updated_profile' => __('The user updates their profile information.', 'achievements'));
     $this->contributors = array(array('name' => 'John James Jacoby', 'gravatar_url' => 'http://www.gravatar.com/avatar/81ec16063d89b162d55efe72165c105f', 'profile_url' => 'http://profiles.wordpress.org/johnjamesjacoby/'), array('name' => 'Paul Gibbs', 'gravatar_url' => 'http://www.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df', 'profile_url' => 'http://profiles.wordpress.org/DJPaul/'), array('name' => 'Boone Gorges', 'gravatar_url' => 'http://www.gravatar.com/avatar/9cf7c4541a582729a5fc7ae484786c0c', 'profile_url' => 'http://profiles.wordpress.org/boonebgorges/'), array('name' => 'Raymond Hoh', 'gravatar_url' => 'http://www.gravatar.com/avatar/3bfa556a62b5bfac1012b6ba5f42ebfa', 'profile_url' => 'http://profiles.wordpress.org/r-a-y/'));
     $this->description = __('Social networking in a box. Build a social network for your company, school, sports team or niche community.', 'achievements');
     $this->id = 'buddypress';
     $this->image_url = trailingslashit(achievements()->includes_url) . 'admin/images/buddypress.png';
     $this->name = __('BuddyPress', 'achievements');
     $this->rss_url = 'https://buddypress.org/blog/feed/';
     $this->small_image_url = trailingslashit(achievements()->includes_url) . 'admin/images/buddypress-small.png';
     $this->version = 1;
     $this->wporg_url = 'https://wordpress.org/plugins/buddypress/';
     add_filter('dpa_handle_event_user_id', array($this, 'event_user_id'), 10, 3);
 }
Ejemplo n.º 11
0
/**
 * Attempt to load a custom Achievements functions file, similar to a theme's functions.php file.
 *
 * @global string $pagenow
 * @since Achievements (3.0)
 */
function dpa_load_theme_functions()
{
    global $pagenow;
    // If Achievements is being deactivated, do not load any more files
    if (dpa_is_deactivation()) {
        return;
    }
    if (!defined('WP_INSTALLING') || !empty($pagenow) && 'wp-activate.php' !== $pagenow) {
        dpa_locate_template('achievements-functions.php', true);
        if (class_exists('DPA_Default')) {
            achievements()->theme_functions = new DPA_Default();
        }
    }
}
Ejemplo n.º 12
0
 /**
  * Constructor
  *
  * Sets up extension properties. See class phpdoc for details.
  *
  * @since Achievements (3.0)
  */
 public function __construct()
 {
     $this->actions = array('courseware_new_teacher_added' => __('The user is added as a teacher', 'achievements'), 'courseware_grade_added' => __('A grade is given to the user', 'achievements'), 'courseware_grade_updated' => __("A user’s grade is updated", 'achievements'), 'courseware_assignment_added' => __('The user creates a new assignment', 'achievements'), 'courseware_lecture_added' => __('The user creates a new lecture', 'achievements'), 'courseware_response_added' => __('The user adds a response to an assignment', 'achievements'), 'courseware_schedule_activity' => __('The user creates a new schedule', 'achievements'));
     $this->contributors = array(array('name' => 'Stas Sușcov', 'gravatar_url' => 'http://www.gravatar.com/avatar/39639fde05c65fae440b775989e55006', 'profile_url' => 'http://profiles.wordpress.org/sushkov/'), array('name' => 'Jeremy Boggs', 'gravatar_url' => 'http://www.gravatar.com/avatar/2a062a10cb94152f4ab3daf569af54c3', 'profile_url' => 'http://profiles.wordpress.org/jeremyboggs/'), array('name' => 'Boone Gorges', 'gravatar_url' => 'http://www.gravatar.com/avatar/9cf7c4541a582729a5fc7ae484786c0c', 'profile_url' => 'http://profiles.wordpress.org/boonebgorges/'), array('name' => 'John James Jacoby', 'gravatar_url' => 'http://www.gravatar.com/avatar/81ec16063d89b162d55efe72165c105f', 'profile_url' => 'http://profiles.wordpress.org/johnjamesjacoby/'), array('name' => 'Chelsea Otakan', 'gravatar_url' => 'http://www.gravatar.com/avatar/0231c6b98cf90defe76bdad0c3c66acf', 'profile_url' => 'http://profiles.wordpress.org/chexee/'));
     $this->description = __('A Learning Management System for BuddyPress.', 'achievements');
     $this->id = 'buddypress-courseware';
     $this->image_url = trailingslashit(achievements()->includes_url) . 'admin/images/buddypress-courseware.png';
     $this->name = __('BuddyPress Courseware', 'achievements');
     $this->rss_url = 'http://feeds.nerd.ro/stas/';
     $this->small_image_url = trailingslashit(achievements()->includes_url) . 'admin/images/buddypress-courseware-small.png';
     $this->version = 1;
     $this->wporg_url = 'https://wordpress.org/plugins/buddypress-courseware/';
     add_filter('dpa_handle_event_user_id', array($this, 'event_user_id'), 10, 3);
 }
Ejemplo n.º 13
0
 /**
  * Constructor
  *
  * Sets up extension properties. See class phpdoc for details.
  *
  * @since Achievements (3.0)
  */
 public function __construct()
 {
     $this->actions = array('comment_post' => __('A comment is written by the user.', 'achievements'), 'wordpress_draft_to_publish' => __('The user publishes a blog post.', 'achievements'), 'signup_finished' => __('A new site is created by the user (multi-site only).', 'achievements'), 'trashed_post' => __('The user trashes a blog post.', 'achievements'), 'user_register' => __('A new user creates an account on your website.', 'achievements'));
     $this->generic_cpt_actions = array('draft_to_publish', 'future_to_publish', 'new_to_publish', 'pending_to_publish', 'private_to_publish');
     $this->contributors = array(array('name' => 'WordPress', 'gravatar_url' => 'http://s.wordpress.org/about/images/logos/wordpress-logo-notext-rgb.png', 'profile_url' => network_admin_url('credits.php')));
     $this->description = __('WordPress started in 2003 with a single bit of code to enhance the typography of everyday writing and with fewer users than you can count on your fingers and toes. Since then it has grown to be the largest self-hosted blogging tool in the world, used on millions of sites and seen by tens of millions of people every day.', 'achievements');
     $this->id = 'wordpress';
     $this->image_url = trailingslashit(achievements()->includes_url) . 'admin/images/wordpress.jpg';
     $this->name = __('WordPress', 'achievements');
     $this->rss_url = 'https://wordpress.org/news/feed/';
     $this->small_image_url = trailingslashit(achievements()->includes_url) . 'admin/images/wordpress-small.jpg';
     $this->version = 2;
     $this->wporg_url = 'https://wordpress.org/about/';
     add_filter('dpa_filter_events', array($this, 'get_generic_cpt_actions'), 1, 1);
     add_filter('dpa_handle_event_name', array($this, 'event_name'), 10, 2);
     add_filter('dpa_handle_event_user_id', array($this, 'event_user_id'), 10, 3);
 }
Ejemplo n.º 14
0
 /**
  * Constructor
  *
  * Sets up extension properties. See class phpdoc for details.
  *
  * @since Achievements (3.0)
  */
 public function __construct()
 {
     $this->actions = array('bbp_deleted_forum' => __('A forum is permanently deleted by the user', 'achievements'), 'bbp_edit_forum' => __("A forum’s settings are changed by the user", 'achievements'), 'bbp_new_forum' => __('The user creates a new forum', 'achievements'), 'bbp_trashed_forum' => __('The user puts a forum into the trash', 'achievements'), 'bbp_untrashed_forum' => __('The user restores a forum from the trash', 'achievements'), 'bbp_closed_topic' => __('The user closes a topic.', 'achievements'), 'bbp_merged_topic' => __('Separate topics are merged together by a user', 'achievements'), 'bbp_opened_topic' => __('The user opens a topic for new replies', 'achievements'), 'bbp_post_split_topic' => __('An existing topic is split into seperate threads by a user', 'achievements'), 'bbp_deleted_topic' => __('The user permanently deletes a topic', 'achievements'), 'bbp_sticked_topic' => __('The user marks a topic as a sticky', 'achievements'), 'bbp_trashed_topic' => __('The user trashes a topic', 'achievements'), 'bbp_unsticked_topic' => __('The user unstickies a topic', 'achievements'), 'bbp_untrashed_topic' => __('The user restores a topic from the trash', 'achievements'), 'bbpress_topic_draft_to_publish' => __('The user creates a new topic.', 'achievements'), 'bbp_deleted_reply' => __('The user permanently deletes a reply', 'achievements'), 'bbp_trashed_reply' => __('The user trashes a reply', 'achievements'), 'bbp_untrashed_reply' => __('The user restores a reply from the trash', 'achievements'), 'bbpress_reply_draft_to_publish' => __('The user replies to a topic.', 'achievements'));
     $this->contributors = array(array('name' => 'Matt', 'gravatar_url' => 'http://www.gravatar.com/avatar/767fc9c115a1b989744c755db47feb60', 'profile_url' => 'http://profiles.wordpress.org/matt/'), array('name' => 'John James Jacoby', 'gravatar_url' => 'http://www.gravatar.com/avatar/81ec16063d89b162d55efe72165c105f', 'profile_url' => 'http://profiles.wordpress.org/johnjamesjacoby/'), array('name' => 'Jennifer M. Dodd', 'gravatar_url' => 'http://www.gravatar.com/avatar/6a7c997edea340616bcc6d0fe03f65dd', 'profile_url' => 'http://profiles.wordpress.org/jmdodd/'), array('name' => 'Stephen Edgar', 'gravatar_url' => 'http://www.gravatar.com/avatar/97e1620b501da675315ba7cfb740e80f', 'profile_url' => 'https://profiles.wordpress.org/netweb/'));
     $this->generic_cpt_actions = array('draft_to_publish', 'future_to_publish', 'new_to_publish', 'pending_to_publish', 'private_to_publish');
     $this->description = __('bbPress is forum software, made the WordPress way.', 'achievements');
     $this->id = 'bbpress';
     $this->image_url = trailingslashit(achievements()->includes_url) . 'admin/images/bbpress.png';
     $this->name = __('bbPress', 'achievements');
     $this->rss_url = 'https://bbpress.org/blog/feed/';
     $this->small_image_url = trailingslashit(achievements()->includes_url) . 'admin/images/bbpress-small.png';
     $this->version = 1;
     $this->wporg_url = 'https://wordpress.org/plugins/bbpress/';
     add_filter('dpa_filter_events', array($this, 'get_generic_cpt_actions'), 1, 1);
     add_filter('dpa_handle_event_name', array($this, 'event_name'), 10, 2);
     add_filter('dpa_handle_event_user_id', array($this, 'event_user_id'), 10, 3);
 }
Ejemplo n.º 15
0
/**
 * Render the "my achievements" template part.
 * 
 * Used by BuddyPress' members/single/plugins.php template part via the 'bp_template_content' filter.
 *
 * @since Achievements (3.2)
 */
function dpa_bp_members_my_achievements_content()
{
    echo achievements()->shortcodes->display_user_achievements();
}
Ejemplo n.º 16
0
/**
 * Returns details of all events from the event taxonomy, and groups the events by extension.
 *
 * This is used in the new/edit post type screen, but can be used anywhere where you need to
 * show a list of all events grouped by the extension which provides them.
 *
 * @return array
 * @since Achievements (3.0)
 */
function dpa_get_all_events_details()
{
    $temp_events = array();
    // Get all events from the event taxonomy and sort them by the plugin which provides them
    $events = get_terms(achievements()->event_tax_id, array('hide_empty' => false));
    foreach ($events as $event) {
        // Find out which plugin provides this event
        foreach (achievements()->extensions as $extension) {
            if (!is_a($extension, 'DPA_Extension')) {
                continue;
            }
            // If this extension contains this event
            if (array_key_exists($event->name, $extension->get_actions())) {
                if (!isset($temp_events[$extension->get_name()])) {
                    $temp_events[$extension->get_name()] = array();
                }
                // Store term description and ID
                $temp_events[$extension->get_name()][] = array('description' => $event->description, 'id' => $event->term_id);
                break;
            }
        }
    }
    $events = $temp_events;
    return apply_filters('dpa_get_all_events_details', $events);
}
Ejemplo n.º 17
0
/**
 * Settings API validation callback function for the _dpa_theme_package_id setting.
 *
 * @param string $new_package User-supplied value to check
 * @return string
 * @see dpa_admin_get_settings_fields()
 * @since Achievements (3.6)
 */
function dpa_admin_setting_validate_theme_package_id($new_package)
{
    $valid_package_ids = array_keys(achievements()->theme_compat->packages);
    $new_package = in_array($new_package, $valid_package_ids) ? $new_package : 'default';
    return apply_filters('dpa_admin_setting_validate_theme_package_id', $new_package);
}
Ejemplo n.º 18
0
/**
 * Determine if Achievements is being deactivated
 *
 * @param string $basename Optional
 * @return bool True if deactivating Achievements, false if not
 * @since Achievements (3.0)
 */
function dpa_is_deactivation($basename = '')
{
    global $pagenow;
    // Bail if not in admin/plugins
    if (!is_admin() || 'plugins.php' !== $pagenow) {
        return false;
    }
    $action = false;
    if (!empty($_REQUEST['action']) && '-1' !== $_REQUEST['action']) {
        $action = $_REQUEST['action'];
    } elseif (!empty($_REQUEST['action2']) && '-1' !== $_REQUEST['action2']) {
        $action = $_REQUEST['action2'];
    }
    // Bail if not deactivating
    if (empty($action) || !in_array($action, array('deactivate', 'deactivate-selected'))) {
        return false;
    }
    // The plugin(s) being deactivated
    if ($action === 'deactivate') {
        $plugins = isset($_GET['plugin']) ? array($_GET['plugin']) : array();
    } else {
        $plugins = isset($_POST['checked']) ? (array) $_POST['checked'] : array();
    }
    // Set basename if empty
    if (empty($basename) && !empty(achievements()->basename)) {
        $basename = achievements()->basename;
    }
    // Bail if no basename
    if (empty($basename)) {
        return false;
    }
    // Is Achievements being deactivated?
    return in_array($basename, $plugins);
}
Ejemplo n.º 19
0
/**
 * Filter the plugin locale and domain.
 *
 * @param string $locale Optional
 * @param string $domain Optionl
 * @since Achievements (3.0)
 */
function dpa_plugin_locale($locale = '', $domain = '')
{
    // Only filter the dpa text domain
    if (achievements()->domain !== $domain) {
        return $locale;
    }
    return apply_filters('dpa_plugin_locale', $locale, $domain);
}
Ejemplo n.º 20
0
/**
 * Return pagination links
 *
 * @return string Pagination links
 * @since Achievements (3.0)
 */
function dpa_get_achievement_pagination_links()
{
    if (!is_a(achievements()->achievement_query, 'WP_Query')) {
        return '';
    }
    return apply_filters('dpa_get_achievement_pagination_links', achievements()->achievement_query->pagination_links);
}
Ejemplo n.º 21
0
/**
 * If the specified achievement's criteria has been met, we unlock the
 * achievement. Otherwise we record progress for the achievement for next time.
 *
 * $skip_validation is the second parameter for backpat with Achievements 2.x
 *
 * @param int     $user_id
 * @param string  $skip_validation  Optional. Set to "skip_validation" to skip Achievement validation (unlock achievement regardless of criteria).
 * @param object  $progress_obj     Optional. The Progress post object. Defaults to Progress object in the Progress loop.
 * @param object  $achievement_obj  Optional. The Achievement post object to maybe_unlock. Defaults to current object in Achievement loop.
 * @since Achievements (2.0)
 */
function dpa_maybe_unlock_achievement($user_id, $skip_validation = '', $progress_obj = null, $achievement_obj = null)
{
    // Only proceed if the specified user is active (logged in and not a spammer)
    if (!dpa_is_user_active($user_id)) {
        return;
    }
    // Only proceed if the specified user can create progress posts
    if (!user_can($user_id, 'publish_achievement_progresses')) {
        return;
    }
    // Default to current object in the achievement loop
    if (empty($achievement_obj)) {
        $achievement_obj = achievements()->achievement_query->post;
    }
    // Default to progress object in the progress loop
    if (empty($progress_obj) && !empty(achievements()->progress_query->posts)) {
        $progress_obj = wp_filter_object_list(achievements()->progress_query->posts, array('post_parent' => $achievement_obj->ID));
        $progress_obj = array_shift($progress_obj);
    }
    // Has the user already unlocked the achievement?
    if (!empty($progress_obj) && dpa_get_unlocked_status_id() === $progress_obj->post_status) {
        return;
    }
    // Prepare default values to create/update a progress post
    $progress_args = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_author' => $user_id, 'post_parent' => $achievement_obj->ID, 'post_title' => $achievement_obj->post_title, 'post_type' => dpa_get_progress_post_type());
    // If achievement already has some progress, grab the ID so we update the post later
    if (!empty($progress_obj->ID)) {
        $progress_args['ID'] = $progress_obj->ID;
    }
    // If the achievement does not have a target set, this is an award achievement.
    $achievement_target = dpa_get_achievement_target($achievement_obj->ID);
    if ($achievement_target) {
        // Increment progress count
        $progress_args['post_content'] = apply_filters('dpa_maybe_unlock_achievement_progress_increment', 1);
        if (!empty($progress_obj)) {
            $progress_args['post_content'] = (int) $progress_args['post_content'] + (int) $progress_obj->post_content;
        }
    }
    // Does the progress count now meet the achievement target?
    if ('skip_validation' === $skip_validation || $achievement_target && (int) $progress_args['post_content'] >= $achievement_target) {
        // Yes. Unlock achievement.
        $progress_args['post_status'] = dpa_get_unlocked_status_id();
        // No, user needs to make more progress. Make sure the locked status is set correctly.
    } else {
        $progress_args['post_status'] = dpa_get_locked_status_id();
    }
    // Create or update the progress post
    $progress_id = wp_insert_post($progress_args);
    // If the achievement was just unlocked, do stuff.
    if (dpa_get_unlocked_status_id() === $progress_args['post_status']) {
        // Achievement was unlocked. Notifications and points updates are hooked to this function.
        do_action('dpa_unlock_achievement', $achievement_obj, $user_id, $progress_id);
    }
}
Ejemplo n.º 22
0
 /**
  * Set up global variables
  *
  * @since Achievements (3.0)
  */
 private function setup_globals()
 {
     // Versions
     $this->version = '3.5.1';
     $this->db_version = 340;
     // Paths - plugin
     $this->file = __FILE__;
     $this->basename = apply_filters('dpa_basename', str_replace(array('build/', 'src/'), '', plugin_basename($this->file)));
     $this->plugin_dir = apply_filters('dpa_plugin_dir_path', plugin_dir_path($this->file));
     $this->plugin_url = apply_filters('dpa_plugin_dir_url', plugin_dir_url($this->file));
     // Paths - theme compatibility packs
     $this->themes_dir = apply_filters('dpa_themes_dir', trailingslashit($this->plugin_dir . 'templates'));
     $this->themes_url = apply_filters('dpa_themes_url', trailingslashit($this->plugin_url . 'templates'));
     // Paths - languages
     $this->lang_dir = apply_filters('dpa_lang_dir', trailingslashit($this->plugin_dir . 'languages'));
     // Includes
     $this->includes_dir = apply_filters('dpa_includes_dir', trailingslashit($this->plugin_dir . 'includes'));
     $this->includes_url = apply_filters('dpa_includes_url', trailingslashit($this->plugin_url . 'includes'));
     // Post type/endpoint/taxonomy identifiers
     $this->achievement_post_type = apply_filters('dpa_achievement_post_type', 'achievement');
     $this->achievement_progress_post_type = apply_filters('dpa_achievement_progress_post_type', 'dpa_progress');
     $this->authors_endpoint = apply_filters('dpa_authors_endpoint', 'achievements');
     $this->event_tax_id = apply_filters('dpa_event_tax_id', 'dpa_event');
     // Post status identifiers
     $this->locked_status_id = apply_filters('dpa_locked_post_status', 'dpa_locked');
     $this->unlocked_status_id = apply_filters('dpa_unlocked_post_status', 'dpa_unlocked');
     // Queries
     $this->current_achievement_id = 0;
     // Current achievement ID
     $this->achievement_query = new WP_Query();
     // Main achievement post type query
     $this->leaderboard_query = new ArrayObject();
     // Leaderboard template loop
     $this->progress_query = new WP_Query();
     // Main dpa_progress post type query
     // Theme compat
     $this->theme_compat = new stdClass();
     // Base theme compatibility class
     $this->filters = new stdClass();
     // Used when adding/removing filters
     // Other stuff
     $this->domain = 'achievements';
     // Unique identifier for retrieving translated strings
     $this->errors = new WP_Error();
     // Errors
     $this->extensions = new stdClass();
     // Other plugins add data here
     // Deep integration with other plugins
     $this->integrate_into_buddypress = false;
     // Use BuddyPress profiles for screens like "my achievements"
     /**
      * If multisite and running network-wide, grab the options from the site options
      * table and store in achievements()->options. dpa_setup_option_filters() sets
      * up a pre_option filter which loads from achievements()->options if an option
      * has been set there. This saves a lot of conditionals throughout the plugin.
      */
     if (is_multisite() && dpa_is_running_networkwide()) {
         $options = dpa_get_default_options();
         foreach ($options as $option_name => $option_value) {
             achievements()->options[$option_name] = get_site_option($option_name);
         }
     }
 }
Ejemplo n.º 23
0
/**
 * Return the unlocked (achievement progress) post status ID
 *
 * @return string
 * @since Achievements (3.0)
 */
function dpa_get_unlocked_status_id()
{
    return apply_filters('dpa_get_unlocked_status_id', achievements()->unlocked_status_id);
}
Ejemplo n.º 24
0
/**
 * Return leaderboard pagination links
 *
 * @return string Pagination links
 * @since Achievements (3.4)
 */
function dpa_get_leaderboard_pagination_links()
{
    if (empty(achievements()->leaderboard_query)) {
        return '';
    }
    return apply_filters('dpa_get_leaderboard_pagination_links', achievements()->leaderboard_query['pagination_links']);
}
Ejemplo n.º 25
0
 /**
  * Add Settings link to plugins area.
  *
  * @param array $links Links array in which we would prepend our link.
  * @param string $file Current plugin basename.
  * @return array
  * @since Achievements (3.6)
  */
 public static function modify_plugin_action_links($links, $file)
 {
     // Return normal links if not Achievements
     if (plugin_basename(achievements()->basename) != $file) {
         return $links;
     }
     return array_merge($links, array('settings' => '<a href="' . esc_url(add_query_arg(array('page' => 'achievements'), admin_url('options-general.php'))) . '">' . esc_html_x('Settings', 'plugin settings', 'achievements') . '</a>', 'about' => '<a href="' . esc_url(add_query_arg(array('page' => 'achievements-about'), admin_url('index.php'))) . '">' . esc_html_x('About', 'plugin about page', 'achievements') . '</a>'));
 }
Ejemplo n.º 26
0
/**
 * Tells Achievements whether to integrate with BuddyPress' profile component or not.
 *
 * @return
 * @since Achievements (3.2)
 */
function dpa_integrate_into_buddypress()
{
    return apply_filters('dpa_integrate_into_buddypress', achievements()->integrate_into_buddypress);
}
Ejemplo n.º 27
0
/**
 * Filter default options and allow them to be overloaded from inside the
 * achievements()->user_options array.
 *
 * @since Achievements (3.0)
 * @param bool $value Optional. Fallback value if none found (default is false).
 * @param string $option Optional. Option name
 * @param WP_User $user Optional. User to get option for
 * @return mixed false if not overloaded, mixed if set
 */
function dpa_filter_get_user_option($value = false, $option = '', WP_User $user = null)
{
    // Check the options global for preset value
    if (isset($user->ID) && isset(achievements()->user_options[$user->ID]) && !empty(achievements()->user_options[$user->ID][$option])) {
        $value = achievements()->user_options[$user->ID][$option];
    }
    return $value;
}
Ejemplo n.º 28
0
/**
 * Display possible errors & messages inside a template file
 *
 * @since Achievements (3.0)
 */
function dpa_template_notices()
{
    // Bail if no notices or errors
    if (!dpa_has_errors()) {
        return;
    }
    // Define local variable(s)
    $errors = $messages = array();
    // Loop through notices
    foreach (achievements()->errors->get_error_codes() as $code) {
        // Get notice severity
        $severity = achievements()->errors->get_error_data($code);
        // Loop through notices and separate errors from messages
        foreach (achievements()->errors->get_error_messages($code) as $error) {
            if ('message' === $severity) {
                $messages[] = $error;
            } else {
                $errors[] = $error;
            }
        }
    }
    // Display errors first...
    if (!empty($errors)) {
        ?>

		<div class="dpa-template-notice error">
			<p>
				<?php 
        echo implode("</p>\n<p>", array_map('esc_html', $errors));
        ?>
			</p>
		</div>

	<?php 
    }
    // ...and messages last
    if (!empty($messages)) {
        ?>

		<div class="dpa-template-notice">
			<p>
				<?php 
        echo implode("</p>\n<p>", array_map('esc_html', $messages));
        ?>
			</p>
		</div>

	<?php 
    }
}
Ejemplo n.º 29
0
 /**
  * Display the contents of a specific achievement ID in an output buffer
  * and return to ensure that post/page contents are displayed first.
  *
  * @param array $attr
  * @param string $content Optional
  * @return string Contents of output buffer
  * @since Achievements (3.0)
  */
 public function display_achievement($attr, $content = '')
 {
     // Sanity check required info
     if (!empty($content) || (empty($attr['id']) || !is_numeric($attr['id']))) {
         return $content;
     }
     $this->unset_globals();
     // Set passed attribute to $achievement_id for clarity
     $achievement_id = achievements()->current_achievement_id = absint($attr['id']);
     // Bail if ID passed is not an achievement
     if (!dpa_is_achievement($achievement_id)) {
         return $content;
     }
     // If not in theme compat, reset necessary achievement_query attributes for achievements loop to function
     if (!dpa_is_theme_compat_active()) {
         achievements()->achievement_query->query_vars['post_type'] = dpa_get_achievement_post_type();
         achievements()->achievement_query->in_the_loop = true;
         achievements()->achievement_query->post = get_post($achievement_id);
     }
     $this->start('dpa_single_achievement');
     dpa_get_template_part('content-single-achievement');
     return $this->end();
 }
 /**
  * Output the notification JS templates.
  * 
  * These will be used with underscore.js' _.template() method. It compiles these JS templates into functions
  * that can be evaluated for rendering. Useful for rendering complicated bits of HTML from JSON data sources,
  * which is exactly what we're going to do.
  *
  * @since Achievements (3.5)
  */
 public static function print_notification_templates()
 {
     // If user's not active or is inside the WordPress Admin, bail out.
     if (!dpa_is_user_active() || is_admin() || is_404()) {
         return;
     }
     echo achievements()->shortcodes->display_notifications_template();
 }