Inventory_Presser_Photo_Numberer::add_sequence_number_to_titles( $title,  $id )


Source

File: includes/class-photo-numberer.php

	public function add_sequence_number_to_titles( $title, $id ) {
		if ( ! is_admin() ) {
			return $title;
		}

		// Is this the Media Library upload.php?
		if ( function_exists( 'get_current_screen' ) && $screen = get_current_screen() ) {
			if ( empty( $screen->parent_file ) || 'upload.php' != $screen->parent_file ) {
				// No
				return $title;
			}
		} else {
			return $title;
		}

		// Is this post ID a vehicle photo?
		if ( 'attachment' != get_post_type( $id ) ) {
			return $title;
		}

		$parent = get_post_parent( $id );
		if ( empty( $parent ) || INVP::POST_TYPE != $parent->post_type ) {
			// No
			return $title;
		}

		// Get the photo count
		return sprintf(
			'%s (%s %s %s %s)',
			$title,
			__( 'Photo', 'inventory-presser' ),
			INVP::get_meta( 'photo_number', $id ),
			__( 'of', 'inventory-presser' ),
			invp_get_the_photo_count( $parent->ID )
		);

	}