• Denki

    (@denki-denise)


    Hola Comunidad! antes que nada agradezco la ayuda que me puedan dar.
    Mi problema es el siguiente estoy creando mi primer Theme de WordPress con pocos conocimientos sobre PHP pero con la ayuda del codex y otras páginas lo voy logrando.
    Se me presentó el error:

    Parse error: syntax error, unexpected ‘}’ in D:\Archivos de Programas\wamp\www\wordpress\wp-content\themes\Theme Blue WP PHP\functions.php on line 85

    <?php
    global $valores_default;
    	global $opciones; 
    
    function bt_registrar_opciones() {
        register_setting( 'bt_opciones_theme', 'bt_opciones', 'bt_validar' );
    }
    
    add_action( 'admin_init', 'bt_registrar_opciones' );
    
    /*$valores_default = array(
                        'copyright' => '&copy;2011 Timersys',
                        'logo' => '.../images/logo_placeholder.png'
                  )
    $opciones = get_option('bt_opciones', $valores_default); */
    
    function bt_opciones_theme() {
        add_theme_page( 'Opciones Theme', 'Opciones Theme', 'edit_theme_options', 'opciones_theme', 'bt_theme_page' );
    }
    
    add_action( 'admin_menu', 'bt_opciones_theme' );
    
    function bt_theme_page() {
    
        if ( ! isset( $_REQUEST['updated'] ) )
        $_REQUEST['updated'] = false; /* Para comprobar si el formulario fue enviado o no. */?>
    
        <div>
        <?php screen_icon(); echo "<h2>". __( ' Opciones de ' ) . get_current_theme() . "</h2>";
        /* Esto muestra el ícono de la página si es que tiene uno y el nombre del theme*/ ?>
    
        <?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
        <div><p><strong><?php _e( 'Opciones guardadas' ); ?></strong></p></div>
        <?php endif; /* Si el formulario se envia mostramos el mensaje.*/ ?>
    
        <form method="post" action="options.php">
    
        <?php $opciones = get_option( 'bt_opciones', $valores_default ); ?>
    
        <?php settings_fields( 'bt_opciones_theme' );
        /* Esta función imprime todos los campos hidden necesarios para que el formulario funcione correctamente */ ?>
    
        <table class="form-table">
    
        <tr valign="top"><th scope="row"><label for="logo">Logo Url</label></th>
        <td>
        <input id="theme_logo" name="bt_opciones[theme_logo]" type="text" value="<?php  esc_attr_e($opciones['theme_logo']); ?>" />
       <?php  if($opciones['theme_logo'] !='') : ?>
            <img src="$opciones['theme_logo']" alt="logo" />
       <? endif; ?>
        </td>
        </tr>
    
        <tr valign="top"><th scope="row"><label for="favico">Favico Url</label></th>
        <td>
        <input id="theme_favico" name="bt_opciones[theme_logo]" type="text" value="<?php  esc_attr_e($opciones['theme_favico']); ?>" />
        <?php if($opciones['theme_favico'] !='') : ?>
             <img src="$opciones['theme_favico']" alt="logo" />
        <? endif; ?>
        </td>
        </tr>
    
        <tr valign="top"><th scope="row"><label for="google_analytics">C&oacute;digo de Google Analytics</label></th>
        <td>
        <textarea id="google_analytics" name="bt_opciones[google_analytics]"><?php  esc_attr_e($opciones['google_analytics']); ?> </textarea>
        </td>
        </tr>
    
        <tr valign="top"><th scope="row"><label for="copyright">Footer Copyright</label></th>
        <td>
        <input id="footer_copyright" name="bt_opciones[copyright]" type="text" value="<?php  esc_attr_e($opciones['copyright']); ?>" />
        </td>
        </tr>
        </table>
    
       <p class="submit">
        <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
        </p>
    
        </form>
    
        </div>
    
    <?php
    }

    No logro resolver cual es el error, alguien podría guiarme??

Viendo 1 respuesta (de un total de 1)
  • Moderador LGrusin

    (@lgrusin)

    Tienes varios errores.

    $opciones[‘theme_logo’]
    $opciones[‘theme_favico’]
    bt_opciones[theme_logo]
    bt_opciones[google_analytics]
    bt_opciones[copyright]
    Todo eso es PHP y va entre <?php y ?>

    <? endif; ?>
    mejor
    <?php endif; ?>

    Eso suponiendo que el código funcione.

    Un saludo

Viendo 1 respuesta (de un total de 1)

El debate ‘Agregando un "menu page" a mi theme’ está cerrado a nuevas respuestas.