What factors should be considered when choosing a CMS as a foundation for integrating custom scripts in PHP?

When choosing a CMS as a foundation for integrating custom scripts in PHP, it is important to consider factors such as the CMS's flexibility, compatibility with PHP scripts, ease of customization, community support, and security features.

// Example PHP code snippet for integrating custom scripts into a CMS

// Define your custom PHP script here
function custom_script() {
    // Your custom PHP code goes here
}

// Hook your custom script into the CMS
add_action('init', 'custom_script');