Yoast\WP\SEO\Presenters\Twitter

Site_Presenter::get_twitter_id()privateYoast 1.0

Checks if the given id is actually an id or a url and if url, distills the id from it.

Solves issues with filters returning urls and theme's/other plugins also adding a user meta twitter field which expects url rather than an id (which is what we expect).

Метод класса: Site_Presenter{}

Хуков нет.

Возвращает

Строку|true|false. Twitter ID or false if it failed to get a valid Twitter ID.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_twitter_id( $id );
$id(строка) (обязательный)
Twitter ID or url.

Код Site_Presenter::get_twitter_id() Yoast 24.0

private function get_twitter_id( $id ) {
	if ( \preg_match( '`([A-Za-z0-9_]{1,25})$`', $id, $match ) ) {
		return $match[1];
	}

	return false;
}