'0', ), $atts ) ); //** //SANITIZE ALL SHORTCODE INPUTS //Check for valid ID $postid = intval($id); if ($postid==0 || !is_int($postid)){ //Return error return '

Invalid Parallax ID

'; } //** //SETUP WP QUERY TO RETREIVE POST //Set up the arguments for query $args = array( 'page_id' => $postid, 'post_type' => array( PARALLAX_POSTTYPE ) ); //Look up the header $post = new WP_Query( $args ); //** //RETRIEVE THE POST AND DISPLAY //Check post exist if ( $post->have_posts() ) { while ( $post->have_posts() ) { $post->the_post(); //** //CHECK AND SANITIZE POST INPUTS // check if the post has a Post Thumbnail assigned to it. if ( !has_post_thumbnail() ) { //Error because of no image wp_reset_postdata(); return '

No Feature Image Defined! Please specify your background image in the featured image meta box on the admin page. For more information please see the help menu from the parallax scroll admin pages.

'; } //Get thumbnail url $thumb_id = get_post_thumbnail_id(); $thumb_url_array = wp_get_attachment_image_src($thumb_id,'thumbnail-size', true); $thumb_url = $thumb_url_array[0]; //Get the height $pheight = absint(get_post_meta(get_the_id(), 'parallax_meta_height', true)); //Check the height if ($pheight==0 || $pheight $parallaxFWStyleClass, 'parallaxcontainerid' => $containerFWStyleClass )); } //Check if Scroll Is Enabled $parallaxScrollingClass=''; if ($bgScrollSpeed>0 && $bgScrollSpeed < 9 && $parallaxJS==false){ //include full width java script wp_enqueue_script( 'parallax-script-scroll' ); $parallaxScrollingClass='adamrob_parallax_scrolling '; //Send parameters to script wp_localize_script('parallax-script-scroll', 'parallax_script_scroll_options', array( 'parallaxcontainerid' => $parallaxScrollingClass )); } //Check if we should use parallax.js to achieve effect if ($parallaxJS==true){ //Attach script wp_enqueue_script( 'parallax-script' ); } //Build the style tag for the parallax container $parallaxStyle=''; if ($pheight!==PARALLAX_MINHEIGHT){ //Use user defined height $parallaxStyle='height:'.$pheight.'px;'; }elseif($pheight!==PARALLAX_MINHEIGHT && $theContent ==""){ //Define the minimum height if no post content. //If there is post content, use min height from css $parallaxStyle='height:'.PARALLAX_MINHEIGHT.'px;'; } //Enable parallax image? $ParallaxImgStyle=''; if (!$disableParImg || wp_is_mobile()===FALSE){ //Only show parallax if not on mobile. //or on a mobile and user wants it $ParallaxImgStyle='background-image: url('.$thumb_url.');'; } //build style tag for background size $ParallaxSizeStyle='background-size: cover;'; if (wp_is_mobile()==FALSE && $psize>0){ //if user not on mobile and wants to change the size $ParallaxSizeStyle='background-size: '.$psize.'px;'; }elseif(wp_is_mobile()&&isset($mobpsize)&&$mobpsize==0){ //User is on mobile and wants to auto size //$ParallaxSizeStyle='background-size: 100% 100%;'; $ParallaxSizeStyle='background-size: cover; background-attachment: scroll;'; }elseif(wp_is_mobile()&&isset($mobpsize)&&$mobpsize>0){ //User is on mobile and wants to use a different size $ParallaxSizeStyle='background-size: '.$mobpsize.'px;background-repeat: no-repeat; background-attachment: scroll;'; } //Give the entire plugin a container if we are full width if ($fullWidthEnable){ //Enables us to pad out when in full screen mode $output .= '
'; }; //Build the parallax container if ($parallaxJS==true){ //Use parallax.JS //Check if we are full width $parallaxJSpos = ""; if ($parallaxFWStyleClass==""){ $parallaxJSpos = " position: relative;"; } if ($bgScrollSpeed>=10) $bgScrollSpeed = 9; $output .= '
'; }else{ //use CSS Only Parallax if(wp_is_mobile()&&isset($mobpsize)){ //Display static image $output .= '
'; }else{ //display parallax image $output .= '
'; } } $output .= '
'; //Build the content if applicable if ($theContent==""){ //Build the title $output .= ''; $output .= '
'; $output .= '
' . get_the_title() . '
'; $output .= '
'; }else{ //Build the title $output = $output . '
'; $output = $output . '
' . get_the_title() . '
'; $output = $output . '
'; //Build the content $output = $output . '
'; $output = $output . $theContent; $output = $output . '
'; } //If we are full width close the container if ($fullWidthEnable){ $output .= '
'; } $output .= '
'; if ($parallaxJS==true){ $output .= '
'; }else{ $output .= ''; } } //Reset query data wp_reset_postdata(); } else { // none were found wp_reset_postdata(); return '

No Parallax Found! Check ID

'; } //Return the result return $output; } //Add the shortcode trigger add_shortcode( PARALLAX_SHORTCODE, 'register_sc_parallax_scroll' ); ?>