/** * recent_mu_posts - for multisite */ function post_type_dropdown_multisite(&$output, $args = array(), $depth = 1) { if (!is_multisite() || !is_main_site()) { return false; } global $mega_main_menu; // global $wpdb; $args = (array) $args; $showposts = get_post_meta($args['menu_item_id'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_columns', true) * 2; $post_type = get_post_meta($args['menu_item_id'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_post_type', true); $columns = get_post_meta($args['menu_item_id'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_columns', true) ? get_post_meta($args['menu_item_id'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_columns', true) : 2; $enable_full_width = get_post_meta($args['menu_main_parent'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_columns', true); $_submenu_enable_full_width = is_array(get_post_meta($args['menu_main_parent'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_enable_full_width', true)) ? get_post_meta($args['menu_main_parent'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_enable_full_width', true) : array(); $dropdown_width = in_array('true', $_submenu_enable_full_width) ? 1140 : 450; $item_width_height = 100 / $columns; $img_width_height = floor(1140 / $columns); $details_height = floor($dropdown_width / 3); $blogs = get_last_updated('', 0, $showposts); foreach ($blogs as $blog) { switch_to_blog($blog["blog_id"]); $lastposts = get_posts('numberposts=1'); foreach ($lastposts as $post) { setup_postdata($post); $recent_query = array($post); if (isset($recent_query) && count($recent_query)) { foreach ($recent_query as $key => $post_object) { $post_icon = get_post_meta($post_object->ID, 'mm_post_icon', true) ? get_post_meta($post_object->ID, 'mm_post_icon', true) : 'im-icon-plus-circle'; $output .= mm_common::ntab($depth + 1) . '<li class="post_item" style="width:' . $item_width_height . '%;">'; if (wp_get_attachment_image_src(get_post_thumbnail_id($post_object->ID), 'full')) { $output .= mm_image_pro::processed_image($img_args = array('post_id' => $post_object->ID, 'width' => $img_width_height, 'height' => $img_width_height, 'permalink' => get_permalink($post_object->ID), 'icon' => $post_icon, 'cover' => 'icon')); } else { $output .= mm_common::ntab($depth + 2) . '<a class="item_link" href="' . get_permalink($post_object->ID) . '" title="' . apply_filters('the_title', $post_object->title, $post_object->ID) . '">'; $output .= mm_common::ntab($depth + 3) . '<i class="' . $post_icon . '"></i>'; $output .= mm_common::ntab($depth + 3) . '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABdJREFUeNpi/P//PwM6YGLAAigUBAgwADZQAwcsn51XAAAAAElFTkSuQmCC" alt="placeholder"/>'; $output .= mm_common::ntab($depth + 2) . '</a>'; } $output .= mm_common::ntab($depth + 2) . '<div class="post_details">'; if (wp_get_attachment_image_src(get_post_thumbnail_id($post_object->ID), 'full')) { $output .= mm_image_pro::processed_image($img_args = array('post_id' => $post_object->ID, 'width' => $dropdown_width, 'height' => $details_height, 'permalink' => get_permalink($post_object->ID), 'icon' => $post_icon, 'cover' => false)); } $output .= mm_common::ntab($depth + 3) . '<div class="post_icon">'; $output .= mm_common::ntab($depth + 4) . '<i class="' . $post_icon . '"></i>'; $output .= mm_common::ntab($depth + 3) . '</div>'; $output .= mm_common::ntab($depth + 3) . '<div class="post_title">'; $output .= mm_common::ntab($depth + 4) . apply_filters('the_title', $post_object->post_title, $post_object->ID); $output .= mm_common::ntab($depth + 3) . '</div>'; $output .= mm_common::ntab($depth + 3) . '<div class="post_description">'; if (isset($post_object->post_excerpt) && !empty($post_object->post_excerpt)) { $post_excerpt = $post_object->post_excerpt; } else { $post_excerpt = $post_object->post_content; } $output .= mm_common::ntab($depth + 4) . mm_common::excerpt($post_excerpt); $output .= mm_common::ntab($depth + 3) . '</div>'; $output .= mm_common::ntab($depth + 2) . '</div><!-- /.post_details -->'; $output .= mm_common::ntab($depth + 1) . '</li><!-- /.post_item -->'; } } } restore_current_blog(); } return $output; }
/** * post_type_dropdown */ function post_type_dropdown(&$output, $args, $depth) { global $mega_main_menu; $args = (array) $args; global $wpdb; //, $shortname $showposts = get_post_meta($args['menu_main_parent'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_columns', true) * 2; $post_type = get_post_meta($args['menu_main_parent'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_post_type', true); $query_args = array('post_type' => $post_type, 'showposts' => $showposts, 'nopaging' => false, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'suppress_filters' => false); if (strripos($post_type, '/') !== false) { $post_type_taxonomy = explode('/', $post_type); $query_args['post_type'] = $post_type_taxonomy[0]; $taxonomy = explode('=', $post_type_taxonomy[1]); $query_args['tax_query'] = array(array('taxonomy' => $taxonomy[0], 'field' => 'slug', 'terms' => $taxonomy[1])); } else { $query_args['post_type'] = $post_type; } $recent_query = get_posts($query_args); if (count($recent_query)) { $columns = get_post_meta($args['menu_main_parent'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_columns', true) ? get_post_meta($args['menu_main_parent'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_columns', true) : 2; $enable_full_width = get_post_meta($args['menu_main_parent'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_columns', true); $_submenu_enable_full_width = is_array(get_post_meta($args['menu_main_parent'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_enable_full_width', true)) ? get_post_meta($args['menu_main_parent'], $mega_main_menu->constant['MM_WARE_PREFIX'] . '_submenu_enable_full_width', true) : array(); $dropdown_width = in_array('true', $_submenu_enable_full_width) ? 1140 : 450; $item_width_height = 100 / $columns; $img_width_height = floor(1140 / $columns); $details_height = floor($dropdown_width / 3); foreach ($recent_query as $key => $post_object) { $post_icon = get_post_meta($post_object->ID, 'mm_post_icon', true) ? get_post_meta($post_object->ID, 'mm_post_icon', true) : ''; $output .= mm_common::ntab($depth + 1) . '<li class="post_item" style="width:' . $item_width_height . '%;">'; if (wp_get_attachment_image_src(get_post_thumbnail_id($post_object->ID), 'full')) { $output .= mm_image_pro::processed_image($img_args = array('post_id' => $post_object->ID, 'width' => $img_width_height, 'height' => $img_width_height, 'permalink' => get_permalink($post_object->ID), 'icon' => $post_icon, 'cover' => 'icon')); } else { $output .= mm_common::ntab($depth + 2) . '<a class="item_link" href="' . get_permalink($post_object->ID) . '" title="' . apply_filters('the_title', $post_object->title, $post_object->ID) . '">'; $output .= mm_common::ntab($depth + 3) . '<i class="' . $post_icon . '"></i>'; $output .= mm_common::ntab($depth + 3) . '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABdJREFUeNpi/P//PwM6YGLAAigUBAgwADZQAwcsn51XAAAAAElFTkSuQmCC" alt="placeholder"/>'; $output .= mm_common::ntab($depth + 2) . '</a>'; } $output .= mm_common::ntab($depth + 2) . '<div class="post_details">'; if (wp_get_attachment_image_src(get_post_thumbnail_id($post_object->ID), 'full')) { $output .= mm_image_pro::processed_image($img_args = array('post_id' => $post_object->ID, 'width' => $dropdown_width, 'height' => $details_height, 'permalink' => get_permalink($post_object->ID), 'icon' => $post_icon, 'cover' => false)); } $output .= mm_common::ntab($depth + 3) . '<div class="post_icon">'; $output .= mm_common::ntab($depth + 4) . '<i class="' . $post_icon . '"></i>'; $output .= mm_common::ntab($depth + 3) . '</div>'; $output .= mm_common::ntab($depth + 3) . '<div class="post_title">'; $output .= mm_common::ntab($depth + 4) . apply_filters('the_title', $post_object->post_title, $post_object->ID); $output .= mm_common::ntab($depth + 3) . '</div>'; $output .= mm_common::ntab($depth + 3) . '<div class="post_description">'; $output .= mm_common::ntab($depth + 4) . mm_common::excerpt($post_object->post_content); $output .= mm_common::ntab($depth + 3) . '</div>'; $output .= mm_common::ntab($depth + 2) . '</div><!-- /.post_details -->'; $output .= mm_common::ntab($depth + 1) . '</li><!-- /.post_item -->'; } } // $output .= '<span class="clearboth"></span><!-- /.clearboth -->'; }