Skip to content

Commit

Permalink
全podcastへのリンクの追加など
Browse files Browse the repository at this point in the history
- シリーズ一覧で「全podcast」へのリンクを追加
- 全podcast のページを改良(登録ボタンなど)
- エピソードの段組表示のレスポンシブを改良
  • Loading branch information
toiee-kameda committed Oct 27, 2020
1 parent 8795588 commit ebb75cf
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 138 deletions.
61 changes: 60 additions & 1 deletion archive-podcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
* @package BusinessPress
*/

$series_image = get_option( 'ss_podcasting_data_image', 'no-image' );
$series_feed = get_home_url() . '/feed/podcast/bpcast_token/' . bpcast_get_user_token() . '/';

$feed_podcast = preg_replace( '/^http.?:/', 'podcast:', $series_feed );
$feed_itunes = preg_replace( '/^http.?:/', 'pcast:', $series_feed );
$feed_ovcast = 'overcast://x-callback-url/add?url=' . $series_feed;
$feed_castro = preg_replace( '/^http.?:/', 'podto:', $series_feed );

$archive_title = get_option( 'ss_podcasting_data_title', 'Podcast' );
$archive_description = get_option( 'ss_podcasting_data_subtitle', '' );


get_header(); ?>

<section id="primary" class="content-area">
Expand All @@ -15,7 +27,54 @@
<?php if ( have_posts() ) : ?>

<header class="page-header">
<h1>ポッドキャストでーす</h1>
<div class="page-header-grid">
<div class="series-icon">
<img src="<?php echo $series_image; ?>">
</div>
<div class="seriees-title">
<h1 class="page-title-series"><?php echo $archive_title; ?></h1>
<div class="taxonomy-description-series"><?php echo $archive_description; ?></div>
</div>
</div>
<div class="subscribe">
<?php if ( is_user_logged_in() ) : ?>
<button onclick="location.href='<?php echo $feed_podcast; ?>'">Podcast</button>
<button onclick="location.href='<?php echo $feed_itunes; ?>'">iTunes</button>
<button onclick="location.href='<?php echo $feed_ovcast; ?>'">Overcast</button>
<button onclick="location.href='<?php echo $feed_castro; ?>'">Castro</button>
<br>
<input type="text" value="<?php echo $series_feed; ?>" id="copy_feed" onclick="this.select();" readonly> <button onclick="copy_feed()">Copy feed</button>
<script>
function copy_feed() {
/* Get the text field */
var copyText = document.getElementById("copy_feed");

/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /*For mobile devices*/

/* Copy the text inside the text field */
document.execCommand("copy");

/* Alert the copied text */
alert("コピーしました");
}
</script>
<?php else : ?>
<button onclick="location.href='#bp-login-form'">Podcast</button>
<button onclick="location.href='#bp-login-form'">iTunes</button>
<button onclick="location.href='#bp-login-form'">Overcast</button>
<button onclick="location.href='#bp-login-form'">Castro</button>
<br>
<input type="text" value="<?php echo $series_feed; ?>" id="copy_feed" onclick="this.select();" readonly> <button onclick="copy_feed()">Copy feed</button>
<script>
function copy_feed() {
/* Get the text field */
location.href='#bp-login-form';
}
</script>
<?php endif; ?>
</div>
</header><!-- .page-header -->

<div class="loop-wrapper">
Expand Down
132 changes: 1 addition & 131 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,137 +49,7 @@ function enqueue_our_required_stylesheets(){
require_once 'includes/frontend.php';
}


// shortcode
function bplib_shortcode( $atts ) {
if ( isset( $atts['q'] ) ) {
$q = $atts['q'];
} else {
$q = 'series';
}

$msg = '';
$tax_query = array();
switch ( $q ) {
case 'welcome' :
case 'featured' :
$tax_query = array(
array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'terms' => $q,
),
);
case 'latest' :
$args = array(
'post_type' => 'podcast',
'tax_query' => $tax_query,
);
$the_query = new WP_Query( $args );

if ( $the_query->have_posts() ) {
remove_filter( 'has_post_thumbnail', 'bpcast_disable_thumbnail', 10 );
ob_start();
?>
<div class="loop-wrapper loop-wrapper-3column">
<?php
while ( $the_query->have_posts() ) {
$the_query->the_post();
?>
<div class="post-grid">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php if ( has_post_thumbnail() ) : ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'businesspress-post-thumbnail-medium' ); ?></a>
</div><!-- .post-thumbnail -->
<?php endif; ?>
<?php bplib_category(); ?>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php businesspress_entry_meta(); ?>
</header><!-- .entry-header -->
<div class="entry-summary">
<p><?php echo businesspress_shorten_text( get_the_excerpt(), 160 ); ?></p>
</div><!-- .entry-summary -->
</article><!-- #post-## -->
</div><!-- .post-grid -->
<?php
}
?>
</div>
<?php
wp_reset_postdata();
add_filter( 'has_post_thumbnail', 'bpcast_disable_thumbnail', 10, 3 );

$msg = ob_get_contents();
ob_end_clean();
} else {
$msg = '<p>投稿はありません</p>';
}
break;

default:
$terms = get_terms( 'series' );

ob_start();
?>
<div class="loop-wrapper loop-wrapper-2column">
<?php foreach ( $terms as $term ) : ?>
<?php
$series_id = $term->term_id;
$series_image = get_option( 'ss_podcasting_data_image_' . $series_id, 'no-image' );
?>
<div class="post-grid">
<div class="page-header-grid">
<div class="series-icon">
<img src="<?php echo $series_image; ?>">
</div>
<div class="seriees-title">
<h2 class="series-2column-title"><a href="<?php echo get_term_link($term); ?>"><?php echo $term->name; ?></a></h2>
<div class="taxonomy-description-series"><?php echo $term->description; ?></div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php

$msg = ob_get_contents();
ob_end_clean();
}

return $msg;
}
add_shortcode( 'bp-lib', 'bplib_shortcode' );


function businesspress_entry_meta() {
// Hide for pages on Search.
if ( 'post' != get_post_type() && 'podcast' != get_post_type() ) {
return;
}
?>
<div class="entry-meta">
<span class="posted-on">
<?php printf( '<a href="%1$s" rel="bookmark"><time class="entry-date published updated" datetime="%2$s">%3$s</time></a>',
esc_url( get_permalink() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
); ?>
</span>
<span class="byline"><?php esc_html_e( 'by', 'businesspress' ); ?>
<span class="author vcard">
<a class="url fn n" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" title="<?php printf( esc_html__( 'View all posts by %s', 'businesspress' ), get_the_author() );?>"><?php echo get_the_author();?></a>
</span>
</span>
<?php if ( ! post_password_required() && comments_open() ) : ?>
<span class="comments-link"><span class="comments-sep"> / </span>
<?php comments_popup_link( esc_html__( '0 Comment', 'businesspress' ), esc_html__( '1 Comment', 'businesspress' ), esc_html__( '% Comments', 'businesspress' ) ); ?>
</span>
<?php endif; ?>
</div><!-- .entry-meta -->
<?php
}
require_once 'includes/shortcode.php';

function bplib_category() {
$post = get_post();
Expand Down
148 changes: 148 additions & 0 deletions includes/shortcode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?php

function bplib_shortcode( $atts ) {
if ( isset( $atts['q'] ) ) {
$q = $atts['q'];
} else {
$q = 'series';
}

$msg = '';
$tax_query = array();
switch ( $q ) {
case 'welcome' :
case 'featured' :
$tax_query = array(
array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'terms' => $q,
),
);
case 'latest' :
$args = array(
'post_type' => 'podcast',
'tax_query' => $tax_query,
);
$the_query = new WP_Query( $args );

if ( $the_query->have_posts() ) {
remove_filter( 'has_post_thumbnail', 'bpcast_disable_thumbnail', 10 );
ob_start();
?>
<div class="loop-wrapper loop-wrapper-3column">
<?php
while ( $the_query->have_posts() ) {
$the_query->the_post();
?>
<div class="post-grid">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php if ( has_post_thumbnail() ) : ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'businesspress-post-thumbnail-medium' ); ?></a>
</div><!-- .post-thumbnail -->
<?php endif; ?>
<?php bplib_category(); ?>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php businesspress_entry_meta(); ?>
</header><!-- .entry-header -->
<div class="entry-summary">
<p><?php echo businesspress_shorten_text( get_the_excerpt(), 160 ); ?></p>
</div><!-- .entry-summary -->
</article><!-- #post-## -->
</div><!-- .post-grid -->
<?php
}
?>
</div>
<?php
wp_reset_postdata();
add_filter( 'has_post_thumbnail', 'bpcast_disable_thumbnail', 10, 3 );

$msg = ob_get_contents();
ob_end_clean();
} else {
$msg = '<p>投稿はありません</p>';
}
break;

default:
$terms = get_terms( 'series' );

$series_image = get_option( 'ss_podcasting_data_image', 'no-image' );
$series_url = get_home_url() . '/podcast/';
$arce_title = get_option( 'ss_podcasting_data_title', 'Podcast' );
$arc_description = get_option( 'ss_podcasting_data_subtitle', '' );

ob_start();
?>
<div class="loop-wrapper loop-wrapper-2column">
<div class="post-grid">
<div class="page-header-grid">
<div class="series-icon">
<img src="<?php echo $series_image; ?>">
</div>
<div class="seriees-title">
<h2 class="series-2column-title"><a href="<?php echo $series_url; ?>"><?php echo $arce_title; ?></a></h2>
<div class="taxonomy-description-series"><?php echo $arc_description; ?></div>
</div>
</div>
</div>

<?php foreach ( $terms as $term ) : ?>
<?php
$series_id = $term->term_id;
$series_image = get_option( 'ss_podcasting_data_image_' . $series_id, 'no-image' );
?>
<div class="post-grid">
<div class="page-header-grid">
<div class="series-icon">
<img src="<?php echo $series_image; ?>">
</div>
<div class="seriees-title">
<h2 class="series-2column-title"><a href="<?php echo get_term_link($term); ?>"><?php echo $term->name; ?></a></h2>
<div class="taxonomy-description-series"><?php echo $term->description; ?></div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php

$msg = ob_get_contents();
ob_end_clean();
}

return $msg;
}
add_shortcode( 'bp-lib', 'bplib_shortcode' );


function businesspress_entry_meta() {
// Hide for pages on Search.
if ( 'post' != get_post_type() && 'podcast' != get_post_type() ) {
return;
}
?>
<div class="entry-meta">
<span class="posted-on">
<?php printf( '<a href="%1$s" rel="bookmark"><time class="entry-date published updated" datetime="%2$s">%3$s</time></a>',
esc_url( get_permalink() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
); ?>
</span>
<span class="byline"><?php esc_html_e( 'by', 'businesspress' ); ?>
<span class="author vcard">
<a class="url fn n" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" title="<?php printf( esc_html__( 'View all posts by %s', 'businesspress' ), get_the_author() );?>"><?php echo get_the_author();?></a>
</span>
</span>
<?php if ( ! post_password_required() && comments_open() ) : ?>
<span class="comments-link"><span class="comments-sep"> / </span>
<?php comments_popup_link( esc_html__( '0 Comment', 'businesspress' ), esc_html__( '1 Comment', 'businesspress' ), esc_html__( '% Comments', 'businesspress' ) ); ?>
</span>
<?php endif; ?>
</div><!-- .entry-meta -->
<?php
}
20 changes: 14 additions & 6 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description: Businesspress child theme.
Author: toiee Lab
Author URI: https://toiee.jp/
Template: businesspress
Version: 0.1.0
Version: 0.2.0
*/

.page-title-series {
Expand Down Expand Up @@ -70,11 +70,19 @@ Version: 0.1.0
display: flex;
flex-wrap: wrap;
}
.loop-wrapper-3column .post-grid {
box-sizing: border-box;
width: 33.3%;
padding-left: 30px;
padding-right: 30px;
@media screen and (min-width: 980px) {
.loop-wrapper-3column .post-grid {
box-sizing: border-box;
width: 33.3%;
padding-left: 30px;
padding-right: 30px;
}
}
@media screen and (max-width: 540px) {
.loop-wrapper-3column .post-grid {
padding-top: 30px;
padding-bottom: 30px;
}
}
.loop-wrapper-2column {
display: flex;
Expand Down

0 comments on commit ebb75cf

Please sign in to comment.