PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.2.4
Kirki – Freeform Page Builder, Website Builder & Customizer v6.2.4
6.2.4 6.2.3 6.2.2 6.2.1 6.2.0 6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / app / Services / PageSettingsService.php
kirki / app / Services Last commit date
AppsService.php 1 month ago CollaborationCommentService.php 1 month ago CollaborationService.php 3 weeks ago CollectionItemService.php 1 week ago CollectionService.php 3 weeks ago ContentManagerTemplateBinder.php 3 weeks ago ContentManagerTemplateService.php 3 weeks ago EditorService.php 1 month ago FontService.php 1 week ago FormSubmissionService.php 1 week ago GlobalDataService.php 1 month ago MediaService.php 1 month ago PageService.php 3 weeks ago PageSettingsService.php 1 month ago PostService.php 3 weeks ago UtilityPageService.php 3 weeks ago
PageSettingsService.php
52 lines
1 <?php
2
3 namespace Kirki\App\Services;
4
5 use Kirki\App\Constants\PageMetaKeys;
6 use Kirki\App\DTO\Page\PageSettingsDTO;
7 use Kirki\App\Models\Page as PageModel;
8 use Kirki\App\Models\PostMeta;
9 use Kirki\App\Utils\PostUtil;
10
11 defined('ABSPATH') || exit;
12
13 class PageSettingsService
14 {
15 public static function create()
16 {
17 return new static();
18 }
19
20 public function update_page_settings(PageModel $page, PageSettingsDTO $payload)
21 {
22 $data = [
23 'post_title' => $payload->page_title,
24 'post_name' => $payload->slug,
25 'post_excerpt' => $payload->page_description,
26 ];
27
28 if (!empty($payload->post_status)) {
29 $data['post_status'] = $payload->post_status;
30 }
31
32 $page = PageModel::update_post($page->ID, $data);
33
34 PostMeta::update_meta_value($page->ID, PageMetaKeys::SEO_SETTINGS, $payload->seo_settings);
35 PostMeta::update_meta_value($page->ID, PageMetaKeys::CUSTOM_CODE, $payload->custom_code);
36
37 $image_id = attachment_url_to_postid($payload->featured_image);
38
39 if ($image_id > 0) {
40 set_post_thumbnail($page->ID, $image_id);
41 } else {
42 delete_post_thumbnail($page->ID);
43 }
44
45 return $page;
46 }
47
48 public function update_page_custom_code(?array $custom_code = null)
49 {
50 return PostMeta::update_meta_value(PostUtil::get_post_id_from_url(), PageMetaKeys::CUSTOM_CODE, $custom_code);
51 }
52 }