Advertisement
Guest User

Cubepoints Buddypress Translation Fix Attempt 1

a guest
Jun 18th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.89 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * BUDDYPRESS CUBEPOINTS CORE
  5.  * Handles the overall operations of the plugin
  6.  *
  7.  * @version 0.1.9.7
  8.  * @since 1.0
  9.  * @package BuddyPress CubePoints
  10.  * @subpackage Main
  11.  * @license GPL v2.0
  12.  * @link http://wordpress.org/extend/plugins/cubepoints-buddypress-integration/
  13.  *
  14.  * ========================================================================================================
  15.  */
  16.  
  17. // Love, The BuddyPress-Media Team ... ;) *** Ahh, thanks ;)
  18. // ------------------------------------------------
  19.  
  20. define ( 'BP_CUBEPOINT_IS_INSTALLED', 1 );
  21. define ( 'BP_CUBEPOINT_DB_VERSION', '1.9.7' );
  22.  
  23. load_plugin_textdomain('cp_buddypress', false, basename( dirname( __FILE__ ) ) . '/languages' );
  24.  
  25. // require ( dirname( __FILE__ ) . '/bp-cubepoint-classes.php' ); // This not being used at the moment. Maybe later..
  26. require ( dirname( __FILE__ ) . '/bp-cubepoint-screens.php' );
  27. require ( dirname( __FILE__ ) . '/bp-cubepoint-cssjs.php' );
  28. // require ( dirname( __FILE__ ) . '/bp-cubepoint-templatetags.php' ); // This not being used at the moment. Maybe later..
  29. require ( dirname( __FILE__ ) . '/bp-cubepoint-functions.php' );
  30. require ( dirname( __FILE__ ) . '/bp-cubepoint-filters.php' );
  31.  
  32.  
  33. /**
  34.  * bp_cubepoint_setup_globals()
  35.  *
  36.  * Sets up BuddyPress CubePoint's global variables.
  37.  *
  38.  *  @version 1.9.7
  39.  *  @since 1.0
  40.  */
  41. function bp_cubepoint_setup_globals() {
  42.    
  43.     global $bp, $wpdb;
  44.  
  45.     $bp->cubepoint->id = 'cubepoint';
  46.     $bp->cubepoint->table_name = $wpdb->base_prefix . 'cubepoints';
  47.     $bp->cubepoint->table_name = $wpdb->prefix . 'cubepoints';
  48.  
  49.     $bp->cubepoint->slug = get_option( 'bp_slug_cp_bp' );
  50.    
  51.     $bp->cubepoint->points_slug = 'points';
  52.     $bp->cubepoint->table_slug = 'table';
  53.     $bp->cubepoint->earnpoints_slug = 'earnpoints';
  54.     $bp->cubepoint->awards_slug = 'awards';
  55.     $bp->cubepoint->bp_cubepoint_per_page = get_option('bp_points_logs_per_page_cp_bp');
  56.    
  57. }
  58. add_action( 'bp_setup_globals', 'bp_cubepoint_setup_globals', 2 );
  59. add_action( 'bp_setup_admin_bar', 'bp_cubepoint_setup_globals', 2 );
  60.  
  61.  
  62. /**
  63.  * bp_cubepoint_add_admin_menu()
  64.  *
  65.  * Adds the BuddyPress CubePoints admin menu to the wordpress "Site" admin menu
  66.  *
  67.  *  @version 1.9.7
  68.  *  @since 1.0
  69.  */
  70. function bp_cubepoint_add_admin_menu() {
  71.  
  72.     global $bp;
  73.  
  74.     if ( !$bp->loggedin_user->is_super_admin ){
  75.        
  76.         return false;
  77.     }
  78.  
  79.     require_once('bp-cubepoint-admin.php');
  80.  
  81.     add_submenu_page('cp_admin_manage', 'Buddypress Integration - ' .__('CubePoints','cp'), __('BuddyPress','cp'), 8, 'cubebp-settings', 'cubebp_admin');
  82.    
  83. }
  84. add_action( 'admin_menu', 'bp_cubepoint_add_admin_menu' );
  85. add_action( 'network_admin_menu', 'bp_cubepoint_add_admin_menu' );
  86.  
  87.  
  88. /**
  89.  * bp_cubepoint_setup_nav()
  90.  *
  91.  * Sets up the user profile navigation items for the component. This adds the top level nav
  92.  * item and all the sub level nav items to the navigation array. This is then
  93.  * rendered in the template.
  94.  *
  95.  *  @version 1.9.7
  96.  *  @since 1.0
  97.  */
  98. function bp_cubepoint_setup_nav() {
  99.    
  100.     global $bp;
  101.     $cb_bp_sitewidemtitle = get_option('bp_sitewidemtitle_cp_bp');
  102.     $cb_bp_earnpointtitle = get_option('bp_earnpoints_menutitle_cp_bp');
  103.     $cb_bp_awardstitle = get_option('bp_awards_menutitle_cp_bp');
  104.  
  105.     if($bp->displayed_user->id){
  106.  
  107.         $cubepoint_link = $bp->displayed_user->domain . $bp->cubepoint->slug . '/';
  108.         $cubepoint_link_title = bp_word_or_name( __( "My Points", 'bp-cubepoint' ), __( "%s's points", 'bp-cubepoint' ) ,false,false);
  109.     }
  110.     else {
  111.         $cubepoint_link = $bp->loggedin_user->domain . $bp->cubepoint->slug . '/';
  112.         $cubepoint_link_title = __( "My Points", 'bp-cubepoint' );
  113.     }
  114.  
  115.  
  116.     // Add 'Points' to the main user profile navigation
  117.     bp_core_new_nav_item( array(
  118.         'name' => __( 'Points', 'bp-cubepoint' ),
  119.         'slug' => $bp->cubepoint->slug,
  120.         'position' => 80,
  121.         'screen_function' => 'bp_cubepoint_screen_points',
  122.         'default_subnav_slug' => $bp->cubepoint->points_slug,
  123.     ) );
  124.        
  125.     bp_core_new_subnav_item( array(
  126.         'name' => $cubepoint_link_title,
  127.         'slug' => $bp->cubepoint->points_slug,
  128.         'parent_slug' => $bp->cubepoint->slug,
  129.         'parent_url' => $cubepoint_link,
  130.         'screen_function' => 'bp_cubepoint_screen_points',
  131.         'position' => 10
  132.     ) );
  133.  
  134.     if(get_option('bp_sitewide_menu_cp_bp')) {
  135.  
  136.         bp_core_new_subnav_item( array(
  137.             'name' => __( $cb_bp_sitewidemtitle, 'bp-cubepoint' ),
  138.             'slug' => $bp->cubepoint->table_slug,
  139.             'parent_slug' => $bp->cubepoint->slug,
  140.             'parent_url' => $cubepoint_link,
  141.             'screen_function' => 'bp_cubepoint_screen_table',
  142.             'position' => 30,
  143.         ) );
  144.     }
  145.    
  146.     if(get_option('bp_earnpoints_menu_cp_bp')) {
  147.  
  148.         bp_core_new_subnav_item( array(
  149.             'name' => __( $cb_bp_earnpointtitle, 'bp-cubepoint' ),
  150.             'slug' => $bp->cubepoint->earnpoints_slug,
  151.             'parent_slug' => $bp->cubepoint->slug,
  152.             'parent_url' => $cubepoint_link,
  153.             'screen_function' => 'bp_cubepoint_screen_earnpoints',
  154.             'position' => 50,
  155.         ) );
  156.     }
  157.    
  158.     if(get_option('bp_awards_menu_onoff_cp_bp')) {
  159.  
  160.         bp_core_new_subnav_item( array(
  161.             'name' => __( $cb_bp_awardstitle, 'bp-cubepoint' ),
  162.             'slug' => $bp->cubepoint->awards_slug,
  163.             'parent_slug' => $bp->cubepoint->slug,
  164.             'parent_url' => $cubepoint_link,
  165.             'screen_function' => 'bp_cubepoint_screen_awards',
  166.             'position' => 70,
  167.         ) );   
  168.     }
  169.        
  170. }
  171. add_action( 'bp_setup_nav', 'bp_cubepoint_setup_nav', 2 );
  172. add_action( 'bp_setup_admin_bar', 'bp_cubepoint_setup_nav', 2 );
  173.  
  174.  
  175. /**
  176.  * bp_cubepoint_load_template_filter()
  177.  *
  178.  * You can define a custom load template filter for your component. This will allow
  179.  * you to store and load template files from your plugin directory.
  180.  *
  181.  * @version 1.9.7
  182.  * @since 1.0
  183.  */
  184. function bp_cubepoint_load_template_filter( $found_template, $templates ) {
  185.    
  186.     global $bp;
  187.  
  188.     if( $bp->current_component != $bp->cubepoint->slug ){
  189.  
  190.         return $found_template;
  191.     }
  192.  
  193.     foreach( (array) $templates as $template ) {
  194.  
  195.         if ( file_exists( STYLESHEETPATH . '/' . $template ) ){
  196.  
  197.             $filtered_templates[] = STYLESHEETPATH . '/' . $template;
  198.         }
  199.         elseif( file_exists( TEMPLATEPATH . '/' . $template ) ){
  200.  
  201.             $filtered_templates[] = TEMPLATEPATH . '/' . $template;
  202.         }
  203.         else {
  204.             $filtered_templates[] = dirname( __FILE__ ) . '/templates/' . $template;
  205.         }
  206.  
  207.     }
  208.  
  209.     $found_template = $filtered_templates[0];
  210.  
  211.     return apply_filters( 'bp_cubepoint_load_template_filter', $found_template );
  212.    
  213. }
  214. add_filter( 'bp_located_template', 'bp_cubepoint_load_template_filter', 10, 2 );
  215.  
  216.  
  217. /**
  218.  * bp_cubepoint_load_subtemplate()
  219.  *
  220.  * @version 1.9.7
  221.  * @since 1.0
  222.  */
  223. function bp_cubepoint_load_subtemplate( $template_name ) {
  224.  
  225.     if ( file_exists(STYLESHEETPATH . '/' . $template_name . '.php')) {
  226.  
  227.         $located = STYLESHEETPATH . '/' . $template_name . '.php';
  228.     }
  229.     else if ( file_exists(TEMPLATEPATH . '/' . $template_name . '.php') ) {
  230.  
  231.         $located = TEMPLATEPATH . '/' . $template_name . '.php';
  232.     }
  233.     else{
  234.         $located = dirname( __FILE__ ) . '/templates/' . $template_name . '.php';
  235.     }
  236.  
  237.     include ($located);
  238.    
  239. }
  240. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement