Skip to content

Commit

Permalink
register post types & expose them on REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
ashfame committed Sep 10, 2024
1 parent 771a396 commit 21646f8
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/plugin/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,67 @@

// composer autoload.
require 'vendor/autoload.php';

class LiberationEngine {
const string POST_TYPE_POST = 'liberated_post';

Check warning on line 17 in src/plugin/plugin.php

View workflow job for this annotation

GitHub Actions / phpcs

Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space
const string POST_TYPE_PAGE = 'liberated_page';

Check warning on line 18 in src/plugin/plugin.php

View workflow job for this annotation

GitHub Actions / phpcs

Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space
const string POST_TYPE_PRODUCT = 'liberated_product';

Check warning on line 19 in src/plugin/plugin.php

View workflow job for this annotation

GitHub Actions / phpcs

Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space
const string POST_TYPE_NAVIGATION = 'liberated_navigation';

public function __construct() {
add_action( 'init', array( $this, 'register_post_types' ) );
}

public function register_post_types() : void {

Check failure on line 26 in src/plugin/plugin.php

View workflow job for this annotation

GitHub Actions / phpcs

There must not be a space before the colon in a return type declaration
register_post_type(
self::POST_TYPE_POST,
array(
'public' => false,
'label' => 'Liberated Post',
'show_in_rest' => true,
'rest_base' => 'liberated_posts', // plural

Check failure on line 33 in src/plugin/plugin.php

View workflow job for this annotation

GitHub Actions / phpcs

Inline comments must end in full-stops, exclamation marks, or question marks
'show_ui' => self::is_debug_mode(),
'show_in_menu' => self::is_debug_mode(),
)
);
register_post_type(
self::POST_TYPE_PAGE,
array(
'public' => false,
'label' => 'Liberated Page',
'show_in_rest' => true,
'rest_base' => 'liberated_pages', // plural

Check failure on line 44 in src/plugin/plugin.php

View workflow job for this annotation

GitHub Actions / phpcs

Inline comments must end in full-stops, exclamation marks, or question marks
'show_ui' => self::is_debug_mode(),
'show_in_menu' => self::is_debug_mode(),
)
);
register_post_type(
self::POST_TYPE_PRODUCT,
array(
'public' => false,
'label' => 'Liberated Product',
'show_in_rest' => true,
'rest_base' => 'liberated_products', // plural

Check failure on line 55 in src/plugin/plugin.php

View workflow job for this annotation

GitHub Actions / phpcs

Inline comments must end in full-stops, exclamation marks, or question marks
'show_ui' => self::is_debug_mode(),
'show_in_menu' => self::is_debug_mode(),
)
);
register_post_type(
self::POST_TYPE_NAVIGATION,
array(
'public' => false,
'label' => 'Liberated Navigation',
'show_in_rest' => true,
'rest_base' => 'liberated_navigations', // plural

Check failure on line 66 in src/plugin/plugin.php

View workflow job for this annotation

GitHub Actions / phpcs

Inline comments must end in full-stops, exclamation marks, or question marks
'show_ui' => self::is_debug_mode(),
'show_in_menu' => self::is_debug_mode(),
)
);
}

public function is_debug_mode() : bool {

Check failure on line 73 in src/plugin/plugin.php

View workflow job for this annotation

GitHub Actions / phpcs

There must not be a space before the colon in a return type declaration
return defined( 'WP_DEBUG' ) && WP_DEBUG;
}
}

new LiberationEngine();

0 comments on commit 21646f8

Please sign in to comment.