Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(media-kit): expose method; add get_page_status method #908

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion includes/media-kit/class-media-kit.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function activate() {
*
* @return int|false Post ID or false if the media kit page was not found.
*/
private static function get_existing_page_id() {
public static function get_existing_page_id() {
$args = [
'post_type' => [ 'page' ],
'post_status' => [ 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private' ],
Expand All @@ -93,6 +93,17 @@ private static function get_existing_page_id() {
return $query->posts[0] ?? false;
}

/**
* Get Media Kit page status.
*/
public static function get_page_status() {
$post_id = self::get_existing_page_id();
if ( ! $post_id ) {
return 'non-existent';
}
return get_post_status( $post_id );
}

/**
* A function to create a Publisher Media Kit page automatically.
*
Expand Down