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.
精彩评论