mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Formally deprecate `get_page_by_title()`. In its current form the function is unpredictable in that it may return a result that leads to a 404 error and will return different results depending on the database version/engine combination used.
It is recommended developers use `WP_Query` instead:
{{{
$query = new WP_Query(
array(
'post_type' => 'page',
'title' => 'Sample Page',
)
);
}}}
Props TimothyBlynJacobs, costdev, mukesh27, spacedmonkey, peterwilsoncc.
Fixes #57041.
git-svn-id: https://develop.svn.wordpress.org/trunk@55207 602fd350-edb4-49c9-b593-d223f7449a82
22 lines
389 B
PHP
22 lines
389 B
PHP
<?php
|
|
|
|
/**
|
|
* @group post
|
|
*
|
|
* @covers ::get_page_by_title
|
|
*/
|
|
class Tests_Post_GetPageByTitle extends WP_UnitTestCase {
|
|
|
|
/**
|
|
* Tests that `get_page_by_title()` has been deprecated.
|
|
*
|
|
* @ticket 57041
|
|
*
|
|
* @expectedDeprecated get_page_by_title
|
|
*/
|
|
public function test_get_page_by_title_should_be_deprecated() {
|
|
$this->assertNull( get_page_by_title( '#57041 Page' ) );
|
|
}
|
|
|
|
}
|