コード例 #1
0
function bp_checkins_administration_menu()
{
    global $bp, $bp_checkins_manager_admin_page, $bp_checkins_logs_slug;
    if (version_compare(BP_CHECKINS_PLUGIN_VERSION, get_option('bp-checkins-version'), '>')) {
        do_action('bp_checkins_plugin_updated');
    }
    if (!$bp->loggedin_user->is_site_admin) {
        return false;
    }
    $admin_page = bp_checkins_16_new_admin();
    if ($admin_page == 'bp-general-settings.php') {
        $submenu = 'bp-general-settings';
    } else {
        $submenu = $admin_page;
    }
    $bp_checkins_manager_admin_page = add_submenu_page($submenu, __('BP Checkins Settings', 'bp-checkins'), __('BP Checkins Settings', 'bp-checkins'), 'manage_options', 'bp-checkins-admin', 'bp_checkins_settings_admin');
    if (bp_checkins_is_foursquare_ready()) {
        $bp_checkins_logs_slug = 'foursquare-logs';
        if (is_multisite()) {
            $bp_checkins_logs_page = add_submenu_page($submenu, __('Foursquare logs', 'bp-checkins'), __('Foursquare logs', 'bp-checkins'), 'manage_options', $bp_checkins_logs_slug, 'bp_checkins_fs_logs');
        } else {
            $bp_checkins_logs_page = add_management_page(__('Foursquare logs', 'bp-checkins'), __('Foursquare logs', 'bp-checkins'), 'manage_options', $bp_checkins_logs_slug, 'bp_checkins_fs_logs');
        }
    }
    add_action("load-{$bp_checkins_manager_admin_page}", 'bp_checkins_admin_css');
}
コード例 #2
0
function bp_checkins_foursquare_cron_job()
{
    if (!bp_checkins_is_foursquare_ready()) {
        return false;
    }
    $limit = @ini_get('max_execution_time');
    set_time_limit(900);
    ini_set('max_execution_time', 900);
    $checkins_cron = new Bp_Checkins_Foursquare_Import();
    $checkins_cron->wpcron_import();
    set_time_limit(intval($limit));
    ini_set('max_execution_time', intval($limit));
}
コード例 #3
0
 function setup_admin_bar()
 {
     global $bp;
     // Prevent debug notices
     $wp_admin_nav = array();
     // Menus for logged in user
     if (is_user_logged_in()) {
         // Setup the logged in user variables
         $checkins_link = trailingslashit(bp_loggedin_user_domain() . BP_CHECKINS_SLUG);
         // Add main bp checkins menu
         $wp_admin_nav[] = array('parent' => 'my-account-buddypress', 'id' => 'my-account-' . BP_CHECKINS_SLUG, 'title' => __('Checkins', 'bp-checkins'), 'href' => trailingslashit($checkins_link));
         // Add main bp checkins my places submenu
         $wp_admin_nav[] = array('parent' => 'my-account-' . BP_CHECKINS_SLUG, 'id' => 'my-account-' . BP_CHECKINS_SLUG . '-checkins', 'title' => __('My Checkins', 'bp-checkins'), 'href' => trailingslashit($checkins_link));
         // Add main bp checkins my places submenu
         $wp_admin_nav[] = array('parent' => 'my-account-' . BP_CHECKINS_SLUG, 'id' => 'my-account-' . BP_CHECKINS_SLUG . '-places', 'title' => __('My Places', 'bp-checkins'), 'href' => trailingslashit($checkins_link . 'places-area'));
         if (bp_checkins_is_foursquare_ready() && bp_is_active('settings')) {
             if (!function_exists('bp_get_settings_slug')) {
                 return;
             }
             // Add bp checkins settings submenu
             $wp_admin_nav[] = array('parent' => 'my-account-settings-default', 'id' => 'my-account-settings-' . BP_CHECKINS_SLUG . '-foursquare', 'title' => __('Checkins', 'bp-checkins'), 'href' => trailingslashit(bp_loggedin_user_domain() . bp_get_settings_slug() . '/checkins-settings'));
         }
     }
     parent::setup_admin_bar($wp_admin_nav);
 }
コード例 #4
0
function bp_checkins_foursquare_user_actions()
{
    global $bp;
    if (!bp_checkins_is_foursquare_ready()) {
        return;
    }
    if (bp_is_current_component('checkins') && !bp_displayed_user_id() && !bp_current_action() && !empty($_GET['code'])) {
        $referer = trailingslashit(bp_loggedin_user_domain() . bp_get_settings_slug()) . 'checkins-settings';
        $foursquare_auth_user = new Bp_Checkins_Foursquare_Oauth();
        $foursquare_user = $foursquare_auth_user->token_url($_GET['code']);
        if ($foursquare_user['type'] == 'error') {
            bp_core_add_message($foursquare_user['message'], 'error');
        } else {
            update_user_meta($bp->loggedin_user->id, 'foursquare_latest_timestamp', current_time('timestamp'));
            bp_core_add_message($foursquare_user['message']);
        }
        bp_core_redirect($referer);
    }
    if (bp_is_settings_component() && bp_displayed_user_id() && 'checkins-settings' == bp_current_action() && !empty($_GET['update'])) {
        $referer = trailingslashit(bp_loggedin_user_domain() . bp_get_settings_slug()) . 'checkins-settings';
        if ((int) bp_get_option('foursquare-user-import')) {
            return false;
        }
        $user_import = new Bp_Checkins_Foursquare_Import($bp->loggedin_user->id);
        $user_import_do = $user_import->user_import();
        if ($user_import_do['type'] == 'error') {
            bp_core_add_message($user_import_do['message'], 'error');
        } else {
            bp_core_add_message($user_import_do['message']);
        }
        bp_core_redirect($referer);
    }
}
コード例 #5
0
/** to add type of activities to the 1.6 new admin screen select box */
function bp_checkins_activity_actions()
{
    global $bp;
    // Bail if activity is not active
    if (!bp_is_active('activity')) {
        return false;
    }
    bp_activity_set_action($bp->checkins->id, 'activity_checkin', __('Activity checkins', 'bp-checkins'));
    bp_activity_set_action($bp->checkins->id, 'place_checkin', __('Place checkins', 'bp-checkins'));
    if (bp_checkins_is_foursquare_ready()) {
        bp_activity_set_action($bp->checkins->id, 'foursquare_checkin', __('Foursquare checkins', 'bp-checkins'));
    }
    bp_activity_set_action($bp->checkins->id, 'new_place', __('All places', 'bp-checkins'));
    bp_activity_set_action($bp->checkins->id, 'place_comment', __('Place comments', 'bp-checkins'));
    do_action('bp_checkins_activity_actions');
}