Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter sam98brown

    (@sam98brown)

    Thanks for the help! Can you point me in the right direction for the documentation for this Data API? I can only find information on the REST API.

    I’ve implemented the code but when I change the category I just see the same taxonomy term ID returned:

    function limitBlocksBasedOnTaxes() {
    
    const unsubscribe = wp.data.subscribe(makeListener())
    
    }
    
    function makeListener() {
    
    let prevCategories
    
    return function updateAllowedBlockTypes() {
    
    const categories = wp.data.select('core/editor').getCurrentPost()[
    
    'article-category'
    
    ]
    
    console.log('categories', categories)
    
    if (categories === prevCategories) {
    
    return
    
    }
    
    prevCategories = categories
    
    const MY_CATEGORY = 4
    
    const MY_CATEGORY_ALLOWED_TYPES = ['core/paragraph']
    
    const currentTypes = wp.data
    
    .select('core/block-editor')
    
    .getSettings().allowedBlockTypes
    
    const nextTypes = categories.includes(MY_CATEGORY)
    
    ? MY_CATEGORY_ALLOWED_TYPES
    
    : true
    
    if (nextTypes !== currentTypes) {
    
    console.log('setting allowed block types to', nextTypes)
    
    wp.data.dispatch('core/block-editor').updateSettings({
    
    allowedBlockTypes: nextTypes,
    
    })
    
    }
    
    }
    
    }

    That console.log returns the same value any time I click a taxonomy term

    Thread Starter sam98brown

    (@sam98brown)

    Hi Jarno

    Here’s the console error:

    Uncaught ReferenceError: google is not defined
        <anonymous> https://mysite.six/wp-content/plugins/propertyhive-map-search/assets/js/ph-map-search.js?ver=1.1.31:586
    ph-map-search.js:586:1

    This file calls the function:
    propertyhive_init_map

    Is this any help?

    • This reply was modified 2 years, 6 months ago by sam98brown.
    Thread Starter sam98brown

    (@sam98brown)

    Hey Jarno

    Thanks for the help here.

    Does the Google Maps service need to be enabled for this to work? I’ve cleared my custom integration and set this file up in mu-plugins but no luck. The file is definitely running as I ran a die(); command to check.

Viewing 3 replies - 1 through 3 (of 3 total)