learndash-cpt-options

apply_filters( 'learndash-cpt-options',  array $cpt_args )

Filters the custom post type arguments.


Description #


Parameters #

$cpt_args

(array) Custom post type arguments.


Source #

File: includes/ld-assignment-uploads.php


Examples #

 <?php
/**
 * Example usage for learndash-cpt-options filter.
 */
add_filter(
	'learndash-cpt-options',
	function( $post_args = array(), $post_type_slug = '' ) {
		if ( 'sfwd-assignment' === $post_type_slug ) {
			if ( ( isset( $post_args['supports'] ) ) && ( ! empty( $post_args['supports'] ) ) && ( is_array( $post_args['supports'] ) ) ) {
				// Simple method to compare the 'supports' array and return all but the 'comments' element.
				$post_args['supports'] = array_diff( $post_args['supports'], array( 'comments' ) );
			}
		}

		// always return the $post_args array
		return $post_args;
	},
	10,
	2
);