承接 themeplate/enqueue 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

themeplate/enqueue

Composer 安装命令:

composer require themeplate/enqueue

包简介

Helper for registered dependencies

README 文档

README

Usage

use ThemePlate\Enqueue;

function theme_scripts() {
	wp_enqueue_script( 'main-script', 'PATH_TO_MAIN_JS' );
	wp_script_add_data( 'main-script', 'async', true );
	wp_enqueue_script( 'extra-script', 'PATH_TO_EXTRA_JS' );
	wp_script_add_data( 'extra-script', 'defer', true );

	wp_enqueue_script( 'jquery-slim', 'https://code.jquery.com/jquery-3.5.1.slim.min.js', array(), '3.5.1', true );
	wp_script_add_data( 'jquery-slim', 'integrity', 'sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj' );
	wp_script_add_data( 'jquery-slim', 'crossorigin', 'anonymous' );
	wp_enqueue_style( 'bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css', array(), '4.5.2' );
	wp_style_add_data( 'bootstrap', 'integrity', 'sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z' );
	wp_style_add_data( 'bootstrap', 'crossorigin', 'anonymous' );

	wp_register_style( 'slick-carousel', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css', array(), '1.9.0', 'all' );
	wp_register_script( 'slick-carousel', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js', array(), '1.9.0', true );
}
add_action( 'wp_enqueue_scripts', 'theme_scripts' );

add_action( 'init', array( Enqueue::class, 'init' ) );

// Set to the wanted insert position; default is 10
Enqueue::$priority = 20;

// In templates before calling the get_header()
Enqueue::script( 'slick-carousel' );
Enqueue::style( 'slick-carousel' );
Enqueue::script(
	'popper',
	'https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js',
	array(
		'integrity' => 'sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN',
		'crossorigin' => 'anonymous',
	)
);

Enqueue::script( $handle, $src, $data )

Enqueue::style( $handle, $src, $data )

  • $handle (string)(Required) Registered handle or unique name if $src is provided
  • $src (string)(Optional) Full URL or path relative to the WordPress root directory
  • $data (array)(Optional) Custom metadata to be added to the registered asset

统计信息

  • 总下载量: 351
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2020-03-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固