0

I'm a beginner of php, I found this custom style in Wordpress Redux framework but I don't understand how the code work.

I would like to know how this formula works:

 <?php echo ($logo_h) ? (str_replace('px','',$logo_h) + 55) : 125; ?>px;

Can someone please explain. So much appreciated.

<?php 
        $logo_w=$sellegance_opt['logo_size']['width'];
        $logo_h=$sellegance_opt['logo_size']['height'];
        ?>

        #header .header_container {
            height: <?php echo ($logo_h) ? (str_replace('px','',$logo_h) + 55) : 125; ?>px;
        }
        .header3 #header .header_container {
            height: <?php echo ($logo_h) ? str_replace('px','',$logo_h) : 70; ?>px;
        }
        .header3 .desktop_nav {
            left: <?php echo $logo_w; ?>;
            margin-left: 10px;
        }
        .logo {
            width: <?php echo ($logo_w) ? str_replace('px','',$logo_w) : 160; ?>px;
            height: <?php echo ($logo_h) ? str_replace('px','',$logo_h) : 70; ?>px;
            margin-left: -<?php echo ($logo_w) ? (str_replace('px','',$logo_w)/2) : 80; ?>px;
        }
Clarkie
  • 6,818
  • 8
  • 33
  • 52
J'ry Wong
  • 39
  • 4

3 Answers3

0

i haven't used that framework yet but looking at the code i can surely tell that this framework certainly offer you to set the height and width of the logo in your backend and gets those entered values as

$logo_w=$sellegance_opt['logo_size']['width'];
$logo_h=$sellegance_opt['logo_size']['height'];

and uses the $logo_w and $logo_h to create the design accordingly.

If you are planning to use just this part of the code from the framework without the framework then you can't. You must have the whole framework and set those values from the appropriate locations.

Yamu
  • 1,522
  • 9
  • 14
0
//add this in functions.php

function mytheme_custom_options(){

global $sellegance_opt;

$logo_w=$sellegance_opt['logo_size']['width'];
$logo_h=$sellegance_opt['logo_size']['height'];

<style>

/*use your style here */

</style>
}

add_action('wp_head','mytheme_custom_options');
0

Ok so I try to explain, but im not sooo good in explaining things :P

  1. The PHP

    • The redux optionsname seems to be "sellegance_opt" see lines 12 & 13 in the sample-config.php shipped with redux.
    • logo_size seems to be a field with (at least) the values url, width and height.
    • the PHP string is dropped to the header.php just before the closing header tag I guess. So the variables are callable in a file.
  2. THE CSS the css styles the output of the php

  3. He (or she) is calling the attribute and gets a result with the uploaded media sizes. He now do some math to get the image size needed to fit the template.

But without all the code, much of this is guessing.

All the best.

ThomasB
  • 383
  • 1
  • 13