# WP Customizer Utilities
Advanced WordPress customizer controls and settings for better user experience.
## Installation
Install it via [Composer](https://getcomposer.org/) and [Packagist](https://packagist.org/packages/proteusthemes/wp-customizer-utilities):
```shell
$ composer require proteusthemes/wp-customizer-utilities
```
Start using the classes and they will be autoloaded (PSR-4).
## Documentation
### Controls
- #### Layout Builder
[jQuery UI slider](https://jqueryui.com/slider/) with an option how many handles you want to control in that slider. Useful for creating dynamic layouts, for example for the footer, where user can congigure how many columns they want and how wide each of these columns will be.
- #### Gradient
Control for the CSS gradient (WP has only support for solid colors by default).
### Settings
- #### Dynamic CSS
Create Dynamic CSS by declaring the selectors (for example for background colors etc.) when defining a setting. Has build-in support for modifiers of that color and media queries.
##### Public methods
- `get_css_props()`
Get entire css_props property of the class.
- `get_single_css_prop( string $name, DynamicCSS\ModInterface|callable $modifier )`
Return all variants of the CSS propery with selectors. Optionally filtered with the modifier.
- `render_css()`
Render the entire CSS for this setting in the inline style (each group of selectors in its own line). Useful for caching the output of the setting and echoing it on the WP frontend.
##### Modifier Interface `ModInterface`
The modifer classes must implement the `DynamicCSS\ModInterface`. It has only one method `modify( $in )` which takes input value and returns the modified value.
Example:
```php
class MyModClass implements \ProteusThemes\CustomizerUtils\Setting\DynamicCSS\ModInterface {
public function modify( $in ) {
return your_modify_function( $in );
}
}
```
##### Included modifiers
Some modifiers are already included with the package and you can use them stright away.
- `ModDarken( $amount )` - darken hexdec color for `$amount` (using [phpColors](https://github.com/mexitek/phpColors#available-methods))
- `ModLighten( $amount )` - lighten hexdec color for `$amount` (using [phpColors](https://github.com/mexitek/phpColors#available-methods))
- `ModLinearGradient( ModInterface $modifier, $orientation = 'to bottom' )` - creates CSS linear-gradient. First color is instact, second color is modified using `$modifier`. `$orientation` can be any valid [CSS orientation](https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient#Syntax).
- `ModPrependAppend( $prefix = '', $suffix = '' )` - adds the prefix or suffix (or both) to the value. Useful for adding ` !import` or `url('value')`.
##### Use
Example of the code you would most likely attach to the action `customize_register`:
```php
function your_func( $wp_customize ) {
$darken5 = new \ProteusThemes\CustomizerUtils\Setting\DynamicCSS\ModDarken( 5 );
$wp_customize->add_setting( new \ProteusThemes\CustomizerUtils\Setting\DynamicCSS( $wp_customize, 'nav_bg', array(
'default' => '#bada55',
'css_props' => array( // list of all css properties this setting controls
array( // each property in it's own array
'name' => 'background-color', // this is actual CSS property
'selectors' => array(
'noop' => array( // regular selectors in the key 'noop'
'body',
'.selector2',
),
'@media (min-width: 900px)' => array( // selectors which should be in MQ
'.selector3',
),
),
'modifier' => $darken5, // optional. Separate data type, with the modify() method (via implemented interface) which takes value and returns modified value OR callable function with 1 argument
),
),
) ) );
}
add_action( 'customize_register', 'your_func' );
```
You must also enqueue the JS file which handles the live preview changes via `postMessage`:
```php
function enqueue_customizer_js() {
wp_enqueue_script(
'mytheme-live-customize',
get_template_directory_uri() . '/vendor/proteusthemes/wp-customizer-utilities/assets/live-customize.js',
array( 'jquery', 'customize-preview' ),
false,
true
);
wp_localize_script( 'mytheme-live-customize', 'ptCustomizerDynamicCSS', array(
array(
'settingID' => 'nav_bg',
'selectors' => 'body, .selector1, .selector2',
'cssProp' => 'background-color',
)
) );
}
add_action( 'customize_preview_init', 'enqueue_customizer_js', 31 );
```
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress主题】2022年最新版完整功能demo+插件v1.6.1.zip
共382个文件
php:136个
mo:55个
po:55个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 65 浏览量
2022-04-04
08:59:15
上传
评论
收藏 1.95MB ZIP 举报
温馨提示
"【WordPress主题】2022年最新版完整功能demo+插件v1.6.1 GrowthPress - Marketing and SEO WordPress Theme 增长 - 营销和SEO WordPress主题" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress主题】2022年最新版完整功能demo+插件v1.6.1.zip (382个子文件)
theme.css 301KB
theme.min.css 253KB
woocommerce.css 34KB
woocommerce.min.css 30KB
font-awesome.min.css 30KB
jquery-ui.min.css 29KB
rtl.css 28KB
rtl.css 17KB
rtl.min.css 14KB
admin.css 2KB
main.css 1KB
style.css 1KB
style.css 420B
admin.css 364B
phpunit.xml.dist 753B
fontawesome-webfont.eot 162KB
screenshot.jpg 85KB
screenshot.jpg 55KB
build.js 90KB
admin.js 21KB
mustache.min.js 9KB
admin.js 8KB
main.js 6KB
modernizr.custom.20170701.js 6KB
sticky-menu.js 5KB
theme-slider.js 5KB
touch-dropdown.js 5KB
youtube-events.js 4KB
NumberCounter.js 4KB
vimeo-events.js 3KB
index.js 2KB
BrochureAdmin.js 2KB
urgency-counter.js 2KB
Gruntfile.js 1KB
webpack.config.js 867B
utils.js 851B
wai-aria.js 565B
live-customize.js 459B
postcss.config.js 181B
installed.json 11KB
package.json 4KB
composer.json 993B
composer.json 917B
composer.json 757B
composer.json 689B
composer.json 606B
composer.json 533B
composer.json 490B
composer.json 368B
composer.json 225B
package.json 166B
LICENSE 34KB
LICENSE 18KB
LICENSE 1KB
LICENSE 1KB
CHANGELOG.md 35KB
LICENSE.md 18KB
README.md 5KB
CONTRIBUTING.md 4KB
README.md 3KB
README.md 3KB
README.md 3KB
readme.md 2KB
CONTRIBUTING.md 1KB
README.md 379B
tgmpa-ru_RU.mo 14KB
tgmpa-sr_RS.mo 13KB
ru_RU.mo 13KB
ru_RU.mo 13KB
tgmpa-pt_BR.mo 11KB
tgmpa-cs_CZ.mo 11KB
tgmpa-fr_FR.mo 11KB
tgmpa-hr_HR.mo 11KB
fr_FR.mo 11KB
fr_FR.mo 11KB
tgmpa-de_DE.mo 11KB
tgmpa-ro_RO.mo 11KB
tr_TR.mo 11KB
tr_TR.mo 11KB
pt_PT.mo 11KB
pt_PT.mo 11KB
es_ES.mo 10KB
es_ES.mo 10KB
nl_NL.mo 10KB
nl_NL.mo 10KB
it_IT.mo 10KB
it_IT.mo 10KB
de_DE.mo 10KB
de_DE.mo 10KB
pl_PL.mo 10KB
pl_PL.mo 10KB
tgmpa-es_ES.mo 10KB
tgmpa-nl_NL.mo 10KB
tgmpa-it_IT.mo 10KB
cs_CZ.mo 10KB
cs_CZ.mo 10KB
sv_SE.mo 10KB
sv_SE.mo 10KB
tgmpa-he_IL.mo 10KB
tgmpa-sv_SE.mo 10KB
共 382 条
- 1
- 2
- 3
- 4
资源评论
Lee达森
- 粉丝: 968
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功