_x('Slidesets','taxonomy general name'), 'singular_name' => _x('Slideset','taxonomy singular name'), 'search_items' => __('Search Slidesets'), 'popular_items' => __('Popular Slidesets'), 'all_items' => __('All Slidesets'), 'parent_item' => __('Parent Slideset'), 'parent_item_colon' => __('Parent Slideset:'), 'separate_items_with_commas' => __('Separate Slidesets with commas'), 'add_or_remove_items' => __('Add or remove tags'), 'choose_from_most_used' => __('Choose from the most used Slidesets'), 'not_found' => __('No Slidesets found'), 'separatewith_commas' => __('Separate Slidesets with commas'), 'edit_item' => __('Edit Slideset'), 'update_item' => __('Update Slideset'), 'add_new_item' => __('Add New Slideset'), 'new_item_name' => __('New Slideset Name'), 'menu_name' => __('Slidesets'), ); $args = array( 'hierarchical' => true, 'show_admin_column' => true, 'labels' => $labels, 'rewrite' => array('slug' => 'slideset'), ); register_taxonomy('slidesets','slides',$args); } add_action('init','aFregslidesets'); } /* C U S T O M P O S T T Y P E =============================== Register Slides post type */ if(!function_exists('aFslds_post_type')){ add_action('init','aFslds_post_type',0); function aFslds_post_type(){ $labels = array( 'name' => _x('Slides','post type general name'), 'singular_name' => _x('Slide','post type singular name'), 'add_new' => __('Add New'), 'add_new_item' => __('Add New'), 'edit_item' => __('Edit Slide'), 'new_item' => __('New Slide'), 'view_item' => __('View Slide'), 'all_items' => __('All Slides'), 'search_items' => __('Search Slides'), 'not_found' => __('No Slides found'), 'not_found_in_trash' => __('No Slides found in Trash'), 'menu_name' => 'Slides' ); $show_in_admin = ''; if(!current_user_can('edit_posts')){ $show_in_admin = false; } else{ $show_in_admin = true; } $supports = array('title','thumbnail','editor','revisions'); $args = array( 'menu_icon' => 'dashicons-images-alt2', 'labels' => $labels, 'public' => false, 'show_ui' => $show_in_admin, 'show_in_menu' => $show_in_admin, 'show_in_admin_bar' => $show_in_admin, 'query_var' => 'slides', 'rewrite' => array('slug'=>'slides'), 'has_archive' => false, 'hierarchical' => false, 'supports' => $supports, 'register_meta_box_cb' => 'aFSMetaBoxes', 'taxonomies' => array('slideset') ); register_post_type('slides',$args); } } /* F U N C T I O N S ================= */ if(!function_exists('aFAutoParam')){ function aFAutoParam($key,$value,$default=NULL){ if(empty($value)){ # If there is no value if($default){ # ...and there is a default $value = $default; # ...use the default } } if(!empty($value)){ # If there is a value and... if((is_string($value)) && (!is_numeric($value)) && ($value!="true") && ($value!="false") && (substr($value,0,1)!= "{")){ # $value is a string and is not a number and is not one of keywords "true" or "false" and is not in curly-brackets $quotes = '"'; } else{ # $value is not a string or is a number or is one of keywords "true" or "false" or is in curly-brackets $quotes = ''; } return $key.": ".$quotes.$value.$quotes.",\n "; # Output with/without quotes } } } if(!function_exists('aFget_posts')){ function aFget_posts($args = null){ $defaults = array( 'numberposts' => 5, 'offset' => 0, 'category' => 0, 'orderby' => 'date', 'order' => 'ASC', 'include' => array(), 'exclude' => array(), 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'suppress_filters' => true ); $r = wp_parse_args($args,$defaults); if(empty($r['post_status'])) $r['post_status'] =('attachment' == $r['post_type'])?'inherit':'publish'; if(!empty($r['numberposts']) && empty($r['posts_per_page'])) $r['posts_per_page'] = $r['numberposts']; if(!empty($r['category'])) $r['cat'] = $r['category']; if(!empty($r['include'])){ $incposts = wp_parse_id_list($r['include']); $r['posts_per_page'] = count($incposts); // only the number of posts included $r['post__in'] = $incposts; }elseif(!empty($r['exclude'])) $r['post__not_in'] = wp_parse_id_list($r['exclude']); $r['ignore_sticky_posts'] = true; $r['no_found_rows'] = true; $aFget_posts = new WP_Query; return $aFget_posts->query($r); } } /* J S & C S S in H E A D ============================== Conditional Styles & Scripts */ $aFSInit = ""; function aFSJSCSS(){ global $post; $aFSOptions = get_option('aFSOpts'); $aFSVals = get_post_custom($post->ID); $aFSDefaultCSS = isset($aFSOptions['aFSDefaultCSS']) ? $aFSOptions['aFSDefaultCSS'][0] : ''; $aFSJSCSSOff = isset($aFSOptions['aFSJSCSSOff']) ? $aFSOptions['aFSJSCSSOff'][0] : ''; $aFSJSCSSOn = isset($aFSVals['aFSJSCSSOn']) ? $aFSVals['aFSJSCSSOn'][0] : ''; wp_register_script('aFSlidesJS',plugins_url('js/addfunc-slides.js?v=2-6',__FILE__)); wp_register_style('aFSlidesCSS',plugins_url('css/addfunc-slides.css',__FILE__)); if(!$aFSJSCSSOff || $aFSJSCSSOn){ if(!$aFSDefaultCSS){ wp_enqueue_style('aFSlidesCSS'); } wp_enqueue_script('aFSlidesJS'); } } add_action('wp_enqueue_scripts','aFSJSCSS'); /* S H O R T C O D E ================= */ function aFSSc($atts){ $aFSMrgd = shortcode_atts(array( 'slideset' => '', 'auto' => '', 'speed' => '', 'prevnext' => '', 'pause' => '', 'tabs' => '', 'tabsfirst' => '', 'stoppable' => '', 'pauseonhover' => '', 'fullscreen' => '', 'swipe' => '', 'class' => '', 'color' => '', 'size' => '', 'height' => '', 'ratio' => '', 'tabsclass' => '', 'order' => 'ASC', 'orderby' => '', 'meta_key' => '', ),$atts,'slides'); extract($aFSMrgd); $aFSOptions = get_option('aFSOpts'); if(!$color){ if(!empty($aFSOptions['aFSDefaultColor'])){ $color = $aFSOptions['aFSDefaultColor']; } } if(empty($size)){ if(!empty($aFSOptions['aFSDefaultSize'])){ $size = $aFSOptions['aFSDefaultSize']; } } $aFSInst = 'aFS'.uniqid(); // http://stackoverflow.com/questions/22873093/generate-different-code-in-wp-footer-for-each-shortcode-instance if(!$orderby){ $orderby = 'meta_value_num'; $meta_key = 'aFSPrior'; } if(($slideset === 'all')||empty($slideset)){ $slideset = ''; $slidesetID = 'all-slides'; } else { $slidesetID = $slideset; } if ((strpos($ratio,':') == true)||(strpos($ratio,'-') == true)||(strpos($ratio,'x') == true)) { preg_match('/\d+/', $ratio, $fstnum); $fst = $fstnum[0]; preg_match('/(\d+)\D*$/', $ratio, $sndnum); $snd = end($sndnum); $prc = ($snd/$fst) * 100; $ratio = $prc."%"; } else { if(($ratio == 'HD')) { $ratio = "56.25%"; } elseif ($ratio == 'half') { $ratio = "50%"; } elseif ($ratio == 'old') { $ratio = "74%"; } elseif ($ratio == 'standard') { $ratio = "75%"; } elseif ($ratio == 'square') { $ratio = "100%"; } elseif ($ratio == 'portrait') { $ratio = "150%"; } } $args = array( 'slidesets' => $slideset, 'post_type' => 'slides', 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key, 'posts_per_page' => -1 ); $aFSPosts = aFget_posts($args); global $post,$aFSInit,$aFDependsOn; $tmp_post = $post; ob_start(); $outputThumbs = ""; $outputLabels = ""; if($tabs && (($tabs != 'labels') && ($tabs != 'true'))){ $outputThumbs = true; } /* Output the thumbnail */ if($tabs && (($tabs != 'thumbnails') && ($tabs != 'true'))){ $outputLabels = true; } /* Output the label */ ?>
__('Display your Slides in an AddFunc slideshow.','text_domain'),)// Args ); if(!self::$did_script && is_active_widget(false,false,$this->id_base,true)){ add_action('wp_enqueue_scripts','aFSJSCSS'); wp_enqueue_style('aFSlidesCSS'); wp_enqueue_script('aFSlidesJS'); self::$did_script = true; } } public function widget($args,$instance) { $aFSOptions = get_option('aFSOpts'); $slideset = isset($instance['slideset']) ? $instance['slideset'] : ''; $auto = isset($instance['auto']) ? $instance['auto'] : ''; $speed = isset($instance['speed']) ? $instance['speed'] : ''; $prevnext = isset($instance['prevnext']) ? $instance['prevnext'] : ''; $pause = isset($instance['pause']) ? $instance['pause'] : ''; $pagination = isset($instance['pagination']) ? $instance['pagination'] : ''; $tabs = isset($instance['tabs']) ? $instance['tabs'] : ''; $tabsfirst = isset($instance['tabsfirst']) ? $instance['tabsfirst'] : ''; $stoppable = isset($instance['stoppable']) ? $instance['stoppable'] : ''; $pauseonhover = isset($instance['pauseonhover']) ? $instance['pauseonhover'] : ''; $fullscreen = isset($instance['fullscreen']) ? $instance['fullscreen'] : ''; $swipe = isset($instance['swipe']) ? $instance['swipe'] : ''; $class = isset($instance['class']) ? $instance['class'] : ''; $color = isset($instance['color']) ? $instance['color'] : ''; $size = isset($instance['size']) ? $instance['size'] : ''; $height = isset($instance['height']) ? $instance['height'] : ''; $ratio = isset($instance['ratio']) ? $instance['ratio'] : ''; $tabsclass = isset($instance['tabsclass']) ? $instance['tabsclass'] : ''; $order = isset($instance['order']) ? $instance['order'] : ''; $orderby = isset($instance['orderby']) ? $instance['orderby'] : ''; $meta_key = isset($instance['meta_key']) ? $instance['meta_key'] : ''; if(!$color){ if(!empty($aFSOptions['aFSDefaultColor'])){ $color = $aFSOptions['aFSDefaultColor']; } } if(empty($size)){ if(!empty($aFSOptions['aFSDefaultSize'])){ $size = $aFSOptions['aFSDefaultSize']; } } $aFSInst = 'aFS'.uniqid(); $title = apply_filters('widget_title',$instance['title']); echo $args['before_widget']; $termid = get_term($slideset,'slidesets'); $slideset = $termid->slug; if(!$orderby){ $orderby = 'meta_value_num'; $meta_key = 'aFSPrior'; } $order = empty($order)? 'ASC' : 'DESC'; if($pagination){ $tabs = true; } if(empty($swipe)){ $swipe = "horizontal"; } if ((strpos($ratio,':') == true)||(strpos($ratio,'x') == true)) { $fstnum = array(); preg_match('/\d+/', $ratio, $fstnum); $fst = $fstnum[0]; $sndnum = array(); preg_match('/(\d+)\D*$/', $ratio, $sndnum); $snd = end($sndnum); $prc = ($snd/$fst) * 100; $ratio = $prc."%"; } else { if(($ratio == 'HD')) { $ratio = "56.25%"; } elseif ($ratio == 'half') { $ratio = "50%"; } elseif ($ratio == 'old') { $ratio = "74%"; } elseif ($ratio == 'standard') { $ratio = "75%"; } elseif ($ratio == 'square') { $ratio = "100%"; } elseif ($ratio == 'portrait') { $ratio = "150%"; } } $aFSArgs = array( 'slidesets' => $slideset, 'post_type' => 'slides', 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key, 'posts_per_page' => -1 ); $outputThumbs = ""; $outputLabels = ""; if(($pagination==="T")||($pagination==="LT")){ $outputThumbs = true; } /* Output the thumbnail */ if(($pagination==="L")||($pagination==="LT")){ $outputLabels = true; } /* Output the label */ if(($slideset === 'all')||empty($slideset)){ $slideset = ''; $slidesetID = 'all-slides'; } else { $slidesetID = $slideset; } $aFSPosts = aFget_posts($aFSArgs); ?>