show_errors(); if(!session_id()) @session_start(); setLocale(LC_TIME, 'es_ES'); $inj_js = []; $inj_css = []; define('SEP', '/'); define('LANG', ICL_LANGUAGE_CODE); define('DOC_ROOT', $_SERVER['DOCUMENT_ROOT'].'/'); define('THEME_PATH', dirname(__FILE__).'/'); define('IS_DEV', ($_SERVER['HTTP_HOST']==='prj7.albin.es')); define('MAIL_TO', IS_DEV ? 'albinworld@gmail.com' : 'albinworld@gmail.com'); define('MAIL_FROM', IS_DEV ? 'albinworld@gmail.com' : 'albinworld@gmail.com'); define('SITE_NAME', tt('Arte rupestre', 'general')); function urlimage($file) { return get_bloginfo('template_url').'/images/'.$file; } function urlfile($file) { return get_bloginfo('template_url').'/'.$file; } function suffix($key, $sep='_') { $lang = ICL_LANGUAGE_CODE; if($lang=='pt-pt') $lang = 'pt'; return $key.$sep.$lang; } function qt($es = '', $va = '', $en = '') { if(LANG=='es') return $es; if(LANG=='va') return $va; if(LANG=='en') return $en; return ''; } function qis($lang) { return LANG==$lang; } function tt($text, $context = 'theme') { return _x($text, $context, 'arterupestre'); } function pid($pid, $ot='page') { return apply_filters('wpml_object_id', $pid, $ot, TRUE); // icl_object_id($pid, $ot); } function my_object_id($id, $type, $lang = null, $org = true) { if($lang===null) $lang = ICL_LANGUAGE_CODE; return apply_filters('wpml_object_id', $id, $type, $org, $lang); } function single_cat_info($post, $single=false) { $html = array(); $cats = get_the_category( $post->ID ); $catid = null; foreach($cats as $cat) if($cat->parent==0) { if($catid===null) $catid = $cat->term_id; $html[] = ''.$cat->name.''; if($single) break; } if($single) return array($catid, $html[0]); else return array($catid, implode(chr(44).chr(32), $html)); } function strdate($dt) { return utf8_encode(strftime(tt('%e de %B de %Y'), strtotime($dt))); // %A } /* * Setup */ function albin_init() { Pages::init(); } add_action( 'init', 'albin_init', 15 ); function albin_setup() { add_editor_style(); add_theme_support('post-thumbnails'); add_post_type_support( 'page', 'excerpt' ); add_image_size('fs_mbl', 375, 0, false); add_image_size('fs_tbl', 768, 0, false); add_image_size('fs_dsk', 1280, 0, false); add_image_size('fs_fhd', 1920, 0, false); add_image_size('medium_sq', 375, 375, true); /* if(!is_admin()) { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'); } else { wp_enqueue_style('thickbox'); wp_enqueue_script('thickbox'); } */ $menus = array( 'headermenu' => 'Header menu', 'footermenu' => 'Footer menu', ); register_nav_menus($menus); /* register_sidebar(array( 'id' => 'sb_home', 'name' => 'Home', 'before_widget' => '
  • ', 'after_widget' => '
  • ', 'before_title' => '

    ', 'after_title' => '

    ', )); register_sidebar(array( 'id' => 'sb_general', 'name' => 'General', 'before_widget' => '
    ', // id="%1$s" 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ', )); */ } add_action('after_setup_theme', 'albin_setup'); function albin_widgets_init() { register_sidebar(array( 'id' => 'sidebar_general', 'name' => 'Sidebar : General', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ', )); } add_action( 'widgets_init', 'albin_widgets_init' ); function amc_admin_setup() { wp_enqueue_media(); wp_enqueue_script('jquery-ui-sortable'); } add_action('admin_enqueue_scripts', 'amc_admin_setup'); /* * Admin pages */ function albin_admin_pages() { add_menu_page( 'Gestión', 'Gestión', 'edit_posts', 'amc', 'amc', NULL, 55 ); add_submenu_page( 'amc', 'Home : Información', 'Home : Información', 'edit_posts', 'home_info', 'wpa_home_info' ); } function wpa_home_info() { include(THEME_PATH.'/wpa-home-info.php'); } add_action('admin_menu', 'albin_admin_pages'); function adding_custom_meta_boxes($post) { add_meta_box('mygallery', 'Galería', 'mb_mygallery', ['nucleo', 'yacimiento', 'naturaleza'], 'advanced', 'default', null); add_meta_box('placewebs', 'Enlaces recomendados', 'mb_placewebs', ['nucleo', 'yacimiento', 'naturaleza', 'ruta'], 'advanced', 'default', null); } add_action('add_meta_boxes', 'adding_custom_meta_boxes'); include('mb-mygallery.php'); function adding_custom_meta_boxes_nucleo($post) { add_meta_box('infonucleo', 'Información del nucleo', 'mb_infonucleo', null, 'advanced', 'default', null); // add_meta_box('placenucleo', 'Relacionar yacimiento con nucleo', 'mb_nucleoplace', null, 'advanced', 'default', null); } function adding_custom_meta_boxes_yacimiento($post) { add_meta_box('infoplace', 'Información del yacimiento', 'mb_infoplace', null, 'advanced', 'default', null); // add_meta_box('placenucleo', 'Relacionar yacimiento con nucleo', 'mb_placenucleo', null, 'advanced', 'default', null); // add_meta_box('placeroute', 'Relacionar yacimiento con ruta' , 'mb_placeroute', null, 'advanced', 'default', null); } function adding_custom_meta_boxes_ruta($post) { add_meta_box('inforoute', 'Información de la ruta', 'mb_inforoute', null, 'advanced', 'default', null); } function adding_custom_meta_boxes_restaurante($post) { add_meta_box('inforeste', 'Información del restaurante', 'mb_inforte', null, 'advanced', 'default', null); } function adding_custom_meta_boxes_hotel($post) { add_meta_box('infohotel', 'Información del hotel', 'mb_infohotel', null, 'advanced', 'default', null); } function adding_custom_meta_boxes_naturaleza($post) { add_meta_box('infonatura', 'Información del paisaje', 'mb_infonatura', null, 'advanced', 'default', null); } add_action('add_meta_boxes_nucleo', 'adding_custom_meta_boxes_nucleo'); add_action('add_meta_boxes_yacimiento', 'adding_custom_meta_boxes_yacimiento'); add_action('add_meta_boxes_ruta', 'adding_custom_meta_boxes_ruta'); add_action('add_meta_boxes_restaurante', 'adding_custom_meta_boxes_restaurante'); add_action('add_meta_boxes_hotel', 'adding_custom_meta_boxes_hotel'); add_action('add_meta_boxes_naturaleza', 'adding_custom_meta_boxes_naturaleza'); include('mb-infonucleo.php'); include('mb-infoplace.php'); include('mb-inforoute.php'); include('mb-inforeste.php'); include('mb-infohotel.php'); include('mb-infonatur.php'); // include('mb-nucleoplace.php'); // include('mb-placenucleo.php'); // include('mb-placeroute.php'); include('mb-placewebs.php'); include('mb-filternucleo.php'); function adding_custom_page_meta_boxes($post) { $tpl = get_post_meta($post->ID, '_wp_page_template', true); if($tpl=='page-yacimientos.php' || $tpl=='page-rutas.php') { add_meta_box('placewebs', 'Filtro por núcleo', 'mb_filternucleo', null, 'advanced', 'default', null); } // add_meta_box('sbar_menu', 'Menú asignado', 'mb_sbar_menu', null, 'side', 'default', null); if($post->ID==pid(Pages::id('proyecto'))) { add_meta_box('placewebs', 'Enlaces recomendados', 'mb_placewebs', null, 'advanced', 'default', null); } } add_action('add_meta_boxes_page', 'adding_custom_page_meta_boxes'); /* * TinyMCE */ function pix_tiny_plugins( $plugin_array ) { $plugin_array['myplugin'] = '/wp-content/themes/amc/tinymce-plugin.js'; return $plugin_array; } // add_filter( 'mce_external_plugins', 'pix_tiny_plugins' ); function pix_tiny_formats( $in ) { $in['wordpress_adv_hidden'] = false; $in['block_formats'] = "Paragraph=p; Heading (h2)=h2; Subheading (h3)=h3"; /* $custom_colours = '179497,83C341,5399DF,B98FBB,00B259,33B4C2,83C341,FF9326'; $in['theme_advanced_text_colors'] = $custom_colours; $in['textcolor_map'] = '[ "000000", "Negro", "179497", "Educación", "83C341", "Disciplina", "5399DF", "Juego", "B98FBB", "Crianza", "00B259", "Libros", "33B4C2", "Cocina", "83C341", "Arte", "FF9326", "DIY" ]'; */ return $in; } add_filter( 'tiny_mce_before_init', 'pix_tiny_formats' ); function pix_tiny_buttons_1( $buttons ) { return array('formatselect', 'forecolor', 'bold', 'italic', 'underline', 'strikethrough', '|', 'numlist', 'bullist', 'alignleft', 'aligncenter', 'alignright', 'alignjustify', '|', 'link', 'unlink', '|', 'pastetext', 'removeformat', '|', 'undo', 'redo'); return array('formatselect', 'bold', 'italic', 'underline', 'strikethrough', '|', 'bullist', 'alignleft', 'aligncenter', 'alignright', '|', 'link', 'unlink', '|', 'wp_adv'); } function pix_tiny_buttons_2( $buttons ) { return array('sc_button', 'sc_textbox', 'sc_excerpt', 'sc_quote', 'sc_balloon', 'sc_features'); return array('pastetext', 'removeformat', '|', 'undo', 'redo'); // 'fontsizeselect', 'forecolor', '|', } add_filter('mce_buttons', 'pix_tiny_buttons_1'); add_filter('mce_buttons_2', 'pix_tiny_buttons_2'); function my_mce_before_init_insert_formats( $init_array ) { $style_formats = array( array( 'title' => 'Texto destacado', 'block' => 'div', 'classes' => 'txtlead', 'wrapper' => true ) ); $custom_colours = '179497,83C341,5399DF,B98FBB,00B259,33B4C2,83C341,FF9326'; // $init_array['style_formats'] = json_encode( $style_formats ); $init_array['theme_advanced_blockformats'] = "h2,h3,p,div"; $init_array['block_formats'] = "Paragraph=p;Header 2=h2;Header 3=h3"; $init_array['theme_advanced_text_colors'] = $custom_colours; $init_array['textcolor_map'] = '[ "000000", "Negro", "179497", "Educación", "83C341", "Disciplina", "5399DF", "Juego", "B98FBB", "Crianza", "00B259", "Libros", "33B4C2", "Cocina", "83C341", "Arte", "FF9326", "DIY" ]'; return $init_array; } // add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' ); /* * Shortcodes */ function sc_gallery($atts, $content) { global $inj_js, $inj_css; $inj_js[] = dirname(__FILE__).'/gallery.js'; $inj_css[] = dirname(__FILE__).'/gallery.css'; $ids = explode(chr(44), $atts['ids']); $cols = $atts['columns'] ?? 0; $cols = min(3, max(2, $cols)); $out = ''; return $out; } add_shortcode('gallery', 'sc_gallery'); function sc_button($atts, $content) { if(!empty($atts['href'])) { $atts['target'] = (substr($atts['href'], 0, 4)=='http' ? '_blank' : ''); return ''.do_shortcode($content).''; } return ''; } function sc_textbox($atts, $content) { if(empty($atts['title'])) return '
    '.do_shortcode($content).'
    '; return '

    '.$atts['title'].'

    '.wpautop($content).'
    '; } function sc_excerpt($atts, $content) { $class = array(); if(isset($atts['align'])) $class[] = $atts['align']; else $class[] = 'center'; if(isset($atts['color'])) $class[] = 'color'.$atts['color']; else $class[] = 'color1'; return ''.$content.''; } function sc_quote($atts, $content) { $class = array(); if(isset($atts['align'])) $class[] = $atts['align']; else $class[] = 'center'; return '

    '.($content).'

    '; } function sc_balloon($atts, $content) { $class = array(); if(isset($atts['align'])) $class[] = $atts['align']; else $class[] = 'right'; if(isset($atts['color'])) $class[] = 'color'.$atts['color']; else $class[] = 'color1'; return ''.($content).''; } function sc_features($atts, $content) { $lines = explode('|nl|', trim($content)); $out = ''; $out .= '
    '; foreach($lines as $line) if(!empty($line)) { $pos = strpos($line, chr(58)); if($pos!==false) { $lbl = substr($line, 0, $pos++); $val = trim(substr($line, $pos)); $out .= '

    '.$lbl.''.$val.'

    '; } } $out .= '
    '; return $out; } function sc_newsection($atts, $content) { return '

    '.($content).'

    '; } function sc_half_col($atts, $content) { return '
    '.($content).'
    '; } add_shortcode('button', 'sc_button'); add_shortcode('sc_textbox', 'sc_textbox'); add_shortcode('sc_excerpt', 'sc_excerpt'); add_shortcode('sc_quote', 'sc_quote'); add_shortcode('sc_balloon', 'sc_balloon'); add_shortcode('sc_features', 'sc_features'); add_shortcode('newsection', 'sc_newsection'); add_shortcode('half_col', 'sc_half_col'); /* * Varios */ function get_post_terms($post, $single=false) { $html = array(); $cats = get_the_terms( is_object($post) ? $post->ID : $post, 'blog_category' ); $catid = null; foreach($cats as $cat) if($cat->parent==0) { if($catid===null) $catid = $cat->term_id; $html[] = ''.$cat->name.''; if($single) break; } if($single) return $html[0]; // array($catid, ); else return implode(chr(44).chr(32), $html); // array($catid, ); } function share_links($url, $txt, $img) { $out = ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; // $out .= ''; // $out .= ''; return $out; } function bhv_proyecto($query) { // var_dump($query->is_archive , $query->query_vars['post_type']); if(!is_admin()) { if($query->is_archive && isset($query->query_vars['post_type']) && $query->query_vars['post_type']==='yacimiento') { $query->set( 'orderby', 'title' ); $query->set( 'order', 'asc' ); $query->set( 'nopaging', 'true' ); $prov = isset($_REQUEST['prov']) ? $_REQUEST['prov'] : false; if(FALSE!==$prov && ''!==$prov) { $query->set( 'meta_query', array( array( 'key' => 'moreinfo', 'value' => '1', 'compare' => '=', ), array( 'key' => 'id_prov', 'value' => $prov, 'compare' => '=', ), )); } elseif(is_archive('yacimiento')) { $query->set( 'meta_key', 'moreinfo' ); $query->set( 'meta_value', '1' ); } } if($query->is_archive && isset($query->query_vars['post_type']) && $query->query_vars['post_type']==='naturaleza') { $query->set( 'nopaging', 'true' ); } if($query->is_archive && isset($query->query_vars['post_type']) && $query->query_vars['post_type']==='ruta') { $query->set( 'nopaging', 'true' ); $query->set( 'orderby', 'title' ); $query->set( 'order', 'asc' ); } } } add_action( 'pre_get_posts', 'bhv_proyecto' ); /* * Mega hack */ function susi_replaces($html) { global $inj_js, $inj_css; $inj_js = array_unique($inj_js); $inj_css = array_unique($inj_css); $style = ''; $script = ''; foreach($inj_css as $file) $style .= file_get_contents($file, THEME_PATH); foreach($inj_js as $file) $script .= file_get_contents($file, THEME_PATH); $html = str_replace('', '', $html); $html = str_replace('', '', $html); return $html; } // include('funcs-ajax.php'); include('funcs-ajax-admin.php'); include('funcs-admin-lists.php'); include('funcs-amenities.php'); include('funcs-data.php'); include('funcs-cpt.php'); include('funcs-rebellion.php'); // include('funcs-shortcodes.php'); /* Google: wordpress shortcode generates empty p https://wordpress.org/plugins/shortcode-empty-paragraph-fix/ https://stackoverflow.com/questions/13510131/remove-empty-p-tags-from-wordpress-shortcodes-via-a-php-functon */ remove_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'wpautop', 99 ); add_filter( 'the_content', 'shortcode_unautop', 100 ); ?>'Castellón', '46'=>'Valencia', '3'=>'Alicante']; if(qis('en')) $provs = ['12'=>'Castellón', '46'=>'Valencia', '3'=>'Alicante']; if(qis('va')) $provs = ['12'=>'Castelló', '46'=>'València', '3'=>'Alacant' ]; $home_h1 = get_option(suffix('home-h1'), ''); $home_intro = get_option(suffix('home-intro'), ''); $home_social = json_decode(get_option(suffix('home-social'), json_encode(array()))); ?>