/** * Loads our JS and markup on a user's BP settings page. */ function mexp_gdrive_bp_settings_loader() { if (false === bp_is_user_settings_general()) { return; } // load our needed JS add_action('wp_enqueue_scripts', array(Media_Explorer::init()->services['gdrive'], 'enqueue_statics')); // add markup on "Settings > General" page add_action('bp_core_general_settings_after_submit', 'mexp_gdrive_bp_user_settings_content', 0); }
/** * Enqueue the required JavaScript files * * @since BuddyPress (1.7) */ public function enqueue_scripts() { $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; // Locate the BP JS file $asset = $this->locate_asset_in_stack("buddypress{$min}.js", 'js'); // Enqueue the global JS, if found - AJAX will not work // without it if (isset($asset['location'], $asset['handle'])) { wp_enqueue_script($asset['handle'], $asset['location'], bp_core_get_js_dependencies(), $this->version); } /** * Filters core JavaScript strings for internationalization before AJAX usage. * * @since BuddyPress (2.0.0) * * @param array $value Array of key/value pairs for AJAX usage. */ $params = apply_filters('bp_core_get_js_strings', array('accepted' => __('Accepted', 'buddypress'), 'close' => __('Close', 'buddypress'), 'comments' => __('comments', 'buddypress'), 'leave_group_confirm' => __('Are you sure you want to leave this group?', 'buddypress'), 'mark_as_fav' => __('Favorite', 'buddypress'), 'my_favs' => __('My Favorites', 'buddypress'), 'rejected' => __('Rejected', 'buddypress'), 'remove_fav' => __('Remove Favorite', 'buddypress'), 'show_all' => __('Show all', 'buddypress'), 'show_all_comments' => __('Show all comments for this thread', 'buddypress'), 'show_x_comments' => __('Show all %d comments', 'buddypress'), 'unsaved_changes' => __('Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress'), 'view' => __('View', 'buddypress'))); wp_localize_script($asset['handle'], 'BP_DTheme', $params); // Maybe enqueue comment reply JS if (is_singular() && bp_is_blog_page() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } // Maybe enqueue password verify JS (register page or user settings page) if (bp_is_register_page() || function_exists('bp_is_user_settings_general') && bp_is_user_settings_general()) { // Locate the Register Page JS file $asset = $this->locate_asset_in_stack("password-verify{$min}.js", 'js', 'bp-legacy-password-verify'); $dependencies = array_merge(bp_core_get_js_dependencies(), array('password-strength-meter')); // Enqueue script wp_enqueue_script($asset['handle'] . '-password-verify', $asset['location'], $dependencies, $this->version); } // Star private messages if (bp_is_active('messages', 'star') && bp_is_user_messages()) { wp_localize_script($asset['handle'], 'BP_PM_Star', array('strings' => array('text_unstar' => __('Unstar', 'buddypress'), 'text_star' => __('Star', 'buddypress'), 'title_unstar' => __('Starred', 'buddypress'), 'title_star' => __('Not starred', 'buddypress'), 'title_unstar_thread' => __('Remove all starred messages in this thread', 'buddypress'), 'title_star_thread' => __('Star the first message in this thread', 'buddypress')), 'is_single_thread' => (int) bp_is_messages_conversation(), 'star_counter' => 0, 'unstar_counter' => 0)); } }
function test_member_settings() { $this->go_to(bp_core_get_user_domain(bp_loggedin_user_id()) . bp_get_settings_slug()); $this->assertTrue(bp_is_user_settings_general()); }
/** * Enqueue the required Javascript files * * @since BuddyPress (1.7) */ public function enqueue_scripts() { $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; // Locate the BP JS file $asset = $this->locate_asset_in_stack("buddypress{$min}.js", 'js'); // Enqueue the global JS, if found - AJAX will not work // without it if (isset($asset['location'], $asset['handle'])) { wp_enqueue_script($asset['handle'], $asset['location'], bp_core_get_js_dependencies(), $this->version); } // Add words that we need to use in JS to the end of the page // so they can be translated and still used. $params = apply_filters('bp_core_get_js_strings', array('accepted' => __('Accepted', 'buddypress'), 'close' => __('Close', 'buddypress'), 'comments' => __('comments', 'buddypress'), 'leave_group_confirm' => __('Are you sure you want to leave this group?', 'buddypress'), 'mark_as_fav' => __('Favorite', 'buddypress'), 'my_favs' => __('My Favorites', 'buddypress'), 'rejected' => __('Rejected', 'buddypress'), 'remove_fav' => __('Remove Favorite', 'buddypress'), 'show_all' => __('Show all', 'buddypress'), 'show_all_comments' => __('Show all comments for this thread', 'buddypress'), 'show_x_comments' => __('Show all %d comments', 'buddypress'), 'unsaved_changes' => __('Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress'), 'view' => __('View', 'buddypress'))); wp_localize_script($asset['handle'], 'BP_DTheme', $params); // Maybe enqueue comment reply JS if (is_singular() && bp_is_blog_page() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } // Maybe enqueue password verify JS (register page or user settings page) if (bp_is_register_page() || function_exists('bp_is_user_settings_general') && bp_is_user_settings_general()) { // Locate the Register Page JS file $asset = $this->locate_asset_in_stack("password-verify{$min}.js", 'js'); $dependencies = array_merge(bp_core_get_js_dependencies(), array('password-strength-meter')); // Enqueue script wp_enqueue_script($asset['handle'] . '-password-verify', $asset['location'], $dependencies, $this->version); } }