diff --git a/src/Posts/Post.php b/src/Posts/Post.php index 34d5282..9ff9d9e 100644 --- a/src/Posts/Post.php +++ b/src/Posts/Post.php @@ -59,7 +59,7 @@ Posts::COMMENT_STATUS->value => "closed", Posts::PING_STATUS->value => "closed", Posts::POST_PASSWORD->value => "", - Posts::POST_NAME->value => slugify($title), + Posts::POST_NAME->value => substr(slugify($title), 0, 200), Posts::TO_PING->value => "", Posts::PINGED->value => "", Posts::POST_MODIFIED->value => date(static::DATETIME_FORMAT), @@ -88,6 +88,111 @@ ); } + public int $post_author { + get => $this->get(Posts::POST_AUTHOR->value); + set (int $post_author) => $this->set(Posts::POST_AUTHOR->value, $post_author); + } + + public DateTimeImmutable $post_date { + get => new DateTimeImmutable($this->get(Posts::POST_DATE->value)); + set (DateTimeImmutable $post_date) => $this->set(Posts::POST_DATE->value, $post_date->format(static::DATETIME_FORMAT)); + } + + public DateTimeImmutable $post_date_gmt { + get => new DateTimeImmutable($this->get(Posts::POST_DATE_GMT->value)); + set (DateTimeImmutable $post_date_gmt) => $this->set(Posts::POST_DATE_GMT->value, $post_date_gmt->format(static::DATETIME_FORMAT)); + } + + public string $post_content { + get => $this->get(Posts::POST_CONTENT->value); + set (string $post_content) => $this->set(Posts::POST_CONTENT->value, $post_content); + } + + public string $post_title { + get => $this->get(Posts::POST_TITLE->value); + set (string $post_title) => $this->set(Posts::POST_TITLE->value, $post_title); + } + + public string $post_excerpt { + get => $this->get(Posts::POST_EXCERPT->value); + set (string $post_excerpt) => $this->set(Posts::POST_EXCERPT->value, $post_excerpt); + } + + public string $post_status { + get => $this->get(Posts::POST_STATUS->value); + set (string $post_status) => $this->set(Posts::POST_STATUS->value, substr($post_status, 0, 20)); + } + + public string $comment_status { + get => $this->get(Posts::COMMENT_STATUS->value); + set (string $comment_status) => $this->set(Posts::COMMENT_STATUS->value, substr($comment_status, 0, 20)); + } + + public string $ping_status { + get => $this->get(Posts::PING_STATUS->value); + set (string $ping_status) => $this->set(Posts::PING_STATUS->value, substr($ping_status, 0, 20)); + } + + public string $post_password { + get => $this->get(Posts::POST_PASSWORD->value); + set (string $post_password) => $this->set(Posts::POST_PASSWORD->value, substr($post_password, 0, 255)); + } + + public string $post_name { + get => $this->get(Posts::POST_NAME->value); + set (string $post_name) => $this->set(Posts::POST_NAME->value, substr($post_name, 0, 200)); + } + + public string $to_ping { + get => $this->get(Posts::TO_PING->value); + set (string $to_ping) => $this->set(Posts::TO_PING->value, $to_ping); + } + + public string $pinged { + get => $this->get(Posts::PINGED->value); + set (string $pinged) => $this->set(Posts::PINGED->value, $pinged); + } + + public DateTimeImmutable $post_modified { + get => new DateTimeImmutable($this->get(Posts::POST_MODIFIED->value)); + set (DateTimeImmutable $post_modified) => $this->set(Posts::POST_MODIFIED->value, $post_modified->format(static::DATETIME_FORMAT)); + } + + public DateTimeImmutable $post_modified_gmt { + get => new DateTimeImmutable($this->get(Posts::POST_MODIFIED_GMT->value)); + set (DateTimeImmutable $post_modified_gmt) => $this->set(Posts::POST_MODIFIED_GMT->value, $post_modified_gmt->format(static::DATETIME_FORMAT)); + } + + public Post|false|null $post_parent { + get => $this->get(Posts::POST_PARENT->value) !== 0 ? new self($this->get(Posts::POST_PARENT->value)) : null; + set (Post|false|null $post_parent) => $this->set(Posts::POST_PARENT->value, $post_parent ? $post_parent->id : 0); + } + + public string $guid { + get => $this->get(Posts::GUID->value); + set (string $guid) => $this->set(Posts::GUID->value, $guid); + } + + public int $menu_order { + get => $this->get(Posts::MENU_ORDER->value); + set (int $menu_order) => $this->set(Posts::MENU_ORDER->value, $menu_order); + } + + public string $post_type { + get => $this->get(Posts::POST_TYPE->value); + set (string $post_type) => $this->set(Posts::POST_TYPE->value, substr($post_type, 0, 20)); + } + + public string $post_mime_type { + get => $this->get(Posts::POST_MIME_TYPE->value); + set (string $post_mime_type) => $this->set(Posts::POST_MIME_TYPE->value, substr($post_mime_type, 0, 100)); + } + + public int $comment_count { + get => $this->get(Posts::COMMENT_COUNT->value); + set (int $comment_count) => $this->set(Posts::COMMENT_COUNT->value, $comment_count); + } + /** * Get post meta fields for this Post. An array of all post meta is returned if no $key is provided * @@ -149,109 +254,4 @@ return Attachment::from_post_featured($this); } - - public int $post_author { - get => $this->get(Posts::POST_AUTHOR->value); - set (int $post_author) => $this->set(Posts::POST_AUTHOR->value, $post_author); - } - - public DateTimeImmutable $post_date { - get => new DateTimeImmutable($this->get(Posts::POST_DATE->value)); - set (DateTimeImmutable $post_date) => $this->set(Posts::POST_DATE->value, $post_date->format(static::DATETIME_FORMAT)); - } - - public DateTimeImmutable $post_date_gmt { - get => new DateTimeImmutable($this->get(Posts::POST_DATE_GMT->value)); - set (DateTimeImmutable $post_date_gmt) => $this->set(Posts::POST_DATE_GMT->value, $post_date_gmt->format(static::DATETIME_FORMAT)); - } - - public string $post_content { - get => $this->get(Posts::POST_CONTENT->value); - set (string $post_content) => $this->set(Posts::POST_CONTENT->value, $post_content); - } - - public string $post_title { - get => $this->get(Posts::POST_TITLE->value); - set (string $post_title) => $this->set(Posts::POST_TITLE->value, $post_title); - } - - public string $post_excerpt { - get => $this->get(Posts::POST_EXCERPT->value); - set (string $post_excerpt) => $this->set(Posts::POST_EXCERPT->value, $post_excerpt); - } - - public string $post_status { - get => $this->get(Posts::POST_STATUS->value); - set (string $post_status) => $this->set(Posts::POST_STATUS->value, $post_status); - } - - public string $comment_status { - get => $this->get(Posts::COMMENT_STATUS->value); - set (string $comment_status) => $this->set(Posts::COMMENT_STATUS->value, $comment_status); - } - - public string $ping_status { - get => $this->get(Posts::PING_STATUS->value); - set (string $ping_status) => $this->set(Posts::PING_STATUS->value, $ping_status); - } - - public string $post_password { - get => $this->get(Posts::POST_PASSWORD->value); - set (string $post_password) => $this->set(Posts::POST_PASSWORD->value, $post_password); - } - - public string $post_name { - get => $this->get(Posts::POST_NAME->value); - set (string $post_name) => $this->set(Posts::POST_NAME->value, $post_name); - } - - public string $to_ping { - get => $this->get(Posts::TO_PING->value); - set (string $to_ping) => $this->set(Posts::TO_PING->value, $to_ping); - } - - public string $pinged { - get => $this->get(Posts::PINGED->value); - set (string $pinged) => $this->set(Posts::PINGED->value, $pinged); - } - - public DateTimeImmutable $post_modified { - get => new DateTimeImmutable($this->get(Posts::POST_MODIFIED->value)); - set (DateTimeImmutable $post_modified) => $this->set(Posts::POST_MODIFIED->value, $post_modified->format(static::DATETIME_FORMAT)); - } - - public DateTimeImmutable $post_modified_gmt { - get => new DateTimeImmutable($this->get(Posts::POST_MODIFIED_GMT->value)); - set (DateTimeImmutable $post_modified_gmt) => $this->set(Posts::POST_MODIFIED_GMT->value, $post_modified_gmt->format(static::DATETIME_FORMAT)); - } - - public Post|false|null $post_parent { - get => $this->get(Posts::POST_PARENT->value) !== 0 ? new self($this->get(Posts::POST_PARENT->value)) : null; - set (Post|false|null $post_parent) => $this->set(Posts::POST_PARENT->value, $post_parent ? $post_parent->id : 0); - } - - public string $guid { - get => $this->get(Posts::GUID->value); - set (string $guid) => $this->set(Posts::GUID->value, $guid); - } - - public int $menu_order { - get => $this->get(Posts::MENU_ORDER->value); - set (int $menu_order) => $this->set(Posts::MENU_ORDER->value, $menu_order); - } - - public string $post_type { - get => $this->get(Posts::POST_TYPE->value); - set (string $post_type) => $this->set(Posts::POST_TYPE->value, $post_type); - } - - public string $post_mime_type { - get => $this->get(Posts::POST_MIME_TYPE->value); - set (string $post_mime_type) => $this->set(Posts::POST_MIME_TYPE->value, $post_mime_type); - } - - public int $comment_count { - get => $this->get(Posts::COMMENT_COUNT->value); - set (int $comment_count) => $this->set(Posts::COMMENT_COUNT->value, $comment_count); - } } diff --git a/src/Posts/PostMeta.php b/src/Posts/PostMeta.php index e5c54d9..0a8ebf1 100644 --- a/src/Posts/PostMeta.php +++ b/src/Posts/PostMeta.php @@ -86,6 +86,21 @@ ); } + public Post $post { + get => new Post($this->get(PostMetaTable::POST_ID->value)); + set (Post $post) => $this->set(PostMetaTable::POST_ID->value, $post->id); + } + + public string $meta_key { + get => $this->get(PostMetaTable::META_KEY->value); + set (string $meta_key) => $this->set(PostMetaTable::META_KEY->value, substr($meta_key, 0, 255)); + } + + public ?string $meta_value { + get => $this->get(PostMetaTable::META_VALUE->value); + set (?string $meta_value) => $this->set(PostMetaTable::META_VALUE->value, $meta_value); + } + /** * Delete this post meta field from the database * @@ -96,19 +111,4 @@ ->from(Database::get_table(PostMetaTable::TABLE_NAME)) ->delete([PostMetaTable::META_ID->value => $this->id]); } - - public Post $post { - get => new Post($this->get(PostMetaTable::POST_ID->value)); - set (Post $post) => $this->set(PostMetaTable::POST_ID->value, $post->id); - } - - public string $meta_key { - get => $this->get(PostMetaTable::META_KEY->value); - set (string $meta_key) => $this->set(PostMetaTable::META_KEY->value, $meta_key); - } - - public ?string $meta_value { - get => $this->get(PostMetaTable::META_VALUE->value); - set (?string $meta_value) => $this->set(PostMetaTable::META_VALUE->value, $meta_value); - } } diff --git a/src/Posts/Taxonomy/Taxonomy.php b/src/Posts/Taxonomy/Taxonomy.php index 303dfa6..02d36c1 100644 --- a/src/Posts/Taxonomy/Taxonomy.php +++ b/src/Posts/Taxonomy/Taxonomy.php @@ -51,7 +51,7 @@ $values = [ Taxonomies::TERM_TAXONOMY_ID->value => null, Taxonomies::TERM_ID->value => $term->id, - Taxonomies::TAXONOMY->value => $taxonomy, + Taxonomies::TAXONOMY->value => substr($taxonomy, 0, 32), Taxonomies::DESCRIPTION->value => "", Taxonomies::PARENT->value => 0, Taxonomies::COUNT->value => 0 @@ -80,7 +80,7 @@ public string $taxonomy { get => $this->get(Taxonomies::TAXONOMY->value); - set (string $taxonomy) => $this->set(Taxonomies::TAXONOMY->value, $taxonomy); + set (string $taxonomy) => $this->set(Taxonomies::TAXONOMY->value, substr($taxonomy, 0, 32)); } public string $description { diff --git a/src/Posts/Taxonomy/Term.php b/src/Posts/Taxonomy/Term.php index ad30da6..097de00 100644 --- a/src/Posts/Taxonomy/Term.php +++ b/src/Posts/Taxonomy/Term.php @@ -62,8 +62,8 @@ $values = [ Terms::TERM_ID->value => null, - Terms::NAME->value => $name, - Terms::SLUG->value => $slug ? $slug : slugify($name), + Terms::NAME->value => substr($name, 0, 200), + Terms::SLUG->value => substr($slug ? $slug : slugify($name), 0, 200), Terms::TERM_GROUP->value => 0 ]; @@ -84,12 +84,12 @@ public string $name { get => $this->get(Terms::NAME->value); - set (string $name) => $this->set(Terms::NAME->value, $name); + set (string $name) => $this->set(Terms::NAME->value, substr($name, 0, 200)); } public string $slug { get => $this->get(Terms::SLUG->value); - set (string $slug) => $this->set(Terms::SLUG->value, $slug); + set (string $slug) => $this->set(Terms::SLUG->value, substr($slug, 0, 200)); } public int $term_group {