BP_Core_BP_Options_Nav_BackCompat

Bp_options_nav backward compatibility class.

Defined (1)

The class is defined in the following location(s).

/bp-core/classes/class-bp-core-bp-options-nav-backcompat.php  
  1. class BP_Core_BP_Options_Nav_BackCompat extends BP_Core_BP_Nav_BackCompat { 
  2. /** 
  3. * Parent slug of the current nav item. 
  4. * @since 2.6.0 
  5. * @access protected 
  6. * @var string 
  7. */ 
  8. protected $parent_slug = ''; 
  9.  
  10. /** 
  11. * Get a value of the nav array at the specified offset. 
  12. * @since 2.6.0 
  13. * @param mixed $offset Array offset. 
  14. * @return BP_Core_BP_Nav_BackCompat 
  15. */ 
  16. public function offsetGet( $offset ) { 
  17. _doing_it_wrong( 
  18. 'bp_nav',  
  19. __( 'These globals should not be used directly and are deprecated. Please use the BuddyPress nav functions instead.', 'buddypress' ),  
  20. '2.6.0' 
  21. ); 
  22.  
  23. if ( empty( $this->backcompat_nav[ $offset ] ) ) { 
  24. $nav = $this->get_nav( $offset ); 
  25. if ( $nav ) { 
  26. $subnavs = $this->get_component_nav( $offset )->get_secondary( array( 'parent_slug' => $offset ) ); 
  27. $subnav_keyed = array(); 
  28. if ( $subnavs ) { 
  29. foreach ( $subnavs as $subnav ) { 
  30. $subnav_keyed[ $subnav->slug ] = (array) $subnav; 
  31.  
  32. $subnav_object = new self( $subnav_keyed ); 
  33. $subnav_object->set_component( $this->get_component() ); 
  34. $subnav_object->set_parent_slug( $offset ); 
  35.  
  36. $this->backcompat_nav[ $offset ] = $subnav_object; 
  37.  
  38. if ( isset( $this->backcompat_nav[ $offset ] ) ) { 
  39. return $this->backcompat_nav[ $offset ]; 
  40.  
  41. return false; 
  42.  
  43. /** 
  44. * Unset a nav array value at the specified offset. 
  45. * @since 2.6.0 
  46. * @param mixed $offset Array offset. 
  47. */ 
  48. public function offsetUnset( $offset ) { 
  49. _doing_it_wrong( 
  50. 'bp_nav',  
  51. __( 'These globals should not be used directly and are deprecated. Please use the BuddyPress nav functions instead.', 'buddypress' ),  
  52. '2.6.0' 
  53. ); 
  54.  
  55. $this->get_component_nav( $offset )->delete_nav( $offset, $this->get_parent_slug() ); 
  56.  
  57. // Clear the cached nav. 
  58. unset( $this->backcompat_nav[ $offset ] ); 
  59.  
  60. /** 
  61. * Get the parent slug of the current nav item. 
  62. * @since 2.6.0 
  63. * @return string 
  64. */ 
  65. public function get_parent_slug() { 
  66. return $this->parent_slug; 
  67.  
  68. /** 
  69. * Set the parent slug of the current nav item. 
  70. * @since 2.6.0 
  71. */ 
  72. public function set_parent_slug( $slug ) { 
  73. $this->parent_slug = $slug; 
  74.  
  75. /** 
  76. * Get the nav object corresponding to the specified offset. 
  77. * @since 2.6.0 
  78. * @param mixed $offset Array offset. 
  79. * @return bool|array 
  80. */ 
  81. public function get_nav( $offset ) { 
  82. $nav = parent::get_nav( $offset ); 
  83.  
  84. if ( ! $nav ) { 
  85. $component_nav = $this->get_component_nav( $offset ); 
  86. $secondary_nav = $component_nav->get_secondary( array( 'slug' => $offset ), false ); 
  87.  
  88. $nav = array(); 
  89.  
  90. if ( empty( $primary_nav ) ) { 
  91. return $nav; 
  92.  
  93. foreach ( $primary_nav as $item ) { 
  94. $nav[ $item->slug ] = (array) $item; 
  95.  
  96. return $nav;