Yoast\WP\SEO\Helpers
Current_Page_Helper::get_current_post_id
Retrieves the current post id. Returns 0 if no post id is found.
Метод класса: Current_Page_Helper{}
Хуков нет.
Возвращает
int. The post id.
Использование
$Current_Page_Helper = new Current_Page_Helper(); $Current_Page_Helper->get_current_post_id(): int;
Код Current_Page_Helper::get_current_post_id() Current Page Helper::get current post id Yoast 28.9
public function get_current_post_id(): int {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are casting to an integer.
if ( isset( $_GET['post'] ) && \is_string( $_GET['post'] ) && (int) \wp_unslash( $_GET['post'] ) > 0 ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are casting to an integer, also this is a helper function.
return (int) \wp_unslash( $_GET['post'] );
}
return 0;
}