0

Basically, if there's an uploaded image for the site title (logo) it will be displayed as the #header h1 a's background (this part works perfectly) and set its text to indent -9999px; (this doesn't work).

I did $text_indent = '-9999px' inside the if statement which says: "//If it is an image"

Why is $text_indent not being displayed in the final input?

header.php

#header h1 a {
        background: url(<?php echo $options['logo']; ?>) no-repeat scroll 0 0;
        text-indent: <?php echo $text_indent; ?>
    }

function.php:

// Logo
function logo_setting() {
   echo '<input type="file" name="logo" />';
}

function validate_setting($plugin_options) {
   $keys = array_keys($_FILES);
   $i = 0;

   foreach ($_FILES as $image) {

      // if a files was upload
      if ($image['size']) {
         // if it is an image
         if (preg_match('/(jpg|jpeg|png|gif)$/', $image['type'])) {
            $override = array('test_form' => false);
            $file = wp_handle_upload($image, $override);

            $plugin_options[$keys[$i]] = $file['url'];

            // Hide site title's text
            $text_indent = '-9999px';

         } else {
            $options = get_option('plugin_options');
            $plugin_options[$keys[$i]] = $options[$logo];
            wp_die('No image was uploaded.');
         }
      }

      // else, retain the image that's already on file.
      else {
         $options = get_option('plugin_options');
         $plugin_options[$keys[$i]] = $options[$keys[$i]];
      }
      $i++;
   }

   return $plugin_options;
}

function section_cb() {}

// Add stylesheet
0

1 Answer 1

1

You are using this variable inside the function in function.php. But this variable will not accessible outside the function.

So you have to declare it as a global variable.

Sign up to request clarification or add additional context in comments.

1 Comment

actually the the function is inside functions/admin-menu.php and then that file is called inside functions.php (i think is not big difference). So I did $text_indent = '-9999px'; global $text_indent; but nothing happened :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.