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

Added function to retrieve filterable post statuses for classification. #310

Merged
merged 4 commits into from
Sep 24, 2021

Conversation

jamesmorrison
Copy link
Member

@jamesmorrison jamesmorrison commented Sep 8, 2021

Description of the Change

Adds a filter to allow post statuses other than publish to be allowed to classify content.

Benefits

Users will be able to save content in other post statuses - e.g. draft and this content will be classified.

Possible Drawbacks

If publish is removed from the array, content will not be classified on publication.

Verification Process

I ran the following code in a MU plugin to modify the post statuses:

add_action(
	'after_setup_theme',
	function() {
		add_filter(
			'classifai_post_statuses_for_post_type_or_id',
			function( $post_statuses, $post_type, $post_id ) {
				return array(
					'publish',
					'draft',
					'future',
				);
			},
			10,
			3
		);
	}
);

The resulting data upon saving a draft post was:

{"post_statuses":["publish","draft","future"],"post_status":"draft","post_type":"post","post_id":2285}

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

#309

Changelog Entry

Added: classifai_post_statuses filter; allows post statuses for content classification to be changed as required (but would apply to all post types).

Added: classifai_post_statuses_for_post_type_or_id filter; allows post statuses for content classification to be changed as required based on post type / post ID.

@jeffpaul jeffpaul added this to the 1.8.0 milestone Sep 8, 2021
@jeffpaul jeffpaul linked an issue Sep 8, 2021 that may be closed by this pull request
includes/Classifai/Admin/SavePostHandler.php Outdated Show resolved Hide resolved
includes/Classifai/Admin/SavePostHandler.php Outdated Show resolved Hide resolved
includes/Classifai/Admin/SavePostHandler.php Outdated Show resolved Hide resolved
@jeffpaul jeffpaul merged commit 8dc621f into develop Sep 24, 2021
@jeffpaul jeffpaul deleted the feature/309-add-post-status-filter branch September 24, 2021 18:34
@dkotter dkotter linked an issue Mar 8, 2022 that may be closed by this pull request
@jeffpaul jeffpaul modified the milestones: 1.8.0, 1.7.1 Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New filter: allow content classification by $post_status Add filter for processing on alternate post status
3 participants