/** * Enqueue scripts and styles for admin side. * * @since 1.0.0 */ public function admin_enqueue_scripts() { // wp_get_environment_type() = 'production' by defaul. // To change it, define the 'WP_ENVIRONMENT_TYPE' constant on wp-config.php // Example: define( 'WP_ENVIRONMENT_TYPE', 'local' ); $min = wp_get_environment_type() !== 'production' ? '' : '.min'; if ( get_post_type() === 'post' ) { // To enqueue only where it's being used. wp_enqueue_style( 'ctp-edit-page-css', THEME_CSS_URL . "cpt-edit-page{$min}.css", [], THEME_VER, 'all' ); wp_enqueue_script( 'cpt-edit-page-js', THEME_JS_URL . "cpt-edit-page{$min}.js", [ 'jquery' ], THEME_VER, false ); } } add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] ); /** * Enqueue scripts and styles for frontend side. * * @since 1.0.0 */ public function wp_enqueue_scripts() { // wp_get_environment_type() = 'production' by defaul. // To change it, define the 'WP_ENVIRONMENT_TYPE' constant on wp-config.php // Example: define( 'WP_ENVIRONMENT_TYPE', 'local' ); $min = wp_get_environment_type() !== 'production' ? '' : '.min'; if ( get_post_type() === 'post' ) { // To enqueue only where it's being used. wp_enqueue_style( 'ctp-edit-page-css', THEME_CSS_URL . "cpt-edit-page{$min}.css", [], THEME_VER, 'all' ); wp_enqueue_script( 'cpt-edit-page-js', THEME_JS_URL . "cpt-edit-page{$min}.js", [ 'jquery' ], THEME_VER, false ); } } add_action( 'wp_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );