Tribe__Events__Community__Main::getContext( string $action = null, int $tribe_id = null )
Get context for where we are.
Contents
Parameters
- $action
-
(string) (Optional) The current action.
Default value: null
- $tribe_id
-
(int) (Optional) The current post id.
Default value: null
Return
(array) The current context.
Source
File: src/Tribe/Main.php
public function getContext( $action = null, $tribe_id = null ) {
// get context from query string
if ( isset( $_GET['tribe_action'] ) )
$action = $_GET['tribe_action'];
if ( isset( $_GET['tribe_id'] ) )
$tribe_id = intval( $_GET['tribe_id'] );
$tribe_id = intval( $tribe_id );
if ( isset( $this->context ) )
return $this->context;
switch ( $action ) {
case 'edit':
$context = array(
'title' => 'Test',
'action' => $action,
);
if ( $tribe_id ) {
$post = get_post( $tribe_id );
if ( is_object( $post ) ) {
$context = array(
'title' => $this->getTitle( $action, $post->post_type ),
'action' => $action,
'post_type' => $post->post_type,
'id' => $tribe_id,
);
}
}
break;
case 'list':
$context = array(
'title' => apply_filters( 'tribe_ce_event_list_page_title', __( 'My Events', 'tribe-events-community' ) ),
'action' => $action,
'id' => null,
);
break;
case 'delete':
if ( $tribe_id )
$post = get_post( $tribe_id );
$context = array(
'title' => $this->getTitle( $action, $post->post_type ),
'post_type' => $post->post_type,
'action' => $action,
'id' => $tribe_id,
);
break;
default:
$context = array(
'title' => apply_filters( 'tribe_ce_submit_event_page_title', __( 'Submit an Event', 'tribe-events-community' ) ),
'action' => 'add',
'id' => null,
);
}
$this->context = $context;
return $context;
}
Changelog
| Version | Description |
|---|---|
| 1.0 | Introduced. |