true, 'query_var' => 'anything_slides', 'supports' => array( 'title', 'editor', 'custom-fields' ), 'labels' => array( 'name' => 'Slides', 'singular_name' => 'Slide', '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' ) ); register_post_type( 'anything_slides', $slide_args ); } // register custom taxonomy for slide categorization add_action( 'init', 'jtd_anythingslider_register_tax' ); function jtd_anythingslider_register_tax() { $tax_args = array( 'hierarchical' => true, 'query_var' => 'slide_cat', 'labels' => array( 'name' => 'Slide Categories', 'edit_item' => 'Edit Category', 'add_new_item' => 'Add New Slide Category', 'all_items' => 'All Slide Categories' ) ); register_taxonomy( 'slide_cat', array( 'anything_slides' ), $tax_args ); } // register shortcode for retrieving slides add_action( 'init', 'jtd_anythingslider_register_shortcodes' ); function jtd_anythingslider_register_shortcodes() { add_shortcode( 'anything_slides', 'jtd_anything_slides_shortcode' ); } function jtd_anything_slides_shortcode( $attr ) { // setup slide query $loop = new WP_Query( array( 'post_type' => 'anything_slides', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, 'slide_cat' => $attr['cat'] ) ); $options = get_option( 'jtd_anything_slides_options' ); $height = ( isset( $attr['height'] ) ) ? $attr['height'] : ( ( $options['height'] ) ? $options['height'] : 300 ); $width = ( isset( $attr['width'] ) ) ? $attr['width'] : ( ( $options['width'] ) ? $options['width'] : 570 ); $delay = ( isset( $attr['delay'] ) ) ? $attr['delay'] : ( ( $options['delay'] ) ? $options['delay'] : 5000 ); $resume = ( isset( $attr['resume'] ) ) ? $attr['resume'] : ( ( $options['resume'] ) ? $options['resume'] : 9000 ); $animation = ( isset( $attr['animation'] ) ) ? $attr['animation'] : ( ( $options['animation'] ) ? $options['animation'] : 800 ); $arrows = ( isset( $options['arrows'] ) ) ? $options['arrows'] : 'true'; $toggleArrows = ( isset( $options['toggleArrows'] ) ) ? $options['toggleArrows'] : 'false'; $navigation = ( isset( $options['navigation'] ) ) ? $options['navigation'] : 'true'; $theme = ( isset( $options['theme'] ) ) ? $options['theme'] : 'default'; $toggleArrows = ( $toggleArrows == 1 ) ? 'true' : 'false'; $arrows = ( $arrows == 1 ) ? 'true' : 'false'; $navigation = ( $navigation == 1 ) ? 'true' : 'false'; // do we have results if ( $loop->have_posts() ) { $rand = rand(5, 500); $output = "
Enter the desired settings for your slider';
}
// Display and fill the form field
function jtd_anything_slides_width_callback() {
$options = get_option( 'jtd_anything_slides_options' );
$width = $options['width'];
echo "";
echo "Override the default CSS width";
}
function jtd_anything_slides_height_callback() {
$options = get_option( 'jtd_anything_slides_options' );
$height = $options['height'];
echo "";
echo "Override the default CSS height";
}
function jtd_anything_slides_delay_callback() {
$options = get_option( 'jtd_anything_slides_options' );
$delay = $options['delay'];
echo "";
echo "How long between slideshow transitions in AutoPlay mode (in milliseconds)";
}
function jtd_anything_slides_resume_callback() {
$options = get_option( 'jtd_anything_slides_options' );
$resume = $options['resume'];
echo "";
echo "Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds)";
}
function jtd_anything_slides_animation_callback() {
$options = get_option( 'jtd_anything_slides_options' );
$animation = $options['animation'];
echo "";
echo "How long the slideshow transition takes (in milliseconds)";
}
function jtd_anything_slides_theme_callback() {
$options = get_option( 'jtd_anything_slides_options' );
$theme = $options['theme'];
echo "";
echo "Select a theme, or leave blank for default";
}
function jtd_anything_slides_navigation_callback() {
$options = get_option( 'jtd_anything_slides_options' );
$navigation = $options['navigation'];
echo "
";
echo "";
echo "If true, builds a list of anchor links to link to each panel";
}
function jtd_anything_slides_arrows_callback() {
$options = get_option( 'jtd_anything_slides_options' );
$arrows = $options['arrows'];
echo "
";
echo "";
echo "If true, builds the forwards and backwards buttons";
}
function jtd_anything_slides_toggleArrows_callback() {
$options = get_option( 'jtd_anything_slides_options' );
$toggleArrows = $options['toggleArrows'];
echo "
";
echo "";
echo "if true, side navigation arrows will slide out on hovering & hide @ other times";
}
// Validate user input (we want numbers only)
function jtd_anything_slides_validate_options($input) {
$themes = array( 'construction', 'cs-portfolio', 'metallic', 'minimalist-round', 'minimalist-square' );
$valid = array();
$valid['width'] = preg_replace( '/[^0-9]/', '', $input['width'] );
$valid['height'] = preg_replace( '/[^0-9]/', '', $input['height'] );
$valid['delay'] = preg_replace( '/[^0-9]/', '', $input['delay'] );
$valid['resume'] = preg_replace( '/[^0-9]/', '', $input['resume'] );
$valid['animation'] = preg_replace( '/[^0-9]/', '', $input['animation'] );
$valid['theme'] = ( in_array( mysql_real_escape_string($input['theme']), $themes ) ) ? $input['theme'] : 'default';
$valid['navigation'] = preg_replace( '/[^0-1]/', '', $input['navigation'] );
$valid['arrows'] = preg_replace( '/[^0-1]/', '', $input['arrows'] );
$valid['toggleArrows'] = preg_replace( '/[^0-1]/', '', $input['toggleArrows'] );
if( $valid['width'] != $input['width'] ) {
add_settings_error(
'jtd_anything_slides-width',
'jtd_anything_slides_texterror',
'Incorrect value entered!',
'error'
);
}
if( $valid['height'] != $input['height'] ) {
add_settings_error(
'jtd_anything_slides-height',
'jtd_anything_slides_texterror',
'Incorrect value entered!',
'error'
);
}
if( $valid['delay'] != $input['delay'] ) {
add_settings_error(
'jtd_anything_slides-delay',
'jtd_anything_slides_texterror',
'Incorrect value entered!',
'error'
);
}
if( $valid['resume'] != $input['resume'] ) {
add_settings_error(
'jtd_anything_slides-resume',
'jtd_anything_slides_texterror',
'Incorrect value entered!',
'error'
);
}
if( $valid['animation'] != $input['animation'] ) {
add_settings_error(
'jtd_anything_slides-animation',
'jtd_anything_slides_texterror',
'Incorrect value entered!',
'error'
);
}
return $valid;
}