/**
         * User Badges Admin Screen
         * @version 1.0
         */
        public function badge_user_screen()
        {
            global $mycred_manual_badges;
            $user_id = absint($_GET['user_id']);
            $user = get_userdata($user_id);
            global $bp;
            $mycred_admin = new myCRED_Admin();
            if (is_object($bp) && isset($bp->version) && version_compare($bp->version, '2.0', '>=') && bp_is_active('xprofile')) {
                $mycred_admin->using_bp = true;
            }
            $all_badges = mycred_get_badge_ids();
            $users_badges = mycred_get_users_badges($user_id);
            ?>
<div class="wrap" id="edit-badges-page">
	<h2><?php 
            _e('User Badges', 'mycred');
            ?>
</h2>
	<?php 
            if (isset($_POST['mycred_badge_manual'])) {
                echo '<div class="updated"><p>Badges successfully updated.</p></div>';
            }
            ?>
	<form id="your-profile" action="" method="post">
		<?php 
            $mycred_admin->user_nav($user, 'badges');
            ?>
		<div class="clear clearfix"></div>
		<p><?php 
            _e('Here you can view the badges this user has earned and if needed, manually give or take away a badge from a user.', 'mycred');
            ?>
</p>
		<div id="badge-wrapper">
<?php 
            if (!empty($all_badges)) {
                foreach ($all_badges as $badge_id) {
                    $badge_id = absint($badge_id);
                    $earned = $level = 0;
                    $status = '<span class="not-earned">' . __('Not earned', 'mycred') . '</span>';
                    $image = get_post_meta($badge_id, 'default_image', true);
                    $requirements = mycred_get_badge_requirements($badge_id);
                    if (array_key_exists($badge_id, $users_badges)) {
                        $earned = 1;
                        $status = '<span class="earned">' . __('Earned', 'mycred') . '</span>';
                        $level = $users_badges[$badge_id];
                        $image = get_post_meta($badge_id, 'level_image' . $level, true);
                        if ($image == '') {
                            $image = get_post_meta($badge_id, 'main_image', true);
                        }
                    }
                    if ($image != '') {
                        $image = '<img src="' . $image . '" alt="" />';
                    } else {
                        $image = '<span>' . __('No image', 'mycred') . '</span>';
                    }
                    $level_select = '<input type="hidden" name="mycred_badge_manual[badges][' . $badge_id . '][level]" value="" />';
                    if (count($requirements) > 1) {
                        $level_select = '<li><select name="mycred_badge_manual[badges][' . $badge_id . '][level]">';
                        $level_select .= '<option value=""';
                        if (!$earned) {
                            $level_select .= ' selected="selected"';
                        }
                        $level_select .= '>' . __('Select a level', 'mycred') . '</option>';
                        foreach ($requirements as $l => $needs) {
                            $level_select .= '<option value="' . $l . '"';
                            if ($earned && $level == $l) {
                                $level_select .= ' selected="selected"';
                            }
                            $level_select .= '>' . __('Level', 'mycred') . ' ' . ($l + 1) . '</option>';
                        }
                        $level_select .= '</select></li>';
                    }
                    ?>
			<div class="the-badge">
				<div class="badge-image-wrap">
					<?php 
                    echo $image;
                    ?>
				</div>
				<h4><?php 
                    echo get_the_title($badge_id);
                    ?>
</h4>
				<div class="badge-status"><label><?php 
                    _e('Status', 'mycred');
                    ?>
</label><?php 
                    echo $status;
                    ?>
</div>
				<div class="badge-actions">
					<ul>
						<li><label><input type="checkbox" name="mycred_badge_manual[badges][<?php 
                    echo $badge_id;
                    ?>
][has]" <?php 
                    checked($earned, 1);
                    ?>
 value="1" /> <?php 
                    _e('Earned', 'mycred');
                    ?>
</label></li>
						<?php 
                    echo $level_select;
                    ?>
					</ul>
				</div>
			</div>
<?php 
                }
            }
            ?>
			<div class="clear clearfix"></div>
		</div>
		<input type="hidden" name="mycred_badge_manual[token]" value="<?php 
            echo wp_create_nonce('mycred-adjust-users-badge' . $user_id);
            ?>
" />
		<p><input type="submit" class="button button-primary" value="<?php 
            _e('Save Changes', 'mycred');
            ?>
" /></p>
	</form>
</div>
<?php 
        }
Example #2
0
 function mycred_plugin_start_up()
 {
     global $mycred, $mycred_types, $mycred_modules;
     $mycred = new myCRED_Settings();
     $mycred_types = mycred_get_types();
     require_once myCRED_INCLUDES_DIR . 'mycred-shortcodes.php';
     // Load Translation
     $locale = apply_filters('plugin_locale', get_locale(), 'mycred');
     load_textdomain('mycred', WP_LANG_DIR . "/mycred/mycred-{$locale}.mo");
     load_plugin_textdomain('mycred', false, dirname(plugin_basename(__FILE__)) . '/lang/');
     // Adjust the plugin links
     add_filter('plugin_action_links_mycred/mycred.php', 'mycred_plugin_links', 10, 4);
     add_filter('plugin_row_meta', 'mycred_plugin_description_links', 10, 2);
     // Lets start with Multisite
     if (is_multisite()) {
         if (!function_exists('is_plugin_active_for_network')) {
             require_once ABSPATH . '/wp-admin/includes/plugin.php';
         }
         if (is_plugin_active_for_network('mycred/mycred.php')) {
             $network = new myCRED_Network_Module();
             $network->load();
         }
     }
     // Load Settings
     require_once myCRED_MODULES_DIR . 'mycred-module-settings.php';
     foreach ($mycred_types as $type => $title) {
         $mycred_modules[$type]['settings'] = new myCRED_Settings_Module($type);
         $mycred_modules[$type]['settings']->load();
     }
     // Load only hooks that we have use of
     if (defined('JETPACK__PLUGIN_DIR')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-jetpack.php';
     }
     if (class_exists('bbPress')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-bbPress.php';
     }
     if (function_exists('invite_anyone_init')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-invite-anyone.php';
     }
     if (function_exists('wpcf7')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-contact-form7.php';
     }
     if (class_exists('BadgeOS')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-badgeOS.php';
     }
     if (function_exists('vote_poll')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-wp-polls.php';
     }
     if (function_exists('wp_favorite_posts')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-wp-favorite-posts.php';
     }
     if (function_exists('bp_em_init')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-events-manager-light.php';
     }
     if (defined('STARRATING_DEBUG')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-gd-star-rating.php';
     }
     if (defined('SFTOPICS')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-simplepress.php';
     }
     if (function_exists('bp_links_setup_root_component')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-buddypress-links.php';
     }
     if (function_exists('bpa_init') || function_exists('bpgpls_init')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-buddypress-gallery.php';
     }
     if (class_exists('GFForms')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-gravityforms.php';
     }
     if (function_exists('rtmedia_autoloader')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-buddypress-media.php';
     }
     if (function_exists('install_ShareThis')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-sharethis.php';
     }
     if (class_exists('WooCommerce')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-woocommerce.php';
     }
     // Load hooks
     require_once myCRED_MODULES_DIR . 'mycred-module-hooks.php';
     foreach ($mycred_types as $type => $title) {
         $mycred_modules[$type]['hooks'] = new myCRED_Hooks_Module($type);
         $mycred_modules[$type]['hooks']->load();
     }
     // Load log
     require_once myCRED_MODULES_DIR . 'mycred-module-log.php';
     foreach ($mycred_types as $type => $title) {
         $mycred_modules[$type]['log'] = new myCRED_Log_Module($type);
         $mycred_modules[$type]['log']->load();
     }
     // BuddyPress
     if (class_exists('BuddyPress')) {
         require_once myCRED_PLUGINS_DIR . 'mycred-hook-buddypress.php';
         require_once myCRED_MODULES_DIR . 'mycred-module-buddypress.php';
         $mycred_modules['mycred_default']['buddypress'] = new myCRED_BuddyPress_Module('mycred_default');
         $mycred_modules['mycred_default']['buddypress']->load();
     }
     // Load admin
     require_once myCRED_INCLUDES_DIR . 'mycred-admin.php';
     $admin = new myCRED_Admin();
     $admin->load();
     do_action('mycred_pre_init');
 }
Example #3
0
 function mycred_plugin_start_up()
 {
     global $mycred, $mycred_types, $mycred_modules;
     $mycred = new myCRED_Settings();
     $mycred_types = mycred_get_types();
     require_once myCRED_INCLUDES_DIR . 'mycred-shortcodes.php';
     require_once myCRED_INCLUDES_DIR . 'mycred-referrals.php';
     // Load Translation
     $locale = apply_filters('plugin_locale', get_locale(), 'mycred');
     load_textdomain('mycred', WP_LANG_DIR . "/mycred/mycred-{$locale}.mo");
     load_plugin_textdomain('mycred', false, dirname(plugin_basename(__FILE__)) . '/lang/');
     // Adjust the plugin links
     add_filter('plugin_action_links_mycred/mycred.php', 'mycred_plugin_links', 10, 4);
     add_filter('plugin_row_meta', 'mycred_plugin_description_links', 10, 2);
     // Lets start with Multisite
     if (is_multisite()) {
         if (!function_exists('is_plugin_active_for_network')) {
             require_once ABSPATH . '/wp-admin/includes/plugin.php';
         }
         if (is_plugin_active_for_network('mycred/mycred.php')) {
             $network = new myCRED_Network_Module();
             $network->load();
         }
     }
     // Load Settings
     require_once myCRED_MODULES_DIR . 'mycred-module-settings.php';
     foreach ($mycred_types as $type => $title) {
         $mycred_modules[$type]['settings'] = new myCRED_Settings_Module($type);
         $mycred_modules[$type]['settings']->load();
     }
     // Load hooks
     require_once myCRED_MODULES_DIR . 'mycred-module-hooks.php';
     foreach ($mycred_types as $type => $title) {
         $mycred_modules[$type]['hooks'] = new myCRED_Hooks_Module($type);
         $mycred_modules[$type]['hooks']->load();
     }
     // Load log
     require_once myCRED_MODULES_DIR . 'mycred-module-log.php';
     foreach ($mycred_types as $type => $title) {
         $mycred_modules[$type]['log'] = new myCRED_Log_Module($type);
         $mycred_modules[$type]['log']->load();
     }
     // BuddyPress
     if (class_exists('BuddyPress')) {
         require_once myCRED_MODULES_DIR . 'mycred-module-buddypress.php';
         $mycred_modules['mycred_default']['buddypress'] = new myCRED_BuddyPress_Module('mycred_default');
         $mycred_modules['mycred_default']['buddypress']->load();
     }
     // Load admin
     require_once myCRED_INCLUDES_DIR . 'mycred-admin.php';
     $admin = new myCRED_Admin();
     $admin->load();
     do_action('mycred_pre_init');
 }