Author: Per Thykjaer Jensen

  • Gutenberg Blocks Markup Cheat Sheet

    I created a WP theme from scratch. Here I followed the fine tutorial by Carolina Nymark.

    Here is a cheat sheet with some of the common blocks in Gutenberg.

    Gutenberg Blocks Cheat Sheet

  • Tutorial: How to Modify a WordPress 6.* Style

    Tutorial: How to Modify a WordPress 6.* Style

    This tutorial is based on the most recent standard theme for WordPress (WP): Twenty Twenty Four. However, the principles should work for any block-based WP theme.

    Select a relevant style

    Select a style
    Select one of the styles in Appearance / Styles. I used Rust for this tutorial.

    Modify the style

    Now you can modify your style. In my case there was a lot of irrelevant information in the header and footer templates. I removed the unwanted informations on the frontpages template too.

    You can edit the header and footer in Appearance / Edit / Patterns / Header

    How to edit all headers in one go
    There is only one header here. This template pattern is used in many places. So if we edit this header, we will edit all headers in the active style.

    In my case the colors were reversed in the header and footer, so that the background was dark and the text was made in a contrasting color. The links were changed too, since they would disaapear with this new background.

    Header in new colors in the Rust style.

    Here you see the header with reversed colors from the theme.

    In this case a worked on a local computer, but you could work in a staging environment too. Now when the work with the styling is finished it is possible to export the entire theme and upload it to your webserver.

    Export the theme

    Under Appearance / Edit / Styles you can click the pen.

    Then click the three dots icon found in the top right corner.

    The menu to the right should appear.

    Now you can export the theme. Click on Export. The file will be downloaded to your Downloads directory on the computer.

    Fonts

    I have tried to add fonts, but this experiment is only a partial success! You can see the fonts in the editor, and sometimes use the additional fonts with the blocks.

    Permanent Marker works fine when my petj_rust style is enabled [this sample will only work as long as I use the petj_RUST style] 😉

    However, if I try to add the costum font to a heading, the style is overruled!

    Even a custom CSS !important clause is ignored by the theme. Perhaps this is a bug in Twenty Twenty Four?

    Code sample.

    The Theme Zip

    If you open the zip file you’ll see the standard Twenty Twendty Four files. In the styles folder you can see a series of JSON files, one for each of the styles. If you want to have your own styles you can copy the rust.json file and give it a new name, e.g.

    aGoodName.json

    You can modify the JSON inside the file. A good start is to rename the theme name and add a description in the key value pairs, e.g. like this in your favorite editor:

    "$schema": "https://schemas.wp.org/trunk/theme.json",
    "version": 2,
    "title": "PETJ Rust",
    "description": "Multimusen's take on the RUST style.",

    Save the JSON file, and yo are ready to go.

    Tweaking All Styles

    You can tweak all the styles in the JSON:

    • Colors
    • Fonts
    • Duotones
    • Blocks

    But this has been covered in some of my other tutorials. You can even select to block other users from changing the palettes and similar settings.

    Then you are ready for the final step in WP.

    Read Carolina Nymark’s article about theme.json.

    Upload the Theme Files.

    Now you can upload the revided theme to WP. Here I’d prefer to upload to the web host via Filezilla. If Twenty Twenty Four is installed, just upload and overwrite the files.

    Filezilla in the local directory with Twenty Twnety Four. And pointing to a similar folder in the directory:

    wp_content/themes/twentytwentyfour/

    The result

    Now that’s all it takes to tweak a style. After the upload the theme will look exactly like what you did with the tweaks. Even headers and footers will look like your local version of the WP JSON Style.

    Here is the final result, a new styled theme for Multimusen.dk:

    This is what MUltimusen.dk looks like after the tweaks.

    Upload the Files to Github

    Since the work is done you can upload your new tweaked theme to a github repository. Here is my repo: https://github.com/asathoor/petj-twentytwentyfour

    That’s all folks!

    The game’s afoot, Watson!

    Sherlock Holmes

  • WordPress: How to Style a Block Theme

    WordPress: How to Style a Block Theme

    Quick and Dirty Start

    As a quick and dirty start you can copy either the theme.json file or one of the additional styles in the ./styles folder of the theme in Twenty Twenty Four. Save your file as ./styles/myFile.json. The styles are:

    • ember.json
    • fossil.json
    • ice.json
    • maelstrom.json
    • mint.json
    • onyx.json
    • rust.json

    Since these files are more simple than theme.json in the root directory of the theme, they are good starting points for developing your personalized theme styles.

    Choose a style that is somewhat close to the endresult you want to acheive. Then you’ll have a good starting point for your design.

    Give your style a title

    First you have to add the title to the file. As soon as the json file is present in ./styles you will be able to activate it in the Dashboard / Appearance / Styles.

    {
    	"$schema": "https://schemas.wp.org/trunk/theme.json",
    	"version": 2,
    	"title": "My new style",
    	"settings": { 
             ... etc ...

    If you work in a copy of the theme.json file, remember to add the “title” : “My Way” key pair. The original theme json is more elaborate than the sample styles, since all blocks are controlled by the file. If you want to create your own theme this may be a good way to work.

    If you’re like me it may be more easy to edit the file in your favorite editor, and upload the file to WP. Now you should be able to see your style in Appearance / Editor / Styles:

    In the WP theme directory ./styles you’ll find the *.json files that will style your theme. They are similar the theme.json file. In my experience the colors are easy to work with. However, fonts can be a challenge.

    If you tamper with the theme.json file problems may arise if you update the theme. Your best option is to add a style in the ./styles directory. Here your code is safe – so in many ways this modus operandi is similar to the child themes that were used before we had the block based themes.

    Below are some notes on how to style with fonts and colors – and other CSS features.

    Fonts

    The best way to add custom fonts is to download the font from either Google Fonts or another font provider and then use the files after this model:

    • First you add the fontface with the filenames.
    • Then you can instantiate the font by the triad
    • fontfamily, name and slug.

    The slug will create CSS-variables. You can use these variables when the block elements are styled. More about this later.

    Font File Format: .woff2

    According to Carolina Nymark you should use font files in the woff2 format:

    “If you choose a font family on https://fonts.google.com/ and then select the “Download family” option, you will only receive a zip file with .ttf files. To get the .woff2 files, you can use a font converter script or an online converter.”

    “I recommend using this time saving tool called Google webfonts helper to download the files.”

    (Carolina Nymark)

    Actually I’ve had strange font problems, perhaps Nymark’s solution is the solution. Sometimes the fonts do not appear no matter what you try. However, now I see that the fonts that gave me problems were actually ttf and odt files. I’ll test this solution and try to use woff2 exclusively.

    /** Model: font via a file */
    
    {
        "fontFace": [
            {
                "fontFamily": "Jost",
                "fontStyle": "normal",
                "fontWeight": "100 900",
                "src": ["file:./assets/fonts/jost/Jost-VariableFont_wght.woff2"]
            }
        ],
        "fontFamily": "\"Jost\", sans-serif",
        "name": "Jost",
        "slug": "body"
    }
    
    /** Model: standard browser fonts */
    
    /* Sans Serif */
    {
        "fontFamily": "-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif",
        "name": "System Sans-serif",
        "slug": "system-sans-serif"
    }
    
    /* Serif */
    {
        "fontFamily": "Iowan Old Style, Apple Garamond, Baskerville, Times New Roman, Droid Serif, Times, Source Serif Pro, serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol",
        "name": "System Serif",
        "slug": "system-serif"
    }
    
    

    Using the Fonts

    Mostly the font will not show up after install, which is quite frustrating. Do thus:

    1. Quit the styles editor
    2. Purge the browser cache
    3. Purge the WP cache
    4. See the webpage frontend – if the font is now visible everything is ok.
    5. Return to the editor.
    6. Now you can see the font.

    It’s quite cumbersome, and may take a lot of experiments.

    Perhaps a good idea is to use an incognito browser window in order to avoid browser cache issues.

    How to Add Standard Browser Fonts

    Standard fonts are more easy to add. Here is the model for serif and sans serif fonts with the most common fallbacks:

    /* Sans Serif */
    {
        "fontFamily": "-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif",
        "name": "System Sans-serif",
        "slug": "system-sans-serif"
    }
    
    /* Serif */
    {
        "fontFamily": "Iowan Old Style, Apple Garamond, Baskerville, Times New Roman, Droid Serif, Times, Source Serif Pro, serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol",
        "name": "System Serif",
        "slug": "system-serif"
    }

    Colours

    The colours are straightforeward. Add the colours as an array:

    "color": {
        "palette": [
            {
                "color": "#548DBF",
                "name": "Base",
                "slug": "base"
            },
            {
                "color": "#0367A6",
                "name": "Base / Two",
                "slug": "base-2"
            }
        ]

    How to Style the Blocks

    In the JSON file we can style the elements (aka. Blocks) in the elements section.

    How do we implement the fonts and styles in the blocks? Here is a typical sample: styling the button block. Other blocks are styled in a similar manner.

    WordPress will create CSS-variables from your JSON-file after this model:

    var( –wp–preset–CSSSLUG )

    for example:

    var(–wp–preset–font-family–heading)

    Below you see the styling of a button by JSON. The example below will define the:

    • Border
    • Color
    • Spacing (whitespace: padding etc.)
    • Typography (fontfamily, fontsize, etc.)
    • :hover (that’s the way to use pseudo classes

    In Practise: Styling the Buttons

    Now a button is a fairly typical block. If you can style a button, you know how to style any block.

    "elements": {
        "button": {
            "border": {
                "radius": "6px"
            },
            "color": {
                "background": "var(--wp--preset--color--contrast)",
                "text": "var(--wp--preset--color--base-2)"
            },
            "spacing": {
                "padding": {
                    "bottom": "0.98rem",
                    "left": "1.6rem",
                    "right": "1.6rem",
                    "top": "0.8rem"
                }
            },
            "typography": {
                "fontFamily": "var(--wp--preset--font-family--heading)",
                "fontSize": "var(--wp--preset--font-size--small)",
                "fontStyle": "normal"
            },
            ":hover": {
                "color": {
                    "background": "var(--wp--preset--color--contrast)"
                }
            }
        }

    Let’s break down this code a little bit. I have cut out the samples from the code above.

    Give the Button Colours

    Here is the :hover pseudo style for our button. A color is defined when the mouse pointer hover over the button. The same principle will work for :link, :active, :hover and so on. In this case the color that will be used is contrast:

    ":hover": {
        "color": {
            "background": "var(--wp--preset--color--contrast)"
        }
    }

    How to add a font

    We can add fonts after a similar manner. The CSS wee need is font-family. So we use –wp–preset–font-family. To the variable we’ll have to add the slug of the selected font which is heading. Now we have constructed the variable:

    var(–wp–preset–font-family–heading)

    Here is a sample for the site-title block:

    "core/site-title": {
        "typography": {
            "fontFamily": "var(--wp--preset--font-family--heading)"
        }
    }

    Blocks in TT4

    Now we have seen how to style one block. Here is a list of styled blocks in the theme.json of TT4, so if you want a deeper study have a look at them, since this article only mentioned “core/button”:

    “core/avatar”: {
    “core/button”: {
    “core/buttons”: {
    “core/calendar”: {
    “core/categories”: {
    “core/code”: {
    “core/comment-author-name”: {
    “core/comment-content”: {
    “core/comment-date”: {
    “core/comment-edit-link”: {
    “core/comment-reply-link”: {
    “core/post-comments-form”: {
    “core/comments-pagination”: {
    “core/comments-pagination-next”: {
    “core/comments-pagination-numbers”: {
    “core/comments-pagination-previous”: {
    “core/footnotes”: {
    “core/gallery”: {
    “core/image”: {
    “core/list”: {
    “core/loginout”: {
    “core/navigation”: {
    “core/post-author”: {
    “core/post-author-name”: {
    “core/post-date”: {
    “core/post-excerpt”: {
    “core/post-featured-image”: {
    “core/post-terms”: {
    “core/post-title”: {
    “core/pullquote”: {
    “core/query-title”: {
    “core/query-no-results”: {
    “core/quote”: {
    “core/search”: {
    “core/separator”: {
    “core/site-tagline”: {
    “core/site-title”: {

    The list above was made via a simple Bash command in a terminal window on a Mac or Linux system, that will filter out any string that contains core/:

    # grep “core/” theme.json

    With this information we should be able to style most of the Gutenberg blocks. Here is an even more extensive list of the Gutenberg blocks: click here.

  • Research: Styling OpenStreetMap

    Research: Styling OpenStreetMap

    (this article is work in progress …)

    I often wondered whether you could create your own styles for OpenStreetMap by some CSS and avoid commercial solutions like Mapbox.

    Here are the links to resources about OpenStreetMap and how to style the maps on web pages.

    Leaflet Styles

    Leaflet is a cool JavaScript / CSS library for adding markers, popups and similar to OpenStreetMap maps. Since the library has a CSS library, you could tweak the setings by additional CSS after the link to the Leaflet CSS. E.g.:

    <link 
            rel="stylesheet" 
            href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
            integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
            crossorigin=""/>
    <style>
      /** tweak something here ... see below */
    </style>

    Here are the typical Leaflet Styles: see it here.

    If we look into these styles an alternative CSS could be added, eg.:

    /* visual tweaks */
    .leaflet-container {
    	background: #ddd;
    	outline-offset: 1px;
    	}

    In the we should be able to tweak a map and change the background color hex to somethig different here.

    Since Leaflet has tweaks to font styles you could change the look and feel of things here.

  • Web Summit Lisbon 2023

    Web Summit Lisbon 2023

    Map


    Hotels and Venue

    Chiado Apartments (Apartment)
    83 Rua do Alecrim, Misericorda
    Lisbon

    Solar dos Poetas (Hotel)
    Rua da Horta Seca nº11
    1200-221 Lisbon

    WebSummit Venue
    Altice Arena and FIL
    Rossio dos Olivais
    1990-231 Lisbon
    Web: https://websummit.com/

    Registration At the airport: 
    Terminal 1 of Humberto Delgado Airport (also known as Lisbon Portela Airport), Alameda das Comunidades Portuguesas, 1700-111 Lisboa, Portugal

    Lisbon

    https://websummit.com/discover-lisbon

    Lufthavnsbus 912x

    Aarhus – Billund

    https://www.midttrafik.dk/media/29087/k%C3%B8replan_912x_k23-ua.pdf

  • Creative with MaKey MaKey and JavaScript

    Creative with MaKey MaKey and JavaScript

    The Makey Makey is a credit card sized mini keyboard. You can create all sorts of buttons or keyboards and use anything that can conduct electricity.

    In this video you will learn to fire off a JavaScript function whenever a button is pushed.

  • Protected: C test

    This content is password protected. To view it please enter your password below:

  • Add an image hover effect in WordPress by a Custom HTML Block

    Add an image hover effect in WordPress by a Custom HTML Block

    What We Try To Do

    Please hover your mouse over the image below.

    The Code We Need

    Here is the kind of code that we need in order to develop this effect:

    
    <!-- In the Custom HTML Block -->
    <!-- add styles first -->
    <style>
    #foto {
      width: 200px;
      height: 200px;
      border: 1px solid red;
      background: pink;
      background-image: url('https://woo.thoth.dk/wp-content/uploads/2023/08/beanie-with-logo-1-600x600.jpg');
      background-size: cover;
    }
    #foto:hover {
      width: 200px;
      height: 200px;
      border: 1px solid blue;
      background: blue;
      background-image: url('https://woo.thoth.dk/wp-content/uploads/2023/08/hoodie-with-zipper-2-600x600.jpg');
        background-size: cover;
    }
    <style>
    <!-- then add the HTML -->
    <div id="foto"></div>
    
    

    Avoid Blank Lines

    Note the ugliness of the code above. No indentations. No whitespace. Unfortunately there is a reason for this mess.

    The reason is this: WP will add stray <p> tags to the code, if whitespace is present. This is utterly destructive to scripts and styles. However, the cure is simple: don’t add any blank lines to the HTML block!

    I hope that WP will correct this in the future – and give us colored syntax. We could use better code editing options. To be honest, I don’t edit this kind of code in WordPress. I write my code in an editor, like Nano, Visual Studio Code or Atom.

    As soon as the code does the trick, I copy paste the code to WP.

  • How to pull new code from origial repository to a local forked repository

    How to pull new code from origial repository to a local forked repository

    In this thread on Stackoverflow you’ll find an easy method to pull new/updated code from an original repository to your local fork:

    # Add this in a terminal in the relevant directory:
    git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
    git fetch upstream
    
    # then: (like "git pull" which is fetch + merge)
    git merge upstream/master master
    
    # or, better, replay your local work on top of the fetched branch
    # like a "git pull --rebase"
    git rebase upstream/master

    After adding the upstream you only have to run the merge or rebase command now and then – whenever you know or suppose that the code was updated.

  • Crash Introduction: Woocommerce REST API

    Crash Introduction: Woocommerce REST API

    Tutorial: Woocommerce REST API.

    Woocommerce REST API

    Here is a short introduction to the Woocommerce REST API. In the tutorial you will learn how to present a product list from the REST API on any HTML page. If you want to create your own markup that does not depend on the limited Woocommerce blocks in the editor the REST API will open endless possibilities.

    Sample Code on Github

    The code from the tutorial is available on Github:

    Questions and Comments

    If you have comments or suggestions for new videos about the subject please let me know in the comments below.

  • Reversed Engineering

    Reversed Engineering

    Hvordan du kan udvikle en Figma-prototype ved at undersøge mulighederne i WP.

    Blokke i Woocommerce

    Der findes et meget stort antal blocks i Woocommerce. Denne artikel viser de fleste. Der findes desuden mange plugins og patterns, der giver yderligere muligheder.

    Når du skal udvikle et design i WP, så kan “reversed engineering” være en rigtig god ide. Før du designer noget, så må du vide, hvordan de enkelte blocks ser ud og hvilke indstillingsmuligheder der er i dit theme – herunder hvor custom HTML / CSS kan blive nødvendig.

    Øvelse

    Lav en side, der simpelt hen lister de enkelte blocks, sådan som de ser ud i dit theme.

    1. Lav en side med samtlige blocks, som du får brug for i dit design.
    2. Inddel dine designs i groups.
    3. Gem disse groups som genbrugelige patterns.

    Dette er ikke en layout-opgave; men derimod en opgave, der handler om at finde ud, hvordan de enkelte blocks ser ud, således at du kan genskabe dem i Figma.

    Reversed engineering handler om at arbejde ud fra det som er kendt. Det er lidt som at designe med Lego-klodser, der jo har en forud defineret form.

    Eksempel

    Herunder er et eksempel på en liste, der kan bruges til Figma reversed engineering.


    Søgning

    Håndplukkede varer

    Minikurv

    Blokgrupper fra Woocommerce

    Pladsholderbillede der skal repræsentere en vare, der bliver vist i en hero-sektion. 1 ud af 2.

    The Fall Collection

    With high-quality materials and expert craftsmanship, our products are built to last and exceed your expectations.

    Quality Materials

    We use only the highest-quality materials in our products, ensuring that they look great and last for years to come.

    Expert Craftsmanship

    Our products are made with expert craftsmanship and attention to detail, ensuring that every stitch and seam is perfect.

    Unique Design

    From bold prints and colors to intricate details and textures, our products are a perfect combination of style and function.

    Customer Satisfaction

    Our top priority is customer satisfaction, and we stand behind our products 100%.

    Pladsholderbillede der skal repræsentere en vare, der bliver vist i en hero-sektion. 2 ud af 2.

    Dine blokgrupper

    Du kunne måske være interesseret i…

    Din kurv er lige nu tom!

    Gennemse webshop


    Ny i webshop

    Etc. etc.

    Fortsæt ind til du har et passende antal varer. Se evt. hvordan templates, som shop / butik opgygger groups og patterns, når varer præsenteres.

  • Easy SMTP på Simply.com

    Easy SMTP på Simply.com

    Her er en vejledning til opsætning af email på Simply.com sites – nyttig når fx WordPress / WooCommerce skal sættes korrekt op.

    Video: WP Easy SMPT (email-settings)
Enable Notifications OK No thanks

We use cookies - more information

Multimusen.dk will set a few cookies from Doubleclick, Google and the Social Media plugins they ay set some cookies. Some of my pages use APIs - such as YouTube, LinkedIn, Google Fonts, Google Maps, Mapbox, Spotify, Jetpack, Twitter, Facebook &c.. Such plugins may set the odd cookie.

Close