Myzwer / foothillschurch

Bootcamp II is a wordpress theme (as well as an inside joke) designed to suit the needs of foothillschurch.com. It makes use of webpack, Babel, Sass, Tailwind, Browsersync, PostCSS, ESLint, Stylelint, Prettier and more. It is meant for that site, but if you can use it by all means go for it.
1 stars 1 forks source link

Simplify to a single action #5

Closed rain2o closed 3 months ago

rain2o commented 3 months ago

https://github.com/Myzwer/foothillschurch/blob/d75494784caf988edbcdb95afebe7becdca009e7/includes/enqueue.php#L21-L42

You're defining 3 functions, and calling add_action on the same hook wp_enqueue_scripts 3 separate times. They are all injected into the same hook, and do the same thing - enqueue a script/style, so there's no need to separate them. You can condense this all down to a single action/function.

function scripts_loadin()
{
    wp_enqueue_style('frontend', get_template_directory_uri() . '/assets/public/css/frontend.css');
    wp_enqueue_script('frontend', get_template_directory_uri() . '/assets/public/js/frontend.js');
    wp_enqueue_script('churchcenter-modal', 'https://js.churchcenter.com/modal/v1', array(), null, true);
}

add_action('wp_enqueue_scripts', 'scripts_loadin');