function set_item_style($item_id, $selector, $property_map) { //Get all stored menu item styles $item_styles = _UBERMENU()->get_item_styles($item_id); //Initialize new array if this menu item doesn't have any rules yet if (!isset(self::$item_styles[$item_id])) { self::$item_styles[$item_id] = array(); } if ($selector) { //Initialize new array if this selector doesn't exist yet if (!isset(self::$item_styles[$item_id][$selector])) { self::$item_styles[$item_id][$selector] = array(); } if (is_array($property_map)) { //Add to the $properties array foreach ($property_map as $property => $value) { self::$item_styles[$item_id][$selector][$property] = $value; } } } }
function ubermenu_get_instance_options($instance) { //echo UBERMENU_PREFIX.$instance; $defaults = _UBERMENU()->get_defaults(UBERMENU_PREFIX . $instance); $options = get_option(UBERMENU_PREFIX . $instance, $defaults); if (!is_array($options) || count($options) == 0) { return $defaults; } return $options; }
function ubermenu_register_font($font_id, $font_ops) { _UBERMENU()->register_font($font_id, $font_ops); }
function ubermenu_get_support_url() { return _UBERMENU()->get_support_url(); }
function ubermenu_set_item_style($item_id, $selector, $property_map) { _UBERMENU()->set_item_style($item_id, $selector, $property_map); }
function ubermenu_get_image($img_id = false, $post_id = false, $data = false, $args = array()) { extract(wp_parse_args($args, array('img_size' => 'inherit', 'img_w' => '', 'img_h' => '', 'default_img' => false))); $config_id = _UBERMENU()->get_current_config(); //Image $img = ''; //If post is set, but img is not, get featured image if (!$img_id && $post_id) { $thumb_id = get_post_thumbnail_id($post_id); if ($thumb_id) { $img_id = $thumb_id; } } if (!$img_id) { $img_id = $default_img; } if ($img_id) { $atts = array(); $atts['class'] = 'ubermenu-image'; //Determine size of image to get if ($img_size == 'inherit') { $img_size = ubermenu_op('image_size', $config_id); } //echo '['.$img_size.']'; $atts['class'] .= ' ubermenu-image-size-' . $img_size; //Get the reight image file $img_src = wp_get_attachment_image_src($img_id, $img_size); $atts['src'] = $img_src[0]; //Apply natural dimensions if not already set if (ubermenu_op('image_set_dimensions', $config_id)) { if ($img_w == '' && $img_h == '') { $img_w = $img_src[1]; $img_h = $img_src[2]; } } //Default dimensions if not natural if (!$img_w) { $img_w = ubermenu_op('image_width', $config_id); $img_h = ubermenu_op('image_height', $config_id); } //Add dimensions as attributes, with pixel units if missing if ($img_w) { //if( is_numeric( $img_w ) ) $img_w.='px'; //Should always be numeric only, no units $atts['width'] = $img_w; } if ($img_h) { //if( is_numeric( $img_h ) ) $img_h.='px'; //Should always be numeric only, no units $atts['height'] = $img_h; } //Add 'alt' & 'title' $meta = get_post_custom($img_id); $alt = isset($meta['_wp_attachment_image_alt']) ? $meta['_wp_attachment_image_alt'][0] : ''; //Alt field $title = ''; if ($alt == '') { $title = get_the_title($img_id); $alt = $title; } $atts['alt'] = $alt; if (ubermenu_op('image_title_attribute', $config_id) == 'on') { if ($title == '') { $title = get_the_title($img_id); } $atts['title'] = $title; } //Build attributes string $attributes = ''; foreach ($atts as $name => $val) { $attributes .= $name . '="' . esc_attr($val) . '" '; } $img = "<img {$attributes} />"; //$img = "<span class='ubermenu-image'><img $attributes /></span>"; if ($data) { $data = array(); $data['img'] = $img; $data['w'] = $img_w; $data['h'] = $img_h; $data['atts'] = $atts; return $data; } } return $img; }
/** * Get the value of a settings field * * @param string $option settings field name * @param string $section the section name this field belongs to * @param string $default default text if it's not found * @return string */ function get_option($option, $section, $default = '') { $options = get_option($section); if (isset($options[$option])) { return $options[$option]; } return _UBERMENU()->get_default($option, $section); //return $default; }
function ubermenu_get_registered_icons() { return _UBERMENU()->get_registered_icons(); }