Entradas etiquetadas con vÃnculo

WordPress 3.x para desarrolladores: Temas y plantillas, content-image.php, content-link.php, content-quote.php y content-status.php
0CONTENT-IMAGE.PHP
Creamos el archivo content-image.php y añadimos el siguiente código:
- <?php
- /**
- * The template for displaying posts in the Image Post Format on index and archive pages
- *
- * Learn more: http://codex.wordpress.org/Post_Formats
- *
- * @package WordPress
- * @subpackage New_Theme
- */
- ?>
- <article id="post-<?php the_ID(); ?>" <?php post_class( 'indexed' ); ?>>
- <header class="entry-header">
- <hgroup>
- <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php mujeres solteras cali colombia( esc_attr__( 'Permalink to %s', 'newtheme' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
- <h3 class="entry-format"><?php _e( 'Image', 'newtheme' ); ?></h3>
- </hgroup>
-
- <?php if ( comments_open() && ! post_password_required() ) : ?>
- <div class="comments-link">
- <?php comments_popup_link( '<span class="leave-reply">' . __( "Reply", 'newtheme' ) . '</span>', _x( '1', 'comments number', 'newtheme' ), _x( '%', 'comments number', 'newtheme' ) ); ?>
- </div>
- <?php endif; ?>
- </header><!-- .entry-header -->
-
- <div class="entry-content">
- <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'newtheme' ) ); ?>
- <?php wp_link_pages( https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'newtheme' ) . '</span>', 'after' => '</div>' ) ); ?>
- </div><!-- .entry-content -->
-
- <footer class="entry-meta">
- <div class="entry-meta">
- <?php
- mujeres solteras cali colombia( __( '<a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s" pubdate>%3$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%4$s" title="%5$s" rel="author">%6$s</a></span></span>', 'newtheme' ),
- esc_url( get_permalink() ),
- get_the_date( 'c' ),
- get_the_date(),
- esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
- esc_attr( https://www.interadictos.es/citas-web-caja-del-seguro-social/( __( 'View all posts by %s', 'newtheme' ), get_the_author() ) ),
- get_the_author()
- );
- ?>
- </div><!-- .entry-meta -->
- <div class="entry-meta">
- <?php
- /* translators: used between list items, there is a space after the comma */
- $categories_list = get_the_category_list( __( ', ', 'newtheme' ) );
- if ( $categories_list ):
- ?>
- <span class="cat-links">
- <?php mujeres solteras cali colombia( __( '<span class="%1$s">Posted in</span> %2$s', 'newtheme' ), 'entry-utility-prep entry-utility-prep-cat-links', $categories_list ); ?>
- </span>
- <?php endif; // End if categories ?>
- <?php
- /* translators: used between list items, there is a space after the comma */
- $tags_list = get_the_tag_list( '', __( ', ', 'newtheme' ) );
- if ( $tags_list ): ?>
- <span class="tag-links">
- <?php mujeres solteras cali colombia( __( '<span class="%1$s">Tagged</span> %2$s', 'newtheme' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
- </span>
- <?php endif; // End if $tags_list ?>
-
- <?php if ( comments_open() ) : ?>
- <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'newtheme' ) . '</span>', __( '<b>1</b> Reply', 'newtheme' ), __( '<b>%</b> Replies', 'newtheme' ) ); ?></span>
- <?php endif; // End if comments_open() ?>
- </div><!-- .entry-meta -->
-
- <?php edit_post_link( __( 'Edit', 'newtheme' ), '<span class="edit-link">', '</span>' ); ?>
- </footer><!-- #entry-meta -->
- </article><!-- #post-<?php the_ID(); ?> -->
Este tipo de contenido simplemente muestra una imagen y su respectivo título.
CONTENT-LINK.PHP
Creamos el archivo content-link.php y añadimos el siguiente código:
- <?php
- /**
- * The template for displaying posts in the Link Post Format on index and archive pages
- *
- * Learn more: http://codex.wordpress.org/Post_Formats
- *
- * @package WordPress
- * @subpackage New_Theme
- */
- ?>
-
- <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
- <header class="entry-header">
- <hgroup>
- <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php mujeres solteras cali colombia( esc_attr__( 'Permalink to %s', 'newtheme' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
- <h3 class="entry-format"><?php _e( 'Link', 'newtheme' ); ?></h3>
- </hgroup>
-
- <?php if ( comments_open() && ! post_password_required() ) : ?>
- <div class="comments-link">
- <?php comments_popup_link( '<span class="leave-reply">' . __( 'Reply', 'newtheme' ) . '</span>', _x( '1', 'comments number', 'newtheme' ), _x( '%', 'comments number', 'newtheme' ) ); ?>
- </div>
- <?php endif; ?>
- </header><!-- .entry-header -->
-
- <?php if ( is_search() ) : // Only display Excerpts for Search ?>
- <div class="entry-summary">
- <?php the_excerpt(); ?>
- </div><!-- .entry-summary -->
- <?php else : ?>
- <div class="entry-content">
- <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'newtheme' ) ); ?>
- <?php wp_link_pages( https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'newtheme' ) . '</span>', 'after' => '</div>' ) ); ?>
- </div><!-- .entry-content -->
- <?php endif; ?>
-
- <footer class="entry-meta">
- <?php newtheme_posted_on(); ?>
- <?php if ( comments_open() ) : ?>
- <span class="sep"> | </span>
- <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'newtheme' ) . '</span>', __( '<b>1</b> Reply', 'newtheme' ), __( '<b>%</b> Replies', 'newtheme' ) ); ?></span>
- <?php endif; ?>
- <?php edit_post_link( __( 'Edit', 'newtheme' ), '<span class="edit-link">', '</span>' ); ?>
- </footer><!-- #entry-meta -->
- </article><!-- #post-<?php the_ID(); ?> -->
Este contenido es más sencillo aún. Simplemente mostramos un link o un conjunto de estos.
CONTENT-QUOTE.PHP
Creamos el archivo content-quote.php y añadimos el siguiente código:
- <?php
-
- <?php
- /**
- * The default template for displaying content
- *
- * @package WordPress
- * @subpackage New_Theme
- */
- ?>
-
- <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
- <header class="entry-header">
- <hgroup>
- <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php mujeres solteras cali colombia( esc_attr__( 'Permalink to %s', 'newtheme' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
- <h3 class="entry-format"><?php _e( 'Quote', 'newtheme' ); ?></h3>
- </hgroup>
-
- <div class="entry-meta">
- <?php newtheme_posted_on(); ?>
- </div><!-- .entry-meta -->
-
- <?php if ( comments_open() && ! post_password_required() ) : ?>
- <div class="comments-link">
- <?php comments_popup_link( '<span class="leave-reply">' . __( 'Reply', 'newtheme' ) . '</span>', _x( '1', 'comments number', 'newtheme' ), _x( '%', 'comments number', 'newtheme' ) ); ?>
- </div>
- <?php endif; ?>
- </header><!-- .entry-header -->
-
- <?php if ( is_search() ) : // Only display Excerpts for Search ?>
- <div class="entry-summary">
- <?php the_excerpt(); ?>
- </div><!-- .entry-summary -->
- <?php else : ?>
- <div class="entry-content">
- <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'newtheme' ) ); ?>
- <?php wp_link_pages( https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'newtheme' ) . '</span>', 'after' => '</div>' ) ); ?>
- </div><!-- .entry-content -->
- <?php endif; ?>
-
- <footer class="entry-meta">
- <?php $show_sep = false; ?>
- <?php
- /* translators: used between list items, there is a space after the comma */
- $categories_list = get_the_category_list( __( ', ', 'newtheme' ) );
- if ( $categories_list ):
- ?>
- <span class="cat-links">
- <?php mujeres solteras cali colombia( __( '<span class="%1$s">Posted in</span> %2$s', 'newtheme' ), 'entry-utility-prep entry-utility-prep-cat-links', $categories_list );
- $show_sep = true; ?>
- </span>
- <?php endif; // End if categories ?>
- <?php
- /* translators: used between list items, there is a space after the comma */
- $tags_list = get_the_tag_list( '', __( ', ', 'newtheme' ) );
- if ( $tags_list ):
- if ( $show_sep ) : ?>
- <span class="sep"> | </span>
- <?php endif; // End if $show_sep ?>
- <span class="tag-links">
- <?php mujeres solteras cali colombia( __( '<span class="%1$s">Tagged</span> %2$s', 'newtheme' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list );
- $show_sep = true; ?>
- </span>
- <?php endif; // End if $tags_list ?>
-
- <?php if ( comments_open() ) : ?>
- <?php if ( $show_sep ) : ?>
- <span class="sep"> | </span>
- <?php endif; // End if $show_sep ?>
- <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'newtheme' ) . '</span>', __( '<b>1</b> Reply', 'newtheme' ), __( '<b>%</b> Replies', 'newtheme' ) ); ?></span>
- <?php endif; // End if comments_open() ?>
-
- <?php edit_post_link( __( 'Edit', 'newtheme' ), '<span class="edit-link">', '</span>' ); ?>
- </footer><!-- #entry-meta -->
- </article><!-- #post-<?php the_ID(); ?> -->
Más de lo mismo, lo único que cambia es que aparece un subtítulo indicando que es una cita.
CONTENT-STATUS.PHP
Creamos el archivo content-status.php y añadimos el siguiente código:
- <?php
- /**
- * The template for displaying posts in the Status Post Format on index and archive pages
- *
- * Learn more: http://codex.wordpress.org/Post_Formats
- *
- * @package WordPress
- * @subpackage New_Theme
- */
- ?>
-
- <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
- <header class="entry-header">
- <hgroup>
- <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php mujeres solteras cali colombia( esc_attr__( 'Permalink to %s', 'newtheme' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
- <h3 class="entry-format"><?php _e( 'Status', 'newtheme' ); ?></h3>
- </hgroup>
-
- <?php if ( comments_open() && ! post_password_required() ) : ?>
- <div class="comments-link">
- <?php comments_popup_link( '<span class="leave-reply">' . __( 'Reply', 'newtheme' ) . '</span>', _x( '1', 'comments number', 'newtheme' ), _x( '%', 'comments number', 'newtheme' ) ); ?>
- </div>
- <?php endif; ?>
- </header><!-- .entry-header -->
-
- <?php if ( is_search() ) : // Only display Excerpts for Search ?>
- <div class="entry-summary">
- <?php the_excerpt(); ?>
- </div><!-- .entry-summary -->
- <?php else : ?>
- <div class="entry-content">
- <div class="avatar"><?php echo get_avatar( get_the_author_meta( 'ID' ), apply_filters( 'newtheme_status_avatar', '65' ) ); ?></div>
-
- <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'newtheme' ) ); ?>
- <?php wp_link_pages( https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'newtheme' ) . '</span>', 'after' => '</div>' ) ); ?>
- </div><!-- .entry-content -->
- <?php endif; ?>
-
- <footer class="entry-meta">
- <?php newtheme_posted_on(); ?>
- <?php if ( comments_open() ) : ?>
- <span class="sep"> | </span>
- <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'newtheme' ) . '</span>', __( '<b>1</b> Reply', 'newtheme' ), __( '<b>%</b> Replies', 'newtheme' ) ); ?></span>
- <?php endif; ?>
- <?php edit_post_link( __( 'Edit', 'newtheme' ), '<span class="edit-link">', '</span>' ); ?>
- </footer><!-- #entry-meta -->
- </article><!-- #post-<?php the_ID(); ?> -->
En este caso se añade la imagen del perfil del autor o avatar para acompañar al contenido.

WordPress 3.x para desarrolladores: Temas y plantillas, theme-options.php
0Nuestro tema va tomando poco a poco forma. Hoy vamos a crear el archivo theme-options.php que contendrá toda la lógica de las opciones de administración.
THEME-OPTIONS.PHP
Creamos el archivo theme-options.php y añadimos el siguiente código:
- <?php
-
- /**
- * Properly enqueue styles and scripts for our theme options page.
- *
- * This function is attached to the admin_enqueue_scripts action hook.
- */
- function newtheme_admin_enqueue_scripts( $hook_suffix ) {
- wp_enqueue_style( 'newtheme-theme-options', get_template_directory_uri() . '/inc/theme-options.css', false, '2011-04-28' );
- wp_enqueue_script( 'newtheme-theme-options', get_template_directory_uri() . '/inc/theme-options.js', https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/( 'farbtastic' ), '2011-06-10' );
- wp_enqueue_style( 'farbtastic' );
- }
- add_action( 'admin_print_styles-appearance_page_theme_options', 'newtheme_admin_enqueue_scripts' );
Esta función añade un archivo css y un archivo javascript a la cabecera al apartado apariencia de la administración de WordPress.
- <?php
-
- /**
- * Register the form setting for our newtheme_options array.
- *
- * This function is attached to the admin_init action hook.
- *
- * This call to register_setting() registers a validation callback, newtheme_theme_options_validate(),
- * which is used when the option is saved, to ensure that our option values are complete, properly
- * formatted, and safe.
- */
- function newtheme_theme_options_init() {
-
- register_setting(
- 'newtheme_options', // Options group, see settings_fields() call in newtheme_theme_options_render_page()
- 'newtheme_theme_options', // Database option, see newtheme_get_theme_options()
- 'newtheme_theme_options_validate' // The sanitization callback, see newtheme_theme_options_validate()
- );
-
- // Register our settings field group
- add_settings_section(
- 'general', // Unique identifier for the settings section
- '', // Section title (we don't want one)
- '__return_false', // Section callback (we don't want anything)
- 'theme_options' // Menu slug, used to uniquely identify the page; see newtheme_theme_options_add_page()
- );
-
- // Register our individual settings fields
- add_settings_field(
- 'color_scheme', // Unique identifier for the field for this section
- __( 'Color Scheme', 'newtheme' ), // Setting field label
- 'newtheme_settings_field_color_scheme', // Function that renders the settings field
- 'theme_options', // Menu slug, used to uniquely identify the page; see newtheme_theme_options_add_page()
- 'general' // Settings section. Same as the first argument in the add_settings_section() above
- );
-
- add_settings_field( 'link_color', __( 'Link Color', 'newtheme' ), 'newtheme_settings_field_link_color', 'theme_options', 'general' );
- add_settings_field( 'layout', __( 'Default Layout', 'newtheme' ), 'newtheme_settings_field_layout', 'theme_options', 'general' );
- }
- add_action( 'admin_init', 'newtheme_theme_options_init' );
Esta función registra la configuración por defecto del tema y añade varios apartados para la administración.
- <?php
-
- /**
- * Change the capability required to save the 'newtheme_options' options group.
- *
- * @see newtheme_theme_options_init() First parameter to register_setting() is the name of the options group.
- * @see newtheme_theme_options_add_page() The edit_theme_options capability is used for viewing the page.
- *
- * By default, the options groups for all registered settings require the manage_options capability.
- * This filter is required to change our theme options page to edit_theme_options instead.
- * By default, only administrators have either of these capabilities, but the desire here is
- * to allow for finer-grained control for roles and users.
- *
- * @param string $capability The capability used for the page, which is manage_options by default.
- * @return string The capability to actually use.
- */
- function newtheme_option_page_capability( $capability ) {
- return 'edit_theme_options';
- }
- add_filter( 'option_page_capability_newtheme_options', 'newtheme_option_page_capability' );
Esta función permite cambiar las opciones del tema. Es obligatorio para controlar los diversos usuarios y roles que tengan acceso.
- <?php
-
- /**
- * Add our theme options page to the admin menu, including some help documentation.
- *
- * This function is attached to the admin_menu action hook.
- */
- function newtheme_theme_options_add_page() {
- $theme_page = add_theme_page(
- __( 'Theme Options', 'newtheme' ), // Name of page
- __( 'Theme Options', 'newtheme' ), // Label in menu
- 'edit_theme_options', // Capability required
- 'theme_options', // Menu slug, used to uniquely identify the page
- 'newtheme_theme_options_render_page' // Function that renders the options page
- );
-
- if ( ! $theme_page )
- return;
-
- add_action( "load-$theme_page", 'newtheme_theme_options_help' );
- }
- add_action( 'admin_menu', 'newtheme_theme_options_add_page' );
Añade la página de opciones de nuestro tema al menú de administración, incluyendo algo de documentación a la ayuda.
- <?php
-
- function newtheme_theme_options_help() {
-
- $help = '<p>' . __( 'Some themes provide customization options that are grouped together on a Theme Options screen. If you change themes, options may change or disappear, as they are theme-specific. Your current theme, Twenty Eleven, provides the following Theme Options:', 'newtheme' ) . '</p>' .
- '<ol>' .
- '<li>' . __( '<strong>Color Scheme</strong>: You can choose a color palette of "Light" (light background with dark text) or "Dark" (dark background with light text) for your site.', 'newtheme' ) . '</li>' .
- '<li>' . __( '<strong>Link Color</strong>: You can choose the color used for text links on your site. You can enter the HTML color or hex code, or you can choose visually by clicking the "Select a Color" button to pick from a color wheel.', 'newtheme' ) . '</li>' .
- '<li>' . __( '<strong>Default Layout</strong>: You can choose if you want your site’s default layout to have a sidebar on the left, the right, or not at all.', 'newtheme' ) . '</li>' .
- '</ol>' .
- '<p>' . __( 'Remember to click "Save Changes" to save any changes you have made to the theme options.', 'newtheme' ) . '</p>';
-
- $sidebar = '<p><strong>' . __( 'For more information:', 'newtheme' ) . '</strong></p>' .
- '<p>' . __( '<a href="http://codex.wordpress.org/Appearance_Theme_Options_Screen" target="_blank">Documentation on Theme Options</a>', 'newtheme' ) . '</p>' .
- '<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>', 'newtheme' ) . '</p>';
-
- $screen = get_current_screen();
-
- // WordPress 3.3
- 'title' => __( 'Overview', 'newtheme' ),
- 'id' => 'theme-options-help',
- 'content' => $help,
- )
- );
-
- $screen->set_help_sidebar( $sidebar );
- } else {
- // WordPress 3.2
- add_contextual_help( $screen, $help . $sidebar );
- }
- }
Esta es la función que añade la ayuda que comentaba en la función anterior. Aquí además podemos ver como se añade un condicional para añadir retrocompatibilidad con versiones anteriores a la 3.3 y la 3.2.
- <?php
-
- /**
- * Returns an array of color schemes registered for New Theme.
- */
- function newtheme_color_schemes() {
- 'value' => 'light',
- 'label' => __( 'Light', 'newtheme' ),
- 'thumbnail' => get_template_directory_uri() . '/inc/images/light.png',
- 'default_link_color' => '#1b8be0',
- ),
- 'value' => 'dark',
- 'label' => __( 'Dark', 'newtheme' ),
- 'thumbnail' => get_template_directory_uri() . '/inc/images/dark.png',
- 'default_link_color' => '#e4741f',
- ),
- );
-
- return apply_filters( 'newtheme_color_schemes', $color_scheme_options );
- }
Esta función devuelve un array con los esquemas de color para cada versión del tema.
- <?php
-
- /**
- * Returns an array of layout options registered for New Theme.
- */
- function newtheme_layouts() {
- 'value' => 'content-sidebar',
- 'label' => __( 'Content on left', 'newtheme' ),
- 'thumbnail' => get_template_directory_uri() . '/inc/images/content-sidebar.png',
- ),
- 'value' => 'sidebar-content',
- 'label' => __( 'Content on right', 'newtheme' ),
- 'thumbnail' => get_template_directory_uri() . '/inc/images/sidebar-content.png',
- ),
- 'value' => 'content',
- 'label' => __( 'One-column, no sidebar', 'newtheme' ),
- 'thumbnail' => get_template_directory_uri() . '/inc/images/content.png',
- ),
- );
-
- return apply_filters( 'newtheme_layouts', $layout_options );
- }
Devuelve un array con las opciones para cada tipo de estructura del diseño.
- <?php
-
- /**
- * Returns the default options for New Theme.
- */
- function newtheme_get_default_theme_options() {
- 'color_scheme' => 'light',
- 'link_color' => newtheme_get_default_link_color( 'light' ),
- 'theme_layout' => 'content-sidebar',
- );
-
- if ( is_rtl() )
- $default_theme_options['theme_layout'] = 'sidebar-content';
-
- return apply_filters( 'newtheme_default_theme_options', $default_theme_options );
- }
Devuelve las opciones por defecto del tema.
- <?php
-
- /**
- * Returns the default link color for New Theme, based on color scheme.
- *
- *
- * @param $string $color_scheme Color scheme. Defaults to the active color scheme.
- * @return $string Color.
- */
- function newtheme_get_default_link_color( $color_scheme = null ) {
- if ( null === $color_scheme ) {
- $options = newtheme_get_theme_options();
- $color_scheme = $options['color_scheme'];
- }
-
- $color_schemes = newtheme_color_schemes();
- return false;
-
- return $color_schemes[ $color_scheme ]['default_link_color'];
- }
Devuelve el color por defecto para los vínculos.
- <?php
-
- /**
- * Returns the options array for New Theme.
- */
- function newtheme_get_theme_options() {
- return get_option( 'newtheme_theme_options', newtheme_get_default_theme_options() );
- }
Devuelve un array con todas las opciones del tema.
- <?php
-
- /**
- * Renders the Color Scheme setting field.
- */
- function newtheme_settings_field_color_scheme() {
- $options = newtheme_get_theme_options();
-
- foreach ( newtheme_color_schemes() as $scheme ) {
- ?>
- <div class="layout image-radio-option color-scheme">
- <label class="description">
- <input type="radio" name="newtheme_theme_options[color_scheme]" value="<?php echo esc_attr( $scheme['value'] ); ?>" <?php checked( $options['color_scheme'], $scheme['value'] ); ?> />
- <input type="hidden" id="default-color-<?php echo esc_attr( $scheme['value'] ); ?>" value="<?php echo esc_attr( $scheme['default_link_color'] ); ?>" />
- <span>
- <img src="<?php echo esc_url( $scheme['thumbnail'] ); ?>" width="136" height="122" alt="" />
- <?php echo $scheme['label']; ?>
- </span>
- </label>
- </div>
- <?php
- }
- }
Esta función genera el grupo de radio buttons que permitirá elegir entre un esquema de color u otro.
- <?php
-
- /**
- * Renders the Link Color setting field.
- */
- function newtheme_settings_field_link_color() {
- $options = newtheme_get_theme_options();
- ?>
- <input type="text" name="newtheme_theme_options[link_color]" id="link-color" value="<?php echo esc_attr( $options['link_color'] ); ?>" />
- <a href="#" class="pickcolor hide-if-no-js" id="link-color-example"></a>
- <input type="button" class="pickcolor button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color', 'newtheme' ); ?>" />
- <div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
- <br />
- <span><?php mujeres solteras cali colombia( __( 'Default color: %s', 'newtheme' ), '<span id="default-color">' . newtheme_get_default_link_color( $options['color_scheme'] ) . '</span>' ); ?></span>
- <?php
- }
Esta función genera el formulario para poder elegir el color de los vínculos.
- <?php
-
- /**
- * Renders the Layout setting field.
- */
- function newtheme_settings_field_layout() {
- $options = newtheme_get_theme_options();
- foreach ( newtheme_layouts() as $layout ) {
- ?>
- <div class="layout image-radio-option theme-layout">
- <label class="description">
- <input type="radio" name="newtheme_theme_options[theme_layout]" value="<?php echo esc_attr( $layout['value'] ); ?>" <?php checked( $options['theme_layout'], $layout['value'] ); ?> />
- <span>
- <img src="<?php echo esc_url( $layout['thumbnail'] ); ?>" width="136" height="122" alt="" />
- <?php echo $layout['label']; ?>
- </span>
- </label>
- </div>
- <?php
- }
- }
Esta función genera el campo para elegir la estructura del blog.
- <?php
-
- /**
- * Returns the options array for New Theme.
- */
- function newtheme_theme_options_render_page() {
- ?>
- <div class="wrap">
- <?php screen_icon(); ?>
- <h2><?php mujeres solteras cali colombia( __( '%s Theme Options', 'newtheme' ), $theme_name ); ?></h2>
- <?php settings_errors(); ?>
-
- <form method="post" action="options.php">
- <?php
- settings_fields( 'newtheme_options' );
- do_settings_sections( 'theme_options' );
- submit_button();
- ?>
- </form>
- </div>
- <?php
- }
Función que genera todo el formulario de opciones.
- <?php
-
- /**
- * Sanitize and validate form input. Accepts an array, return a sanitized array.
- *
- * @see newtheme_theme_options_init()
- * @todo set up Reset Options action
- */
- function newtheme_theme_options_validate( $input ) {
- $output = $defaults = newtheme_get_default_theme_options();
-
- // Color scheme must be in our array of color scheme options
- if ( isset( $input['color_scheme'] ) && array_key_exists( $input['color_scheme'], newtheme_color_schemes() ) )
- $output['color_scheme'] = $input['color_scheme'];
-
- // Our defaults for the link color may have changed, based on the color scheme.
- $output['link_color'] = $defaults['link_color'] = newtheme_get_default_link_color( $output['color_scheme'] );
-
- // Link color must be 3 or 6 hexadecimal characters
- if ( isset( $input['link_color'] ) && preg_match( '/^#?([a-f0-9]{3}){1,2}$/i', $input['link_color'] ) )
-
- // Theme layout must be in our array of theme layout options
- if ( isset( $input['theme_layout'] ) && array_key_exists( $input['theme_layout'], newtheme_layouts() ) )
- $output['theme_layout'] = $input['theme_layout'];
-
- return apply_filters( 'newtheme_theme_options_validate', $output, $input, $defaults );
- }
Esta función valida que los datos del formulario son correctos.
- <?php
-
- /**
- * Enqueue the styles for the current color scheme.
- */
- function newtheme_enqueue_color_scheme() {
- $options = newtheme_get_theme_options();
- $color_scheme = $options['color_scheme'];
-
- if ( 'dark' == $color_scheme )
- wp_enqueue_style( 'dark', get_template_directory_uri() . '/colors/dark.css', https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/(), null );
-
- do_action( 'newtheme_enqueue_color_scheme', $color_scheme );
- }
- add_action( 'wp_enqueue_scripts', 'newtheme_enqueue_color_scheme' );
Función que cambiará el estilo actual de la página dependiendo del color de esquema elegido.
- <?php
-
- /**
- * Add a style block to the theme for the current link color.
- *
- * This function is attached to the wp_head action hook.
- */
- function newtheme_print_link_color_style() {
- $options = newtheme_get_theme_options();
- $link_color = $options['link_color'];
-
- $default_options = newtheme_get_default_theme_options();
-
- // Don't do anything if the current link color is the default.
- if ( $default_options['link_color'] == $link_color )
- return;
- ?>
- <style>
- /* Link color */
- a,
- #site-title a:focus,
- #site-title a:hover,
- #site-title a:active,
- .entry-title a:hover,
- .entry-title a:focus,
- .entry-title a:active,
- .widget_newtheme_ephemera .comments-link a:hover,
- section.recent-posts .other-recent-posts a[rel="bookmark"]:hover,
- section.recent-posts .other-recent-posts .comments-link a:hover,
- .format-image footer.entry-meta a:hover,
- #site-generator a:hover {
- color: <?php echo $link_color; ?>;
- }
- section.recent-posts .other-recent-posts .comments-link a:hover {
- border-color: <?php echo $link_color; ?>;
- }
- article.feature-image.small .entry-summary p a:hover,
- .entry-header .comments-link a:hover,
- .entry-header .comments-link a:focus,
- .entry-header .comments-link a:active,
- .feature-slider a.active {
- background-color: <?php echo $link_color; ?>;
- }
- </style>
- <?php
- }
- add_action( 'wp_head', 'newtheme_print_link_color_style' );
Función que añadirá el color a los vínculos a través de los estilos si este no es el mismo que el de defecto.
- <?php
-
- /**
- * Adds New Theme layout classes to the array of body classes.
- */
- function newtheme_layout_classes( $existing_classes ) {
- $options = newtheme_get_theme_options();
- $current_layout = $options['theme_layout'];
-
- if ( in_array( $current_layout, https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/( 'content-sidebar', 'sidebar-content' ) ) )
- else
-
- if ( 'content-sidebar' == $current_layout )
- $classes[] = 'right-sidebar';
- elseif ( 'sidebar-content' == $current_layout )
- $classes[] = 'left-sidebar';
- else
- $classes[] = $current_layout;
-
- $classes = apply_filters( 'newtheme_layout_classes', $classes, $current_layout );
-
- }
- add_filter( 'body_class', 'newtheme_layout_classes' );
Esta función añade las clases correspondientes a la etiqueta body dependiendo de la estructura de blog elegida.
- <?php
-
- /**
- * Implements New Theme theme options into Theme Customizer
- *
- * @param $wp_customize Theme Customizer object
- * @return void
- */
- function newtheme_customize_register( $wp_customize ) {
- $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
- $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
-
- $options = newtheme_get_theme_options();
- $defaults = newtheme_get_default_theme_options();
-
- $wp_customize->add_setting( 'newtheme_theme_options[color_scheme]', https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/(
- 'default' => $defaults['color_scheme'],
- 'type' => 'option',
- 'capability' => 'edit_theme_options',
- ) );
-
- $schemes = newtheme_color_schemes();
- foreach ( $schemes as $scheme ) {
- $choices[ $scheme['value'] ] = $scheme['label'];
- }
-
- $wp_customize->add_control( 'newtheme_color_scheme', https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/(
- 'label' => __( 'Color Scheme', 'newtheme' ),
- 'section' => 'colors',
- 'settings' => 'newtheme_theme_options[color_scheme]',
- 'type' => 'radio',
- 'choices' => $choices,
- 'priority' => 5,
- ) );
-
- // Link Color (added to Color Scheme section in Theme Customizer)
- $wp_customize->add_setting( 'newtheme_theme_options[link_color]', https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/(
- 'default' => newtheme_get_default_link_color( $options['color_scheme'] ),
- 'type' => 'option',
- 'sanitize_callback' => 'sanitize_hex_color',
- 'capability' => 'edit_theme_options',
- ) );
-
- $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/(
- 'label' => __( 'Link Color', 'newtheme' ),
- 'section' => 'colors',
- 'settings' => 'newtheme_theme_options[link_color]',
- ) ) );
-
- // Default Layout
- $wp_customize->add_section( 'newtheme_layout', https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/(
- 'title' => __( 'Layout', 'newtheme' ),
- 'priority' => 50,
- ) );
-
- $wp_customize->add_setting( 'newtheme_theme_options[theme_layout]', https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/(
- 'type' => 'option',
- 'default' => $defaults['theme_layout'],
- 'sanitize_callback' => 'sanitize_key',
- ) );
-
- $layouts = newtheme_layouts();
- foreach ( $layouts as $layout ) {
- $choices[$layout['value']] = $layout['label'];
- }
-
- $wp_customize->add_control( 'newtheme_theme_options[theme_layout]', https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/(
- 'section' => 'newtheme_layout',
- 'type' => 'radio',
- 'choices' => $choices,
- ) );
- }
- add_action( 'customize_register', 'newtheme_customize_register' );
Esta función añade todas las opciones al personalizador de temas.
- <?php
-
- /**
- * Bind JS handlers to make Theme Customizer preview reload changes asynchronously.
- * Used with blogname and blogdescription.
- */
- function newtheme_customize_preview_js() {
- wp_enqueue_script( 'newtheme-customizer', get_template_directory_uri() . '/inc/theme-customizer.js', https://www.interadictos.es/cuevas-bajas-ligar-en-gratis/( 'customize-preview' ), '20120523', true );
- }
- add_action( 'customize_preview_init', 'newtheme_customize_preview_js' );
Esta función indica a WordPress que añada un archivo javascript para la previsualización de la página para poder ver los cambios del tema.