CollaborationComment
2 weeks ago
Collection
2 weeks ago
CollectionItem
2 weeks ago
Media
2 weeks ago
PageResource.php
2 weeks ago
PageSettingsResource.php
2 weeks ago
SymbolResource.php
2 weeks ago
PageSettingsResource.php
35 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kirki\App\Resources; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use Kirki\App\Supports\PageUrl; |
| 8 | use Kirki\Framework\Resource; |
| 9 | |
| 10 | class PageSettingsResource extends Resource |
| 11 | { |
| 12 | /** |
| 13 | * Convert the collection resource to an array. |
| 14 | * |
| 15 | * @return array The collection data as an associative array. |
| 16 | */ |
| 17 | public function to_array() |
| 18 | { |
| 19 | $page_url = PageUrl::create($this->resource); |
| 20 | |
| 21 | return [ |
| 22 | 'page_title' => $this->post_title, |
| 23 | 'slug' => $this->post_name, |
| 24 | 'page_description' => $this->post_excerpt, |
| 25 | 'post_status' => $this->post_status, |
| 26 | 'post_url' => str_replace(get_http_origin(), '', $page_url->get_page_permalink()), |
| 27 | // NB: These are sent debugging purpose, please don't remove them without being sure. |
| 28 | 'page_full_url' => $page_url->get_page_permalink(), |
| 29 | 'home_url' => $page_url->get_home_url(), |
| 30 | 'origin' => get_http_origin(), |
| 31 | 'site_url' => $page_url->get_site_url(), |
| 32 | ]; |
| 33 | } |
| 34 | } |
| 35 |