_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-format-gallery', '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('slideshows') ); 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('aFslug')){ function aFslug($echo=true){ # Lengthy code to define aFslug() $slug = basename(get_permalink()); do_action('before_slug',$slug); $slug = apply_filters('slug_filter',$slug); if($echo)echo $slug; do_action('after_slug',$slug); return $slug; } } 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 */ add_filter('the_posts','aFSJSCSS_if_Sc'); function aFSJSCSS_if_Sc($posts){ if(empty($posts))return $posts; $shortcode_found = 0; foreach($posts as $post){ if(stripos($post->post_content,'[slides')=== false){ $shortcode_found = false; } else{ $shortcode_found = true; } } if($shortcode_found){ aFSJSCSS(); aFSScFn(); } return $posts; } function aFSJSCSS(){ $aFSOptions = get_option('aFSOpts'); if (!get_option('aFSDefaultCSS')){ wp_enqueue_style('aFSStylesheet',plugins_url('css/addfunc-slides.css',__FILE__)); } wp_register_script('aFslides',plugins_url('js/addfunc-slides.js',__FILE__)); wp_enqueue_script('aFslides'); } $aFSInit = ""; $aFSOpts = ""; /* S H O R T C O D E ================= */ function aFSScFn(){ 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,$aFSOpts,$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_script('aFSJSCSS'); self::$did_script = true; } } public function widget($args,$instance) { $tabs = ""; extract($instance); $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(); $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($pagenation){ $tabs = true; } if(empty($swipe)){ $swipe = "horizontal"; } if ((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%"; } } $aFSArgs = array( 'slidesets' => $slideset, 'post_type' => 'slides', 'order' => $order, 'orderby' => $orderby, 'meta_key' => $meta_key, 'posts_per_page' => -1 ); $outputThumbs = ""; $outputLabels = ""; if(($pagenation==="T")||($pagenation==="LT")){ $outputThumbs = true; } /* Output the thumbnail */ if(($pagenation==="L")||($pagenation==="LT")){ $outputLabels = true; } /* Output the label */ if(($slideset === 'all')||empty($slideset)){ $slideset = ''; $slidesetID = 'all-slides'; } else { $slidesetID = $slideset; } $aFSPosts = aFget_posts($aFSArgs); ?>
Type: (Requires theme or skin support.)
Note: The Choose Image file uploader/selector buttons (in this version of AddFunc Slides) don't provide the popup windows that they should, until the Slide is saved. This is a known issue. The image-path fields do however accept and store any valid data that is manually entered.
Warning: The link selector (in this version of AddFunc Slides) highjacks the function used for adding links in the main editor (for Slides only, not Pages, Posts, etc.). The adverse result is that after you save the Slide, the link Quicktag (in Text view) adds your chosen URL to the Slide Options Link field instead of your highlighted text in the editor. Therefore, links have to be added in the editor manually or created in Visual mode. Additionally, the Choose Post button doesn't provide the popup window that it should until the Slide is saved. These are known issues. The Link field does however store any valid data that is entered.
value='1'>'.__( 'Here are the shortcodes to use for your current Slidesets:' ).'
[slides slideset='.$sldset->slug.']'.__( 'You currently have no Slidesets. You can create one by clicking on Slidesets in the Slides menu (or here) or by adding a Slide to a Slideset when editing it.' ).'
'; return ob_get_clean(); } } $screen = get_current_screen(); $screen->add_help_tab( array( 'id' => 'aFSHelpTab', 'title' => __('Slideshows'), 'content' => ''.__( 'You can display all* of your Slides by adding [slides] to any Page, Post or anywhere else your theme and plugins let you add a shortcode. To display a specific Slideset, use [slides slideset=my-slideset] (replacing "my-slideset" with your Slideset\'s slug*).' ).'
' .aFSHTShortcodes().''.__( 'There are more parameters (settings) you can add to your shortcode to change it\'s end result (e.g. [slides slideset=my-slideset prevnext=false] will remove the slideshow\'s "Previous" and "Next" buttons). No parameters are required unless customization is necessary. Here is a list of all parameters (in the convention: parameter "default value" — Description; optional values):' ).'
slideset "" — Selects a specific Slideset; slideset-slug or all (shows all slides)auto false — Automate Slide transitioning; true or falsespeed 7000 (7 seconds) — Duration each Slide is displayed; number of milliseconds (no commas)prevnext true — Adds "Previous" and "Next" buttons; true or falsepause false — Adds Pause button; true or falsetabs false — Adds tabs/pager; true, false, thumbnails, labels, all or fulltabsfirst false — Outputs tabs before the slideshow; true or falsestoppable true — Stops automated transition upon user interaction; true or falsepauseonhover true — Pause on hover/mouseover; true or falsefullscreen false — Adds Fullscreen button (note limited browser support); true or falseswipe true (horizontal) — Adds touchscreen swipe capability;
class "" — Adds CSS class(es) to the slideset, "any css-classes"tabsclass "" — Adds CSS class(es) to the tabs. Note: doesn\'t work if "tabs" is "true" unless "tabsfirst" is also "true". Works with all other options ("labels", "thumbnails", etc.)color (inherited) — Sets the color of the controls (may affect text in Slides as well). Examples: #fff, rgb(255,135,125), orangesize (inherited) — Sets the size of the controls (may affect text in Slides as well). Examples: 22px, 1.6em, 110%order asc — The order in which Slides are displayed; asc (ascending), desc (descending) orderby priority — What the display order is based upon; date (date of Slide), priority (if set in Slide options), name (Slide name), ID (Slide ID), rand (random order)meta_key "" — For advanced users to specify a meta_key (experimental—may eventually be removed)'.__( '*WARNING: Depending on the number of Slides this website has, adding all of them to a single slideshow can drastically slow down the website\'s load time when outputting the slideshow.' ).'
'.__( '*Slugs: You can obtain the slug of any of your slidesets by visiting the Slidesets page. To learn more about slugs in general, go here.' ).'
'.__( ' = Opens in a new tab/window.' ).'
'.__( ' = Links to an external website.' ).'
' )); }