admin管理员组

文章数量:1418064

The functions.php file of my Child Theme is a mess...
I'd like to use classes in a separate folder (like /inc) but I would like to keep a maximum of security.
For now everything works as excepted, but is my code safe enough to use in production ?

  • functions.php

    // Include our classes.  
    require_once( get_stylesheet_directory() . '/inc/class.my-class-1.php' );  
    require_once( get_stylesheet_directory() . '/inc/class.my-class-2.php' );  
    ...  
    
    // Instantiate our classes.  
    $my_class_1 = new My_Class_1();  
    $my_class_2 = new My_Class_2();  
    
    // Hooks goes here.  
    add_action( 'hook_i_want', array( $my_class_1, 'my_function_in_class_1'), 10 );  
    add_filter( 'other_hook_i_want', array( $my_class_2, 'my_function_in_class_2' ) );  
    ...
    

Or maybe a better idea ?

本文标签: Child themehow to cut the functionsphp file into several classes