-
Notifications
You must be signed in to change notification settings - Fork 16
/
page-cover-top-block.php
112 lines (90 loc) · 4.87 KB
/
page-cover-top-block.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<section id="post-<?php the_ID(); ?>" <?php post_class( [ 'top-block', 'clearfix', 'home-post' ] ); ?>>
<?php pb_get_links( false ); ?>
<?php $metadata = pb_get_book_information();?>
<div class="log-wrap"> <!-- Login/Logout -->
<?php if ( ! is_single() ) : ?>
<?php if ( ! is_user_logged_in() ) : ?>
<a href="<?php echo wp_login_url( get_permalink() ); ?>" class=""><?php _e( 'login', 'pressbooks-book' ); ?></a>
<?php else : ?>
<a href="<?php echo wp_logout_url(); ?>" class=""><?php _e( 'logout', 'pressbooks-book' ); ?></a>
<?php if ( is_super_admin() || is_user_member_of_blog() ) : ?>
<a href="<?php echo get_option( 'home' ); ?>/wp-admin"><?php _e( 'Admin', 'pressbooks-book' ); ?></a>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="right-block">
<?php do_action( 'pb_cover_promo' ); ?>
</div>
<div class="book-info">
<!-- Book Title -->
<h1 class="entry-title"><a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php if ( ! empty( $metadata['pb_author'] ) ) : ?>
<p class="book-author vcard author"><span class="fn"><?php echo $metadata['pb_author']; ?></span></p>
<span class="stroke"></span>
<?php endif; ?>
<?php if ( ! empty( $metadata['pb_contributing_authors'] ) ) : ?>
<p class="book-author"><?php echo $metadata['pb_contributing_authors']; ?> </p>
<?php endif; ?>
<?php if ( ! empty( $metadata['pb_about_140'] ) ) : ?>
<p class="sub-title"><?php echo $metadata['pb_about_140']; ?></p>
<span class="detail"></span>
<?php endif; ?>
<?php if ( ! empty( $metadata['pb_about_50'] ) ) : ?>
<p><?php echo pb_decode( $metadata['pb_about_50'] ); ?></p>
<?php endif; ?>
</div> <!-- end .book-info -->
<?php if ( ! empty( $metadata['pb_cover_image'] ) ) : ?>
<div class="book-cover">
<img src="<?php echo $metadata['pb_cover_image']; ?>" alt="book-cover" title="<?php bloginfo( 'name' ); ?> book cover" />
</div>
<?php endif; ?>
<div class="call-to-action-wrap">
<?php global $first_chapter; ?>
<div class="call-to-action">
<a class="btn red" href="<?php global $first_chapter;
echo $first_chapter; ?>"><span class="read-icon"></span><?php _e( 'Read', 'pressbooks-book' ); ?></a>
<?php if ( array_filter( get_option( 'pressbooks_ecommerce_links', [] ) ) ) : ?>
<!-- Buy -->
<a class="btn black" href="<?php echo get_option( 'home' ); ?>/buy"><span class="buy-icon"></span><?php _e( 'Buy', 'pressbooks-book' ); ?></a>
<?php endif; ?>
</div> <!-- end .call-to-action -->
</div><!-- end .call-to-action-wrap -->
<?php
/**
* @author Brad Payne <brad@bradpayne.ca>
* @copyright 2014 Brad Payne
* @since 3.8.0
*/
$files = \Pressbooks\Utility\latest_exports();
$site_option = get_site_option( 'pressbooks_sharingandprivacy_options', [ 'allow_redistribution' => 0 ] );
$option = get_option( 'pbt_redistribute_settings', [ 'latest_files_public' => 0 ] );
if ( ! empty( $files ) && ( ! empty( $site_option['allow_redistribution'] ) ) && ( ! empty( $option['latest_files_public'] ) ) ) { ?>
<div class="downloads">
<h4><?php _e( 'Download in the following formats:', 'pressbooks-book' ); ?></h4>
<?php foreach ( $files as $filetype => $filename ) :
$filename = preg_replace( '/(-\d{10})(.*)/ui', '$1', $filename );
// Rewrite rule
$url = home_url( "/open/download?type={$filetype}" );
// Tracking event defaults to Google Analytics (Universal). @codingStandardsIgnoreStart
// Filter like so (for Piwik):
// add_filter('pressbooks_download_tracking_code', function( $tracking, $filetype ) {
// return "_paq.push(['trackEvent','exportFiles','Downloads','{$filetype}']);";
// }, 10, 2);
// Or for Google Analytics (Classic):
// add_filter('pressbooks_download_tracking_code', function( $tracking, $filetype ) {
// return "_gaq.push(['_trackEvent','exportFiles','Downloads','{$file_class}']);";
// }, 10, 2); @codingStandardsIgnoreEnd
$tracking = apply_filters( 'pressbooks_download_tracking_code', "ga('send','event','exportFiles','Downloads','{$filetype}');", $filetype );
?>
<link itemprop="bookFormat" href="http://schema.org/EBook">
<a rel="nofollow" onclick="<?php echo $tracking; ?>" itemprop="offers" itemscope itemtype="http://schema.org/Offer" href="<?php echo $url; ?>">
<span class="export-file-icon small <?php echo $filetype; ?>" title="<?php echo esc_attr( $filename ); ?>"></span>
<meta itemprop="price" content="$0.00">
<link itemprop="availability" href="http://schema.org/InStock">
</a>
<?php endforeach; ?>
</div>
<?php }
?>
</section> <!-- end .top-block -->