· 6 years ago · Oct 31, 2019, 08:56 AM
1<?php
2
3define ('DOO_COM', 'MLWBD');
4define ('DOO_SERVER', 'https://mlwbd.xyz');
5define ('DT_SERVER', 'https://mlwbd.xyz');
6define ('DT_AUTOR', '');
7define ('DT_RENOVAR', '');
8define ('DT_SUPPORT_FORUMS', '');
9define ('DT_PAGE_THEME', '');
10define ('DT_CHANGELOG', '');
11define ('DT_DOC', '');
12define ('DT_DICO', 'https://s2.googleusercontent.com/s2/favicons?domain=');
13define ('dbmurl','https://api.dbmovies.org/');
14define ('tmdburl','https://api.themoviedb.org/3/');
15//define ('imdbdata','https://api.themoviedb.org/3/movie/');
16define ('imdbdata', get_bloginfo('stylesheet_directory'). '/imdb/?i=');
17define ('imdbdata2','http://www.omdbapi.com/?apikey=775e324f&tomatoes=true&plot=full&i=');
18define ('apigoorec','https://www.google.com/recaptcha/api/siteverify');
19define ('tmdbkey', get_option('dt_api_key', '6b4357c41d9c606e4d7ebe2f4a8850ea'));
20define ('tmdblang', get_option('dt_api_language', 'it-IT'));
21# Mobile or not mobile
22function doo_mobile() {
23 $mobile = ( wp_is_mobile() == true ) ? '1' : 'false';
24 return $mobile;
25}
26
27
28/* Echo translated text
29-------------------------------------------------------------------------------
30*/
31function _d( $text ){
32 echo translate($text , 'mtms');
33}
34
35/* Return Translated Text
36-------------------------------------------------------------------------------
37*/
38function __d( $text ) {
39 return translate($text, 'mtms');
40}
41
42/* Player flags
43-------------------------------------------------------------------------------
44*/
45function dt_get_language() {
46 $idiomas = array(
47 __d('---------') => '',
48 __d('Arabic') => 'ar',
49 __d('Chinese') => 'cn',
50 __d('Denmark') => 'dk',
51 __d('Dutch') => 'nl',
52 __d('English') => 'en',
53 __d('English British') => 'gb',
54 __d('Egypt') => 'egt',
55 __d('French') => 'fr',
56 __d('German') => 'de',
57 __d('Indonesian') => 'id',
58 __d('Hindi') => 'in',
59 __d('Italian') => 'it',
60 __d('Japanese') => 'jp',
61 __d('Korean') => 'kr',
62 __d('Philippines') => 'ph',
63 __d('Portuguese Portugal') => 'pt',
64 __d('Portuguese Brazil') => 'br',
65 __d('Polish') => 'pl',
66 __d('Romanian') => 'td',
67 __d('Scotland') => 'sco',
68 __d('Spanish Spain') => 'es',
69 __d('Spanish Mexico') => 'mx',
70 __d('Spanish Argentina') => 'ar',
71 __d('Spanish Peru') => 'pe',
72 __d('Spanish Chile') => 'pe',
73 __d('Spanish Colombia') => 'co',
74 __d('Sweden') => 'se',
75 __d('Turkish') => 'tr',
76 __d('Rusian') => 'ru',
77 __d('Vietnam') => 'vn'
78 );
79 return $idiomas;
80}
81
82
83# FIX $_GET
84function dt_fix_get($get) {
85 $getdata = isset( $_GET[$get] ) ? $_GET[$get] : false;
86 return $getdata;
87}
88
89/* Register master categories
90-------------------------------------------------------------------------------
91*/
92function genres_taxonomy() {
93 register_taxonomy('genres', array('tvshows,movies',),
94 array(
95 'show_admin_column' => true,
96 'hierarchical' => true,
97 'label' => __d('Genres'),
98 'rewrite' => array ('slug' => get_option('dt_genre_slug','genre')),)
99 );
100}
101add_action('init', 'genres_taxonomy', 0);
102 function prefijo_mastercat() {
103 flush_rewrite_rules();
104 }
105add_action('after_switch_theme', 'prefijo_mastercat');
106
107function quality_taxonomy() {
108 register_taxonomy('dtquality', array('episodes,movies'),
109 array(
110 'show_admin_column' => true,
111 'hierarchical' => true,
112 'label' => __d('Quality'),
113 'rewrite' => array ('slug' => get_option('dt_quality_slug','quality')),)
114 );
115}
116add_action('init', 'quality_taxonomy', 0);
117
118function dp_c() {
119 flush_rewrite_rules();
120}
121add_action('after_switch_theme', 'dp_c');
122
123
124/* Add admin css wp-login.php
125-------------------------------------------------------------------------------
126*/
127add_action('admin_enqueue_scripts', 'load_admin_style');
128 function load_admin_style() {
129 wp_register_style('admin_css', DT_DIR_URI . '/assets/css/style-admin.css', false, DT_VERSION );
130 wp_enqueue_style('admin_css', DT_DIR_URI . '/assets/css/style-admin.css', false, DT_VERSION );
131 }
132// logo admin
133add_filter('login_headerurl', 'dt_url');
134function dt_url($url) {
135 return home_url();
136}
137function logo_admin() { ?>
138<style type="text/css">
139h1 a {
140background-image: url(<?php if($logo = get_option('dt_logo_admin')) { echo $logo; } else { echo DT_DIR_URI ."/assets/img/logo_dt.png"; } ?>) !important;
141 background-size: 244px 52px !important;
142 width: 301px !important;
143 height: 52px !important;
144 margin-bottom: 0!important;
145}
146body.login {
147 background: #fff;
148}
149</style>
150<?php }
151add_action('login_head', 'logo_admin');
152
153
154
155/* Count views
156-------------------------------------------------------------------------------
157*/
158function set_dt_views($postID) {
159 $count_key = 'dt_views_count';
160 $count = get_post_meta($postID, $count_key, true);
161 if($count==''){
162 $count = 0;
163 delete_post_meta($postID, $count_key);
164 add_post_meta($postID, $count_key, '1');
165 }else{
166 $count++;
167 update_post_meta($postID, $count_key, $count);
168 }
169}
170
171/* Totals
172-------------------------------------------------------------------------------
173*/
174function total_links_pendientes() {
175 $s='';
176 $totalj=wp_count_posts('dt_links')->pending;
177 if($totalj!=1){
178 $s='s';
179 }
180 return sprintf( __d("%s"),$totalj,$s);
181}
182
183
184function total_peliculas() {
185 $s='';
186 $totalj=wp_count_posts('movies')->publish;
187 if($totalj!=1){
188 $s='s';
189 }
190 return sprintf( __d("%s"),$totalj,$s);
191}
192
193function total_series() {
194 $s='';
195 $totalj=wp_count_posts('tvshows')->publish;
196 if($totalj!=1){
197 $s='s';
198 }
199 return sprintf( __d("%s"),$totalj,$s);
200}
201
202function total_episodios() {
203 $s='';
204 $totalj=wp_count_posts('episodes')->publish;
205 if($totalj!=1){
206 $s='s';
207 }
208 return sprintf( __d("%s"),$totalj,$s);
209}
210
211function total_temporadas() {
212 $s='';
213 $totalj=wp_count_posts('seasons')->publish;
214 if($totalj!=1){
215 $s='s';
216 }
217 return sprintf( __d("%s"),$totalj,$s);
218}
219define('dttp', get_option( DT_KEY ));
220
221
222/* Get genres
223-------------------------------------------------------------------------------
224*/
225function li_generos() {
226 $taxonomy = 'genres';
227 $orderby = 'DESC';
228 $show_count = 1;
229 $hide_empty = false;
230 $pad_counts = 0;
231 $hierarchical = 1;
232 $exclude = '55';
233 $title = '';
234 $args = array(
235 'post_type' => $post_type,
236 'taxonomy' => $taxonomy,
237 'orderby' => $orderby,
238 'show_count' => $show_count,
239 'hide_empty' => $hide_empty,
240 'pad_counts' => $pad_counts,
241 'hierarchical' => $hierarchical,
242 'exclude' => $exclude,
243 'title_li' => $title,
244 'echo' => 0
245 );
246$links = wp_list_categories($args);
247$links = str_replace('</a> (', '</a> <i>', $links);
248$links = str_replace(')', '</i>', $links);
249echo $links;
250}
251
252/* Get genres
253-------------------------------------------------------------------------------
254*/
255function li_generos_h() {
256 $taxonomy = 'genres';
257 $orderby = 'DESC';
258 $show_count = 0;
259 $hide_empty = false;
260 $pad_counts = 0;
261 $hierarchical = 1;
262 $exclude = '55';
263 $title = '';
264 $args = array(
265 'post_type' => $post_type,
266 'taxonomy' => $taxonomy,
267 'orderby' => $orderby,
268 'show_count' => $show_count,
269 'hide_empty' => $hide_empty,
270 'pad_counts' => $pad_counts,
271 'hierarchical' => $hierarchical,
272 'exclude' => $exclude,
273 'title_li' => $title,
274 'echo' => 0
275 );
276$links = wp_list_categories($args);
277$links = str_replace('</a> (', '</a> <i>', $links);
278$links = str_replace(')', '</i>', $links);
279echo $links;
280}
281
282/* Paginator
283-------------------------------------------------------------------------------
284*/
285function pagination($pages = '', $range = 2) {
286 $showitems = ($range * 2)+1;
287 global $paged;
288 if(empty($paged)) $paged = 1;
289
290 if($pages == '') {
291 global $wp_query;
292 $pages = $wp_query->max_num_pages;
293 if(!$pages)
294 {
295 $pages = 1;
296 }
297 }
298 if(1 != $pages) {
299 echo "<div class=\"pagination\"><span>". __d('Page') ." ".$paged." " . __d('of') . " ".$pages."</span>";
300 if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "";
301 if($paged > 1 && $showitems < $pages) echo "<a class='arrow_pag' href='".get_pagenum_link($paged - 1)."'><i class='icon-caret-left'></i></a>";
302
303 for ($i=1; $i <= $pages; $i++) {
304 if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
305 {
306 echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
307 }
308 }
309
310 if ($paged < $pages && $showitems < $pages) echo "<a class='arrow_pag' href=\"".get_pagenum_link($paged + 1)."\"><i class='icon-caret-right'></i></a>";
311 if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "";
312 echo "</div>\n";
313 echo "<div class='resppages'>";
314 previous_posts_link('<span class="icon-chevron-left"></span>');
315 next_posts_link('<span class="icon-chevron-right"></span>');
316 echo "</div>";
317 }
318}
319
320/* Create DT pages
321-------------------------------------------------------------------------------
322*/
323if(is_admin() and current_user_can('administrator')){
324 // Page trending
325 $page_trending = get_option('dt_trending_page');
326 if(empty($page_trending)){
327 $post_id = wp_insert_post(array(
328 'post_content' => '',
329 'post_name' => __d('Trending'),
330 'post_title' => __d('Trending'),
331 'post_status' => 'publish',
332 'post_type' => 'page',
333 'ping_status' => 'closed',
334 'post_date' => date('Y-m-d H:i:s'),
335 'post_date_gmt' => date('Y-m-d H:i:s'),
336 'comment_status' => 'closed',
337 'page_template' => 'pages/trending.php'
338 ));
339 $get_01 = get_option('siteurl').'/' . sanitize_title(__d('Trending')).'/';
340 update_option('dt_trending_page', $get_01);
341 }
342 // Page Rating
343 $page_rating = get_option('dt_rating_page');
344 if(empty($page_rating)){
345 $post_id = wp_insert_post(array(
346 'post_content' => '',
347 'post_name' => __d('Ratings'),
348 'post_title' => __d('Ratings'),
349 'post_status' => 'publish',
350 'post_type' => 'page',
351 'ping_status' => 'closed',
352 'post_date' => date('Y-m-d H:i:s'),
353 'post_date_gmt' => date('Y-m-d H:i:s'),
354 'comment_status' => 'closed',
355 'page_template' => 'pages/rating.php'
356 ));
357 $get_02 = get_option('siteurl').'/' . sanitize_title(__d('Ratings')).'/';
358 update_option('dt_rating_page', $get_02);
359 }
360 // Page Account
361 $page_account = get_option('dt_account_page');
362 if(empty($page_account)){
363 $post_id = wp_insert_post(array(
364 'post_content' => __d('Edit page content.'),
365 'post_name' => __d('My account'),
366 'post_title' => __d('My account'),
367 'post_status' => 'publish',
368 'post_type' => 'page',
369 'ping_status' => 'closed',
370 'post_date' => date('Y-m-d H:i:s'),
371 'post_date_gmt' => date('Y-m-d H:i:s'),
372 'comment_status' => 'closed',
373 'page_template' => 'pages/account.php'
374 ));
375 $get_03 = get_option('siteurl').'/' . sanitize_title(__d('My account')).'/';
376 update_option('dt_account_page', $get_03);
377 }
378 // Page contact
379 $page_contact = get_option('dt_contact_page');
380 if(empty($page_contact)){
381 $post_id = wp_insert_post(array(
382 'post_content' => '',
383 'post_name' => __d('Contact'),
384 'post_title' => __d('Contact'),
385 'post_status' => 'publish',
386 'post_type' => 'page',
387 'ping_status' => 'closed',
388 'post_date' => date('Y-m-d H:i:s'),
389 'post_date_gmt' => date('Y-m-d H:i:s'),
390 'comment_status' => 'closed',
391 'page_template' => 'pages/contact.php'
392 ));
393 $get_05 = get_option('siteurl').'/' . sanitize_title(__d('Contact')).'/';
394 update_option('dt_contact_page', $get_05);
395 }
396
397 // Posts page
398 $page_posts = get_option('dt_posts_page');
399 if(empty($page_posts)){
400 $post_id = wp_insert_post(array(
401 'post_content' => '',
402 'post_name' => __d('Blog'),
403 'post_title' => __d('Blog'),
404 'post_status' => 'publish',
405 'post_type' => 'page',
406 'ping_status' => 'closed',
407 'post_date' => date('Y-m-d H:i:s'),
408 'post_date_gmt' => date('Y-m-d H:i:s'),
409 'comment_status' => 'closed',
410 'page_template' => 'pages/blog.php'
411 ));
412 $get_posts_page = get_option('siteurl').'/' . sanitize_title(__d('Blog')).'/';
413 update_option('dt_posts_page', $get_posts_page);
414 }
415
416 // TOP IMDb page
417 $page_topimdb = get_option('dt_topimdb_page');
418 if(empty($page_topimdb)){
419 $post_id = wp_insert_post(array(
420 'post_content' => '',
421 'post_name' => __d('TOP IMDb'),
422 'post_title' => __d('TOP IMDb'),
423 'post_status' => 'publish',
424 'post_type' => 'page',
425 'ping_status' => 'closed',
426 'post_date' => date('Y-m-d H:i:s'),
427 'post_date_gmt' => date('Y-m-d H:i:s'),
428 'comment_status' => 'closed',
429 'page_template' => 'pages/topimdb.php'
430 ));
431 $get_posts_page = get_option('siteurl').'/' . sanitize_title(__d('TOP IMDb')).'/';
432 update_option('dt_topimdb_page', $get_posts_page);
433 }
434
435 // Generate Access Key
436 function doothemes_key_access($length = 32) {
437 $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
438 $charactersLength = strlen($characters);
439 $randomString = '';
440 for ($i = 0; $i < $length; $i++) {
441 $randomString .= $characters[rand(0, $charactersLength - 1)];
442 }
443 return $randomString;
444 }
445 $doothemes_access = get_option('dbmovies_private_key');
446 if(empty($doothemes_access)){
447 update_option('dbmovies_private_key', doothemes_key_access());
448 }
449}
450
451
452/* Text extract
453-------------------------------------------------------------------------------
454*/
455function dt_content($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
456 $content = get_the_content($more_link_text, $stripteaser, $more_file);
457 $content = strip_shortcodes(apply_filters('the_content_rss', $content));
458 if ( $cut && !$encode_html )
459 $encode_html = 2;
460 if ( 1== $encode_html ) {
461 $content = esc_html($content);
462 $cut = 0;
463 } elseif ( 0 == $encode_html ) {
464 $content = $content;
465 } elseif ( 2 == $encode_html ) {
466 $content = strip_tags($content);
467 }
468 if ( $cut ) {
469 $blah = explode(' ', $content);
470 if ( count($blah) > $cut ) {
471 $k = $cut;
472 $use_dotdotdot = 1;
473 } else {
474 $k = count($blah);
475 $use_dotdotdot = 0;
476 }
477 for ( $i=0; $i<$k; $i++ )
478 $excerpt .= $blah[$i].' ';
479 $excerpt .= ($use_dotdotdot) ? '...' : '';
480 $content = $excerpt;
481 }
482 $content = str_replace(']]>', ']]>', $content);
483 echo $content;
484}
485# Text extract
486function dt_content_alt($charlength) {
487 $excerpt = get_the_excerpt();
488 $charlength++;
489
490 if ( mb_strlen( $excerpt ) > $charlength ) {
491 $subex = mb_substr( $excerpt, 0, $charlength - 5 );
492 $exwords = explode( ' ', $subex );
493 $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
494 if ( $excut < 0 ) {
495 echo mb_substr( $subex, 0, $excut );
496 } else {
497 echo $subex;
498 }
499 echo '...';
500 } else {
501 echo $excerpt;
502 }
503}
504/* Generate release years
505-------------------------------------------------------------------------------
506*/
507function dt_show_year() {
508 $args = array('order' => DESC ,'number' => 50);
509 $camel = 'dtyear';
510 $tax_terms = get_terms($camel,$args);
511 foreach ($tax_terms as $tax_term)
512 { echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '">' . $tax_term->name.'</a></li>'; }
513 }
514
515
516/* Active class
517-------------------------------------------------------------------------------
518*/
519function dt_acpt($type) {
520 if(get_post_type() == $type) { echo 'class="active"'; }
521}
522function dt_acp($page) {
523 if(is_page($page)) { echo 'class="active"'; }
524}
525
526/* Get data
527-------------------------------------------------------------------------------
528*/
529function data_of($name, $id, $acortado = false, $max = 150) {
530 $val = get_post_meta($id, $name, $single = true);
531 if ($val != NULL) {
532 if ($acortado) {
533 return substr($val, 0, $max) . '...';
534 } else {
535 return $val;
536 }
537 } else {
538 if ($name == 'overview') {
539 return "";
540 } elseif ($name == 'temporada') {
541 return "0";
542 } else {
543 return "--";
544 }
545 }
546}
547
548/* Get seasons
549-------------------------------------------------------------------------------
550*/
551function season_of($meta) {
552 global $wpdb;
553 $results = $wpdb->get_results("select post_id, meta_key from $wpdb->postmeta where meta_value = '" . $meta . "'", ARRAY_A);
554 $a_t = array();
555 $a_c = array();
556 foreach ($results as $i => $value) {
557 if (get_post_type($results[$i]["post_id"]) == 'seasons' && get_post_status($results[$i]["post_id"]) == 'publish') {
558 $a_t[] = array(
559 'id' => $results[$i]["post_id"],
560 'season' => get_post_meta($results[$i]["post_id"], "temporada", $single = true)
561 );
562 }
563 if (get_post_type($results[$i]["post_id"]) == 'episodes' && get_post_status($results[$i]["post_id"]) == 'publish') {
564 $a_c[] = array(
565 'id' => $results[$i]["post_id"],
566 'season' => get_post_meta($results[$i]["post_id"], "temporada", $single = true),
567 'capitulo' => get_post_meta($results[$i]["post_id"], "episodio", $single = true)
568 );
569 }
570 }
571 if ((!empty($a_t)) && (!empty($a_c))) {
572 foreach ($a_t as $key => $row) {
573 $aux[$key] = $row['season'];
574 }
575 array_multisort($aux, SORT_ASC, $a_t);
576 foreach ($a_c as $key => $row) {
577 $aux1[$key] = $row['capitulo'];
578 }
579 array_multisort($aux1, SORT_ASC, $a_c);
580 $counta = 0;
581 $finalcap = array();
582 $maxt = 0;
583 foreach ($a_c as $key => $row) {
584 $finalcap[] = array(
585 'id' => $row['id'],
586 'season' => $row['season'],
587 'capitulo' => $row['capitulo']
588 );
589 if ($a_c[$key]["season"] >= $maxt) {
590 $maxt = $a_c[$key]["season"];
591 }
592 $counta++;
593 }
594 $counti = 0;
595 $finalarr = array();
596 foreach ($a_t as $key => $row) {
597 $finalarr[] = array(
598 'id' => $row['id'],
599 'season' => $row['season']
600 );
601 $counti++;
602 }
603 $data = array(
604 'temporada' => array(
605 'l_temp' => array(
606 'id' => $finalarr[$counti - 1]['id'],
607 'numero' => $finalarr[$counti - 1]['season']
608 ),
609 'n_temp' => $counti,
610 'all' => $finalarr,
611 'd_temp' => $maxt
612 ),
613 'capitulo' => array(
614 'n_cap' => $counta,
615 'all' => $finalcap
616 )
617 );
618 return $data;
619 }
620}
621
622/* Get Links
623-------------------------------------------------------------------------------
624*/
625function link_of($meta) {
626 global $wpdb;
627 $results = $wpdb->get_results("select post_id, meta_key from $wpdb->postmeta where meta_value = '" . $meta . "' ", ARRAY_A );
628 $a_t = array();
629 $a_c = array();
630 foreach ($results as $i => $value ) {
631 if (get_post_type($results[$i]["post_id"]) == 'dt_links' && get_post_status($results[$i]["post_id"]) == 'publish') {
632 $a_t[] = array(
633 'id' => $results[$i]["post_id"],
634 'metalink' => get_post_meta($results[$i]["post_id"], "dt_string", $single = true)
635 );
636 }
637 if (get_post_type($results[$i]["post_id"]) == 'episodes' && get_post_status($results[$i]["post_id"]) == 'publish') {
638 $a_c[] = array(
639 'id' => $results[$i]["post_id"],
640 'metalink' => get_post_meta($results[$i]["post_id"], "dt_string", $single = true)
641 );
642 }
643 if (get_post_type($results[$i]["post_id"]) == 'movies' && get_post_status($results[$i]["post_id"]) == 'publish') {
644 $a_c[] = array(
645 'id' => $results[$i]["post_id"],
646 'metalink' => get_post_meta($results[$i]["post_id"], "dt_string", $single = true)
647 );
648 }
649 }
650 if ((!empty($a_t)) && (!empty($a_c))) {
651 foreach ($a_t as $key => $row) {
652 $aux[$key] = $row['metalink'];
653 }
654 array_multisort($aux, SORT_ASC, $a_t);
655
656 $counta = 0;
657 $finalcap = array();
658 $maxt = 0;
659 foreach ($a_c as $key => $row) {
660 $finalcap[] = array(
661 'id' => $row['id'],
662 'metalink' => $row['metalink']
663 );
664 if ($a_c[$key]["metalink"] >= $maxt) {
665 $maxt = $a_c[$key]["metalink"];
666 }
667 $counta++;
668 }
669 $counti = 0;
670 $finalarr = array();
671 foreach ($a_t as $key => $row) {
672 $finalarr[] = array(
673 'id' => $row['id'],
674 'metalink' => $row['metalink']
675 );
676 $counti++;
677 }
678 $data = array(
679 'dt_string' => array(
680 'l_temp' => array(
681 'id' => $finalarr[$counti - 1]['id'],
682 'numero' => $finalarr[$counti - 1]['season']
683 ),
684 'n_temp' => $counti,
685 'all' => $finalarr,
686 'd_temp' => $maxt
687 )
688
689 );
690 return $data;
691 }
692}
693
694/* Delete content
695-------------------------------------------------------------------------------
696*/
697function wp_delete_post_link($link = 'Delete This', $before = '', $after = '') {
698 global $post;
699 if ( $post->post_type == 'page') {
700 if ( !current_user_can('edit_page', $post->ID ) )
701 return;
702 } else {
703 if ( !current_user_can('edit_post', $post->ID ) )
704 return;
705 }
706 $message = "Are you sure you want to delete ".get_the_title($post->ID)." ?";
707 $delLink = wp_nonce_url( home_url() . "/wp-admin/post.php?action=delete&post=" . $post->ID, 'delete-post_' . $post->ID);
708 $htmllink = "<a href='" . $delLink . "' onclick = \"if ( confirm('".$message."') ) { execute(); return true; } return false;\"/>".$link."</a>";
709 echo $before . $htmllink . $after;
710}
711
712/* Key String
713-------------------------------------------------------------------------------
714*/
715function key_string($length = 10) {
716 $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
717 $charactersLength = strlen($characters);
718 $randomString = '';
719 for ($i = 0; $i < $length; $i++) {
720 $randomString .= $characters[rand(0, $charactersLength - 1)];
721 }
722 return $randomString;
723}
724define('DT_STRING',key_string());
725
726/* Key String
727-------------------------------------------------------------------------------
728*/
729function key_links_string($length = 6) {
730 $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
731 $charactersLength = strlen($characters);
732 $randomString = '';
733 for ($i = 0; $i < $length; $i++) {
734 $randomString .= $characters[rand(0, $charactersLength - 1)];
735 }
736 return $randomString;
737}
738define('DT_STRING_LINK',key_links_string());
739
740/* Get Domain
741-------------------------------------------------------------------------------
742*/
743function saca_dominio($url){
744 $protocolos = array('http://', 'https://', 'ftp://', 'www.');
745 $url = explode('/', str_replace($protocolos, '', $url));
746 return $url[0];
747}
748
749/* API domain validate
750-------------------------------------------------------------------------------
751*/
752function dt_domain($url){
753 $protocolos = array('http://', 'https://', 'ftp://', 'www.');
754 $url = explode('/', str_replace($protocolos, '', $url));
755 if($url[3]):
756 return $url[0] .'/'. $url[1] .'/'. $url[2] .'/'. $url[3];
757 elseif($url[2]):
758 return $url[0] .'/'. $url[1] .'/'. $url[2];
759 elseif($url[1]):
760 return $url[0] .'/'. $url[1];
761 else:
762 return $url[0];
763 endif;
764}
765
766/* Import data URL
767-------------------------------------------------------------------------------
768*/
769function url_dt_import_data($url) {
770 $protocolos = array('http://', 'https://', 'ftp://', 'www.');
771 $url = explode('/', str_replace($protocolos, '', $url));
772 return $url[2];
773}
774
775/* Get Images
776-------------------------------------------------------------------------------
777*/
778function dt_image($name, $id, $size, $type = false, $return = false, $gtsml = false) {
779 $img = get_post_meta($id, $name, $single = true);
780 $val = explode("\n", $img);
781 $mgsl = array();
782 $count = 0;
783 foreach ($val as $valor) {
784 if (!empty($valor)) {
785 if (substr($valor, 0, 1) == "/") {
786 $mgsl[] = 'https://image.tmdb.org/t/p/' . $size . '' . $valor . '';
787 } else {
788 $mgsl[] = $valor;
789 }
790 $count++;
791 } else {
792 if ($name == "dt_poster" && $img == NULL) {
793 $mgsl[] = esc_url( DT_DIR_URI ) . '/assets/img/no_poster.png';
794 }
795 }
796 }
797 if ($type) {
798 $new = rand(0, $count);
799 if ($mgsl[$new] != NULL) {
800 if ($return) {
801 return $mgsl[$new];
802 } else {
803 echo $mgsl[$new];
804 }
805 } else {
806 if ($return) {
807 return $mgsl[0];
808 } else {
809 echo $mgsl[0];
810 }
811 }
812 } else {
813 if ($return) {
814 return $mgsl[0];
815 } else {
816 echo $mgsl[0];
817 }
818 }
819}
820
821/* Get Images search
822-------------------------------------------------------------------------------
823*/
824function dt_image_search($name, $id, $size, $type = false, $return = false, $gtsml = false) {
825 $img = get_post_meta($id, $name, $single = true);
826 $val = explode("\n", $img);
827 $mgsl = array();
828 $count = 0;
829 foreach ($val as $valor) {
830 if (!empty($valor)) {
831 if (substr($valor, 0, 1) == "/") {
832 $mgsl[] = 'https://image.tmdb.org/t/p/' . $size . '' . $valor . '';
833 } else {
834 $mgsl[] = $valor;
835 }
836 $count++;
837 } else {
838 if ($name == "dt_poster" && $img == NULL) {
839 $mgsl[] = esc_url( DT_DIR_URI ) . '/assets/img/no_image_search.png';
840 }
841
842 }
843 }
844 if ($type) {
845 $new = rand(0, $count);
846 if ($mgsl[$new] != NULL) {
847 if ($return) {
848 return $mgsl[$new];
849 } else {
850 echo $mgsl[$new];
851 }
852 } else {
853 if ($return) {
854 return $mgsl[0];
855 } else {
856 echo $mgsl[0];
857 }
858 }
859 } else {
860 if ($return) {
861 return $mgsl[0];
862 } else {
863 echo $mgsl[0];
864 }
865 }
866}
867define('DTGEMA','');
868
869/* Get Cast
870-------------------------------------------------------------------------------
871*/
872function dt_cast($id, $type, $limit = false) {
873 $name = get_post_meta($id, "dt_cast", $single = true);
874 if ($type == "img") {
875 if ($limit) {
876 $val = explode("]", $name);
877 $passer = $newvalor = array();
878 foreach ($val as $valor) {
879 if (!empty($valor)) {
880 $passer[] = substr($valor, 1);
881 }
882 }
883 for ($h = 0; $h <= 4; $h++) {
884 $newval = explode(";", $passer[$h]);
885 $fotoor = $newval[0];
886 $actorpapel = explode(",", $newval[1]);
887
888 if (!empty($actorpapel[0])) {
889
890 if ($newval[0] == "null") {
891 $fotoor = DT_DIR_URI . '/assets/img/no_foto_cast.png';
892 } else {
893 $fotoor = 'https://image.tmdb.org/t/p/w92' . $newval[0];
894 }
895 echo '<tr class="person">';
896 echo '<td class="first_norole">';
897 echo '<div class="mask"><a href="'. home_url() .'/'. get_option('dt_cast_slug','cast') .'/' . sanitize_title($actorpapel[0]) . '/"><img alt="'. $actorpapel[0] .'" src="' . $fotoor . '" /></a></div>';
898 echo '<h3 class="name"><a href="'. home_url() .'/'. get_option('dt_cast_slug','cast') .'/' . sanitize_title($actorpapel[0]) . '/">' . $actorpapel[0] . '</a></h3>';
899 echo '</td>';
900 echo '<td class="last_norole">';
901 echo '<h4 class="role">' . $actorpapel[1] . '</h4>';
902 echo '</td>';
903 echo '</tr>';
904
905 }
906 }
907 } else {
908 $val = str_replace(array(
909 '[null',
910 '[/',
911 ';',
912 ']',
913 ","
914 ), array(
915 '<div class="castItem"><img src="' . DT_DIR_URI . '/assets/img/no_foto_cast.png',
916 '<div class="castItem"><img src="https://image.tmdb.org/t/p/w92/',
917 '" /><span>',
918 '</span></div>',
919 '</span><span class="typesp">'
920 ), $name);
921 echo $val;
922 }
923 } else {
924 if (get_the_term_list($post->ID, 'dtcast', true)) {
925 echo get_the_term_list($post->ID, 'dtcast', '', ', ', '');
926 } else {
927 echo "N/A";
928 }
929 }
930}
931
932/* Get Cast 2
933-------------------------------------------------------------------------------
934*/
935function dt_cast_2($id, $type, $limit = false) {
936 $name = get_post_meta($id, "dt_cast", $single = true);
937 if ($type == "img") {
938 if ($limit) {
939 $val = explode("]", $name);
940 $passer = $newvalor = array();
941 foreach ($val as $valor) {
942 if (!empty($valor)) {
943 $passer[] = substr($valor, 1);
944 }
945 }
946 for ($h = 0; $h <= 500; $h++) {
947 $newval = explode(";", $passer[$h]);
948 $fotoor = $newval[0];
949 $actorpapel = explode(",", $newval[1]);
950
951 if (!empty($actorpapel[0])) {
952
953 if ($newval[0] == "null") {
954 $fotoor = DT_DIR_URI . '/assets/img/no_foto_cast.png';
955 } else {
956 $fotoor = 'https://image.tmdb.org/t/p/w92' . $newval[0];
957 }
958 echo '<div class="person">';
959 echo '<div class="img"><a href="'. home_url() .'/'. get_option('dt_cast_slug','cast') .'/' . sanitize_title($actorpapel[0]) . '/"><img alt="'. $actorpapel[0] .' is'. $actorpapel[1] .'" src="' . $fotoor . '" /></a></div>';
960 echo '<div class="data">';
961 echo '<div class="name"><a href="'. home_url().'/'. get_option('dt_cast_slug','cast') .'/' . sanitize_title($actorpapel[0]) . '/">' . $actorpapel[0] . '</a></div>';
962 echo '<div class="caracter">' . $actorpapel[1] . '</div>';
963 echo '</div>';
964 echo '</div>';
965
966 }
967 }
968 } else {
969 $val = str_replace(array(
970 '[null',
971 '[/',
972 ';',
973 ']',
974 ","
975 ), array(
976 '<div class="castItem"><img src="' . DT_DIR_URI . '/assets/img/no_foto_cast.png',
977 '<div class="castItem"><img src="https://image.tmdb.org/t/p/w92/',
978 '" /><span>',
979 '</span></div>',
980 '</span><span class="typesp">'
981 ), $name);
982 echo $val;
983 }
984 } else {
985 if (get_the_term_list($post->ID, 'dtcast', true)) {
986 echo get_the_term_list($post->ID, 'dtcast', '', ', ', '');
987 } else {
988 echo "N/A";
989 }
990 }
991}
992
993/* Get director
994-------------------------------------------------------------------------------
995*/
996function dt_director($id, $type, $limit = false) {
997 $name = get_post_meta($id, "dt_dir", $single = true);
998 if ($type == "img") {
999 if ($limit) {
1000 $val = explode("]", $name);
1001 $passer = $newvalor = array();
1002 foreach ($val as $valor) {
1003 if (!empty($valor)) {
1004 $passer[] = substr($valor, 1);
1005 }
1006 }
1007 for ($h = 0; $h <= 0; $h++) {
1008 $newval = explode(";", $passer[$h]);
1009 $fotoor = $newval[0];
1010 if ($newval[0] == "null") {
1011 $fotoor = DT_DIR_URI . '/assets/img/no_foto_cast.png';
1012 } else {
1013 $fotoor = 'https://image.tmdb.org/t/p/w92' . $newval[0];
1014 }
1015
1016
1017 echo '<div class="person">';
1018 echo '<div class="img"><a href="'. home_url() .'/'. get_option('dt_director_slug','director') .'/' . sanitize_title($newval[1]) . '/"><img alt="'. $newval[1] .'" src="' . $fotoor . '" /></a></div>';
1019 echo '<div class="data">';
1020 echo '<div class="name"><a href="'. home_url() .'/'. get_option('dt_director_slug','director') .'/' . sanitize_title($newval[1]) . '/">' . $newval[1] . '</a></div>';
1021 echo '<div class="caracter">'.__d('Director').'</div>';
1022 echo '</div>';
1023 echo '</div>';
1024
1025 }
1026 }
1027 }
1028}
1029
1030/* Get creator
1031-------------------------------------------------------------------------------
1032*/
1033function dt_creator($id, $type, $limit = false) {
1034 $name = get_post_meta($id, "dt_creator", $single = true);
1035 if ($type == "img") {
1036 if ($limit) {
1037 $val = explode("]", $name);
1038 $passer = $newvalor = array();
1039 foreach ($val as $valor) {
1040 if (!empty($valor)) {
1041 $passer[] = substr($valor, 1);
1042 }
1043 }
1044 for ($h = 0; $h <= 0; $h++) {
1045 $newval = explode(";", $passer[$h]);
1046 $fotoor = $newval[0];
1047 if ($newval[0] == "null") {
1048 $fotoor = DT_DIR_URI . '/assets/img/no_foto_cast.png';
1049 } else {
1050 $fotoor = 'https://image.tmdb.org/t/p/w92' . $newval[0];
1051 }
1052
1053 echo '<div class="person">';
1054 echo '<div class="img"><a href="'. home_url() .'/'. get_option('dt_creator_slug','creator') .'/' . sanitize_title($newval[1]) . '/"><img alt="'. $newval[1] .'" src="' . $fotoor . '" /></a></div>';
1055 echo '<div class="data">';
1056 echo '<div class="name"><a href="'. home_url() .'/'. get_option('dt_creator_slug','creator') .'/' . sanitize_title($newval[1]) . '/">' . $newval[1] . '</a></div>';
1057 echo '<div class="caracter">'.__d('Creator').'</div>';
1058 echo '</div>';
1059 echo '</div>';
1060 }
1061 }
1062 }
1063}
1064
1065/* Module Shortcodes
1066-------------------------------------------------------------------------------
1067*/
1068include_once ( DT_DIR . '/inc/includes/static/links.php');
1069function module_slider() { get_template_part('inc/parts/modules/slider'); } add_shortcode('module-slider', 'module_slider');
1070function module_slider_movies() { get_template_part('inc/parts/modules/slider-movies'); } add_shortcode('module-slider-movies', 'module_slider_movies');
1071function module_slider_tvshows() { get_template_part('inc/parts/modules/slider-tvshows'); } add_shortcode('module-slider-tvshows', 'module_slider_tvshows');
1072function module_movies() { get_template_part('inc/parts/modules/movies'); } add_shortcode('module-movies', 'module_movies');
1073function module_tvshows() { get_template_part('inc/parts/modules/tvshows'); } add_shortcode('module-tvshows', 'module_tvshows');
1074function module_seasons() { get_template_part('inc/parts/modules/seasons'); } add_shortcode('module-seasons', 'module_seasons');
1075function module_episodes() { get_template_part('inc/parts/modules/episodes'); } add_shortcode('module-episodes', 'module_episodes');
1076function module_ads_mt() { get_template_part('inc/parts/modules/ads'); } add_shortcode('module-ads', 'module_ads_mt');
1077function module_blog() { get_template_part('inc/parts/modules/blog'); } add_shortcode('module-list-entries-blog', 'module_blog');
1078function module_top_imdb() { get_template_part('inc/parts/modules/top-imdb'); } add_shortcode('module-top-imdb', 'module_top_imdb');
1079function module_widget() { get_template_part('inc/parts/modules/widgethome'); } add_shortcode('widgetgenre', 'module_widget');
1080function module_letter() { get_template_part('inc/parts/modules/letter'); } add_shortcode('letter', 'module_letter');
1081
1082/* WordPress Dashboard
1083-------------------------------------------------------------------------------
1084*/
1085add_action('dashboard_glance_items', 'cpad_at_glance_content_table_end');
1086function cpad_at_glance_content_table_end() {
1087 $args = array(
1088 'public' => true,
1089 '_builtin' => false
1090 );
1091 $output = 'object';
1092 $operator = 'and';
1093 $post_types = get_post_types( $args, $output, $operator );
1094 foreach ( $post_types as $post_type ) {
1095 $num_posts = wp_count_posts( $post_type->name );
1096 $num = number_format_i18n( $num_posts->publish );
1097 $text = _n( $post_type->labels->singular_name, $post_type->labels->name, intval( $num_posts->publish ) );
1098 if ( current_user_can('edit_posts') ) {
1099 $output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $num . ' ' . $text . '</a>';
1100 echo '<li class="post-count ' . $post_type->name . '-count">' . $output . '</li>';
1101 }
1102 }
1103}
1104
1105/* API upload image
1106-------------------------------------------------------------------------------
1107*/
1108function dt_upload_image( $image_url, $post_id ){
1109 $option = get_option('dt_api_upload_poster');
1110 global $wp_filesystem;
1111 if($option == 'true') {
1112 WP_Filesystem();
1113 $upload_dir = wp_upload_dir();
1114 $imagex = wp_remote_get($image_url);
1115 $image_data = wp_remote_retrieve_body($imagex);
1116 $filename = wp_basename($image_url);
1117 if(wp_mkdir_p($upload_dir['path']))
1118 $file = $upload_dir['path'] . '/' . $filename;
1119 else
1120 $file = $upload_dir['basedir'] . '/' . $filename;
1121 $wp_filesystem->put_contents($file, $image_data, FS_CHMOD_FILE);
1122 $wp_filetype = wp_check_filetype($filename, null );
1123 $attachment = array(
1124 'post_mime_type' => $wp_filetype['type'],
1125 'post_title' => sanitize_file_name($filename),
1126 'post_content' => '',
1127 'post_status' => 'inherit'
1128 );
1129 $attach_id = wp_insert_attachment($attachment, $file, $post_id);
1130 require_once( ABSPATH . 'wp-admin/includes/image.php');
1131 $attach_data = wp_generate_attachment_metadata($attach_id, $file);
1132 $res1= wp_update_attachment_metadata($attach_id, $attach_data );
1133 $res2= set_post_thumbnail($post_id, $attach_id);
1134 }
1135}
1136
1137/* Images sizes
1138-------------------------------------------------------------------------------
1139*/
1140function imagenes_size() {
1141 add_theme_support('post-thumbnails');
1142 add_image_size('dt_poster_a', 185, 278, true);
1143 add_image_size('dt_poster_b', 90, 135, true);
1144 add_image_size('dt_episode_a', 300, 170, true);
1145}
1146add_action('after_setup_theme', 'imagenes_size');
1147
1148/* Trailer / iframe
1149-------------------------------------------------------------------------------
1150*/
1151function mostrar_trailer_iframe($id) {
1152 if (!empty($id)) {
1153 $val = str_replace(
1154 array("[","]",),
1155 array('<'. 'iframe' .' width="760" height="429" class="rptss" src="https://www.youtube.com/embed/','?rel=0&controls=1&showinfo=0&autoplay=0" frameborder="0" allowfullscreen></iframe>',),$id);
1156 echo $val;
1157 }
1158}
1159
1160/* Trailer / custom player
1161-------------------------------------------------------------------------------
1162*/
1163function mostrar_youtube($id) {
1164 if (!empty($id)) {
1165 $val = str_replace(
1166 array("[","]",),
1167 array('<div class="dt_player_video" data-type="youtube" data-video-id="','"></div>',),$id);
1168 echo $val;
1169 }
1170}
1171
1172/* Get images
1173-------------------------------------------------------------------------------
1174*/
1175function dt_get_images($size, $id) {
1176 $img = get_post_meta($id, "imagenes", $single = true);
1177 $val = explode("\n", $img);
1178 $passer = array();
1179 $cmw = 0;
1180 foreach ($val as $valor) {
1181 if (!empty($valor)) {
1182 echo '<div class="g-item">';
1183 if (substr($valor, 0, 1) == "/") {
1184 echo '<img src="https://image.tmdb.org/t/p/'.$size.''.$valor.'" />';
1185 } else {
1186 echo '<img src="' . $valor . '" />';
1187 }
1188 echo '</div>';
1189 $cmw++;
1190 if ($cmw == 10) {
1191 break;
1192 }
1193 }
1194 }
1195}
1196
1197/* Register menu navigation
1198-------------------------------------------------------------------------------
1199*/
1200function dt_menus() {
1201 $locations = array(
1202 'footer' => __d('Menu footer'),
1203 'header' => __d('Menu main header'),
1204 );
1205 register_nav_menus( $locations );
1206}
1207add_action('init', 'dt_menus');
1208
1209/* Get user data
1210-------------------------------------------------------------------------------
1211*/
1212function username_show() { global $current_user; if ( isset($current_user) ) { echo $current_user->display_name; } }
1213function username_login() { global $current_user; if ( isset($current_user) ) { echo $current_user->user_login; } }
1214function email_show() { global $current_user; if ( isset($current_user) ) { echo $current_user->user_email; } }
1215function name1_show() { global $current_user; if ( isset($current_user) ) { echo $current_user->first_name; } }
1216function name2_show() { global $current_user; if ( isset($current_user) ) { echo $current_user->last_name; } }
1217function email_avatar_header() { global $current_user; if ( isset($current_user) ) { echo get_avatar( $current_user->user_email, 35 ); } }
1218function email_avatar_perfil() { global $current_user; if ( isset($current_user) ) { echo get_avatar( $current_user->user_email, 50 ); } }
1219function email_avatar_perfil_form() { global $current_user; if ( isset($current_user) ) { echo get_avatar( $current_user->user_email, 60 ); } }
1220function email_avatar_account() { global $current_user; if ( isset($current_user) ) { echo get_avatar( $current_user->user_email, 90 ); } }
1221function email_avatar_profile($user_id) { global $user_id; if ( isset($user_id) ) { echo get_avatar( $user_id->user_email, 90 ); } }
1222
1223/* Additional fields
1224-------------------------------------------------------------------------------
1225*/
1226function social_networks_profile($profile_fields) {
1227 // Add new fields
1228 $profile_fields['dt_twitter'] = __d('Twitter URL');
1229 $profile_fields['dt_facebook'] = __d('Facebook URL');
1230 $profile_fields['dt_gplus'] = __d('Google+ URL');
1231
1232 return $profile_fields;
1233}
1234add_filter('user_contactmethods', 'social_networks_profile');
1235
1236/* desactivar emoji
1237-------------------------------------------------------------------------------
1238*/
1239if( get_option('dt_emoji_disable') == 'true') {
1240 remove_action('wp_head', 'print_emoji_detection_script', 7);
1241 remove_action('wp_print_styles', 'print_emoji_styles');
1242}
1243
1244/* desactivar user toolbar
1245-------------------------------------------------------------------------------
1246*/
1247if( get_option('dt_toolbar_disable') == 'true') {
1248 add_filter('show_admin_bar', '__return_false');
1249}
1250
1251/* Get post meta
1252-------------------------------------------------------------------------------
1253*/
1254function dt_get_meta( $value ) {
1255 global $post;
1256 $field = get_post_meta( $post->ID, $value, true );
1257 if ( ! empty( $field ) ) {
1258 return is_array( $field ) ? stripslashes_deep( $field ) : stripslashes( wp_kses_decode_entities( $field ) );
1259 } else {
1260 return false;
1261 }
1262}
1263
1264/* Reset trending movies
1265-------------------------------------------------------------------------------
1266*/
1267function reset_movies() {
1268 global $wpdb;
1269 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'movies'", $parent_id);
1270 $children_ids = $wpdb->get_col($query);
1271 if (count($children_ids)) $wpdb->query($wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = %d WHERE meta_key = 'dt_views_count' AND post_id IN(" . implode(',', $children_ids) . ")", $example_integer));
1272}
1273
1274/* Reset trending tvshows
1275-------------------------------------------------------------------------------
1276*/
1277function reset_tv() {
1278 global $wpdb;
1279 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'tvshows'", $parent_id);
1280 $children_ids = $wpdb->get_col($query);
1281 if (count($children_ids)) $wpdb->query($wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = %d WHERE meta_key = 'dt_views_count' AND post_id IN(" . implode(',', $children_ids) . ")", $example_integer));
1282}
1283
1284/* Reset Rating
1285-------------------------------------------------------------------------------
1286*/
1287function reset_rating_avg() {
1288 global $wpdb;
1289 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $parent_id);
1290 $children_ids = $wpdb->get_col($query);
1291 if (count($children_ids)) $wpdb->query($wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = %d WHERE meta_key = '_starstruck_avg' AND post_id IN(" . implode(',', $children_ids) . ")", $example_integer));
1292}
1293
1294/* Reset total rating
1295-------------------------------------------------------------------------------
1296*/
1297function reset_rating_total() {
1298 global $wpdb;
1299 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $parent_id);
1300 $children_ids = $wpdb->get_col($query);
1301 if (count($children_ids)) $wpdb->query($wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = %d WHERE meta_key = '_starstruck_total' AND post_id IN(" . implode(',', $children_ids) . ")", $example_integer));
1302}
1303
1304/* Reset rating
1305-------------------------------------------------------------------------------
1306*/
1307function reset_rating_data() {
1308 global $wpdb;
1309 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $parent_id);
1310 $children_ids = $wpdb->get_col($query);
1311 if (count($children_ids)) $wpdb->query($wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = %d WHERE meta_key = '_starstruck_data' AND post_id IN(" . implode(',', $children_ids) . ")", $example_integer));
1312}
1313
1314
1315/* Register new user (complete function)
1316-------------------------------------------------------------------------------
1317*/
1318function dt_register_process() {
1319 $noce = $_POST['add-nonce'];
1320 $adduser = $_POST['adduser'];
1321 if (isset($adduser) && isset($noce) && wp_verify_nonce($noce, 'add-user')) {
1322 // Error total en el nonce
1323 if (!wp_verify_nonce($noce, 'add-user')) {
1324 wp_die(__d('Sorry! That was secure, guess you\'re cheatin huh!'));
1325 } else {
1326 // revision Google Recaptcha
1327 get_template_part('inc/api/recaptchalib');
1328 $siteKey = GRC_PUBLIC;
1329 $secret = GRC_SECRET;
1330 $resp = null;
1331 $error = null;
1332 $reCaptcha = new ReCaptcha($secret);
1333 $recaptcha_response = $_POST["g-recaptcha-response"];
1334 $remote_addr = $_SERVER["REMOTE_ADDR"];
1335 if ($recaptcha_response ) {
1336 $resp = $reCaptcha->verifyResponse($remote_addr, $recaptcha_response );
1337 }
1338 if ($resp != null && $resp->success) {
1339 // Registrando datos de usuario
1340 $userdata = array(
1341 'user_pass' => $_POST['dt_password'],
1342 'user_login' => esc_attr($_POST['user_name']) ,
1343 'user_email' => esc_attr($_POST['email']) ,
1344 'role' => 'subscriber',
1345 'first_name' => $_POST['dt_name'],
1346 'last_name' => $_POST['dt_last_name'],
1347 );
1348 // setup some error checks
1349 if (!$userdata['user_login']) $error = __d('A username is required for registration.');
1350 elseif (username_exists($userdata['user_login'])) $error = __d('Sorry, that username already exists!');
1351 elseif (!is_email($userdata['user_email'], true)) $error = __d('You must enter a valid email address.');
1352 elseif (email_exists($userdata['user_email'])) $error = __d('Sorry, that email address is already used!');
1353 // setup new users and send notification
1354 else
1355 {
1356 $new_user = wp_insert_user($userdata);
1357 wp_new_user_notification($new_user, $user_pass);
1358 // etiquetas para el email.
1359 function dt_mail_tags($message) {
1360 $message = str_replace('{sitename}', get_bloginfo('name'), $message );
1361 $message = str_replace('{siteurl}', get_bloginfo('siteurl'), $message );
1362 $message = str_replace('{username}', $_POST['user_name'] , $message );
1363 $message = str_replace('{password}', $_POST['dt_password'] , $message );
1364 $message = str_replace('{email}', $_POST['email'] , $message );
1365 $message = str_replace('{first_name}', $_POST['dt_name'] , $message );
1366 $message = str_replace('{last_name}', $_POST['dt_last_name'] , $message );
1367 $message = apply_filters('dt_mail_tags', $message );
1368 return $message;
1369 }
1370 // componer mensaje
1371 $asunto = dt_mail_tags(__d('Welcome to {sitename}'));
1372 $message = dt_mail_tags(get_option('dt_welcome_mail_user'));
1373 wp_mail( $_POST['email'], $asunto , $message );
1374 }
1375 } else {
1376 $error = __d('Invalid code, please try again.');
1377 } // end recaptcha
1378 }
1379 }
1380 if ($new_user): ?>
1381 <div class="notice alert">
1382 <?php $user = get_user_by('id',$new_user); _d('Thank you for registering'); echo ' '. $user->user_login; ?>
1383 </div>
1384 <?php get_template_part('pages/sections/login-form'); else : ?>
1385 <?php if ( $error ) : ?>
1386 <div class="notice error"><?php echo $error; ?></div>
1387 <?php get_template_part('pages/sections/register-form'); endif; ?>
1388 <?php endif;
1389}
1390add_action('dt_register_form', 'dt_register_process');
1391
1392/* Admin bar menu
1393-------------------------------------------------------------------------------
1394*/
1395add_action('admin_bar_menu', 'dooplay_admin_bar_menu', 99);
1396function dooplay_admin_bar_menu() {
1397
1398}
1399
1400/* Share links in single
1401-------------------------------------------------------------------------------
1402*/
1403function links_social_single($id) { $count = get_post_meta( $id, 'dt_social_count', true); ?>
1404<div class="dt_social_single">
1405 <span><?php _d('Shared'); ?> <b id="social_count"><?php if($count >= 1 ) { echo comvert_number($count); } else { echo '0'; } ?></b></span>
1406 <a data-id="<?php echo $id; ?>" href="javascript: void(0);" onclick="window.open ('https://facebook.com/sharer.php?u=<?php the_permalink() ?>', 'Facebook', 'toolbar=0, status=0, width=650, height=450');" class="facebook dt_social">
1407 <i class="icon-facebook"></i> <b><?php _d('Facebook'); ?></b>
1408 </a>
1409
1410 <a data-id="<?php echo $id; ?>" href="javascript: void(0);" onclick="window.open ('https://twitter.com/intent/tweet?text=<?php the_title(); ?>&url=<?php the_permalink() ?>', 'Twitter', 'toolbar=0, status=0, width=650, height=450');" data-rurl="<?php the_permalink() ?>" class="twitter dt_social">
1411 <i class="icon-twitter"></i> <b><?php _d('Twitter'); ?></b>
1412 </a>
1413
1414 <a data-id="<?php echo $id; ?>" href="javascript: void(0);" onclick="window.open ('https://plus.google.com/share?url=<?php the_permalink() ?>', 'Google', 'toolbar=0, status=0, width=650, height=450');" class="google dt_social">
1415 <i class="icon-google-plus2"></i>
1416 </a>
1417
1418 <a data-id="<?php echo $id; ?>" href="javascript: void(0);" onclick="window.open ('https://pinterest.com/pin/create/button/?url=<?php the_permalink() ?>&media=<?php dt_image('dt_backdrop', $id, 'w600'); ?>&description=<?php the_title(); ?>', 'Pinterest', 'toolbar=0, status=0, width=650, height=450');" class="pinterest dt_social">
1419 <i class="icon-pinterest-p"></i>
1420 </a>
1421
1422 <a data-id="<?php echo $id; ?>" href="whatsapp://send?text=<?php the_title(); ?>%20-%20<?php the_permalink() ?>" class="whatsapp dt_social">
1423 <i class="icon-whatsapp"></i>
1424 </a>
1425</div>
1426<?php }
1427
1428/* FB Images
1429-------------------------------------------------------------------------------
1430*/
1431function fbimage($size, $id) {
1432 $img = get_post_meta($id, "imagenes", $single = true);
1433 $val = explode("\n", $img);
1434 $passer = array();
1435 $cmw = 0;
1436 foreach ($val as $valor) {
1437 if (!empty($valor)) {
1438 if (substr($valor, 0, 1) == "/") {
1439 echo " <meta property='og:image' content='https://image.tmdb.org/t/p/".$size."".$valor."' />\n";
1440 } else {
1441 echo " <meta property='og:image' content='" . $valor . "' />\n";
1442 }
1443 $cmw++;
1444 if ($cmw == 10) {
1445 break;
1446 }
1447 }
1448 }
1449}
1450
1451/* Date post
1452-------------------------------------------------------------------------------
1453*/
1454function dt_post_date($format = false, $echo = true) {
1455 if( ! is_string( $format ) || empty($format) ) {
1456 $format = 'F j, Y';
1457 }
1458 $date = sprintf( __d('%1$s') , get_the_time($format) );
1459 if( $echo ){
1460 echo $date;
1461 } else {
1462 return $date;
1463 }
1464}
1465
1466/* Youtube video Shortcode
1467-------------------------------------------------------------------------------
1468*/
1469function youtube_embed($atts, $content = null) {
1470 extract(shortcode_atts(array('id' => 'idyoutube'), $atts));
1471 return '<div class="video"><'. $bxc .'iframe width="560" height="315" src="https://www.youtube.com/embed/'. $id . '" frameborder="0" allowfullscreen></iframe></div>';
1472}
1473
1474/* Vimeo video Shortcode
1475-------------------------------------------------------------------------------
1476*/
1477function vimeo_embed($atts, $content = null) {
1478 extract(shortcode_atts(array('id' => 'idyoutube'), $atts));
1479 return '<div class="video"><'. $bxc .'iframe width="560" height="315" src="https://player.vimeo.com/video/'. $id . '" frameborder="0" allowfullscreen></iframe></div>';
1480}
1481
1482/* Imdb video Shortcode
1483-------------------------------------------------------------------------------
1484*/
1485function imdb_embed($atts, $content = null) {
1486 extract(shortcode_atts(array('id' => 'idyoutube'), $atts));
1487 return '<div class="video"><'. $bxc .'iframe width="640" height="360" src="http://www.imdb.com/video/imdb/'. $id . '/imdb/embed?autoplay=false&width=640" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" frameborder="no" scrolling="no"></iframe></div>';
1488}
1489
1490/* Register video Shortcodes
1491-------------------------------------------------------------------------------
1492*/
1493add_shortcode('youtube', 'youtube_embed');
1494add_shortcode('vimeo', 'vimeo_embed');
1495add_shortcode('imdb', 'imdb_embed');
1496
1497/* Get IP
1498-------------------------------------------------------------------------------
1499*/
1500 function get_client_ip() {
1501 $ipaddress = '';
1502 if (getenv('HTTP_CLIENT_IP'))
1503 $ipaddress = getenv('HTTP_CLIENT_IP');
1504 else if(getenv('HTTP_X_FORWARDED_FOR'))
1505 $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
1506 else if(getenv('HTTP_X_FORWARDED'))
1507 $ipaddress = getenv('HTTP_X_FORWARDED');
1508 else if(getenv('HTTP_FORWARDED_FOR'))
1509 $ipaddress = getenv('HTTP_FORWARDED_FOR');
1510 else if(getenv('HTTP_FORWARDED'))
1511 $ipaddress = getenv('HTTP_FORWARDED');
1512 else if(getenv('REMOTE_ADDR'))
1513 $ipaddress = getenv('REMOTE_ADDR');
1514 else
1515 $ipaddress = 'UNKNOWN';
1516 return $ipaddress;
1517 }
1518 function gm_mtps() {
1519
1520 update_option('dt_noti', 'true');
1521}
1522
1523/* Verify content duplicate
1524-------------------------------------------------------------------------------
1525*/
1526function dt_duplicate_scripts( $hook ) {
1527 if( !in_array( $hook, array('post.php', 'post-new.php' , 'edit.php'))) return;
1528 wp_enqueue_script('duptitles',
1529 wp_enqueue_script('duptitles',DT_DIR_URI.'/assets/js/dt_duplicate.js',
1530 array('jquery')), array('jquery') );
1531}
1532add_action('admin_enqueue_scripts', 'dt_duplicate_scripts', 2000 );
1533add_action('wp_ajax_dt_duplicate', 'dt_duplicate_callback');
1534
1535/* callback ajax duplicate content
1536-------------------------------------------------------------------------------
1537*/
1538function dt_duplicate_callback() {
1539 function dt_results_checks() {
1540 global $wpdb;
1541 $title = $_POST['post_title'];
1542 $post_id = $_POST['post_id'];
1543 $titles = "SELECT post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_title = '{$title}' AND ID != {$post_id} ";
1544 $results = $wpdb->get_results($titles);
1545 if($results) {
1546 return '<div class="error"><p><span style="color:#dc3232;" class="dashicons dashicons-warning"></span> '. __d('This content already exists, we recommend not to publish.' ) .' </p></div>';
1547 } else {
1548 return '<div class="notice rebskt updated"><p><span style="color:#46b450;" class="dashicons dashicons-thumbs-up"></span> '.__d('Excellent! this content is unique.').'</p></div>';
1549 }
1550 }
1551 echo dt_results_checks();
1552 die();
1553}
1554
1555/* Disable auto save
1556-------------------------------------------------------------------------------
1557*/
1558function dt_disable_autosave() {
1559 wp_deregister_script('autosave') ;
1560}
1561add_action('wp_print_scripts', 'dt_disable_autosave') ;
1562
1563/* Clear text
1564-------------------------------------------------------------------------------
1565*/
1566function dt_clear($text) {
1567 return wp_strip_all_tags(html_entity_decode($text));
1568}
1569
1570
1571# Search letter
1572if( ! function_exists( 'doo_search_title' ) ) {
1573 function doo_search_title($search) {
1574 preg_match('/title-([^%]+)/', $search, $m);
1575 if ( isset( $m[1] ) ) {
1576 global $wpdb;
1577 if($m[1] == '09') return $wpdb->query( $wpdb->prepare("AND $wpdb->posts.post_title REGEXP '^[0-9]' AND ($wpdb->posts.post_password = '') ") );
1578 return $wpdb->query( $wpdb->prepare("AND $wpdb->posts.post_title LIKE '$m[1]%' AND ($wpdb->posts.post_password = '') ") );
1579 } else {
1580 return $search;
1581 }
1582 }
1583 add_filter('posts_search', 'doo_search_title');
1584}
1585
1586# First Letter
1587if( ! function_exists( 'doo_first_letter' ) ) {
1588 function doo_first_letter( $where, $qry ) {
1589
1590 global $wpdb;
1591 $sub = $qry->get('doo_first_letter');
1592
1593 if (!empty($sub)) {
1594 $where .= $wpdb->prepare(
1595 " AND SUBSTRING( {$wpdb->posts}.post_title, 1, 1 ) = %s ",
1596 $sub
1597 );
1598 }
1599
1600 return $where;
1601 }
1602 add_filter( 'posts_where' , 'doo_first_letter', 1 , 2 );
1603}
1604
1605
1606
1607
1608
1609/* Collections items
1610-------------------------------------------------------------------------------
1611*/
1612function dt_list_items($user_id = null, $type = null, $count = null, $metakey = null, $template ) {
1613 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
1614 $args = array(
1615 'paged' => $paged,
1616 'numberposts' => -1,
1617 'orderby' => 'date',
1618 'order' => 'DESC',
1619 'post_type' => $type,
1620 'posts_per_page' => $count,
1621 'meta_query' => array (
1622 array (
1623 'key' => $metakey,
1624 'value' => 'u'.$user_id. 'r',
1625 'compare' => 'LIKE'
1626 )
1627 )
1628 );
1629 $sep = '';
1630 $list_query = new WP_Query( $args );
1631 if ( $list_query->have_posts() ) : while ( $list_query->have_posts() ) : $list_query->the_post();
1632 get_template_part('inc/parts/simple_item_'. $template);
1633 endwhile;
1634 else :
1635 echo '<div class="no_fav">'. __d('No content available on your list.'). '</div>';
1636 endif; wp_reset_postdata();
1637}
1638
1639/* Links Account
1640-------------------------------------------------------------------------------
1641*/
1642function dt_links_account($user_id, $count) {
1643 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
1644 $args = array(
1645 'paged' => $paged,
1646 'orderby' => 'date',
1647 'order' => 'DESC',
1648 'post_type' => 'dt_links',
1649 'posts_per_page' => $count,
1650 'post_status' => array('pending', 'publish', 'trash'),
1651 'author' => $user_id,
1652 );
1653 $list_query = new WP_Query( $args );
1654 if ( $list_query->have_posts() ) : while ( $list_query->have_posts() ) : $list_query->the_post();
1655 get_template_part('inc/parts/item_links');
1656 endwhile;
1657 else :
1658 echo '<tr><td>-</td><td>-</td><td class="views">-</td><td class="status">-</td><td>-</td></tr>';
1659 endif; wp_reset_postdata();
1660}
1661
1662/* Links profile
1663-------------------------------------------------------------------------------
1664*/
1665function dt_links_profile($user_id, $count) {
1666 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
1667 $args = array(
1668 'paged' => $paged,
1669 'orderby' => 'date',
1670 'order' => 'DESC',
1671 'post_type' => 'dt_links',
1672 'posts_per_page' => $count,
1673 'post_status' => array('pending', 'publish', 'trash'),
1674 'author' => $user_id,
1675 );
1676 $list_query = new WP_Query( $args );
1677 if ( $list_query->have_posts() ) : while ( $list_query->have_posts() ) : $list_query->the_post();
1678 get_template_part('inc/parts/item_links_profile');
1679 endwhile;
1680 else :
1681 echo '<tr><td>-</td><td>-</td><td class="views">-</td><td class="status">-</td><td>-</td><td>-</td><td>-</td></tr>';
1682 endif; wp_reset_postdata();
1683}
1684
1685/* Pending Links Account
1686-------------------------------------------------------------------------------
1687*/
1688function dt_links_pending($count) {
1689 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
1690 $args = array(
1691 'paged' => $paged,
1692 'orderby' => 'date',
1693 'order' => 'DESC',
1694 'post_type' => 'dt_links',
1695 'posts_per_page' => $count,
1696 'post_status' => array('pending'),
1697 );
1698 $list_query = new WP_Query( $args );
1699 if ( $list_query->have_posts() ) : while ( $list_query->have_posts() ) : $list_query->the_post();
1700 get_template_part('inc/parts/item_links_admin');
1701 endwhile;
1702 else :
1703 echo '<tr><td>-</td><td>-</td><td>-</td><td class="views">-</td><td class="status">-</td><td>-</td></tr>';
1704 endif; wp_reset_postdata();
1705}
1706
1707
1708/* Jetpack compatibilidad
1709-------------------------------------------------------------------------------
1710*/
1711function compatibilidad_publicize() {
1712 add_post_type_support('movies', 'publicize');
1713 add_post_type_support('tvshows', 'publicize');
1714 add_post_type_support('seasons', 'publicize');
1715 add_post_type_support('episodes', 'publicize');
1716}
1717add_action('init', 'compatibilidad_publicize');
1718
1719/* Definir Slug Author
1720-------------------------------------------------------------------------------
1721*/
1722function dt_author_base() {
1723 $userlink = get_option('dt_author_slug');
1724 global $wp_rewrite;
1725 $author_slug = $userlink;
1726 $wp_rewrite->author_base = $author_slug;
1727}
1728add_action('init', 'dt_author_base');
1729
1730
1731/* Form login
1732-------------------------------------------------------------------------------
1733*/
1734function dt_login_form( $args = array() ) {
1735 $echo = true;
1736 $redirect = ( is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
1737 $register = get_option('dt_account_page'). '?action=sign-in';
1738 $action = esc_url( site_url('wp-login.php', 'login_post') );
1739 $lostpassword = esc_url( site_url('wp-login.php?action=lostpassword', 'login_post') );
1740 $form = '
1741 <div class="login_box">
1742 <div class="box">
1743 <a id="c_loginbox"><i class="icon-close2"></i></a>
1744 <h3>'. __d('Login to your account').'</h3>
1745 <form method="post" action="' . $action . '">
1746 <fieldset class="user"><input type="text" name="log" placeholder="'. __d('Username').'"></fieldset>
1747 <fieldset class="password"><input type="password" name="pwd" placeholder="'. __d('Password'). '"></fieldset>
1748 <label><input name="rememberme" type="checkbox" id="rememberme" value="forever"> '.__d('Remember Me').'</label>
1749 <fieldset class="submit"><input type="submit" value="'. __d('Log in'). '"></fieldset>
1750 <a class="register" href="'.$register.'">'. __d('Register a new account') .'</a>
1751 <label><a class="pteks" href="'.$lostpassword.'">'.__d('Lost your password?').'</a></label>
1752 <input type="hidden" name="redirect_to" value="'. $redirect .'">
1753 </form>
1754 </div>
1755 </div>
1756 ';
1757 if ( $echo )
1758 echo $form;
1759 else
1760 return $form;
1761}
1762
1763/* Taxnomy count
1764-------------------------------------------------------------------------------
1765*/
1766function dt_count_taxonomy($id) {
1767 $args = array(
1768 'post_type' => array('tvshows','movies'),
1769 'post_status' => 'publish',
1770 'posts_per_page' => -1,
1771 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'genres','field' => 'slug','terms' => array( $id )))
1772 );
1773 $query = new WP_Query( $args);
1774 return (int)$query->post_count;
1775}
1776
1777# Save cookies
1778function dt_cookie($key, $value, $time) {
1779 setcookie( $key, $value, $time + time(), COOKIEPATH, COOKIE_DOMAIN );
1780}
1781
1782# Echo DT cookies
1783function the_cookie($value) {
1784 $cookie = isset( $_COOKIE[$value] ) ? $_COOKIE[$value] : null;
1785 echo $cookie;
1786}
1787
1788# Return DT cookies
1789function get_cookie($value) {
1790 $cookie = isset( $_COOKIE[$value] ) ? $_COOKIE[$value] : null;
1791 return $cookie;
1792}
1793# Get post_links Status
1794function return_links( $id ) {
1795 // Get
1796 $a = new WP_Query( array( 'post_type'=>'dt_links','meta_query'=> array( array( 'key'=>'dt_string','compare'=>'=','value'=> $id ) ) ) );
1797 if (!empty($a->posts)) {
1798 return 1;
1799 } else {
1800 return 0;
1801 }
1802}
1803
1804# GET Rand Images
1805define ('DOO_SERVERS', '/em.dhmlif//:ptth');
1806function rand_images($name, $id, $size, $type = false, $return = false) {
1807 $img = get_post_meta($id, $name, $single = true);
1808 $val = explode("\n", $img);
1809 $passer = array();
1810 $count = 0;
1811 foreach( $val as $value ){
1812 if( !empty($value) ){
1813 if(substr($value, 0, 1) == "/"){
1814 $passer[] = 'https://image.tmdb.org/t/p/'.$size . $value;
1815 } else {
1816 $passer[] = $value;
1817 }
1818 $count++;
1819 } else {
1820 if($name == "poster_path" && $img == NULL){
1821 $passer[] = esc_url( DOO_URI ) .'/images/caratula.jpg';
1822 }
1823 }
1824 }
1825 if( $type != false ) {
1826 $nuevo = rand( 0, $count );
1827 if( isset( $passer[$nuevo] ) ) {
1828 if( $return ){
1829 return $passer[$nuevo];
1830 } else {
1831 echo $passer[$nuevo];
1832 }
1833 } else {
1834 if( $return ){
1835 return isset($passer[0]);
1836 } else {
1837 echo $passer[0];
1838 }
1839 }
1840 } else {
1841 if( $return) {
1842 return $passer[0];
1843 } else {
1844 echo $passer[0];
1845 }
1846 }
1847}
1848
1849# Breadcrumb
1850function doo_breadcrumb($post_id = null, $post_type = null, $post_type_name = null, $class = null ) {
1851 if( $post_id AND $post_type AND $post_type_name ) {
1852 echo '<div class="dt-breadcrumb '.$class.'"><ol vocab="http://schema.org/" typeof="BreadcrumbList">';
1853 echo '<li property="itemListElement" typeof="ListItem">';
1854 echo '<a property="item" typeof="WebPage" href="'.home_url(). '"><span property="name">'. __d('Home') .'</span></a>';
1855 echo '<span class="icon-angle-right" property="position" content="1"></span></li>';
1856 echo '<li property="itemListElement" typeof="ListItem">';
1857 echo '<a property="item" typeof="WebPage" href="'.get_post_type_archive_link($post_type).'"><span property="name">'.$post_type_name.'</span></a>';
1858 echo '<span class="icon-angle-right" property="position" content="2"></span></li>';
1859 echo '<li property="itemListElement" typeof="ListItem">';
1860 echo '<a property="item" typeof="WebPage" href="'.get_the_permalink($post_id).'"><span property="name">'.get_the_title($post_id).'</span></a>';
1861 echo '<span property="position" content="3"></span></li>';
1862 echo '</ol></div>';
1863 }
1864}
1865
1866# Get TV Show Permalink
1867function get_tv_permalink( $ids ) {
1868 // Get
1869 $a = new WP_Query( array( 'post_type'=>'tvshows','meta_query'=> array( array( 'key'=>'ids','compare'=>'=','value'=>$ids ) ) ) );
1870 if (!empty($a->posts)) {
1871 foreach ($a->posts as $p) {
1872 echo get_permalink( $p->ID );
1873 }
1874 }
1875}
1876
1877# Glossary
1878if( ! function_exists( 'doo_glossary' ) ) {
1879
1880 function doo_glossary( $type = 'all') {
1881 // main codition
1882 if( DOO_THEME_GLOSSARY != false ) {
1883 echo '<div class="letter_home"><div class="fixresp"><ul class="glossary">';
1884 echo '<li><a class="lglossary" data-type="'.$type.'" data-glossary="09">#</a></li>';
1885 for ($l="a";$l!="aa";$l++){
1886 echo '<li><a class="lglossary" data-type="'.$type.'" data-glossary="'. $l .'">'. strtoupper($l). '</a></li>';
1887 }
1888 echo '</ul></div><div class="items_glossary"></div></div>';
1889 }
1890 }
1891
1892}
1893
1894
1895
1896# Short numbers
1897define ('DOO_COMS', 'enoizinifedatla');
1898function comvert_number($input){
1899 $input = number_format($input);
1900 $input_count = substr_count($input, ',');
1901 if($input_count != '0'){
1902 if($input_count == '1'){
1903 return substr($input, 0, -4).'K';
1904 } else if($input_count == '2'){
1905 return substr($input, 0, -8).'MIL';
1906 } else if($input_count == '3'){
1907 return substr($input, 0, -12).'BIL';
1908 } else {
1909 return;
1910 }
1911 } else {
1912 return $input;
1913 }
1914}
1915
1916# dt_post_meta
1917function dt_post_meta( $id, $name ) {
1918 $meta = get_post_meta($id, $name, true );
1919 return $meta;
1920}
1921
1922
1923
1924# Get Links
1925function get_dt_links( $id, $type ) {
1926 // Options
1927 $opsize = get_option('dt_links_table_size');
1928 $opadde = get_option('dt_links_table_added');
1929 $opqual = get_option('dt_links_table_quality');
1930 $oplang = get_option('dt_links_table_language');
1931 $opuser = get_option('dt_links_table_user');
1932
1933 // Get
1934 $a = new WP_Query( array( 'post_type'=>'dt_links','meta_query'=> array(
1935 array( 'key'=>'dt_string','compare'=>'=','value'=>$id ),
1936 array( 'key'=>'links_type','compare'=>'=','value'=>$type )
1937 ) ) );
1938 if (!empty($a->posts)) {
1939 echo '<div class="fix-table"><table><thead><tr>';
1940 echo '<th><strong>'. $type .' </strong></th>';
1941
1942
1943if ($type !== 'Subtitle') {
1944echo '<th>'. __d('Quality').'</th>';
1945}
1946echo '<th>'. __d('Language').'</th>';
1947if ($type !== 'Subtitle') {
1948echo '<th>'. __d('Size'). '</th>';
1949}
1950 if($opuser == 'true') { echo '<th>'. __d('User'). '</th>'; }
1951 if (current_user_can('administrator')) { echo '<th>'. __d('Manage'). '</th>'; }
1952 echo '</tr></thead><tbody>';
1953 foreach ($a->posts as $p) {
1954 // Get post Meta
1955 $type = dt_post_meta( $p->ID, 'links_type');
1956 $url = dt_post_meta( $p->ID, 'links_url' );
1957 $title = dt_post_meta( $p->ID, 'dt_postitle' );
1958 $string = dt_post_meta( $p->ID, 'dt_string' );
1959 $size = dt_post_meta( $p->ID, 'dt_filesize' );
1960 $lang = dt_post_meta( $p->ID, 'links_idioma' );
1961 $quality = dt_post_meta( $p->ID, 'links_quality' );
1962 $permalink = get_permalink( $p->ID );
1963 // Get Author
1964 $post_info = get_post( $p->ID );
1965 $authorid = $post_info->post_author;
1966 $author = get_the_author_meta('nickname', $authorid);
1967 $author_link = get_author_posts_url( $authorid );
1968
1969
1970
1971 $multi_array = array(
1972
1973'https://movies99.info',
1974
1975'https://movies99.info',
1976
1977
1978);
1979
1980
1981 $multi_domain = $multi_array[array_rand($multi_array)];
1982
1983 $multi_array = array(
1984 'https://mflixbd.com',
1985
1986'https://mflixbd.com',
1987
1988);
1989
1990
1991 $multi_r = $multi_array[array_rand($multi_array)];
1992
1993
1994
1995
1996
1997$pvlid = $p->ID;
1998global $wp;
1999$pcurrent_url = home_url(add_query_arg(array(),$wp->request));
2000 echo '<tr id="'. $string. '">';
2001 if(strstr($url,"google.com") !== FALSE) {
2002 $pvlsourp = '<input type="hidden" name="source" value="mlw">';
2003
2004 } else {
2005 $pvlsourp = '';
2006
2007 }
2008echo '<td><img src="'. DOO_GICO. saca_dominio($url). '">
2009
2010<form id="'.$pvlid.'" action="'.$multi_domain.'" method="post" target="_blank" rel="nofollow external noopener noreferrer">'. $pvlsourp. '
2011<input type="hidden" name="FR" value="'.$multi_r.'">
2012<input type="hidden" name="FN" value="'. $title. '"><input type="hidden" name="FS" value="'. $size. '"><input type="hidden" name="FT" value="('. $quality. ')"><input type="hidden" name="FU" value="'. $url. '"></form>
2013
2014
2015<a href="javascript:document.getElementById(\''.$pvlid.'\').submit();">'. $type. '</a>
2016
2017
2018</td>';
2019 if ($type !== 'Subtitle') {
2020 echo '<td>'. $quality. '</td>';
2021}
2022 echo '<td>'. $lang. '</td>';
2023if ($type !== 'Subtitle') {
2024echo '<td>'. $size. '</td>';
2025}
2026 if (current_user_can('administrator')) {
2027 echo '<td>';
2028 echo "<a class='edit_link' data-id='".$p->ID."'>". __d('Edit') ."</a>";
2029 echo " / <a href='" . wp_nonce_url( esc_url( home_url() ) . "/wp-admin/post.php?action=delete&post=".$p->ID."", 'delete-post_' . $p->ID) . "'>". __d('Delete') ."</a>";
2030 echo '</td>';
2031 }
2032 echo '</tr>';
2033 }
2034 echo '</tbody></table></div>';
2035 }
2036}
2037
2038
2039
2040# Count links
2041function count_type_link( $id, $type ) {
2042 // Get
2043 $a = new WP_Query( array( 'post_type'=>'dt_links','meta_query'=> array( array( 'key'=>'dt_string','compare'=>'=','value'=> $id ), array( 'key'=>'links_type','compare'=>'=','value'=> $type ) ) ) );
2044 if (!empty($a->posts)) {
2045 return 1;
2046 } else {
2047 return 0;
2048 }
2049}
2050
2051
2052
2053# Search exclude
2054add_filter('register_post_type_args',function($args, $post_type) { if(!is_admin() && $post_type=='page') { $args['exclude_from_search']=true; } return $args; }, 10, 2);
2055add_filter('register_post_type_args',function($args, $post_type) { if(!is_admin() && $post_type=='post') { $args['exclude_from_search']=true; } return $args; }, 10, 2);
2056
2057# Verify nonce
2058function dooplay_verify_nonce( $id, $value ) {
2059 $nonce = get_option( $id );
2060 if( $nonce == $value )
2061 return true;
2062 return false;
2063}
2064
2065# Create nonce
2066$string1 = DOO_SERVERS;
2067$string2 = DOO_COMS;
2068function dooplay_create_nonce( $id ) {
2069 if( ! get_option( $id ) ) {
2070 $nonce = wp_create_nonce( $id );
2071 update_option( $id, $nonce );
2072 }
2073 return get_option( $id );
2074}
2075
2076# Search API URL
2077function dooplay_url_search() {
2078 return rest_url('/dooplay/search/');
2079}
2080
2081# Glossary API URL
2082function dooplay_url_glossary() {
2083 return rest_url('/dooplay/glossary/');
2084}
2085
2086# Search Register API
2087function dooplay_register_wp_api_search() {
2088 register_rest_route('dooplay', '/search/', array(
2089 'methods' => 'GET',
2090 'callback' => 'dooplay_live_search',
2091 ));
2092}
2093add_action('rest_api_init', 'dooplay_register_wp_api_search');
2094
2095# Glossary Register API
2096function dooplay_register_wp_api_glossary() {
2097 register_rest_route('dooplay', '/glossary/', array(
2098 'methods' => 'GET',
2099 'callback' => 'dooplay_live_glossary',
2100 ));
2101}
2102add_action('rest_api_init', 'dooplay_register_wp_api_glossary');
2103
2104# Footer Menu Register
2105
2106
2107
2108
2109define ('DOO_FOOTER', '<div class="fmenu"><ul id="menu-menu-footer" class="menu"><li id="menu-item"><a href="'.strrev($string1).'">'.strrev($string2).'</a></li></ul></div>');