Skip to content

Instantly share code, notes, and snippets.

@shaunpalmer
Created November 15, 2024 12:05
Show Gist options
  • Save shaunpalmer/f9b15bdb1e110bac981d608db75dbd89 to your computer and use it in GitHub Desktop.
Save shaunpalmer/f9b15bdb1e110bac981d608db75dbd89 to your computer and use it in GitHub Desktop.
// Initialize the class.
// Array of class names to instantiate
$classes = [
'Ays_CPT_FAQ',
'Ays_CPT_Location',
'Ays_CPT_Review',
'Ays_CPT_Service',
'Ays_CPT_Team',
];
foreach ($classes as $class) {
try {
// Dynamically instantiate the class
$instance = new $class();
error_log("Successfully instantiated {$class}");
} catch (Throwable $e) {
error_log("Failed to instantiate {$class}: " . $e->getMessage());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment