Procházet zdrojové kódy

Merge pull request #183 from Automattic/fixes-152-scratchpad-password-protected

Scratchpad: Update post formats to check for password-protected posts
Laurel před 7 roky
rodič
revize
ef3eba734f

+ 43 - 2
scratchpad/inc/wpcom-colors.php

@@ -16,7 +16,27 @@ add_color_rule( 'bg', '#bdcbcc', array(
 		.post-navigation-container a:hover,
 		.post-navigation-container a:hover,
 		.page-header p,
 		.page-header p,
 		.error404 .page-content > p,
 		.error404 .page-content > p,
-		.search-no-results .page-content > p', 'color', 'bg', 5 ),
+		.search-no-results .page-content > p,
+		body:not(.single) .format-audio.post-password-required,
+		body:not(.single) .format-audio .post-password-form label,
+		body:not(.single) .format-gallery.post-password-required,
+		body:not(.single) .format-gallery .post-password-form label,
+		body:not(.single) .format-image.post-password-required,
+		body:not(.single) .format-image .post-password-form label,
+		body:not(.single) .format-video.post-password-required,
+		body:not(.single) .format-video .post-password-form label,
+		body:not(.single) .format-audio .post-password-form input[type="submit"],
+		body:not(.single) .format-gallery .post-password-form input[type="submit"],
+		body:not(.single) .format-image .post-password-form input[type="submit"],
+		body:not(.single) .format-video .post-password-form input[type="submit"],
+		body:not(.single) .format-audio .post-password-form input[type="submit"]:hover,
+		body:not(.single) .format-audio .post-password-form input[type="submit"]:focus,
+		body:not(.single) .format-gallery .post-password-form input[type="submit"]:hover,
+		body:not(.single) .format-gallery .post-password-form input[type="submit"]:focus,
+		body:not(.single) .format-image .post-password-form input[type="submit"]:hover,
+		body:not(.single) .format-image .post-password-form input[type="submit"]:focus,
+		body:not(.single) .format-video .post-password-form input[type="submit"]:hover,
+		body:not(.single) .format-video .post-password-form input[type="submit"]:focus', 'color', 'bg', 5 ),
 
 
 	array( 'body:not(.single) .format-audio .entry-meta,
 	array( 'body:not(.single) .format-audio .entry-meta,
 		body:not(.single) .format-audio .entry-meta a,
 		body:not(.single) .format-audio .entry-meta a,
@@ -37,6 +57,19 @@ add_color_rule( 'bg', '#bdcbcc', array(
 		.posts-navigation .nav-previous a,
 		.posts-navigation .nav-previous a,
 		.posts-navigation .nav-next a', 'color', 'bg', 3 ),
 		.posts-navigation .nav-next a', 'color', 'bg', 3 ),
 
 
+	array( 'body:not(.single) .format-audio .post-password-form input[type="submit"],
+		body:not(.single) .format-gallery .post-password-form input[type="submit"],
+		body:not(.single) .format-image .post-password-form input[type="submit"],
+		body:not(.single) .format-video .post-password-form input[type="submit"],
+		body:not(.single) .format-audio .post-password-form input[type="submit"]:hover,
+		body:not(.single) .format-audio .post-password-form input[type="submit"]:focus,
+		body:not(.single) .format-gallery .post-password-form input[type="submit"]:hover,
+		body:not(.single) .format-gallery .post-password-form input[type="submit"]:focus,
+		body:not(.single) .format-image .post-password-form input[type="submit"]:hover,
+		body:not(.single) .format-image .post-password-form input[type="submit"]:focus,
+		body:not(.single) .format-video .post-password-form input[type="submit"]:hover,
+		body:not(.single) .format-video .post-password-form input[type="submit"]:focus', 'border-color', 'bg', 5 ),
+
 	array( '.single #primary .author-info', 'background-color', 0.1 ),
 	array( '.single #primary .author-info', 'background-color', 0.1 ),
 
 
 	// Background colour - contrast against background
 	// Background colour - contrast against background
@@ -95,7 +128,15 @@ add_color_rule( 'bg', '#bdcbcc', array(
 		body:not(.single) .format-aside,
 		body:not(.single) .format-aside,
 		body:not(.single) .format-aside a', 'color' ),
 		body:not(.single) .format-aside a', 'color' ),
 
 
-	array( 'body:not(.single) .format-aside .entry-content', 'color', 0.8 ),
+	array( 'body:not(.single) .format-aside .entry-content,
+		body:not(.single) .format-aside input[type="submit"],
+		body:not(.single) .format-aside input[type="submit"]:hover,
+		body:not(.single) .format-aside input[type="submit"]:focus,
+		body:not(.single) .format-aside .post-password-form label', 'color', 0.8 ),
+
+	array( 'body:not(.single) .format-aside input[type="submit"],
+		body:not(.single) .format-aside input[type="submit"]:hover,
+		body:not(.single) .format-aside input[type="submit"]:focus', 'border-color', 0.8 ),
 
 
 	array( 'body:not(.single) .format-aside .entry-meta,
 	array( 'body:not(.single) .format-aside .entry-meta,
 		body:not(.single) .format-aside .entry-meta .entry-meta,
 		body:not(.single) .format-aside .entry-meta .entry-meta,

+ 56 - 0
scratchpad/style.css

@@ -1544,6 +1544,31 @@ body:not(.single) .format-aside .entry-meta a {
 	color: rgba(255, 255, 255, 0.4);
 	color: rgba(255, 255, 255, 0.4);
 }
 }
 
 
+body:not(.single) .format-aside button,
+body:not(.single) .format-aside input[type="button"],
+body:not(.single) .format-aside input[type="reset"],
+body:not(.single) .format-aside input[type="submit"] {
+	border-color: rgba(255, 255, 255, 0.5);
+	color: rgba(255, 255, 255, 0.8);
+}
+
+body:not(.single) .format-aside button:hover,
+body:not(.single) .format-aside input[type="button"]:hover,
+body:not(.single) .format-aside input[type="reset"]:hover,
+body:not(.single) .format-aside input[type="submit"]:hover,
+body:not(.single) .format-aside button:focus,
+body:not(.single) .format-aside input[type="button"]:focus,
+body:not(.single) .format-aside input[type="reset"]:focus,
+body:not(.single) .format-aside input[type="submit"]:focus {
+	border-color: rgba(255, 255, 255, 0.8);
+	color: #fff;
+}
+
+body:not(.single) .format-aside .post-password-form label {
+	color: rgba(255,255,255,0.8);
+}
+
+
 /*--------------------------------------------------------------
 /*--------------------------------------------------------------
 10.4 Audio
 10.4 Audio
 --------------------------------------------------------------*/
 --------------------------------------------------------------*/
@@ -3088,6 +3113,37 @@ iframe[src*='bandcamp'] {
 	top: -3px;
 	top: -3px;
 }
 }
 
 
+body:not(.single) .format-audio.post-password-required,
+body:not(.single) .format-audio .post-password-form label,
+body:not(.single) .format-gallery.post-password-required,
+body:not(.single) .format-gallery .post-password-form label,
+body:not(.single) .format-image.post-password-required,
+body:not(.single) .format-image .post-password-form label,
+body:not(.single) .format-video.post-password-required,
+body:not(.single) .format-video .post-password-form label {
+	color: #537375;
+}
+
+ body:not(.single) .format-audio .post-password-form input[type="submit"],
+ body:not(.single) .format-gallery .post-password-form input[type="submit"],
+ body:not(.single) .format-image .post-password-form input[type="submit"],
+ body:not(.single) .format-video .post-password-form input[type="submit"] {
+	border-color: #537375;
+	color: #537375;
+}
+
+body:not(.single) .format-audio .post-password-form input[type="submit"]:hover,
+body:not(.single) .format-audio .post-password-form input[type="submit"]:focus,
+body:not(.single) .format-gallery .post-password-form input[type="submit"]:hover,
+body:not(.single) .format-gallery .post-password-form input[type="submit"]:focus,
+body:not(.single) .format-image .post-password-form input[type="submit"]:hover,
+body:not(.single) .format-image .post-password-form input[type="submit"]:focus,
+body:not(.single) .format-video .post-password-form input[type="submit"]:hover,
+body:not(.single) .format-video .post-password-form input[type="submit"]:focus {
+	border-color: #3e5f61;
+	color: #3e5f61;
+}
+
 /*--------------------------------------------------------------
 /*--------------------------------------------------------------
 15.0 Infinite scroll
 15.0 Infinite scroll
 --------------------------------------------------------------*/
 --------------------------------------------------------------*/

+ 4 - 0
scratchpad/template-parts/content-audio.php

@@ -52,4 +52,8 @@ $content = apply_filters( 'the_content', get_the_content() );
 			?>
 			?>
 		</div><!-- .entry-meta -->
 		</div><!-- .entry-meta -->
 	</header><!-- .entry-header -->
 	</header><!-- .entry-header -->
+
+	<?php if ( post_password_required() ) {
+		the_content();
+	} ?>
 </article><!-- #post-## -->
 </article><!-- #post-## -->

+ 6 - 1
scratchpad/template-parts/content-gallery.php

@@ -14,7 +14,7 @@
 	<?php scratchpad_sticky(); ?>
 	<?php scratchpad_sticky(); ?>
 
 
 	<?php
 	<?php
-		if ( get_post_gallery() ) { ?>
+		if ( get_post_gallery() && ! post_password_required() ) { ?>
 			<div class="entry-gallery">
 			<div class="entry-gallery">
 				<?php echo get_post_gallery(); ?>
 				<?php echo get_post_gallery(); ?>
 				<div class="photo-corners">
 				<div class="photo-corners">
@@ -53,4 +53,9 @@
 			);
 			);
 		?>
 		?>
 	</footer><!-- .entry-footer -->
 	</footer><!-- .entry-footer -->
+
+	<?php
+	if ( post_password_required() ) {
+		the_content();
+	} ?>
 </article><!-- #post-## -->
 </article><!-- #post-## -->

+ 6 - 2
scratchpad/template-parts/content-image.php

@@ -20,7 +20,7 @@ $image = get_media_embedded_in_content( $content, array( 'image' ) );
 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 	<?php scratchpad_sticky(); ?>
 	<?php scratchpad_sticky(); ?>
 
 
-	<?php if ( has_post_thumbnail() ) { ?>
+	<?php if ( has_post_thumbnail() && ! post_password_required() ) { ?>
 		<div class="featured-image">
 		<div class="featured-image">
 			<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'scratchpad-featured' ); ?></a>
 			<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'scratchpad-featured' ); ?></a>
 			<div class="photo-corners">
 			<div class="photo-corners">
@@ -33,7 +33,7 @@ $image = get_media_embedded_in_content( $content, array( 'image' ) );
 			</div><!-- .photo-corners -->
 			</div><!-- .photo-corners -->
 		</div><!-- .featured-image -->
 		</div><!-- .featured-image -->
 
 
-	<?php } else if ( ! empty( $image ) ) { ?>
+	<?php } else if ( ! empty( $image ) && ! post_password_required() ) { ?>
 		<div class="featured-image">
 		<div class="featured-image">
 			<a href="<?php the_permalink(); ?>"><?php echo $image[0]; ?></a>
 			<a href="<?php the_permalink(); ?>"><?php echo $image[0]; ?></a>
 			<div class="photo-corners">
 			<div class="photo-corners">
@@ -67,4 +67,8 @@ $image = get_media_embedded_in_content( $content, array( 'image' ) );
 			?>
 			?>
 		</div><!-- .entry-meta -->
 		</div><!-- .entry-meta -->
 	</header><!-- .entry-header -->
 	</header><!-- .entry-header -->
+
+	<?php if ( post_password_required() ) {
+		the_content();
+	} ?>
 </article><!-- #post-## -->
 </article><!-- #post-## -->

+ 1 - 1
scratchpad/template-parts/content-single.php

@@ -10,7 +10,7 @@
 ?>
 ?>
 
 
 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
-	<?php if ( has_post_thumbnail() ) { ?>
+	<?php if ( has_post_thumbnail() && ! post_password_required() ) { ?>
 		<div class="featured-image">
 		<div class="featured-image">
 			<span>
 			<span>
 				<?php get_template_part( 'images/inline', 'paperclip.svg' ); ?>
 				<?php get_template_part( 'images/inline', 'paperclip.svg' ); ?>

+ 4 - 0
scratchpad/template-parts/content-video.php

@@ -64,4 +64,8 @@ $content = apply_filters( 'the_content', get_the_content( $content_text ) );
 		<?php
 		<?php
 		endif; ?>
 		endif; ?>
 	</header><!-- .entry-header -->
 	</header><!-- .entry-header -->
+
+	<?php if ( post_password_required() ) {
+		the_content();
+	} ?>
 </article><!-- #post-## -->
 </article><!-- #post-## -->