wordpress:environmentnotice
This is an old revision of the document!
Environment Notice for Wordpress
- environmentnotice.php
<?php /* Plugin Name: Environment Notice Plugin URI: http://public.gfsolone.com/wiki/doku.php?id=wordpress:environmentnotice Description: Visualizza un messaggio di allerta in ogni sezione di Wordpress (per ricordare all'utente di passare dall'ambiente di test a quello di produzione). <strong>Modificare le opzioni del plugin per specificare l'URL dell'installazione di produzione</strong> (based on fcc_oldpost: fullo.net/blog/2007/05/07/oldposts-plugin-per-wordpress). Version: 0.2 Author: Giovanni Francesco Solone Author URI: http://gioxx.org */ function environment_notice() { global $post; $defaults = array('sitoweb'=> 'http://gioxx.org'); $options = (array) get_option('environment_notice'); $options = array_merge($defaults,$options); extract($options); echo '<div class="error">'; echo ' <p><img src="http://gioxx.org/img/cautela.png" alt="" style="float: left; padding-right: 10px;" /><strong style="font-size: x-large;">ATTENZIONE</strong><br />'; echo ' Stai utilizzando l\'ambiente di test di <strong><a href="'; echo bloginfo('url'); echo '">'; echo bloginfo('name'); echo '</a></strong>. '; echo ' Se stai per scrivere un articolo di produzione passa su <strong><a href="'.stripslashes($sitoweb).'">'.stripslashes($sitoweb).'</a></strong> ;-)</p>'; echo '</div>'; } function environment_notice_admin() { global $enotice_nonce,$wpdb; if ( isset($_POST['submit']) ) { if ( function_exists('current_user_can') && !current_user_can('manage_options') ) die(__('Cheatin’ uh?')); check_admin_referer($enotice_nonce); update_option('environment_notice', array( 'sitoweb' => htmlentities(strip_tags($_POST['sitoweb'])) ) ); } $environment_notice_config = get_option('environment_notice'); ?> <div class="wrap"> <h2>Environment Notice</h2> <p style="font-size: large;">Specifica l'URL dell'installazione di produzione <br /> alla quale rimandare, <strong style="color: #FF0000;">completa di http:// iniziale</strong> (es. http://gioxx.org)</p> <form action="" method="post" id="environment_notice_conf" style="width: 400px; "> <?php environment_notice_nonce($enotice_nonce) ?> <p> <input id="sitoweb" name="sitoweb" type="text" size="50" maxlength="90" value="<?php echo $environment_notice_config['sitoweb']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 0.9em;" /> </p> <p> <input type="submit" name="submit" value="Aggiorna" /> </p> </form> <p style="float: left;"> <img src="http://public.gfsolone.com/wiki/lib/tpl/dokuwiki/images/logo.png" style="max-width: 16px; float: left;"><a href="http://public.gfsolone.com/wiki/doku.php?id=wordpress:environmentnotice" style="font-size: x-small; font-variant: small-caps;">Environment Notice</a><br /> <a href="http://gfsolone.com"><img src="http://gfsolone.com/images/gfsolone.footer.png" style="padding-left: 12px; padding-top: 5px;" /></a> </p> </div> <?php } if ( ! function_exists('wp_nonce_field') ) { function environment_notice_nonce($action = -1) { return; } $enotice_nonce = -1; } else { function environment_notice_nonce($action = -1) { return wp_nonce_field($action); } $enotice_nonce = 'fcg-save-option'; } function environment_notice_admin_page() { global $wpdb; if ( function_exists('add_submenu_page') ) add_submenu_page('plugins.php','Environment Notice', 'Environment Notice', 'manage_options', 'environmentnotice', 'environment_notice_admin'); } add_action('admin_menu', 'environment_notice_admin_page'); add_action('admin_notices', 'environment_notice'); ?>
Allo stato attuale non ci sono ulteriori aggiornamenti e l'ultima versione del widget è la 0.2 (16102015). Potete segnalarmi qualsiasi anomalia tramite l'area commenti del blog. Se volete suggerire ulteriori modifiche / personalizzazioni tramite CSS siete i benvenuti, contattatemi pure tramite mail (l'indirizzo lo trovate nella home di questo Wiki!).
wordpress/environmentnotice.1445243550.txt.gz · Last modified: 2015/10/19 10:32 by gfsadministrator