From 75299f85faa3fbd49e82f3f10dc6f1ecf70667cc Mon Sep 17 00:00:00 2001 From: andrewmbacon Date: Wed, 24 Jun 2015 10:19:49 -0400 Subject: [PATCH] adding logic to Nav Style Options only display max mega menu if plugin is active. --- inc/customizer-nav.php | 54 ++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/inc/customizer-nav.php b/inc/customizer-nav.php index 78346e8..39b4e28 100644 --- a/inc/customizer-nav.php +++ b/inc/customizer-nav.php @@ -1,23 +1,37 @@ add_setting( 'navoption1', //Give it a SERIALIZED name (so all theme settings can live under one db record) - array( - 'default' => 'drop', //Default setting/value to save - 'type' => 'option', //Is this an 'option' or a 'theme_mod'? - 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. - 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? - ) - ); - $wp_customize->add_control('navoption1', array( - 'type' => 'select', - 'label' => 'Navigation Option 1', - 'section' => 'nav', - 'choices' => array( - 'drop'=>'Dropdowns', - 'drop-multi' => 'Multi-level Dropdowns', - 'tabs'=>'Tabs', - 'maxmegamenu'=>'Maxmegamenu Dropdown', - 'left'=>'Left Only' - ) - ) - ); + array( + 'default' => 'drop', //Default setting/value to save + 'type' => 'option', //Is this an 'option' or a 'theme_mod'? + 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. + 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? + ) +); + + +// Setup Navigation options as an array +$navStyleOptions = array( + 'drop'=>'Dropdowns', + 'drop-multi' => 'Multi-level Dropdowns', + 'tabs'=>'Tabs' +); + +// Check to see if max mega menu is active +include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); +$maxMegaMenuActive = is_plugin_active('megamenu/megamenu.php'); + +// If it's active, add that option to the array. +if ($maxMegaMenuActive){ + $navStyleOptions['maxmegamenu'] = 'Maxmegamenu Dropdown'; +}; + +// create the nav style options using the array. +$wp_customize->add_control('navoption1', array( + 'type' => 'select', + 'label' => 'Navigation Style', + 'section' => 'nav', + 'choices' => $navStyleOptions + ) +); + ?> \ No newline at end of file