%2$s';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '';
}
$time_string = sprintf(
$time_string,
esc_attr( get_the_date( DATE_W3C ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( DATE_W3C ) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf(
/* translators: %s: post date. */
esc_html_x( 'Publicado el %s', 'post date', 'roi' ),
'' . $time_string . ''
);
echo '' . $posted_on . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* Prints HTML with meta information for the current author.
*
* @since 1.0.0
*/
function roi_posted_by() {
$byline = sprintf(
/* translators: %s: post author. */
esc_html_x( 'por %s', 'post author', 'roi' ),
'' . esc_html( get_the_author() ) . ''
);
echo ' ' . $byline . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* Prints HTML with meta information for the categories, tags, and comments.
*
* @since 1.0.0
*/
function roi_entry_footer() {
// Hide category and tag text for pages.
if ( 'post' === get_post_type() ) {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ', ', 'roi' ) );
if ( $categories_list ) {
/* translators: 1: list of categories. */
printf( '' . esc_html__( 'Categorías: %1$s', 'roi' ) . '', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'roi' ) );
if ( $tags_list ) {
/* translators: 1: list of tags. */
printf( '' . esc_html__( 'Etiquetas: %1$s', 'roi' ) . '', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '';
}
edit_post_link(
sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Editar %s', 'roi' ),
array(
'span' => array(
'class' => array(),
),
)
),
wp_kses_post( get_the_title() )
),
'',
''
);
}
/**
* Custom excerpt length
*
* @since 1.0.0
* @param int $length Default excerpt length.
* @return int Modified excerpt length.
*/
function roi_excerpt_length( $length ) {
if ( is_admin() ) {
return $length;
}
return 40; // Change this to desired excerpt length.
}
add_filter( 'excerpt_length', 'roi_excerpt_length', 999 );
/**
* Custom excerpt more string
*
* @since 1.0.0
* @param string $more Default more string.
* @return string Modified more string.
*/
function roi_excerpt_more( $more ) {
if ( is_admin() ) {
return $more;
}
return '…';
}
add_filter( 'excerpt_more', 'roi_excerpt_more' );
/**
* Get custom excerpt by character count
*
* @since 1.0.0
* @param int $charlength Character length.
* @param string $more More string.
* @return string Custom excerpt.
*/
function roi_get_excerpt( $charlength = 200, $more = '...' ) {
$excerpt = get_the_excerpt();
$charlength++;
if ( mb_strlen( $excerpt ) > $charlength ) {
$subex = mb_substr( $excerpt, 0, $charlength - 5 );
$exwords = explode( ' ', $subex );
$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
if ( $excut < 0 ) {
$excerpt = mb_substr( $subex, 0, $excut );
} else {
$excerpt = $subex;
}
$excerpt .= $more;
}
return $excerpt;
}
/**
* Get post thumbnail URL
*
* @since 1.0.0
* @param string $size Image size.
* @return string|false Thumbnail URL or false if not found.
*/
function roi_get_post_thumbnail_url( $size = 'full' ) {
if ( has_post_thumbnail() ) {
$thumb_id = get_post_thumbnail_id();
$thumb = wp_get_attachment_image_src( $thumb_id, $size );
if ( $thumb ) {
return $thumb[0];
}
}
return false;
}
/**
* Display breadcrumbs
*
* @since 1.0.0
* @param array $args Breadcrumb arguments.
*/
function roi_breadcrumbs( $args = array() ) {
// Default arguments.
$defaults = array(
'separator' => '/',
'home_label' => esc_html__( 'Inicio', 'roi' ),
'show_home' => true,
'show_current' => true,
'before' => '',
'link_before' => '
',
'link_after' => '',
);
$args = wp_parse_args( $args, $defaults );
// Don't display on homepage.
if ( is_front_page() ) {
return;
}
global $post;
echo $args['before']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
// Home link.
if ( $args['show_home'] ) {
echo $args['link_before'] . '' . esc_html( $args['home_label'] ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['separator']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
if ( is_category() ) {
$category = get_queried_object();
if ( $category->parent ) {
$parent_cats = get_category_parents( $category->parent, true, $args['separator'] );
echo $args['link_before'] . $parent_cats . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo $args['link_before'] . '' . esc_html( single_cat_title( '', false ) ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( is_single() && ! is_attachment() ) {
if ( get_post_type() !== 'post' ) {
$post_type = get_post_type_object( get_post_type() );
$post_type_archive = get_post_type_archive_link( get_post_type() );
if ( $post_type_archive ) {
echo $args['link_before'] . '' . esc_html( $post_type->labels->name ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['separator']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
if ( $args['show_current'] ) {
echo $args['link_before'] . '' . esc_html( get_the_title() ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
} else {
$category = get_the_category();
if ( $category ) {
$category_values = array_values( $category );
$category_last = end( $category_values );
$category_parents = get_category_parents( $category_last->term_id, true, $args['separator'] );
echo $args['link_before'] . $category_parents . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
if ( $args['show_current'] ) {
echo $args['link_before'] . '' . esc_html( get_the_title() ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
} elseif ( is_page() && ! $post->post_parent ) {
if ( $args['show_current'] ) {
echo $args['link_before'] . '' . esc_html( get_the_title() ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
} elseif ( is_page() && $post->post_parent ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ( $parent_id ) {
$page = get_post( $parent_id );
$breadcrumbs[] = '' . esc_html( get_the_title( $page->ID ) ) . '';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse( $breadcrumbs );
foreach ( $breadcrumbs as $crumb ) {
echo $args['link_before'] . $crumb . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['separator']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
if ( $args['show_current'] ) {
echo $args['link_before'] . '' . esc_html( get_the_title() ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
} elseif ( is_search() ) {
echo $args['link_before'] . '' . esc_html__( 'Resultados de búsqueda para: ', 'roi' ) . get_search_query() . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( is_tag() ) {
echo $args['link_before'] . '' . esc_html__( 'Etiqueta: ', 'roi' ) . esc_html( single_tag_title( '', false ) ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( is_author() ) {
$author = get_queried_object();
echo $args['link_before'] . '' . esc_html__( 'Autor: ', 'roi' ) . esc_html( $author->display_name ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( is_day() ) {
echo $args['link_before'] . '' . esc_html( get_the_time( 'Y' ) ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['separator']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['link_before'] . '' . esc_html( get_the_time( 'F' ) ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['separator']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['link_before'] . '' . esc_html( get_the_time( 'd' ) ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( is_month() ) {
echo $args['link_before'] . '' . esc_html( get_the_time( 'Y' ) ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['separator']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['link_before'] . '' . esc_html( get_the_time( 'F' ) ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( is_year() ) {
echo $args['link_before'] . '' . esc_html( get_the_time( 'Y' ) ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( is_404() ) {
echo $args['link_before'] . '' . esc_html__( 'Error 404', 'roi' ) . '' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo $args['after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* Add custom body classes
*
* @since 1.0.0
* @param array $classes Existing body classes.
* @return array Modified body classes.
*/
function roi_body_classes( $classes ) {
// Add class if sidebar is active.
if ( is_active_sidebar( 'sidebar-1' ) ) {
$classes[] = 'has-sidebar';
} else {
$classes[] = 'no-sidebar';
}
// Add class if it's a singular post/page.
if ( is_singular() ) {
$classes[] = 'singular';
}
// Add class for specific post formats.
if ( is_singular() && has_post_format() ) {
$post_format = get_post_format();
$classes[] = 'post-format-' . $post_format;
}
return $classes;
}
add_filter( 'body_class', 'roi_body_classes' );
/**
* Add custom post classes
*
* @since 1.0.0
* @param array $classes Existing post classes.
* @return array Modified post classes.
*/
function roi_post_classes( $classes ) {
// Add class if post has thumbnail.
if ( has_post_thumbnail() ) {
$classes[] = 'has-post-thumbnail';
} else {
$classes[] = 'no-post-thumbnail';
}
return $classes;
}
add_filter( 'post_class', 'roi_post_classes' );
/**
* Sanitize SVG uploads
*
* @since 1.0.0
* @param array $mimes Allowed mime types.
* @return array Modified mime types.
*/
function roi_add_svg_mime_types( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'roi_add_svg_mime_types' );
/**
* Pagination for archive pages
*
* @since 1.0.0
* @param array $args Pagination arguments.
*/
function roi_pagination( $args = array() ) {
global $wp_query;
// Don't print empty markup if there's only one page.
if ( $wp_query->max_num_pages < 2 ) {
return;
}
$defaults = array(
'mid_size' => 2,
'prev_text' => esc_html__( '← Anterior', 'roi' ),
'next_text' => esc_html__( 'Siguiente →', 'roi' ),
'screen_reader_text' => esc_html__( 'Navegación de entradas', 'roi' ),
'type' => 'list',
'current' => max( 1, get_query_var( 'paged' ) ),
);
$args = wp_parse_args( $args, $defaults );
// Make sure we get a string back. Plain is the next best thing.
if ( isset( $args['type'] ) && 'array' === $args['type'] ) {
$args['type'] = 'plain';
}
echo '';
}
/**
* Get footer column Bootstrap class
*
* Returns the appropriate Bootstrap grid classes for footer columns
* based on the column number. Supports configurable widths and
* responsive breakpoints.
*
* @since 1.0.0
* @param int $column Column number (1-4).
* @return string Bootstrap column classes.
*/
function roi_get_footer_column_class( $column = 1 ) {
// Default configuration: Equal width columns (3 columns each on desktop).
// You can customize these classes per column as needed.
$column_classes = array(
1 => 'col-12 col-md-6 col-lg-3', // Column 1: Full width mobile, half tablet, quarter desktop.
2 => 'col-12 col-md-6 col-lg-3', // Column 2: Full width mobile, half tablet, quarter desktop.
3 => 'col-12 col-md-6 col-lg-3', // Column 3: Full width mobile, half tablet, quarter desktop.
4 => 'col-12 col-md-6 col-lg-3', // Column 4: Full width mobile, half tablet, quarter desktop.
);
/**
* Filter footer column classes
*
* Allows customization of footer column widths via filter.
*
* @since 1.0.0
* @param array $column_classes Array of column classes.
*/
$column_classes = apply_filters( 'roi_footer_column_classes', $column_classes );
// Return the class for the specified column, or default to col-12 if not found.
return isset( $column_classes[ $column ] ) ? $column_classes[ $column ] : 'col-12';
}