Đơn giản hóa mã để đăng ký nhiều khu vực tiện ích con trong Genesis

Trong mạch của bài viết trước đây của tôi về việc đơn giản hóa mã để hiển thị nhiều vùng widget trong Genesis, tôi chia sẻ mã cô đọng để đăng ký 4 vùng widget tại đây.

// Register front-page widget areas
for ( $i = 1; $i <= 4; $i++ ) {
	genesis_register_widget_area(
		array(
			'id'          => "front-page-{$i}",
			'name'        => __( "Front Page {$i}", 'my-theme-text-domain' ),
			'description' => __( "This is the front page {$i} section.", 'my-theme-text-domain' ),
		)
	);
}

(đi trong functions.php của chủ đề con)

Ở trên cũng giống như

genesis_register_widget_area(
	array(
		'id'          => "front-page-1",
		'name'        => __( "Front Page 1", 'my-theme-text-domain' ),
		'description' => __( "This is the front page 1 section.", 'my-theme-text-domain' ),
	)
);

genesis_register_widget_area(
	array(
		'id'          => "front-page-2",
		'name'        => __( "Front Page 2", 'my-theme-text-domain' ),
		'description' => __( "This is the front page 2 section.", 'my-theme-text-domain' ),
	)
);

genesis_register_widget_area(
	array(
		'id'          => "front-page-3",
		'name'        => __( "Front Page 3", 'my-theme-text-domain' ),
		'description' => __( "This is the front page 3 section.", 'my-theme-text-domain' ),
	)
);

genesis_register_widget_area(
	array(
		'id'          => "front-page-4",
		'name'        => __( "Front Page 4", 'my-theme-text-domain' ),
		'description' => __( "This is the front page 4 section.", 'my-theme-text-domain' ),
	)
);