logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$15
Changing the WP tagline from a theme options page

Hello,

Using the (Automattic) `_s` theme as an example to create my own theme options page,
would it perhaps be possible to add a text field which matches the WP (default) tagline/description? (making it back-and-forward updatable between `options-general.php` and `themes.php?page=theme_options`)

Here's the code from the theme options page I'm currently using: http://pastebin.com/fFFcVTSU

Best regards,

Cor

This question has been answered.

Cor van Noorloos | 05/30/12 at 3:29pm Edit


(1) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    05/30/12
    3:53pm
    John Cotton says:

    Hi Cor

    Do you mean have someone enter a value on your page and that value get set as the site description (and appear on the General settings page if they visit there). And if they update the General settings page and update, that update is reflected in the value you display on your page?

    If so, the short answer is yes, but not with the settings API as you are using it since that will send the values to rows other that the blogdescription value (which is the one you need).

    If the above is what you want, I can give you some pointers for the code.

    Previous versions of this answer: 05/30/12 at 3:53pm

    • 05/30/12 3:55pm

      Cor van Noorloos says:

      Hi John,

      The short answer would indeed be 'yes'.

      Being just beyond novice php-wise, any pointers would be more than appreciated.

    • 05/30/12 5:42pm

      John Cotton says:

      It's not very pretty, and I haven't actually tried the code, but I think this should work:


      function _s_theme_options_render_page() {

      // This is new - need to get the current value
      $tagline = get_option('blogdescription ');

      ?>
      <div class="wrap">
      <?php screen_icon(); ?>
      <?php $theme_name = function_exists( 'wp_get_theme' ) ? wp_get_theme() : get_current_theme(); ?>
      <h2><?php printf( __( '%s Theme Options', '_s' ), $theme_name ); ?></h2>
      <?php settings_errors(); ?>

      <form method="post" action="options.php">
      <?php
      settings_fields( '_s_options' );
      do_settings_sections( 'theme_options' );
      // Here's the change:
      echo sprintf('<input type="text" name="txtBlogInfo" value="%s" />', $tagline);
      // You could put some styling and prompts around this if you wanted to...

      submit_button();
      ?>
      </form>
      </div>
      <?php
      }

      function _s_theme_options_validate( $input ) {
      $output = array();

      // This is new: gets the contents of the postback and sticks it into the database
      update_option( 'blogdescription ', $_POST['txtBlogInfo'] );

      // The sample text input must be safe text with no HTML tags
      if ( isset( $input['sample_text_input'] ) && ! empty( $input['sample_text_input'] ) )
      $output['sample_text_input'] = wp_filter_nohtml_kses( $input['sample_text_input'] );

      // The sample textarea must be safe text with the allowed tags for posts
      if ( isset( $input['sample_textarea'] ) && ! empty( $input['sample_textarea'] ) )
      $output['sample_textarea'] = wp_filter_post_kses( $input['sample_textarea'] );

      return apply_filters( '_s_theme_options_validate', $output, $input );
      }

    • 05/31/12 12:24pm

      Cor van Noorloos says:

      Hi John,

      Still figuring out on how to implement this best, but yours is definitely the right answer.

      Again, much appreciated!

This question has expired.



Cor van Noorloos, Agus Setiawan voted on this question.



Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.