ACF_Admin_Field_Groups::check_duplicate()
Checks for the custom "duplicate" action.
Метод класса: ACF_Admin_Field_Groups{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$ACF_Admin_Field_Groups = new ACF_Admin_Field_Groups(); $ACF_Admin_Field_Groups->check_duplicate();
Список изменений
С версии 5.9.0 | Введена. |
Код ACF_Admin_Field_Groups::check_duplicate() ACF Admin Field Groups::check duplicate ACF 6.0.4
public function check_duplicate() { // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Used for redirect notice. // Display notice on success redirect. if ( isset( $_GET['acfduplicatecomplete'] ) ) { $ids = array_map( 'intval', explode( ',', $_GET['acfduplicatecomplete'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized with intval(). // phpcs:enable WordPress.Security.NonceVerification.Recommended // Generate text. $text = sprintf( _n( 'Field group duplicated.', '%s field groups duplicated.', count( $ids ), 'acf' ), count( $ids ) ); // Append links to text. $links = array(); foreach ( $ids as $id ) { $links[] = '<a href="' . get_edit_post_link( $id ) . '">' . get_the_title( $id ) . '</a>'; } $text .= ' ' . implode( ', ', $links ); // Add notice. acf_add_admin_notice( $text, 'success' ); return; } // Find items to duplicate. $ids = array(); if ( isset( $_GET['acfduplicate'] ) ) { $ids[] = intval( $_GET['acfduplicate'] ); } elseif ( isset( $_GET['post'], $_GET['action2'] ) && $_GET['action2'] === 'acfduplicate' ) { $ids = array_map( 'intval', $_GET['post'] ); } if ( $ids ) { check_admin_referer( 'bulk-posts' ); // Duplicate field groups and generate array of new IDs. $new_ids = array(); foreach ( $ids as $id ) { $field_group = acf_duplicate_field_group( $id ); $new_ids[] = $field_group['ID']; } // Redirect. wp_redirect( $this->get_admin_url( '&acfduplicatecomplete=' . implode( ',', $new_ids ) ) ); exit; } }