/** * hooked into plugins_loaded action : creates the plugin instance */ public static function init() { is_null(self::$instance) && (self::$instance = new self()); return self::$instance; }
/** * switch the current settings for those indicated by a cmwizard shortcode * * @param object $args The args passed into walk() * @param string $at The current processing stage * @param boolean $hasCurrent Whether or not current item is in this stage * @param boolean $hasOutput Whether or not there will be any output (as best we know so far) * @return boolean True if we can use alternative settings */ private function _cmw_switch_settings(&$args, $at = '', $hasCurrent = false, $hasOutput = false) { if ($args->_custom_menu_wizard['switch_at'] == $at && ($args->_custom_menu_wizard['switch_if'] == 'current' && $hasCurrent || $args->_custom_menu_wizard['switch_if'] == 'no-current' && !$hasCurrent || $args->_custom_menu_wizard['switch_if'] == 'no-output' && !$hasOutput)) { $plugin = Custom_Menu_Wizard_Plugin::init(); //if switch_to is empty, it gets defaulted to a minimum //trim off square brackets, self-terminators, and spaces... $switchTo = trim($args->_custom_menu_wizard['switch_to'], ' ][/'); //if it doesn't start with our shortcode, prepend it... if (substr($switchTo . ' ', 0, 9) != 'cmwizard ') { $switchTo = 'cmwizard ' . $switchTo; } //append our current menu so that it will be used when the shortcode atts are parsed... $switchTo = trim($switchTo) . ' menu=' . $args->_custom_menu_wizard['menu']; if (($new_cmw = $plugin->encode_shortcode($switchTo)) !== false) { //store old... $old_cmw = array_merge(array(), $args->_custom_menu_wizard); //merge new into old, overriding _walker... $new_cmw = array_merge($old_cmw, (array) $new_cmw, array('_walker' => array('alternative' => true))); //overwrite current with new... $args->_custom_menu_wizard = $new_cmw; //put new and old into the current _walker, so that they become available to the widget //instance (as long as there's some output!)... $args->_custom_menu_wizard['_walker']['instances'] = array('old' => $old_cmw, 'new' => $new_cmw); unset($old_cmw); return true; } } return false; }