Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter saxbill

    (@saxbill)

    Hello,
    A friend has identified the issue…he says:

    The plugin is directly echoing text from the DLS_Sign_Up_Sheet::display_sheet() function which is used as a shortcode, instead of returning the shortcode text.

    Not sure what the fix for this is, but any help you can give would be appreciated.

    Bill

    Thread Starter saxbill

    (@saxbill)

    ESMI – Had no idea this wasn’t acceptable, and I didn’t even know what a pastebin was. Now that you’ve made that clear, feel free to delete my above posts as I’ve figured it out on my own and linked to them below.

    blogheader.php

    postheader.php

    header_alt_h.php

    header_logo.php

    header_masthead.php

    Thread Starter saxbill

    (@saxbill)

    header_masthead.php
    
    <div id="masthead-image-wrapper">
    
    	<?php
    
    	if ( ppImg::id( 'masthead_frame' )->exists && !ppUtil::renderingMobileSite() ) {
    		$frameImgTag    = new ppImgTag( ppImg::id( 'masthead_frame' )->url, array( 'id' => 'masthead-frame' ) );
    		$blogWidth      = ppOpt::id( 'blog_width', 'int' );
    		$framemaxWidth  = ppOpt::test( 'headerlayout', 'logomasthead_nav || mastheadlogo_nav' ) ? $blogWidth - ppImg::id( 'logo' )->width : $blogWidth;
    		$frameMaxHeight = ppHelper::logoInMasthead() ? ppImg::id( 'logo' )->height : 1000000;
    		$frameImgTag    = ppGdModify::constrainImgSize( $frameImgTag, $framemaxWidth, $frameMaxHeight );
    		echo $frameImgTag->markup();
    	}
    
    	?>
    
    	<div id="masthead_image" class="<?php echo $classes ?>">
    
    		<?php
    
    		if ( $href && !NrUtil::isIn( 'pp-slideshow', $classes ) ) {
    			echo NrHtml::a( $href, $img->markup() );
    		} else {
    			echo $img->markup();
    		}
    
    		?>
    
    	</div><!-- #masthead_image -->
    
    </div><!-- #masthead-image-wrapper -->
    Thread Starter saxbill

    (@saxbill)

    header_logo.php
    
    <div id="logo-wrap">
    	<div id="logo">
    
    		<a href="<?php echo $logo->linkurl ?>" title="<?php echo pp::site()->name ?>" rel="home" id="logo-img-a">
    			<img id="logo-img" src="<?php echo $logo->url ?>" <?php echo $logo->htmlAttr ?> alt="<?php echo pp::site()->name ?> logo" />
    		</a>
    
    		<<?php echo $h1or2 ?>>
    			<a href="<?php echo $logo->linkurl ?>" title="<?php echo pp::site()->name ?>" rel="home"><?php echo pp::site()->name ?></a>
    		</<?php echo $h1or2 ?>>
    
    		<p>
    			<?php echo pp::site()->tagline ?>
    		</p>
    
    	</div><!-- #logo -->
    
    	<?php
    
    	if ( ppOpt::test( 'headerlayout', 'pptclassic' ) ) {
    		echo ppBlogHeader::nav();
    	}
    
    	?>
    
    </div><!-- #logo-wrap -->
    Thread Starter saxbill

    (@saxbill)

    header_alt_h.php
    
    <<?php echo $hTag ?> id="alt-h1">
    	<a href="<?php echo pp::site()->url ?>" title="<?php echo esc_attr( pp::site()->name ) ?>" rel="home">
    		<?php echo pp::site()->name ?> &raquo; <?php echo pp::site()->tagline ?>
    	</a>
    </<?php echo $hTag ?>>
    Thread Starter saxbill

    (@saxbill)

    postheader.php
    
    <?php
    
    class ppPostHeader {
    
    	private $post;
    	private $dateBeforeTitle;
    	private $dateSameLineWithTitle;
    	private $dateInMeta;
    
    	public static function render( ppPost $post ) {
    		$postHeader = new ppPostHeader( $post );
    		echo $postHeader->completeMarkup();
    	}
    
    	public function completeMarkup() {
    		return
    			'<div class="article-header ' . ppOpt::id( 'postdate_display' ) . '" data-role="header">' .
    				$this->dateBeforeTitle .
    				$this->titleDiv() .
    				$this->entryMeta() .
    			'</div>';
    	}
    
    	protected function __construct( ppPost $post ) {
    		$this->post = $post;
    		$this->setupDateProperties();
    	}
    
    	protected function titleDiv() {
    		$linkedTitle = NrHtml::a(
    			$this->post->permalink(),
    			$this->post->title(),
    			'title=Permalink to ' . esc_attr( $this->post->title() ) . '&rel=bookmark'
    		);
    
    		$title = ( is_singular() || is_404() ) ? $this->post->title() : $linkedTitle;
    
    		if ( !ppQuery::instance()->isGalleryQuasiPage() ) {
    			if ( $this->editLinkBeforeTitle() ) {
    				$title = ppUtil::ob( 'edit_post_link', 'Edit' ) . $title;
    			} else {
    				$title .= ppUtil::ob( 'edit_post_link', 'Edit' );
    			}
    		}
    
    		return
    			'<div class="article-title-wrap">' .
    				$this->dateSameLineWithTitle .
    				NrHtml::h( $this->headerTagNum(), $title, 'class=article-title' ) .
    			'</div>';
    	}
    
    	protected function entryMeta() {
    		if ( is_page() || is_404() || ppUtil::isEmptySearch() ) {
    			return;
    		}
    
    		$metaElements  = '';
    		if ( !is_search() ) {
    			$metaElements .= $this->categoryList();
    			$metaElements .= $this->tagList();
    			$metaElements .= $this->commentCount();
    		}
    
    		if ( $this->dateInMeta || $metaElements ) {
    			return
    				'<div class="article-meta article-meta-top">' .
    				 	$this->dateInMeta . $metaElements .
    				'</div>';
    		}
    	}
    
    	protected function dateMarkup() {
    		return
    			'<span class="article-date article-meta-item">
    				<span>' .
    					$this->publishedDay() . ' ' . $this->publishedTime() .
    				'</span>
    			</span>';
    	}
    
    	protected function publishedDay() {
    		if ( ppOpt::test( 'postdate_display', 'boxy' ) ) {
    			$day   = $this->post->publishedDate( 'd' );
    			$month = $this->post->publishedDate( 'M' );
    			$year  = $this->post->publishedDate( 'Y' );
    			return
    				"<div class='boxy-date-wrap'>
    					<span class='boxy-month'>$month</span>
    					<span class='boxy-day'>$day</span>
    					<span class='boxy-year'>$year</span>
    				</div>";
    
    		} else if ( ppOpt::test( 'dateformat', 'custom' ) ) {
    			 return $this->post->publishedDate( ppOpt::id( 'dateformat_custom' ) );
    
    		} else {
    			return $this->post->publishedDate( ppOpt::id( 'dateformat' ) );
    		}
    	}
    
    	protected function publishedTime() {
    		if ( ppOpt::test( 'show_post_published_time', 'yes' ) && !ppOpt::test( 'postdate_display', 'boxy' ) ) {
    			return get_the_time();
    		}
    	}
    
    	protected function headerTagNum() {
    		if ( is_singular() ) {
    			return '1';
    		} elseif ( !is_archive() ) {
    			return '2';
    		} else {
    			return '3';
    		}
    	}
    
    	protected function categoryList() {
    		if ( ppOpt::test( 'categories_in_post_header', 'yes' ) ) {
    			return ppHtml::categoryList();
    		}
    	}
    
    	protected function tagList() {
    		if ( ppOpt::test( 'tags_in_post_header', 'yes' ) ) {
    			return ppHtml::tagList();
    		}
    	}
    
    	protected function commentCount() {
    		if ( ppOpt::test( 'comment_count_in_post_header', 'yes' ) && ppOpt::test( 'comments_enable', 'true' ) ) {
    			return '<span class="article-header-comment-count article-meta-item">' . ucfirst( ppCommentsRenderer::countString( $this->post->commentsCount() ) ) . '</span>';
    		}
    	}
    
    	protected function setupDateProperties() {
    		if ( is_page() || is_404() || ppUtil::isEmptySearch() ) {
    			return;
    		}
    
    		if ( ppOpt::test( 'postdate_display', 'boxy' ) ) {
    			$this->dateBeforeTitle = $this->dateMarkup();
    
    		} else if ( ppOpt::test( 'postdate_display', 'normal' ) )  {
    
    			switch ( ppOpt::id( 'postdate_placement' ) ) {
    
    				case 'above':
    					$this->dateBeforeTitle = $this->dateMarkup();
    					break;
    				case 'below':
    					$this->dateInMeta = $this->dateMarkup();
    					break;
    				case 'withtitle' :
    					$this->dateSameLineWithTitle = $this->dateMarkup();
    					break;
    				default:
    					new ppIssue( 'Unknown "postdate_placement"' );
    			}
    		}
    	}
    
    	protected function editLinkBeforeTitle() {
    		if ( !ppOpt::test( 'post_header_align', 'right' ) ) {
    			return false;
    
    		} else if ( ppOpt::test( 'postdate_display', 'boxy' ) ) {
    			return true;
    
    		} else if ( !ppOpt::test( 'postdate_placement', 'withtitle' ) ) {
    			return true;
    
    		} else {
    			return false;
    		}
    	}
    
    	public static function advancedDateCss( $selector = '.article-date span' ) {
    		if ( ppOpt::test( 'postdate_advanced_switch', 'off' ) || ppOpt::test( 'postdate_display', 'boxy' ) ) {
    			return;
    		}
    
    		$postdate_border_width = ppOpt::id( 'postdate_border_width' );
    		$postdate_border_top   = ppOpt::test( 'postdate_border_top', 'on' )    ? $postdate_border_width : '0';
    		$postdate_border_btm   = ppOpt::test( 'postdate_border_bottom', 'on' ) ? $postdate_border_width : '0';
    		$postdate_border_left  = ppOpt::test( 'postdate_border_left', 'on' )   ? $postdate_border_width : '0';
    		$postdate_border_right = ppOpt::test( 'postdate_border_right', 'on' )  ? $postdate_border_width : '0';
    
    		return <<<CSS
    		$selector {
    			margin-right:0;
    			border-top-width:{$postdate_border_top}px;
    			border-bottom-width:{$postdate_border_btm}px;
    			border-left-width:{$postdate_border_left}px;
    			border-right-width:{$postdate_border_right}px;
    			border-style:[~postdate_border_style];
    			border-color:[~postdate_border_color];
    			background-color:[~postdate_bg_color];
    			padding:[~postdate_tb_padding]px [~postdate_lr_padding]px;
    		}
    CSS;
    	}
    }
    Thread Starter saxbill

    (@saxbill)

    Thanks for the fast reply! There is no file only named header.php but there are 4 that include header in the name. I’ll post each below:

    blogheader.php
    
    <?php
    
    class ppBlogHeader {
    
    	const FOR_MOBILE = true;
    	protected static $layout;
    	protected static $hTag;
    	protected static $mastheadImgNum;
    	protected static $mastheadHasOverrideImg;
    	protected static $elements = array();
    	protected static $usingSubnav;
    	protected static $subnavPlacement;
    
    	public static function markup() {
    		do_action( 'pp_pre_header' );
    
    		$markup = '';
    		self::$hTag = is_singular() ? 'h2' : 'h1';
    
    		if ( ppHelper::logoInMasthead() ) {
    			$markup .= self::maybeAddSubNav( 1 );
    			$markup .= NrHtml::div( self::logo() . self::masthead(), 'id=masthead&class=sc' );
    			$markup .= self::maybeAddSubNav( 2 );
    			$markup .= self::nav();
    			$markup .= self::maybeAddSubNav( 3 );
    
    		} else {
    
    			$orderedElements = self::orderedElements();
    
    			if ( !NrUtil::isIn( 'logo', self::$layout ) ) {
    				$markup .= ppUtil::renderView( 'header_alt_h', array( 'hTag' => self::$hTag ), ppUtil::RETURN_VIEW );
    			}
    
    			$markup .= self::maybeAddSubNav( $subNavIndex = 1 );
    			foreach ( $orderedElements as $element ) {
    				if ( 'masthead' == $element && !ppHelper::skipMasthead() ) {
    					$markup .= NrHtml::div( self::masthead(), 'id=masthead&class=sc' );
    				} else {
    					$markup .= self::$element();
    				}
    				$subNavIndex++;
    				$markup .= self::maybeAddSubNav( $subNavIndex );
    			}
    			$markup .= self::maybeAddSubNav( $subNavIndex + 1 );
    		}
    
    		return apply_filters( 'pp_blog_header_markup', NrHtml::tag( 'header', $markup , 'class=sc' ) );
    	}
    
    	public static function mastheadDims( $mobileWidth = null, $considerRequestingBrowser = true ) {
    		$blogWidth = ppOpt::id( 'blog_width', 'int' );
    
    		if ( is_int( $mobileWidth ) ) {
    			$widthConstraint = $mobileWidth;
    			$mb_ = ppOpt::test( 'mobile_masthead_use_desktop_settings', 'false' ) ? 'mobile_' : '';
    		} else {
    			$widthConstraint = $blogWidth;
    			$mb_  = '';
    		}
    
    		$img = self::mastheadImgTag( $mb_ );
    
    		$frameImg          = ppImg::id( 'masthead_frame' );
    		$frameOffsetLeft   = ppOpt::id( 'masthead_frame_padding_left',   'int' );
    		$frameOffsetRight  = ppOpt::id( 'masthead_frame_padding_right',  'int' );
    		$frameOffsetTop    = ppOpt::id( 'masthead_frame_padding_top',    'int' );
    		$frameOffsetBottom = ppOpt::id( 'masthead_frame_padding_bottom', 'int' );
    
    		if ( is_int( $mobileWidth ) ) {
    			$width  = $widthConstraint;
    			$height = intval( NrUtil::constrainRectSide( $width, $img->width(), $img->height() ) );
    
    		} else if ( !ppHelper::logoInMasthead() ) {
    
    			if ( !$frameImg->exists ) {
    				$width  = $widthConstraint;
    				$height = intval( NrUtil::constrainRectSide( $width, $img->width(), $img->height() ) );
    
    			} else {
    				$width = $blogWidth - $frameOffsetLeft - $frameOffsetRight;
    				if ( $frameImg->width > $widthConstraint ) {
    					$frameHeight = intval( NrUtil::constrainRectSide( $widthConstraint, $frameImg->width, $frameImg->height ) );
    				} else {
    					$frameHeight = $frameImg->height;
    				}
    				$height = $frameHeight - $frameOffsetTop - $frameOffsetBottom;
    			}
    
    		} else if ( ppOpt::test( 'headerlayout', 'logomasthead_nav || mastheadlogo_nav' ) ) {
    			$logo   = ppImg::id( 'logo' );
    			$width  = $widthConstraint - $logo->width;
    			$height = $logo->height;
    			if ( $frameImg->exists ) {
    				$width  = $width  - $frameOffsetLeft - $frameOffsetRight;
    				$height = $height - $frameOffsetTop  - $frameOffsetBottom;
    			}
    
    		} else if ( ppOpt::test( 'headerlayout', 'mastlogohead_nav' ) ) {
    			$width  = $widthConstraint;
    			$height = ppImg::id( 'logo' )->height;
    			if ( $frameImg->exists ) {
    				$width  = $width  - $frameOffsetLeft - $frameOffsetRight;
    				$height = $height - $frameOffsetTop  - $frameOffsetBottom;
    			}
    
    		} else {
    			new ppIssue( 'Unexpected condition in ppBlogHeader::mastheadDims()' );
    		}
    
    		return (object) compact( 'width', 'height' );
    	}
    
    	public static function menuDim( $key, $dim ) {
    		$key = NrUtil::isIn( 'secondary_', $key ) ? 'secondary_nav_menu_' : 'primary_nav_menu_';
    		$padding = intval( ppOpt::orVal( $key . 'link_tb_padding', round( ppOpt::id( $key . 'link_font_size' ) * 0.715, 0 ) ) );
    		$fontsize = ppOpt::id( $key . 'link_font_size', 'int' );
    		if ( $dim == 'height' ) {
    			return intval( $fontsize + ( $padding * 2 ) );
    		} else if ( $dim == 'fontsize' ) {
    			return $fontsize;
    		} else if ( $dim == 'padding' ) {
    			return $padding;
    		} else {
    			new ppIssue( 'Invalid $dim param passed to ppBlogHeader::menuDim()' );
    		}
    	}
    
    	protected static function maybeAddSubNav( $index ) {
    		if ( ppOpt::test( 'secondary_nav_menu_onoff', 'off' ) ) {
    			return '';
    		}
    
    		if ( null === self::$usingSubnav ) {
    			self::$usingSubnav = ppMenuUtil::menuHasItems( 'secondary_nav_menu' );
    		}
    
    		if ( null == self::$subnavPlacement ) {
    			self::$subnavPlacement = ppOpt::id( 'secondary_nav_menu_placement' );
    		}
    
    		if ( self::$usingSubnav && self::$subnavPlacement == strval( $index ) ) {
    			$menuItems = $menuItems = ppMenuUtil::menuItems( 'secondary_nav_menu' );
    			$menuItems = self::reorderForSplit( $menuItems, 'secondary' );
    			$markup = '';
    			$firstItemID = reset( array_keys( $menuItems ) );
    			$lastItemID  = end( array_keys( $menuItems ) );
    			foreach ( $menuItems as $itemID => $children ) {
    				$item = ppMenuUtil::menuItem( $itemID, $children );
    				if ( $itemID == $firstItemID ) {
    					$item->addClass( 'first-menu-item' );
    				}
    				if ( $itemID == $lastItemID ) {
    					$item->addClass( 'last-menu-item' );
    				}
    				$markup .= $item->markup();
    			}
    			$markup  = NrHtml::div( NrHtml::ul( $markup, 'class=secondary-nav-menu suckerfish sc' ), 'id=secondary-nav&class=sc' );
    			$markup .= NrHtml::div( '', 'id=secondary-nav-ajax-receptacle&class=nav-ajax-receptacle sc content-bg' );
    			return $markup;
    		} else {
    			return '';
    		}
    	}
    
    	private static function logo() {
    		return ppUtil::renderView( 'header_logo', array( 'logo' => ppImg::id( 'logo' ), 'h1or2' => self::$hTag ), ppUtil::RETURN_VIEW );
    	}
    
    	private static function reorderForSplit( $menuItems, $which ) {
    		if ( !ppOpt::test( $which . '_nav_menu_align', 'split' ) || !ppOpt::test( $which . '_nav_menu_split_after_id' ) ) {
    			return $menuItems;
    		}
    
    		if ( $which == 'primary' && ppOpt::test( 'headerlayout', 'pptclassic' ) ) {
    			return $menuItems;
    		}
    
    		$splitIndex = null;
    		foreach ( array_keys( $menuItems ) as $index => $ID ) {
    			if ( $ID == ppOpt::id( $which . '_nav_menu_split_after_id' ) ) {
    				$splitIndex = $index;
    			}
    		}
    		if ( $splitIndex !== null ) {
    			$leftSide  = array_slice( $menuItems, 0, $splitIndex + 1 );
    			$rightSide = array_reverse( array_slice( $menuItems, $splitIndex + 1, count( $menuItems ) - ( $splitIndex + 1 ) ) );
    			$menuItems = array_merge( $leftSide, $rightSide );
    		}
    
    		return $menuItems;
    	}
    
    	public static function nav() {
    		$markup = '';
    		if ( ppOpt::test( 'primary_nav_menu_onoff', 'off' ) ) {
    			return $markup;
    		}
    
    		$menuItems = ppMenuUtil::menuItems( 'primary_nav_menu' );
    
    		if ( !$menuItems ) {
    			return $markup;
    		}
    
    		$menuItems = self::reorderForSplit( $menuItems, 'primary' );
    
    		$lastItemID  = end( array_keys( $menuItems ) );
    		$firstItemID = reset( array_keys( $menuItems ) );
    		foreach ( (array) $menuItems as $itemID => $children ) {
    			$item = ppMenuUtil::menuItem( $itemID, $children );
    			if ( $itemID == $firstItemID ) {
    				$item->addClass( 'first-menu-item' );
    			}
    			if ( $itemID == $lastItemID ) {
    				$item->addClass( 'last-menu-item' );
    			}
    			$markup .= $item->markup();
    		}
    		$markup  = NrHtml::tag( 'nav', NrHtml::ul( $markup, 'class=primary-nav-menu suckerfish sc' ), 'id=primary-nav&class=sc' );
    		$markup .= NrHtml::div( '', 'id=primary-nav-ajax-receptacle&class=nav-ajax-receptacle sc content-bg' );
    		return $markup;
    	}
    
    	private static function masthead() {
    		if ( ppHelper::skipMasthead() ) {
    			return '';
    		}
    
    		$max = self::mastheadDims();
    
    		$imgTag = self::mastheadImgTag();
    		if ( !ppOpt::test( 'headerlayout', 'logomasthead_nav || mastheadlogo_nav' ) ) {
    			$imgTag = ppGdModify::constrainImgSize( $imgTag, $max->width, $max->height );
    		}
    
    		$classes = 'masthead-image';
    
    		if ( self::mastheadSlideshowOnThisPage() ) {
    			$classes .= ' pp-slideshow pp-slideshow-not-loaded autostart';
    		}
    
    		if ( self::customFlashOnThisPage() ) {
    			$classes .= ' custom-flash';
    		}
    
    		if ( self::$mastheadImgNum && ppOpt::test( 'masthead_image' . self::$mastheadImgNum . '_linkurl' ) ) {
    			$href = ppUtil::userUrl( 'masthead_image' . self::$mastheadImgNum . '_linkurl' );
    		} else {
    			$href = null;
    		}
    
    		return ppUtil::renderView( 'header_masthead', array( 'img' => $imgTag, 'classes' => $classes, 'href' => $href ), ppUtil::RETURN_VIEW );
    	}
    
    	protected function customFlashOnThisPage() {
    		if ( !ppOpt::test( 'masthead_display', 'custom' ) ) {
    			return false;
    		}
    		if ( ppOpt::test( 'masthead_modify', 'false' ) ) {
    			return true;
    		}
    		if ( ppOpt::test( 'masthead_on_' . ppUtil::pageType( ppUtil::NO_ARCHIVE_TYPE ), 'modified' ) ) {
    			return false;
    		}
    		return true;
    	}
    
    	public function mastheadSlideshowOnThisPage( $prefix_ = '' ) {
    		if ( !ppOpt::test( "{$prefix_}masthead_display", 'slideshow' ) ) {
    			return false;
    
    		} else if ( self::$mastheadHasOverrideImg ) {
    			return false;
    
    		} else if ( ppOpt::test( "{$prefix_}masthead_modify", 'false' ) ) {
    			return self::hasAtLeastTwoMastheadImgs( $prefix_ );
    
    		} else if ( ppHelper::logoInMasthead() && ppOpt::test( "{$prefix_}masthead_on_" . ppUtil::pageType( ppUtil::NO_ARCHIVE_TYPE ), 'modified' ) ) {
    			return false;
    
    		} else if ( ppOpt::test( "{$prefix_}modified_masthead_display", 'image' ) && ppOpt::test( "{$prefix_}masthead_on_" . ppUtil::pageType( ppUtil::NO_ARCHIVE_TYPE ), 'modified' ) ) {
    			return false;
    
    		} else {
    			return self::hasAtLeastTwoMastheadImgs( $prefix_ );
    		}
    	}
    
    	protected function hasAtLeastTwoMastheadImgs( $prefix_ ) {
    		$foundImgs = 0;
    		for ( $i = 1; $i <= pp::num()->maxMastheadImages; $i++ ) {
    			if ( ppImg::id( $prefix_ . 'masthead_image' . $i )->exists ) {
    				$foundImgs++;
    			}
    			if ( $foundImgs > 1 ) {
    				return true;
    			}
    		}
    		return false;
    	}
    
    	protected function mastheadImgTag( $mb_ = '' ) {
    		if ( $overrideImgUrl = self::mastheadOverrideImg( $mb_ ) ) {
    			$imgTag = new ppImgTag( $overrideImgUrl );
    			$imgData = NrUtil::imgData( ppUtil::pathFromUrl( $overrideImgUrl ) );
    			if ( $imgData ) {
    				$imgTag->width( $imgData->width );
    				$imgTag->height( $imgData->height );
    			}
    		} else {
    			self::$mastheadImgNum = self::mastheadImgNum( $mb_ );
    			$img = ppImg::id( $mb_ . 'masthead_image' . self::$mastheadImgNum );
    			$imgTag = new ppImgTag( $img->url );
    			$imgTag->width( $img->width );
    			$imgTag->height( $img->height );
    		}
    		$imgTag->id( 'masthead-img' );
    		$imgTag->alt( 'Masthead header' );
    		return $imgTag;
    	}
    
    	public static function mastheadImgNum( $mb_ ) {
    		$mastheadDisplay = ppOpt::id( $mb_ . 'masthead_display' );
    
    		if ( $mastheadDisplay == 'static' ) {
    			$imgNum = '1';
    
    		} else if ( $mastheadDisplay == 'random' ) {
    			$imgNum = self::randomMastheadImgNum();
    
    		} else if ( $mastheadDisplay == 'slideshow' && ppOpt::test( 'masthead_slideshow_image_order', 'random' ) ) {
    			$imgNum = self::randomMastheadImgNum();
    
    		} else if ( ppOpt::test( $mb_ . 'masthead_modify', 'false' ) ) {
    			$imgNum = '1';
    
    		} else if ( ppOpt::test( $mb_ . 'modified_masthead_image' ) &&
    				    ppOpt::test( $mb_ . 'masthead_on_' . ppUtil::pageType( ppUtil::NO_ARCHIVE_TYPE ), 'modified' ) ) {
    			$imgNum = ppOpt::id( $mb_ . 'modified_masthead_image' );
    
    		} else {
    			$imgNum = '1';
    		}
    
    		if ( ppImg::id( $mb_ . "masthead_image{$imgNum}" )->exists ) {
    			return $imgNum;
    		} else {
    			return '1';
    		}
    	}
    
    	private static function randomMastheadImgNum() {
    		$nums = array();
    		for ( $i = 1; $i <= pp::num()->maxMastheadImages; $i++ ) {
    			if ( ppImg::id( "masthead_image{$i}" )->exists ) {
    				$nums[] = strval( $i );
    			}
    		}
    		if ( empty( $nums ) ) {
    			new ppIssue( 'No masthead imgs found in ppBlogHeader::randomMastheadImgNum()' );
    			return '1';
    		}
    
    		shuffle( $nums );
    		return array_shift( $nums );
    	}
    
    	private static function mastheadOverrideImg() {
    		if ( pp::site()->hasStaticFrontPage && ppQuery::instance()->isBlogPostsPage() ) {
    			$articleID = get_option( 'page_for_posts' );
    		} else if ( is_singular() && ppPost::fromGlobal() ) {
    			$articleID = ppPost::fromGlobal()->id();
    		} else {
    			return false;
    		}
    
    		if ( !$customMeta = get_post_meta( $articleID, 'custom_masthead_image', AS_STRING ) ) {
    			return false;
    		}
    
    		if ( is_numeric( $customMeta ) && ppImg::id( "masthead_image$customMeta" )->exists ) {
    			self::$mastheadHasOverrideImg = true;
    			return ppImg::id( "masthead_image$customMeta" )->url;
    
    		} else if ( NrUtil::isWebSafeImg( $customMeta ) ) {
    			$customImgName = basename( $customMeta );
    			$customImgPath = pp::fileInfo()->imagesFolderPath . '/' . $customImgName;
    			if ( file_exists( $customImgPath ) ) {
    				self::$mastheadHasOverrideImg = true;
    				return ppUtil::urlFromPath( $customImgPath );
    			}
    		}
    
    		return false;
    	}
    
    	private static function orderedElements() {
    		self::$layout = ppOpt::id( 'headerlayout' );
    
    		if ( self::$layout == 'pptclassic' ) {
    			return array( 'logo', 'masthead' );
    
    		} else {
    			return explode( '_', str_replace( array( 'left', 'right', 'center' ), '', self::$layout ) );
    		}
    	}
    
    	/* TODO: move this out of this class eventually */
    	public static function mastheadOptions( $context ) {
    		if ( $context == 'desktop' ) {
    			$prefix_ = '';
    			$Masthead = 'Masthead';
    		} else {
    			$prefix_ = 'mobile_';
    			$Masthead = 'Mobile masthead';
    		}
    
    		// DISPLAY options
    		ppStartMultiple( "$Masthead display" );
    		if ( $context == 'desktop' && ppHelper::logoInMasthead() && !ppOpt::test( "{$prefix_}masthead_display", 'off' ) ) {
    			$offOption = array();
    		} else {
    			$offOption = array( 'off' => 'do not display masthead' );
    		}
    		ppO( "{$prefix_}masthead_display", ppUtil::radioParams( array_merge( $offOption, array(
    			'static'    => 'single static image',
    			'random'    => 'random static image',
    			'slideshow' => 'slideshow of images',
    			'custom'    => 'custom uploaded flash .swf file',
    		) ) ) );
    
    		ppO( "{$prefix_}masthead_modify", ppUtil::radioParams( array(
    			'false' => 'same masthead on all page types',
    			'true'  => 'remove or change on some page types',
    		) ), 'optionally override the masthead display for select page types' );
    
    		if ( pp::site()->hasStaticFrontPage ) {
    			$home = 'posts page';
    			$static = array( "{$prefix_}masthead_on_front_page" => 'static front page' );
    		} else {
    			$home = 'home page';
    			$static = array();
    		}
    		ppO( "{$prefix_}modify_masthead_on", ppUtil::checkboxParams( 'modified', array_merge( $static, array(
    			$prefix_ . 'masthead_on_home'    => $home,
    			$prefix_ . 'masthead_on_single'  => 'individual post pages',
    			$prefix_ . 'masthead_on_page'    => 'static WordPress "Pages"',
    			$prefix_ . 'masthead_on_archive' => 'archive, category, author, and search',
    		) ) ), 'on selected (checked) page types, masthead will be removed or changed' );
    
    		ppO( "{$prefix_}modified_masthead_display", ppUtil::radioParams( array(
    			'none'  => 'remove masthead',
    			'image' => 'show a single static masthead image',
    		) ), 'how to modify masthead on selected pages' );
    
    		$imgOptions = array();
    		for ( $i = 1; $i <= pp::num()->maxMastheadImages; $i++ ) {
    			if ( !ppImg::id( "{$prefix_}masthead_image" . $i )->exists ) continue;
    			$imgOptions[$i] = 'Masthead image #' . $i;
    		}
    		ppO( "{$prefix_}modified_masthead_image", ppUtil::selectParams( $imgOptions ), 'choose one of your uploaded masthead images to display on selected page-types' );
    
    		ppStopMultiple();
    
    		// SLIDESHOW options
    		ppStartMultiple( "$Masthead slideshow options" );
    		ppO( "{$prefix_}masthead_slideshow_hold_time", 'slider|1|30| seconds|0.5', 'hold time (in seconds) each slideshow image is shown' );
    		ppO( "{$prefix_}masthead_slideshow_transition_time", 'slider|0|6| seconds|0.2', 'time of transition effect between slideshow images' );
    		ppO( "{$prefix_}masthead_slideshow_image_order", 'radio|random|play images in random order|sequential|play images in sequential order' );
    		ppO( "{$prefix_}masthead_slideshow_loop_images", 'radio|true|loop images|false|stop on last image' );
    		ppO( "{$prefix_}masthead_slideshow_transition_type", ppUtil::radioParams( array(
    			'crossfade'   => 'cross-fade',
    			'fade'        => 'fade to bg color then to image',
    			'slide'       => 'hold then slide horizontally',
    			'topslide'    => 'hold then slide vertically',
    			'steadyslide' => 'steady horizontal slide',
    		) ), 'image transition effect' );
    		ppO( "{$prefix_}masthead_slideshow_bg_color", 'color|optional', 'background color of masthead slideshow' );
    		ppStopMultiple();
    	}
    
    	/* TODO: move this out of this class eventually */
    	public static function mastheadOptionJs() {
    		echo <<<HTML
    		<script type="text/javascript" charset="utf-8">
    			jQuery(document).ready(function($){
    				if ( /area=header/.test( window.location.href ) ) {
    					var prefix = '';
    				} else {
    					var prefix = 'mobile_';
    				}
    				function ppProcessMastheadDisplayChoice( choice ) {
    					$('#subgroup-masthead').removeClass('static random slideshow custom off').addClass(choice);
    
    					// image titles and comments
    					$('span.masthead-conditional').hide();
    					$('span.mc-'+choice).show();
    
    					// add image and custom swf upload show/hide
    					if ( choice == 'static' ) {
    						$('#add-masthead-upload').addClass('hidden').hide();
    						$('#subgroup-masthead .upload-box').not(':first').not('#upload-box-masthead_image1').hide();
    						$('#subgroup-masthead .upload-box:first').show();
    						$('#upload-box-'+prefix+'masthead_custom_flash').addClass('hidden').hide();
    					} else if ( choice == 'random' ) {
    						$('#subgroup-masthead .upload-box').not('.empty').show();
    						$('#subgroup-masthead .upload-box.empty:first').show();
    						$('#upload-box-'+prefix+'masthead_custom_flash').addClass('hidden').hide();
    					} else if ( choice == 'slideshow' ) {
    						$('#subgroup-masthead .upload-box').not('.empty').show();
    						$('#subgroup-masthead .upload-box.empty:first').show();
    						$('#upload-box-'+prefix+'masthead_custom_flash').addClass('hidden').hide();
    					} else if ( choice == 'custom' ) {
    						$('#subgroup-masthead .upload-box').not(':first').hide();
    						$('#upload-box-'+prefix+'masthead_custom_flash').removeClass('hidden').show();
    					} else if ( choice == 'off' ) {
    						$('#subgroup-masthead .upload-box').hide();
    					}
    				}
    				ppProcessMastheadDisplayChoice( $('#'+prefix+'masthead_display-individual-option input[type=radio]:checked').val() );
    				$('#'+prefix+'masthead_display-individual-option input[type=radio]').click(function(){
    					ppProcessMastheadDisplayChoice( $(this).val() );
    				});
    
    				// classes for masthead modification, used for show/hide ux of complex masthead modified options
    				var masthead_modify = $('#'+prefix+'masthead_modify-individual-option input[type=radio]:checked').val();
    				$('#'+prefix+'masthead_display-option-section').addClass('masthead-modify-'+masthead_modify);
    				$('#'+prefix+'masthead_modify-individual-option input[type=radio]').click(function(){
    					$('#'+prefix+'masthead_display-option-section')
    						.removeClass('masthead-modify-true masthead-modify-false')
    						.addClass( 'masthead-modify-'+$(this).val() );
    				});
    				var modify_display = $('#'+prefix+'modified_masthead_display-individual-option input[type=radio]:checked').val();
    				$('#'+prefix+'masthead_display-option-section table').addClass('modify-display-'+modify_display);
    				$('#'+prefix+'modified_masthead_display-individual-option input[type=radio]').click(function(){
    					$('#'+prefix+'masthead_display-option-section table')
    						.removeClass('modify-display-none modify-display-image')
    						.addClass( 'modify-display-'+$(this).val() );
    				});
    			});
    		</script>
    HTML;
    	}
    
    	public static function flushCache() {
    		self::$usingSubnav = null;
    		self::$subnavPlacement = null;
    	}
    }
Viewing 7 replies - 1 through 7 (of 7 total)