WPML
do_action( 'wpml_admin_make_post_duplicates', int $master_post_id )
유형
action
카테고리
콘텐츠 삽입
WPML 버전
3.2

설명

“master” 글에서 복제 글을 생성하거나 업데이트합니다. 이 액션 훅은 관리 화면 백엔드 호출을 위해 예약되어 있습니다.

인수

$master_post_id
(int) (필수) 복제할 원본 글의 ID입니다. 글, 페이지 또는 사용자 정의 글일 수 있습니다. “마스터 글”이 기본 언어일 필요는 없습니다.

사용 예시

예제
// this will create duplicates for the "Hello World!" post
do_action( 'wpml_admin_make_post_duplicates', 1 );

아래 예제에서는 ‘edit-post’ 관리 화면에서 ‘publish’를 클릭할 때 글, 페이지 또는 사용자 정의 글의 복제본을 생성합니다.
고급 예제
add_action( 'wp_insert_post', 'my_duplicate_on_publish' );
function my_duplicate_on_publish( $post_id ) {
	global $post;

	// don't save for autosave
	if (is_null($post))
		{
       		 return $post_id;
		}

	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
		return $post_id;
	}

	// dont save for revisions
	if ( isset( $post->post_type ) && $post->post_type == 'revision' ) {
		return $post_id;
	}

	// we need this to avoid recursion see add_action at the end
	remove_action( 'wp_insert_post', 'my_duplicate_on_publish' );

	// make duplicates if the post being saved:
	// #1. is not a duplicate of another or
	// #2. does not already have translations

	$is_translated = apply_filters( 'wpml_element_has_translations', '', $post_id, $post->post_type );

	if ( !$is_translated ) {
		do_action( 'wpml_admin_make_post_duplicates', $post_id );
	}

	// must hook again - see remove_action further up
	add_action( 'wp_insert_post', 'my_duplicate_on_publish' );
}

wpml_set_element_language_details, wpml_make_post_duplicates, wpml_copy_post_to_language, wpml_delete_package, wpml_import_get_trid_from_imported_translations, wpml_register_string, wpml_register_single_string, wpml_show_package_language_ui, wpml_delete_package_action

모든 콘텐츠 삽입 훅 10개 →