Page_API::get_local_id_in_admin( int $post_id )
Get the Facebook Page id in the WordPress admin.
Contents
Parameters
- $post_id
-
(int) (Required) The optional post id.
Return
(string) The page id or empty string if not found.
Source
File: src/Tribe/Meetings/Facebook/Page_API.php
public function get_local_id_in_admin( $post_id = 0 ) {
// If there is a post id, check if it is a post and if so use to get the page id.
$post = $post_id ? get_post( $post_id ) : '';
if ( $post instanceof \WP_Post ) {
return get_post_meta( $post_id, $this->page_local_id_meta_field_name, true );
}
// Attempt to load through ajax requested variables.
$nonce = tribe_get_request_var( '_ajax_nonce' );
$page_id = tribe_get_request_var( 'page_id' );
$requested_post_id = tribe_get_request_var( 'post_id' );
if ( $page_id && $requested_post_id && $nonce ) {
// Verify the nonce is valid.
$valid_nonce = $this->is_valid_nonce( $nonce );
if ( ! $valid_nonce ) {
return '';
}
// Verify there is a real post.
$post = get_post( $post_id );
if ( $post instanceof \WP_Post ) {
return esc_html( $page_id );
}
}
// Safety check.
if ( ! function_exists( 'get_current_screen' ) ) {
return '';
}
// Set the ID if on the single event editor.
if ( ! $post_id ) {
$screen = get_current_screen();
if ( ! empty( $screen->id ) && $screen->id == TEC::POSTTYPE ) {
global $post;
$post_id = $post->ID;
}
}
if ( ! $post_id ) {
return '';
}
return esc_html( get_post_meta( $post_id, $this->page_local_id_meta_field_name, true ) );
}
Changelog
| Version | Description |
|---|---|
| 1.7.0 | Introduced. |