WordPress.org

Ready to get started?Download WordPress

Forums

Classes vs Functions in functions.php and others (1 post)

  1. Comparativa de Bancos
    Member
    Posted 1 year ago #

    Hello,

    I see everywhere (http://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

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by Comparativa de Bancos
  • This topic is not resolved
  • WordPress version: 3.5.1