コード例 #1
0
function shiftnav_get_settings_fields()
{
    $prefix = SHIFTNAV_PREFIX;
    $main_assigned = '';
    if (!has_nav_menu('shiftnav')) {
        $main_assigned = 'No Menu Assigned';
    } else {
        $menus = get_nav_menu_locations();
        $menu_title = wp_get_nav_menu_object($menus['shiftnav'])->name;
        $main_assigned = $menu_title;
    }
    $main_assigned = '<span class="shiftnav-main-assigned">' . $main_assigned . '</span>  <p class="shiftnav-desc-understated">The menu assigned to the <strong>ShiftNav [Main]</strong> theme location will be displayed.  <a href="' . admin_url('nav-menus.php?action=locations') . '">Assign a menu</a></p>';
    $fields = array($prefix . 'shiftnav-main' => array(array('name' => 'menu_assignment', 'label' => __('Assigned Menu', 'shiftnav'), 'desc' => $main_assigned, 'type' => 'html'), array('name' => 'display_main', 'label' => __('Display Main ShiftNav', 'shiftnav'), 'desc' => __('Do not uncheck this unless you want to disable the main ShiftNav panel entirely.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on'), array('name' => 'edge', 'label' => __('Edge', 'shiftnav'), 'type' => 'radio', 'options' => array('left' => 'Left', 'right' => 'Right'), 'default' => 'left'), array('name' => 'swipe_open', 'label' => __('Swipe Open', 'shiftnav'), 'desc' => __('Swipe to open the main ShiftNav Panel in iOS and Android.  Not all themes will be compatible, as touch swipes can conflict with theme scripts.  Make sure enabling this doesn\'t prevent other touch functionality on your site from working', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'skin', 'label' => __('Skin', 'shiftnav'), 'type' => 'select', 'options' => shiftnav_get_skin_ops(), 'default' => 'standard-dark'), array('name' => 'indent_submenus', 'label' => __('Indent Always Visible Submenus', 'shiftnav'), 'desc' => __('Check this to indent submenu items of always-visible submenus', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'display_site_title', 'label' => __('Display Site Title', 'shiftnav'), 'desc' => __('Display the site title in the menu', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on')), $prefix . 'togglebar' => array(array('name' => 'display_toggle', 'label' => __('Display Toggle Bar', 'shiftnav'), 'desc' => __('', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on'), array('name' => 'breakpoint', 'label' => __('Toggle Breakpoint', 'shiftnav'), 'desc' => __('Show the toggle bar only below this pixel width.  Leave blank to show at all times.  Do not include "px"', 'shiftnav'), 'type' => 'text', 'default' => ''), array('name' => 'hide_theme_menu', 'label' => __('Hide Theme Menu', 'shiftnav'), 'desc' => __('Enter the selector of the theme\'s menu if you wish to hide it below the breakpoint above.  For example, <code>#primary-nav</code> or <code>.topnav</code>.  ', 'shiftnav'), 'type' => 'text', 'default' => ''), array('name' => 'hide_ubermenu', 'label' => __('Hide UberMenu', 'shiftnav'), 'desc' => __('Hide all UberMenus when ShiftNav is displayed.  If you would like to only hide a specific UberMenu, use the setting above with a specific UberMenu ID.', 'shiftnav') . ' ( <a href="http://wpmegamenu.com">What is UberMenu?</a> )', 'type' => 'checkbox', 'default' => 'off'), array('name' => 'toggle_content', 'label' => __('Toggle Content', 'shiftnav'), 'desc' => __('[shift_toggle_title]', 'shiftnav'), 'type' => 'textarea', 'default' => '[shift_toggle_title]', 'sanitize_callback' => 'shiftnav_allow_html'), array('name' => 'toggle_close_icon', 'label' => __('Close Icon', 'shiftnav'), 'desc' => __('When the toggle is open, choose which icon to display.', 'shiftnav'), 'type' => 'radio', 'options' => array('bars' => '<i class="fa fa-bars"></i> Hamburger Bars', 'x' => '<i class="fa fa-times"></i> Close button'), 'default' => 'x'), array('name' => 'toggle_position', 'label' => __('Toggle Bar Position', 'shiftnav'), 'desc' => __('Choose Fixed if you\'d like the toggle bar to always be visible, or Absolute if you\'d like it only to be visible when scrolled to the very top of the page', 'shiftnav'), 'type' => 'radio', 'options' => array('fixed' => __('Fixed', 'shiftnav'), 'absolute' => __('Absolute', 'shiftnav')), 'default' => 'fixed'), array('name' => 'align', 'label' => __('Align Text', 'shiftnav'), 'desc' => __('Align text left, right, or center.  Applies to inline elements only.', 'shiftnav'), 'type' => 'radio', 'options' => array('center' => 'Center', 'left' => 'Left', 'right' => 'Right'), 'default' => 'center'), array('name' => 'background_color', 'label' => __('Background Color', 'shiftnav'), 'desc' => __('', 'shiftnav'), 'type' => 'color'), array('name' => 'text_color', 'label' => __('Text Color', 'shiftnav'), 'desc' => __('', 'shiftnav'), 'type' => 'color'), array('name' => 'font_size', 'label' => __('Font Size', 'shiftnav'), 'desc' => __('Override the default font size of the toggle bar by setting a value here.', 'shiftnav'), 'type' => 'text', 'default' => '')));
    $fields = apply_filters('shiftnav_settings_panel_fields', $fields);
    $fields[$prefix . 'general'] = array(array('name' => 'css_tweaks', 'label' => __('CSS Tweaks', 'shiftnav'), 'desc' => __('Add custom CSS here, which will be printed in the site head.', 'shiftnav'), 'type' => 'textarea', 'sanitize_callback' => 'shiftnav_allow_html'), array('name' => 'target_size', 'label' => __('Button Size', 'shiftnav'), 'desc' => __('The size of the padding on the links in the menu.  The larger the setting, the easier to click; but fewer menu items will appear on the screen at a time.', 'shiftnav'), 'type' => 'radio', 'options' => array('default' => 'Default', 'medium' => 'Medium', 'large' => 'Large', 'enormous' => 'Enormous'), 'default' => 'default'), array('name' => 'text_size', 'label' => __('Text Size', 'shiftnav'), 'desc' => __('The size of the font on the links in the menu (will override all levels).', 'shiftnav'), 'type' => 'radio', 'options' => array('default' => 'Default', 'small' => 'Small', 'medium' => 'Medium', 'large' => 'Large', 'enormous' => 'Enormous'), 'default' => 'default'), array('name' => 'icon_size', 'label' => __('Icon Size', 'shiftnav'), 'desc' => __('The size of the icons in the menu.', 'shiftnav'), 'type' => 'radio', 'options' => array('default' => 'Default', 'small' => 'Small', 'medium' => 'Medium', 'large' => 'Large', 'enormous' => 'Enormous'), 'default' => 'default'), array('name' => 'shift_body', 'label' => __('Shift Body', 'shiftnav'), 'desc' => __('Shift the body of the site when the menu is revealed.  For some themes, this may negatively affect the site content, so this can be disabled.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on'), array('name' => 'swipe_close', 'label' => __('Swipe Close', 'shiftnav'), 'desc' => __('Enable swiping to close the ShiftNav panel on Android and iOS.  Touch events may not interact well with all themes.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on'), array('name' => 'swipe_tolerance_x', 'label' => __('Swipe Tolerance: Horizontal', 'shiftnav'), 'desc' => __('The minimum horizontal pixel distance before the swipe is triggered.  Do not include <code>px</code>', 'shiftnav'), 'type' => 'text', 'default' => 150), array('name' => 'swipe_tolerance_y', 'label' => __('Swipe Tolerance: Vertical', 'shiftnav'), 'desc' => __('The maximum horizontal pixel distance allowed for the swipe to be triggered.  Do not include <code>px</code>', 'shiftnav'), 'type' => 'text', 'default' => 60), array('name' => 'swipe_edge_proximity', 'label' => __('Swipe Edge Proximity', 'shiftnav'), 'desc' => __('The distance from the edge, within which the first touch event must occur for the swipe to be triggered.  Do not include <code>px</code>', 'shiftnav'), 'type' => 'text', 'default' => 80), array('name' => 'open_current', 'label' => __('Open Current Accordion Submenu', 'shiftnav'), 'desc' => __('Open the submenu of the current menu item on page load (accordion submenus only).', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'collapse_accordions', 'label' => __('Collapse Accordions', 'shiftnav'), 'desc' => __('When an accordion menu is opened, collapse any other accordions on that level.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'scroll_panel', 'label' => __('Scroll Shift Submenus to Top', 'shiftnav'), 'desc' => __('When a Shift submenu is activated, scroll that item to the top to maximize submenu visibility.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on'), array('name' => 'active_on_hover', 'label' => __('Highlight Targets on Hover', 'shiftnav'), 'desc' => __('With this setting enabled, the links will be highlighted when hovered or touched.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'active_highlight', 'label' => __('Highlight Targets on :active', 'shiftnav'), 'desc' => __('With this setting enabled, the links will be highlighted while in the :active state.  May not be desirable for touch scrolling.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'admin_tips', 'label' => __('Show Tips to Admins', 'shiftnav'), 'desc' => __('Display tips to admin users', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on'), array('name' => 'lock_body_x', 'label' => __('Lock Horizontal Scroll', 'shiftnav'), 'desc' => __('Attempt to prevent the content from scrolling horizontally when the menu is active.  On some themes, may also prevent vertical scrolling.  May not prevent touch scrolling in Chrome.  No effect if <strong>Shift Body</strong> is disabled.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'lock_body', 'label' => __('Lock Scroll', 'shiftnav'), 'desc' => __('Lock both vertical and horizontal scrolling on site content when menu is active.  No effect if <strong>Shift Body</strong> is disabled.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on'), array('name' => 'load_fontawesome', 'label' => __('Load Font Awesome', 'shiftnav'), 'desc' => __('If you are already loading Font Awesome 4 elsewhere in your setup, you can disable this.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on'), array('name' => 'inherit_ubermenu_conditionals', 'label' => __('Inherit UberMenu Conditionals', 'shiftnav'), 'desc' => __('Display menu items based on UberMenu Conditionals settings', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'force_filter', 'label' => __('Force Filter Menu Args', 'shiftnav'), 'desc' => __('Some themes will filter the menu arguments on all menus on the site, which can break things.  This will re-filter those arguments for ShiftNav menus only.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'kill_class_filter', 'label' => __('Kill Menu Class Filter', 'shiftnav'), 'desc' => __('Some themes filter the menu item classes and strip out core WordPress functionality.  This will change the structure of ShiftNav and prevent styles from being applies.  This will prevent any actions on the <code>nav_menu_css_class</code> filter.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'));
    return $fields;
}
コード例 #2
0
ファイル: settings.pro.php プロジェクト: swc-dng/swcsandbox
function shiftnav_settings_panel_fields_pro($fields = array())
{
    /** ADD MAIN NAV PRO OPTIONS **/
    $main = SHIFTNAV_PREFIX . 'shiftnav-main';
    $fields[$main][] = array('name' => 'disable_menu', 'label' => __('Disable Menu', 'shiftnav'), 'desc' => __('Check this to disable the menu entirely; the panel can be used for custom content', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off');
    $fields[$main][] = array('name' => 'image', 'label' => __('Top Image', 'shiftnav'), 'desc' => __('', 'shiftnav'), 'type' => 'image', 'default' => '');
    $fields[$main][] = array('name' => 'image_padded', 'label' => __('Pad Image', 'shiftnav'), 'desc' => __('Add padding to align image with menu item text.  Uncheck to expand to the edges of the panel.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on');
    $fields[$main][] = array('name' => 'image_link', 'label' => __('Image Link (URL)', 'shiftnav'), 'desc' => __('Make the image a link to this URL.', 'shiftnav'), 'type' => 'text', 'default' => '');
    $fields[$main][] = array('name' => 'content_before', 'label' => __('Custom Content Before Menu', 'shiftnav'), 'desc' => __('', 'shiftnav'), 'type' => 'textarea', 'default' => '', 'sanitize_callback' => 'shiftnav_allow_html');
    $fields[$main][] = array('name' => 'content_after', 'label' => __('Custom Content After Menu', 'shiftnav'), 'desc' => __('', 'shiftnav'), 'type' => 'textarea', 'default' => '', 'sanitize_callback' => 'shiftnav_allow_html');
    /** ADD MAIN TOGGLE OPTIONS **/
    $toggle = SHIFTNAV_PREFIX . 'togglebar';
    $fields[$toggle][] = array('name' => 'toggle_content_left', 'label' => __('Toggle Content Left Edge', 'shiftnav'), 'desc' => '', 'type' => 'textarea', 'default' => '', 'sanitize_callback' => 'shiftnav_allow_html');
    $fields[$toggle][] = array('name' => 'toggle_content_right', 'label' => __('Toggle Content Right Edge', 'shiftnav'), 'desc' => '', 'type' => 'textarea', 'default' => '', 'sanitize_callback' => 'shiftnav_allow_html');
    /** ADD INSTANCES **/
    $menus = get_option('shiftnav_menus', array());
    foreach ($menus as $menu) {
        $integration_code = '
			<div class="shiftnav-desc-row">
				<span class="shiftnav-code-snippet-type">PHP</span> <code class="shiftnav-highlight-code">&lt;?php shiftnav_toggle( \'' . $menu . '\' ); ?&gt;</code>
			</div>
			<div class="shiftnav-desc-row">
				<span class="shiftnav-code-snippet-type">Shortcode</span> <code class="shiftnav-highlight-code">[shiftnav_toggle target="' . $menu . '"]</code>' . '</div>
			<div class="shiftnav-desc-row">
				<span class="shiftnav-code-snippet-type">HTML</span> <code class="shiftnav-highlight-code">&lt;a class="shiftnav-toggle" data-shiftnav-target="' . $menu . '"&gt; Toggle Content &lt;/a&gt;</code>
			</div>
			<p class="shiftnav-sub-desc shiftnav-desc-mini" >Click to select, then <strong><em>&#8984;+c</em></strong> or <strong><em>ctrl+c</em></strong> to copy to clipboard</p>
			<p class="shiftnav-sub-desc shiftnav-desc-understated">Pick the appropriate code and add to your template or content where you want the toggle to appear.  The menu panel itself is loaded automatically.  You can add the toggle code as many times as you like.</p>
		';
        $fields[SHIFTNAV_PREFIX . $menu] = array(array('name' => 'php', 'label' => __('Integration Code', 'shiftnav'), 'desc' => $integration_code, 'type' => 'html'), array('name' => 'instance_name', 'label' => __('Instance Name', 'shiftnav'), 'desc' => __('', 'shiftnav'), 'type' => 'text', 'default' => $menu), array('name' => 'menu', 'label' => __('Display Menu', 'shiftnav'), 'desc' => 'Select the menu to display or <a href="' . admin_url('nav-menus.php') . '">create a new menu</a>.  This setting will override the Theme Location setting.', 'type' => 'select', 'options' => shiftnav_get_nav_menu_ops()), array('name' => 'theme_location', 'label' => __('Theme Location', 'shiftnav'), 'desc' => __('Select the Theme Location to display.  The Menu setting will override this setting if a menu is selected.', 'shiftnav'), 'type' => 'select', 'options' => shiftnav_get_theme_location_ops()), array('name' => 'edge', 'label' => __('Edge', 'shiftnav'), 'desc' => __('Select which edge of your site to display the menu on', 'shiftnav'), 'type' => 'radio', 'options' => array('left' => 'Left', 'right' => 'Right'), 'default' => 'left'), array('name' => 'disable_menu', 'label' => __('Disable Menu', 'shiftnav'), 'desc' => __('Check this to disable the menu entirely; the panel can be used for custom content', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'skin', 'label' => __('Skin', 'shiftnav'), 'desc' => __('Select which skin to use for this instance', 'shiftnav'), 'type' => 'select', 'options' => shiftnav_get_skin_ops()), array('name' => 'indent_submenus', 'label' => __('Indent Always Visible Submenus', 'shiftnav'), 'desc' => __('Check this to indent submenu items of always-visible submenus', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'toggle_content', 'label' => __('Toggle Content', 'shiftnav'), 'desc' => __('Enter the content to be displayed in the toggle, which you will insert into your template with the integration code at the top of this tab.', 'shiftnav'), 'type' => 'textarea', 'default' => 'Toggle', 'sanitize_callback' => 'shiftnav_allow_html'), array('name' => 'display_site_title', 'label' => __('Display Site Title', 'shiftnav'), 'desc' => __('Display the site title in the menu', 'shiftnav'), 'type' => 'checkbox', 'default' => 'off'), array('name' => 'display_instance_title', 'label' => __('Display Instance Name', 'shiftnav'), 'desc' => __('Display the instance name in the menu', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on'), array('name' => 'image', 'label' => __('Top Image', 'shiftnav'), 'desc' => __('', 'shiftnav'), 'type' => 'image', 'default' => ''), array('name' => 'image_padded', 'label' => __('Pad Image', 'shiftnav'), 'desc' => __('Add padding to align image with menu item text.  Uncheck to expand to the edges of the panel.', 'shiftnav'), 'type' => 'checkbox', 'default' => 'on'), array('name' => 'image_link', 'label' => __('Image Link (URL)', 'shiftnav'), 'desc' => __('Make the image a link to this URL.', 'shiftnav'), 'type' => 'text', 'default' => ''), array('name' => 'content_before', 'label' => __('Custom Content Before Menu', 'shiftnav'), 'desc' => __('', 'shiftnav'), 'type' => 'textarea', 'default' => '', 'sanitize_callback' => 'shiftnav_allow_html'), array('name' => 'content_after', 'label' => __('Custom Content After Menu', 'shiftnav'), 'desc' => __('', 'shiftnav'), 'type' => 'textarea', 'default' => '', 'sanitize_callback' => 'shiftnav_allow_html'), array('name' => 'delete', 'label' => __('Delete Instance', 'shiftnav'), 'desc' => '<a class="shiftnav_instance_button shiftnav_instance_button_delete" href="#" data-shiftnav-instance-id="' . $menu . '" data-shiftnav-nonce="' . wp_create_nonce('shiftnav-delete-instance') . '">' . __('Permanently Delete Instance', 'shiftnav') . '</a>', 'type' => 'html'));
    }
    return $fields;
}