PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.2.5
Kirki – Freeform Page Builder, Website Builder & Customizer v6.2.5
6.3.0 6.2.5 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 / EditorService.php
kirki / app / Services Last commit date
AppsService.php 1 month ago CollaborationCommentService.php 1 month ago CollaborationService.php 1 month ago CollectionItemService.php 3 weeks ago CollectionService.php 1 month ago ContentManagerTemplateBinder.php 1 month ago ContentManagerTemplateService.php 1 month ago EditorService.php 1 month ago FontService.php 2 weeks ago FormSubmissionService.php 1 week ago GlobalDataService.php 1 month ago MediaService.php 1 month ago PageService.php 1 month ago PageSettingsService.php 1 month ago PostService.php 1 month ago UtilityPageService.php 1 month ago
EditorService.php
46 lines
1 <?php
2
3 namespace Kirki\App\Services;
4
5 use Kirki\App\Constants\PageMetaKeys;
6 use Kirki\App\Constants\PostStatus;
7 use Kirki\App\Models\Page as PageModel;
8 use Kirki\App\Models\PostMeta;
9 use Kirki\App\Supports\Canvas;
10
11 defined('ABSPATH') || exit;
12
13 class EditorService
14 {
15 public function back_to_kirki_editor(PageModel $page, ?string $new_title = null)
16 {
17 if ($page->post_status === PostStatus::AUTO_DRAFT) {
18 if (empty($new_title)) {
19 $new_title = 'Untitled';
20 }
21
22 $data = [
23 'ID' => $page->ID,
24 'post_title' => $new_title,
25 'post_name' => $new_title,
26 'post_status' => PostStatus::DRAFT,
27 ];
28
29 $page = PageModel::update_post($page->ID, $data);
30 }
31
32 PostMeta::update_meta_value($page->ID, PageMetaKeys::PAGE_TEMPLATE, Canvas::get_full_canvas_template_path());
33
34 return $page;
35 }
36
37 public function back_to_wordpress_editor(PageModel $page)
38 {
39 $is_deleted = PostMeta::query()
40 ->where('post_id', $page->ID)
41 ->where('meta_key', PageMetaKeys::EDITOR_MODE)
42 ->delete();
43
44 return !empty($is_deleted);
45 }
46 }