API

Knowledgebase Docs » ShiftNav » API

Toggles: PHP 5

PHP toggle tags are perfect for adding toggles in your theme templates. To insert a toggle for the main ShiftNav panel, you would use this You can set the content of the toggle with the second parameter. The third parameter takes an array of arguments which can be used to define an ID, element/tag, and additional classes to add to the toggle. For example, the following: would produce this markup: Hint: Mobile visibility By default this toggle will appear at all viewport widths. Want it to appear only below the same breakpoint as the main toggle bar? Add the shiftnav-toggle-mobile class to the toggle bar element Note that this visibility can be easily overridden by other CSS on your site, so if it is not working, check that you don’t have other CSS setting this to display:none;

View

PHP API 7

ShiftNav provides two functions that developers can use to generate ShiftNav components. shiftnav() The shiftnav() function generates a ShiftNav menu panel (the part that slides out from the side of the viewport). Basic usage Pass the function the ID of an instance in order to generate the panel based on those instance styles. The default instance is shiftnav-main. So to generate the main ShiftNav instance panel, you would use The ShiftNav panels should be added in the footer. So this function will almost always be called within a wp_footer callback Use case: precision menu integration Out of the box, all ShiftNav instances will automatically be generated and added to the footer of the site on every page. If you would like more precise control over which pages the menus are generated on, you can unhook the automatic menu generation and manually integrate each instance. For example, the code below will remove all of the automatically generated instances beside the main instance. Then it will add the custom ‘shop’ instance only on page 52. This could be expanded to generate any number of custom instances only under specific conditions – e.g. logged in users, specific pages, specific sections of a site, etc. If you would like to disable ShiftNav entirely on a page, see Disable ShiftNav on a specific page (or any custom condition) Custom Settings The shiftnav() function also takes an optional second argument which is an array of settings. These settings can override options set in the instance Control Panel settings, specifically theme_location, menu, container, edge, and skin. This way if you want to change one of these particular settings without creating an entire new instance, you can do so. shiftnav_toggle() The shiftnav_toggle() function will generate a ShiftNav toggle for a specific ShiftNav instance – an element that, when […]

View