show_errors(); if(!session_id()) @session_start(); // setLocale(LC_TIME, 'es_ES'); $inj_js = []; $inj_css = []; // define('ICL_LANGUAGE_CODE', 'es'); define('LANG', ICL_LANGUAGE_CODE); define('DOC_ROOT', $_SERVER['DOCUMENT_ROOT'].'/'); define('THEME_PATH', dirname(__FILE__).'/'); define('IS_DEV', ($_SERVER['HTTP_HOST']!=='www.ambulanciascivera.com')); define('MAIL_TO', IS_DEV ? 'albinworld@gmail.com' : 'comercial@ambulanciascivera.com'); define('MAIL_WC', IS_DEV ? 'albinworld@gmail.com' : 'coordinacion@ambulanciascivera.com'); // we call define('WSDL', 'https://95.39.28.196:4455/WebService.asmx?wsdl&dt='.time()); 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 = '', $en = '') { if(LANG=='es') return $es; if(LANG=='pt') return $pt; return ''; } function qis($lang) { return LANG==$lang; } function tt($text, $context = 'theme') { return _x($text, $context, 'civera'); } function pid($pid, $ot='page') { return 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_setup() { Pages::init(); add_editor_style(); add_theme_support('post-thumbnails'); add_image_size("newslist", 480, 480, true); add_image_size("retenes", 600, 480, true); add_image_size("related", 480, 0, false); add_image_size("xlarge", 1600, 0, false); /* 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( 'primary' => 'Main menu', 'whoweare' => 'Quienes somos', 'services' => 'Servicios', 'ambulances' => 'Ambulancias', 'courses' => 'Cursos', ); 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' => '
    ', )); */ /* $edit_author = get_role('author'); $edit_author->add_cap('edit_pages'); $edit_author->remove_cap('delete_others_pages'); $edit_author->remove_cap('edit_others_pages'); */ } 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 civera_admin_setup() { wp_enqueue_media(); wp_enqueue_script('jquery-ui-sortable'); } add_action('admin_enqueue_scripts', 'civera_admin_setup'); /* * Admin pages */ function albin_admin_pages() { add_menu_page( 'Bases', 'Bases', 'edit_posts', 'bases', 'wpa_bases_list', NULL, 54 ); add_submenu_page( 'bases', 'Añadir base', 'Añadir base', 'edit_posts', 'bases_edit', 'wpa_bases_edit'); add_menu_page( 'Gestión', 'Gestión', 'edit_posts', 'civera', 'civera', NULL, 55 ); add_submenu_page( 'civera', 'Home : Slider', 'Home : Slider', 'edit_posts', 'slider_list', 'wpa_slider_list' ); add_submenu_page( null, 'Home : Slider', 'Home : Slider', 'edit_posts', 'slider_form', 'wpa_slider_form' ); add_submenu_page( 'civera', 'Home : Secciones', 'Home : Secciones', 'edit_posts', 'home_sections', 'wpa_home_sections' ); add_submenu_page( 'civera', 'Home : Retenes', 'Home : Retenes', 'edit_posts', 'retenes_list', 'wpa_retenes_list' ); add_submenu_page( null, 'Home : Retenes', 'Home : Retenes', 'edit_posts', 'retenes_form', 'wpa_retenes_form' ); add_submenu_page( 'civera', 'Home : Ambulancias', 'Home : Ambulancias', 'edit_posts', 'ambus_list', 'wpa_ambus_list' ); add_submenu_page( null, 'Home : Ambulancias', 'Home : Ambulancias', 'edit_posts', 'ambus_form', 'wpa_ambus_form' ); add_submenu_page( 'civera', 'Clientes', 'Clientes', 'edit_posts', 'customers', 'wpa_customers_list' ); add_submenu_page( null, 'Clientes', 'Clientes', 'edit_posts', 'customers_form', 'wpa_customers_form' ); add_submenu_page( null, 'Clientes', 'Clientes', 'edit_posts', 'customers_order', 'wpa_customers_order'); add_submenu_page( 'civera', 'Descargas', 'Descargas', 'edit_posts', 'descargas', 'wpa_descargas' ); add_submenu_page( null, 'Descarga', 'Descarga', 'edit_posts', 'descargas_form', 'wpa_descargas_form' ); add_submenu_page( 'civera', 'Ofertas de trabajo', 'Ofertas de trabajo', 'edit_posts', 'ofertrabs', 'wpa_ofertrabs' ); add_submenu_page( null, 'Ofertas de trabajo', 'Ofertas de trabajo', 'edit_posts', 'ofertrabs_form', 'wpa_ofertrabs_form' ); add_menu_page( 'Monerías', 'Monerías', 'edit_posts', 'monerias', 'wpa_checkillus', NULL, 56 ); add_submenu_page( 'monerias', 'Checkillus', 'Checkillus', 'edit_posts', 'checkillus', 'wpa_checkillus' ); add_submenu_page( 'monerias', 'Landing Blase', 'Landing Blase', 'edit_posts', 'landing_blase', 'wpa_landing_blase' ); add_submenu_page( 'monerias', 'Landing Zizag', 'Landing Zizag', 'edit_posts', 'landing_zizag', 'wpa_landing_zizag' ); add_submenu_page( 'monerias', 'Descargas', 'Descargas', 'edit_posts', 'documentos', 'wpa_documentos' ); add_submenu_page( 'monerias', 'Acordeón', 'Acordeón', 'edit_posts', 'accordion', 'wpa_accordion' ); } function wpa_home_sections() { include(THEME_PATH.'/wpa-home-sections.php'); } function wpa_customers_list() { include(THEME_PATH.'/wpa-customers-list.php'); } function wpa_customers_form() { include(THEME_PATH.'/wpa-customers-form.php'); } function wpa_customers_order() { include(THEME_PATH.'/wpa-customers-order.php'); } function wpa_slider_list() { include(THEME_PATH.'/wpa-slider-lst.php'); } function wpa_slider_form() { include(THEME_PATH.'/wpa-slider-frm.php'); } function wpa_retenes_list() { include(THEME_PATH.'/wpa-retenes-lst.php'); } function wpa_retenes_form() { include(THEME_PATH.'/wpa-retenes-frm.php'); } function wpa_ambus_list() { include(THEME_PATH.'/wpa-ambus-lst.php'); } function wpa_ambus_form() { include(THEME_PATH.'/wpa-ambus-frm.php'); } function wpa_bases_list() { include(THEME_PATH.'/wpa-bases-list.php'); } function wpa_bases_edit() { include(THEME_PATH.'/wpa-bases-edit.php'); } function wpa_descargas() { include(THEME_PATH.'/wpa-descargas-list.php'); } function wpa_descargas_form() { include(THEME_PATH.'/wpa-descargas-form.php'); } function wpa_ofertrabs() { include(THEME_PATH.'/wpa-ofertrabs-list.php'); } function wpa_ofertrabs_form() { include(THEME_PATH.'/wpa-ofertrabs-form.php'); } function wpa_checkillus() { include(THEME_PATH.'/wpa-checkillus.php'); } function wpa_landing_blase() { include(THEME_PATH.'/wpa-landing-blase.php'); } function wpa_landing_zizag() { include(THEME_PATH.'/wpa-landing-zizag.php'); } function wpa_documentos() { include(THEME_PATH.'/wpa-documentos.php'); } function wpa_accordion() { include(THEME_PATH.'/wpa-accordion.php'); } add_action('admin_menu', 'albin_admin_pages'); function adding_custom_meta_boxes($post) { $tpl = get_post_meta($post->ID, '_wp_page_template', true); add_meta_box('sbar_menu', 'Menú asignado', 'mb_sbar_menu', null, 'side', 'default', null); // if($post->ID==pid(Pages::id('quienes')) || $post->ID==pid(Pages::id('calidad'))) { if($post->ID==pid(Pages::id('calidad'))) { add_meta_box('calidad_sellos', 'Calidad : Sellos', 'mb_calidad_sellos', null, 'advanced', 'default', null); } add_meta_box('gen_relpages', 'General : Páginas relacionadas', 'mb_gen_relpages', null, 'advanced', 'default', null); // add_meta_box('gen_checkillus', 'General : Transición de textos con imágenes', 'mb_gen_checkillus', null, 'advanced', 'default', null); if($tpl=='page-generic.php') { add_meta_box('mygallery', 'Galería de imágenes', 'mb_mygallery', null, 'advanced', 'default', null); } } add_action('add_meta_boxes_page', 'adding_custom_meta_boxes'); include('mb-sbarmenu.php'); include('mb-calidad-sellos.php'); include('mb-gen-relpages.php'); // include('mb-gen-checkillus.php'); include('mb-mygallery.php'); /* * TinyMCE */ function pix_tiny_plugins( $plugin_array ) { $plugin_array['myplugin'] = '/wp-content/themes/civera/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', 'sc_presupuesto', 'sc_civera'); 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'); function sc_mygallery($atts, $content) { global $inj_js, $inj_css; $inj_js[] = dirname(__FILE__).'/mygallery.js'; $inj_css[] = dirname(__FILE__).'/mygallery.css'; $out = ''; $pid = get_the_ID(); $pics = array(); $title = get_the_title(); $ids = get_post_meta($pid, 'ids_pics', true); if(!empty($ids)) { $ids = explode(chr(44), $ids); foreach($ids as $id) { $pics[$id] = wp_get_attachment_image_src($id, 'large'); } $out .= '
    '; $out .= '
    '; $out .= '
    '; $out .= '
    '; $out .= '
    '; foreach($pics as $pic) { $out .= '
    '; } $out .= '
    '; $out .= ''; $out .= ''; $out .= '
    '; } return $out; } add_shortcode('mygallery', 'sc_mygallery'); /* * Varios */ 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_search) { $query->set( 'post_type', 'post' ); } if(is_front_page() && !is_home()) { $query->set( 'offset', 8 ); } } } 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-amenities.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 ); if( FALSE!==strpos($_SERVER['REQUEST_URI'], '/clientes/') || FALSE!==strpos($_SERVER['REQUEST_URI'], '/empleados/') || FALSE!==strpos($_SERVER['REQUEST_URI'], '/wp-admin/admin-ajax.php') || FALSE!==strpos($_SERVER['REQUEST_URI'], '/admin-post.php') ) { include('funcs-area-cliente.php'); if( FALSE!==strpos($_SERVER['REQUEST_URI'], '/admin-post.php') ) { include(DOC_ROOT.'vendor/phpexcel/Classes/PHPExcel.php'); include(DOC_ROOT.'vendor/html2pdf/html2pdf.class.php'); } } ?>post_parent) { Breadcrumb::addItem(get_the_title($post->post_parent), get_permalink($post->post_parent)); } Breadcrumb::addItem(get_the_title(), get_permalink()); $menu = get_post_meta(get_the_ID(), 'sbar_menu', true); if(!$menu) $menu = 'whoweare'; $cont = wpautop(get_the_content()); $index = ''; $hh = array(); // $res = preg_match_all('|(.+<\/h\d>)|', $cont, $hh); $res = preg_match_all('|(]+)>.+<\/h2>)|', $cont, $hh); if(FALSE!==$res && 0!==$res) { $index .= '

    '.tt('Hablamos sobre…', 'nav').'

    '; $index .= ''; $index .= ''; $inj_js[] = 'index.js'; } if(FALSE!==strpos($post->post_content, '