HEX
Server: Apache/2
System: Linux server-27-254-144-72.da.direct 5.10.0-33-amd64 #1 SMP Debian 5.10.226-1 (2024-10-03) x86_64
User: pokaorgani (1114)
PHP: 8.1.33
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/pokaorgani/public_html/wp-content/themes/sydney/inc/customizer/options/cpt-panels.php
<?php
/**
 * Register panels and sections for all public CPTs
 *
 * @package Sydney
 */

//Get post types
$args       = array(
	'public' => true,
);
$post_types = get_post_types( $args, 'objects' );

//Remove unwanted post types
$unset_types = array(
	'page',
	'post',
	'product',
	'attachment',
	'e-landing-page',
	'elementor_library',
	'athemes_hf',
);

foreach ( $unset_types as $type ) {
	unset( $post_types[ $type ] );
}

//Register panels and sections
foreach ( $post_types as $post_type ) {

	//Panel
	$wp_customize->add_panel(
		'sydney_panel_cpt_' . $post_type->name,
		array(
			'title'     => $post_type->label,
			'priority'  => 50,
		)
	);

	//Singles section
	$wp_customize->add_section(
		'sydney_cpt_' . $post_type->name,
		array(
			'title'     => __( 'Singles', 'sydney' ),
			'panel'     => 'sydney_panel_cpt_' . $post_type->name,
		)
	);

	//Archives section
	$wp_customize->add_section(
		'sydney_cpt_' . $post_type->name . '_archives',
		array(
			'title'     => __( 'Archives', 'sydney' ),
			'panel'     => 'sydney_panel_cpt_' . $post_type->name,
		)
	);
}