helsingborg-stad / modularity
WordPress的模块化组件系统
Requires
- php: ^8.0
- clark-nikdel-powell/post-type-select-for-acf: dev-master
- composer/installers: ~1.0
- enshrined/svg-sanitize: dev-master
- helsingborg-stad/acf-export-manager: >=1.0.0
- helsingborg-stad/acf-select-image-field: ~1.4.3
- jeradin/acf-dynamic-table-field: dev-master
- jeradin/acf-website-field: dev-master
- johannheyne/advanced-custom-fields-table-field: dev-master
- landrok/language-detector: dev-master
- ooksanen/acf-focuspoint: ^1.2.1
- wpackagist-plugin/acf-extended: 0.8.9.4
Requires (Dev)
- 10up/wp_mock: dev-trunk#1.0.1
- php-mock/php-mock-mockery: ^1.4
Suggests
- helsingborg-stad/component-library: Required for modules in modularity
- dev-master
- dev-main
- 6.28.0
- 6.27.0
- 6.26.0
- 6.25.2
- 6.25.1
- 6.25.0
- 6.24.2
- 6.24.0
- 6.23.21
- 6.23.20
- 6.23.19
- 6.23.18
- 6.23.17
- 6.23.15
- 6.23.12
- 6.23.10
- 6.23.8
- 6.23.7
- 6.23.5
- 6.23.3
- 6.23.1
- 6.23.0
- 6.22.4
- 6.22.3
- 6.22.1
- 6.22.0
- 6.21.0
- 6.20.1
- 6.20.0
- 6.19.0
- 6.18.9
- 6.18.8
- 6.18.7
- 6.18.6
- 6.18.4
- 6.18.2
- 6.18.1
- 6.18.0
- 6.17.2
- 6.17.1
- 6.17.0
- 6.16.14
- 6.16.13
- 6.16.12
- 6.16.11
- 6.16.10
- 6.16.9
- 6.16.8
- 6.16.7
- 6.16.6
- 6.16.5
- 6.16.4
- 6.16.3
- 6.16.2
- 6.16.1
- 6.16.0
- 6.15.10
- 6.15.9
- 6.15.8
- 6.15.4
- 6.15.3
- 6.15.2
- 6.15.1
- 6.15.0
- 6.14.1
- 6.13.16
- 6.13.15
- 6.13.14
- 6.13.11
- 6.13.10
- 6.13.9
- 6.13.8
- 6.13.7
- 6.13.6
- 6.13.5
- 6.13.4
- 6.13.3
- 6.13.2
- 6.13.1
- 6.12.0
- 6.11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3.66
- 2.3.65
- 2.3.64
- 2.3.63
- 2.3.62
- 2.3.61
- 2.3.60
- 2.3.59
- 2.3.58
- 2.3.57
- 2.3.56
- 2.3.55
- 2.3.54
- 2.3.53
- 2.3.52
- 2.3.51
- 2.3.50
- 2.3.49
- 2.3.48
- 2.3.47
- 2.3.46
- 2.3.45
- 2.3.44
- 2.3.43
- 2.3.42
- 2.3.41
- 2.3.40
- 2.3.39
- 2.3.38
- 2.3.37
- 2.3.36
- 2.3.35
- 2.3.34
- 2.3.33
- 2.3.32
- 2.3.31
- 2.3.30
- 2.3.29
- 2.3.28
- 2.3.27
- 2.3.26
- 2.3.25
- 2.3.24
- 2.3.23
- 2.3.22
- 2.3.21
- 2.3.20
- 2.3.19
- 2.3.18
- 2.3.17
- 2.3.16
- 2.3.15
- 2.3.14
- 2.3.13
- 2.3.12
- 2.3.11
- 2.3.10
- 2.3.9
- 2.3.8
- 2.3.7
- 2.3.6
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.2.51
- 2.2.50
- 2.2.49
- 2.2.48
- 2.2.47
- 2.2.46
- 2.2.45
- 2.2.44
- 2.2.43
- 2.2.42
- 2.2.41
- 2.2.40
- 2.2.39
- 2.2.38
- 2.2.37
- 2.2.36
- 2.2.35
- 2.2.34
- 2.2.33
- 2.2.32
- 2.2.31
- 2.2.30
- 2.2.29
- 2.2.28
- 2.2.27
- 2.2.26
- 2.2.25
- 2.2.24
- 2.2.23
- 2.2.22
- 2.2.21
- 2.2.20
- 2.2.19
- 2.2.18
- 2.2.17
- 2.2.16
- 2.2.15
- 2.2.14
- 2.2.13
- 2.2.12
- 2.2.11
- 2.2.1
- 2.2.0
- 2.1.9
- 2.1.8
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.23
- 2.0.22
- 2.0.21
- 2.0.20
- 2.0.19
- 2.0.18
- 2.0.17
- 2.0.16
- 2.0.15
- 2.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3.91
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.1.50
- 1.1.49
- 1.1.48
- 1.1.47
- 1.1.46
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-feat/imageFocusResolver
- dev-feat/srcset
- dev-fix/script-module-audio
- dev-hoftix/disable-autodetect-lang
- dev-hotfix/cache-module-usage
- dev-fix/remove-unused-acf-slider-field
- dev-fix/subscribe-notice-message
- dev-feature/modularity-typescript
- dev-fix/tsconfig
- dev-refactor/get-pages-from-module-id
- dev-feat/upgrade-posts-to-manual-input
- dev-dependabot/npm_and_yarn/axios-and-browser-sync--removed
- dev-refactor/remove-index-module
- dev-feature/refactorRendering
- dev-feat/post-type-modules-CU-865d6czkd
- dev-3.0/develop
- dev-3.0/fix/remove-index-error-notices
- dev-dependabot/npm_and_yarn/word-wrap-1.2.4
- dev-dependabot/npm_and_yarn/tough-cookie-4.1.3
- dev-fix/slider-acf-video
- dev-dependabot/npm_and_yarn/engine.io-and-socket.io-6.4.2
- dev-3.0/feature/like-icon
- dev-feature/Inlggs-modul-visar-inte-bild-som-lggs-in-i-betonat-strre-frsta-inlgg-d-man-anvnder-manuell-inmatning-2-CU-865c5p2mp
- dev-3.0/fix/slider-video-text
- dev-3.0/feature/adjacent-slides
- dev-feature/Skapa-modul-fr-quicklinks-som-fljer-samma-beteende-som-breadcrumbs-CU-865c0dky2
- dev-3.0/feature/truncate-posts-content
- dev-feature/tests
- dev-dependabot/npm_and_yarn/webpack-5.76.0
- dev-dependabot/npm_and_yarn/qs-and-browser-sync-6.11.1
- dev-dependabot/npm_and_yarn/ua-parser-js-and-browser-sync-1.0.34
- dev-dependabot/npm_and_yarn/socket.io-parser-4.0.5
- dev-3.0/feature/segment-post-as-slider
- dev-3.0/feature/posts-as-collection
- dev-3.0/fix/tooltip-z-index
- dev-3.0/feature/postType-based-slider-view
- dev-feature/Om-inlgg-som-datatyp-och-bildspel-som-vy-i-Posts-modul-s-fungerar-ej-bildspelslider-CU-865be54rt
- dev-feature/Cover-art-fr-videos-i-acceptance-CU-3ymrp06
- dev-feature/Moduler-som-anvnder-post_id-till-i-sitt-id-attribut-fr-Element-IDn-r-inte-unika-om-det-finns-flera-ggr-p-samma-sida-2-CU-3wadfmj
- dev-feature/Modul-och-block-fr-Breadcrumb-CU-3nbba5k
- dev-feature/Script-modulen-blockera-ej-scripts-utan-extern-src-CU-3qnp224
- dev-3.0/feature/map-iframe-implementation
- dev-3.0/feature/iframe-video-ratio
- dev-3.0/develop-temp-stable-revert
- dev-3.0/feature/iframe-video
- dev-3.0/feature/iframe-unknow-supplier
- dev-3.0/fix/slider-ratio
- dev-3.0/feature/notice-for-empty-block-CU-3g59yyr
- dev-3.0/feature/module-use-iframe-component
- dev-3.0/fix/suppress-iframe-class-remove
- dev-feature/iframe-module-gdpr-tweaks
- dev-3.0/feature/defer-scripts
- dev-3.0/feat-php-update
- dev-3.0/feature/expandable-list-title-background
- dev-feature/iframe-acceptance
- dev-3.0/feature/iframe-acceptance-styling
- dev-3.0/feature/iframe-height-width-set
- dev-3.0/feature/iframe-acceptance
- dev-ci/composer-builder
- dev-3.0/feature/modules-municipio
- dev-3.0/ci/npm-ci
- dev-3.0/feature/register-site
- dev-3.0/fix/block-title
- dev-feature/3.0/wp-objects
- dev-3.0/feature/allowed-inner-blocks
- dev-feature/3.0/webpack
- dev-3.0/feature/slider
- dev-feature/3.0/filesSearch
- dev-3.0/feature/post-index-search
- dev-3.0/feature/module-post-index
- dev-3.0/feature/o-grid
- dev-3.0/feature/collection
- dev-3.0/feature/render-external
- dev-feature/3.0/edit-modal
- dev-3.0/develop-backup
- dev-3.0/feature/blade_view_path_const
- dev-3.0/feature/webpack
- dev-3.0/feature/table-html_to_blade
- dev-3.0/feature/render-event-module
- dev-3.0/feature/video
- dev-3.0/feature/social
- dev-3.0/feature/sites-view
- dev-3.0/feature/rss
- dev-3.0/feature/inheritPost
- dev-feature/files-module
- dev-3.0/feature/modularity-post-module-horizontal
- dev-3.0/feature/contacts-module
- dev-3.0/feature/inlaylist-title
- dev-3.0/feature/notice-blade
- dev-3.0/feature/slider-blade
- dev-3.0/feature/inlaylist
- dev-3.0/feature/index-module
- dev-3.0/feature/module_rendering
- dev-3.0/feature/module-grid-circular
- dev-3.0/feature/module-posts-partials
- dev-3.0/feature/module-index
- dev-3.0/feature/module-posts-items
- dev-3.0/feature/module-posts
- dev-feature/3.0/errorhandling
- dev-feature/3.0/image-module
- dev-feature/3.0/module-gallery
- dev-feature/update-dependecy-version
- dev-feature/render-with-new-blade-engine
- dev-develop
- dev-feature/imageSizeIcon
- dev-shortcodesAllowNested
- dev-feature/removeFrontendUpdateQuery
- dev-feature/moduleSearch
- dev-feature/fixSlowQuerys
- dev-feature/modified_module_date
- dev-feature/filter-mod-shortcodes
- dev-feature/depricate-social
- dev-sff
- dev-sff2
- dev-flickity
This package is auto-updated.
Last update: 2024-09-20 11:14:51 UTC
README
WordPress模块化组件系统插件。拖放捆绑的模块或您自定义的模块到您的页面布局。
下载插件。
下载一个无需编译或获取依赖项即可立即使用的完整插件。
请点击此处,从最新版本下载full-release.zip
。
创建模块
要创建您自己的Modularity模块,您只需创建一个扩展我们的Modularity\Module类的类的插件。
实际上,模块与自定义文章类型相同。但我们添加了一些细节,以便您可以使用它们作为模块。
使用$this->register()
方法创建一个非常基本的模块。
以下是一个非常基本的示例模块供您参考
/* * Plugin Name: Modularity Article Module * Plugin URI: - * Description: Article module for Modularity * Version: 1.0 * Author: Modularity */ namespace MyArticleModule; class Article extends \Modularity\Module { public function __construct() { $id = 'article'; $nameSingular = 'Article'; $namePlural = 'Articles'; $description = 'Outputs a full article with title and content'; $supports = array('editor'); // All modules automatically supports title $icon = '[BASE-64 encoded svg data-uri]'; $plugin = '/path/to/include-file.php' // CAn also be an array of paths to include $cacheTTL = 60*60*24 //Time to live for fragment cache (stored in persistent object store redis / memcached). $this->register( $id, $nameSingular, $namePlural, $description, $supports, $icon, $plugin, $cacheTTL ); } } new \MyArticleModule\Article;
模块模板
您可以通过将其放在以下位置轻松创建自己的模块模板:/wp-content/themes/[my-theme]/templates/module/
。
将模板文件命名为以下模式:modularity-[module-id].php
。您可以从Modularity选项页面获取模块的ID。
模块样板
您可以从我们这里下载模块样板。它将是您想要构建的任何自定义模块的好起点。
操作参考
Modularity
当Modularity核心加载时运行。通常用于添加自定义模块。
示例
add_action('Modularity', function () { // Do your thing });
Modularity/Module/[MODULE SLUG]/enqueue
仅对指定模块的添加和编辑页面添加js或css。
示例
add_action('Modularity/Module/mod-article/enqueue', function () { // Do your thing });
Modularity/Options/Module
用于向modularity选项页添加选项字段的动作。使用“Modularity/Options/Save”动作来处理添加的选项字段的保存
示例
add_action('Modularity/Options/Module', function () { echo '<input type="text">'; });
Modularity/save_block
每当创建或更新文章或页面时都会触发此操作。
示例
add_action('Modularity/save_block', function ($block, $post) { // Your code here });
过滤器参考
Modularity/Module/TemplateVersion3
启用BEM格式化即将推出的版本3视图的预览。这可以在向BEM迈进时使用。
示例
add_filter('Modularity/Module/TemplateVersion3', function(){return true;});
Modularity/Editor/WidthOptions
过滤模块宽度选项
参数
$options The default width options array ('value' => 'label')
示例
add_filter('Modularity/Editor/WidthOptions', function ($options) { // Do your thing return $filteredValue; });
Modularity/Editor/SidebarIncompability
启用主题向侧边栏区域添加特定模块的不兼容性指示器。用户将无法将它们拖放到不支持的区域。此过滤器可能通过排除一些情况来简化主题开发人员的工作。
参数
$moduleSpecification The default options for the module post object.
示例
add_filter('Modularity/Editor/WidthOptions', function ($moduleSpecification) { $moduleSpecification['sidebar_compability'] = array("content-area-top"); return $moduleSpecification; });
Modularity/Display/BeforeModule
过滤模块侧边栏包装器(之前)
参数
$beforeModule The value to filter
$args Arguments of the sidebar (ex: before_widget)
$moduleType The module's type
$moduleId The ID of the module
示例
add_filter('Modularity/Display/BeforeModule', function ($beforeModule, $args, $moduleType, $moduleId) { // Do your thing return $filteredValue; });
Modularity/Display/AfterModule
过滤模块侧边栏包装器(之后)
参数
$afterModule The value to filter
$args Arguments of the sidebar (ex: before_widget)
$moduleType The module's type
$moduleId The ID of the module
示例
add_filter('Modularity/Display/AfterModule', function ($afterModule, $args, $moduleType, $moduleId) { // Do your thing return $filteredValue; });
Modularity/Module/Container/Sidebars
容器包装器:过滤应支持包含包装器的侧边栏
参数
$sidebars A array of sidebar id's
Modularity/Module/Container/Modules
容器包装器:过滤应支持包含包装器的模块
参数
$modules A array of module ids (post-type names)
Modularity/Module/Container/Template
容器包装器:过滤应围绕每个模块包装的html模板
参数
$markup A string with markup containing {{module-markup}} replacement key
Modularity/Module/TemplatePath & Modularity/Theme/TemplatePath
修改(添加/编辑)查找模块/主题模板的路径。通常用于添加用于查找自定义模块/主题模板的搜索路径。
注意:取消设置路径可能导致显示模块时出现问题。除非您确切知道您在做什么,否则请勿这样做。
参数
$paths The value to filter
示例
add_filter('Modularity/Module/TemplatePath', function ($paths) { return $paths; }); add_filter('Modularity/Theme/TemplatePath', function ($paths) { return $paths; });
Modularity/Module/Classes
修改模块主元素添加的类列表
参数
$classes The classes (array)
$moduleType The module type
$sidebarArgs The sidebar's args
示例
add_filter('Modularity/Module/Classes', function ($classes, $moduleType, $sidebarArgs) { $classes[] = 'example-class'; return $classes; });
模块化/显示/标记
模块显示标记
参数
$markup The markup
$module The module post
示例
add_filter('Modularity/Display/Markup', function ($markup, $module) { return $markup; });
模块化/显示/[模块短名]/标记
参数
$markup The markup
$module The module post
示例
add_filter('Modularity/Display/Markup', function ($markup, $module) { return $markup; });
模块化/核心模板/搜索模板
要查找哪些模板文件
参数
$templates
示例
add_filter('Modularity/CoreTemplatesSearchTemplates', function ($templates) { $templates[] = 'my-custom-template'; return $templates; });
模块化/模块/帖子/日期
修改帖子模块中显示的发布日期
参数
$date
$postId
$postType
示例
add_filter('Modularity/Module/Posts/Date', function ($date, $postId, $postType) { return $date; });
模块化/模块/帖子/滑块/参数
修改帖子模块中的滑块参数
参数
$args['slider']['slidesPerPage']
$args['slider']['autoSlide']
$args['slider']['showStepper']
$args['slider']['repeatSlide']
示例
add_filter('Modularity/Module/Posts/Slider/Arguments', function ($args) { return $args; });
模块化/编辑器/模块CSS作用域
允许编辑器为模块选择独特的样式(由主题等提供)。向模块包装器添加单个类,以允许CSS样式的作用域。
参数
$scopes - Previously declared scopes.
示例
add_filter('Modularity/Editor/ModuleCssScope',function($scopes) { return array( 'mod-posts' => array( 's-buy-card' => __("Make this module sparkle!", 'modularity'), 's-user-list' => __("A boring user list is what i see", 'modularity') ) ); });
模块化/显示/视图数据
参数
$viewData - array
示例
add_filter('Modularity/Display/viewData',function($data) { //do something return $data; });
模块化/显示/{模块帖子类型短名}/视图数据
参数
$viewData - array
示例
add_filter("Modularity/Display/mod-posts/viewData", function($data) { //do something return $data; });
模块属性API
某些模块功能可以通过在模块的最外层元素上设置某些属性来获得。
data-module-refresh-interval
创建一个间隔,通过调用REST API通过XHR刷新模块。此属性还需要在相同元素上设置data-module-id属性。
属性值应该是刷新间隔运行的秒数。
示例
<div data-module-id="123" data-module-refresh-interval="60"> This content will get refreshed every 60 seconds. </div>
REST API
WordPress REST API通过以下端点进行了扩展。
modularity/v1/modules/{id}
此端点返回特定模块的标记。
- 方法:
GET
- 参数
id
: 要检索的模块的ID。
- 响应: 模块的html标记。
升级
在某些更新中,可能需要运行数据库迁移(将在发布文档中说明)。要在多站网络中运行所有站点的升级操作,请在您站点的文档根目录中运行以下命令。
wp site list --field=url --public=1 --archived=0 --deleted=0 --allow-root | xargs -n1 -I % wp modularity upgrade --url=% --allow-root
或对于单个站点安装
wp modularity upgrade
常量
MODULARITY_DISABLE_FRAGMENT_CACHE
禁用内置的片段缓存意味着每个模块的输出将不会存储为HTML缓存。因此,每次访客重新加载页面时,每个模块都必须重新渲染。然而,只有在您没有启用任何对象缓存(如Redis或Memcached)的情况下,才应考虑此选项。我们强烈建议在您的应用程序中启用片段缓存功能,以提高性能和缓存效率,使模块能够更快地渲染,并减少页面重新加载时重复渲染的需求。
将此定义为true,则缓存将关闭。默认:未定义。
如果启用,每个缓存的模块将以以下格式渲染带有时间戳和缓存ID
与BrowserStack支持测试
此软件与Browserstack的出色工具进行了测试。