• Hello,

    I see everywhere (https://underscores.me/ and many others) using functions like

    function _s_register_custom_background() {
    
    }
    add_action( 'after_setup_theme', 'cdb13_register_custom_background' );

    directly in functions.php.

    I have also seen implementations like this one

    `if ( !defined( ‘DOING_AJAX’ ) || !DOING_AJAX )
    { my code goes here… }

    if ( is_admin() ) {
    if ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) {
    more code here
    } else {
    add_action( ‘admin_init’, ‘my_admin_init’, 15 );
    }

    } else {

    add_action( ‘after_setup_theme’, ‘my_frontend_init’, 15 );
    }

    where my_frontend_init is a require to a Class.

    I like more the second one but as every sample from automattic (like underscore) is using functions and they are never defining these functions within classes and never just in the frontend I was hesitating is this really make any kind of difference.

    Is it really worthy from a performance point of view? Is it really worthy from an implementation point of view?

    What do you think?

    Thanks

  • The topic ‘Classes vs Functions in functions.php and others’ is closed to new replies.