3542 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 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

493 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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 :)
493 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
493 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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 :(
493 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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];
    }
}
1476 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+3 more
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
493 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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 :(

492 posts
  • Has referred 1000+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+8 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.

493 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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

1476 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+3 more
OriginalEXE says

No problem ;)

by
by
by
by
by
by