proteusthemes/wp-customizer-utilities
Composer 安装命令:
composer require proteusthemes/wp-customizer-utilities
包简介
Advanced WordPress customizer controls and settings for better user experience.
README 文档
README
Advanced WordPress customizer controls and settings for better user experience.
Requirements
Requires PHP version 7.2.0 or greater.
Installation
Install it via Composer and Packagist:
$ composer require proteusthemes/wp-customizer-utilities
Start using the classes and they will be autoloaded (PSR-4).
Documentation
Controls
-
Layout Builder
jQuery UI 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
ModInterfaceThe modifer classes must implement the
DynamicCSS\ModInterface. It has only one methodmodify( $in )which takes input value and returns the modified value.Example:
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)ModLighten( $amount )- lighten hexdec color for$amount(using phpColors)ModLinearGradient( ModInterface $modifier, $orientation = 'to bottom' )- creates CSS linear-gradient. First color is instact, second color is modified using$modifier.$orientationcan be any valid CSS orientation.ModPrependAppend( $prefix = '', $suffix = '' )- adds the prefix or suffix (or both) to the value. Useful for adding!importorurl('value').
Use
Example of the code you would most likely attach to the action
customize_register: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: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 );
-
proteusthemes/wp-customizer-utilities 适用场景与选型建议
proteusthemes/wp-customizer-utilities 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.98k 次下载、GitHub Stars 达 32, 最近一次更新时间为 2015 年 10 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「theme」 「wordpress」 「control」 「wp」 「customizer」 「proteusthemes」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 proteusthemes/wp-customizer-utilities 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 proteusthemes/wp-customizer-utilities 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 proteusthemes/wp-customizer-utilities 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provide a way to secure accesses to all routes of an symfony application.
A Bootstrap 4.x base theme for SilverStripe
Lucency Theme
Selectize Theme for Bootstrap 4
Yii2 prettyPhoto image galary widget uses Lightbox view control jquery.prettyphoto.js
Yii2 DynaTree Menu widget uses Dynamic tree view control jquery.dynatree.js
统计信息
- 总下载量: 9.98k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 32
- 点击次数: 27
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2015-10-08