'item_updated' => sprintf( esc_html__( '%s updated.', 'tribe-events-calendar-pro' ), $this->singular_label ), 'item_link' => sprintf( // Translators: %s: Series singular. esc_html__( '%s Link', 'tribe-events-calendar-pro' ), $this->singular_label ), 'item_link_description' => sprintf( // Translators: %s: Series singular. esc_html__( 'A link to a particular %s.', 'tribe-events-calendar-pro' ), $this->singular_label ), ] ); } /** * Gets the post type args. * * @since 6.0.0 * * @return array An array used to register a new post type. */ public function get_post_type_args() { $args = $this->post_type_args; /** * Gets the series post type args. * * @param array $post_type_args Post Type args. */ return apply_filters( 'tribe_events_register_series_type_args', $args ); } /** * Registers the post type. * * @since 6.0.0 * * @return WP_Error|WP_Post_Type The registered post type or error if it was not registered correctly. */ public function register_post_type() { if ( post_type_exists( static::POSTTYPE ) ) { return get_post_type_object( static::POSTTYPE ); } return register_post_type( static::POSTTYPE, $this->get_post_type_args() ); } /** * Since we are adding a new post type, let's flush rewrite rules this once. * * @since 6.0.0 */ public function flush_rewrite() { if ( ! get_transient( static::FLUSH_REWRITE_TRANSIENT ) ) { set_transient( static::FLUSH_REWRITE_TRANSIENT, true, MONTH_IN_SECONDS ); flush_rewrite_rules(); } } /** * Allow users to specify their own singular label for Series. * * @since 6.0.0 * * @return string */ public function get_label_singular() : string { /** * Filter the series post type singular label. * * @param string $label The label. */ return apply_filters( 'tribe_series_label_singular', _x( 'Series', 'Singular name of the Series post type.', 'tribe-events-calendar-pro' ) ); } /** * Allow users to specify their own plural label for Series. * * @return string */ public function get_label_plural() : string { /** * Filter the series post type plural label. * * @param string $label The label. */ return apply_filters( 'tribe_series_label_plural', _x( 'Series', 'Plural name of the Series post type', 'tribe-events-calendar-pro' ) ); } /** * Allow users to specify their own lowercase singular label for Series. * @return string */ public function get_label_singular_lowercase() : string { /** * Filter the series post type singular lowercase label. * * @param string $label The label. */ return apply_filters( 'tribe_series_label_singular_lowercase', _x( 'series', 'Lowercase singular name of the Series post type', 'tribe-events-calendar-pro' ) ); } /** * Allow users to specify their own lowercase plural label for Series. * * @return string */ public function get_label_plural_lowercase() : string { /** * Filter the series post type plural lowercase label. * * @param string $label The label. */ return (string) apply_filters( 'tribe_series_label_plural_lowercase', _x( 'series', 'Lowercase plural name of the Series post type', 'tribe-events-calendar-pro' ) ); } /** * Detect if the provided post is of the same type as the current post type. * * @since 6.0.0 * * @param WP_Post|null $post The post object to compare against with. * * @return boolean `true` if is of $post is of the same type as the current post type, `false` otherwise. */ public function is_same_type( WP_Post $post = null ) { return $post instanceof WP_Post && $post->post_type === static::POSTTYPE; } /** * Registers the Series post type or throws on failure. * * @since 6.0.2 * * @return WP_Post_Type The registered Series post type. * * @throws \RuntimeException If the post type registration fails. */ public function register_post_type_or_fail(): WP_Post_Type { $registered = $this->register_post_type(); if ( ! $registered instanceof WP_Post_Type ) { throw new \RuntimeException( 'Failed to register the Series post type' ); } return $registered; } }