3507 posts Ruben Bristian
  • Most Wanted Bounty Winner
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 6-7 years
  • Repeatedly helped protect Envato Market against copyright violations
  • Won a Competition
  • Bought between 100 and 499 items
  • Exclusive Author
  • Referred between 500 and 999 users
+5 more
KrownThemes says

thanks for your code. if the option alway have real init so I never care for notice problem :) . because I’m alway set init for it , so the notice’s never come. I just don’t happy with init value for empty var

I don’t understand.. You came here and said that your item got rejected because you tried to echo empty variables and asked for a solution. We gave you a solution but now you’re saying that you didn’t needed our solution since you already had empty values in those variables. So if you had empty values why did your theme got rejected over issets issues?

I’m sorry but nothing makes sense here :D

492 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
wopethemes says


why not? I just call them in theme options. which only use once. it’s simple the code.
done few times the overhead is negligible so it really doesn’t matter but, if it’s all around in your code, including nested loops, you may want to avoid unnecessary functions call and use directly
if (isset($var)) echo $var;
absolute true!
But you may don’t know where I got the problem. If I need to check the var in some case for example like “full screen” or “boxed” layout IN FRONT END then I’ll use what you’re mention.
The problem’s come in almost task : keep form status. example
$radio_site_layout[$main_option['site-layout']] = 'checked="checked"';
...

<input type="radio" name="site-layout" id="layout-fullscreen" value="1" <?php echo $radio_site_layout[1];?>><label for="layout-fullscreen">Full Screen</label>
                            <input type="radio" name="site-layout" id="layout-boxed" value="2" <?php echo $radio_site_layout[2];?> ><label for="layout-boxed">Boxed</label>
or even hell like this :D
<option value="easeInExpo" <?php echo $easing_select['easeInExpo'];?>>easeInExpo</option>
                                                <option value="easeOutExpo" <?php echo $easing_select['easeOutExpo'];?>>easeOutExpo</option>
                                                <option value="easeInOutExpo" <?php echo $easing_select['easeInOutExpo'];?>>easeInOutExpo</option>
                                                <option value="easeInElastic" <?php echo $easing_select['easeInElastic'];?>>easeInElastic</option>
                                                <option value="easeOutElastic" <?php echo $easing_select['easeOutElastic'];?>>easeOutElastic</option>
                                                <option value="easeInOutElastic" <?php echo $easing_select['easeInOutElastic'];?>>easeInOutElastic</option>
                                                <option value="easeInBack" <?php echo $easing_select['easeInBack'];?>>easeInBack</option>
                                                <option value="easeOutBack" <?php echo $easing_select['easeOutBack'];?>>easeOutBack</option>
...
but this case can use array and foreach to solve problem. :D. actually almost notices I got is from the example #1 :)
492 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
wopethemes says


thanks for your code. if the option alway have real init so I never care for notice problem :) . because I’m alway set init for it , so the notice’s never come. I just don’t happy with init value for empty var

I don’t understand.. You came here and said that your item got rejected because you tried to echo empty variables and asked for a solution. We gave you a solution but now you’re saying that you didn’t needed our solution since you already had empty values in those variables. So if you had empty values why did your theme got rejected over issets issues?

I’m sorry but nothing makes sense here :D
haha , it’s my fault. Sorry I don’t provide my problem case. ok let me describe
my normal code is
$radio_site_layout[$main_option['site-layout']] = 'checked="checked"';
...
<input type="radio" name="site-layout" id="layout-fullscreen" value="1" <?php echo $radio_site_layout[1];?>><label for="layout-fullscreen">Full Screen</label>
                            <input type="radio" name="site-layout" id="layout-boxed" value="2" <?php echo $radio_site_layout[2];?> ><label for="layout-boxed">Boxed</label>
it got notice because the $radio_site_layout array could not have exists key “1” or “2”
so I need to fix it by place this code above :
$radio_site_layout[1] = '';
$radio_site_layout[2] = '';
:D
492 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
wopethemes says

Honestly, for theme options, we just set default values once. A very simple way to do it by using http://codex.wordpress.org/Function_Reference/shortcode_atts
$options = shortcode_adds($defaults,$options)
thanks for suggestion but I did not use any shortcodes :(
492 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
wopethemes says
better code
//prevent notice when the var is not set
function prevent_notice($var){
    if($var){
        echo $var;
    }
}
//for array
function prevent_notice_array($var,$key = ""){
    if(isset($var[$key]) and array_key_exists($key,$var)){
        echo $var[$key];
    }
}
1470 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Croatia
OriginalEXE says
Not totally related to your issue, but are you aware of these two functions ( I see you manually echo “selected state so I though I could point it out ) http://codex.wordpress.org/Function_Reference/selected http://codex.wordpress.org/Function_Reference/checked
492 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
wopethemes says

Not totally related to your issue, but are you aware of these two functions ( I see you manually echo “selected state so I though I could point it out ) http://codex.wordpress.org/Function_Reference/selected http://codex.wordpress.org/Function_Reference/checked

hmm you saved my life. never seen this function. thank a million times :(

491 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Won a Competition
  • Referred between 1000 and 1999 users
  • Author had a Free File of the Month
  • Author had a File in an Envato Bundle
  • Bought between 10 and 49 items
+3 more
pixelentity says

thanks for suggestion but I did not use any shortcodes :(
forget about the name (actually there’s a typo in my previous post as function name is shortcode_atts)

what that function does is setting a default value for keys not set in the 2nd array.

492 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
wopethemes says

hmmm, I never know selected and checked function which can pass the php notice. so I can go to simple way and forgot the prevent_notice functions.
Thanks OriginalEXE for your recommend :)
Thanks pixelentity & RubenBristian was too patience to let me see my fault. :D I’m alway kid like that when I don’t understand something. LOL

1470 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Croatia
OriginalEXE says

No problem ;)

by
by
by
by
by
by