Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Add Post Types and Taxonomies #6

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

ronalfy
Copy link
Collaborator

@ronalfy ronalfy commented Sep 30, 2021

Resolves #5

This PR does the following:

  1. Disables Theme Post Types (if installed)
  2. Adds Post Types
  3. Add Taxonomies
  4. Adds Posts to Posts integration
  5. Adds rewrite rules

@ronalfy ronalfy added the ➕ Enhancement New feature or request label Sep 30, 2021
@ronalfy ronalfy added this to the Milestone 1 (Alpha) milestone Sep 30, 2021
@ronalfy ronalfy requested a review from sc0ttkclark September 30, 2021 14:52
break;
}

return '<p class="status ' . $status . '" id="status-label">' . $label . '</p>';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return '<p class="status ' . $status . '" id="status-label">' . $label . '</p>';
return '<p class="status ' . esc_attr( $status ) . '" id="status-label">' . $label . '</p>';

* Default false.
* @return WP_Post|null WP_Post object for the Explanation, null otherwise.
*/
function get_explanation( $post, $published = false ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in the class

return;
}

$explanation = get_explanation( $post );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should call our get_explanation()?

}

// Proceed only if there's an explanation for the current reference post type.
if ( ! empty( $screen->post_type ) && $explanation = get_explanation( $screen ) ) { // phpcs:ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should call our get_explanation()?

return $actions;
}

$expl = \DevHub\get_explanation( $post );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should call our get_explanation()?

* @param int|WP_Post $post Post ID or WP_Post object.
*/
public function status_controls( $post ) {
$explanation = DevHub\get_explanation( $post );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should call our get_explanation()?

$post_id = empty( $_REQUEST['post_id'] ) ? 0 : absint( $_REQUEST['post_id'] );
$context = empty( $_REQUEST['context'] ) ? '' : sanitize_text_field( wp_unslash( $_REQUEST['context'] ) );

if ( DevHub\get_explanation( $post_id ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should call our get_explanation()?


$post_id = empty( $_REQUEST['post_id'] ) ? 0 : absint( $_REQUEST['post_id'] );

if ( $explanation = get_explanation( $post_id ) ) { // phpcs:ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should call our get_explanation()?

*/
public function handle_column_data( $column_name, $post_id ) {
if ( 'has_explanation' === $column_name ) {
if ( $explanation = get_explanation( $post_id ) ) { // phpcs:ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should call our get_explanation()?

* @see WP after_setup_theme action.
*/
public function after_setup_theme() {
// Remove post types registered by theme.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a check to see if at least $explanations is set and if the remove_action is needed here

Comment on lines +50 to +51
add_action( 'init', array( $this, 'register_post_type' ), 0 );
add_action( 'init', array( $this, 'remove_editor_support' ), 100 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run these right away and call the set up in the init with the other classes

* @see WP plugins_loaded action.
*/
public function plugins_loaded() {
new Explanations();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this into the init() and have Explanations::__construct() run it's init stuff right away or move those into a ::init() method that can get called

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that doesn't work as expected, we can bail on that path and just keep it as is

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
➕ Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Post Types and Taxonomies
2 participants