_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 */ // $aFSInit = ""; $aFSOpts = ""; // add_filter('the_posts','aFSJSCSS_if_Sc'); // function aFSJSCSS_if_Sc($posts){ // $shortcode_found = 0; // if(empty($posts)){ // $shortcode_found = true; // } // else{ // foreach($posts as $post){ // if(stripos($post->post_content,'[slides')=== false){ // $shortcode_found = false; // } // else{ // $shortcode_found = true; // } // } // } // if($shortcode_found){ // global $aFSInit; // $aFSInit = true; // aFSJSCSS(); // } // return $posts; // } function aFSJSCSS(){ // global $aFSInit; // $aFSInit = true; $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'); } add_action('wp_enqueue_scripts','aFSJSCSS'); /* S H O R T C O D E ================= */ // function aFSScFn(){ // if (!function_exists('aFSSc')) { 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 */ ?>
>
    ">
  1. ID,'thumbnail',array('alt' => $aFSPost->post_title.' thumbnail')); } /* Output the thumbnail */ ?>
    post_title; ?>
> ID,'aFSldTyp',true); $aFSGetMnImg = get_post_meta($aFSPost->ID,'aFSMnImg',true); $aFSGetMnAlt = get_post_meta($aFSPost->ID,'aFSMnAlt',true); $aFSGetMnLnk = get_post_meta($aFSPost->ID,'aFSMnLnk',true); $aFSGetMTarg = get_post_meta($aFSPost->ID,'aFSMTarg',true)? ' target="_blank"' : ''; $aFSGetBgImg = get_post_meta($aFSPost->ID,'aFSBgImg',true); $aFSGetClass = get_post_meta($aFSPost->ID,'aFSClass',true); ?>
>
> > <?php echo $aFSGetMnAlt; ?>
ID)){ echo ' Edit';} ?>
    ">
  1. ID,'thumbnail',array('alt' => $aFSPost->post_title.' thumbnail')); } ?>
    post_title; ?>
__('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); ?>
" >
    ">
  1. ID,'thumbnail',array('alt' => $aFSPost->post_title.' thumbnail')); } ?>
    post_title; ?>
> ID,'aFSldTyp',true); $aFSGetMnImg = get_post_meta($aFSPost->ID,'aFSMnImg',true); $aFSGetMnAlt = get_post_meta($aFSPost->ID,'aFSMnAlt',true); $aFSGetMnLnk = get_post_meta($aFSPost->ID,'aFSMnLnk',true); $aFSGetMTarg = get_post_meta($aFSPost->ID,'aFSMTarg',true)? ' target="_blank"' : ''; $aFSGetBgImg = get_post_meta($aFSPost->ID,'aFSBgImg',true); $aFSGetClass = get_post_meta($aFSPost->ID,'aFSClass',true); ?>
>
> > <?php echo $aFSGetMnAlt; ?>
ID)){ echo ' Edit';} ?>
    ">
  1. ID,'thumbnail',array('alt' => $aFSPost->post_title.' thumbnail')); } ?>
    post_title; ?>
get_field_id('slideset'); $autoGfid = $this->get_field_id('auto'); $speedGfid = $this->get_field_id('speed'); $pagenationGfid = $this->get_field_id('pagenation'); $tabsFirstGfid = $this->get_field_id('tabsFirst'); $prevNextGfid = $this->get_field_id('prevNext'); $pauseGfid = $this->get_field_id('pause'); $stoppableGfid = $this->get_field_id('stoppable'); $pauseOnHoverGfid = $this->get_field_id('pauseOnHover'); $fullScreenGfid = $this->get_field_id('fullScreen'); $swipeGfid = $this->get_field_id('swipe'); $classGfid = $this->get_field_id('class'); $colorGfid = $this->get_field_id('color'); $sizeGfid = $this->get_field_id('size'); $tabsclassGfid = $this->get_field_id('tabsclass'); $orderGfid = $this->get_field_id('order'); $orderbyGfid = $this->get_field_id('orderby'); ?>

/>
1000 = 1 sec.
/>
/>
/>
/>
/>
/>
/>

"; global $aFSOpts; echo $aFSOpts."\n"; echo "\n"; // } } add_action('wp_footer','aFSInit'); /* M E T A B O X ============= */ add_action('add_meta_boxes','aFSMetaBoxes'); function aFSMetaBoxes() { if(current_user_can('manage_options')){ add_meta_box('aFSMetaBox','Slide Options','aFSMB','slides','normal','high'); } } function aFSMB($post) { $aFSVals = get_post_custom($post->ID); $aFSPriority = isset($aFSVals['aFSPrior'])? esc_attr($aFSVals['aFSPrior'][0]): ''; $aFSlideType = isset($aFSVals['aFSldTyp'])? esc_attr($aFSVals['aFSldTyp'][0]): ''; $aFSMnImgURL = isset($aFSVals['aFSMnImg'])? esc_attr($aFSVals['aFSMnImg'][0]): ''; $aFSMnATgLnk = isset($aFSVals['aFSMnLnk'])? esc_attr($aFSVals['aFSMnLnk'][0]): ''; $aFSMLnkTarg = isset($aFSVals['aFSMTarg'])? esc_attr($aFSVals['aFSMTarg'][0]): ''; $aFSMnAltAtt = isset($aFSVals['aFSMnAlt'])? esc_attr($aFSVals['aFSMnAlt'][0]): ''; $aFSBgImgURL = isset($aFSVals['aFSBgImg'])? esc_attr($aFSVals['aFSBgImg'][0]): ''; $aFSClassVal = isset($aFSVals['aFSClass'])? esc_attr($aFSVals['aFSClass'][0]): ''; wp_nonce_field('aFSNonce','aFSMBNonce'); ?>

Type: (Requires theme or skin support.)

Main Image

/>

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.

post_type){ // wp_enqueue_media(); wp_enqueue_script('addfunc-slides-uploader',plugins_url('js/addfunc-slides-uploader.js',__FILE__),array('jquery')); } } } /* S E T T I N G S P A G E ========================= Thanks to Jeroen Sormani http://wpsettingsapi.jeroensormani.com/ */ add_action('admin_menu','aFSAddAdminMenu'); add_action('admin_init','aFSSettingsInit'); function aFSAddAdminMenu() { add_submenu_page( 'edit.php?post_type=slides', 'Slides Settings', 'Settings', 'manage_options', 'slides', 'aFSOptionsPage' ); } function aFSSettingsInit() { register_setting( 'aFSOptsPg', 'aFSOpts' ); add_settings_section( 'aFSOptsPgSection', __( '', 'aFS' ), 'aFSSettingsSection', 'aFSOptsPg' ); add_settings_field( 'aFSDefaultCSS', __('Don\'t load default stylesheet','aFS'), 'aFSDefaultCSSOpt', 'aFSOptsPg', 'aFSOptsPgSection' ); add_settings_field( 'aFSDefaultColor', __('Default color of controls','aFS'), 'aFSDefaultColorOpt', 'aFSOptsPg', 'aFSOptsPgSection' ); add_settings_field( 'aFSDefaultSize', __('Default size of controls','aFS'), 'aFSDefaultSizeOpt', 'aFSOptsPg', 'aFSOptsPgSection' ); } function aFSDefaultCSSOpt() { $aFSOptions = get_option('aFSOpts'); if (!$aFSOptions['aFSDefaultCSS']) { $aFSOptions['aFSDefaultCSS'] = 0; } ?> value='1'>

Slides Settings

$value){ $new_columns[$key] = $value; if($key == 'title'){ $new_columns['aFSPrior_column'] = 'Priority'; $new_columns['aFSldTyp_column'] = 'Type'; } } return $new_columns; } return $columns; } add_filter('manage_edit-slides_sortable_columns','aFS_manage_sortable_columns'); function aFS_manage_sortable_columns($sortable_columns){ $sortable_columns['aFSPrior_column'] = 'aFSPrior'; $sortable_columns['aFSldTyp_column'] = 'aFSldTyp'; return $sortable_columns; } add_action('manage_posts_custom_column','aFS_manage_posts_custom_column',10,2); function aFS_manage_posts_custom_column($column_name,$post_id){ switch($column_name){ case 'aFSPrior_column': echo '
'.get_post_meta($post_id,'aFSPrior',true).'
'; break; case 'aFSldTyp_column': echo '
'.get_post_meta($post_id,'aFSldTyp',true).'
'; break; } } add_action('pre_get_posts','aFS_pre_get_posts',1); function aFS_pre_get_posts($query){ if($query->is_main_query() && ($orderby = $query->get('orderby'))){ switch($orderby){ case 'aFSPrior': $query->set('meta_key','aFSPrior'); $query->set('orderby','meta_value_num'); break; case 'aFSldTyp': $query->set('meta_key','aFSldTyp'); $query->set('orderby','meta_value'); break; } } } /* Q U I C K E D I T & B U L K E D I T =========================================== */ add_action('bulk_edit_custom_box','aFS_bulk_quick_edit_custom_box',10,2); add_action('quick_edit_custom_box','aFS_bulk_quick_edit_custom_box',10,2); function aFS_bulk_quick_edit_custom_box($column_name,$post_type){ switch($post_type){ case 'slides': switch($column_name){ case 'aFSPrior_column': ?>
post_type) && $post->post_type == 'revision') return $post_id; switch( $post->post_type ) { case 'slides': $custom_fields = array('aFSPrior','aFSldTyp'); foreach($custom_fields as $field){ if(array_key_exists($field,$_POST))update_post_meta($post_id,$field,$_POST[$field]); } break; } } add_action('wp_ajax_aFS_bulk_quick_save_edit','aFS_bulk_quick_save_edit'); function aFS_bulk_quick_save_edit(){ // we need the post IDs $post_ids =(isset($_POST['post_ids']) && !empty($_POST['post_ids']))? $_POST['post_ids'] : NULL; // if we have post IDs if(!empty($post_ids) && is_array($post_ids)){ // get the custom fields $custom_fields = array('aFSPrior','aFSldTyp'); foreach($custom_fields as $field){ // if it has a value,doesn't update if empty on bulk if(isset($_POST[ $field]) && !empty($_POST[ $field])){ // update for each post ID foreach($post_ids as $post_id){ update_post_meta($post_id,$field,$_POST[$field]); } } } } } /* M C E B U T T O N S ===================== */ # Register tinyMCE Plugin & Button add_action('init','aFSRegMCEPlugin'); function aFSRegMCEPlugin(){ add_filter('mce_external_plugins','aFSMCEPlugin'); add_filter('mce_buttons_4','aFSRegButton'); } # tinyMCE Plugin function aFSMCEPlugin($plugin_array){ global $post_type; if('slides' == $post_type){ $plugin_array['aFSMCE'] = plugins_url('js/addfunc-slides-mce.js',__FILE__); return $plugin_array; } else { return $plugin_array; } } # tinyMCE Buttons function aFSRegButton($buttons){ global $post_type; if('slides' == $post_type){ array_push($buttons,'aFSLeft'); array_push($buttons,'aFSRight'); array_push($buttons,'aFSUp'); array_push($buttons,'aFSDown'); array_push($buttons,'aFSClock'); array_push($buttons,'aFSCntrClock'); array_push($buttons,'aFSMor'); array_push($buttons,'aFSLes'); return $buttons; } else { return $buttons; } } function aFSEnqCSS() { global $post_type; if('slides' == $post_type){ wp_enqueue_style('aFScss', plugins_url('/css/mce-icons.css', __FILE__)); } } add_action('admin_enqueue_scripts', 'aFSEnqCSS'); /* H E L P T A B =============== */ add_action('load-post.php','aFSHelpTab'); function aFSHelpTab() { function aFSHTShortcodes(){ $sldsets = get_terms('slidesets'); if (!empty($sldsets) && !is_wp_error($sldsets)){ ob_start(); echo '

'.__( 'Here are the shortcodes to use for your current Slidesets:' ).'

'; foreach ($sldsets as $sldset){ echo '
'.$sldset->name.': [slides slideset='.$sldset->slug.']
'; } echo '
'; return ob_get_clean(); } else { ob_start(); echo '

'.__( '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):' ).'

'.__( '*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.' ).'

' )); }