### Install Composer dependencies Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Use this command to install all project dependencies defined in composer.json. ```bash $ composer install ``` -------------------------------- ### Vite Development Commands Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Commands for starting the development server, building development assets, and enabling file watching. ```bash $ npm run dev ``` ```bash $ npm run build:dev ``` ```bash $ npm run watch ``` -------------------------------- ### Install ImageFocus dependencies via Composer Source: https://github.com/helsingborg-stad/municipio/blob/main/library/ImageFocus/README.md Install the required PHP package for DeepFace integration. ```bash composer require astrotomic/php-deepface ``` -------------------------------- ### Run Modularity Upgrade Commands Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Commands to execute database migrations for multisite networks or single site installations. ```bash wp site list --field=url --public=1 --archived=0 --deleted=0 --allow-root | xargs -n1 -I % wp modularity upgrade --url=% --allow-root ``` ```bash wp modularity upgrade ``` -------------------------------- ### Install DeepFace Python requirements Source: https://github.com/helsingborg-stad/municipio/blob/main/library/ImageFocus/README.md Install the necessary Python packages required by the FaceDetectorResolver. ```bash pip install deepface numpy pandas tensorflow tf-keras ``` -------------------------------- ### GET modularity/v1/modules/{id} Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Retrieves the HTML markup for a specific module by its ID. ```APIDOC ## GET modularity/v1/modules/{id} ### Description This endpoint returns the rendered HTML markup for a specific module. ### Method GET ### Endpoint modularity/v1/modules/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the module to retrieve. ``` -------------------------------- ### GET municipio/v1/view/render/{view} Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Retrieves the rendered HTML for a specified Blade view. This endpoint allows external systems to fetch pre-rendered theme components. ```APIDOC ## [GET] municipio/v1/view/render/{view} ### Description Returns the rendered HTML for a specific Blade view. This is useful for fetching partials or components dynamically. ### Method GET ### Endpoint /wp-json/municipio/v1/view/render/{view} ### Parameters #### Path Parameters - **view** (string) - Required - The path to the blade view to be rendered. ### Response #### Success Response (200) - **html** (string) - The rendered HTML content of the requested view. ### Response Example "
Rendered view content
" ``` -------------------------------- ### Initialize Build System Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Navigate to the theme directory and execute the build script to prepare the environment. ```bash $ cd [THEME-DIR] $ php build.php ``` -------------------------------- ### Enable development mode Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Set the DEV_MODE constant to true to load assets from the local styleguide. ```php define('DEV_MODE', true); ``` -------------------------------- ### Generate Feature Documentation Prompt Source: https://github.com/helsingborg-stad/municipio/blob/main/docs/utils/copilot-feature-prompt.md Use this prompt template to instruct Copilot to generate documentation for a specific feature directory. ```markdown @workspace #codebase 1. Generate markdown documentation for the feature located in the #file:library/[folder] directory. 2. Use the following markdown as a template for the documentation: ```markdown # Feature Name ### Description Provide a **brief overview** of the feature and its functionality. Explain what it does and where it is used in the system. ## How to Utilize ### For Administrators / Editors - Explain how **administrators** can use the feature, including step-by-step instructions. - Mention any **capabilities/permissions** required (e.g., `edit_posts`, `manage_options`). - Detail where to find the settings (e.g., in the WordPress admin panel). ### For Users - Describe how users will see or experience the feature on the frontend. --- ## Purpose ### Why This Feature Exists - Describe **what problem this feature solves** and why it was implemented. - Explain how it benefits different user groups (administrators, editors, and end users). ### Key Benefits ✅ Centralizes functionality or information. ✅ Improves the user experience by [explain benefit]. ✅ Reduces manual work for [specific user roles]. --- ## Meta - **Author:** [Name or Team] - **Initial Release Date:** [Month, Year] ``` ``` -------------------------------- ### Configuring core system filters Source: https://github.com/helsingborg-stad/municipio/blob/main/library/ImageConvert/README.md Adjust core settings like enabling the system, maximum dimensions, output format, and quality. ```php add_filter('Municipio/ImageConvert/IsEnabled', '__return_false'); // Disable ``` ```php add_filter('Municipio/ImageConvert/MaxImageDimension', function() { return 2560; // Allow up to 2560px images }); ``` ```php add_filter('Municipio/ImageConvert/IntermidiateImageFormat', function() { return 'jpg'; // Convert all images to JPG }); ``` ```php add_filter('Municipio/ImageConvert/IntermidiateImageQuality', function() { return 90; // Higher quality }); ``` -------------------------------- ### Vite Production Build Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Builds optimized assets for production environments. ```bash $ npm run build ``` -------------------------------- ### Initialize ChainFocusPointResolver Source: https://github.com/helsingborg-stad/municipio/blob/main/library/ImageFocus/README.md Configure the resolver chain by passing the desired resolver instances to the constructor. ```php $resolver = new ChainFocusPointResolver( new ManualFocusPointResolver($storage), new FaceDetectorResolver(), new FocalPointDetectorResolver($detector) ); ``` -------------------------------- ### Run Composer scripts Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Various scripts for testing, linting, and fixing code quality. ```bash composer run test # Run phpunit tests ``` ```bash composer run test:coverage # Run phpunit tests with code coverage ``` ```bash composer run lint # Run phpcs ``` ```bash composer run lint:changed # Run phpcs on changed files (Compares to main branch). ``` ```bash composer run fix # Run phpcbf to apply fixes to code. ``` ```bash composer run fix:changed # Run phpcbf to apply fixes to changed files (Compares to main branch). ``` -------------------------------- ### Run Kulturkortet tests Source: https://github.com/helsingborg-stad/municipio/blob/main/library/Kulturkortet/readme.md Command to execute PHPUnit tests for the Kulturkortet library. ```bash ./vendor/bin/phpunit library/Kulturkortet ``` -------------------------------- ### Configuring file handling filters Source: https://github.com/helsingborg-stad/municipio/blob/main/library/ImageConvert/README.md Manage supported MIME types and maximum source file size limits. ```php add_filter('Municipio/ImageConvert/MimeTypes', function($types) { $types[] = 'image/avif'; // Add AVIF support return $types; }); ``` ```php add_filter('Municipio/ImageConvert/MaxSourceFileSize', function() { return 1024 * 1024 * 10; // 10MB limit }); ``` -------------------------------- ### Enable BEM template version Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Filter to enable preview of version 3 views using BEM formatting. ```php add_filter('Modularity/Module/TemplateVersion3', function(){return true;}); ``` -------------------------------- ### Configuring performance and caching filters Source: https://github.com/helsingborg-stad/municipio/blob/main/library/ImageConvert/README.md Adjust cache expiry durations and lock timeouts for image processing. ```php add_filter('Municipio/ImageConvert/FailedCacheExpiry', function() { return 3600; // Cache failures for 1 hour instead of 24 hours }); ``` ```php add_filter('Municipio/ImageConvert/SuccessCacheExpiry', function() { return 7 * 24 * 3600; // Cache success for 1 week }); ``` ```php add_filter('Municipio/ImageConvert/LockExpiry', function() { return 600; // 10 minute lock timeout }); ``` ```php add_filter('Municipio/ImageConvert/PageCacheExpiry', function() { return 1800; // 30 minutes }); ``` -------------------------------- ### Retrieve a Mirrored Post via URL Source: https://github.com/helsingborg-stad/municipio/blob/main/library/MirroredPost/readme.md Use the p and fetch_from_blog query parameters to display a post from a different blog within the multisite network. ```text https://blog-b.example.com/?p=123&fetch_from_blog=456 ``` -------------------------------- ### Configure Visma federated login constants Source: https://github.com/helsingborg-stad/municipio/blob/main/library/Kulturkortet/MunicipioAuth/readme.md Define these constants to establish the connection with the Visma authentication service. ```php define('VISMA_AUTH_CUSTOMERKEY', '...'); define('VISMA_AUTH_SERVICEKEY', '...'); define('VISMA_AUTH_BASEURL', 'https://...'); ``` -------------------------------- ### Configure Vitec API constants Source: https://github.com/helsingborg-stad/municipio/blob/main/library/Kulturkortet/readme.md Recommended production configuration for Vitec API credentials. ```php define('VITEC_API_BASEURL', 'https://...'); define('VITEC_API_KEY', '...'); ``` -------------------------------- ### Implement the Hookable interface Source: https://github.com/helsingborg-stad/municipio/blob/main/library/HooksRegistrar/readme.md Create a class that implements the Hookable interface to define WordPress actions and filters. ```php register( $id, $nameSingular, $namePlural, $description, $supports, $icon, $plugin, $cacheTTL ); } } new \MyArticleModule\Article; ``` -------------------------------- ### Retrieve Posts from Multiple Sites via SQL Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/source/php/Module/Posts/Helper/GetPosts/__snapshots__/GetPostsFromMultipleSitesTest__testReturnsPostsFromMultipleSites with data set post type from schema__1.txt Used to fetch published posts from multiple site tables while filtering for specific metadata and ordering by sticky status and date. ```sql SELECT blog_id, post_id, post_date, is_sticky, post_title, post_modified, menu_order, user_group_visibility FROM ( SELECT DISTINCT '1' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (0) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_posts posts LEFT JOIN mun_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN () AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() UNION SELECT DISTINCT '2' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (0) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_2_posts posts LEFT JOIN mun_2_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN () AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() ) as posts WHERE user_group_visibility IS NULL ORDER BY is_sticky DESC, post_date DESC ``` -------------------------------- ### Define custom core templates Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Add custom template file names to the search list for core templates. ```php add_filter('Modularity/CoreTemplatesSearchTemplates', function ($templates) { $templates[] = 'my-custom-template'; return $templates; }); ``` -------------------------------- ### Retrieve feature code for LLM input Source: https://github.com/helsingborg-stad/municipio/blob/main/docs/utils/llm-prompt.md Use this command in the feature directory to concatenate all files and copy them to the clipboard. ```bash find . -type f -not -path '*/\.*' | while read -r file; do echo -e "\n=== File: $file ===\n"; cat "$file"; done | pbcopy ``` -------------------------------- ### Register custom modules with Modularity action Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Use the Modularity action hook to register custom modules when the core is loaded. ```php add_action('Modularity', function () { // Do your thing }); ``` -------------------------------- ### Enqueue assets for specific module Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Enqueue JavaScript or CSS files specifically for the add and edit pages of a given module. ```php add_action('Modularity/Module/mod-article/enqueue', function () { // Do your thing }); ``` -------------------------------- ### Theme view directory structure Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Visual representation of the bem-views directory hierarchy. ```text bem-views │ [Main folder for theme views, containing WordPress templates like page.blade.php] │ └───components │ │ [Components for the theme like card.blade.php] │ │ └───partials │ │ [Big chunks that are reused in templates footer.blade.php] │ │ └───templates │ [General templates that are included in main WordPress views like master.blade.php] │ │ └───utilities │ [Small pieces used by components like button.blade.php] │ │ └───widgets │ [Widgetized components] │ │ ``` -------------------------------- ### Configure WordPress constants Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Constants to be defined in wp-config.php to modify theme behavior, styleguide loading, and development settings. ```php define('MUNICIPIO_BLOCK_AUTHOR_PAGES', false); ``` ```php define('MUNICIPIO_STYLEGUIDE_URI', '//example.com/style/guide'); ``` ```php define('STYLEGUIDE_VERSION', 1.0.32); ``` ```php define('DEV_MODE', true); ``` ```php MUNICIPIO_BEM_THEME_NAME ``` -------------------------------- ### Register the Hookable object Source: https://github.com/helsingborg-stad/municipio/blob/main/library/HooksRegistrar/readme.md Instantiate the HooksRegistrar and register the Hookable object to activate the defined hooks. ```php register($myHookable); ``` -------------------------------- ### Enable Vertical Menu Sidebars Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Defines which sidebars should trigger the vertical menu display. ```php apply_filters('Municipio/Menu/Vertical/EnabledSidebars', $sidebars); ``` -------------------------------- ### Retrieve and Sort Posts from Multiple Sites Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/source/php/Module/Posts/Helper/GetPosts/__snapshots__/GetPostsFromMultipleSitesTest__testReturnsPostsFromMultipleSites with data set sort by menu order__1.txt This query aggregates posts from two different blog tables, applying a filter for visibility and sorting by sticky status and menu order. ```sql SELECT blog_id, post_id, post_date, is_sticky, post_title, post_modified, menu_order, user_group_visibility FROM ( SELECT DISTINCT '1' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (2) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_posts posts LEFT JOIN mun_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN ('custom_post_type') AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() UNION SELECT DISTINCT '2' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (2) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_2_posts posts LEFT JOIN mun_2_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN ('custom_post_type') AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() ) as posts WHERE user_group_visibility IS NULL ORDER BY is_sticky DESC, menu_order DESC ``` -------------------------------- ### SQL Query for Multi-Site Post Aggregation Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/source/php/Module/Posts/Helper/GetPosts/__snapshots__/GetPostsFromMultipleSitesTest__testReturnsPostsFromMultipleSites with data set custom count__1.txt Use this query to retrieve posts from multiple blog tables while filtering by post type, status, and visibility metadata. ```sql SELECT blog_id, post_id, post_date, is_sticky, post_title, post_modified, menu_order, user_group_visibility FROM ( SELECT DISTINCT '1' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (2) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_posts posts LEFT JOIN mun_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN ('custom_post_type') AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() UNION SELECT DISTINCT '2' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (2) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_2_posts posts LEFT JOIN mun_2_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN ('custom_post_type') AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() ) as posts WHERE user_group_visibility IS NULL ORDER BY is_sticky DESC, post_date DESC ``` -------------------------------- ### Filter Municipio/theme/key Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Filters the styleguide theme asset key. ```php apply_filters('Municipio/theme/key', $key); ``` -------------------------------- ### WordPress Widget Configuration Array Structure Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/source/php/Module/WpWidget/list.txt Defines the configuration schema for multiple WordPress widgets. Each key represents a widget type with its corresponding settings array. ```php array( 'archive' => array( 'title' => 'Title', //Text 'count' => '0', // Numeric boolean 'dropdown' => '' // Numeric boolean ), 'calendar' => array( 'title' => 'Title' ) 'categories' => array( 'title' => 'Title', 'count' => '0', // Numeric boolean 'hierarchical' => '0', // Numeric boolean 'dropdown' => '' // Numeric boolean ), 'meta' => array( 'title' => 'Title' ), 'pages' => array( 'title' => 'Title', 'sortby' => ('post_author', 'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt', 'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'), 'exclude' => '1,2' //Comma separated page id's ), 'comments' => array( 'title' => 'Title', 'number' => 5 //Number of comments to show ), 'recentposts' => array( 'title' => 'Title', 'number' => 5 //Number of posts to show ), 'rss' => array( 'title' => 'Title', 'url' => 5, //rss url atom/rss-xml, 'items' => 4, //Max number of items to show 'show_summary' => true, 'show_author' => true, 'show_date' => true ), 'search' => array( 'title' => 'Title' ), 'tag_cloud' => array( 'title' => 'Title', 'taxonomy' => 'post_tag' //Number of posts to show ), 'text' => array( 'title' => 'Title', 'text_content' => 'Lorem ipsum', 'filter' => true //Enable filters. ), ); ``` -------------------------------- ### Configure Module Refresh Interval Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Set the refresh interval in seconds for a module using data attributes. Requires the data-module-id attribute to be present. ```html
This content will get refreshed every 60 seconds.
``` -------------------------------- ### Filter oEmbed Markup Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Determines whether oEmbed markup should be processed for the HbgPrime video player. ```php apply_filters('Municipio/oembed/should_filter_markup', true, $url, $postId); ``` -------------------------------- ### Modularity/Display/AfterModule Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Filter the sidebar wrapper markup that appears after a module. ```APIDOC ## Filter: Modularity/Display/AfterModule ### Description Allows modification of the sidebar wrapper markup rendered after a module. ### Parameters - **$afterModule** (mixed) - The value to filter. - **$args** (array) - Arguments of the sidebar (e.g., before_widget). - **$moduleType** (string) - The module's type. - **$moduleId** (int|string) - The ID of the module. ``` -------------------------------- ### Retrieve Posts from Multiple Sites with Random Sorting Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/source/php/Module/Posts/Helper/GetPosts/__snapshots__/GetPostsFromMultipleSitesTest__testReturnsPostsFromMultipleSites with data set sort by random__1.txt This SQL query selects posts from two distinct site tables, joins them with post meta for visibility checks, and applies a random sort order. ```sql SELECT blog_id, post_id, post_date, is_sticky, post_title, post_modified, menu_order, user_group_visibility FROM ( SELECT DISTINCT '1' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (2) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_posts posts LEFT JOIN mun_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN ('custom_post_type') AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() UNION SELECT DISTINCT '2' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (2) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_2_posts posts LEFT JOIN mun_2_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN ('custom_post_type') AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() ) as posts WHERE user_group_visibility IS NULL ORDER BY is_sticky DESC, RAND() ``` -------------------------------- ### Modularity/Module/TemplatePath & Modularity/Theme/TemplatePath Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Modify the search paths for module or theme templates. ```APIDOC ## Filter: Modularity/Module/TemplatePath / Modularity/Theme/TemplatePath ### Description Modify or add paths where the system looks for module or theme templates. Useful for adding custom search paths. ### Parameters - **$paths** (array) - The array of template paths to filter. ``` -------------------------------- ### SQL Query for Multi-Site Post Aggregation Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/source/php/Module/Posts/Helper/GetPosts/__snapshots__/GetPostsFromMultipleSitesTest__testReturnsPostsFromMultipleSites with data set sort by modified__1.txt Retrieves posts from multiple site tables using a UNION operation, filtering by visibility and applying custom sorting logic. ```sql SELECT blog_id, post_id, post_date, is_sticky, post_title, post_modified, menu_order, user_group_visibility FROM ( SELECT DISTINCT '1' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (2) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_posts posts LEFT JOIN mun_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN ('custom_post_type') AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() UNION SELECT DISTINCT '2' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (2) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_2_posts posts LEFT JOIN mun_2_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN ('custom_post_type') AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() ) as posts WHERE user_group_visibility IS NULL ORDER BY is_sticky DESC, post_modified DESC ``` -------------------------------- ### Set sidebar compatibility for modules Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Restrict where a module can be dragged and dropped by defining sidebar compatibility. ```php add_filter('Modularity/Editor/WidthOptions', function ($moduleSpecification) { $moduleSpecification['sidebar_compability'] = array("content-area-top"); return $moduleSpecification; }); ``` -------------------------------- ### Modularity/Editor/ModuleCssScope Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Define unique appearance scopes for modules to allow CSS scoping. ```APIDOC ## Filter: Modularity/Editor/ModuleCssScope ### Description Allows editors to select a unique appearance for a module, adding a specific class to the module wrapper for CSS scoping. ### Parameters - **$scopes** (array) - Previously declared scopes. ``` -------------------------------- ### Define module CSS scopes Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Register unique appearance options for modules to allow CSS scoping via wrapper classes. ```php 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') ) ); }); ``` -------------------------------- ### Filter module width options Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Modify the available width options for modules in the editor. ```php add_filter('Modularity/Editor/WidthOptions', function ($options) { // Do your thing return $filteredValue; }); ``` -------------------------------- ### Retrieve and Sort Posts from Multiple Sites Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/source/php/Module/Posts/Helper/GetPosts/__snapshots__/GetPostsFromMultipleSitesTest__testReturnsPostsFromMultipleSites with data set sort by title__1.txt This query aggregates post data from two distinct site tables and filters results based on user group visibility and sticky status. ```sql SELECT blog_id, post_id, post_date, is_sticky, post_title, post_modified, menu_order, user_group_visibility FROM ( SELECT DISTINCT '1' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (2) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_posts posts LEFT JOIN mun_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN ('custom_post_type') AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() UNION SELECT DISTINCT '2' AS blog_id, posts.ID AS post_id, posts.post_date, posts.post_title, posts.post_modified, posts.menu_order, CASE WHEN posts.ID IN (2) THEN 1 ELSE 0 END AS is_sticky, postmeta2.meta_value AS user_group_visibility FROM mun_2_posts posts LEFT JOIN mun_2_postmeta postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = 'user-group-visibility' WHERE posts.post_type IN ('custom_post_type') AND posts.post_status IN ('publish') AND posts.post_date_gmt < NOW() ) as posts WHERE user_group_visibility IS NULL ORDER BY is_sticky DESC, post_title DESC ``` -------------------------------- ### Handle block save events Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Execute custom logic whenever a post or page containing a module block is created or updated. ```php add_action('Modularity/save_block', function ($block, $post) { // Your code here }); ``` -------------------------------- ### Add Taxonomy Tag Styles Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Applies custom CSS styles to taxonomy labels. ```php apply_filters('Municipio/taxonomy/tag_style', $style, $term, $taxonomy); ``` -------------------------------- ### Configure JWT and Cookie security constants Source: https://github.com/helsingborg-stad/municipio/blob/main/library/Kulturkortet/MunicipioAuth/readme.md Set these constants to manage the secure cookie name, JWT secret key, and expiration duration. ```php define('SECURE_MUNICIPIO_AUTH_COOKIE_NAME', 'secure_municipio_auth'); define('SECURE_MUNICIPIO_AUTH_JWT_KEY', 'a-string-secret-at-least-256-bits-long'); define('SECURE_MUNICIPIO_AUTH_EXPIRES_SECONDS_OPT', 60 * 60 * 24); ``` -------------------------------- ### Add option fields to Modularity Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Inject custom option fields into the Modularity options page. ```php add_action('Modularity/Options/Module', function () { echo ''; }); ``` -------------------------------- ### Clear ImageConvert Caches Source: https://github.com/helsingborg-stad/municipio/blob/main/library/ImageConvert/README.md Use these commands to flush or delete specific cache groups related to image conversion. ```php // Clear all ImageConvert caches wp_cache_flush(); // Or clear specific cache groups if your setup supports it wp_cache_delete_group('municipio_image_convert'); ``` -------------------------------- ### Modify template search paths Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Adjust the paths used to locate module or theme templates. Avoid unsetting existing paths to prevent display issues. ```php add_filter('Modularity/Module/TemplatePath', function ($paths) { return $paths; }); add_filter('Modularity/Theme/TemplatePath', function ($paths) { return $paths; }); ``` -------------------------------- ### Filter Municipio/author_display/name Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Sets the author name display string. ```php apply_filters('Municipio/author_display/name', $name, $userId); ``` -------------------------------- ### Modularity/Display/viewData Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Filter the data passed to the module view. ```APIDOC ## Filter: Modularity/Display/viewData ### Description Allows modification of the data array passed to the module view template. ### Parameters - **$viewData** (array) - The data array used in the view. ``` -------------------------------- ### Trigger Municipio/comment/save_like action Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Executes an action when a comment is liked or unliked. ```php do_action('Municipio/comment/save_like', $comment, $userId, $create); ``` -------------------------------- ### Modify post module slider arguments Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Adjust configuration settings for sliders used in Post Modules. ```php add_filter('Modularity/Module/Posts/Slider/Arguments', function ($args) { return $args; }); ``` -------------------------------- ### Filter Municipio/favicon_sizes Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Adds custom sizes to theme options for favicons. ```php apply_filters('Municipio/favicon_sizes', $sizes); ``` -------------------------------- ### Render views via REST API Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Fetch rendered HTML for a specific blade view using the REST API. ```typescript fetch('/wp-json/municipio/v1/view/render/partials/preloader') .then((response) => console.log(response)) ``` -------------------------------- ### Requesting images with custom dimensions Source: https://github.com/helsingborg-stad/municipio/blob/main/library/ImageConvert/README.md Use wp_get_attachment_image_src to request images by exact pixel dimensions or by constraining one dimension while preserving aspect ratio. ```php // Create a 100x100 pixel image wp_get_attachment_image_src($id, [100, 100]); // Create a 300px wide image, preserving aspect ratio wp_get_attachment_image_src($id, [300, false]); // Create a 200px tall image, preserving aspect ratio wp_get_attachment_image_src($id, [false, 200]); ``` -------------------------------- ### Include sub-view with data Source: https://github.com/helsingborg-stad/municipio/blob/main/guidelines.md Pass data to a sub-view to handle array expansion instead of accessing array items directly in the main view. ```blade @include('text', $array); ``` -------------------------------- ### Modularity/Module/Classes Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Modify the CSS classes applied to a module's main element. ```APIDOC ## Filter: Modularity/Module/Classes ### Description Allows adding or removing CSS classes from the module's main wrapper element. ### Parameters - **$classes** (array) - The current list of classes. - **$moduleType** (string) - The module type. - **$sidebarArgs** (array) - The sidebar's arguments. ``` -------------------------------- ### Filter Municipio/author_display/title Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Sets the title label for the author name display. ```php apply_filters('Municipio/author_display/title', $title); ``` -------------------------------- ### Filter PostObject instances Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Use this filter to modify or wrap the PostObject instance before it is returned by the factory. ```php add_filter('Municipio/DecoratePostObject', function(PostObjectInterface $postObject):PostObjectInterface { // Example: Add custom decorator or modify the post object return new MyCustomPostObjectDecorator($postObject); }); ``` -------------------------------- ### Filter Municipio/mobile_menu_breakpoint Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Modifies the CSS classes for the mobile hamburger menu breakpoint. ```php apply_filters('Municipio/mobile_menu_breakpoint', $classes); ``` -------------------------------- ### Municipio/DecoratePostObject Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md A WordPress filter hook that allows developers to modify or wrap the PostObject instance after it has been constructed. ```APIDOC ## Filter: Municipio/DecoratePostObject ### Description Filters the PostObject instance after it has been constructed and decorated. This allows for injecting additional behavior or properties into the post object. ### Parameters - **postObject** (\Municipio\PostObject\PostObjectInterface) - The decorated PostObject instance to be filtered. ### Return - **\Municipio\PostObject\PostObjectInterface** - The modified PostObject instance. ### Example ```php add_filter('Municipio/DecoratePostObject', function(PostObjectInterface $postObject):PostObjectInterface { return new MyCustomPostObjectDecorator($postObject); }); ``` ``` -------------------------------- ### Filter Municipio/ajax_url_in_head Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Sets the AJAX URL within the document head. ```php apply_filters('Municipio/ajax_url_in_head', $ajax_url); ``` -------------------------------- ### Modify post module date Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Customize the published date string displayed within Post Modules. ```php add_filter('Modularity/Module/Posts/Date', function ($date, $postId, $postType) { return $date; }); ``` -------------------------------- ### Modify module CSS classes Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Inject custom CSS classes into the main element of a module. ```php add_filter('Modularity/Module/Classes', function ($classes, $moduleType, $sidebarArgs) { $classes[] = 'example-class'; return $classes; }); ``` -------------------------------- ### Modify Singular Content Type Listing Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Appends or modifies items within the listing array for singular content types. ```php add_filter('Municipio/Controller/SingularContentType/listing', function($listing, $fields) { // Example modification to the listing array if (!empty($fields['custom_field'])) { $listing['custom_field'] = $fields['custom_field']; } return $listing; }, 10, 2); ``` -------------------------------- ### wp_get_attachment_image_src Source: https://github.com/helsingborg-stad/municipio/blob/main/library/ImageConvert/README.md Request an image with specific dimensions using the standard WordPress function, which is intercepted by ImageConvert. ```APIDOC ## wp_get_attachment_image_src ### Description Retrieves an image attachment source with custom dimensions. ImageConvert intercepts this call to generate the image on-demand based on the provided pixel dimensions. ### Usage ```php // Create a 100x100 pixel image wp_get_attachment_image_src($id, [100, 100]); // Create a 300px wide image, preserving aspect ratio wp_get_attachment_image_src($id, [300, false]); // Create a 200px tall image, preserving aspect ratio wp_get_attachment_image_src($id, [false, 200]); ``` ``` -------------------------------- ### Filter module sidebar wrapper Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Modify the HTML wrapper displayed before a module in the sidebar. ```php add_filter('Modularity/Display/BeforeModule', function ($beforeModule, $args, $moduleType, $moduleId) { // Do your thing return $filteredValue; }); ``` -------------------------------- ### Apply global view filter Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Use this filter to access the full array of data sent to a view after individual variable filters have been applied. ```php apply_filters('Municipio/viewData', $var); ``` -------------------------------- ### Display Table of Contents in Blade Views Source: https://github.com/helsingborg-stad/municipio/blob/main/library/Toc/readme.md Use the post object properties to conditionally render the TOC and display filtered content with injected anchor IDs. ```blade @if (!empty($post->tableOfContents)) {{-- Display table of contents --}} @endif {{-- Content automatically includes anchor IDs when TOC is enabled --}} {!! $post->postContentFiltered !!} ``` -------------------------------- ### Filter Municipio/Template/viewData Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Filters the view data passed to templates. ```php apply_filters('Municipio/Template/viewData', $viewData); ``` -------------------------------- ### Filter Search Result Components Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Applies filters to individual components of a search result, such as date, title, excerpt, and permalink. ```php apply_filters('Municipio/search_result/date', $date, $post); apply_filters('Municipio/search_result/title', $title, $post); apply_filters('Municipio/search_result/excerpt', $excerpt, $post); apply_filters('Municipio/search_result/permalink_url', $permalink_url, $post); apply_filters('Municipio/search_result/permalink_text', $permalink_text, $post); ``` -------------------------------- ### Filter Municipio/header_grid_size Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Modifies the CSS classes for header grid sizes. ```php apply_filters('Municipio/header_grid_size', $classes); ``` -------------------------------- ### Trigger Municipio/post/page/edit action Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Executes an action when editing a post in the WordPress admin area. ```php do_action('Municipio/post/page/edit', $postId, $postType); ``` -------------------------------- ### Filter Vertical Menu Items Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Defines the items visible in the vertical navigation menu. ```php apply_filters('Municipio/Menu/Vertical/EnabledSidebars', array(array('title' => 'Page section title', 'link' => '#anchorlink')); ``` -------------------------------- ### Trigger Municipio/share_post/recipients action Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Executes an action when a post is shared via email, typically for sending notifications. ```php do_action('Municipio/share_post/recipients', $user, $recipients); ``` -------------------------------- ### Filter Template viewData variants Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Provides specific filters for single and archive template view data based on post type. ```php apply_filters('Municipio/Template/single/viewData', $viewData, $postType); apply_filters('Municipio/Template/archive/viewData', $viewData, $postType, $template); apply_filters("Municipio/Template/{$postType}/viewData", $viewData); apply_filters("Municipio/Template/{$postType}/single/viewData", $viewData); apply_filters("Municipio/Template/{$postType}/archive/viewData", $viewData, $template); ``` -------------------------------- ### Modify Archive Sort Keys Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Adjusts the available sorting keys for archive pages. ```php apply_filters('Municipio/archive/sort_keys', $keys, $postType); ``` -------------------------------- ### Filter module display markup Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Modify the raw HTML markup generated for a module. ```php add_filter('Modularity/Display/Markup', function ($markup, $module) { return $markup; }); ``` -------------------------------- ### Filter Municipio/favicon_tag Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Modifies the HTML tag for the favicon. ```php apply_filters('Municipio/favicon_tag', $tag, $icon); ``` -------------------------------- ### Filter Municipio/logotype_tooltip Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Modifies the tooltip text for the logotype. ```php apply_filters('Municipio/logotype_tooltip', $tooltip); ``` -------------------------------- ### Filter module sidebar wrapper Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Use this filter to modify the wrapper markup after a module is rendered. ```php add_filter('Modularity/Display/AfterModule', function ($afterModule, $args, $moduleType, $moduleId) { // Do your thing return $filteredValue; }); ``` -------------------------------- ### Modify Content Type Schema Parameters Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Extends or modifies structured data (schema.org) attributes for a specific content type. ```php add_filter('Municipio/ContentType/schemaParams', function($schemaParams, $contentTypeKey) { if ($contentTypeKey === 'yourContentTypeKey') { $schemaParams['newParameter'] = [ 'schemaType' => 'Text', 'value' => 'Custom Value' ]; } return $schemaParams; }, 10, 2); ``` -------------------------------- ### Toggle Breadcrumbs Visibility Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Controls whether breadcrumbs are displayed on the page. ```php apply_filters('Municipio/Breadcrumbs', $bool, get_queried_object()) ``` -------------------------------- ### Change Admin Editor Stylesheet Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Overrides the URL for the stylesheet used in the WordPress admin editor. ```php apply_filters('Municipio/admin/editor_stylesheet', $url); ``` -------------------------------- ### Modify Archive Taxonomy Query Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Allows for the injection of additional taxonomy queries into the archive query. ```php apply_filters('Municipio/archive/tax_query', $taxQuery, $query); ``` -------------------------------- ### Filter Municipio/logotype_text Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Modifies the text displayed as the logo when no image is uploaded. ```php apply_filters('Municipio/logotype_text', $title); ``` -------------------------------- ### Apply Blade view filter Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Use this filter to intercept variables created in a controller based on their key. ```php apply_filters('Municipio/{{KEY}}', $var); ``` -------------------------------- ### Modify Archive Date Filter Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Updates the SQL WHERE clause used for date-based archive filtering. ```php apply_filters('Municipio/archive/date_filter', $where, $from, $to); ``` -------------------------------- ### Filter Municipio/logotype_class Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Modifies the CSS class attribute for the logotype. ```php apply_filters('Municipio/logotype_class', $classes); ``` -------------------------------- ### Filter module view data Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Modify the data array passed to module views. ```php add_filter('Modularity/Display/viewData',function($data) { //do something return $data; }); ``` -------------------------------- ### Filter Search Form Action Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Modifies the action URL of the search form. ```php apply_filters('Municipio/search_form/action', $url); ``` -------------------------------- ### Filter Municipio/blade/template_types Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Modifies the list of available Blade template types. ```php apply_filters('Municipio/blade/template_types', $types); ``` -------------------------------- ### Filter Breadcrumb Items Source: https://github.com/helsingborg-stad/municipio/blob/main/readme.md Modifies the array of items or links displayed within the breadcrumb navigation. ```php apply_filters('Municipio/Breadcrumbs/Items', $items, get_queried_object()); ``` -------------------------------- ### Filter specific module view data Source: https://github.com/helsingborg-stad/municipio/blob/main/Modularity/readme.md Modify the data array passed to a specific module type's view. ```php add_filter("Modularity/Display/mod-posts/viewData", function($data) { //do something return $data; }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.