PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / bulk-editor / domain / updates / post-update.php

post-update.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/bulk-editor/domain/updates/post-update.php

117 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
4 namespace Yoast\WP\SEO\Bulk_Editor\Domain\Updates;
5
6 /**
7 * This class describes a title, description and/or focus keyphrase update for a single post.
8 */
9 class Post_Update {
10
11 /**
12 * The ID of the post to update.
13 *
14 * @var int
15 */
16 private $post_id;
17
18 /**
19 * The new title, or null when the title should be left untouched.
20 *
21 * @var string|null
22 */
23 private $title;
24
25 /**
26 * The new description, or null when the description should be left untouched.
27 *
28 * @var string|null
29 */
30 private $description;
31
32 /**
33 * The new focus keyphrase, or null when the focus keyphrase should be left untouched.
34 *
35 * @var string|null
36 */
37 private $focus_keyphrase;
38
39 /**
40 * The constructor.
41 *
42 * @param int $post_id The ID of the post to update.
43 * @param string|null $title The new title, or null to leave the title untouched.
44 * @param string|null $description The new description, or null to leave the description untouched.
45 * @param string|null $focus_keyphrase The new focus keyphrase, or null to leave the focus keyphrase untouched.
46 */
47 public function __construct( int $post_id, ?string $title, ?string $description, ?string $focus_keyphrase ) {
48 $this->post_id = $post_id;
49 $this->title = $title;
50 $this->description = $description;
51 $this->focus_keyphrase = $focus_keyphrase;
52 }
53
54 /**
55 * Gets the ID of the post to update.
56 *
57 * @return int The ID of the post to update.
58 */
59 public function get_post_id(): int {
60 return $this->post_id;
61 }
62
63 /**
64 * Gets the new title.
65 *
66 * @return string|null The new title, or null when the title should be left untouched.
67 */
68 public function get_title(): ?string {
69 return $this->title;
70 }
71
72 /**
73 * Gets the new description.
74 *
75 * @return string|null The new description, or null when the description should be left untouched.
76 */
77 public function get_description(): ?string {
78 return $this->description;
79 }
80
81 /**
82 * Gets the new focus keyphrase.
83 *
84 * @return string|null The new focus keyphrase, or null when the focus keyphrase should be left untouched.
85 */
86 public function get_focus_keyphrase(): ?string {
87 return $this->focus_keyphrase;
88 }
89
90 /**
91 * Whether this update carries a title. An empty string is a value: it clears the title.
92 *
93 * @return bool Whether this update carries a title.
94 */
95 public function has_title(): bool {
96 return $this->title !== null;
97 }
98
99 /**
100 * Whether this update carries a description. An empty string is a value: it clears the description.
101 *
102 * @return bool Whether this update carries a description.
103 */
104 public function has_description(): bool {
105 return $this->description !== null;
106 }
107
108 /**
109 * Whether this update carries a focus keyphrase. An empty string is a value: it clears the focus keyphrase.
110 *
111 * @return bool Whether this update carries a focus keyphrase.
112 */
113 public function has_focus_keyphrase(): bool {
114 return $this->focus_keyphrase !== null;
115 }
116 }
117