[
  {
    "path": ".codeclimate.yml",
    "content": "---\nversion: \"2\"\nplugins:\n  duplication:\n    enabled: true\n    config:\n      languages:\n      - php\n  fixme:\n    enabled: true\n  markdownlint:\n    enabled: true\n  phpcodesniffer:\n    enabled: true\n    config:\n      file_extensions: \"php\"\n      standard: \"WordPress-Docs,WordPress-Extra\"\n  phpmd:\n    enabled: true\n    checks:\n      Controversial/CamelCaseMethodName:\n        enabled: false\n      Controversial/CamelCaseParameterName:\n        enabled: false\n      Controversial/CamelCasePropertyName:\n        enabled: false\n      Controversial/CamelCaseVariableName:\n        enabled: false\n      CleanCode/ElseExpression:\n        enabled: false\n  shellcheck:\n    enabled: true\nexclude_patterns:\n  - \"**.dist\"\n  - \"**.lock\"\n  - \"**.json\"\n  - \"**.txt\"\n  - \"tests/*\"\n  - \"vendor/**\"\n"
  },
  {
    "path": ".editorconfig",
    "content": "# This file is for unifying the coding style for different editors and IDEs\n# editorconfig.org\n\n# WordPress Coding Standards\n# https://make.wordpress.org/core/handbook/coding-standards/\n\nroot = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\ninsert_final_newline = true\ntrim_trailing_whitespace = true\nindent_style = tab\n\n[{.jshintrc,*.json,*.yml}]\nindent_style = space\nindent_size = 2\n\n[{*.txt,wp-config-sample.php}]\nend_of_line = crlf\n"
  },
  {
    "path": ".gitattributes",
    "content": "# Set the default behavior, in case people don't have core.autocrlf set.\n* text=auto\n\n# Explicitly declare text files that will always be normalized and converted\n# to native line endings on checkout.\n.editorconfig   text\n.gitattributes  text\n.gitignore      text\n*.json          text\n*.md            text\n*.txt           text\n*.xml           text\n*.yml           text\n\n# Declare files that will always have LF line endings on checkout.\n*.php text eol=lf\n*.sh  text eol=lf\n\n# Exclude from export.\n.*                  export-ignore\nbin                 export-ignore\ntests               export-ignore\n*.dist              export-ignore\nCODE_OF_CONDUCT.md  export-ignore\ncomposer.*          export-ignore\n"
  },
  {
    "path": ".github/CONTRIBUTING.md",
    "content": "# Want to contribute?\n\nDid you know that you could be instrumental in making the WP Bootstrap NavWalker more robust? If you use and love it, why not contribute to the project?\n\n## Contributing for Everyone!\n\nWhether you can barely recognize a filter (or don’t know what that means) or you’ve already authored your own plugins, there are ways for you to pitch in.\n\n### Create Bug Reports\n\nIf you find a bug, just [file a GitHub issue](https://github.com/wp-bootstrap/wp-bootstrap-navwalker/issues), that’s all. If you want to prefix the title with a “Question:”, “Bug:”, or the general area of the application, that would be helpful, but by no means mandatory. If you have write access, add the appropriate labels.\n\nIf you’re filing a bug, specific steps to reproduce are helpful. Please include the URL of the page that has the bug, along with what you expected to see and what happened instead. \n\n### Write and submit a patch\n\nIf you'd like to fix a bug, you can submit a Pull Request. \n\n#### Where to get started?\n\nIf you'd like to contribute but don't know where to get started, you can take a look at existing issues:\n\n- [\"Good First Bug\"](https://github.com/wp-bootstrap/wp-bootstrap-navwalker/labels/%5BTYPE%5D%20GOOD%20FIRST%20BUG) issues are a good entry point to get familiar with the codebase.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "content": "<!-- Thanks for contributing to WP Bootstrap NavWalker! Pick a clear title and proceed. -->\n\n#### Steps to reproduce the issue:\n\n#### What I expected:\n\n#### What happened instead:\n\n<!--\nPLEASE NOTE\n- These comments won't show up when you submit the issue.\n- Everything is optional, but try to add as many details as possible.\n- If requesting a new feature, explain why you'd like to see it added.\n- This issue tracker is not for support.\n-->\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "Fixes #\n\n#### Changes proposed in this Pull Request:\n\n*\n\n#### Testing instructions:\n\n*\n\n<!-- Add the following only if this is meant to be in changelog -->\n#### Proposed changelog entry for your changes:\n"
  },
  {
    "path": ".gitignore",
    "content": "/vendor/\n/phpcs.xml\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: php\n\nos:\n  - linux\n\ndist: bionic\n\nphp:\n  - 7.4\n  - 7.3\n  - 7.2\n  - 7.1\n  - nightly\n\nenv:\n  - WP_VERSION=latest WP_MULTISITE=0 PHPUNIT_VERSION=\"^5.7\"\n  - WP_VERSION=latest WP_MULTISITE=1 PHPUNIT_VERSION=\"^5.7\"\n\nservices:\n  - mysql\n\njobs:\n  include:\n    - php: 7.0\n      dist: xenial\n      env:\n        - WP_VERSION=latest WP_MULTISITE=0 PHPUNIT_VERSION=\"^5.7\"\n    - php: 7.0\n      dist: xenial\n      env:\n        - WP_VERSION=latest WP_MULTISITE=1 PHPUNIT_VERSION=\"^5.7\"\n    - php: 5.6\n      dist: xenial\n      env:\n        - WP_VERSION=latest WP_MULTISITE=0 PHPUNIT_VERSION=\"^5.7\"\n    - php: 5.6\n      dist: xenial\n      env:\n        - WP_VERSION=latest WP_MULTISITE=1 PHPUNIT_VERSION=\"^5.7\"\n    - name: \"Coding Standars\"\n      php: 7.4\n      install:\n        - composer require --dev wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer\n        # Counter wp-enforcer\n        - rm -f ./phpcs.xml\n      script:\n        - vendor/bin/phpcs\n    - name: \"Static Analysis\"\n      php: 7.4\n      install:\n        - composer require --dev szepeviktor/phpstan-wordpress\n      script:\n        - vendor/bin/phpstan analyze\n  allow_failures:\n    - php: nightly\n\nbranches:\n  only:\n    - master\n\ncache:\n  directories:\n    - \"${HOME}/.composer/cache\"\n\ninstall:\n  - bin/install-wp-tests.sh wordpress_test root \"\" localhost \"${WP_VERSION}\"\n  - composer global require --dev \"phpunit/phpunit=${PHPUNIT_VERSION}\"\n\nscript:\n  - \"${HOME}/.composer/vendor/bin/phpunit\"\n\nnotifications:\n  email:\n    on_success: never\n    on_failure: change\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "#CHANGELOG\n\n## [4.3.0]\n- Added an `aria-current` item.\n- Added `.nav-item` for the `<li>` and `.nav-link` for the `<a>` in fallback function.\n- Some escape improvements.\n- Don't pass `$attributes` to element closing function as it's ignored anyway.\n\n## [4.2.0]\n- Fix typo in function name 'seporate'->'separate' (private function, no need to add back-compat).\n\n## [4.1.0]\n- Prevent error `trying to get property of non-object` when no menu is set to a location using the walker.\n- Add `$depth` as 4th parameter passed to `nav_menu_link_attributes`.\n- Add support for `dropdown-item-text` linkmod type.\n## [4.0.3]\n- Drop composer class autoload statement.\n\n## [4.0.2]\n- Fix dropdown opener having empty string for href value.\n- More accurate regex matching of icon and linkmod classnames.\n- Changed composer package type to `library` from `wordpress-plugin` again.\n- Tests: Add unit tests for the function that separates classnames for the walker.\n- Fix case sensitive matching to now match mixes of upper and lower case.\n\n## [4.0.1]\n- Fix untranslated string in fallback (this was lost in transition between v3 and v4, fixed again).\n\n## [4.0.0]\n- Added a prefix on @since tags to highlight when they refer to WP core instead of this class.\n- Rework of `start_lvl()` and `start_el()` based on latest `Walker_Nav_Menu` Class from WP core.\n\t- Whitespace preservation method improvements.\n\t- Added `nav_menu_item_args` filter and `nav_menu_item_title` brought in at WP 4.4.0\n\t- Use `the_title` filter prior to `nav_menu_item_title`.\n- Added a labelled-by attribute to dropdowns for accessibility.\n- Links inside dropdown have `.dropdown-item` instead of `.nav-link`.\n- Remove `<span class=\"carat\">` after parent dropdown items.\n- Support `echo` arg in fallback menu. props: @toddlevy\n- Add `.active` to parent when a child is current page. props: @zyberspace\n- Fix to correct output of dropdown atts and styles when depth passed to wp_nav_menu is <= 1. props: @chrisgeary92\n- Move icon output to a local var instead of modifying and clearing a global object.\n- Reassign filtered classes back to $classes array so that updated classes can be accessed later if needed. props: @lf-jeremy\n- Update to work with Bootstrap v4.\n\t- Added `.nav-item` and `.nav-link` to `<li>` and `<a>` respectively.\n- Dropped support for using title attribute to add link modifiers and icons.\n- Added support for link modifiers and icons through WP Menu Builder 'classes' input.\n\t- Icon support is for Font Awesome 4/5 and Glyphicons icons.\n- Added unit tests for the `fallback` method.\n- Added code to handle icon-only menus.\n\n## [3.0.0]\n\n- Fix untranslated string in fallback.\n- Instruct screenreaders to ignore icons when present.\n- Added basic unit tests and travis config.\n- Swapped to IF statements with curly braces.\n- Adds `$depth` arg for nav_menu_css_class filter.\n- Fix sanitization function used for class output in fallback.\n- Changed composer package type to `library` from `wordpress-plugin`.\n\n## [2.0.5] - 2016-011-15\n\n- Fixed all reported issues by WP Enforcer.\n- Fixed several Code Climate issues.\n\n## [2.0.4]\n\n- Updated fallback function to accept args array from `wp_nav_menu`.\n\n## [2.0.3]\n\n- Included a fallback function that adds a link to the WordPress menu manager if no menu has been assigned to the theme location.\n\n## [2.0.2]\n\n- Small tweak to ensure carets are only displayed on top level dropdowns.\n\n## [2.0.1]\n\n- Added missing active class to active menu items.\n\n## [2.0.0]\n\n- Class was completly re-written using the latest Wordpress 3.6 walker class.\n- Now full supports Bootstrap 3.0+\n- Tested with wp_debug & the Theme Check plugin.\n\n\n---\n<small>All notable changes to this project will be documented in this file. Please read [Keep a Change Log](http://keepachangelog.com) for more information. This project adheres to [Semantic Versioning](http://semver.org).</small>\n"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.\n\n## Our Standards\n\nExamples of behavior that contributes to creating a positive environment include:\n\n* Using welcoming and inclusive language\n* Being respectful of differing viewpoints and experiences\n* Gracefully accepting constructive criticism\n* Focusing on what is best for the community\n* Showing empathy towards other community members\n\nExamples of unacceptable behavior by participants include:\n\n* The use of sexualized language or imagery and unwelcome sexual attention or advances\n* Trolling, insulting/derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or electronic address, without explicit permission\n* Other conduct which could reasonably be considered inappropriate in a professional setting\n\n## Our Responsibilities\n\nProject maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.\n\nProject maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.\n\n## Scope\n\nThis Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at brandon@imforza.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.\n\nProject maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]\n\n[homepage]: http://contributor-covenant.org\n[version]: http://contributor-covenant.org/version/1/4/\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\r\n"
  },
  {
    "path": "README.md",
    "content": "# WP Bootstrap Navwalker\n\n[![Code Climate](https://codeclimate.com/github/wp-bootstrap/wp-bootstrap-navwalker/badges/gpa.svg)](https://codeclimate.com/github/wp-bootstrap/wp-bootstrap-navwalker)\n[![Test Coverage](https://codeclimate.com/github/wp-bootstrap/wp-bootstrap-navwalker/badges/coverage.svg)](https://codeclimate.com/github/wp-bootstrap/wp-bootstrap-navwalker/coverage)\n[![Issue Count](https://codeclimate.com/github/wp-bootstrap/wp-bootstrap-navwalker/badges/issue_count.svg)](https://codeclimate.com/github/wp-bootstrap/wp-bootstrap-navwalker)\n[![Build Status](https://travis-ci.org/wp-bootstrap/wp-bootstrap-navwalker.svg?branch=master)](https://travis-ci.org/wp-bootstrap/wp-bootstrap-navwalker)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/wp-bootstrap/wp-bootstrap-navwalker/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/wp-bootstrap/wp-bootstrap-navwalker/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/wp-bootstrap/wp-bootstrap-navwalker/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/wp-bootstrap/wp-bootstrap-navwalker/?branch=master)\n[![Build Status](https://scrutinizer-ci.com/g/wp-bootstrap/wp-bootstrap-navwalker/badges/build.png?b=master)](https://scrutinizer-ci.com/g/wp-bootstrap/wp-bootstrap-navwalker/build-status/master)\n\n**This code in the main repo branch is undergoing a big shakeup to bring it in line with recent standards and to merge and test the backlog of PRs I have left for too long. Please use the v4.3.0 tag for stable version while this process happens. https://github.com/wp-bootstrap/wp-bootstrap-navwalker/releases/tag/v4.3.0**\n\nA custom WordPress Nav Walker Class to fully implement the Bootstrap 4 navigation style in a custom theme using the WordPress built in menu manager.\n\n## NOTES\n\nThis is a utility class that is intended to format your WordPress theme menu with the correct syntax and CSS classes to utilize the Bootstrap dropdown navigation. It does not include the required Bootstrap JS and CSS files - you will have to include them manually.\n\n### WordPress.org Theme Compliance\n\n*This walker is fully compliant with all Theme Review guidelines for wordpress.org theme submission.* It requires no modification to be compliant but you can optionally replace the `wp-bootstrap-navwalker` text domain (which appears twice in the `fallback` function) with the text domain of your theme.\n\n### Upgrade Notes\n\nBetween version 3 and version 4 of the walker there have been significant changes to the codebase. Version 4 of the walker is built to work with Bootstrap 4 and has not been tested for backwards compatibility with Bootstrap 3. A separate branch for Bootstrap 3 is maintained here: <https://github.com/wp-bootstrap/wp-bootstrap-navwalker/tree/v3-branch>\n\nHere is a list of the most notable changes:\n\n- The filename has been changed and prefixed with `class-` to better fit PHP coding standards naming conventions.\n  - New Name: `class-wp-bootstrap-navwalker.php`\n  - Old Name: `wp-bootstrap-navwalker.php`\n- Icon and link modifier handling is now done through the `CSS Classes` menu item input instead of the `Title` input.\n- Icon only items are possible using icon classes in combination with the `sr-only` classname.\n\n## Installation\n\nPlace **class-wp-bootstrap-navwalker.php** in your WordPress theme folder `/wp-content/themes/your-theme/`\n\nOpen your WordPress themes **functions.php** file - `/wp-content/themes/your-theme/functions.php` - and add the following code:\n\n```php\n/**\n * Register Custom Navigation Walker\n */\nfunction register_navwalker(){\n\trequire_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';\n}\nadd_action( 'after_setup_theme', 'register_navwalker' );\n```\n\nIf you encounter errors with the above code use a check like this to return clean errors to help diagnose the problem.\n\n```php\nif ( ! file_exists( get_template_directory() . '/class-wp-bootstrap-navwalker.php' ) ) {\n    // File does not exist... return an error.\n    return new WP_Error( 'class-wp-bootstrap-navwalker-missing', __( 'It appears the class-wp-bootstrap-navwalker.php file may be missing.', 'wp-bootstrap-navwalker' ) );\n} else {\n    // File exists... require it.\n    require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';\n}\n```\n\nYou will also need to declare a new menu in your `functions.php` file if one doesn't already exist.\n\n```php\nregister_nav_menus( array(\n    'primary' => __( 'Primary Menu', 'THEMENAME' ),\n) );\n```\n\n## Usage\n\nAdd or update any `wp_nav_menu()` functions in your theme (often found in `header.php`) to use the new walker by adding a `'walker'` item to the wp_nav_menu args array.\n\n```php\nwp_nav_menu( array(\n    'theme_location'  => 'primary',\n    'depth'           => 2, // 1 = no dropdowns, 2 = with dropdowns.\n    'container'       => 'div',\n    'container_class' => 'collapse navbar-collapse',\n    'container_id'    => 'bs-example-navbar-collapse-1',\n    'menu_class'      => 'navbar-nav mr-auto',\n    'fallback_cb'     => 'WP_Bootstrap_Navwalker::fallback',\n    'walker'          => new WP_Bootstrap_Navwalker(),\n) );\n```\n\nYour menu will now be formatted with the correct syntax and classes to implement Bootstrap dropdown navigation.\n\nTypically the menu is wrapped with additional markup, here is an example of a `fixed-top` menu that collapse for responsive navigation at the md breakpoint.\n\n```php\n<nav class=\"navbar navbar-expand-md navbar-light bg-light\" role=\"navigation\">\n  <div class=\"container\">\n    <!-- Brand and toggle get grouped for better mobile display -->\n    <button class=\"navbar-toggler\" type=\"button\" data-toggle=\"collapse\" data-target=\"#bs-example-navbar-collapse-1\" aria-controls=\"bs-example-navbar-collapse-1\" aria-expanded=\"false\" aria-label=\"<?php esc_attr_e( 'Toggle navigation', 'your-theme-slug' ); ?>\">\n        <span class=\"navbar-toggler-icon\"></span>\n    </button>\n    <a class=\"navbar-brand\" href=\"#\">Navbar</a>\n        <?php\n        wp_nav_menu( array(\n            'theme_location'    => 'primary',\n            'depth'             => 2,\n            'container'         => 'div',\n            'container_class'   => 'collapse navbar-collapse',\n            'container_id'      => 'bs-example-navbar-collapse-1',\n            'menu_class'        => 'nav navbar-nav',\n            'fallback_cb'       => 'WP_Bootstrap_Navwalker::fallback',\n            'walker'            => new WP_Bootstrap_Navwalker(),\n        ) );\n        ?>\n    </div>\n</nav>\n```\n\nTo change your menu style add Bootstrap nav class names to the `menu_class` declaration.\n\nReview options in the Bootstrap docs for more information on [nav classes](https://getbootstrap.com/components/#nav).\n\n### Displaying the Menu\n\nTo display the menu you must associate your menu with your theme location. You can do this by selecting your theme location in the *Theme Locations* list while editing a menu in the WordPress menu manager.\n\n### Making this Walker the Default Walker for Nav Menus\n\nThere has been some interest in making this walker the default walker for all menus. That could result in some unexpected situations but it can be achieved by adding this function to your functions.php file.\n\n```php\nfunction prefix_modify_nav_menu_args( $args ) {\n    return array_merge( $args, array(\n        'walker' => new WP_Bootstrap_Navwalker(),\n    ) );\n}\nadd_filter( 'wp_nav_menu_args', 'prefix_modify_nav_menu_args' );\n```\n\nSimply updating the walker may not be enough to get menus working right, you may need to add wrappers or additional classes, you can do that via the above function as well.\n\n### Usage with Bootstrap 5\n\nBootstrap 5 uses namespaced data attributes. All `data` attributes now include `bs` as an infix. The new attributes work just like the old ones. Here’s the menu toggle button from the example above with the renamed data attributes.\n\n```php\n<button class=\"navbar-toggler\" type=\"button\" data-bs-toggle=\"collapse\" data-bs-target=\"#bs-example-navbar-collapse-1\" aria-controls=\"bs-example-navbar-collapse-1\" aria-expanded=\"false\" aria-label=\"<?php esc_attr_e( 'Toggle navigation', 'your-theme-slug' ); ?>\">\n    <span class=\"navbar-toggler-icon\"></span>\n</button>\n```\n\nThe walker also adds a data attribute for dropdown toggles via the `start_el()` method. Paste this to your functions.php to make the walker use the infixed data attibute.\n\n```php\nadd_filter( 'nav_menu_link_attributes', 'prefix_bs5_dropdown_data_attribute', 20, 3 );\n/**\n * Use namespaced data attribute for Bootstrap's dropdown toggles.\n *\n * @param array    $atts HTML attributes applied to the item's `<a>` element.\n * @param WP_Post  $item The current menu item.\n * @param stdClass $args An object of wp_nav_menu() arguments.\n * @return array\n */\nfunction prefix_bs5_dropdown_data_attribute( $atts, $item, $args ) {\n    if ( is_a( $args->walker, 'WP_Bootstrap_Navwalker' ) ) {\n        if ( array_key_exists( 'data-toggle', $atts ) ) {\n            unset( $atts['data-toggle'] );\n            $atts['data-bs-toggle'] = 'dropdown';\n        }\n    }\n    return $atts;\n}\n```\n\n### Menu Caching\n\nOn some sites generating a large menu that rarely ever changes on every page request is an overhead that you may want to avoid. In those cases I can suggest you look at storing menu results in a transient.\n\nThe biggest drawback to caching nav menus with this method is that it cannot easily apply the `.current-menu-item` or the `.active` class to the currently active item as WP decides what is currently active on page load - and since the menu is cached it only knows the active page that it was cached on originally.\n\nYou can decide yourself if you want to put up with those drawbacks for the benefit of removing the menu generation time on most page loads. You can follow this article by Dave Clements to see how we cached nav menus that were generated by this walker: <https://www.doitwithwp.com/use-transients-speed-wordpress-menus/>\n\nBe sure to set the `echo` argument to FALSE in `the wp_nav_menu()` call when doing this so that the results can be stored instead of echoed to the page.\n\nSee also:\n\n- <https://generatewp.com/how-to-use-transients-to-speed-up-wordpress-menus/>\n- <https://vip-svn.wordpress.com/plugins/cache-nav-menu/cache-nav-menu.php>\n\n### Extras\n\nThis script included the ability to use Bootstrap nav link mods in your menus through the WordPress menu UI. Disabled links, dropdown headers and dropdown dividers are supported. Additionally icon support is built-in for Glyphicons and Font Awesome (note: you will need to include the icon stylesheets or assets separately).\n\n#### Icons\n\nTo add an Icon to your link simply enter Glyphicons or Font Awesome class names in the links **CSS Classes** field in the Menu UI and the walker class will do the rest. IE `glyphicons glyphicons-bullhorn` or `fa fa-arrow-left` or `fas fa-arrow-left`.\n\n#### Icon-Only Items\n\nTo make an item appear with the icon only apply the bootstrap screen reader class `sr-only` to the item alongside any icon classnames. This will then hide only the text that would appear as the link text.\n\n#### Disabled Links\n\nTo set a disabled link simply add `disabled` to the **CSS Classes** field in the Menu UI and the walker class will do the rest. _Note: In addition to adding the .disabled class this will change the link `href` to `#` as well so that it is not a follow-able link._\n\n#### Dropdown Headers, Dropdown Dividers & Dropdown Item Text\n\nHeaders, dividers and text only items can be added within dropdowns by adding a Custom Link and adding either `dropdown-header`, `dropdown-divider` or `dropdown-item-text` into the **CSS Classes** input. _Note: This will remove the `href` on the item and change it to either a `<span>` for headers or a `<div>` for dividers._\n\n### Missing Edit Shortcut in Customizer Preview\n\nAccording to the documentation for [`wp_nav_menu()`](https://developer.wordpress.org/reference/functions/wp_nav_menu/) one has to provide an instance of the custom walker class in order to apply the custom walker to the menu. As the instance is not [JSON serializable](https://make.wordpress.org/core/2015/07/29/fast-previewing-changes-to-menus-in-the-customizer/) this will cause the menu edit shortcut to not appear in the Customizer preview. To fix this do the following:\n1. Provide the class name string instead of the class instance as value for the 'walker' key in the array of wp_nav_menu's arguments,\n```diff\nwp_nav_menu( array(\n    'theme_location'  => 'primary',\n    'depth'           => 2, // 1 = no dropdowns, 2 = with dropdowns.\n    'container'       => 'div',\n    'container_class' => 'collapse navbar-collapse',\n    'container_id'    => 'bs-example-navbar-collapse-1',\n    'menu_class'      => 'navbar-nav mr-auto',\n    'fallback_cb'     => 'WP_Bootstrap_Navwalker::fallback',\n-    'walker'          => new WP_Bootstrap_Navwalker(),\n+    'walker'          => 'WP_Bootstrap_Navwalker',\n) );\n```\n2. re-add the class instance by adding this filter to your `functions.php`\n```php\nfunction slug_provide_walker_instance( $args ) {\n    if ( isset( $args['walker'] ) && is_string( $args['walker'] ) && class_exists( $args['walker'] ) ) {\n        $args['walker'] = new $args['walker'];\n    }\n    return $args;\n}\nadd_filter( 'wp_nav_menu_args', 'slug_provide_walker_instance', 1001 );\n```\n\n## Changelog\n\nPlease see the [Changelog](https://github.com/wp-bootstrap/wp-bootstrap-navwalker/blob/master/CHANGELOG.md).\n"
  },
  {
    "path": "bin/install-wp-tests.sh",
    "content": "#!/usr/bin/env bash\n\nif [ $# -lt 3 ]; then\n\techo \"usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]\"\n\texit 1\nfi\n\nDB_NAME=$1\nDB_USER=$2\nDB_PASS=$3\nDB_HOST=${4-localhost}\nWP_VERSION=${5-latest}\nSKIP_DB_CREATE=${6-false}\n\nWP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}\nWP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}\n\ndownload() {\n    if [ `which curl` ]; then\n        curl -s \"$1\" > \"$2\";\n    elif [ `which wget` ]; then\n        wget -nv -O \"$2\" \"$1\"\n    fi\n}\n\nif [[ $WP_VERSION =~ [0-9]+\\.[0-9]+(\\.[0-9]+)? ]]; then\n\tWP_TESTS_TAG=\"tags/$WP_VERSION\"\nelif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then\n\tWP_TESTS_TAG=\"trunk\"\nelse\n\t# http serves a single offer, whereas https serves multiple. we only want one\n\tdownload http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json\n\tgrep '[0-9]+\\.[0-9]+(\\.[0-9]+)?' /tmp/wp-latest.json\n\tLATEST_VERSION=$(grep -o '\"version\":\"[^\"]*' /tmp/wp-latest.json | sed 's/\"version\":\"//')\n\tif [[ -z \"$LATEST_VERSION\" ]]; then\n\t\techo \"Latest WordPress version could not be found\"\n\t\texit 1\n\tfi\n\tWP_TESTS_TAG=\"tags/$LATEST_VERSION\"\nfi\n\nset -ex\n\ninstall_wp() {\n\n\tif [ -d $WP_CORE_DIR ]; then\n\t\treturn;\n\tfi\n\n\tmkdir -p $WP_CORE_DIR\n\n\tif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then\n\t\tmkdir -p /tmp/wordpress-nightly\n\t\tdownload https://wordpress.org/nightly-builds/wordpress-latest.zip  /tmp/wordpress-nightly/wordpress-nightly.zip\n\t\tunzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/\n\t\tmv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR\n\telse\n\t\tif [ $WP_VERSION == 'latest' ]; then\n\t\t\tlocal ARCHIVE_NAME='latest'\n\t\telse\n\t\t\tlocal ARCHIVE_NAME=\"wordpress-$WP_VERSION\"\n\t\tfi\n\t\tdownload https://wordpress.org/${ARCHIVE_NAME}.tar.gz  /tmp/wordpress.tar.gz\n\t\ttar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR\n\tfi\n\n\tdownload https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php\n}\n\ninstall_test_suite() {\n\t# portable in-place argument for both GNU sed and Mac OSX sed\n\tif [[ $(uname -s) == 'Darwin' ]]; then\n\t\tlocal ioption='-i .bak'\n\telse\n\t\tlocal ioption='-i'\n\tfi\n\n\t# set up testing suite if it doesn't yet exist\n\tif [ ! -d $WP_TESTS_DIR ]; then\n\t\t# set up testing suite\n\t\tmkdir -p $WP_TESTS_DIR\n\t\tsvn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes\n\t\tsvn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data\n\tfi\n\n\tif [ ! -f wp-tests-config.php ]; then\n\t\tdownload https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php \"$WP_TESTS_DIR\"/wp-tests-config.php\n\t\t# remove all forward slashes in the end\n\t\tWP_CORE_DIR=$(echo $WP_CORE_DIR | sed \"s:/\\+$::\")\n\t\tsed $ioption \"s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':\" \"$WP_TESTS_DIR\"/wp-tests-config.php\n\t\tsed $ioption \"s/youremptytestdbnamehere/$DB_NAME/\" \"$WP_TESTS_DIR\"/wp-tests-config.php\n\t\tsed $ioption \"s/yourusernamehere/$DB_USER/\" \"$WP_TESTS_DIR\"/wp-tests-config.php\n\t\tsed $ioption \"s/yourpasswordhere/$DB_PASS/\" \"$WP_TESTS_DIR\"/wp-tests-config.php\n\t\tsed $ioption \"s|localhost|${DB_HOST}|\" \"$WP_TESTS_DIR\"/wp-tests-config.php\n\tfi\n\n}\n\ninstall_db() {\n\n\tif [ ${SKIP_DB_CREATE} = \"true\" ]; then\n\t\treturn 0\n\tfi\n\n\t# parse DB_HOST for port or socket references\n\tlocal PARTS=(${DB_HOST//\\:/ })\n\tlocal DB_HOSTNAME=${PARTS[0]};\n\tlocal DB_SOCK_OR_PORT=${PARTS[1]};\n\tlocal EXTRA=\"\"\n\n\tif ! [ -z $DB_HOSTNAME ] ; then\n\t\tif [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\\{1,\\}$') ]; then\n\t\t\tEXTRA=\" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp\"\n\t\telif ! [ -z $DB_SOCK_OR_PORT ] ; then\n\t\t\tEXTRA=\" --socket=$DB_SOCK_OR_PORT\"\n\t\telif ! [ -z $DB_HOSTNAME ] ; then\n\t\t\tEXTRA=\" --host=$DB_HOSTNAME --protocol=tcp\"\n\t\tfi\n\tfi\n\n\t# create database\n\tmysqladmin create $DB_NAME --user=\"$DB_USER\" --password=\"$DB_PASS\"$EXTRA\n}\n\ninstall_wp\ninstall_test_suite\ninstall_db\n"
  },
  {
    "path": "class-wp-bootstrap-navwalker.php",
    "content": "<?php\n/**\n * WP Bootstrap Navwalker\n *\n * @package WP-Bootstrap-Navwalker\n *\n * @wordpress-plugin\n * Plugin Name: WP Bootstrap Navwalker\n * Plugin URI:  https://github.com/wp-bootstrap/wp-bootstrap-navwalker\n * Description: A custom WordPress nav walker class to implement the Bootstrap 4 navigation style in a custom theme using the WordPress built in menu manager.\n * Author: Edward McIntyre - @twittem, WP Bootstrap, William Patton - @pattonwebz, IanDelMar - @IanDelMar\n * Version: 4.3.0\n * Author URI: https://github.com/wp-bootstrap\n * GitHub Plugin URI: https://github.com/wp-bootstrap/wp-bootstrap-navwalker\n * GitHub Branch: master\n * License: GPL-3.0+\n * License URI: http://www.gnu.org/licenses/gpl-3.0.txt\n */\n\n// Check if Class Exists.\nif ( ! class_exists( 'WP_Bootstrap_Navwalker' ) ) :\n\t/**\n\t * WP_Bootstrap_Navwalker class.\n\t */\n\tclass WP_Bootstrap_Navwalker extends Walker_Nav_Menu {\n\n\t\t/**\n\t\t * Whether the items_wrap contains schema microdata or not.\n\t\t *\n\t\t * @since 4.2.0\n\t\t * @var boolean\n\t\t */\n\t\tprivate $has_schema = false;\n\n\t\t/**\n\t\t * Ensure the items_wrap argument contains microdata.\n\t\t *\n\t\t * @since 4.2.0\n\t\t */\n\t\tpublic function __construct() {\n\t\t\tif ( ! has_filter( 'wp_nav_menu_args', array( $this, 'add_schema_to_navbar_ul' ) ) ) {\n\t\t\t\tadd_filter( 'wp_nav_menu_args', array( $this, 'add_schema_to_navbar_ul' ) );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Starts the list before the elements are added.\n\t\t *\n\t\t * @since WP 3.0.0\n\t\t *\n\t\t * @see Walker_Nav_Menu::start_lvl()\n\t\t *\n\t\t * @param string           $output Used to append additional content (passed by reference).\n\t\t * @param int              $depth  Depth of menu item. Used for padding.\n\t\t * @param WP_Nav_Menu_Args $args   An object of wp_nav_menu() arguments.\n\t\t */\n\t\tpublic function start_lvl( &$output, $depth = 0, $args = null ) {\n\t\t\tif ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {\n\t\t\t\t$t = '';\n\t\t\t\t$n = '';\n\t\t\t} else {\n\t\t\t\t$t = \"\\t\";\n\t\t\t\t$n = \"\\n\";\n\t\t\t}\n\t\t\t$indent = str_repeat( $t, $depth );\n\t\t\t// Default class to add to the file.\n\t\t\t$classes = array( 'dropdown-menu' );\n\t\t\t/**\n\t\t\t * Filters the CSS class(es) applied to a menu list element.\n\t\t\t *\n\t\t\t * @since WP 4.8.0\n\t\t\t *\n\t\t\t * @param array    $classes The CSS classes that are applied to the menu `<ul>` element.\n\t\t\t * @param stdClass $args    An object of `wp_nav_menu()` arguments.\n\t\t\t * @param int      $depth   Depth of menu item. Used for padding.\n\t\t\t */\n\t\t\t$class_names = join( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) );\n\t\t\t$class_names = $class_names ? ' class=\"' . esc_attr( $class_names ) . '\"' : '';\n\n\t\t\t/*\n\t\t\t * The `.dropdown-menu` container needs to have a labelledby\n\t\t\t * attribute which points to it's trigger link.\n\t\t\t *\n\t\t\t * Form a string for the labelledby attribute from the the latest\n\t\t\t * link with an id that was added to the $output.\n\t\t\t */\n\t\t\t$labelledby = '';\n\t\t\t// Find all links with an id in the output.\n\t\t\tpreg_match_all( '/(<a.*?id=\\\"|\\')(.*?)\\\"|\\'.*?>/im', $output, $matches );\n\t\t\t// With pointer at end of array check if we got an ID match.\n\t\t\tif ( end( $matches[2] ) ) {\n\t\t\t\t// Build a string to use as aria-labelledby.\n\t\t\t\t$labelledby = 'aria-labelledby=\"' . esc_attr( end( $matches[2] ) ) . '\"';\n\t\t\t}\n\t\t\t$output .= \"{$n}{$indent}<ul$class_names $labelledby>{$n}\";\n\t\t}\n\n\t\t/**\n\t\t * Starts the element output.\n\t\t *\n\t\t * @since WP 3.0.0\n\t\t * @since WP 4.4.0 The {@see 'nav_menu_item_args'} filter was added.\n\t\t *\n\t\t * @see Walker_Nav_Menu::start_el()\n\t\t *\n\t\t * @param string           $output Used to append additional content (passed by reference).\n\t\t * @param WP_Nav_Menu_Item $item   Menu item data object.\n\t\t * @param int              $depth  Depth of menu item. Used for padding.\n\t\t * @param WP_Nav_Menu_Args $args   An object of wp_nav_menu() arguments.\n\t\t * @param int              $id     Current item ID.\n\t\t */\n\t\tpublic function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {\n\t\t\tif ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {\n\t\t\t\t$t = '';\n\t\t\t\t$n = '';\n\t\t\t} else {\n\t\t\t\t$t = \"\\t\";\n\t\t\t\t$n = \"\\n\";\n\t\t\t}\n\t\t\t$indent = ( $depth ) ? str_repeat( $t, $depth ) : '';\n\n\t\t\tif ( false !== strpos( $args->items_wrap, 'itemscope' ) && false === $this->has_schema ) {\n\t\t\t\t$this->has_schema  = true;\n\t\t\t\t$args->link_before = '<span itemprop=\"name\">' . $args->link_before;\n\t\t\t\t$args->link_after .= '</span>';\n\t\t\t}\n\n\t\t\t$classes = empty( $item->classes ) ? array() : (array) $item->classes;\n\n\t\t\t// Updating the CSS classes of a menu item in the WordPress Customizer preview results in all classes defined\n\t\t\t// in that particular input box to come in as one big class string.\n\t\t\t$split_on_spaces = function ( $class ) {\n\t\t\t\treturn preg_split( '/\\s+/', $class );\n\t\t\t};\n\t\t\t$classes         = $this->flatten( array_map( $split_on_spaces, $classes ) );\n\n\t\t\t/*\n\t\t\t * Initialize some holder variables to store specially handled item\n\t\t\t * wrappers and icons.\n\t\t\t */\n\t\t\t$linkmod_classes = array();\n\t\t\t$icon_classes    = array();\n\n\t\t\t/*\n\t\t\t * Get an updated $classes array without linkmod or icon classes.\n\t\t\t *\n\t\t\t * NOTE: linkmod and icon class arrays are passed by reference and\n\t\t\t * are maybe modified before being used later in this function.\n\t\t\t */\n\t\t\t$classes = $this->separate_linkmods_and_icons_from_classes( $classes, $linkmod_classes, $icon_classes, $depth );\n\n\t\t\t// Join any icon classes plucked from $classes into a string.\n\t\t\t$icon_class_string = join( ' ', $icon_classes );\n\n\t\t\t/**\n\t\t\t * Filters the arguments for a single nav menu item.\n\t\t\t *\n\t\t\t * @since WP 4.4.0\n\t\t\t *\n\t\t\t * @param WP_Nav_Menu_Args $args  An object of wp_nav_menu() arguments.\n\t\t\t * @param WP_Nav_Menu_Item $item  Menu item data object.\n\t\t\t * @param int              $depth Depth of menu item. Used for padding.\n\t\t\t *\n\t\t\t * @var WP_Nav_Menu_Args\n\t\t\t */\n\t\t\t$args = apply_filters( 'nav_menu_item_args', $args, $item, $depth );\n\n\t\t\t// Add .dropdown or .active classes where they are needed.\n\t\t\tif ( $this->has_children ) {\n\t\t\t\t$classes[] = 'dropdown';\n\t\t\t}\n\t\t\tif ( in_array( 'current-menu-item', $classes, true ) || in_array( 'current-menu-parent', $classes, true ) ) {\n\t\t\t\t$classes[] = 'active';\n\t\t\t}\n\n\t\t\t// Add some additional default classes to the item.\n\t\t\t$classes[] = 'menu-item-' . $item->ID;\n\t\t\t$classes[] = 'nav-item';\n\n\t\t\t// Allow filtering the classes.\n\t\t\t$classes = apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth );\n\n\t\t\t// Form a string of classes in format: class=\"class_names\".\n\t\t\t$class_names = join( ' ', $classes );\n\t\t\t$class_names = $class_names ? ' class=\"' . esc_attr( $class_names ) . '\"' : '';\n\n\t\t\t/**\n\t\t\t * Filters the ID applied to a menu item's list item element.\n\t\t\t *\n\t\t\t * @since WP 3.0.1\n\t\t\t * @since WP 4.1.0 The `$depth` parameter was added.\n\t\t\t *\n\t\t\t * @param string           $menu_id The ID that is applied to the menu item's `<li>` element.\n\t\t\t * @param WP_Nav_Menu_Item $item    The current menu item.\n\t\t\t * @param WP_Nav_Menu_Args $args    An object of wp_nav_menu() arguments.\n\t\t\t * @param int              $depth   Depth of menu item. Used for padding.\n\t\t\t */\n\t\t\t$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );\n\t\t\t$id = $id ? ' id=\"' . esc_attr( $id ) . '\"' : '';\n\n\t\t\t$output .= $indent . '<li ' . $id . $class_names . '>';\n\n\t\t\t// Initialize array for holding the $atts for the link item.\n\t\t\t$atts           = array();\n\t\t\t$atts['title']  = ! empty( $item->attr_title ) ? $item->attr_title : '';\n\t\t\t$atts['target'] = ! empty( $item->target ) ? $item->target : '';\n\t\t\tif ( '_blank' === $item->target && empty( $item->xfn ) ) {\n\t\t\t\t$atts['rel'] = 'noopener noreferrer';\n\t\t\t} else {\n\t\t\t\t$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';\n\t\t\t}\n\n\t\t\t// If the item has_children add atts to <a>.\n\t\t\tif ( $this->has_children && 0 === $depth ) {\n\t\t\t\t$atts['href']          = '#';\n\t\t\t\t$atts['data-toggle']   = 'dropdown';\n\t\t\t\t$atts['aria-expanded'] = 'false';\n\t\t\t\t$atts['class']         = 'dropdown-toggle nav-link';\n\t\t\t\t$atts['id']            = 'menu-item-dropdown-' . $item->ID;\n\t\t\t} else {\n\t\t\t\tif ( true === $this->has_schema ) {\n\t\t\t\t\t$atts['itemprop'] = 'url';\n\t\t\t\t}\n\n\t\t\t\t$atts['href'] = ! empty( $item->url ) ? $item->url : '#';\n\t\t\t\t// For items in dropdowns use .dropdown-item instead of .nav-link.\n\t\t\t\tif ( $depth > 0 ) {\n\t\t\t\t\t$atts['class'] = 'dropdown-item';\n\t\t\t\t} else {\n\t\t\t\t\t$atts['class'] = 'nav-link';\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t$atts['aria-current'] = $item->current ? 'page' : '';\n\n\t\t\t// Update atts of this item based on any custom linkmod classes.\n\t\t\t$atts = $this->update_atts_for_linkmod_type( $atts, $linkmod_classes );\n\n\t\t\t// Allow filtering of the $atts array before using it.\n\t\t\t$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );\n\n\t\t\t// Build a string of html containing all the atts for the item.\n\t\t\t$attributes = '';\n\t\t\tforeach ( $atts as $attr => $value ) {\n\t\t\t\tif ( ! empty( $value ) ) {\n\t\t\t\t\t$value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );\n\t\t\t\t\t$attributes .= ' ' . $attr . '=\"' . $value . '\"';\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Set a typeflag to easily test if this is a linkmod or not.\n\t\t\t$linkmod_type = $this->get_linkmod_type( $linkmod_classes );\n\n\t\t\t// START appending the internal item contents to the output.\n\t\t\t$item_output = isset( $args->before ) ? $args->before : '';\n\n\t\t\t/*\n\t\t\t * This is the start of the internal nav item. Depending on what\n\t\t\t * kind of linkmod we have we may need different wrapper elements.\n\t\t\t */\n\t\t\tif ( '' !== $linkmod_type ) {\n\t\t\t\t// Is linkmod, output the required element opener.\n\t\t\t\t$item_output .= $this->linkmod_element_open( $linkmod_type, $attributes );\n\t\t\t} else {\n\t\t\t\t// With no link mod type set this must be a standard <a> tag.\n\t\t\t\t$item_output .= '<a' . $attributes . '>';\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Initiate empty icon var, then if we have a string containing any\n\t\t\t * icon classes form the icon markup with an <i> element. This is\n\t\t\t * output inside of the item before the $title (the link text).\n\t\t\t */\n\t\t\t$icon_html = '';\n\t\t\tif ( ! empty( $icon_class_string ) ) {\n\t\t\t\t// Append an <i> with the icon classes to what is output before links.\n\t\t\t\t$icon_html = '<i class=\"' . esc_attr( $icon_class_string ) . '\" aria-hidden=\"true\"></i> ';\n\t\t\t}\n\n\t\t\t/** This filter is documented in wp-includes/post-template.php */\n\t\t\t$title = apply_filters( 'the_title', $item->title, $item->ID );\n\n\t\t\t/**\n\t\t\t * Filters a menu item's title.\n\t\t\t *\n\t\t\t * @since WP 4.4.0\n\t\t\t *\n\t\t\t * @param string           $title The menu item's title.\n\t\t\t * @param WP_Nav_Menu_Item $item  The current menu item.\n\t\t\t * @param WP_Nav_Menu_Args $args  An object of wp_nav_menu() arguments.\n\t\t\t * @param int              $depth Depth of menu item. Used for padding.\n\t\t\t */\n\t\t\t$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );\n\n\t\t\t// If the .sr-only class was set apply to the nav items text only.\n\t\t\tif ( in_array( 'sr-only', $linkmod_classes, true ) ) {\n\t\t\t\t$title         = $this->wrap_for_screen_reader( $title );\n\t\t\t\t$keys_to_unset = array_keys( $linkmod_classes, 'sr-only', true );\n\t\t\t\tforeach ( $keys_to_unset as $k ) {\n\t\t\t\t\tunset( $linkmod_classes[ $k ] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Put the item contents into $output.\n\t\t\t$item_output .= isset( $args->link_before ) ? $args->link_before . $icon_html . $title . $args->link_after : '';\n\n\t\t\t/*\n\t\t\t * This is the end of the internal nav item. We need to close the\n\t\t\t * correct element depending on the type of link or link mod.\n\t\t\t */\n\t\t\tif ( '' !== $linkmod_type ) {\n\t\t\t\t// Is linkmod, output the required closing element.\n\t\t\t\t$item_output .= $this->linkmod_element_close( $linkmod_type );\n\t\t\t} else {\n\t\t\t\t// With no link mod type set this must be a standard <a> tag.\n\t\t\t\t$item_output .= '</a>';\n\t\t\t}\n\n\t\t\t$item_output .= isset( $args->after ) ? $args->after : '';\n\n\t\t\t// END appending the internal item contents to the output.\n\t\t\t$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );\n\t\t}\n\n\t\t/**\n\t\t * Menu fallback.\n\t\t *\n\t\t * If this function is assigned to the wp_nav_menu's fallback_cb variable\n\t\t * and a menu has not been assigned to the theme location in the WordPress\n\t\t * menu manager the function will display nothing to a non-logged in user,\n\t\t * and will add a link to the WordPress menu manager if logged in as an admin.\n\t\t *\n\t\t * @param array $args passed from the wp_nav_menu function.\n\t\t * @return string|void String when echo is false.\n\t\t */\n\t\tpublic static function fallback( $args ) {\n\t\t\tif ( ! current_user_can( 'edit_theme_options' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Initialize var to store fallback html.\n\t\t\t$fallback_output = '';\n\n\t\t\t// Menu container opening tag.\n\t\t\t$show_container = false;\n\t\t\tif ( $args['container'] ) {\n\t\t\t\t/**\n\t\t\t\t * Filters the list of HTML tags that are valid for use as menu containers.\n\t\t\t\t *\n\t\t\t\t * @since WP 3.0.0\n\t\t\t\t *\n\t\t\t\t * @param array $tags The acceptable HTML tags for use as menu containers.\n\t\t\t\t *                    Default is array containing 'div' and 'nav'.\n\t\t\t\t */\n\t\t\t\t$allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );\n\t\t\t\tif ( is_string( $args['container'] ) && in_array( $args['container'], $allowed_tags, true ) ) {\n\t\t\t\t\t$show_container   = true;\n\t\t\t\t\t$class            = $args['container_class'] ? ' class=\"menu-fallback-container ' . esc_attr( $args['container_class'] ) . '\"' : ' class=\"menu-fallback-container\"';\n\t\t\t\t\t$id               = $args['container_id'] ? ' id=\"' . esc_attr( $args['container_id'] ) . '\"' : '';\n\t\t\t\t\t$fallback_output .= '<' . $args['container'] . $id . $class . '>';\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// The fallback menu.\n\t\t\t$class            = $args['menu_class'] ? ' class=\"menu-fallback-menu ' . esc_attr( $args['menu_class'] ) . '\"' : ' class=\"menu-fallback-menu\"';\n\t\t\t$id               = $args['menu_id'] ? ' id=\"' . esc_attr( $args['menu_id'] ) . '\"' : '';\n\t\t\t$fallback_output .= '<ul' . $id . $class . '>';\n\t\t\t$fallback_output .= '<li class=\"nav-item\"><a href=\"' . esc_url( admin_url( 'nav-menus.php' ) ) . '\" class=\"nav-link\" title=\"' . esc_attr__( 'Add a menu', 'wp-bootstrap-navwalker' ) . '\">' . esc_html__( 'Add a menu', 'wp-bootstrap-navwalker' ) . '</a></li>';\n\t\t\t$fallback_output .= '</ul>';\n\n\t\t\t// Menu container closing tag.\n\t\t\tif ( $show_container ) {\n\t\t\t\t$fallback_output .= '</' . $args['container'] . '>';\n\t\t\t}\n\n\t\t\t// if $args has 'echo' key and it's true echo, otherwise return.\n\t\t\tif ( array_key_exists( 'echo', $args ) && $args['echo'] ) {\n\t\t\t\t// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped\n\t\t\t\techo $fallback_output;\n\t\t\t} else {\n\t\t\t\treturn $fallback_output;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Filter to ensure the items_Wrap argument contains microdata.\n\t\t *\n\t\t * @since 4.2.0\n\t\t *\n\t\t * @param  array $args The nav instance arguments.\n\t\t * @return array $args The altered nav instance arguments.\n\t\t */\n\t\tpublic function add_schema_to_navbar_ul( $args ) {\n\t\t\tif ( isset( $args['items_wrap'] ) ) {\n\t\t\t\t$wrap = $args['items_wrap'];\n\t\t\t\tif ( strpos( $wrap, 'SiteNavigationElement' ) === false ) {\n\t\t\t\t\t$args['items_wrap'] = preg_replace( '/(>).*>?\\%3\\$s/', ' itemscope itemtype=\"http://www.schema.org/SiteNavigationElement\"$0', $wrap );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn $args;\n\t\t}\n\n\t\t/**\n\t\t * Find any custom linkmod or icon classes and store in their holder\n\t\t * arrays then remove them from the main classes array.\n\t\t *\n\t\t * Supported linkmods: .disabled, .dropdown-header, .dropdown-divider, .sr-only\n\t\t * Supported iconsets: Font Awesome 4/5, Glypicons\n\t\t *\n\t\t * NOTE: This accepts the linkmod and icon arrays by reference.\n\t\t *\n\t\t * @since 4.0.0\n\t\t *\n\t\t * @param array   $classes         an array of classes currently assigned to the item.\n\t\t * @param array   $linkmod_classes an array to hold linkmod classes.\n\t\t * @param array   $icon_classes    an array to hold icon classes.\n\t\t * @param integer $depth           an integer holding current depth level.\n\t\t *\n\t\t * @return array  $classes         a maybe modified array of classnames.\n\t\t */\n\t\tprivate function separate_linkmods_and_icons_from_classes( $classes, &$linkmod_classes, &$icon_classes, $depth ) {\n\t\t\t// Loop through $classes array to find linkmod or icon classes.\n\t\t\tforeach ( $classes as $key => $class ) {\n\t\t\t\t/*\n\t\t\t\t * If any special classes are found, store the class in it's\n\t\t\t\t * holder array and and unset the item from $classes.\n\t\t\t\t */\n\t\t\t\tif ( preg_match( '/^disabled|^sr-only/i', $class ) ) {\n\t\t\t\t\t// Test for .disabled or .sr-only classes.\n\t\t\t\t\t$linkmod_classes[] = $class;\n\t\t\t\t\tunset( $classes[ $key ] );\n\t\t\t\t} elseif ( preg_match( '/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class ) && $depth > 0 ) {\n\t\t\t\t\t/*\n\t\t\t\t\t * Test for .dropdown-header or .dropdown-divider and a\n\t\t\t\t\t * depth greater than 0 - IE inside a dropdown.\n\t\t\t\t\t */\n\t\t\t\t\t$linkmod_classes[] = $class;\n\t\t\t\t\tunset( $classes[ $key ] );\n\t\t\t\t} elseif ( preg_match( '/^fa-(\\S*)?|^fa(s|r|l|b)?(\\s?)?$/i', $class ) ) {\n\t\t\t\t\t// Font Awesome.\n\t\t\t\t\t$icon_classes[] = $class;\n\t\t\t\t\tunset( $classes[ $key ] );\n\t\t\t\t} elseif ( preg_match( '/^glyphicon-(\\S*)?|^glyphicon(\\s?)$/i', $class ) ) {\n\t\t\t\t\t// Glyphicons.\n\t\t\t\t\t$icon_classes[] = $class;\n\t\t\t\t\tunset( $classes[ $key ] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn $classes;\n\t\t}\n\n\t\t/**\n\t\t * Return a string containing a linkmod type and update $atts array\n\t\t * accordingly depending on the decided.\n\t\t *\n\t\t * @since 4.0.0\n\t\t *\n\t\t * @param array $linkmod_classes array of any link modifier classes.\n\t\t *\n\t\t * @return string                empty for default, a linkmod type string otherwise.\n\t\t */\n\t\tprivate function get_linkmod_type( $linkmod_classes = array() ) {\n\t\t\t$linkmod_type = '';\n\t\t\t// Loop through array of linkmod classes to handle their $atts.\n\t\t\tif ( ! empty( $linkmod_classes ) ) {\n\t\t\t\tforeach ( $linkmod_classes as $link_class ) {\n\t\t\t\t\tif ( ! empty( $link_class ) ) {\n\n\t\t\t\t\t\t// Check for special class types and set a flag for them.\n\t\t\t\t\t\tif ( 'dropdown-header' === $link_class ) {\n\t\t\t\t\t\t\t$linkmod_type = 'dropdown-header';\n\t\t\t\t\t\t} elseif ( 'dropdown-divider' === $link_class ) {\n\t\t\t\t\t\t\t$linkmod_type = 'dropdown-divider';\n\t\t\t\t\t\t} elseif ( 'dropdown-item-text' === $link_class ) {\n\t\t\t\t\t\t\t$linkmod_type = 'dropdown-item-text';\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn $linkmod_type;\n\t\t}\n\n\t\t/**\n\t\t * Update the attributes of a nav item depending on the limkmod classes.\n\t\t *\n\t\t * @since 4.0.0\n\t\t *\n\t\t * @param array $atts            array of atts for the current link in nav item.\n\t\t * @param array $linkmod_classes an array of classes that modify link or nav item behaviors or displays.\n\t\t *\n\t\t * @return array                 maybe updated array of attributes for item.\n\t\t */\n\t\tprivate function update_atts_for_linkmod_type( $atts = array(), $linkmod_classes = array() ) {\n\t\t\tif ( ! empty( $linkmod_classes ) ) {\n\t\t\t\tforeach ( $linkmod_classes as $link_class ) {\n\t\t\t\t\tif ( ! empty( $link_class ) ) {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * Update $atts with a space and the extra classname\n\t\t\t\t\t\t * so long as it's not a sr-only class.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tif ( 'sr-only' !== $link_class ) {\n\t\t\t\t\t\t\t$atts['class'] .= ' ' . esc_attr( $link_class );\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Check for special class types we need additional handling for.\n\t\t\t\t\t\tif ( 'disabled' === $link_class ) {\n\t\t\t\t\t\t\t// Convert link to '#' and unset open targets.\n\t\t\t\t\t\t\t$atts['href'] = '#';\n\t\t\t\t\t\t\tunset( $atts['target'] );\n\t\t\t\t\t\t} elseif ( 'dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class ) {\n\t\t\t\t\t\t\t// Store a type flag and unset href and target.\n\t\t\t\t\t\t\tunset( $atts['href'] );\n\t\t\t\t\t\t\tunset( $atts['target'] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn $atts;\n\t\t}\n\n\t\t/**\n\t\t * Wraps the passed text in a screen reader only class.\n\t\t *\n\t\t * @since 4.0.0\n\t\t *\n\t\t * @param string $text the string of text to be wrapped in a screen reader class.\n\t\t * @return string      the string wrapped in a span with the class.\n\t\t */\n\t\tprivate function wrap_for_screen_reader( $text = '' ) {\n\t\t\tif ( $text ) {\n\t\t\t\t$text = '<span class=\"sr-only\">' . $text . '</span>';\n\t\t\t}\n\t\t\treturn $text;\n\t\t}\n\n\t\t/**\n\t\t * Returns the correct opening element and attributes for a linkmod.\n\t\t *\n\t\t * @since 4.0.0\n\t\t *\n\t\t * @param string $linkmod_type a sting containing a linkmod type flag.\n\t\t * @param string $attributes   a string of attributes to add to the element.\n\t\t *\n\t\t * @return string              a string with the openign tag for the element with attribibutes added.\n\t\t */\n\t\tprivate function linkmod_element_open( $linkmod_type, $attributes = '' ) {\n\t\t\t$output = '';\n\t\t\tif ( 'dropdown-item-text' === $linkmod_type ) {\n\t\t\t\t$output .= '<span class=\"dropdown-item-text\"' . $attributes . '>';\n\t\t\t} elseif ( 'dropdown-header' === $linkmod_type ) {\n\t\t\t\t/*\n\t\t\t\t * For a header use a span with the .h6 class instead of a real\n\t\t\t\t * header tag so that it doesn't confuse screen readers.\n\t\t\t\t */\n\t\t\t\t$output .= '<span class=\"dropdown-header h6\"' . $attributes . '>';\n\t\t\t} elseif ( 'dropdown-divider' === $linkmod_type ) {\n\t\t\t\t// This is a divider.\n\t\t\t\t$output .= '<div class=\"dropdown-divider\"' . $attributes . '>';\n\t\t\t}\n\t\t\treturn $output;\n\t\t}\n\n\t\t/**\n\t\t * Return the correct closing tag for the linkmod element.\n\t\t *\n\t\t * @since 4.0.0\n\t\t *\n\t\t * @param string $linkmod_type a string containing a special linkmod type.\n\t\t *\n\t\t * @return string              a string with the closing tag for this linkmod type.\n\t\t */\n\t\tprivate function linkmod_element_close( $linkmod_type ) {\n\t\t\t$output = '';\n\t\t\tif ( 'dropdown-header' === $linkmod_type || 'dropdown-item-text' === $linkmod_type ) {\n\t\t\t\t/*\n\t\t\t\t * For a header use a span with the .h6 class instead of a real\n\t\t\t\t * header tag so that it doesn't confuse screen readers.\n\t\t\t\t */\n\t\t\t\t$output .= '</span>';\n\t\t\t} elseif ( 'dropdown-divider' === $linkmod_type ) {\n\t\t\t\t// This is a divider.\n\t\t\t\t$output .= '</div>';\n\t\t\t}\n\t\t\treturn $output;\n\t\t}\n\n\t\t/**\n\t\t * Flattens a multidimensional array to a simple array.\n\t\t *\n\t\t * @param array $array a multidimensional array.\n\t\t *\n\t\t * @return array a simple array\n\t\t */\n\t\tpublic function flatten( $array ) {\n\t\t\t$result = array();\n\t\t\tforeach ( $array as $element ) {\n\t\t\t\tif ( is_array( $element ) ) {\n\t\t\t\t\tarray_push( $result, ...$this->flatten( $element ) );\n\t\t\t\t} else {\n\t\t\t\t\t$result[] = $element;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn $result;\n\t\t}\n\n\t}\n\nendif;\n"
  },
  {
    "path": "composer.json",
    "content": "{\n    \"name\": \"wp-bootstrap/wp-bootstrap-navwalker\",\n    \"description\": \"A custom WordPress nav walker class to fully implement the Bootstrap 4 navigation style in a custom theme using the WordPress built in menu manager.\",\n    \"type\": \"library\",\n    \"license\": \"GPL-3.0+\",\n    \"authors\": [\n        {\n            \"name\": \"Brandon Hubbard\"\n        },\n        {\n            \"name\": \"William Patton\",\n            \"email\": \"will@pattonwebz.com\"\n        }\n    ],\n    \"support\": {\n        \"issues\": \"https://github.com/wp-bootstrap/wp-bootstrap-navwalker/issues/\",\n        \"source\": \"https://github.com/wp-bootstrap/wp-bootstrap-navwalker/\"\n    },\n    \"require\": {\n      \"composer/installers\": \"~1.0\",\n      \"php\": \"^5.5 || ^7.0\"\n    },\n    \"require-dev\": {\n        \"stevegrunwell/wp-enforcer\": \"^0.5.0\"\n    },\n    \"archive\": {\n        \"exclude\": [\"/.*\", \"/composer.lock\"]\n    },\n    \"scripts\": {\n        \"post-install-cmd\": [\n            \"wp-enforcer\"\n        ],\n        \"post-update-cmd\": [\n            \"wp-enforcer\"\n        ]\n    }\n}\n"
  },
  {
    "path": "phpcs.xml.dist",
    "content": "<?xml version=\"1.0\"?>\n<ruleset name=\"WordPress Coding Standards for Plugins\">\n\t<description>Generally-applicable sniffs for WordPress plugins</description>\n\n\t<rule ref=\"WordPress-Core\"/>\n\t<rule ref=\"WordPress-Docs\"/>\n\n\t<file>./class-wp-bootstrap-navwalker.php</file>\n\t<file>./tests/</file>\n</ruleset>\n"
  },
  {
    "path": "phpstan.neon.dist",
    "content": "includes:\n    - phar://phpstan.phar/conf/bleedingEdge.neon\n    - vendor/szepeviktor/phpstan-wordpress/extension.neon\nparameters:\n    level: 6\n    inferPrivatePropertyTypeFromConstructor: true\n    checkMissingIterableValueType: false\n    paths:\n        - class-wp-bootstrap-navwalker.php\n    scanFiles:\n        - tests/phpstan/class-wp-nav-menu-args.php\n        - tests/phpstan/class-wp-nav-menu-item.php\n        - class-wp-bootstrap-navwalker.php\n    ignoreErrors:\n        # Uses func_get_args()\n        - '#^Function apply_filters(_ref_array)? invoked with [34567] parameters, 2 required\\.$#'\n        # False item type in core.\n        -\n            message: \"#^Parameter \\\\#2 \\\\$item \\\\(WP_Nav_Menu_Item\\\\) of method WP_Bootstrap_Navwalker\\\\:\\\\:start_el\\\\(\\\\) should be compatible with parameter \\\\$item \\\\(WP_Post\\\\) of method Walker_Nav_Menu\\\\:\\\\:start_el\\\\(\\\\)$#\"\n            path: class-wp-bootstrap-navwalker.php\n        # $output passed by reference.\n        -\n            message: '#^Method WP_Bootstrap_Navwalker::(start_lvl|start_el)\\(\\) has no return typehint specified\\.$#'\n            path: class-wp-bootstrap-navwalker.php\n        # Uncertain properties.\n        -\n            message: '#^Property WP_Nav_Menu_Args::\\$\\S+ \\(string\\) in isset\\(\\) is not nullable\\.$#'\n            path: class-wp-bootstrap-navwalker.php\n"
  },
  {
    "path": "phpunit.xml.dist",
    "content": "<phpunit\n\tbootstrap=\"tests/bootstrap.php\"\n\tbackupGlobals=\"false\"\n\tcolors=\"true\"\n\tconvertErrorsToExceptions=\"true\"\n\tconvertNoticesToExceptions=\"true\"\n\tconvertWarningsToExceptions=\"true\"\n\t>\n\t<testsuites>\n\t\t<testsuite>\n\t\t\t<directory prefix=\"test-\" suffix=\".php\">./tests/</directory>\n\t\t</testsuite>\n\t</testsuites>\n</phpunit>\n"
  },
  {
    "path": "tests/bootstrap.php",
    "content": "<?php\n/**\n * PHPUnit bootstrap file\n *\n * @package Wp_Bootstrap_Navwalker\n */\n\n$_tests_dir = getenv( 'WP_TESTS_DIR' );\nif ( ! $_tests_dir ) {\n\t$_tests_dir = '/tmp/wordpress-tests-lib';\n}\n\n// Give access to tests_add_filter() function.\nrequire_once $_tests_dir . '/includes/functions.php';\n\n/**\n * Manually load the plugin being tested.\n */\nfunction _manually_load_plugin() {\n\trequire dirname( dirname( __FILE__ ) ) . '/class-wp-bootstrap-navwalker.php';\n}\ntests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );\n\n// Start up the WP testing environment.\nrequire $_tests_dir . '/includes/bootstrap.php';\n"
  },
  {
    "path": "tests/phpstan/class-wp-nav-menu-args.php",
    "content": "<?php\n/**\n * Data object for displaying navigation menu.\n * Created to aid static analysis.\n *\n * @package WordPress\n * @see wp_nav_menu()\n */\n\n/**\n * Nav menu arguments.\n */\nclass WP_Nav_Menu_Args {\n\n\t/**\n\t * Desired menu. Accepts a menu ID, slug, name, or object. Default empty.\n\t *\n\t * @var int|string|\\WP_Term\n\t */\n\tpublic $menu;\n\n\t/**\n\t * CSS class to use for the ul element which forms the menu. Default 'menu'.\n\t *\n\t * @var string\n\t */\n\tpublic $menu_class;\n\n\t/**\n\t * The ID that is applied to the ul element which forms the menu.\n\t * Default is the menu slug, incremented.\n\t *\n\t * @var string\n\t */\n\tpublic $menu_id;\n\n\t/**\n\t * Whether to wrap the ul, and what to wrap it with. Default 'div'.\n\t *\n\t * @var string\n\t */\n\tpublic $container;\n\n\t/**\n\t * Class that is applied to the container. Default 'menu-{menu slug}-container'.\n\t *\n\t * @var string\n\t */\n\tpublic $container_class;\n\n\t/**\n\t * The ID that is applied to the container. Default empty.\n\t *\n\t * @var string\n\t */\n\tpublic $container_id;\n\n\t/**\n\t * The aria-label attribute that is applied to the container\n\t * when it's a nav element. Default empty.\n\t *\n\t * @var string\n\t */\n\tpublic $container_aria_label;\n\n\t/**\n\t * If the menu doesn't exists, a callback function will fire.\n\t * Default is 'wp_page_menu'. Set to false for no fallback.\n\t *\n\t * @var callable|bool\n\t */\n\tpublic $fallback_cb;\n\n\t/**\n\t * Text before the link markup. Default empty.\n\t *\n\t * @var string\n\t */\n\tpublic $before;\n\n\t/**\n\t * Text after the link markup. Default empty.\n\t *\n\t * @var string\n\t */\n\tpublic $after;\n\n\t/**\n\t * Text before the link text. Default empty.\n\t *\n\t * @var string\n\t */\n\tpublic $link_before;\n\n\t/**\n\t * Text after the link text. Default empty.\n\t *\n\t * @var string\n\t */\n\tpublic $link_after;\n\n\t/**\n\t * Whether to echo the menu or return it. Default true.\n\t *\n\t * @var bool\n\t */\n\tpublic $echo;\n\n\t/**\n\t * How many levels of the hierarchy are to be included. 0 means all.\n\t * Default 0.\n\t *\n\t * @var int\n\t */\n\tpublic $depth;\n\n\t/**\n\t * Instance of a custom walker class. Default empty.\n\t *\n\t * @var \\Walker_Nav_Menu\n\t */\n\tpublic $walker;\n\n\t/**\n\t * Theme location to be used. Must be registered with register_nav_menu()\n\t * in order to be selectable by the user.\n\t *\n\t * @var string\n\t */\n\tpublic $theme_location;\n\n\t/**\n\t * How the list items should be wrapped. Default is a ul with an id and class.\n\t * Uses printf() format with numbered placeholders.\n\t *\n\t * @var string\n\t */\n\tpublic $items_wrap;\n\n\t/**\n\t * Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'.\n\t * Default 'preserve'.\n\t *\n\t * @var string\n\t */\n\tpublic $item_spacing;\n}\n"
  },
  {
    "path": "tests/phpstan/class-wp-nav-menu-item.php",
    "content": "<?php\n/**\n * Value object for nav menu item objects.\n *\n * Created to aid static analysis by PHPStan.\n *\n * @package WordPress\n * @see wp_setup_nav_menu_item()\n */\n\n/**\n * Decorates a menu item (WP_Post) object with the shared navigation menu item properties.\n */\nclass WP_Nav_Menu_Item {\n\n\t/**\n\t * The term_id if the menu item represents a taxonomy term.\n\t *\n\t * @overrides WP_Post\n\t * @var int\n\t */\n\tpublic $ID;\n\n\t/**\n\t * The title attribute of the link element for this menu item.\n\t *\n\t * @var string\n\t */\n\tpublic $attr_title;\n\n\t/**\n\t * The array of class attribute values for the link element of this menu item.\n\t *\n\t * @var array\n\t */\n\tpublic $classes;\n\n\t/**\n\t * The DB ID of this item as a nav_menu_item object, if it exists (0 if it doesn't exist).\n\t *\n\t * @var int\n\t */\n\tpublic $db_id;\n\n\t/**\n\t * The description of this menu item.\n\t *\n\t * @var string\n\t */\n\tpublic $description;\n\n\t/**\n\t * The DB ID of the nav_menu_item that is this item's menu parent, if any. 0 otherwise.\n\t *\n\t * @var int\n\t */\n\tpublic $menu_item_parent;\n\n\t/**\n\t * The type of object originally represented, such as \"category,\" \"post\", or \"attachment.\"\n\t *\n\t * @var string\n\t */\n\tpublic $object;\n\n\t/**\n\t * The DB ID of the original object this menu item represents,\n\t * e.g. ID for posts and term_id for categories.\n\t *\n\t * @var int\n\t */\n\tpublic $object_id;\n\n\t/**\n\t * The DB ID of the original object's parent object, if any (0 otherwise).\n\t *\n\t * @overrides WP_Post\n\t * @var int\n\t */\n\tpublic $post_parent;\n\n\t/**\n\t * A \"no title\" label if menu item represents a post that lacks a title.\n\t *\n\t * @overrides WP_Post\n\t * @var string\n\t */\n\tpublic $post_title;\n\n\t/**\n\t * The target attribute of the link element for this menu item.\n\t *\n\t * @var string\n\t */\n\tpublic $target;\n\n\t/**\n\t * The title of this menu item.\n\t *\n\t * @var string\n\t */\n\tpublic $title;\n\n\t/**\n\t * The family of objects originally represented, such as \"post_type\" or \"taxonomy.\"\n\t *\n\t * @var string\n\t */\n\tpublic $type;\n\n\t/**\n\t * The singular label used to describe this type of menu item.\n\t *\n\t * @var string\n\t */\n\tpublic $type_label;\n\n\t/**\n\t * The URL to which this menu item points.\n\t *\n\t * @var string\n\t */\n\tpublic $url;\n\n\t/**\n\t * The XFN relationship expressed in the link of this menu item.\n\t *\n\t * @var string\n\t */\n\tpublic $xfn;\n\n\t/**\n\t * Whether the menu item represents an object that no longer exists.\n\t *\n\t * @var bool\n\t */\n\tpublic $_invalid; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore\n\n\t/**\n\t * Whether the menu item represents the active menu item.\n\t *\n\t * @var bool\n\t */\n\tpublic $current;\n\n\t/**\n\t * Whether the menu item represents an parent menu item.\n\t *\n\t * @var bool\n\t */\n\tpublic $current_item_parent;\n\n\t/**\n\t * Whether the menu item represents an ancestor menu item.\n\t *\n\t * @var bool\n\t */\n\tpublic $current_item_ancestor;\n\n\t/* Copy of WP_Post */\n\n\t/**\n\t * ID of post author.\n\t *\n\t * A numeric string, for compatibility reasons.\n\t *\n\t * @var string\n\t */\n\tpublic $post_author = 0;\n\n\t/**\n\t * The post's local publication time.\n\t *\n\t * @var string\n\t */\n\tpublic $post_date = '0000-00-00 00:00:00';\n\n\t/**\n\t * The post's GMT publication time.\n\t *\n\t * @var string\n\t */\n\tpublic $post_date_gmt = '0000-00-00 00:00:00';\n\n\t/**\n\t * The post's content.\n\t *\n\t * @var string\n\t */\n\tpublic $post_content = '';\n\n\t/**\n\t * The post's excerpt.\n\t *\n\t * @var string\n\t */\n\tpublic $post_excerpt = '';\n\n\t/**\n\t * The post's status.\n\t *\n\t * @var string\n\t */\n\tpublic $post_status = 'publish';\n\n\t/**\n\t * Whether comments are allowed.\n\t *\n\t * @var string\n\t */\n\tpublic $comment_status = 'open';\n\n\t/**\n\t * Whether pings are allowed.\n\t *\n\t * @var string\n\t */\n\tpublic $ping_status = 'open';\n\n\t/**\n\t * The post's password in plain text.\n\t *\n\t * @var string\n\t */\n\tpublic $post_password = '';\n\n\t/**\n\t * The post's slug.\n\t *\n\t * @var string\n\t */\n\tpublic $post_name = '';\n\n\t/**\n\t * URLs queued to be pinged.\n\t *\n\t * @var string\n\t */\n\tpublic $to_ping = '';\n\n\t/**\n\t * URLs that have been pinged.\n\t *\n\t * @var string\n\t */\n\tpublic $pinged = '';\n\n\t/**\n\t * The post's local modified time.\n\t *\n\t * @var string\n\t */\n\tpublic $post_modified = '0000-00-00 00:00:00';\n\n\t/**\n\t * The post's GMT modified time.\n\t *\n\t * @var string\n\t */\n\tpublic $post_modified_gmt = '0000-00-00 00:00:00';\n\n\t/**\n\t * A utility DB field for post content.\n\t *\n\t * @var string\n\t */\n\tpublic $post_content_filtered = '';\n\n\t/**\n\t * The unique identifier for a post, not necessarily a URL, used as the feed GUID.\n\t *\n\t * @var string\n\t */\n\tpublic $guid = '';\n\n\t/**\n\t * A field used for ordering posts.\n\t *\n\t * @var int\n\t */\n\tpublic $menu_order = 0;\n\n\t/**\n\t * The post's type, like post or page.\n\t *\n\t * @var string\n\t */\n\tpublic $post_type = 'post';\n\n\t/**\n\t * An attachment's mime type.\n\t *\n\t * @var string\n\t */\n\tpublic $post_mime_type = '';\n\n\t/**\n\t * Cached comment count.\n\t *\n\t * A numeric string, for compatibility reasons.\n\t *\n\t * @var string\n\t */\n\tpublic $comment_count = 0;\n\n\t/**\n\t * Stores the post object's sanitization level.\n\t *\n\t * Does not correspond to a DB field.\n\t *\n\t * @var string\n\t */\n\tpublic $filter;\n}\n"
  },
  {
    "path": "tests/test-navwalker.php",
    "content": "<?php\n/**\n * Class SampleTest\n *\n * @package Wp_Bootstrap_Navwalker\n *\n * phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_print_r -- used for returned failure messages to give some details.\n */\n\n/**\n * Test_WP_Bootstrap_NavWalker class.\n *\n * @extends WP_UnitTestCase\n */\nclass Test_WP_Bootstrap_NavWalker extends WP_UnitTestCase {\n\t/**\n\t * The setUp function.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function setUp() {\n\n\t\tparent::setUp();\n\n\t\t$this->walker = new WP_Bootstrap_Navwalker();\n\n\t\t// this is a test array of valid values that the fallback method will accept.\n\t\t$this->valid_sample_fallback_args = array(\n\t\t\t'container'       => 'div',\n\t\t\t'container_id'    => 'a_container_id',\n\t\t\t'container_class' => 'a_container_class',\n\t\t\t'menu_class'      => 'a_menu_class',\n\t\t\t'menu_id'         => 'a_menu_id',\n\t\t\t'echo'            => true,\n\t\t);\n\n\t\t// array of the possible linkmod typeflags.\n\t\t$this->valid_linkmod_typeflags = array(\n\t\t\t'dropdown-header',\n\t\t\t'dropdown-divider',\n\t\t\t'dropdown-item-text',\n\t\t);\n\n\t\t// array of all possible linkmods, including the valid typeflags.\n\t\t$this->valid_linkmod_classes = array_merge(\n\t\t\t$this->valid_linkmod_typeflags,\n\t\t\tarray(\n\t\t\t\t'disabled',\n\t\t\t\t'sr-only',\n\t\t\t)\n\t\t);\n\n\t\t// array of valid font-awesome icon class starters plus some randomly\n\t\t// chosen icon classes and some variations of upper/lower case letters.\n\t\t$this->some_fontawesome_classes = array(\n\t\t\t'fa',\n\t\t\t'fas',\n\t\t\t'fab',\n\t\t\t'far',\n\t\t\t'fal',\n\t\t\t'fa-android',\n\t\t\t'fa-css3',\n\t\t\t'fa-home',\n\t\t\t'fa-bluetooth-b',\n\t\t\t'fa-chess-rook',\n\t\t\t'fA-home',\n\t\t\t'Fa-HoMe',\n\t\t\t'fa-HomE',\n\t\t);\n\n\t\t// array of valid glyphicon icon class starters plus some randomly\n\t\t// chosen icon classes and some variations of upper/lower case letters.\n\t\t$this->some_glyphicons_classes = array(\n\t\t\t'glyphicon',\n\t\t\t'glyphicon-asterisk',\n\t\t\t'glyphicon-ok',\n\t\t\t'glyphicon-file',\n\t\t\t'glyphicon-hand-left',\n\t\t\t'glyphicon-sd-video',\n\t\t\t'glyphicon-subscript',\n\t\t\t'glyphicon-grain',\n\t\t\t'Glyphicon-file',\n\t\t\t'Glyphicon-File',\n\t\t\t'glyphicon-File',\n\t\t\t'glYphiCon-fiLe',\n\t\t);\n\n\t}\n\n\t/**\n\t * Test NavWalker File Exists.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_navwalker_file_exists() {\n\t\t$this->assertFileExists( 'class-wp-bootstrap-navwalker.php' );\n\t}\n\n\t/**\n\t * Test Start LVL Function.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_startlvl_function_exists() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\n\t\t$this->assertTrue(\n\t\t\tmethod_exists( $wp_bootstrap_navwalker, 'start_lvl' ),\n\t\t\t'Class does not have method start_lvl.'\n\t\t);\n\n\t}\n\n\t/**\n\t * Test Start El Function.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_start_el_function_exists() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\n\t\t$this->assertTrue(\n\t\t\tmethod_exists( $wp_bootstrap_navwalker, 'start_el' ),\n\t\t\t'Class does not have method start_el.'\n\t\t);\n\n\t}\n\n\t/**\n\t * Test for Display Element.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_display_element_function_exists() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\n\t\t$this->assertTrue(\n\t\t\tmethod_exists( $wp_bootstrap_navwalker, 'display_element' ),\n\t\t\t'Class does not have method display_element.'\n\t\t);\n\n\t}\n\n\t/**\n\t * Test Fallback function exists.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_fallback_function_exists() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\n\t\t$this->assertTrue(\n\t\t\tmethod_exists( $wp_bootstrap_navwalker, 'fallback' ),\n\t\t\t'Class does not have method fallback.'\n\t\t);\n\n\t}\n\n\t/**\n\t * Test Fallback method output for logged out users.\n\t *\n\t * Expects that for logged out users both echo and return requests should\n\t * produce empty strings.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_fallback_function_output_loggedout() {\n\n\t\t// default is to echo reults, buffer.\n\t\tob_start();\n\t\tWP_Bootstrap_Navwalker::fallback( $this->valid_sample_fallback_args );\n\t\t$fallback_output_echo = ob_get_clean();\n\n\t\t// empty string expected when not logged in.\n\t\t$this->assertEmpty(\n\t\t\t$fallback_output_echo,\n\t\t\t'Fallback output for logged out user created a non-empty string in echo mode.'\n\t\t);\n\n\t\t// set 'echo' to false and request the markup returned.\n\t\t$fallback_output_return = WP_Bootstrap_Navwalker::fallback(\n\t\t\tarray_merge(\n\t\t\t\t$this->valid_sample_fallback_args,\n\t\t\t\tarray(\n\t\t\t\t\t'echo' => false,\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\n\t\t// return and echo should result in the same values (both empty).\n\t\t$this->assertEquals(\n\t\t\t$fallback_output_echo,\n\t\t\t$fallback_output_return,\n\t\t\t'Fallback output for logged out user created a non-empty string in return mode.'\n\t\t);\n\t}\n\n\t/**\n\t * Test Fallback method output for logged in users.\n\t *\n\t * Expects strings to be produced with html markup and that they match when\n\t * requesting either a return or defaulting to echo.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_fallback_function_output_loggedin() {\n\n\t\t// make an admin user and set it to be the current user.\n\t\t$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );\n\t\twp_set_current_user( $user_id );\n\n\t\t// default is to echo results, buffer.\n\t\tob_start();\n\t\tWP_Bootstrap_Navwalker::fallback( $this->valid_sample_fallback_args );\n\t\t$fallback_output_echo = ob_get_clean();\n\n\t\t// rudimentary content test - confirm it opens a div with 2 expected\n\t\t// values and ends by closing a div.\n\t\t$match = ( preg_match( '/^(<div id=\"a_container_id\" class=\"menu-fallback-container a_container_class\">)(.*?)(<\\/div>)$/', $fallback_output_echo ) ) ? true : false;\n\t\t$this->assertTrue(\n\t\t\t$match,\n\t\t\t'Fallback method seems to create unexpected html for logged in users in echo mode.'\n\t\t);\n\n\t\t// set 'echo' to false and request the markup returned.\n\t\t$fallback_output_return = WP_Bootstrap_Navwalker::fallback(\n\t\t\tarray_merge(\n\t\t\t\t$this->valid_sample_fallback_args,\n\t\t\t\tarray(\n\t\t\t\t\t'echo' => false,\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\n\t\t// return and echo should both produce the same strings.\n\t\t$this->assertEquals(\n\t\t\t$fallback_output_echo,\n\t\t\t$fallback_output_return,\n\t\t\t'Fallback method seems to create unexpected html for logged in users in return mode.'\n\t\t);\n\t}\n\n\t/**\n\t * Test separate_linkmods_and_icons_from_classes Function exists.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_separate_linkmods_and_icons_from_classes_function_exists() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\n\t\t$this->assertTrue(\n\t\t\tmethod_exists( $wp_bootstrap_navwalker, 'separate_linkmods_and_icons_from_classes' ),\n\t\t\t'Class does not have method separate_linkmods_and_icons_from_classes.'\n\t\t);\n\n\t}\n\n\t/**\n\t * Test that the function catches a random assortment of glyphicon icon\n\t * classes mixed with with regular classnames.\n\t *\n\t * @depends test_separate_linkmods_and_icons_from_classes_function_exists\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_separate_linkmods_and_icons_from_classes_fontawesome() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\t\t// since we're working with private methods we need to use a reflector.\n\t\t$reflector = new ReflectionClass( 'WP_Bootstrap_Navwalker' );\n\n\t\t// get a reflected method for the opener function and set to public.\n\t\t$method_open = $reflector->getMethod( 'separate_linkmods_and_icons_from_classes' );\n\t\t$method_open->setAccessible( true );\n\n\t\t$icons_array     = $this->some_fontawesome_classes;\n\t\t$linkmod_classes = array();\n\t\t$icon_classes    = array();\n\t\t$chars           = range( 'a', 'z' );\n\t\t$extra_classes   = array();\n\t\t// make 10 random valid classnames with legth of 8 chars (there should\n\t\t// be no naming collisions here with this random string gen method).\n\t\tfor ( $i = 0; $i < 20; $i++ ) {\n\t\t\t$string = '';\n\t\t\t$length = mt_rand( 4, 10 );\n\t\t\tfor ( $j = 0; $j < $length; $j++ ) {\n\t\t\t\t$string .= $chars[ mt_rand( 0, count( $chars ) - 1 ) ];\n\t\t\t}\n\t\t\t$extra_classes[] = $string;\n\t\t}\n\t\t// merge the valid icon classes with the extra classes and shuffle order.\n\t\t$icons_array = array_merge( $icons_array, $extra_classes );\n\t\tshuffle( $icons_array );\n\n\t\t$returned_array = $method_open->invokeArgs( $wp_bootstrap_navwalker, array( $icons_array, &$linkmod_classes, &$icon_classes, 0 ) );\n\n\t\t// linkmod_classes should be empty and returned_array should not.\n\t\t$this->assertTrue( ( empty( $linkmod_classes ) && ! empty( $returned_array ) ) );\n\t\t// icon_classes should no longer be empty.\n\t\t$this->assertNotTrue( empty( $icon_classes ) );\n\t\t// the number of items inside updated $icon_classes should match number of valids we started with.\n\t\t$this->assertTrue( count( $this->some_fontawesome_classes ) === count( $icon_classes ), \"Seems that glyphicons classes are not catptured properly... \\nvalid: \\n\" . print_r( $this->some_fontawesome_classes, true ) . \"\\nreturned: \\n\" . print_r( $icon_classes, true ) );\n\t\t// get the differences between the original classes and updated classes.\n\t\t$icon_differences = array_diff( $this->some_fontawesome_classes, $icon_classes );\n\t\t// should be no differences thus empty array, this being TRUE also means\n\t\t// that text was exact match in the updated array vs the original.\n\t\t$this->assertTrue( empty( $icon_differences ) );\n\n\t}\n\n\t/**\n\t * Test that the function catches a random assortment of font awesome icon\n\t * classes mixed with with regular classnames.\n\t *\n\t * @depends test_separate_linkmods_and_icons_from_classes_function_exists\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_separate_linkmods_and_icons_from_classes_glyphicons() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\t\t// since we're working with private methods we need to use a reflector.\n\t\t$reflector = new ReflectionClass( 'WP_Bootstrap_Navwalker' );\n\n\t\t// get a reflected method for the opener function and set to public.\n\t\t$method_open = $reflector->getMethod( 'separate_linkmods_and_icons_from_classes' );\n\t\t$method_open->setAccessible( true );\n\n\t\t$icons_array     = $this->some_glyphicons_classes;\n\t\t$linkmod_classes = array();\n\t\t$icon_classes    = array();\n\t\t$chars           = range( 'a', 'z' );\n\t\t$extra_classes   = array();\n\t\t// make 10 random valid classnames with legth of 8 chars (there should\n\t\t// be no naming collisions here with this random string gen method).\n\t\tfor ( $i = 0; $i < 10; $i++ ) {\n\t\t\t$string = '';\n\t\t\t$length = mt_rand( 4, 10 );\n\t\t\tfor ( $j = 0; $j < $length; $j++ ) {\n\t\t\t\t$string .= $chars[ mt_rand( 0, count( $chars ) - 1 ) ];\n\t\t\t}\n\t\t\t$extra_classes[] = $string;\n\t\t}\n\t\t// merge the valid icon classes with the extra classes and shuffle order.\n\t\t$icons_array = array_merge( $icons_array, $extra_classes );\n\t\tshuffle( $icons_array );\n\n\t\t$returned_array = $method_open->invokeArgs( $wp_bootstrap_navwalker, array( $icons_array, &$linkmod_classes, &$icon_classes, 0 ) );\n\n\t\t// linkmod_classes should be empty and returned_array should not.\n\t\t$this->assertTrue( ( empty( $linkmod_classes ) && ! empty( $returned_array ) ) );\n\t\t// icon_classes should no longer be empty.\n\t\t$this->assertNotTrue( empty( $icon_classes ) );\n\t\t// the number of items inside updated $icon_classes should match number of valids we started with.\n\t\t$this->assertTrue( count( $this->some_glyphicons_classes ) === count( $icon_classes ), \"Seems that glyphicons classes are not catptured properly... \\nvalid: \\n\" . print_r( $this->some_glyphicons_classes, true ) . \"\\nreturned: \\n\" . print_r( $icon_classes, true ) );\n\t\t// get the differences between the original classes and updated classes.\n\t\t$icon_differences = array_diff( $this->some_glyphicons_classes, $icon_classes );\n\t\t// should be no differences thus empty array, this being TRUE also means\n\t\t// that text was exact match in the updated array vs the original.\n\t\t$this->assertTrue( empty( $icon_differences ) );\n\n\t}\n\n\t/**\n\t * Test that the function catches a random assortment of font awesome icon\n\t * classes mixed with with regular classnames.\n\t *\n\t * @depends test_separate_linkmods_and_icons_from_classes_function_exists\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_separate_linkmods_and_icons_from_classes_linkmods() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\t\t// since we're working with private methods we need to use a reflector.\n\t\t$reflector = new ReflectionClass( 'WP_Bootstrap_Navwalker' );\n\n\t\t// get a reflected method for the opener function and set to public.\n\t\t$method_open = $reflector->getMethod( 'separate_linkmods_and_icons_from_classes' );\n\t\t$method_open->setAccessible( true );\n\n\t\t$valid_linkmods  = $this->valid_linkmod_classes;\n\t\t$linkmod_classes = array();\n\t\t$icon_classes    = array();\n\t\t$chars           = range( 'a', 'z' );\n\t\t$extra_classes   = array();\n\t\t// make 20 random valid classnames with legth of 4 to 10 chars. There\n\t\t// should be no naming collisions here with this random string gen.\n\t\tfor ( $i = 0; $i < 10; $i++ ) {\n\t\t\t$string = '';\n\t\t\t$length = mt_rand( 4, 10 );\n\t\t\tfor ( $j = 0; $j < $length; $j++ ) {\n\t\t\t\t$string .= $chars[ mt_rand( 0, count( $chars ) - 1 ) ];\n\t\t\t}\n\t\t\t$extra_classes[] = $string;\n\t\t}\n\t\t// merge the valid icon classes with the extra classes and shuffle order.\n\t\t$linkmod_array = array_merge( $valid_linkmods, $extra_classes );\n\t\tshuffle( $linkmod_array );\n\n\t\t// NOTE: this is depth of 0 and meaning valid_linkmod_typeflags won't be captured.\n\t\t$returned_array = $method_open->invokeArgs( $wp_bootstrap_navwalker, array( $linkmod_array, &$linkmod_classes, &$icon_classes, 0 ) );\n\n\t\t// linkmod_classes should NOT be empty and returned_array should not.\n\t\t$this->assertTrue( ( ! empty( $linkmod_classes ) && ! empty( $returned_array ) ) );\n\t\t// icon_classes should be empty.\n\t\t$this->assertTrue( empty( $icon_classes ) );\n\n\t\t$num_of_items_left = count( $this->valid_linkmod_classes ) - count( $linkmod_classes ) - count( $this->valid_linkmod_typeflags );\n\t\t// the number of items inside updated array should match [what we started with - minus the linkmods for inside dropdowns].\n\t\t$this->assertNotTrue(\n\t\t\t(bool) $num_of_items_left,\n\t\t\t\"Seems that the linkmod classes are not catptured properly when outside of dropdowns... \\nvalid: \\n\" . print_r( $this->valid_linkmod_classes, true ) . \"\\nreturned: \\n\" . print_r( $linkmod_classes, true )\n\t\t);\n\t\t// get the differences between the original classes and updated classes.\n\t\t$linkmod_differences = array_diff( $this->valid_linkmod_classes, $linkmod_classes, $this->valid_linkmod_typeflags );\n\n\t\t// should be no differences thus empty array, this being TRUE also means\n\t\t// that text was exact match in the updated array vs the original.\n\t\t$this->assertTrue( empty( $linkmod_differences ) );\n\n\t\t// repeat some of the above tests but this time with depth = 1 so that we catch classes intended for inside dropdowns.\n\t\t$depth             = 1;\n\t\t$linkmod_classes_d = array();\n\t\t$icon_classes_d    = array();\n\t\t$returned_array_d  = $method_open->invokeArgs( $wp_bootstrap_navwalker, array( $linkmod_array, &$linkmod_classes_d, &$icon_classes_d, $depth ) );\n\n\t\t$this->assertTrue( count( $this->valid_linkmod_classes ) === count( $linkmod_classes_d ), \"Seems that the linkmod classes are not catptured properly when inside dropdowns... \\nvalid: \\n\" . print_r( $this->valid_linkmod_classes, true ) . \"\\nreturned: \\n\" . print_r( $linkmod_classes, true ) );\n\t\t$linkmod_differences_d = array_diff( $this->valid_linkmod_classes, $linkmod_classes_d );\n\t\t$this->assertTrue( empty( $linkmod_differences_d ), 'There are differences between the matched classnames and the valid classnames.' );\n\n\t}\n\n\t/**\n\t * Test that the function catches all possible linkmod classes, any icon\n\t * classes and leaves the other classes as-is on the array.\n\t *\n\t * @depends test_separate_linkmods_and_icons_from_classes_function_exists\n\t *\n\t * @depends test_separate_linkmods_and_icons_from_classes_fontawesome\n\t * @depends test_separate_linkmods_and_icons_from_classes_glyphicons\n\t * @depends test_separate_linkmods_and_icons_from_classes_linkmods\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_separate_linkmods_and_icons_from_classes_fulltest() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\t\t// since we're working with private methods we need to use a reflector.\n\t\t$reflector = new ReflectionClass( 'WP_Bootstrap_Navwalker' );\n\n\t\t// get a reflected method for the opener function and set to public.\n\t\t$method_open = $reflector->getMethod( 'separate_linkmods_and_icons_from_classes' );\n\t\t$method_open->setAccessible( true );\n\n\t\t$icons_array     = array_merge( $this->some_fontawesome_classes, $this->some_glyphicons_classes );\n\t\t$linkmod_array   = $this->valid_linkmod_classes;\n\t\t$linkmod_classes = array();\n\t\t$icon_classes    = array();\n\t\t$chars           = range( 'a', 'z' );\n\t\t$extra_classes   = array();\n\t\t// make 1000 random valid classnames with legth of 8 chars (there should\n\t\t// be no naming collisions here with this random string gen method).\n\t\tfor ( $i = 0; $i < 1000; $i++ ) {\n\t\t\t$string = '';\n\t\t\t$length = mt_rand( 4, 10 );\n\t\t\tfor ( $j = 0; $j < $length; $j++ ) {\n\t\t\t\t$string .= $chars[ mt_rand( 0, count( $chars ) - 1 ) ];\n\t\t\t}\n\t\t\t$extra_classes[] = $string;\n\t\t}\n\t\t// merge the valid icon classes with valid linkmod classes and the extra classes then shuffle order.\n\t\t$classname_array = array_merge( $icons_array, $linkmod_array, $extra_classes );\n\t\tshuffle( $classname_array );\n\n\t\t// need a depth of 1 to ensure that our linkmods classes for inside dropdowns are also captured.\n\t\t$depth          = 1;\n\t\t$returned_array = $method_open->invokeArgs( $wp_bootstrap_navwalker, array( $classname_array, &$linkmod_classes, &$icon_classes, $depth ) );\n\n\t\t// linkmod_classes NOT should be empty and returned_array should not.\n\t\t$this->assertTrue( ( ! empty( $linkmod_classes ) && ! empty( $returned_array ) ), 'Either the linkmod array or the returned non matching classes array is empty when they shoud not be.' );\n\t\t// starting arrays should no longer be empty.\n\t\t$this->assertNotTrue( empty( $icon_classes ), 'Did not catch any icons.' );\n\t\t$this->assertNotTrue( empty( $linkmod_classes ), 'Did not catch any linkmods.' );\n\n\t\t// icons compair.\n\t\t$this->assertTrue( count( $icons_array ) === count( $icon_classes ), \"Seems that icon classes are not catptured properly... valid: \\n\" . print_r( $icons_array, true ) . \"returned: \\n\" . print_r( $icon_classes, true ) );\n\t\t$icon_differences = array_diff( $icons_array, $icon_classes );\n\t\t$this->assertTrue( empty( $icon_differences ), 'Seems that we did not catch all of the icon classes.' );\n\t\t// linkmod compair.\n\t\t$this->assertTrue( count( $linkmod_array ) === count( $linkmod_classes ), \"Seems that linkmod classes are not catptured properly... valid: \\n\" . print_r( $linkmod_array, true ) . \"returned: \\n\" . print_r( $linkmod_classes, true ) );\n\t\t$linkmod_differences = array_diff( $icons_array, $icon_classes );\n\t\t$this->assertTrue( empty( $linkmod_differences ), 'Seems that we did not catch all of the linkmod classes.' );\n\t\t// extra classes string matches checks.\n\t\t$returned_differences = array_diff( $returned_array, $extra_classes );\n\t\t$this->assertTrue( empty( $returned_differences ), 'The returned array minus the extra classes should be empty, likely some classes were missed or string malformation occured.' );\n\n\t}\n\n\t/**\n\t * Test get_linkmod_type Function exists.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_get_linkmod_type_function_exists() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\n\t\t$this->assertTrue(\n\t\t\tmethod_exists( $wp_bootstrap_navwalker, 'get_linkmod_type' ),\n\t\t\t'Class does not have method get_linkmod_type.'\n\t\t);\n\n\t}\n\n\t/**\n\t * Test update_atts_for_linkmod_type Function exists.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_update_atts_for_linkmod_type_function_exists() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\n\t\t$this->assertTrue(\n\t\t\tmethod_exists( $wp_bootstrap_navwalker, 'update_atts_for_linkmod_type' ),\n\t\t\t'Class does not have method update_atts_for_linkmod_type.'\n\t\t);\n\n\t}\n\n\t/**\n\t * Test linkmod_element_open Function exists.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_linkmod_element_open_function_exists() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\n\t\t$this->assertTrue(\n\t\t\tmethod_exists( $wp_bootstrap_navwalker, 'linkmod_element_open' ),\n\t\t\t'Class does not have method linkmod_element_open.'\n\t\t);\n\n\t}\n\n\t/**\n\t * Test linkmod_element_close Function exists.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_linkmod_element_close_function_exists() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\n\t\t$this->assertTrue(\n\t\t\tmethod_exists( $wp_bootstrap_navwalker, 'linkmod_element_close' ),\n\t\t\t'Class does not have method linkmod_element_close.'\n\t\t);\n\n\t}\n\n\t/**\n\t * Tests for valid markup being used as the opener and closer sections for\n\t * some different linkmod types.\n\t *\n\t * @access public\n\t * @return void\n\t */\n\tpublic function test_linkmod_elements_open_and_close_successfully() {\n\n\t\t$wp_bootstrap_navwalker = $this->walker;\n\n\t\t// since we're working with private methods we need to use a reflector.\n\t\t$reflector = new ReflectionClass( 'WP_Bootstrap_Navwalker' );\n\n\t\t// get a reflected method for the opener function and set to public.\n\t\t$method_open = $reflector->getMethod( 'linkmod_element_open' );\n\t\t$method_open->setAccessible( true );\n\n\t\t// test openers for headers and dividers.\n\t\t$header_open = $method_open->invokeArgs( $wp_bootstrap_navwalker, array( $this->valid_linkmod_typeflags[0], 'stringOfAttributes' ) );\n\t\t$this->assertNotEmpty( $header_open, 'Got empty string for opener of ' . $this->valid_linkmod_typeflags[0] );\n\t\t$divider_open = $method_open->invokeArgs( $wp_bootstrap_navwalker, array( $this->valid_linkmod_typeflags[1], 'stringOfAttributes' ) );\n\t\t$this->assertNotEmpty( $divider_open, 'Got empty string for opener of ' . $this->valid_linkmod_typeflags[1] );\n\t\t$text_open = $method_open->invokeArgs( $wp_bootstrap_navwalker, array( $this->valid_linkmod_typeflags[2], 'stringOfAttributes' ) );\n\t\t$this->assertNotEmpty( $divider_open, 'Got empty string for opener of ' . $this->valid_linkmod_typeflags[2] );\n\n\t\t// test that that an unknown linkmod type being passed results in no output.\n\t\t$nonexistent_linkmod_type_open = $method_open->invokeArgs( $wp_bootstrap_navwalker, array( 'nonexistentlinkmodtype', 'stringOfAttributes' ) );\n\t\t$this->assertEmpty( $nonexistent_linkmod_type_open, 'Expected empty string when using non-existent linkmod type.' );\n\n\t\t// get a reflected method for the closer function and set to public.\n\t\t$method_close = $reflector->getMethod( 'linkmod_element_close' );\n\t\t$method_close->setAccessible( true );\n\n\t\t$header_close = $method_close->invokeArgs( $wp_bootstrap_navwalker, array( $this->valid_linkmod_typeflags[0] ) );\n\t\t$this->assertNotEmpty( $header_close, 'Got empty string for closer of ' . $this->valid_linkmod_typeflags[0] );\n\t\t$divider_close = $method_close->invokeArgs( $wp_bootstrap_navwalker, array( $this->valid_linkmod_typeflags[1] ) );\n\t\t$this->assertNotEmpty( $divider_close, 'Got empty string for closer of ' . $this->valid_linkmod_typeflags[1] );\n\t\t$text_close = $method_close->invokeArgs( $wp_bootstrap_navwalker, array( $this->valid_linkmod_typeflags[2] ) );\n\t\t$this->assertNotEmpty( $divider_close, 'Got empty string for closer of ' . $this->valid_linkmod_typeflags[2] );\n\n\t\t// test that that an unknown linkmod type being passed results in no output.\n\t\t$nonexistent_linkmod_type_close = $method_open->invokeArgs( $wp_bootstrap_navwalker, array( 'nonexistentlinkmodtype' ) );\n\t\t$this->assertEmpty( $nonexistent_linkmod_type_close, 'Expected empty string when using non-existent linkmod type.' );\n\n\t\t// dropdown-header should be a span.\n\t\t$this->assertRegExp(\n\t\t\t'/^(<span(.*?)>)(.*?)(<\\/span>)$/',\n\t\t\t$header_open . $header_close,\n\t\t\t'The opener and closer for ' . $this->valid_linkmod_typeflags[0] . ' does not seem to match expected elements.'\n\t\t);\n\t\t// dropdown-divider should be a div.\n\t\t$this->assertRegExp(\n\t\t\t'/^(<div(.*?)>)(.*?)(<\\/div>)$/',\n\t\t\t$divider_open . $divider_close,\n\t\t\t'The opener and closer for ' . $this->valid_linkmod_typeflags[1] . ' does not seem to match expected elements.'\n\t\t);\n\t\t// dropdown-item-text should be a span.\n\t\t$this->assertRegExp(\n\t\t\t'/^(<span(.*?)>)(.*?)(<\\/span>)$/',\n\t\t\t$text_open . $text_close,\n\t\t\t'The opener and closer for ' . $this->valid_linkmod_typeflags[2] . ' does not seem to match expected elements.'\n\t\t);\n\t}\n}\n"
  }
]