_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 Slide'),
'add_new_item' => __('Add New Slide'),
'edit_item' => __('Edit Slide'),
'new_item' => __('New Slide'),
'view_item' => __('View Slide'),
'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' => '',
'order' => 'ASC',
'orderby' => '',
'meta_key' => '',
),$atts,'slides');
extract($aFSMrgd);
$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';
}
$args = array(
'slidesets' => $slideset,
'class' => $class,
'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 */ ?>
">
">
- 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); ?>
>
Edit';} ?>
">
- 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);
$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"; }
$aFSArgs = array(
'slidesets' => $slideset,
'class' => $class,
'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 */
$aFSPosts = aFget_posts($aFSArgs); ?>
">
">
- 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); ?>
>
Edit';} ?>
">
- 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');
$orderGfid = $this->get_field_id('order');
$orderbyGfid = $this->get_field_id('orderby');
?>
get_field_name('generalOpts'); ?>" id="" value="1" />