Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.35 KB | None | 0 0
  1. <?php
  2.  
  3. add_shortcode( 'themeum_all_movies', function($atts, $content = null) {
  4.  
  5. extract(shortcode_atts(array(
  6. 'category' => 'themeumall',
  7. 'number' => '10',
  8. 'column' => '3',
  9. 'show_top' => 'yes',
  10. 'class' => '',
  11. ), $atts));
  12.  
  13.  
  14. global $post;
  15. $posts = 0;
  16. global $wpdb;
  17. $output = $args = $url_encode = $get_keyword = $get_keyword_raw = $get_genero_raw = $get_anio_final = $get_anio_inicio = $get_genero = $sp = '';
  18. $args2 = [];
  19. $generos = [];
  20. $genero = [];
  21. $generos_arr = [];
  22. $letras = range('a','z');
  23. $numeros = range('0','9');
  24. $keyword_arr = array_merge($letras, $numeros);
  25. //Todos los géneros
  26. //$generos = get_terms(array('taxonomy' => 'movie_cat', 'orderby' => 'name'));
  27. $term_ficcion = get_term_by('name', 'ficcion', 'movie_cat');
  28. $name_ficcion = $term_ficcion->name;
  29. $slug_ficcion = $term_ficcion->slug;
  30. $genero_ficcion["name"]= $name_ficcion;
  31. $genero_ficcion["slug"]= $slug_ficcion;
  32. array_push($generos, $genero_ficcion);
  33.  
  34. $term_documental = get_term_by('name', 'documental', 'movie_cat');
  35. $name_documental = $term_documental->name;
  36. $slug_documental = $term_documental->slug;
  37. $genero_documental["name"]= $name_documental;
  38. $genero_documental["slug"]= $slug_documental;
  39. array_push($generos, $genero_documental);
  40.  
  41. $term_animacion = get_term_by('name', 'animacion', 'movie_cat');
  42. $name_animacion = $term_animacion->name;
  43. $slug_animacion = $term_animacion->slug;
  44. $genero_animacion["name"]= $name_animacion;
  45. $genero_animacion["slug"]= $slug_animacion;
  46. array_push($generos, $genero_animacion);
  47.  
  48. $alfabeticas = get_terms(array('taxonomy' => 'movie_alfabetica', 'orderby' => 'name'));
  49. $url = get_permalink();
  50.  
  51. // FILTRO GÉNERO
  52. if(isset( $_GET['genero%5BO%5D']))
  53. $_GET['genero'] = $_GET['genero%5BO%5D'];
  54.  
  55. if(isset( $_GET['genero%5B%5D']))
  56. $_GET['genero'] = $_GET['genero%5B%5D'];
  57.  
  58. if(isset( $_GET['genero'])){
  59. if(is_array($_GET['genero'])){
  60. foreach ($_GET['genero'] as $g) {
  61. $get_genero .= "&genero=".$g;
  62. }
  63. }
  64. $get_genero_raw = $_GET['genero'];
  65. }
  66.  
  67. /*
  68. $args_maximo = [
  69. 'post_type' => 'movie',
  70. 'post_status' => 'publish',
  71. 'meta_key' => 'themeum_anio_final',
  72. 'meta_type' => 'NUMERIC',
  73. 'orderby' => 'meta_value_num',
  74. 'order' => 'DESC',
  75. 'posts_per_page' => 1
  76. ];
  77.  
  78. $args_minimo = [
  79. 'post_type' => 'movie',
  80. 'post_status' => 'publish',
  81. 'meta_key' => 'themeum_anio_final',
  82. 'meta_type' => 'NUMERIC',
  83. 'orderby' => 'meta_value_num',
  84. 'order' => 'ASC',
  85. 'posts_per_page' => 1
  86. ];
  87. $the_query = new WP_Query($args_maximo);
  88. $anio_maximo = get_post_meta($the_query->ID, 'themeum_anio_final', false);
  89. $the_query = new WP_Query($args_minimo);
  90. $anio_minimo = get_post_meta($the_query->ID, 'themeum_anio_final', false);
  91.  
  92. echo "<pre>";
  93. print_r(new WP_Query($args_minimo));
  94. echo "</pre>";
  95. var_dump(new WP_Query($args_maximo));
  96.  
  97. ================================================================================
  98.  
  99. global $wpdb;
  100. $query_string_anio_minimo = "SELECT MIN(meta_value) FROM cd_postmeta WHERE meta_key = 'themeum_anio_final'";
  101. $query_string_anio_maximo = "SELECT MAX(meta_value) FROM cd_postmeta WHERE meta_key = 'themeum_anio_final'";
  102.  
  103. $anio_minimo = $wpdb->get_var($query_string_anio_minimo);
  104. $anio_maximo = $wpdb->get_var($query_string_anio_maximo);
  105.  
  106. echo $anio_minimo;
  107. echo $anio_maximo;
  108. */
  109.  
  110.  
  111. // FILTRO AÑOS
  112. $get_anio_inicio_raw = 1900;
  113. $get_anio_final_raw = 2018;
  114.  
  115.  
  116. if(isset( $_GET['inicio']) && $_GET['inicio'] != "" ){
  117. $get_anio_inicio = '?inicio='.$_GET["inicio"];
  118. $get_anio_inicio_raw = $_GET["inicio"];
  119. }
  120.  
  121. if(isset( $_GET['final'] ) && $_GET['inicio'] != "" ){
  122. $get_anio_final = '&final='.$_GET["final"];
  123. $get_anio_final_raw = $_GET["final"];
  124. }
  125.  
  126. // FILTRO ALFABETICO nativo del tema MOVIEW
  127. if(isset( $_GET['keyword'] )){
  128. $get_keyword = '?keyword='.$_GET["keyword"];
  129. $get_keyword_raw = $_GET["keyword"];
  130. }
  131.  
  132.  
  133. $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
  134.  
  135.  
  136. // CONSULTA BÁSICA => obtiene todos los post de película ordenados por AÑO FINAL en orden descendente
  137. $args = array(
  138. 'post_type' => 'movie',
  139. 'post_status' => 'publish',
  140. 'posts_per_page' => esc_attr($number),
  141. 'meta_type' => 'NUMERIC',
  142. 'meta_key' => 'themeum_anio_final',
  143. 'orderby' => 'meta_value_num',
  144. 'order' => 'DESC',
  145. 'paged' => $paged
  146. );
  147.  
  148. if($show_top == 'yes'){
  149.  
  150. $output .= '<div class="moview-filters clearfix mb5">';
  151. $output .= '<div class="pull-left">';
  152. $output .= '<ul class="list-inline list-style-none">';
  153. $alphabate = array('TODAS','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9');
  154. foreach ($alphabate as $value) {
  155. /*
  156. $sp = $get_genero.$get_anio_inicio.$get_anio_final;
  157. if (isset($get_anio_inicio_raw))
  158. if(isset($get_anio_final_raw) && isset($get_genero_raw))
  159. $sp = $get_anio_inicio.$get_anio_final.$get_genero;
  160. elseif (isset($get_anio_final_raw) && !isset($get_genero_raw))
  161. $sp = $get_anio_inicio.$get_anio_final;
  162. elseif (!isset($get_anio_final_raw) && isset($get_genero_raw))
  163. $sp = $get_anio_inicio.$get_genero;
  164. else
  165. if(isset($get_anio_final_raw) && isset($get_genero_raw))
  166. $sp = $get_anio_final.$get_genero;
  167. elseif (isset($get_anio_final_raw) && !isset($get_genero_raw))
  168. $sp = $get_anio_final;
  169. elseif (!isset($get_anio_final_raw) && isset($get_genero_raw))
  170. $sp = $get_genero;
  171. elseif (!isset($get_anio_final_raw) && !isset($get_genero_raw))
  172. $sp = '';
  173.  
  174. if($sp == '')
  175. $sp = '?keyword='.$value;
  176. else
  177. $sp = '?keyword='.$value.$sp;
  178. */
  179. $sp = '?keyword='.$value;
  180.  
  181. if( ($value=='TODAS') && ($get_keyword_raw == '') )
  182. $output .= '<li class="active" ><a href="'.$url.$sp.'">'.esc_attr($value).'</a></li>';
  183. else{
  184. if($get_keyword_raw == $value)
  185. $output .= '<li class="active" ><a href="'.$sp.'">'.esc_attr($value).'</a></li>';
  186. else
  187. $output .= '<li><a href="'.$url.$sp.'">'.esc_attr($value).'</a></li>';
  188. }
  189. }
  190. $output .= '</ul>';
  191. $output .= '</div>';
  192.  
  193. $output .= '</div>';
  194.  
  195. $output .= '<hr>';
  196.  
  197. $output .= '<div class="filtro-cinedata">';
  198. $output .= '<form id="filtros" action="'.$url.'" method="GET">';
  199. /*
  200. if(isset($_GET['keyword']))
  201. $output .= '<input type="hidden" id="anio-inicio" name="keyword" value='.$_GET['keyword'].'>'; */
  202. /*
  203. //TODOS LOS GENEROS
  204. $output .= '<div id="generos">';
  205. $output .= '<label for="genero">Géneros</label>';
  206. if ( ! empty( $generos ) && !is_wp_error( $generos ) ){
  207. foreach ( $generos as $genero ) {
  208. $output .= '<input type="checkbox" name="genero[]" value="'.$genero->slug.'">'.$genero->name;
  209. }
  210. $output .= '<br>';
  211. }
  212. $output .= '</div>';
  213. */
  214.  
  215. //GENEROS ESPECÍFICOS
  216. $output .= '<div id="generos">';
  217. $output .= '<label>Géneros:</label>';
  218. if ( ! empty( $generos ) && !is_wp_error( $generos ) ){
  219. if(isset( $_GET['genero'])){
  220. foreach ( $generos as $genero ) {
  221. if(in_array($genero['slug'], $_GET['genero'])){
  222. $output .= '<label for="'.$genero["slug"].'"><input type="checkbox" name="genero[]" id="'.$genero["slug"].'" value="'.$genero["slug"].'" checked>'.$genero["name"].'</label>';
  223. }else{
  224. $output .= '<label for="'.$genero["slug"].'"><input type="checkbox" name="genero[]" id="'.$genero["slug"].'" value="'.$genero["slug"].'">'.$genero["name"].'</label>';
  225. }
  226. }
  227. }else{
  228. foreach ( $generos as $genero ) {
  229. $output .= '<label for="'.$genero["slug"].'"><input type="checkbox" name="genero[]" id="'.$genero["slug"].'" value="'.$genero["slug"].'" checked>'.$genero["name"].'</label>';
  230. }
  231. }
  232. $output .= '<br>';
  233. }
  234. $output .= '</div>';
  235.  
  236.  
  237.  
  238. // ANIO INICIO y ANIO FIN
  239. $output .= '<div id="anios">';
  240. $output .= '<label for=""><strong>Período:</strong></label>';
  241. $output .= '<input type="hidden" id="anio-inicio" name="inicio" value="'.$get_anio_inicio_raw.'">';
  242. $output .= '<input type="hidden" id="anio-final" name="final" value="'.$get_anio_final_raw.'">';
  243. $output .= '<input id="valores_rango" type="hidden" data-desde="'.$get_anio_inicio_raw.'" data-hasta="'.$get_anio_final_raw.'" class="slider-input range-slider anios" value="'.$get_anio_inicio_raw.','.$get_anio_final_raw.'"/>';
  244. $output .= '</div>';
  245.  
  246. // DURACION
  247. $output .= '<div id="duracion">';
  248. $output .= '<label for="duracion"><strong>Duración:</strong></label>';
  249. $output .= '<select name="duracion" id="select-duracion">';
  250. //TODOS
  251. if(isset($_GET['duracion']) && $_GET['duracion'] == 'todos')
  252. $output .= '<option value="todos" selected="selected">Todos</option>';
  253. else
  254. $output .= '<option value="todos">Todos</option>';
  255. //LARGO
  256. if(isset($_GET['duracion']) && $_GET['duracion'] == 'corto')
  257. $output .= '<option value="corto" selected="selected">Corto (menos de 30 minutos)</option>';
  258. else
  259. $output .= '<option value="corto">Corto (menos de 30 minutos)</option>';
  260. //MEDIO
  261. if(isset($_GET['duracion']) && $_GET['duracion'] == 'medio')
  262. $output .= '<option value="medio" selected="selected">Medio (entre 30 y 60 minutos)</option>';
  263. else
  264. $output .= '<option value="medio">Medio (entre 30 y 60 minutos)</option>';
  265. //CORTO
  266. if(isset($_GET['duracion']) && $_GET['duracion'] == 'largo')
  267. $output .= '<option value="largo" selected="selected">Largo (más de 60 minutos)</option>';
  268. else
  269. $output .= '<option value="largo">Largo (más de 60 minutos)</option>';
  270. $output .= '</select>';
  271. $output .= '</div>';
  272. $output .= '<button id="btn_enviar" type="submit" class="btn mr20 ml10">Filtrar</button>';
  273. $output .= '<button class="btn invertido" type="button" id="limpiar-filtros">Limpiar filtros</button>';
  274. $output .= '</form>';
  275.  
  276. $output .= '<hr>';
  277. $output .= '</div>';
  278.  
  279. }
  280.  
  281. if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != ""){
  282. //Si hay parametros para filtrar => reseteo argumentos de wp_query
  283.  
  284. $args = array(
  285. 'post_type' => 'movie',
  286. 'post_status' => 'publish',
  287. 'posts_per_page' => esc_attr($number),
  288. 'meta_type' => 'NUMERIC',
  289. 'meta_key' => 'themeum_anio_final',
  290. 'orderby' => 'meta_value_num',
  291. 'order' => 'DESC',
  292. 'paged' => $paged
  293. );
  294.  
  295. //PROCESO EL QUERYSTRING
  296. $query_exploded = explode('&', $_SERVER['QUERY_STRING']);
  297. $query_con_parametros = crear_querystring_filtro_peliculas($query_exploded);
  298.  
  299. //FILTRO ALFABETICO
  300. if(isset($query_con_parametros['keyword']) && $query_con_parametros['keyword'] != ""){
  301.  
  302. if($query_con_parametros['keyword'] != "TODAS"){
  303. $tax_query_args = array(
  304. array(
  305. 'taxonomy' => 'movie_alfabetica',
  306. 'field' => 'slug',
  307. 'terms' => $query_con_parametros['keyword']
  308. )
  309. );
  310. }elseif ($query_con_parametros['keyword'] == "TODAS") {
  311. $tax_query_args = array(
  312. array(
  313. 'taxonomy' => 'movie_alfabetica',
  314. 'field' => 'slug',
  315. 'terms' => $keyword_arr,
  316. 'operator' => 'IN'
  317. )
  318. );
  319. }
  320.  
  321. $args2 = array(
  322. 'tax_query' => $tax_query_args
  323. );
  324.  
  325. }
  326. //FILTRO POR GENERO, DURACION y AÑO
  327. else{
  328. //PROCESO LOS AÑOS
  329. if((isset($query_con_parametros['anios']['inicio']) && $query_con_parametros['anios']['inicio'] != "") && (isset($query_con_parametros['anios']['final']) && $query_con_parametros['anios']['final'] == "")){
  330. $meta_query = array(
  331. array(
  332. 'key' => 'themeum_anio_final',
  333. 'value' => $query_con_parametros['anios']['inicio'],
  334. 'compare' => '>=',
  335. 'type' => 'NUMERIC'
  336. )
  337. );
  338. }
  339. elseif((isset($query_con_parametros['anios']['inicio']) && $query_con_parametros['anios']['inicio'] == "") && (isset($query_con_parametros['anios']['final']) && $query_con_parametros['anios']['final'] != "")){
  340. $meta_query = array(
  341. array(
  342. 'key' => 'themeum_anio_final',
  343. 'value' => $query_con_parametros['anios']['final'],
  344. 'compare' => '<=',
  345. 'type' => 'NUMERIC'
  346. )
  347. );
  348. }
  349. elseif((isset($query_con_parametros['anios']['inicio']) && $query_con_parametros['anios']['inicio'] != "") && (isset($query_con_parametros['anios']['final']) && $query_con_parametros['anios']['final'] != "")){
  350. $meta_query = array(
  351. 'relation' => 'AND',
  352. array(
  353. 'key' => 'themeum_anio_final',
  354. 'value' => $query_con_parametros['anios']['inicio'],
  355. 'compare' => '>=',
  356. 'type' => 'NUMERIC'
  357. ),
  358. array(
  359. 'key' => 'themeum_anio_final',
  360. 'value' => $query_con_parametros['anios']['final'],
  361. 'compare' => '<=',
  362. 'type' => 'NUMERIC'
  363. )
  364. );
  365. }else{
  366. $meta_query = "";
  367. }
  368.  
  369. if($meta_query != ""){
  370. $args2 = array(
  371. 'meta_query' => $meta_query,
  372. );
  373. }
  374. $args = array_merge( $args,$args2 );
  375.  
  376. //PROCESO GENEROS Y AGREGO $generos_arr en el TAX_QUERY
  377. if(!empty($query_con_parametros['generos']) && (isset($query_con_parametros['duracion']) && $query_con_parametros['duracion'] != "todos" )){
  378. $generos_arr = $query_con_parametros['generos'];
  379. if((isset($query_con_parametros['duracion']) && $query_con_parametros['duracion'] == "corto")){
  380. $tax_query_args = array(
  381. 'relation' => 'AND',
  382. array(
  383. 'taxonomy' => 'movie_cat',
  384. 'field' => 'slug',
  385. 'terms' => $generos_arr,
  386. 'operator' => 'IN',
  387. ),
  388. array(
  389. 'taxonomy' => 'movie_duracion',
  390. 'field' => 'slug',
  391. 'terms' => 'corto'
  392. )
  393. );
  394. }
  395. elseif ((isset($query_con_parametros['duracion']) && $query_con_parametros['duracion'] == "medio")) {
  396. $tax_query_args = array(
  397. 'relation' => 'AND',
  398. array(
  399. 'taxonomy' => 'movie_cat',
  400. 'field' => 'slug',
  401. 'terms' => $generos_arr,
  402. 'operator' => 'IN',
  403. ),
  404. array(
  405. 'taxonomy' => 'movie_duracion',
  406. 'field' => 'slug',
  407. 'terms' => 'medio'
  408. )
  409. );
  410. }
  411. elseif ((isset($query_con_parametros['duracion']) && $query_con_parametros['duracion'] == "largo")) {
  412. $tax_query_args = array(
  413. 'relation' => 'AND',
  414. array(
  415. 'taxonomy' => 'movie_cat',
  416. 'field' => 'slug',
  417. 'terms' => $generos_arr,
  418. 'operator' => 'IN',
  419. ),
  420. array(
  421. 'taxonomy' => 'movie_duracion',
  422. 'field' => 'slug',
  423. 'terms' => 'largo'
  424. )
  425. );
  426. }
  427. }elseif (!empty($query_con_parametros['generos']) && (isset($query_con_parametros['duracion']) && $query_con_parametros['duracion'] == "todos" )) {
  428. $generos_arr = $query_con_parametros['generos'];
  429. $tax_query_args = array(
  430. 'relation' => 'AND',
  431. array(
  432. 'taxonomy' => 'movie_cat',
  433. 'field' => 'slug',
  434. 'terms' => $generos_arr,
  435. 'operator' => 'IN'
  436. )
  437. );
  438. }elseif (empty($query_con_parametros['generos']) && $query_con_parametros['duracion'] != "todos" ) {
  439. if($query_con_parametros['duracion'] == "corto"){
  440. $tax_query_args = array(
  441. array(
  442. 'taxonomy' => 'movie_duracion',
  443. 'field' => 'slug',
  444. 'terms' => 'corto'
  445. )
  446. );
  447. }
  448. elseif ($query_con_parametros['duracion'] == "medio") {
  449. $tax_query_args = array(
  450. array(
  451. 'taxonomy' => 'movie_duracion',
  452. 'field' => 'slug',
  453. 'terms' => 'medio'
  454. )
  455. );
  456. }
  457. elseif ($query_con_parametros['duracion'] == "largo") {
  458. $tax_query_args = array(
  459. array(
  460. 'taxonomy' => 'movie_duracion',
  461. 'field' => 'slug',
  462. 'terms' => 'largo'
  463. )
  464. );
  465. }
  466. }
  467.  
  468.  
  469. if(isset($tax_query_args))
  470. $args2 = array(
  471. 'tax_query' => $tax_query_args
  472. );
  473.  
  474. }
  475.  
  476. $args = array_merge( $args,$args2 );
  477. }
  478.  
  479. $posts = get_posts( $args );
  480. $cantidad_posts = count($posts);
  481. $the_query = new WP_Query( $args );
  482.  
  483. $output .= '<div id="response"></div>';
  484.  
  485. // The Loop
  486. if($cantidad_posts == 0)
  487. $output .= "<p>No existen películas que coincidan con el criterio de búsqueda seleccionado.</p>";
  488. else {
  489. if(isset($_GET['inicio']) || isset($_GET['final']) || isset($_GET['keyword']) || isset($_GET['duracion']) || isset($_GET['genero'])){
  490. $output .= "<p id='cantidad_filtrados'>Encontramos <b>".$the_query->found_posts."</b> títulos que coinciden con los criterios seleccionados :)</p>";
  491. }
  492. $output .= '<div class="clearfix"></div>';
  493.  
  494. $output .= '<div class="moview-common-layout moview-celebrities-filters">';
  495. $x = 1;
  496.  
  497. foreach ($posts as $key=>$mpost): setup_postdata($mpost);
  498.  
  499. if( $x == 1 ){
  500. $output .= '<div class="row margin-bottom">';
  501. }
  502.  
  503. $anio_finalizacion = get_post_meta($mpost->ID,'themeum_anio_final',true);
  504. $duracion = get_post_meta($mpost->ID,'themeum_duracion',true);
  505. $paises = get_post_meta($mpost->ID,'themeum_movie_pais_productor',true);
  506. $formato_exhibicion = get_post_meta($mpost->ID,'themeum_movie_formato_exhibicion',true);
  507.  
  508.  
  509. $output .= '<div class="item movies col-sm-6 col-md-'.$column.'">';
  510. $output .= '<a href="'.get_the_permalink($mpost->ID).'" class="over-link"></a>';
  511. $output .= '<div class="item-wrapper">';
  512. $output .= '<div class="movie-poster">';
  513. if(get_the_post_thumbnail($mpost->ID,'moview-profile')) {
  514. $output .= get_the_post_thumbnail($mpost->ID,'moview-profile-uncropped', array('class' => 'img-responsive'));
  515. } else {
  516. $output .= '<img src="/wp-content/uploads/2018/04/afiche-por-defecto.jpg">';
  517. }
  518.  
  519. $output .= '</div>';//movie-poster
  520. $output .= '<div class="movie-details">';
  521.  
  522. $output .= '<div class="movie-name">';
  523. $output .= '<h4 class="movie-title uppercase"><a href="'.get_the_permalink($mpost->ID).'">'.get_the_title($mpost->ID).'</a>';
  524. $output .= '<span class="acotacion"> ('.$anio_finalizacion.')</span>';
  525. $output .= '</h4>';
  526. /* No queremos el genero acá, sino más abajo
  527. if ($movie_type) {
  528. $output .= '<span class="tag">'.esc_attr($movie_type).'</span>';
  529. } */
  530. $output .= '</div>';//movie-name
  531.  
  532. $output .= '<p class="movie-logline fontSizeSmall">';
  533. $output .= wp_trim_words( get_the_excerpt($mpost->ID), 40, '...' );
  534. $output .= '</p>';//movie-logline (agregado por nosotros)
  535.  
  536. $output .= '<div class="contenedor-datos">';
  537.  
  538.  
  539. $output .= '<div class="info-item fontSizeSmall">';
  540.  
  541. $output .= '<div class="sub-item">';
  542. $output .= '<strong class="title">Director:</strong>';
  543. $director = cd_obtener_nombres_por_idPelicula_metakey_rol($mpost->ID, 'themeum_movie_direccion', 'director');
  544.  
  545. $output .= '<ul class="inline mb0">';
  546. if(isset($director[0]) && $director[0] != "")
  547. $output .= '<li>'.$director[0].'</li>';
  548. if(isset($director[1]) && $director[1] != "")
  549. $output .= '<li>'.$director[1].'</li>';
  550. if(isset($director[2]) && $director[2] != "")
  551. $output .= '<li>'.$director[2].'</li>';
  552. $output .= '</ul>';
  553. $output .= '</div>';
  554.  
  555. $empresa_prod = cd_obtener_nombres_por_idPelicula_metakey_rol($mpost->ID, 'themeum_movie_direccion', 'empresa-productora');
  556.  
  557. if(isset($empresa_prod) && !empty($empresa_prod) ){
  558.  
  559. $output .= '<div class="sub-item">';
  560. $output .= '<strong class="title">Empresa Productora:</strong>';
  561. $output .= '<ul class="inline mb0">';
  562. if(isset($empresa_prod[0]) && $empresa_prod[0] != "")
  563. $output .= '<li>'.$empresa_prod[0].'</li>';
  564. if(isset($empresa_prod[1]) && $empresa_prod[1] != "")
  565. $output .= '<li>'.$empresa_prod[1].'</li>';
  566. if(isset($empresa_prod[2]) && $empresa_prod[2] != "")
  567. $output .= '<li>'.$empresa_prod[2].'</li>';
  568. $output .= '</ul>';
  569. $output .= '</div>';
  570. }
  571. $output .= '</div>';
  572.  
  573.  
  574. $protagonistas = cd_obtener_nombres_por_idPelicula_metakey_rol($mpost->ID, 'themeum_movie_direccion', 'elenco');
  575. if(isset($protagonistas) && !empty($protagonistas)){
  576. $output .= '<div class="protagonistas info-item fontSizeSmall">';
  577. $output .= '<strong class="title">Protagonistas:</strong>';
  578. $output .= '<ul class="inline mb0">';
  579. if(isset($protagonistas[0]) && $protagonistas[0] != "" )
  580. $output .= '<li>'.$protagonistas[0].'</li>';
  581. if(isset($protagonistas[1]) && $protagonistas[1] != "" )
  582. $output .= '<li>'.$protagonistas[1].'</li>';
  583. if(isset($protagonistas[2]) && $protagonistas[2] != "" )
  584. $output .= '<li>'.$protagonistas[2].'</li>';
  585. $output .= '</ul>';
  586. $output .= '</div>';
  587. }
  588.  
  589.  
  590.  
  591. if($duracion || $paises || $formato_exhibicion){
  592. $output .= '<div class="info-item fontSizeSmall">';
  593. if($duracion){ $output .= '<span class="sub-item">'.$duracion.' min. </span>';}
  594. if($paises){ $output .= '<span class="sub-item">'.$paises.'</span>';}
  595. if($formato_exhibicion){ $output .= '<span class="sub-item">'.$formato_exhibicion.'</span>';}
  596. $output .= '</div>';
  597. }
  598.  
  599.  
  600. $output .= '<div class="info-item fontSizeSmall">';
  601.  
  602. $generos_pelicula = get_the_terms($mpost->ID,'movie_cat');
  603. if(isset($generos_pelicula) && $generos_pelicula != ""){
  604. $output .= '<div class="sub-item">';
  605. $output .= '<strong class="title">Género:</strong>';
  606. $output .= '<ul class="inline mb0">';
  607. if(isset($generos_pelicula[0]->name) && $generos_pelicula[0]->name != "")
  608. $output .= '<li>'.$generos_pelicula[0]->name.'</li>';
  609. if(isset($generos_pelicula[1]->name) && $generos_pelicula[1]->name != "")
  610. $output .= '<li>'.$generos_pelicula[1]->name.'</li>';
  611. if(isset($generos_pelicula[2]->name) && $generos_pelicula[2]->name != "")
  612. $output .= '<li>'.$generos_pelicula[2]->name.'</li>';
  613. $output .= '</ul>';
  614. $output .= '</div>';
  615. }
  616.  
  617.  
  618.  
  619. $output .= '</div>';
  620.  
  621.  
  622. $output .= '<div class="info-item fontSizeSmall">';
  623. $movie_color = get_post_meta($mpost->ID,'themeum_color',true);
  624. switch ($movie_color){
  625. case '0': $movie_color = 'Color';
  626. break;
  627. case '1': $movie_color = 'Blanco y Negro';
  628. break;
  629. case '2': $movie_color = 'Color / Blanco y Negro';
  630. break;
  631. }
  632. if(isset($movie_color) && $movie_color != ""){
  633.  
  634. $output .= '<div class="sub-item">';
  635. $output .= '<strong class="title">Color o ByN:</strong>';
  636. $output .= '<ul class="inline mb0">';
  637. $output .= '<li>'.$movie_color.'</li>';
  638. $output .= '</ul>';
  639. $output .= '</div>';
  640. }
  641.  
  642. $output .= '</div>';
  643.  
  644. $output .= '</div>'; /* cierra .contanedor-datos */
  645.  
  646. $output .= '<a class="ver-mas" href="'.get_the_permalink($mpost->ID).'">ver ficha</a>';
  647. $output .= '</div>';//movie-details
  648. $output .= '</div>';//item wrapper
  649. $output .= '</div>';//item
  650.  
  651.  
  652. if( $x == (12/$column) ){
  653. $output .= '</div>'; //row
  654. $x = 1;
  655. }else{
  656. $x++;
  657. }
  658. endforeach;
  659. $output .= '</div>';//spotlight-common
  660. if($x != 1 ){
  661. $output .= '</div>'; //row
  662. }
  663.  
  664. wp_reset_postdata();
  665.  
  666. // Total Post
  667. $args['posts_per_page'] = -1;
  668. $total_post = get_posts( $args );
  669. $var = $number;
  670.  
  671. if( $var == "" || $var == 0 ){
  672. $total_post = 1;
  673. }else{
  674. $total_post = ceil( count($total_post)/(int)$var );
  675. }
  676.  
  677. $output .= '<div class="themeum-pagination">';
  678. $big = 999999999; // need an unlikely integer
  679. $output .= paginate_links( array(
  680. 'type' => 'list',
  681. 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) )),
  682. 'format' => '?paged=%#%',
  683. 'current' => max( 1, get_query_var('paged') ),
  684. 'total' => $total_post
  685. ) );
  686. $output .= '</div>'; //pagination-in
  687. }
  688.  
  689.  
  690. return $output;
  691. });
  692.  
  693.  
  694. //Visual Composer
  695. if (class_exists('WPBakeryVisualComposerAbstract')) {
  696. vc_map(array(
  697. "name" => esc_html__("Latest Movies Listing", 'themeum-core'),
  698. "base" => "themeum_all_movies",
  699. 'icon' => 'icon-thm-video_post',
  700. "class" => "",
  701. "description" => esc_html__("Widget Movies Listing", 'themeum-core'),
  702. "category" => esc_html__('Moview', 'themeum-core'),
  703. "params" => array(
  704. /*
  705. array(
  706. "type" => "dropdown",
  707. "heading" => esc_html__("Category Filter", 'themeum-core'),
  708. "param_name" => "category",
  709. "value" => themeum_cat_list('movie_cat'),
  710. ),
  711. */
  712. array(
  713. "type" => "textfield",
  714. "heading" => esc_html__("Number of items", 'themeum-core'),
  715. "param_name" => "number",
  716. "value" => "8",
  717. ),
  718.  
  719. array(
  720. "type" => "dropdown",
  721. "heading" => esc_html__("Number Of Column", "themeum-core"),
  722. "param_name" => "column",
  723. "value" => array('Select'=>'','column 2'=>'6','column 3'=>'4','column 4'=>'3'),
  724. ),
  725.  
  726.  
  727. array(
  728. "type" => "dropdown",
  729. "heading" => esc_html__("Show Top Filter", 'themeum-core'),
  730. "param_name" => "show_top",
  731. "value" => array('Select'=>'','YES'=>'yes','NO'=>'no'),
  732. ),
  733.  
  734. array(
  735. "type" => "dropdown",
  736. "heading" => esc_html__("OderBy", 'themeum-core'),
  737. "param_name" => "orderby",
  738. "value" => array('Select'=>'','Date'=>'date','Title'=>'title','Modified'=>'modified','Author'=>'author','Random'=>'rand'),
  739. ),
  740.  
  741. array(
  742. "type" => "dropdown",
  743. "heading" => esc_html__("Order", 'themeum-core'),
  744. "param_name" => "order",
  745. "value" => array('Select'=>'','DESC'=>'DESC','ASC'=>'ASC'),
  746. ),
  747.  
  748. array(
  749. "type" => "textfield",
  750. "heading" => esc_html__("Custom Class", 'themeum-core'),
  751. "param_name" => "class",
  752. "value" => "",
  753. ),
  754. )
  755.  
  756. ));
  757. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement