Advertisement
Guest User

Plugin's Code

a guest
Nov 27th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: TCH BP Posts On Profile
  4. Plugin URI: http://azchipka.thechipkahouse.com/services/technology/development/wordpress-plugins
  5. Description: Adds a tab to Buddy Press User Profile displaying the posts they have published.
  6. Version: 0.1
  7. Author: Avery Z Chipka
  8. Author URI: http://azchipka.thechipkahouse.com
  9. License: GPLv2 or later
  10. */
  11. // Make sure we don't expose any info if called directly
  12.  
  13. if ( !function_exists( 'add_action' ) ) {
  14.         echo '404';
  15.         exit;
  16. }
  17. define('TCH_PostsOnProfilesVersion', '0.1');
  18. define('TCH_PostsOnProfilesVersion_PLUGIN_URL', plugin_dir_url( __FILE__ ));
  19.  
  20. function my_setup_nav() {
  21.           if (!user_can(bp_displayed_user_id(), 'edit_posts')) return false;
  22.       global $bp;
  23.  
  24.       bp_core_new_nav_item( array(
  25.         'name' => __( 'Articles', 'buddypress' ),
  26.         'slug' => 'articles',
  27.         'position' => 75,
  28.         'screen_function' => 'my_posts_hooks',
  29.             'show_for_displayed_user' => true,
  30.             'default_subnav_slug' => 'articles',
  31.             'item_css_id' => 'articles'
  32.       ) );
  33. }
  34.  
  35. add_action( 'bp_setup_nav', 'my_setup_nav', 1000 );
  36.  
  37. function my_posts_title() {
  38.         echo 'Articles';
  39. }
  40.  
  41. function my_posts_content() {
  42.                 locate_template( array( 'members/single/posts/loop-posts.php' ), true );
  43. }
  44.  
  45. function my_posts_hooks () {
  46.         add_action( 'bp_template_title', 'my_posts_title' );
  47.         add_action( 'bp_template_content', 'my_posts_content' );
  48.         bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement