Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

395 lines (347 sloc) 17.296 kb
<?php
add_theme_support('menus');
function home_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter('wp_page_menu_args', 'home_page_menu_args');
// Clean up the <head>
function removeHeadLinks() {
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
}
add_action('init', 'removeHeadLinks');
remove_action('wp_head', 'wp_generator');
// Cargamos los javascripts
function sf_scripts() {
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js');
wp_enqueue_script('jquery');
wp_enqueue_script('cufon', get_stylesheet_directory_uri() . '/js/cufont-yui.js');
wp_enqueue_script('gotham_rounded_book', get_stylesheet_directory_uri() . '/js/gotham_rounded/Gotham_Rounded_Book_325.font.js');
wp_enqueue_script('gotham_rounded_medium', get_stylesheet_directory_uri() . '/js/gotham_rounded/Gotham_Rounded_Medium_350.font.js');
//wp_enqueue_script('sf_slides', get_stylesheet_directory_uri() . '/js/slides/slides.jquery.js', NULL, NULL, true);
wp_enqueue_script('validate', get_stylesheet_directory_uri() . '/js/jquery-validation/jquery.validate.min.js', NULL, NULL, true);
wp_enqueue_script('validate_l10n', get_stylesheet_directory_uri() . '/js/jquery-validation/localization/messages_es.js', NULL, NULL, true);
wp_enqueue_script('fancybox', get_stylesheet_directory_uri() . '/js/jquery.fancybox/jquery.fancybox-1.3.4.pack.js', NULL, NULL, true);
wp_enqueue_script('nivo', get_stylesheet_directory_uri() . '/js/nivo-slider/jquery.nivo.slider.js', NULL, NULL, true);
wp_enqueue_script('sofammm', get_stylesheet_directory_uri() . '/js/sofammm.js', NULL, NULL, true);
}
add_action('wp_enqueue_scripts', 'sf_scripts');
// Medidas para las imágenes
/*
if (function_exists('add_theme_support')) {
add_theme_support('post-thumbnails');
set_post_thumbnail_size(150, 150, true);
add_image_size(PREFIJO_PLUGIN . 'thumb', 218, 123, true); // Thumbnail
add_image_size(PREFIJO_PLUGIN . 'foto1', 698, 308, true); // Foto grande
add_image_size(PREFIJO_PLUGIN . 'thumb2', 158, 68, true); // Foto mediana
add_image_size(PREFIJO_PLUGIN . 'thumb3', 158, 73, true); // Foto relacionados
add_image_size(PREFIJO_PLUGIN . 'thumb4', 63, 63, true); // Foto favoritos
add_image_size(PREFIJO_PLUGIN . 'testimonio_thumb', 70, 70, true); // Foto testimonios
add_image_size(PREFIJO_PLUGIN . 'modulos_libres_thumb', 220, 147, true); // Foto módulos libres
}
*/
// Quitamos los <p> del contenido de los wysiwg
remove_filter('the_content', 'wpautop');
// Área para el widget de los tweets
register_sidebar( array(
'name' => __('Área tweets'),
'id' => 'area-tweets',
'description' => __('Zona para el widget de twitter'),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h4 class="encabezado_recuadro_izq">',
'after_title' => '</h4>',
) );
// Área para el widget del breadcrumb
register_sidebar( array(
'name' => __('Área breadcrumb'),
'id' => 'area-breadcrumb',
'description' => __('Zona para el breadcrumb')
));
// Área para el widget de AddThis
register_sidebar( array(
'name' => __('Área iconos compartir'),
'id' => 'area-compartir',
'description' => __('Zona para los iconos de compartir')
));
// Opciones de administración
function sofammm_opciones_menu() {
add_theme_page('Opciones Sofammm', 'Opciones Sofammm', 'edit_theme_options', 'sofammm-opciones', 'sofammm_pagina_opciones');
}
add_action('admin_menu', 'sofammm_opciones_menu');
function sofammm_pagina_opciones() {
?>
<div class="wrap">
<?php if ( isset( $_GET['settings-updated'] ) ) {
echo "<div class='updated'><p>Se han actualizado las opciones del tema.</p></div>";
} ?>
<form action="options.php" method="post">
<?php
settings_fields('theme_sofammm_opciones');
do_settings_sections('sofammm');
?>
<br />
<input name="theme_sofammm_options[submit-general]" type="submit" class="button-primary" value="<?php esc_attr_e('Guardar opciones', 'sofammm'); ?>" />
</form>
</div>
<?php
}
function sofammm_opciones_init() {
register_setting('theme_sofammm_opciones', 'theme_sofammm_opciones', 'sofammm_opciones_validacion');
add_settings_section('sofammm_opciones_seccion', _x('Opciones generales', 'Administración de opciones del tema'), 'sofammm_texto_seccion', 'sofammm');
add_settings_field('sofammm_datos_contacto', 'Datos de contacto', 'sofammm_opciones_datos_contacto', 'sofammm', 'sofammm_opciones_seccion');
add_settings_field('sofammm_url_facebook', 'URL Facebook', 'sofammm_opciones_url_facebook', 'sofammm', 'sofammm_opciones_seccion');
add_settings_field('sofammm_url_twitter', 'URL Twitter', 'sofammm_opciones_url_twitter', 'sofammm', 'sofammm_opciones_seccion');
add_settings_field('sofammm_url_linkedin', 'URL LinkedIn', 'sofammm_opciones_url_linkedin', 'sofammm', 'sofammm_opciones_seccion');
add_settings_field('sofammm_url_flickr', 'URL Flickr', 'sofammm_opciones_url_flickr', 'sofammm', 'sofammm_opciones_seccion');
}
add_action('admin_init', 'sofammm_opciones_init');
function sofammm_texto_seccion() {
}
function sofammm_opciones_datos_contacto() {
$opciones = get_option('theme_sofammm_opciones');
echo "<input id='sofammm_datos_contacto' name='theme_sofammm_opciones[datos_contacto]' type='text' size='60' value='{$opciones['datos_contacto']}' />
(" . _x("aparecerán en el pie de la página", "Administración de opciones del tema") . ")";
}
function sofammm_opciones_url_facebook() {
$opciones = get_option('theme_sofammm_opciones');
echo "<input id='sofammm_url_facebook' name='theme_sofammm_opciones[url_facebook]' type='text' size='60' value='{$opciones['url_facebook']}' />";
}
function sofammm_opciones_url_twitter() {
$opciones = get_option('theme_sofammm_opciones');
echo "<input id='sofammm_url_twitter' name='theme_sofammm_opciones[url_twitter]' type='text' size='60' value='{$opciones['url_twitter']}' />";
}
function sofammm_opciones_url_linkedin() {
$opciones = get_option('theme_sofammm_opciones');
echo "<input id='sofammm_url_linkedin' name='theme_sofammm_opciones[url_linkedin]' type='text' size='60' value='{$opciones['url_linkedin']}' />";
}
function sofammm_opciones_url_flickr() {
$opciones = get_option('theme_sofammm_opciones');
echo "<input id='sofammm_url_flickr' name='theme_sofammm_opciones[url_flickr]' type='text' size='60' value='{$opciones['url_flickr']}' />";
}
function sofammm_opciones_validacion($dato) {
$nuevo_dato["datos_contacto"] = trim($dato["datos_contacto"]);
$nuevo_dato["url_facebook"] = trim($dato["url_facebook"]);
$nuevo_dato["url_twitter"] = trim($dato["url_twitter"]);
$nuevo_dato["url_linkedin"] = trim($dato["url_linkedin"]);
$nuevo_dato["url_flickr"] = trim($dato["url_flickr"]);
if ($nuevo_dato["url_facebook"] != "" && substr($nuevo_dato["url_facebook"], 0, 4) != "http") $nuevo_dato["url_facebook"] = "http://" . $nuevo_dato["url_facebook"];
if ($nuevo_dato["url_twitter"] != "" && substr($nuevo_dato["url_twitter"], 0, 4) != "http") $nuevo_dato["url_twitter"] = "http://" . $nuevo_dato["url_twitter"];
if ($nuevo_dato["url_linkedin"] != "" && substr($nuevo_dato["url_linkedin"], 0, 4) != "http") $nuevo_dato["url_linkedin"] = "http://" . $nuevo_dato["url_linkedin"];
if ($nuevo_dato["url_flickr"] != "" && substr($nuevo_dato["url_flickr"], 0, 4) != "http") $nuevo_dato["url_flickr"] = "http://" . $nuevo_dato["url_flickr"];
return $nuevo_dato;
}
// Conexiones Post2Post
function sf_conexiones() {
global $post;
// Comprobamos que el plugin Posts 2 Posts está activado
if (!function_exists('p2p_register_connection_type'))
return;
p2p_register_connection_type( array(
'name' => 'modulos_to_productos',
'from' => 'sf_modulos_post',
'to' => 'sf_productos',
'title' => __('Pertenece a'),
'can_create_post' => false,
'admin_column' => 'from'
));
}
add_action('init', 'sf_conexiones', 100);
// Cargamos el dominio de traducciones
function sf_carga_textdomain() {
load_theme_textdomain('sofammm', TEMPLATEPATH . '/po');
}
add_action('init', 'sf_carga_textdomain');
// Ocultamos opciones en el admin
if (!function_exists('sf_quitar_opciones_menu_admin')) {
function sf_quitar_opciones_menu_admin() {
global $menu;
unset($menu[5]); // Entradas
unset($menu[15]); // Enlaces
unset($menu[25]); // Comentarios
}
}
add_action('admin_menu', 'sf_quitar_opciones_menu_admin');
// Paginación
function sf_paginacion($pages = '', $range = 2) {
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if ($pages == '') {
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages) {
$pages = 1;
}
}
if (1 != $pages) {
echo "<div class='separador'></div><div class='divisor_puntos inferior'></div><ul class='paginacion'>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo "<li class='numeros'><a href='".get_pagenum_link($i)."' class='" . ($i == $paged ? "actual" : "") . "' >".$i."</a></li>";
}
}
if ($paged > 1) echo "<li class='limites'><a href='" . get_pagenum_link($paged - 1) . "'>" . __("Anterior", "Sofammm") . "</a></li>";
if ($paged < $pages && $paged > 1) echo "<li class='limites'>|</li>";
if ($paged < $pages) echo "<li class='limites'><a href='" . get_pagenum_link($paged + 1) . "'>" . __("Siguiente", "Sofammm") . "</a></li>";
echo "</ul>\n";
}
}
// Extendemos la clase walker del menú para hacer dinámico el link a la página de inicio
class sf_walker extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
$class_names = ' class="'. esc_attr( $class_names ) . '"';
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
if ($item->ID == 364) { // Link a la Home
$attributes .= ' href="' . home_url() .'"';
} else {
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
}
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before .apply_filters( 'the_title', $item->title, $item->ID );
$item_output .= $args->link_after;
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
}
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-author vcard">
<?//php echo get_avatar( $comment->comment_author_email, 48 ); ?>
<?php printf(__('<cite class="fn">%s</cite> <span class="says"></span>'), get_comment_author_link()) ?><br/>
<a class="comment-date" href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s'), get_comment_date(), get_comment_time()) ?></a>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata"><?php edit_comment_link(__('(Edit)'),' ','') ?></div>
<div class="comment-data">
<?php comment_text() ?>
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
</div>
<div style="clear:both">&nbsp;</div>
<div class="sep">&nbsp;</div>
</div>
<?php
}
function my_category( $separator = '', $parents='', $post_id = false ) {
global $wp_rewrite;
$categories = get_the_category( $post_id );
if ( !is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) )
return apply_filters( 'the_category', '', $separator, $parents );
if ( empty( $categories ) )
return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents );
$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
$thelist = '';
if ( '' == $separator ) {
$thelist .= '<ul class="post-categories">';
foreach ( $categories as $category ) {
$thelist .= "\n\t<li>";
switch ( strtolower( $parents ) ) {
case 'multiple':
if ( $category->parent )
$thelist .= get_category_parents( $category->parent, true, $separator );
$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "%s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
break;
case 'single':
$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "%s" ), $category->name ) ) . '" ' . $rel . '>';
if ( $category->parent )
$thelist .= get_category_parents( $category->parent, false, $separator );
$thelist .= $category->name.'</a></li>';
break;
case '':
default:
$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "%s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
}
}
$thelist .= '</ul>';
} else {
$i = 0;
foreach ( $categories as $category ) {
if ( 0 < $i )
$thelist .= $separator;
switch ( strtolower( $parents ) ) {
case 'multiple':
if ( $category->parent )
$thelist .= get_category_parents( $category->parent, true, $separator );
$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "%s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
break;
case 'single':
$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "%s" ), $category->name ) ) . '" ' . $rel . '>';
if ( $category->parent )
$thelist .= get_category_parents( $category->parent, false, $separator );
$thelist .= "$category->name</a>";
break;
case '':
default:
$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "%s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'<img src="'. $category->term_icon . '"/></a>';
}
++$i;
}
}
return apply_filters( 'the_category', $thelist, $separator, $parents );
}
add_action( 'widgets_init', 'my_register_sidebars' );
function my_register_sidebars() {
/*Home sidebar*/
$blog_sidebar_one=array(
'id' => 'blog_sidebar_one',
'name' => __( 'Sidebar One: Reserved for Image' ),
'description' => __( 'This sidebar is designed for displaying Image' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<div class="image-title">',
'after_title' => '</div>'
);
$blog_sidebar_three=array(
'id' => 'blog_sidebar_three',
'name' => __( 'Sidebar Two: Reserved for Twitter' ),
'description' => __( 'This sidebar is designed for displaying Twitter' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="twitter-title">',
'after_title' => '</h3>'
);
$blog_sidebar_two=array(
'id' => 'blog_sidebar_two',
'name' => __( 'Sidebar Two: Reserved for archives' ),
'description' => __( 'This sidebar is designed for displaying archives' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="archive-title">',
'after_title' => '</h3>'
);
$blog_sidebar_four=array(
'id' => 'blog_sidebar_four',
'name' => __( 'Sidebar Four: Add category image' ),
'description' => __( 'This sidebar is designed for adding category image (Size: 52 by 42 pixels)' ),
//'before_widget' => '<div id="%1$s" class="widget %2$s">',
//'after_widget' => '</div>',
//'before_title' => '<h3 class="cat-img">',
//'after_title' => '</h3>'
);
register_sidebar( $blog_sidebar_one );
register_sidebar( $blog_sidebar_two );
register_sidebar( $blog_sidebar_three );
register_sidebar( $blog_sidebar_four );
}
?>
Jump to Line
Something went wrong with that request. Please try again.