helsingborg-stad / modularity
Modular component system for WordPress
Installs: 21 575
Dependents: 8
Suggesters: 0
Security: 0
Stars: 8
Watchers: 14
Forks: 9
Open Issues: 28
Type:wordpress-plugin
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.43.4
- 6.43.3
- 6.43.2
- 6.43.1
- 6.43.0
- 6.42.3
- 6.42.2
- 6.42.1
- 6.42.0
- 6.41.1
- 6.41.0
- 6.40.3
- 6.40.2
- 6.40.1
- 6.40.0
- 6.39.0
- 6.38.1
- 6.38.0
- 6.37.0
- 6.36.3
- 6.36.1
- 6.36.0
- 6.35.0
- 6.34.1
- 6.34.0
- 6.33.3
- 6.33.1
- 6.33.0
- 6.32.8
- 6.32.7
- 6.32.5
- 6.32.4
- 6.32.3
- 6.32.2
- 6.32.1
- 6.32.0
- 6.31.0
- 6.30.1
- 6.30.0
- 6.29.0
- 6.28.2
- 6.28.1
- 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.3
- 6.11.2
- 6.11.1
- 6.11.0
- 6.10.1
- 6.10.0
- 6.9.0
- 6.8.2
- 6.8.1
- 6.8.0
- 6.7.3
- 6.7.2
- 6.7.1
- 6.7.0
- 6.6.1
- 6.6.0
- 6.5.0
- 6.4.0
- 6.3.0
- 6.2.4
- 6.2.2
- 6.2.1
- 6.2.0
- 6.1.2
- 6.1.1
- 6.1.0
- 6.0.21
- 6.0.20
- 6.0.19
- 6.0.17
- 6.0.16
- 6.0.15
- 6.0.14
- 6.0.13
- 6.0.12
- 6.0.11
- 6.0.10
- 6.0.8
- 6.0.7
- 6.0.6
- 6.0.5
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.23.3
- 5.23.2
- 5.23.1
- 5.23.0
- 5.22.2
- 5.22.1
- 5.22.0
- 5.21.16
- 5.21.15
- 5.21.14
- 5.21.13
- 5.21.12
- 5.21.11
- 5.21.10
- 5.21.9
- 5.21.8
- 5.21.7
- 5.21.5
- 5.21.4
- 5.21.3
- 5.21.2
- 5.21.1
- 5.21.0
- 5.20.5
- 5.20.4
- 5.20.3
- 5.20.2
- 5.20.1
- 5.20.0
- 5.19.1
- 5.19.0
- 5.18.6
- 5.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.4.46
- 1.4.45
- 1.4.44
- 1.4.43
- 1.4.41
- 1.4.40
- 1.4.39
- 1.4.38
- 1.4.37
- 1.4.36
- 1.4.35
- 1.4.34
- 1.4.33
- 1.4.32
- 1.4.31
- 1.4.30
- 1.4.29
- 1.4.28
- 1.4.27
- 1.4.26
- 1.4.25
- 1.4.24
- 1.4.23
- 1.4.22
- 1.4.21
- 1.4.20
- 1.4.19
- 1.4.18
- 1.4.17
- 1.4.16
- 1.4.15
- 1.4.14
- 1.4.13
- 1.4.12
- 1.4.11
- 1.4.10
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.96
- 1.3.95
- 1.3.94
- 1.3.93
- 1.3.92
- 1.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/menu-module-description
- dev-fix/only-allow-1-100-in-post-module
- dev-feat/manual-input-free-text-filtering
- dev-feature/Erstt-Features-Grid-med-rendering-frn-Municipio-CU-8696jdckc
- dev-feat/compressed-collection-sidebars
- dev-fix/remove-unused-post-id-param
- dev-feat/install-npm
- 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-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-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-11-13 09:46:43 UTC
README
Modular component system plugin for WordPress. Drag and drop the bundled modules or your custom modules to your page layout.
Download plugin.
To download a complete out of the box working plugin without the need to compile or fetch dependencies.
Go here and download the full-release.zip
from the latest version.
Creating modules
To create your very own Modularity module you simply create a plugin with a class that extends our Modularity\Module class.
A module actually is the same as a custom post type. However we've added a few details to enable you to use them as modules.
Use the $this->register()
method to create a very basic module.
Here's a very basic example module for you:
/* * 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;
Module templates
You can easily create your own module templates by placing them in: /wp-content/themes/[my-theme]/templates/module/
.
Name your template file with the following pattern: modularity-[module-id].php
. You can get your module's id from the Modularity options page.
Module boilerplate
You can download our module boilerplate. It will be a good starting point for any custom module that you would like to build.
Download it here (NOT AVAILABLE YET)
Action reference
Modularity
Runs when Modularity core is loaded. Typically used to add custom modules.
Example:
add_action('Modularity', function () { // Do your thing });
Modularity/Module/[MODULE SLUG]/enqueue
Enqueue js or css only for the add and edit page of the specified module.
Example:
add_action('Modularity/Module/mod-article/enqueue', function () { // Do your thing });
Modularity/Options/Module
Action to use for adding option fields to modularity options page. Use "Modularity/Options/Save" action to handle save of the option field added
Example:
add_action('Modularity/Options/Module', function () { echo '<input type="text">'; });
Modularity/save_block
Action triggered whenever a post or page is created or updated.
Example:
add_action('Modularity/save_block', function ($block, $post) { // Your code here });
Filter reference
Modularity/Module/TemplateVersion3
Enable preview of the upcoming version 3 views with BEM formatting. This may be used already when progressing towards BEM.
Example:
add_filter('Modularity/Module/TemplateVersion3', function(){return true;});
Modularity/Editor/WidthOptions
Filter module width options
Params:
$options The default width options array ('value' => 'label')
Example:
add_filter('Modularity/Editor/WidthOptions', function ($options) { // Do your thing return $filteredValue; });
Modularity/Editor/SidebarIncompability
Enables the theme to add incompability indicators of specific module to an sidebar area. The user will not be able to drag and drop to unsupported areas. This filter may simplify the theme developers work by ruling out some cases.
Params:
$moduleSpecification The default options for the module post object.
Example:
add_filter('Modularity/Editor/WidthOptions', function ($moduleSpecification) { $moduleSpecification['sidebar_compability'] = array("content-area-top"); return $moduleSpecification; });
Modularity/Display/BeforeModule
Filter module sidebar wrapper (before)
Params:
$beforeModule The value to filter
$args Arguments of the sidebar (ex: before_widget)
$moduleType The module's type
$moduleId The ID of the module
Example:
add_filter('Modularity/Display/BeforeModule', function ($beforeModule, $args, $moduleType, $moduleId) { // Do your thing return $filteredValue; });
Modularity/Display/AfterModule
Filter module sidebar wrapper (after)
Params:
$afterModule The value to filter
$args Arguments of the sidebar (ex: before_widget)
$moduleType The module's type
$moduleId The ID of the module
Example:
add_filter('Modularity/Display/AfterModule', function ($afterModule, $args, $moduleType, $moduleId) { // Do your thing return $filteredValue; });
Modularity/Module/Container/Sidebars
Container wrapper: Filter what sidebars that should support a containing wrapper on some modules
Params:
$sidebars A array of sidebar id's
Modularity/Module/Container/Modules
Container wrapper: Filter what modules that should support a containing wrapper
Params:
$modules A array of module ids (post-type names)
Modularity/Module/Container/Template
Container wrapper: Filter the template with html that should be wrapped around each module
Params:
$markup A string with markup containing {{module-markup}} replacement key
Modularity/Module/TemplatePath & Modularity/Theme/TemplatePath
Modify (add/edit) paths where to look for module/theme templates Typically used for adding search path's for finding custom modules/theme templates.
Attention: Unsetting paths may cause issues displaying modules. Plase do not do this unless you know exacly what you are doing.
Params:
$paths The value to filter
Example:
add_filter('Modularity/Module/TemplatePath', function ($paths) { return $paths; }); add_filter('Modularity/Theme/TemplatePath', function ($paths) { return $paths; });
Modularity/Module/Classes
Modify the list of classes added to a module's main element
Params:
$classes The classes (array)
$moduleType The module type
$sidebarArgs The sidebar's args
Example:
add_filter('Modularity/Module/Classes', function ($classes, $moduleType, $sidebarArgs) { $classes[] = 'example-class'; return $classes; });
Modularity/Display/Markup
Module display markup
Params:
$markup The markup
$module The module post
Example:
add_filter('Modularity/Display/Markup', function ($markup, $module) { return $markup; });
Modularity/Display/[MODULE SLUG]/Markup
Params:
$markup The markup
$module The module post
Example:
add_filter('Modularity/Display/Markup', function ($markup, $module) { return $markup; });
Modularity/CoreTemplatesSearchTemplates
What template files to look for
Params:
$templates
Example:
add_filter('Modularity/CoreTemplatesSearchTemplates', function ($templates) { $templates[] = 'my-custom-template'; return $templates; });
Modularity/Module/Posts/Date
Modify the displayed publish date in Post Modules
Params:
$date
$postId
$postType
Example:
add_filter('Modularity/Module/Posts/Date', function ($date, $postId, $postType) { return $date; });
Modularity/Module/Posts/Slider/Arguments
Modify the slider arguments in Post Modules
Params:
$args['slider']['slidesPerPage']
$args['slider']['autoSlide']
$args['slider']['showStepper']
$args['slider']['repeatSlide']
Example:
add_filter('Modularity/Module/Posts/Slider/Arguments', function ($args) { return $args; });
Modularity/Editor/ModuleCssScope
Allow editors to select a unique appeance (provided by a theme etc) for a module. Adds a single class to the module wrapper, to allow scoping of css styles.
Params:
$scopes - Previously declared scopes.
Example:
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') ) ); });
Modularity/Display/viewData
Params:
$viewData - array
Example:
add_filter('Modularity/Display/viewData',function($data) { //do something return $data; });
Modularity/Display/{modulePostTypeSlug}/viewData
Params:
$viewData - array
Example:
add_filter("Modularity/Display/mod-posts/viewData", function($data) { //do something return $data; });
Module Attributes API
Some module features are available by setting certain attributes on the module's outmost element.
data-module-refresh-interval
Creates an interval on which the module is refreshed via XHR by calling the REST API. This attribute also requires that the data-module-id
attribute is set on the same element.
The value of the attribute should be the number of seconds on which to run the refresh interval.
Example:
<div data-module-id="123" data-module-refresh-interval="60"> This content will get refreshed every 60 seconds. </div>
Rest API
The WordPress REST API is extended with the following endpoints.
modularity/v1/modules/{id}
This endpoint returns the markup for a specific module.
- Method:
GET
- Params:
id
: The ID of the module to retrieve.
- Response: The html markup of the module.
Upgrade
In some updates, database migrations might need to be run (will be in the release docs). To run the upgrade action on all sites in a multisite network, run the following command in the document root of your site.
wp site list --field=url --public=1 --archived=0 --deleted=0 --allow-root | xargs -n1 -I % wp modularity upgrade --url=% --allow-root
Or for a single site installation:
wp modularity upgrade
Constants
MODULARITY_DISABLE_FRAGMENT_CACHE
Disabling the built-in fragment cache means that each module's output will not be stored as an HTML cache. As a result, every time a visitor reloads the page, each module will have to be rendered again. However, it is important to consider this option only if you do not have any object cache enabled, such as Redis or Memcached. We strongly advise enabling the fragment cache feature in your application to enhance performance and caching efficiency, allowing modules to be rendered more quickly and reducing the need for repetitive rendering upon page reloads.
By defining this as true, cache will be turned off. Default: Undefined.
If enabled, each cached module will be rendered with a timestamp and cache ID in the following format:
Tested with support from BrowserStack
This software is tested with the awesome tools from Browserstack.