Created
May 19, 2010 08:27
-
-
Save stefanoverna/406088 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function gsa_theme_page() { | |
if (isset($_POST['info_update'])){ | |
if ( isset($_POST['headerimage']) ) { | |
if ( '' == $_REQUEST['headerimage'] ) | |
delete_option('gsa_header_image'); | |
else { | |
update_option('gsa_header_image', $_REQUEST['headerimage']); | |
} | |
} | |
?> | |
<div id="message" class="updated fade"> | |
<p>Opzioni salvate. <a href="<?php echo get_option('home'); ?>">View site »</a></p> | |
</div> | |
<?php | |
} | |
?> | |
<div class=wrap> | |
<h2>Immagine Header</h2> | |
<div style="padding-top: 15px;"><strong>Attenzione:</strong> le immagini vanno inserite via FTP nella directory <span style="font-family:Monaco,'Courier New',monospace;">wp-content/themes/gsa/imgs/headers/</span>. La dimensione delle immagini non deve essere inferiore a 500x200px. Nel caso fossero più grandi, verranno automaticamente ritagliate mantenendo visibile la parte destra-centrale.</div> | |
<form method="post" style="margin: 20px 0px"> | |
<label for="headerimage" style="font-weight: bold;">Immagine da utilizzare nell'header: </label> | |
<select name="headerimage" id="headerimage"> | |
<option value="random" <?=(gsa_header_image() == 'random' ? 'selected':'')?>>Immagine casuale</option> | |
<?php | |
if ($handle = opendir(dirname(__FILE__)."/imgs/headers/")) { | |
while (false !== ($file = readdir($handle))) { | |
if ( preg_match( "/.(jpg|png|gif)$/", $file ) ) { | |
echo '<option value="'.$file.'" '. ( gsa_header_image() == $file ? 'selected':'' ) .'>'.$file.'</option>'; | |
} | |
} | |
closedir($handle); | |
} | |
?> | |
</select> | |
<div class="submit"> | |
<input type="submit" name="info_update" value="Salva »" /> | |
</div> | |
</form> | |
</div> | |
<?php | |
} | |
function gsa_add_theme_page() { | |
add_management_page('Immagine Header', 'Immagine Header', 'edit_themes', basename(__FILE__), 'gsa_theme_page'); | |
} | |
add_action('admin_menu', 'gsa_add_theme_page'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment