current_action == BP_DEDICATION_SLUG || ( isset($bp->action_variables[1]) && $bp->action_variables[1] == BP_DEDICATION_SLUG )) { wp_enqueue_script('jquery-autocomplete-js', plugins_url("includes/js/jquery.autocomplete-min.js", __FILE__), array('jquery')); /* wp_enqueue_script('invite-anyone-autocomplete-js', WP_PLUGIN_URL . '/invite-anyone/group-invites/jquery.autocomplete/jquery.autocomplete-min.js', array('jquery')); wp_register_script('invite-anyone-js', WP_PLUGIN_URL . '/invite-anyone/group-invites/group-invites-js.js', array('invite-anyone-autocomplete-js')); wp_enqueue_script('invite-anyone-js'); */ } } add_action('wp_head', 'bp_dedication_add_js', 1); function bp_dedication_css() { global $bp; if ($bp->current_action == BP_DEDICATION_SLUG || ( isset($bp->action_variables[1]) && $bp->action_variables[1] == BP_DEDICATION_SLUG )) { /* $style_url = WP_PLUGIN_URL . '/invite-anyone/group-invites/group-invites-css.css'; $style_file = WP_PLUGIN_DIR . '/invite-anyone/group-invites/group-invites-css.css'; if (file_exists($style_file)) { wp_register_style('invite-anyone-group-invites-style', $style_url); wp_enqueue_style('invite-anyone-group-invites-style'); } */ } } add_action('wp_print_styles', 'bp_dedication_add_css'); class BP_Dedication extends BP_Component { /* var $enable_nav_item = true; var $enable_create_step = true; var $enable_edit_item = false; */ /** * Constructor method * * You can do all sorts of stuff in your constructor, but it's recommended that, at the * very least, you call the parent::start() function. This tells the parent BP_Component * to begin its setup routine. * * BP_Component::start() takes three parameters: * (1) $id - A unique identifier for the component. Letters, numbers, and underscores * only. * (2) $name - This is a translatable name for your component, which will be used in * various places through the BuddyPress admin screens to identify it. * (3) $path - The path to your plugin directory. Primarily, this is used by * BP_Component::includes(), to include your plugin's files. See loader.php * to see how BP_EXAMPLE_PLUGIN_DIR was defined. * * @package BuddyPress_Skeleton_Component * @since 1.6 */ function __construct() { global $bp; parent::start( BP_DEDICATION_SLUG, __('Dedications', 'bp-dedication'), BP_DEDICATION_PLUGIN_DIR ); $this->includes(); /** * Put your component into the active components array, so that * bp_is_active( 'example' ); * returns true when appropriate. We have to do this manually, because non-core * components are not saved as active components in the database. */ $bp->active_components[$this->id] = '1'; /** * Hook the register_post_types() method. If you're using custom post types to store * data (which is recommended), you will need to hook your function manually to * 'init'. */ //add_action( 'init', array( &$this, 'register_post_types' ) ); } function includes() { // Files to include $includes = array( 'includes/create-dedication.php', 'includes/bp-dedication-screens.php', 'includes/bp-dedication-activity.php', 'includes/bp-example-functions.php', /* 'includes/bp-example-filters.php', 'includes/bp-example-classes.php', 'includes/bp-example-template.php', 'includes/bp-example-notifications.php', 'includes/bp-example-widgets.php', 'includes/bp-example-cssjs.php', 'includes/bp-example-ajax.php' */ ); parent::includes($includes); /* if ( is_admin() || is_network_admin() ) { include( BP_EXAMPLE_PLUGIN_DIR . '/includes/bp-example-admin.php' ); } */ } function setup_nav() { $main_nav = array( 'name' => __('Dedications', 'bp-dedication'), 'slug' => bp_get_dedication_slug(), 'position' => 80, 'screen_function' => 'bp_dedication_my_dedications', 'default_subnav_slug' => 'my-dedications' ); $dedication_link = trailingslashit(bp_loggedin_user_domain() . bp_get_dedication_slug()); // Add a few subnav items under the main Example tab $sub_nav[] = array( 'name' => __('My dedications', 'bp-dedication'), 'slug' => 'my-dedications', 'parent_url' => $dedication_link, 'parent_slug' => bp_get_dedication_slug(), 'screen_function' => 'bp_dedication_my_dedications', 'position' => 10 ); // Add the subnav items to the friends nav item $sub_nav[] = array( 'name' => __('Dedicated 2u', 'bp-dedication'), 'slug' => 'dedicated-2u', 'parent_url' => $dedication_link, 'parent_slug' => bp_get_dedication_slug(), 'screen_function' => 'bp_dedication_dedications_to_me', 'position' => 20 ); // Add the subnav items to the friends nav item $sub_nav[] = array( 'name' => __('New dedication', 'bp-dedication'), 'slug' => 'new-dedication', 'parent_url' => $dedication_link, 'parent_slug' => bp_get_dedication_slug(), 'screen_function' => 'bp_dedication_new_dedication', 'position' => 30 ); parent::setup_nav($main_nav, $sub_nav); //parent::setup_nav( $main_nav ); // If your component needs additional navigation menus that are not handled by // BP_Component::setup_nav(), you can register them manually here. For example, // if your component needs a subsection under a user's Settings menu, add // it like this. See bp_example_screen_settings_menu() for more info /* bp_core_new_subnav_item( array( 'name' => __( 'Example', 'bp-example' ), 'slug' => 'example-admin', 'parent_slug' => bp_get_settings_slug(), 'parent_url' => trailingslashit( bp_loggedin_user_domain() . bp_get_settings_slug() ), 'screen_function' => 'bp_example_screen_settings_menu', 'position' => 40, 'user_has_access' => bp_is_my_profile() // Only the logged in user can access this on his/her profile ) ); */ } } function bp_load_dedication_component() { global $bp; $bp->dedications = new BP_Dedication; } add_action('bp_loaded', 'bp_load_dedication_component'); //function bp_example_var_dump() { // global $bp; // var_dump( $bp->dedications ); // } //add_action( 'bp_init', 'bp_example_var_dump' ); /** * Extends the WP_User_Query class to make it easier for us to search across different fields * * @package Invite Anyone * @since 1.0.4 */ class User_Dedication_Query extends WP_User_Query { function __construct($query = null) { add_action('pre_user_query', array(&$this, 'filter_registered_users_only')); parent::__construct($query); } /** * BuddyPress has different user statuses. We need to filter the user list so only registered users are shown. */ function filter_registered_users_only($query) { $query->query_where .= ' AND user_status = 0'; } /** * @see WP_User_Query::get_search_sql() */ function get_search_sql($string, $cols, $wild = false) { $string = esc_sql($string); // Always search all columns $cols = array( 'user_email', 'user_login', 'user_nicename', 'user_url', 'display_name' ); // Always do 'both' for trailing_wild $wild = 'both'; $searches = array(); $leading_wild = ( 'leading' == $wild || 'both' == $wild ) ? '%' : ''; $trailing_wild = ( 'trailing' == $wild || 'both' == $wild ) ? '%' : ''; foreach ($cols as $col) { if ('ID' == $col) $searches[] = "$col = '$string'"; else $searches[] = "$col LIKE '$leading_wild" . like_escape($string) . "$trailing_wild'"; } return ' AND (' . implode(' OR ', $searches) . ') AND user_status = 0'; } } ?>