=' ) ) add_theme_support( 'custom-background' ); else add_custom_background(); // Your changeable header business starts here if ( ! defined( 'HEADER_TEXTCOLOR' ) ) define( 'HEADER_TEXTCOLOR', '' ); // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI. if ( ! defined( 'HEADER_IMAGE' ) ) define( 'HEADER_IMAGE', '%s/images/logo.png' ); // The height and width of your custom header. You can hook into the theme's own filters to change these values. // Add a filter to baobab_header_image_width and baobab_header_image_height to change these values. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'baobab_header_image_width', 36 ) ); define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'baobab_header_image_height', 36 ) ); // We'll be using post thumbnails for custom header images on posts and pages. // We want them to be 940 pixels wide by 198 pixels tall. // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Don't support text inside the header image. if ( ! defined( 'NO_HEADER_TEXT' ) ) define( 'NO_HEADER_TEXT', true ); // Add a way for the custom header to be styled in the admin panel that controls // custom headers. See baobab_admin_header_style(), below. global $wp_version; if ( version_compare( $wp_version, '3.4', '>=' ) ) add_theme_support( 'custom-header' ); else add_custom_image_header( '', 'baobab_admin_header_style' ); // ... and thus ends the changeable header business. } endif; if ( ! function_exists( 'baobab_admin_header_style' ) ) : /** * Styles the header image displayed on the Appearance > Header admin panel. * * Referenced via add_custom_image_header() in baobab_setup(). * * @since Twenty Ten 1.0 */ function baobab_admin_header_style() { ?> ', ']]>', $content); $content = strip_tags($content); if (strlen($_GET['p']) > 0) { if($noticiagp) { echo substr($content,0,$max_char); } else { echo '
'; echo substr($content,0,$max_char); echo "
"; } } else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) { $content = substr($content, 0, $espacio); $content = $content; if($noticiagp) { echo substr($content,0,$max_char); echo $more_link_text; } else { echo ''; echo substr($content,0,$max_char); echo $more_link_text; echo "
"; } } else { if($noticiagp) { echo substr($content,0,$max_char); } else { echo ''; echo substr($content,0,$max_char); echo "
"; } } } */ /* Acortando titulos por caracteres para mostrar en el Home y Página específica de cada tipo de publicación */ function titulo_corto($after = null, $length) { $mytitle = get_the_title(); $size = strlen($mytitle); if($size>$length) { $mytitle = substr($mytitle, 0, $length); $mytitle = explode(' ',$mytitle); array_pop($mytitle); $mytitle = implode(" ",$mytitle).$after; } return $mytitle; } /* Comentarios */ function baobab_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case 'pingback' : case 'trackback' : ?>', '' ); ?>
'; while( $noticias->have_posts() && $i < 4 ) : $noticias->the_post(); echo '- ';
echo'';
echo ''.the_author_meta('first_name').'';
echo ', ';
echo '';
echo '
'; endif; $post = $the_post; } add_action('save_post', 'save_noticias_metabox'); function save_noticias_metabox( $postid ){ } /*Ideas*/ function listar_ideas(){ global $post; $the_post = $post; $ideas = new WP_Query(array( 'post_type' => 'idea', )); if ( $ideas->have_posts() ) : $i = 0; echo ''. titulo_corto ('...', 50) .'
'; $i++; endwhile; echo ''; while( $ideas->have_posts() && $i < 4 ) : $ideas->the_post(); echo '- ';
echo'';
echo ''.the_author_meta('first_name').'';
echo ', ';
echo '';
echo '
'; endif; $post = $the_post; } add_action('save_post', 'save_ideas_metabox'); function save_ideas_metabox( $postid ){ } /*Eventos*/ function listar_eventos(){ global $post; $the_post = $post; $eventos = new WP_Query(array( 'post_type' => 'evento', )); if ( $eventos->have_posts() ) : $i = 0; echo ''. titulo_corto ('...', 50) .'
'; $i++; endwhile; echo ''; while( $eventos->have_posts() && $i < 4 ) : $eventos->the_post(); echo '- ';
echo'';
echo ''.the_author_meta('first_name').'';
echo ', ';
echo '';
echo '
'; endif; $post = $the_post; } add_action('save_post', 'save_eventos_metabox'); function save_eventos_metabox( $postid ){ } /*Debates*/ function listar_debates(){ global $post; $the_post = $post; $debates = new WP_Query(array( 'post_type' => 'debate', )); if ( $debates->have_posts() ) : $i = 0; echo ''. titulo_corto ('...', 50) .'
'; $i++; endwhile; echo ''; while( $debates->have_posts() && $i < 4 ) : $debates->the_post(); echo '- ';
echo'';
echo ''.the_author_meta('first_name').'';
echo ', ';
echo '';
echo '
'; endif; $post = $the_post; } add_action('save_post', 'save_debates_metabox'); function save_debates_metabox( $postid ){ } /*Proyectos*/ function listar_proyectos(){ global $post; $the_post = $post; $proyectos = new WP_Query(array( 'post_type' => 'proyecto', )); if ( $proyectos->have_posts() ) : $i = 0; echo ''. titulo_corto ('...', 50) .'
'; $i++; endwhile; echo ''; while( $proyectos->have_posts() && $i < 4 ) : $proyectos->the_post(); echo '- ';
echo'';
echo ''.the_author_meta('first_name').'';
echo ', ';
echo '';
echo '
'; endif; $post = $the_post; } add_action('save_post', 'save_proyectos_metabox'); function save_proyectos_metabox( $postid ){ } /*Mercado*/ function listar_mercado(){ global $post; $the_post = $post; $mercado = new WP_Query(array( 'post_type' => 'mercado', )); if ( $mercado->have_posts() ) : $i = 0; echo ''. titulo_corto ('...', 50) .'
'; $i++; endwhile; echo ''; while( $mercado->have_posts() && $i < 4 ) : $mercado->the_post(); echo '- ';
echo'';
echo ''.the_author_meta('first_name').'';
echo ', ';
echo '';
echo '
'; endif; $post = $the_post; } add_action('save_post', 'save_mercado_metabox'); function save_mercado_metabox( $postid ){ } /** * @param string $objeto tipo de objeto que se va a enviar o editar * @param object $edit objeto que se está editando **/ function baobab_category_checkbox( $objeto, $edit = false ){ if ( $edit ) { $edit_terms = get_the_terms( $edit->ID, 'category' ); $post_terms = array(); if ( $edit_terms ) { foreach ( $edit_terms as $et ) { $post_terms[] = $et->term_id; } } } $terms = get_terms('category', array('hide_empty'=>false)); if ( $terms ) { echo ''. titulo_corto ('...', 50) .'
'; $i++; endwhile; echo ''; foreach ( $terms as $term ) { $exits = array($term->term_id) ? '' : ''; /* $exits = in_array($term->term_id, $post_terms) ? ' checked="checked" ' : ''; */ echo ''; } echo '
'; } } function estorninos_search_query( $request ){ $dummy_query = new WP_Query(); // the query isn't run if we don't pass any query vars $dummy_query->parse_query( $request ); // this is the actual manipulation; do whatever you need here if ( $dummy_query->is_search() ) { $request['post_type'] = 'any'; $request['post_per_page'] = 10; //$request['category_name'] = 'news'; } return $request; } add_filter('request', 'estorninos_search_query'); /* Permito Widgets */ if ( function_exists('register_sidebars') ) register_sidebars(1); /* add a default-gravatar to options */ if ( !function_exists('fb_addgravatar') ) { function fb_addgravatar( $avatar_defaults ) { $myavatar = get_template_directory_uri('template_directory') . '/images/avatar.png'; $avatar_defaults[$myavatar] = 'Estornino'; return $avatar_defaults; } add_filter( 'avatar_defaults', 'fb_addgravatar' ); } /* Baobab Multilenguaje */ load_theme_textdomain( 'Baobab', get_template_directory().'/languages' ); $locale = get_locale(); $locale_file = get_template_directory()."/languages/$locale.php"; if ( is_readable($locale_file) ) require_once($locale_file); /* Aparecen los Customs Posts en el resultado de las Categorías */ function namespace_add_custom_types( $query ) { if( is_category() && empty( $query->query_vars['suppress_filters'] ) ) { $query->set( 'post_type', array( 'post', 'proyecto', 'idea', 'debate', 'evento', 'mercado')); return $query; } } add_filter( 'pre_get_posts', 'namespace_add_custom_types' ); /* Conceptos a Traducir: Noticias, Proyectos, Debates, Eventos, Ideas y Mercado*/ function traducir_conceptos() { ?> editar-perfil.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Editar Perfil", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("editar-perfil.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Página de Logueo -> iniciar-sesion.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Inicia Sesión", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("iniciar-sesion.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Página de Registro -> registro.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Registro", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("registro.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Archivo Noticias -> archive.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Noticias", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("archive.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Archivo Proyectos -> archive-proyecto.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Proyectos", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("archive-proyecto.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Archivo Debates -> archive-debate.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Debates", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("archive-debate.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Archivo Eventos -> archive-evento.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Eventos", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("archive-evento.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Archivo Ideas -> archive-idea.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Ideas", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("archive-idea.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Archivo Mercado -> archive-mercado.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Mercado", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("archive-mercado.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Enviar Proyecto -> plantilla-enviar-proyecto.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Enviar Proyecto", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("plantilla-enviar-proyecto.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Enviar Debate -> plantilla-enviar-debate.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Enviar Debate", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("plantilla-enviar-debate.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Enviar Evento -> plantilla-enviar-evento.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Enviar Evento", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("plantilla-enviar-evento.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Enviar Idea -> plantilla-enviar-idea.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Enviar Idea", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("plantilla-enviar-idea.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Página: Enviar Mercado -> plantilla-enviar-mercado.php */ if ( isset($_GET['activated']) ) { if (isset($_GET['activated']) && is_admin()) $pages = array( 'post_name' => __("Enviar Mercado", "Baobab"), ); foreach ($pages as $value) { $page_check = get_page_by_title($pages); $post = array( 'post_name' => $value, 'post_status' => 'publish', 'post_title' => $value, 'post_type' => 'page', ); $id = wp_insert_post( $post, $wp_error); $template = strtolower("plantilla-enviar-mercado.php"); $update = update_post_meta($id, '_wp_page_template', $template); } } /* Creación de Tablas */ // if (isset($_GET['activated']) && is_admin()) // $sql_t_participantes = "CREATE TABLE IF NOT EXISTS wp_participantes ( // id bigint(20) NOT NULL auto_increment, // post_id int(11) NOT NULL, // user_id int(11) NOT NULL, // PRIMARY KEY (id) // ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0;"; // $sql_t_votes ="CREATE TABLE IF NOT EXISTS wp_votes ( // id bigint(20) NOT NULL auto_increment, // post_id int(11) NOT NULL, // vote_text varchar(255) NOT NULL, // PRIMARY KEY (id) // ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0;"; // $sql_t_votes_user = " CREATE TABLE IF NOT EXISTS wp_votes_user ( // id bigint(20) NOT NULL auto_increment, // post_id int(11) NOT NULL, // vote_id int(11) NOT NULL, // user_id int(11) NOT NULL, // PRIMARY KEY (id) // ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0;"; // mysql_query($sql_t_participantes); // mysql_query($sql_t_votes); // mysql_query($sql_t_votes_user); /* Campos de Twitter y Facebook en el Perfil del Usuario */ add_action( 'show_user_profile', 'show_extra_profile_fields', 10 ); add_action( 'edit_user_profile', 'show_extra_profile_fields', 10 ); function show_extra_profile_fields( $user ) { ?>