开发者

WordPress Custom Theme & jQuery > Updating user after a save event of theme options

开发者 https://www.devze.com 2022-12-23 12:55 出处:网络
The script below resides in my theme\'s functions.php file. It is designed to show and fade an \"update\" div which com开发者_如何学Ces on screen after each save event. Just asking if this is the bes

The script below resides in my theme's functions.php file.

It is designed to show and fade an "update" div which com开发者_如何学Ces on screen after each save event. Just asking if this is the best approach to take so that it only executes on save and is not constantly trying to run the jQuery...

<form method="post">

<?php
if ( $_REQUEST['saved']) 
  { ?>
     <div id="message" class="updated fade"><p>The settings were saved</p></div>

    <script type="text/javascript">
       $('#message').delay(3000).fadeOut(3000);
    </script>

<?php }?>

<?php foreach ($options as $value) {
switch ( $value['type'] ) {


This will try to run the given code every-time $_REQEST['saved'] is not falsy.

So, it will run if $_REQUEST is equal to anything except 0, false, empty strings, or a few other falsy values.

See the documentation for a full list of falsy values.

0

精彩评论

暂无评论...
验证码 换一张
取 消