Tribe__Admin__Help_Page::remove_section( string|int $section_id )
Remove a section based on the ID This method will remove any sections that are indexed at that ID on the sections array And the sections that have a propriety of id equals to the given $section_id argument
Contents
Parameters
- $section_id
-
(string|int) (Required) You can use Numeric or String indexes to search.
Return
(bool|int) Returns false when no sections were removed and an int with the number of sections removed.
Source
File: src/Tribe/Admin/Help_Page.php
public function remove_section( $section_id ) {
if (
! isset( $this->sections[ $section_id ] ) &&
! in_array( (object) array( 'id' => $section_id ), $this->sections, true )
) {
// There are no sections to remove, so false
return false;
}
$removed = array();
foreach ( $this->sections as $id => $section ) {
if ( ! is_numeric( $id ) && ! is_numeric( $section_id ) && ! empty( $section->id ) ) {
if ( $section->id === $section_id ) {
unset( $this->sections[ $id ] );
// Mark that this section was removed
$removed[ $id ] = true;
}
} elseif ( $id === $section_id ) {
unset( $this->sections[ $section_id ] );
// Mark that this section was removed
$removed[ $id ] = true;
} else {
// Mark that this section was NOT removed
$removed[ $id ] = false;
}
}
// Count how many were removed
$total = count( array_filter( $removed ) );
// if Zero just return false
return $total === 0 ? false : $total;
}