function wpdev_fsi_should_display() { if (is_page()) { global $post; $images = array(); for ($i = 0; $i < WPDS_NUM_ADD_IMAGES; $i++) { if (has_fsi_bg_image($post->ID, $i)) { $images[] = the_fsi_bg_image_url($post->ID, $i); } } if (!empty($images)) { return 11; } } $display_on = get_option('fsi_display_on'); if (!is_array($display_on)) { $display_on = array($display_on); } if (is_front_page()) { if (in_array('frontpage', $display_on)) { return 1; } } elseif (is_home()) { if (in_array('home', $display_on)) { return 2; } } elseif (is_page()) { if (in_array('pages', $display_on)) { return 3; } } elseif (is_single()) { if (in_array('posts', $display_on)) { return 4; } } elseif (is_category()) { if (in_array('category', $display_on)) { return 5; } } elseif (is_tag()) { if (in_array('tag', $display_on)) { return 6; } } elseif (is_archive()) { if (in_array('archive', $display_on)) { return 7; } } return false; }
function fsi_bg_images_cb($post) { echo '<table> <tr><td colspan="2"><label><input id="fsi_fs_images" name="fsi_fs_images" type="checkbox" value="1" ' . checked(get_post_meta($post->ID, 'fsi_fs_images', true), '1', false) . ' /> Enable custom background image for this page</label></td> <td colspan="2"><label><input id="fsi_fs_images_slideshow" name="fsi_fs_images_slideshow" type="checkbox" value="1" ' . checked(get_post_meta($post->ID, 'fsi_fs_images_slideshow', true), '1', false) . ' /> Enable slideshow</label></td> </tr> '; for ($i = 0; $i < WPDS_NUM_ADD_IMAGES; $i++) { echo $i % 2 == 0 ? '<tr valign="top">' : ''; echo '<td valign=top width="40%"><input id="fsi_fs_images' . $i . '_field" type="text" size="36" name="fsi_fs_images' . $i . '" value="' . get_post_meta($post->ID, 'fsi_fs_images' . $i, true) . '" /> <input id="fsi_fs_images' . $i . '" class="upload_buttons" type="button" value="Upload/Select" /></td><td width="10%">'; if (has_fsi_bg_image($post->ID, $i)) { echo '<a href="' . the_fsi_bg_image_url($post->ID, $i) . ' target="_blank"><img src="' . the_fsi_bg_image_url($post->ID, $i, array(30, 30)) . '" height=30 /></a>'; } echo '</td>'; echo ($i + 1) % 2 == 0 ? '</tr>' : ''; } echo ' <tr><td colspan="4">You can specify an image URL or an attachment ID through Upload/Select button. </td></tr> </table>'; ?> <script type="text/javascript"> jQuery(document).ready(function() { var formfieldID = ''; var wpds_orig_send_to_editor = window.send_to_editor; jQuery('.upload_buttons').click(function() { formfieldID = jQuery(this).attr('id')+'_field'; tb_show('', 'media-upload.php?type=image&TB_iframe=true'); window.send_to_editor = function(html) { attachmentID = html.match(/wp-image-([0-9]+)/); if(attachmentID) pasteValue = attachmentID[1]; else pasteValue = jQuery(html).filter('img').attr('src'); jQuery('#'+formfieldID).val(pasteValue); tb_remove(); window.send_to_editor = wpds_orig_send_to_editor; } return false; }); }); </script> <?php }