-
Notifications
You must be signed in to change notification settings - Fork 7
/
single-orbita.php
executable file
·128 lines (107 loc) · 4.05 KB
/
single-orbita.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* Órbita
*
* @package orbita
* @author Gabriel Nunes, Rodrigo Ghedin, Clarissa Mendes, Renan Altendorf
* @copyright 2022 Manual do Usuário
* @license GPL-3.0
**/
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php
while ( have_posts() ) :
the_post();
$external_url = get_post_meta( get_the_id(), 'external_url', true );
$attach_file = get_post_meta( get_the_id(), 'attach_file', true );
$only_domain = wp_parse_url( str_replace( 'www.', '', $external_url ), PHP_URL_HOST );
$count = get_post_meta( get_the_id(), 'post_like_count', true );
if ( ! $count ) {
$count = 'nenhum';
}
$votes_text = $count > 1 ? 'votos' : 'voto';
if ( ! $external_url ) {
$get_post_id = get_the_ID();
$get_term = get_term_by( 'name', 'conversas', 'orbita_category' );
if(isset($get_term->term_id)) {
$get_term_id = $get_term->term_id;
wp_set_object_terms( $get_post_id, $get_term_id, 'orbita_category' );
}
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php
wp_timezone_string( 'America/Sao_Paulo' );
$date = get_the_date( 'j/n/y, G\hi' );
$author_display_name = esc_html( get_the_author_meta( 'display_name', $post->post_author ) );
$author_nickname = esc_html( get_the_author_meta( 'nickname', $post->post_author ) );
echo do_shortcode( '[orbita-header]' );
if ( $external_url ) :
$separator = '?';
if(strpos($external_url, '?') !== false) :
$separator = '&';
endif;
the_title( '<h1 class="entry-title orbita-post-title"><a href="' . esc_url( $external_url ) . $separator . 'utm_source=ManualdoUsuarioNet&utm_medium=Orbita" rel="ugc">', '</a> ' . orbita_link_options( $external_url, get_the_title() ) . '<span class="domain">' . $only_domain . '</span></h1>' );
else :
the_title( '<h1 class="entry-title orbita-post-title">', '</h1>' );
endif;
?>
<div class="orbita-meta link-alt">
<?php echo do_shortcode( '[orbita-vote]' ); ?><span data-votes-post-id="<?php the_ID(); ?>"><?php echo esc_html( $count ); ?></span> <?php echo esc_html( $votes_text ); ?> · <?php echo $author_display_name; ?> · <?php echo esc_html( $date ); ?>
</div>
</header>
<div class="entry-content">
<?php
$oembed = false;
if( $external_url ) {
$providers = ['youtube.com', 'youtu.be', 'vimeo.com', 'dailymotion.com', 'dai.ly'];
foreach($providers as $provider) {
if( strpos( $only_domain, $provider ) !== false ) {
$oembed = true;
?>
<div class="orbita-oembed orbita-oembed-16by9">
<?php echo wp_oembed_get( $external_url ); ?>
</div>
<?php
break;
}
}
}
if( $attach_file == 1 && $oembed == false ) {
if ( has_post_thumbnail() ) {
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );
$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
if ( ! empty( $large_image_url[0] ) ) {
printf( '<a target="_blank" href="%1$s" alt="%2$s">%3$s</a>',
esc_url( $full_image_url[0] ),
esc_attr( get_the_title() ),
dez_post_thumbnail()
);
}
}
}
esc_textarea( the_content() );
?>
</div>
<?php the_post_navigation(
array(
'prev_text' => '<span class="nav-title">%title</span> <span class="nav-subtitle">' . esc_html__( '»', 'dez' ) . '</span>',
'next_text' => '<span class="nav-subtitle">' . esc_html__( '«', 'dez' ) . '</span> <span class="nav-title">%title</span>',
'class' => 'link-alt',
)
); ?>
</article>
<?php
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_footer();