'vertical', 'type' => 'post', 'post_number' => 5, 'effect' => 'swing', 'opened_d' => 200, 'closed_d' => 100, 'width' => get_option('medium_size_w'), 'height' => get_option('medium_size_h'), 'duration' => 300, 'border' => 1, 'border_color' => '#000000', 'title'=>'over', 'open' => '', 'include_jquery' => 1, 'version' => AIM_VERSION ); function aim_options ($default = false){ global $d_aim_options; $options = get_option('a_i_m'); if ($default) { update_option('a_i_m', $d_aim_options); return $d_aim_options; } if (isset($options)){ $chk_version = version_compare(AIM_VERSION,$options['version']); if ($chk_version == 0) return $options; else if ($chk_version > 0) { $options = $d_aim_options; } } else { $options = $d_aim_options; } update_option('a_i_m', $options); return $options; } /** * Header */ function a_image_menu_head() { $options = aim_options (); $a_image_menu_header = "\n\n"; if ($options['include_jquery'] == "1") $a_image_menu_header .= "\n"; $a_image_menu_header .= "\n"; $a_image_menu_header .= "\n"; $a_image_menu_header .= "\n\n"; $a_image_menu_header .= "\n\n"; print($a_image_menu_header); } add_action('wp_head', 'a_image_menu_head'); /** * The widget */ class AccordionImageMenuWidget extends WP_Widget { /** constructor */ function AccordionImageMenuWidget() { $widget_ops = array('classname' => 'accordion_image_menu', 'title' => __( 'Accordion Image Menu'), 'description' => __( 'Accordion Image Menu using the parameters saved on the Plugin Settings Page') ); $this->WP_Widget('accordion_image_menu', __('Accordion Image Menu'), $widget_ops); } /** @see WP_Widget::widget */ function widget($args, $instance) { extract( $args ); $title = apply_filters('widget_title', $instance['title']); ?>
$the_parent, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 1) ); if($attachments == true) : foreach($attachments as $id => $attachment) : $img = wp_get_attachment_image_src($id, 'medium'); endforeach; endif; } if (isset($img[0])) return $img[0]; } /** * Get the items */ function a_image_m_items($num, $cat, $type){ $options = aim_options (); /** * Recent Posts */ if ($type == 'post'){ $i = 0; if (empty($cat)) $my_query = get_posts(array('numberposts'=>$num)); else if (!is_array($cat)){ $mcat = explode (",",$cat); $my_query = get_posts(array('category__in'=>$mcat,'numberposts'=>$num)); } else { $my_query = get_posts(array('category__in'=>$cat,'numberposts'=>$num)); } foreach ($my_query as $post) { $the_image = a_m_image_url($post -> ID); $the_title = get_the_title($post -> ID); $the_link = get_permalink($post -> ID); $item[$i] = array("img" => $the_image,"title" => $the_title,"link" => $the_link); $i ++; } } else if ($type == 'page'){ /** * Pages */ if(isset($options['pag_or'])){ foreach ($options['pag_or'] as $m_pages => $order){ if (is_numeric($order) and ($order != 0)) { $the_image = a_m_image_url($m_pages); $the_title = get_the_title($m_pages); $the_link = get_permalink($m_pages); $item[$order] = array("img" => $the_image,"title" => $the_title,"link" => $the_link); } } } /** * Categories */ if(isset($options['cat_or'])){ foreach ($options['cat_or'] as $m_cat => $order){ if (is_numeric($order) and ($order != 0)) { $my_query = get_posts(array('cat'=>$m_cat,'numberposts'=>1)); $the_image = ""; foreach ($my_query as $post) { $the_image = a_m_image_url($post -> ID); $the_title = get_cat_name($m_cat); $the_link = get_category_link($m_cat); $item[$order] = array("img" => $the_image,"title" => $the_title,"link" => $the_link); } } } } } return $item; } function a_image_m_items_from_id($ids) { $my_query = get_posts(array('include'=>$ids,'post_type'=>'any')); $i = 0; foreach ($my_query as $post) { $the_image = a_m_image_url($post -> ID); $the_title = get_the_title($post -> ID); $the_link = get_permalink($post -> ID); $item[$i] = array("img" => $the_image,"title" => $the_title,"link" => $the_link); $i ++; } return $item; } function a_image_m_items_from_menu($name) { $item = array (); if ($menu_items = wp_get_nav_menu_items($name)) { $i = 0; foreach ($menu_items as $post) { $the_image = ""; if ($post -> object == "category") { $my_query = get_posts(array('cat'=>$post -> object_id,'numberposts'=>5)); foreach ($my_query as $cat_post) { $the_image = a_m_image_url($cat_post -> ID); if (!empty($the_image)) break; } } else if ($post -> object == "page"){ $the_image = a_m_image_url($post -> object_id); } $the_title = $post -> title; $the_link = $post -> url; $item[$post -> menu_order] = array("img" => $the_image,"title" => $the_title,"link" => $the_link); } } return $item; } /** * The shortcode */ function a_image_menu_func($atts) { $options = aim_options (); //position $position = $options['position']; $post_number = $options['post_number']; //type of menu cat/pages if(isset($options['m_cat'])) $m_cat = $options['m_cat']; if(isset($options['cat_or'])) $cat_or = $options['cat_or']; if(isset($options['pag_or'])) $pag_or = $options['pag_or']; //menu $width = $options['width']; $height = $options['height']; $opened_d = $options['opened_d']; $closed_d = $options['closed_d']; $border = $options['border']; $border_color = $options['border_color']; //title $title = $options['title']; //effects $open = $options['open']; $effect = $options['effect']; $duration = $options['duration']; //menu name if(isset($options['name'])) $menu_name = $options['name']; extract(shortcode_atts(array( 'position' => $position, 'cat' => $m_cat, 'number' => $post_number, 'effect' => $effect, 'closed_d' => $closed_d, 'opened_d' => $opened_d, 'width' => $width, 'height' => $height, 'duration' => $duration, 'border' => $border, 'border_color' => $border_color, 'open' => $open, 'type' =>$options['type'], 'id' => '', 'name' =>'' ), $atts)); $alert=__("Error generating the menu"); // For Wordpress version above 3.0.0 $chk_wp_version = version_compare("3.0.0",get_bloginfo("version")); if (!empty($id)) $the_items = a_image_m_items_from_id($id); else if (!empty($name)) { if ($chk_wp_version <= 0) $the_items = a_image_m_items_from_menu($name); else $alert = __("Your Wordpress Version doesn't allows menus"); } else if (!empty($menu_name) && $type == "menu") { if ($chk_wp_version <= 0) $the_items = a_image_m_items_from_menu($menu_name); else $alert = __("Your Wordpress Version doesn't allows menus"); } else $the_items = a_image_m_items($number, $cat, $type); if(isset($the_items) and count($the_items)>0) { ksort($the_items); $random = wp_generate_password(6, false); $image_menu_div = "imageMenu_".$random; $image_menu = "\n\n"; $image_menu .= "\n"; $image_menu .= "\n"; $image_menu .= "\n"; return $image_menu; } else { return $alert; } } add_shortcode('a_image_menu', 'a_image_menu_func'); add_action('admin_menu', 'a_img_menu_set'); /** * Settings */ function a_img_menu_set() { add_options_page('Accordion Image Menu', 'Accordion Image Menu', 'administrator', 'accordion-image-menu', 'a_image_menu_page'); } function a_image_menu_page() { $options = aim_options(); $categories = get_categories(); $trans_type = array("swing","easeOutBack","easeOutBounce","easeOutCubic","easeOutElastic","easeOutExpo","easeOutQuart","easeOutQuin","easeOutSine","easeOutExpo","easeInCirc"); if(isset($_POST['Reset'])){ $options = aim_options(true); } if(isset($_POST['Submit'])){ //position $newoptions['position'] = $_POST['position']; //type of menu recent post or cat/pages $newoptions['type'] = $_POST['type']; $newoptions['post_number'] = $_POST['post_number']; //type of menu cat/pages $newoptions['m_cat'] = $_POST['m_cat']; $newoptions['cat_or'] = $_POST['cat_or']; $newoptions['pag_or'] = $_POST['pag_or']; //dimensions $newoptions['width'] = $_POST['width']; $newoptions['height'] = $_POST['height']; $newoptions['opened_d'] = $_POST['opened_d']; $newoptions['closed_d'] = $_POST['closed_d']; $newoptions['border'] = $_POST['border']; //title $newoptions['title'] = $_POST['title']; //effects if ($_POST['open'] == 1) $newoptions['open'] = $_POST['open_number']; else $newoptions['open'] = $_POST['open']; $newoptions['effect'] = $_POST['effect']; $newoptions['duration'] = $_POST['duration']; $newoptions['border_color'] = $_POST['border_color']; //menu name $newoptions['name'] = $_POST['menu_name']; //version $newoptions['version'] = $options['version']; //jquery $newoptions['include_jquery'] = $_POST['jq']; if ( $options != $newoptions ) { $options = $newoptions; update_option('a_i_m', $options); } ?>
plugin page. If everything works fine you can consider to support the plugin code by clicking on the donate button.') ?>