0,
'lng' => 0,
'address' => '',
'zoom' => 15,
'title' => '',
'width' => '100%',
'height' => '200px'
), $atts));
$html = '
';
return $html;
}
add_shortcode( 'ubermenu-map' , 'ubermenu_google_maps' );
/*
* Recent Posts Shortcodes - optional Image (via "Featured Image" functionality).
*/
function ubermenu_recent_posts($atts){
global $uberMenu;
extract(shortcode_atts(array(
'num' => 3,
'img' => 'on',
'excerpt' => 'off',
'category' => '',
'default_img' => false,
'offset' => 0,
), $atts));
$args = array(
'numberposts' => $num,
'offset' => $offset,
'suppress_filters' => false
);
if(!empty($category)){
if(is_numeric($category)){
$args['category'] = $category;
}
else $args['category_name'] = $category;
}
$posts = get_posts($args);
$class = 'wpmega-postlist';
if($img == 'on') $class.= ' wpmega-postlist-w-img';
$html= '';
foreach($posts as $post){
$ex = $post->post_excerpt;
if( $ex == '' && function_exists( 'wp_trim_words' ) ){ //wp_trim_words is a WP3.3 function
$ex = $post->post_content;
$ex = strip_shortcodes( $ex );
$ex = str_replace(']]>', ']]>', $ex);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$ex = wp_trim_words( $ex, $excerpt_length, $excerpt_more );
}
//$ex = apply_filters('get_the_excerpt', $post->post_excerpt);
$post_url = get_permalink($post->ID);
$image = '';
$w = 45;
$h = 45;
if($img == 'on') $image = $uberMenu->getPostImage($post->ID, $w, $h, $default_img);
$html.= '- '. $image.
'';
if($excerpt == 'on')
$html.= '
'.$ex.'
';
$html.= ''.
' ';
}
$html.= '
';
return $html;
}
add_shortcode('wpmega-recent-posts', 'ubermenu_recent_posts'); //legacy
add_shortcode('ubermenu-recent-posts', 'ubermenu_recent_posts');
/*
* Column Group Shortcode - must wrap [wpmega-col] shortcode
*/
function ubermenu_colgroup($atts, $data){
$col_index = 0;
$pattern = get_shortcode_regex();
$pat = '/\[ubermenu\-col(?.*?)\]'.'(?.*?)'.'\[\/ubermenu\-col\]/s'; //trailing /s makes dot (.) match newlines
preg_match_all($pat, $data, $matches, PREG_SET_ORDER);
if( empty( $matches ) ){
$pat = '/\[wpmega\-col(?.*?)\]'.'(?.*?)'.'\[\/wpmega\-col\]/s'; //trailing /s makes dot (.) match newlines
preg_match_all($pat, $data, $matches, PREG_SET_ORDER);
}
$columns = array();
foreach($matches as $m){
//get the colspan
$colspan_pat = '/colspan="(?[\d]*?)"/';
preg_match($colspan_pat, $m['atts'], $match);
$colspan = isset($match['colspan']) ? $match['colspan'] : 1;
$col_index += $colspan; //increment by colspan, so if we have 2 cols in a 2/3rds format it's a 3-col with a 2-span and a 1-span
$columns[] = '[ubermenu-col '.$m['atts'].' col_index="'.$col_index.'" ]'.$m['data'].'[/ubermenu-col]';
}
$html ='';
foreach($columns as $c){
$html.= do_shortcode($c);
}
$html.= '
';
return $html;
}
add_shortcode( 'wpmega-colgroup', 'ubermenu_colgroup'); //legacy
add_shortcode( 'ubermenu-colgroup', 'ubermenu_colgroup');
/*
* Column Shortcode
*/
function ubermenu_col($atts, $data){
extract(shortcode_atts(array(
'colspan' => 1,
'col_index' => 0,
), $atts));
$col_index;
$data = do_shortcode($data);
$data = wpmega_trim_tag($data, array('br', 'br/', 'br /'));
return ''.$data.'
';
}
add_shortcode( 'wpmega-col', 'ubermenu_col' ); //legacy
add_shortcode( 'ubermenu-col', 'ubermenu_col' );
/** this allows shortcodes in widgets **/
add_filter('widget_text', 'do_shortcode');
/* Tag Trimming Helper Function */
function wpmega_trim_tag($s, $tags){
$s = trim($s);
foreach($tags as $tag){
$tag = '<'.$tag.'>';
if(strpos($s, $tag) === 0){
$s = substr($s, strlen($tag));
}
if(strpos($s, $tag) === strlen($s) - strlen($tag)){
$s = substr($s, 0, strlen($s) - strlen($tag));
}
}
return $s;
}
function ubermenu_searchform(){
$form = '';
return $form;
//get_search_form( false );
}
add_shortcode('ubermenu-search', 'ubermenu_searchform');
/*function wpmega_filter_search_val($form){
$form = str_replace('value="Search"', 'value="→"', $form);
return $form;
}
add_filter('get_search_form', 'wpmega_filter_search_val');*/