| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | require_once dirname(__FILE__) . '/../wp-config.php'; |
|---|
| 4 | |
|---|
| 5 | if (!defined('ENABLE_CACHE')) define('ENABLE_CACHE', true); |
|---|
| 6 | if (defined('DISABLE_CACHE')) { |
|---|
| 7 | echo 'oops, `DISABLE_CACHE\' is defined.'; |
|---|
| 8 | exit -1; |
|---|
| 9 | } |
|---|
| 10 | |
|---|
| 11 | add_filter('get_pages', 'test_sort_pages', 99, 2); |
|---|
| 12 | |
|---|
| 13 | function test_sort_pages($pages, $r) |
|---|
| 14 | { |
|---|
| 15 | krsort($pages); |
|---|
| 16 | return $pages; |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | function test_get_pages_cache() |
|---|
| 20 | { |
|---|
| 21 | wp_cache_delete('get_pages', 'page'); |
|---|
| 22 | for ($i = 0; $i < 3; ++$i) { |
|---|
| 23 | printf("[loop %d : %s]\n", $i + 1, $i ? 'cached' : 'not cached'); |
|---|
| 24 | foreach (get_pages('hierarchical=1') as $page) { // hierarchical |
|---|
| 25 | printf("%02d %s\n", $page->ID, $page->post_title); |
|---|
| 26 | } |
|---|
| 27 | } |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | test_get_pages_cache(); |
|---|