├── .distignore ├── .editorconfig ├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── continuous-integration-lint-php.yml │ ├── deploytowp.yml │ ├── lint-css-js-md.yml │ ├── upateassets.yml │ └── upload-asset-on-release.yml ├── .gitignore ├── .nvmrc ├── .phpcs.xml.dist ├── .stylelintrc.json ├── .wordpress-org ├── icon-128x128.png ├── icon-256x256.png └── screenshot-1.png ├── LICENSE ├── block.json ├── classic-menu-block.php ├── composer.json ├── composer.lock ├── package-lock.json ├── package.json ├── readme.md └── src ├── block.js ├── edit.js ├── editor.scss ├── index.js ├── style.scss └── use-navigation-entities.js /.distignore: -------------------------------------------------------------------------------- 1 | # A set of files you probably don't want in your WordPress.org distribution 2 | .distignore 3 | .editorconfig 4 | .git 5 | .gitignore 6 | .gitlab-ci.yml 7 | .travis.yml 8 | .DS_Store 9 | .nvmrc 10 | .stylelintrc.json 11 | .wordpress-org 12 | composer.json 13 | composer.lock 14 | Thumbs.db 15 | behat.yml 16 | bitbucket-pipelines.yml 17 | bin 18 | vendor 19 | .circleci/config.yml 20 | .github 21 | Gruntfile.js 22 | package.json 23 | package-lock.json 24 | phpunit.xml 25 | phpunit.xml.dist 26 | phpunit-multisite.xml.dist 27 | multisite.xml 28 | multisite.xml.dist 29 | .phpcs.xml 30 | phpcs.xml 31 | .phpcs.xml.dist 32 | phpcs.xml.dist 33 | wp-cli.local.yml 34 | yarn.lock 35 | tests 36 | node_modules 37 | *.sql 38 | *.tar.gz 39 | *.zip 40 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs 2 | # editorconfig.org 3 | 4 | # WordPress Coding Standards 5 | # https://make.wordpress.org/core/handbook/coding-standards/ 6 | 7 | root = true 8 | 9 | [*] 10 | charset = utf-8 11 | end_of_line = lf 12 | insert_final_newline = true 13 | trim_trailing_whitespace = true 14 | indent_style = tab 15 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: spacedmonkey 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: composer 9 | directory: '/' 10 | schedule: 11 | interval: weekly 12 | open-pull-requests-limit: 10 13 | labels: 14 | - Dependencies 15 | - PHP 16 | - package-ecosystem: npm 17 | directory: '/' 18 | schedule: 19 | interval: weekly 20 | open-pull-requests-limit: 15 21 | labels: 22 | - Dependencies 23 | - JavaScript 24 | - package-ecosystem: "github-actions" 25 | directory: "/" 26 | schedule: 27 | interval: "daily" 28 | open-pull-requests-limit: 10 29 | groups: 30 | github-actions: 31 | patterns: 32 | - "*" 33 | -------------------------------------------------------------------------------- /.github/workflows/continuous-integration-lint-php.yml: -------------------------------------------------------------------------------- 1 | name: PHP Lints 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - release/* 8 | pull_request: 9 | 10 | jobs: 11 | lint-php: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v4 16 | 17 | - name: Setup PHP 18 | uses: shivammathur/setup-php@v2 19 | with: 20 | php-version: '7.4' 21 | coverage: none 22 | tools: composer, cs2pr 23 | 24 | - name: Get Composer cache directory 25 | id: composer-cache 26 | run: echo "::set-output name=dir::$(composer config cache-files-dir)" 27 | 28 | - name: Setup Composer cache 29 | uses: pat-s/always-upload-cache@v3.0.11 30 | with: 31 | path: ${{ steps.composer-cache.outputs.dir }} 32 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 33 | restore-keys: | 34 | ${{ runner.os }}-composer- 35 | ${{ runner.os }}- 36 | 37 | - name: Validate composer.json 38 | run: composer --no-interaction validate --no-check-all 39 | 40 | - name: Install dependencies 41 | run: composer install --prefer-dist --no-suggest --no-progress --no-interaction 42 | 43 | - name: Detect coding standard violations (PHPCS) 44 | run: vendor/bin/phpcs -q --report=checkstyle --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | cs2pr --graceful-warnings 45 | -------------------------------------------------------------------------------- /.github/workflows/deploytowp.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to WordPress.org 2 | on: 3 | push: 4 | tags: 5 | - '**' 6 | jobs: 7 | tag: 8 | name: New tag 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@main 12 | 13 | - name: Setup PHP 14 | uses: shivammathur/setup-php@v2 15 | with: 16 | php-version: '7.4' 17 | coverage: none 18 | tools: composer 19 | 20 | - name: Setup Node 21 | uses: actions/setup-node@v4.0.2 22 | with: 23 | node-version-file: '.nvmrc' 24 | cache: npm 25 | 26 | - name: Validate composer.json and composer.lock 27 | run: composer validate 28 | 29 | - name: Get Composer Cache Directory 30 | id: composer-cache 31 | run: echo "::set-output name=dir::$(composer config cache-files-dir)" 32 | 33 | - name: Cache Composer vendor directory 34 | uses: actions/cache@v4 35 | with: 36 | path: ${{ steps.composer-cache.outputs.dir }} 37 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 38 | restore-keys: | 39 | ${{ runner.os }}-composer- 40 | 41 | - name: Install PHP Dependencies 42 | run: composer install --prefer-dist --no-progress --no-dev --optimize-autoloader --no-interaction 43 | 44 | - name: Install dependencies 45 | run: npm ci 46 | 47 | - name: Build plugin 48 | run: npm run build 49 | 50 | - name: WordPress Plugin Deploy 51 | uses: 10up/action-wordpress-plugin-deploy@stable 52 | env: 53 | SLUG: ${{ secrets.SLUG }} 54 | SVN_USERNAME: ${{ secrets.SVN_USERNAME }} 55 | SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} 56 | -------------------------------------------------------------------------------- /.github/workflows/lint-css-js-md.yml: -------------------------------------------------------------------------------- 1 | name: Lint CSS/JS 2 | 3 | on: 4 | push: 5 | # Only run if CSS/JS/MD-related files changed. 6 | paths: 7 | - '**.js' 8 | - '**.cjs' 9 | - '**.css' 10 | - 'packages/**/*.md' 11 | - '.eslint*' 12 | - '.markdownlint*' 13 | - '.npmpackagejsonlintrc.json' 14 | - '.nvmrc' 15 | - '.prettier*' 16 | - '.stylelint*' 17 | - '**/package.json' 18 | - 'package-lock.json' 19 | branches: 20 | - main 21 | - release/* 22 | pull_request: 23 | # Only run if CSS/JS/MD-related files changed. 24 | paths: 25 | - '**.js' 26 | - '**.cjs' 27 | - '**.css' 28 | - 'packages/**/*.md' 29 | - '.eslint*' 30 | - '.markdownlint*' 31 | - '.npmpackagejsonlintrc.json' 32 | - '.nvmrc' 33 | - '.prettier*' 34 | - '.stylelint*' 35 | - '**/package.json' 36 | - 'package-lock.json' 37 | 38 | # Cancels all previous workflow runs for pull requests that have not completed. 39 | concurrency: 40 | # The concurrency group contains the workflow name and the branch name for pull requests 41 | # or the commit hash for any other events. 42 | group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} 43 | cancel-in-progress: true 44 | 45 | jobs: 46 | lint: 47 | name: Lint 48 | runs-on: ubuntu-latest 49 | timeout-minutes: 10 50 | steps: 51 | - name: Checkout 52 | uses: actions/checkout@v4 53 | 54 | - name: Setup Node 55 | uses: actions/setup-node@v4.0.2 56 | with: 57 | node-version-file: '.nvmrc' 58 | cache: npm 59 | 60 | - name: Install dependencies 61 | run: npm ci 62 | 63 | - name: JS Lint 64 | run: npm run lint:js 65 | 66 | - name: Markdown Lint 67 | run: npm run lint:md:docs 68 | 69 | - name: CSS Lint 70 | run: npm run lint:css 71 | -------------------------------------------------------------------------------- /.github/workflows/upateassets.yml: -------------------------------------------------------------------------------- 1 | name: Asset update 2 | on: 3 | push: 4 | branches: 5 | - main 6 | jobs: 7 | main: 8 | name: Push to main 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@main 12 | - name: WordPress.org asset update 13 | uses: 10up/action-wordpress-plugin-asset-update@stable 14 | env: 15 | SLUG: ${{ secrets.SLUG }} 16 | SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} 17 | SVN_USERNAME: ${{ secrets.SVN_USERNAME }} 18 | -------------------------------------------------------------------------------- /.github/workflows/upload-asset-on-release.yml: -------------------------------------------------------------------------------- 1 | name: Package Plugin 2 | 3 | on: 4 | release: 5 | types: 6 | - created 7 | - updated 8 | 9 | jobs: 10 | build: 11 | name: On Release 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v4 16 | 17 | - name: Setup PHP 18 | uses: shivammathur/setup-php@v2 19 | with: 20 | php-version: '7.4' 21 | coverage: none 22 | tools: composer, cs2pr 23 | 24 | - name: Setup Node 25 | uses: actions/setup-node@v4.0.2 26 | with: 27 | node-version-file: '.nvmrc' 28 | cache: npm 29 | 30 | - name: Setup Workflow Context 31 | id: workflow 32 | working-directory: ${{ runner.temp }} 33 | env: 34 | REPO: ${{ github.repository }} 35 | run: | 36 | mkdir dist 37 | echo ::set-output name=DIST::${PWD}/dist 38 | echo ::set-output name=PACKAGE::${REPO##*/} 39 | 40 | - name: PHP version 41 | run: php --version 42 | 43 | - name: Validate composer.json and composer.lock 44 | run: composer validate 45 | 46 | - name: Get Composer Cache Directory 47 | id: composer-cache 48 | run: echo "::set-output name=dir::$(composer config cache-files-dir)" 49 | 50 | - name: Cache Composer vendor directory 51 | uses: actions/cache@v4 52 | with: 53 | path: ${{ steps.composer-cache.outputs.dir }} 54 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 55 | restore-keys: | 56 | ${{ runner.os }}-composer- 57 | 58 | - name: Install PHP Dependencies 59 | run: composer install --no-progress --no-dev --optimize-autoloader 60 | 61 | - name: Install dependencies 62 | run: npm ci 63 | 64 | - name: Build plugin 65 | run: npm run build 66 | 67 | - name: Prepare files 68 | run: rsync -r --exclude-from=.distignore . ${{ steps.workflow.outputs.DIST }}/${{ steps.workflow.outputs.PACKAGE }} 69 | 70 | - name: List Files 71 | working-directory: ${{ steps.workflow.outputs.DIST }} 72 | run: find . 73 | 74 | - name: Create Zip 75 | working-directory: ${{ steps.workflow.outputs.DIST }} 76 | run: zip -r ${{ steps.workflow.outputs.PACKAGE }}.zip . 77 | 78 | - name: Upload Release Asset 79 | uses: actions/upload-release-asset@v1 80 | env: 81 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 82 | with: 83 | upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets{?name,label} 84 | asset_path: ${{ steps.workflow.outputs.DIST }}/${{ steps.workflow.outputs.PACKAGE }}.zip 85 | asset_name: ${{ steps.workflow.outputs.PACKAGE }}.zip 86 | asset_content_type: application/zip 87 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Coverage directory used by tools like istanbul 9 | coverage 10 | 11 | # Compiled binary addons (https://nodejs.org/api/addons.html) 12 | build/ 13 | 14 | # Dependency directories 15 | node_modules/ 16 | vendor/ 17 | 18 | # Optional npm cache directory 19 | .npm 20 | 21 | # Optional eslint cache 22 | .eslintcache 23 | 24 | # Output of 'npm pack' 25 | *.tgz 26 | 27 | # dotenv environment variables file 28 | .env 29 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 20 2 | -------------------------------------------------------------------------------- /.phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | Generally-applicable sniffs for WordPress plugins. 4 | 5 | 6 | . 7 | /vendor/ 8 | /node_modules/ 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | test 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | tests/* 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | test 47 | 48 | 49 | 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | */build/* 74 | 75 | -------------------------------------------------------------------------------- /.stylelintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@wordpress/stylelint-config/scss", 3 | "rules": { 4 | "selector-class-pattern": null, 5 | "no-descending-specificity": null 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.wordpress-org/icon-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spacedmonkey/classic-menu-block/4f77b8408ad0a9d16c2973b7bf5d3ffa0512b5b2/.wordpress-org/icon-128x128.png -------------------------------------------------------------------------------- /.wordpress-org/icon-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spacedmonkey/classic-menu-block/4f77b8408ad0a9d16c2973b7bf5d3ffa0512b5b2/.wordpress-org/icon-256x256.png -------------------------------------------------------------------------------- /.wordpress-org/screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spacedmonkey/classic-menu-block/4f77b8408ad0a9d16c2973b7bf5d3ffa0512b5b2/.wordpress-org/screenshot-1.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /block.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/block.json", 3 | "apiVersion": 2, 4 | "name": "spacedmonkey/classic-menu-block", 5 | "version": "0.1.7", 6 | "title": "Classic Menu Block", 7 | "category": "theme", 8 | "description": "A gutenberg block to use classic menus.", 9 | "supports": { 10 | "html": false, 11 | "anchor": true 12 | }, 13 | "attributes": { 14 | "anchor": { 15 | "type": "string" 16 | }, 17 | "menu": { 18 | "type": "number", 19 | "default": 0 20 | } 21 | }, 22 | "textdomain": "classic-menu-block", 23 | "editorScript": "file:./build/index.js", 24 | "editorStyle": "file:./build/index.css", 25 | "style": "file:./build/style-index.css" 26 | } 27 | -------------------------------------------------------------------------------- /classic-menu-block.php: -------------------------------------------------------------------------------- 1 | 'render_block_classic_menu', 28 | ] 29 | ); 30 | } 31 | add_action( 'init', 'create_block_classic_menu_block_block_init' ); 32 | 33 | /** 34 | * Block render callback. 35 | * 36 | * @since 0.1.0 37 | * @param array $attrs Block attributes. 38 | * 39 | * @return string 40 | */ 41 | function render_block_classic_menu( $attrs ) { 42 | $attrs = wp_parse_args( 43 | $attrs, 44 | [ 45 | 'className' => '', 46 | 'anchor' => '', 47 | 'menu' => 0, 48 | ] 49 | ); 50 | $menu_attrs = [ 51 | 'echo' => false, 52 | 'container_class' => 'wp-classic-menu-block ' . $attrs['className'], 53 | 'container_id' => $attrs['anchor'], 54 | 'menu' => $attrs['menu'], 55 | ]; 56 | 57 | /** 58 | * Filters menu attributes. 59 | * 60 | * @since 0.1.0 61 | * 62 | * @param array $menu_attrs Menu attributes. 63 | * @param array $attrs Block attributes. 64 | */ 65 | $menu_attrs = apply_filters( 'classic_menu_block_attributes', $menu_attrs, $attrs ); 66 | 67 | return (string) wp_nav_menu( $menu_attrs ); 68 | } 69 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spacedmonkey/classic-menu-block", 3 | "description": "A gutenberg block to use classic menus.", 4 | "license": "GPL-2.0-or-later", 5 | "type": "wordpress-plugin", 6 | "authors": [ 7 | { 8 | "name": "Jonny Harris", 9 | "homepage": "https://www.spacedmonkey.com/" 10 | } 11 | ], 12 | "homepage": "http://wp-api.org/", 13 | "support": { 14 | "issues": "https://github.com/spacedmonkey/classic-menu-block/issues" 15 | }, 16 | "require": { 17 | "php": "^5.6 || ^7.0 || ^8.0", 18 | "composer/installers": "^1.10" 19 | }, 20 | "require-dev": { 21 | "dealerdirect/phpcodesniffer-composer-installer": "^1.0", 22 | "phpcompatibility/phpcompatibility-wp": "^2.1", 23 | "sirbrillig/phpcs-variable-analysis": "^2.11", 24 | "squizlabs/php_codesniffer": "^3.6", 25 | "wp-coding-standards/wpcs": "^3.1" 26 | }, 27 | "config": { 28 | "allow-plugins": { 29 | "composer/installers": true, 30 | "dealerdirect/phpcodesniffer-composer-installer": true 31 | }, 32 | "discard-changes": true, 33 | "platform": { 34 | "php": "5.6" 35 | }, 36 | "sort-packages": true 37 | }, 38 | "scripts": { 39 | "phpcbf": "phpcbf", 40 | "phpcs": "phpcs", 41 | "test": "phpunit" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "3780b72e133ed68c85870c67bf8bdfe8", 8 | "packages": [ 9 | { 10 | "name": "composer/installers", 11 | "version": "v1.12.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/composer/installers.git", 15 | "reference": "d20a64ed3c94748397ff5973488761b22f6d3f19" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/composer/installers/zipball/d20a64ed3c94748397ff5973488761b22f6d3f19", 20 | "reference": "d20a64ed3c94748397ff5973488761b22f6d3f19", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "composer-plugin-api": "^1.0 || ^2.0" 25 | }, 26 | "replace": { 27 | "roundcube/plugin-installer": "*", 28 | "shama/baton": "*" 29 | }, 30 | "require-dev": { 31 | "composer/composer": "1.6.* || ^2.0", 32 | "composer/semver": "^1 || ^3", 33 | "phpstan/phpstan": "^0.12.55", 34 | "phpstan/phpstan-phpunit": "^0.12.16", 35 | "symfony/phpunit-bridge": "^4.2 || ^5", 36 | "symfony/process": "^2.3" 37 | }, 38 | "type": "composer-plugin", 39 | "extra": { 40 | "class": "Composer\\Installers\\Plugin", 41 | "branch-alias": { 42 | "dev-main": "1.x-dev" 43 | } 44 | }, 45 | "autoload": { 46 | "psr-4": { 47 | "Composer\\Installers\\": "src/Composer/Installers" 48 | } 49 | }, 50 | "notification-url": "https://packagist.org/downloads/", 51 | "license": [ 52 | "MIT" 53 | ], 54 | "authors": [ 55 | { 56 | "name": "Kyle Robinson Young", 57 | "email": "kyle@dontkry.com", 58 | "homepage": "https://github.com/shama" 59 | } 60 | ], 61 | "description": "A multi-framework Composer library installer", 62 | "homepage": "https://composer.github.io/installers/", 63 | "keywords": [ 64 | "Craft", 65 | "Dolibarr", 66 | "Eliasis", 67 | "Hurad", 68 | "ImageCMS", 69 | "Kanboard", 70 | "Lan Management System", 71 | "MODX Evo", 72 | "MantisBT", 73 | "Mautic", 74 | "Maya", 75 | "OXID", 76 | "Plentymarkets", 77 | "Porto", 78 | "RadPHP", 79 | "SMF", 80 | "Starbug", 81 | "Thelia", 82 | "Whmcs", 83 | "WolfCMS", 84 | "agl", 85 | "aimeos", 86 | "annotatecms", 87 | "attogram", 88 | "bitrix", 89 | "cakephp", 90 | "chef", 91 | "cockpit", 92 | "codeigniter", 93 | "concrete5", 94 | "croogo", 95 | "dokuwiki", 96 | "drupal", 97 | "eZ Platform", 98 | "elgg", 99 | "expressionengine", 100 | "fuelphp", 101 | "grav", 102 | "installer", 103 | "itop", 104 | "joomla", 105 | "known", 106 | "kohana", 107 | "laravel", 108 | "lavalite", 109 | "lithium", 110 | "magento", 111 | "majima", 112 | "mako", 113 | "mediawiki", 114 | "miaoxing", 115 | "modulework", 116 | "modx", 117 | "moodle", 118 | "osclass", 119 | "pantheon", 120 | "phpbb", 121 | "piwik", 122 | "ppi", 123 | "processwire", 124 | "puppet", 125 | "pxcms", 126 | "reindex", 127 | "roundcube", 128 | "shopware", 129 | "silverstripe", 130 | "sydes", 131 | "sylius", 132 | "symfony", 133 | "tastyigniter", 134 | "typo3", 135 | "wordpress", 136 | "yawik", 137 | "zend", 138 | "zikula" 139 | ], 140 | "support": { 141 | "issues": "https://github.com/composer/installers/issues", 142 | "source": "https://github.com/composer/installers/tree/v1.12.0" 143 | }, 144 | "funding": [ 145 | { 146 | "url": "https://packagist.com", 147 | "type": "custom" 148 | }, 149 | { 150 | "url": "https://github.com/composer", 151 | "type": "github" 152 | }, 153 | { 154 | "url": "https://tidelift.com/funding/github/packagist/composer/composer", 155 | "type": "tidelift" 156 | } 157 | ], 158 | "time": "2021-09-13T08:19:44+00:00" 159 | } 160 | ], 161 | "packages-dev": [ 162 | { 163 | "name": "dealerdirect/phpcodesniffer-composer-installer", 164 | "version": "v1.0.0", 165 | "source": { 166 | "type": "git", 167 | "url": "https://github.com/PHPCSStandards/composer-installer.git", 168 | "reference": "4be43904336affa5c2f70744a348312336afd0da" 169 | }, 170 | "dist": { 171 | "type": "zip", 172 | "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", 173 | "reference": "4be43904336affa5c2f70744a348312336afd0da", 174 | "shasum": "" 175 | }, 176 | "require": { 177 | "composer-plugin-api": "^1.0 || ^2.0", 178 | "php": ">=5.4", 179 | "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" 180 | }, 181 | "require-dev": { 182 | "composer/composer": "*", 183 | "ext-json": "*", 184 | "ext-zip": "*", 185 | "php-parallel-lint/php-parallel-lint": "^1.3.1", 186 | "phpcompatibility/php-compatibility": "^9.0", 187 | "yoast/phpunit-polyfills": "^1.0" 188 | }, 189 | "type": "composer-plugin", 190 | "extra": { 191 | "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" 192 | }, 193 | "autoload": { 194 | "psr-4": { 195 | "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" 196 | } 197 | }, 198 | "notification-url": "https://packagist.org/downloads/", 199 | "license": [ 200 | "MIT" 201 | ], 202 | "authors": [ 203 | { 204 | "name": "Franck Nijhof", 205 | "email": "franck.nijhof@dealerdirect.com", 206 | "homepage": "http://www.frenck.nl", 207 | "role": "Developer / IT Manager" 208 | }, 209 | { 210 | "name": "Contributors", 211 | "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" 212 | } 213 | ], 214 | "description": "PHP_CodeSniffer Standards Composer Installer Plugin", 215 | "homepage": "http://www.dealerdirect.com", 216 | "keywords": [ 217 | "PHPCodeSniffer", 218 | "PHP_CodeSniffer", 219 | "code quality", 220 | "codesniffer", 221 | "composer", 222 | "installer", 223 | "phpcbf", 224 | "phpcs", 225 | "plugin", 226 | "qa", 227 | "quality", 228 | "standard", 229 | "standards", 230 | "style guide", 231 | "stylecheck", 232 | "tests" 233 | ], 234 | "support": { 235 | "issues": "https://github.com/PHPCSStandards/composer-installer/issues", 236 | "source": "https://github.com/PHPCSStandards/composer-installer" 237 | }, 238 | "time": "2023-01-05T11:28:13+00:00" 239 | }, 240 | { 241 | "name": "phpcompatibility/php-compatibility", 242 | "version": "9.3.5", 243 | "source": { 244 | "type": "git", 245 | "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", 246 | "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" 247 | }, 248 | "dist": { 249 | "type": "zip", 250 | "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", 251 | "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", 252 | "shasum": "" 253 | }, 254 | "require": { 255 | "php": ">=5.3", 256 | "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" 257 | }, 258 | "conflict": { 259 | "squizlabs/php_codesniffer": "2.6.2" 260 | }, 261 | "require-dev": { 262 | "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" 263 | }, 264 | "suggest": { 265 | "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", 266 | "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." 267 | }, 268 | "type": "phpcodesniffer-standard", 269 | "notification-url": "https://packagist.org/downloads/", 270 | "license": [ 271 | "LGPL-3.0-or-later" 272 | ], 273 | "authors": [ 274 | { 275 | "name": "Wim Godden", 276 | "homepage": "https://github.com/wimg", 277 | "role": "lead" 278 | }, 279 | { 280 | "name": "Juliette Reinders Folmer", 281 | "homepage": "https://github.com/jrfnl", 282 | "role": "lead" 283 | }, 284 | { 285 | "name": "Contributors", 286 | "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" 287 | } 288 | ], 289 | "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", 290 | "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", 291 | "keywords": [ 292 | "compatibility", 293 | "phpcs", 294 | "standards" 295 | ], 296 | "support": { 297 | "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", 298 | "source": "https://github.com/PHPCompatibility/PHPCompatibility" 299 | }, 300 | "time": "2019-12-27T09:44:58+00:00" 301 | }, 302 | { 303 | "name": "phpcompatibility/phpcompatibility-paragonie", 304 | "version": "1.3.3", 305 | "source": { 306 | "type": "git", 307 | "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", 308 | "reference": "293975b465e0e709b571cbf0c957c6c0a7b9a2ac" 309 | }, 310 | "dist": { 311 | "type": "zip", 312 | "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/293975b465e0e709b571cbf0c957c6c0a7b9a2ac", 313 | "reference": "293975b465e0e709b571cbf0c957c6c0a7b9a2ac", 314 | "shasum": "" 315 | }, 316 | "require": { 317 | "phpcompatibility/php-compatibility": "^9.0" 318 | }, 319 | "require-dev": { 320 | "dealerdirect/phpcodesniffer-composer-installer": "^1.0", 321 | "paragonie/random_compat": "dev-master", 322 | "paragonie/sodium_compat": "dev-master" 323 | }, 324 | "suggest": { 325 | "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", 326 | "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." 327 | }, 328 | "type": "phpcodesniffer-standard", 329 | "notification-url": "https://packagist.org/downloads/", 330 | "license": [ 331 | "LGPL-3.0-or-later" 332 | ], 333 | "authors": [ 334 | { 335 | "name": "Wim Godden", 336 | "role": "lead" 337 | }, 338 | { 339 | "name": "Juliette Reinders Folmer", 340 | "role": "lead" 341 | } 342 | ], 343 | "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", 344 | "homepage": "http://phpcompatibility.com/", 345 | "keywords": [ 346 | "compatibility", 347 | "paragonie", 348 | "phpcs", 349 | "polyfill", 350 | "standards", 351 | "static analysis" 352 | ], 353 | "support": { 354 | "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", 355 | "security": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/security/policy", 356 | "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" 357 | }, 358 | "funding": [ 359 | { 360 | "url": "https://github.com/PHPCompatibility", 361 | "type": "github" 362 | }, 363 | { 364 | "url": "https://github.com/jrfnl", 365 | "type": "github" 366 | }, 367 | { 368 | "url": "https://opencollective.com/php_codesniffer", 369 | "type": "open_collective" 370 | } 371 | ], 372 | "time": "2024-04-24T21:30:46+00:00" 373 | }, 374 | { 375 | "name": "phpcompatibility/phpcompatibility-wp", 376 | "version": "2.1.5", 377 | "source": { 378 | "type": "git", 379 | "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", 380 | "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082" 381 | }, 382 | "dist": { 383 | "type": "zip", 384 | "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/01c1ff2704a58e46f0cb1ca9d06aee07b3589082", 385 | "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082", 386 | "shasum": "" 387 | }, 388 | "require": { 389 | "phpcompatibility/php-compatibility": "^9.0", 390 | "phpcompatibility/phpcompatibility-paragonie": "^1.0" 391 | }, 392 | "require-dev": { 393 | "dealerdirect/phpcodesniffer-composer-installer": "^1.0" 394 | }, 395 | "suggest": { 396 | "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", 397 | "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." 398 | }, 399 | "type": "phpcodesniffer-standard", 400 | "notification-url": "https://packagist.org/downloads/", 401 | "license": [ 402 | "LGPL-3.0-or-later" 403 | ], 404 | "authors": [ 405 | { 406 | "name": "Wim Godden", 407 | "role": "lead" 408 | }, 409 | { 410 | "name": "Juliette Reinders Folmer", 411 | "role": "lead" 412 | } 413 | ], 414 | "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", 415 | "homepage": "http://phpcompatibility.com/", 416 | "keywords": [ 417 | "compatibility", 418 | "phpcs", 419 | "standards", 420 | "static analysis", 421 | "wordpress" 422 | ], 423 | "support": { 424 | "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", 425 | "security": "https://github.com/PHPCompatibility/PHPCompatibilityWP/security/policy", 426 | "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" 427 | }, 428 | "funding": [ 429 | { 430 | "url": "https://github.com/PHPCompatibility", 431 | "type": "github" 432 | }, 433 | { 434 | "url": "https://github.com/jrfnl", 435 | "type": "github" 436 | }, 437 | { 438 | "url": "https://opencollective.com/php_codesniffer", 439 | "type": "open_collective" 440 | } 441 | ], 442 | "time": "2024-04-24T21:37:59+00:00" 443 | }, 444 | { 445 | "name": "phpcsstandards/phpcsextra", 446 | "version": "1.2.1", 447 | "source": { 448 | "type": "git", 449 | "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", 450 | "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489" 451 | }, 452 | "dist": { 453 | "type": "zip", 454 | "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", 455 | "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", 456 | "shasum": "" 457 | }, 458 | "require": { 459 | "php": ">=5.4", 460 | "phpcsstandards/phpcsutils": "^1.0.9", 461 | "squizlabs/php_codesniffer": "^3.8.0" 462 | }, 463 | "require-dev": { 464 | "php-parallel-lint/php-console-highlighter": "^1.0", 465 | "php-parallel-lint/php-parallel-lint": "^1.3.2", 466 | "phpcsstandards/phpcsdevcs": "^1.1.6", 467 | "phpcsstandards/phpcsdevtools": "^1.2.1", 468 | "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" 469 | }, 470 | "type": "phpcodesniffer-standard", 471 | "extra": { 472 | "branch-alias": { 473 | "dev-stable": "1.x-dev", 474 | "dev-develop": "1.x-dev" 475 | } 476 | }, 477 | "notification-url": "https://packagist.org/downloads/", 478 | "license": [ 479 | "LGPL-3.0-or-later" 480 | ], 481 | "authors": [ 482 | { 483 | "name": "Juliette Reinders Folmer", 484 | "homepage": "https://github.com/jrfnl", 485 | "role": "lead" 486 | }, 487 | { 488 | "name": "Contributors", 489 | "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" 490 | } 491 | ], 492 | "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", 493 | "keywords": [ 494 | "PHP_CodeSniffer", 495 | "phpcbf", 496 | "phpcodesniffer-standard", 497 | "phpcs", 498 | "standards", 499 | "static analysis" 500 | ], 501 | "support": { 502 | "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", 503 | "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", 504 | "source": "https://github.com/PHPCSStandards/PHPCSExtra" 505 | }, 506 | "funding": [ 507 | { 508 | "url": "https://github.com/PHPCSStandards", 509 | "type": "github" 510 | }, 511 | { 512 | "url": "https://github.com/jrfnl", 513 | "type": "github" 514 | }, 515 | { 516 | "url": "https://opencollective.com/php_codesniffer", 517 | "type": "open_collective" 518 | } 519 | ], 520 | "time": "2023-12-08T16:49:07+00:00" 521 | }, 522 | { 523 | "name": "phpcsstandards/phpcsutils", 524 | "version": "1.0.11", 525 | "source": { 526 | "type": "git", 527 | "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", 528 | "reference": "c457da9dabb60eb7106dd5e3c05132b1a6539c6a" 529 | }, 530 | "dist": { 531 | "type": "zip", 532 | "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/c457da9dabb60eb7106dd5e3c05132b1a6539c6a", 533 | "reference": "c457da9dabb60eb7106dd5e3c05132b1a6539c6a", 534 | "shasum": "" 535 | }, 536 | "require": { 537 | "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", 538 | "php": ">=5.4", 539 | "squizlabs/php_codesniffer": "^3.9.0 || 4.0.x-dev@dev" 540 | }, 541 | "require-dev": { 542 | "ext-filter": "*", 543 | "php-parallel-lint/php-console-highlighter": "^1.0", 544 | "php-parallel-lint/php-parallel-lint": "^1.3.2", 545 | "phpcsstandards/phpcsdevcs": "^1.1.6", 546 | "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" 547 | }, 548 | "type": "phpcodesniffer-standard", 549 | "extra": { 550 | "branch-alias": { 551 | "dev-stable": "1.x-dev", 552 | "dev-develop": "1.x-dev" 553 | } 554 | }, 555 | "autoload": { 556 | "classmap": [ 557 | "PHPCSUtils/" 558 | ] 559 | }, 560 | "notification-url": "https://packagist.org/downloads/", 561 | "license": [ 562 | "LGPL-3.0-or-later" 563 | ], 564 | "authors": [ 565 | { 566 | "name": "Juliette Reinders Folmer", 567 | "homepage": "https://github.com/jrfnl", 568 | "role": "lead" 569 | }, 570 | { 571 | "name": "Contributors", 572 | "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" 573 | } 574 | ], 575 | "description": "A suite of utility functions for use with PHP_CodeSniffer", 576 | "homepage": "https://phpcsutils.com/", 577 | "keywords": [ 578 | "PHP_CodeSniffer", 579 | "phpcbf", 580 | "phpcodesniffer-standard", 581 | "phpcs", 582 | "phpcs3", 583 | "standards", 584 | "static analysis", 585 | "tokens", 586 | "utility" 587 | ], 588 | "support": { 589 | "docs": "https://phpcsutils.com/", 590 | "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", 591 | "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", 592 | "source": "https://github.com/PHPCSStandards/PHPCSUtils" 593 | }, 594 | "funding": [ 595 | { 596 | "url": "https://github.com/PHPCSStandards", 597 | "type": "github" 598 | }, 599 | { 600 | "url": "https://github.com/jrfnl", 601 | "type": "github" 602 | }, 603 | { 604 | "url": "https://opencollective.com/php_codesniffer", 605 | "type": "open_collective" 606 | } 607 | ], 608 | "time": "2024-04-24T11:47:18+00:00" 609 | }, 610 | { 611 | "name": "sirbrillig/phpcs-variable-analysis", 612 | "version": "v2.11.18", 613 | "source": { 614 | "type": "git", 615 | "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", 616 | "reference": "ca242a0b7309e0f9d1f73b236e04ecf4ca3248d0" 617 | }, 618 | "dist": { 619 | "type": "zip", 620 | "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/ca242a0b7309e0f9d1f73b236e04ecf4ca3248d0", 621 | "reference": "ca242a0b7309e0f9d1f73b236e04ecf4ca3248d0", 622 | "shasum": "" 623 | }, 624 | "require": { 625 | "php": ">=5.4.0", 626 | "squizlabs/php_codesniffer": "^3.5.6" 627 | }, 628 | "require-dev": { 629 | "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0", 630 | "phpcsstandards/phpcsdevcs": "^1.1", 631 | "phpstan/phpstan": "^1.7", 632 | "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.5 || ^7.0 || ^8.0 || ^9.0", 633 | "sirbrillig/phpcs-import-detection": "^1.1", 634 | "vimeo/psalm": "^0.2 || ^0.3 || ^1.1 || ^4.24 || ^5.0@beta" 635 | }, 636 | "type": "phpcodesniffer-standard", 637 | "autoload": { 638 | "psr-4": { 639 | "VariableAnalysis\\": "VariableAnalysis/" 640 | } 641 | }, 642 | "notification-url": "https://packagist.org/downloads/", 643 | "license": [ 644 | "BSD-2-Clause" 645 | ], 646 | "authors": [ 647 | { 648 | "name": "Sam Graham", 649 | "email": "php-codesniffer-variableanalysis@illusori.co.uk" 650 | }, 651 | { 652 | "name": "Payton Swick", 653 | "email": "payton@foolord.com" 654 | } 655 | ], 656 | "description": "A PHPCS sniff to detect problems with variables.", 657 | "keywords": [ 658 | "phpcs", 659 | "static analysis" 660 | ], 661 | "support": { 662 | "issues": "https://github.com/sirbrillig/phpcs-variable-analysis/issues", 663 | "source": "https://github.com/sirbrillig/phpcs-variable-analysis", 664 | "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" 665 | }, 666 | "time": "2024-04-13T16:42:46+00:00" 667 | }, 668 | { 669 | "name": "squizlabs/php_codesniffer", 670 | "version": "3.10.1", 671 | "source": { 672 | "type": "git", 673 | "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", 674 | "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877" 675 | }, 676 | "dist": { 677 | "type": "zip", 678 | "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/8f90f7a53ce271935282967f53d0894f8f1ff877", 679 | "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877", 680 | "shasum": "" 681 | }, 682 | "require": { 683 | "ext-simplexml": "*", 684 | "ext-tokenizer": "*", 685 | "ext-xmlwriter": "*", 686 | "php": ">=5.4.0" 687 | }, 688 | "require-dev": { 689 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" 690 | }, 691 | "bin": [ 692 | "bin/phpcbf", 693 | "bin/phpcs" 694 | ], 695 | "type": "library", 696 | "extra": { 697 | "branch-alias": { 698 | "dev-master": "3.x-dev" 699 | } 700 | }, 701 | "notification-url": "https://packagist.org/downloads/", 702 | "license": [ 703 | "BSD-3-Clause" 704 | ], 705 | "authors": [ 706 | { 707 | "name": "Greg Sherwood", 708 | "role": "Former lead" 709 | }, 710 | { 711 | "name": "Juliette Reinders Folmer", 712 | "role": "Current lead" 713 | }, 714 | { 715 | "name": "Contributors", 716 | "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" 717 | } 718 | ], 719 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", 720 | "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", 721 | "keywords": [ 722 | "phpcs", 723 | "standards", 724 | "static analysis" 725 | ], 726 | "support": { 727 | "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", 728 | "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", 729 | "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", 730 | "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" 731 | }, 732 | "funding": [ 733 | { 734 | "url": "https://github.com/PHPCSStandards", 735 | "type": "github" 736 | }, 737 | { 738 | "url": "https://github.com/jrfnl", 739 | "type": "github" 740 | }, 741 | { 742 | "url": "https://opencollective.com/php_codesniffer", 743 | "type": "open_collective" 744 | } 745 | ], 746 | "time": "2024-05-22T21:24:41+00:00" 747 | }, 748 | { 749 | "name": "wp-coding-standards/wpcs", 750 | "version": "3.1.0", 751 | "source": { 752 | "type": "git", 753 | "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", 754 | "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7" 755 | }, 756 | "dist": { 757 | "type": "zip", 758 | "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/9333efcbff231f10dfd9c56bb7b65818b4733ca7", 759 | "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7", 760 | "shasum": "" 761 | }, 762 | "require": { 763 | "ext-filter": "*", 764 | "ext-libxml": "*", 765 | "ext-tokenizer": "*", 766 | "ext-xmlreader": "*", 767 | "php": ">=5.4", 768 | "phpcsstandards/phpcsextra": "^1.2.1", 769 | "phpcsstandards/phpcsutils": "^1.0.10", 770 | "squizlabs/php_codesniffer": "^3.9.0" 771 | }, 772 | "require-dev": { 773 | "php-parallel-lint/php-console-highlighter": "^1.0.0", 774 | "php-parallel-lint/php-parallel-lint": "^1.3.2", 775 | "phpcompatibility/php-compatibility": "^9.0", 776 | "phpcsstandards/phpcsdevtools": "^1.2.0", 777 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" 778 | }, 779 | "suggest": { 780 | "ext-iconv": "For improved results", 781 | "ext-mbstring": "For improved results" 782 | }, 783 | "type": "phpcodesniffer-standard", 784 | "notification-url": "https://packagist.org/downloads/", 785 | "license": [ 786 | "MIT" 787 | ], 788 | "authors": [ 789 | { 790 | "name": "Contributors", 791 | "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" 792 | } 793 | ], 794 | "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", 795 | "keywords": [ 796 | "phpcs", 797 | "standards", 798 | "static analysis", 799 | "wordpress" 800 | ], 801 | "support": { 802 | "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", 803 | "source": "https://github.com/WordPress/WordPress-Coding-Standards", 804 | "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" 805 | }, 806 | "funding": [ 807 | { 808 | "url": "https://opencollective.com/php_codesniffer", 809 | "type": "custom" 810 | } 811 | ], 812 | "time": "2024-03-25T16:39:00+00:00" 813 | } 814 | ], 815 | "aliases": [], 816 | "minimum-stability": "stable", 817 | "stability-flags": [], 818 | "prefer-stable": false, 819 | "prefer-lowest": false, 820 | "platform": { 821 | "php": "^5.6 || ^7.0 || ^8.0" 822 | }, 823 | "platform-dev": [], 824 | "platform-overrides": { 825 | "php": "5.6" 826 | }, 827 | "plugin-api-version": "2.6.0" 828 | } 829 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "classic-menu-block", 3 | "version": "0.1.7", 4 | "description": "A gutenberg block to use classic menus.", 5 | "author": "Jonathan Harris", 6 | "license": "GPL-2.0-or-later", 7 | "main": "build/index.js", 8 | "scripts": { 9 | "build": "wp-scripts build", 10 | "check-engines": "wp-scripts check-engines", 11 | "check-licenses": "wp-scripts check-licenses", 12 | "format": "wp-scripts format", 13 | "lint:css": "wp-scripts lint-style", 14 | "lint:js": "wp-scripts lint-js", 15 | "lint:md:docs": "wp-scripts lint-md-docs", 16 | "lint:md:js": "wp-scripts lint-md-js", 17 | "lint:pkg-json": "wp-scripts lint-pkg-json", 18 | "packages-update": "wp-scripts packages-update", 19 | "plugin-zip": "wp-scripts plugin-zip", 20 | "start": "wp-scripts start", 21 | "test:e2e": "wp-scripts test-e2e", 22 | "test:unit": "wp-scripts test-unit-js" 23 | }, 24 | "dependencies": { 25 | "@wordpress/block-editor": "^13.2.0", 26 | "@wordpress/blocks": "^13.2.0", 27 | "@wordpress/components": "^28.2.0", 28 | "@wordpress/core-data": "^7.2.0", 29 | "@wordpress/data": "^10.2.0", 30 | "@wordpress/i18n": "^5.2.0", 31 | "@wordpress/icons": "^10.2.0", 32 | "@wordpress/server-side-render": "^5.2.0" 33 | }, 34 | "devDependencies": { 35 | "@wordpress/scripts": "^28.2.0" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Classic Menu Block 2 | 3 | Stable tag: 0.1.7 4 | Requires at least: 5.9 5 | Tested up to: 6.5 6 | Requires PHP: 5.6 7 | License: GPL v2 or later 8 | Tags: block, menu, navigation 9 | Contributors: spacedmonkey 10 | Donate link: 11 | 12 | A gutenberg block to use classic menus. 13 | 14 | ## Description 15 | 16 | Use classic menus in gutenberg, using this block. This block renders classic menu data using wp_nav_menu function, improving backwards compatiblity. 17 | 18 | ## Installation 19 | 20 | This section describes how to install the plugin and get it working. 21 | 22 | 1. Upload the plugin files to the `/wp-content/plugins/classic-menu-block` directory, or install the plugin through the WordPress plugins screen directly. 23 | 1. Activate the plugin through the 'Plugins' screen in WordPress 24 | 25 | ## Screenshots 26 | 27 | 1. The navigation block \ ![Block](.wordpress-org/screenshot-1.png) 28 | 29 | ### Do you accept donations? 30 | 31 | [I am accepting sponsorships via the GitHub Sponsors program](https://github.com/sponsors/spacedmonkey) and any support you can give will help me maintain this plugin and keep it free for everyone. 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/block.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Internal dependencies 3 | */ 4 | import metadata from '../block.json'; 5 | 6 | export default metadata; 7 | -------------------------------------------------------------------------------- /src/edit.js: -------------------------------------------------------------------------------- 1 | /** 2 | * WordPress dependencies 3 | */ 4 | import { __ } from '@wordpress/i18n'; 5 | import { useBlockProps } from '@wordpress/block-editor'; 6 | import { SelectControl, Placeholder, Disabled } from '@wordpress/components'; 7 | import ServerSideRender from '@wordpress/server-side-render'; 8 | import { navigation as icon } from '@wordpress/icons'; 9 | 10 | /** 11 | * Internal dependencies 12 | */ 13 | import useNavigationEntities from './use-navigation-entities'; 14 | import './editor.scss'; 15 | import metadata from './block'; 16 | 17 | const { name } = metadata; 18 | 19 | /** 20 | * The edit function describes the structure of your block in the context of the 21 | * editor. This represents what the editor will render when the block is used. 22 | * 23 | * @param {Object} props 24 | * @param {Function} props.setAttributes 25 | * @param {Object} props.attributes 26 | * @param {boolean} props.isSelected 27 | * @return {Object} Element to render. 28 | */ 29 | export default function Edit( { setAttributes, attributes, isSelected } ) { 30 | const { menu = 0 } = attributes || {}; 31 | 32 | const { menus, hasMenus } = useNavigationEntities(); 33 | 34 | const options = [ 35 | { value: 0, label: __( 'Not set', 'classic-menu-block' ) }, 36 | ]; 37 | if ( hasMenus ) { 38 | menus.forEach( function ( item ) { 39 | options.push( { value: parseInt( item.id ), label: item.name } ); 40 | } ); 41 | } 42 | 43 | const onSaveMenu = ( value ) => { 44 | setAttributes( { menu: parseInt( value ) } ); 45 | }; 46 | 47 | return ( 48 |
49 | { isSelected || ! menu ? ( 50 | 54 | 60 | 61 | ) : ( 62 | 63 | 67 | 68 | ) } 69 |
70 | ); 71 | } 72 | -------------------------------------------------------------------------------- /src/editor.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * The following styles get applied inside the editor only. 3 | * 4 | * Replace them with your own styles or remove the file completely. 5 | */ 6 | 7 | .wp-block-spacedmonkey-classic-menu-block { 8 | 9 | .components-base-control__field { 10 | min-width: 180px; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * WordPress dependencies 3 | */ 4 | import { registerBlockType } from '@wordpress/blocks'; 5 | import { __ } from '@wordpress/i18n'; 6 | import { navigation as icon } from '@wordpress/icons'; 7 | 8 | /** 9 | * Internal dependencies 10 | */ 11 | import './style.scss'; 12 | import Edit from './edit'; 13 | import metadata from './block'; 14 | 15 | const { name, category, attributes, supports } = metadata; 16 | 17 | /** 18 | * Every block starts by registering a new block type definition. 19 | * 20 | * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/ 21 | */ 22 | registerBlockType( name, { 23 | title: __( 'Classic menu', 'classic-menu-block' ), 24 | description: __( 25 | 'Render classic menu data as a block', 26 | 'classic-menu-block' 27 | ), 28 | keywords: [ 29 | __( 'classic', 'classic-menu-block' ), 30 | __( 'menu', 'classic-menu-block' ), 31 | __( 'navigation', 'classic-menu-block' ), 32 | ], 33 | category, 34 | attributes, 35 | supports, 36 | icon, 37 | /** 38 | * @see ./edit.js 39 | */ 40 | edit: Edit, 41 | } ); 42 | -------------------------------------------------------------------------------- /src/style.scss: -------------------------------------------------------------------------------- 1 | .wp-classic-menu-block { 2 | 3 | > .menu { 4 | margin: 0; 5 | padding: 0; 6 | list-style: none; 7 | width: 100%; 8 | text-align: left; 9 | 10 | ul { 11 | margin: 0; 12 | padding: 0; 13 | list-style: none; 14 | position: absolute; 15 | left: -999em; 16 | } 17 | 18 | li { 19 | display: inline-block; 20 | position: relative; 21 | text-align: left; 22 | padding-right: var(--wp--style--block-gap, 2em); 23 | 24 | &:hover { 25 | 26 | > ul { 27 | left: auto; 28 | } 29 | } 30 | 31 | li { 32 | display: block; 33 | 34 | &:hover { 35 | 36 | > ul { 37 | left: 100%; 38 | top: 0; 39 | } 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/use-navigation-entities.js: -------------------------------------------------------------------------------- 1 | /** 2 | * WordPress dependencies 3 | */ 4 | import { useSelect } from '@wordpress/data'; 5 | import { store as coreStore } from '@wordpress/core-data'; 6 | 7 | /** 8 | * @typedef {Object} NavigationEntitiesData 9 | * @property {Array|undefined} menus - a collection of Menu entity objects. 10 | * @property {boolean} isResolvingMenus - indicates whether the request to fetch menus is currently resolving. 11 | * @property {boolean} hasResolvedMenus - indicates whether the request to fetch menus has finished resolving. 12 | * @property {Array|undefined} menusItems - a collection of Menu Item entity objects for the current menuId. 13 | * @property {boolean} hasResolvedMenuItems - indicates whether the request to fetch menuItems has finished resolving. 14 | * @property {boolean} hasPages - indicates whether there is currently any data for pages. 15 | * @property {boolean} hasMenus - indicates whether there is currently any data for menus. 16 | */ 17 | 18 | /** 19 | * Manages fetching and resolution state for all entities required 20 | * for the Navigation block. 21 | * 22 | * @return { NavigationEntitiesData } the entity data. 23 | */ 24 | export default function useNavigationEntities() { 25 | const { menus, isResolvingMenus, hasResolvedMenus } = useSelect( 26 | ( select ) => { 27 | const { getMenus, isResolving, hasFinishedResolution } = 28 | select( coreStore ); 29 | 30 | const menusParameters = [ { per_page: -1, context: 'view' } ]; 31 | 32 | return { 33 | menus: getMenus( ...menusParameters ), 34 | isResolvingMenus: isResolving( 'getMenus', menusParameters ), 35 | hasResolvedMenus: hasFinishedResolution( 36 | 'getMenus', 37 | menusParameters 38 | ), 39 | }; 40 | }, 41 | [] 42 | ); 43 | 44 | return { 45 | menus, 46 | isResolvingMenus, 47 | hasResolvedMenus, 48 | hasMenus: !! ( hasResolvedMenus && menus?.length ), 49 | }; 50 | } 51 | --------------------------------------------------------------------------------