Inventory_Presser_Photo_Numberer::add_sequence_number_to_titles( string $title, int $id = null )
Dynamically changes post titles of vehicle attachments in the dashboard to identify their sequence number.
On This Page
Parameters Parameters
- $title
-
(string) (Required) The post title.
- $id
-
(int) (Optional) The post ID.
Default value: null
Return Return
(string)
Source Source
File: includes/class-photo-numberer.php
public function add_sequence_number_to_titles( $title, $id = null ) { // Don't double dip during REST API requests. if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { return $title; } // What post? if ( empty( $id ) ) { return $title; } if ( ! is_admin() ) { return $title; } // Is this the Media Library upload.php? if ( ! function_exists( 'get_current_screen' ) ) { return $title; } $screen = get_current_screen(); if ( empty( $screen->parent_file ) || 'upload.php' !== $screen->parent_file ) { // No. return $title; } if ( 'attachment' !== get_post_type( $id ) ) { // No. 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 ) ); }
Expand full source codeCollapse full source codeView on Github