-
-
Save espellcaste/6025100 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 | |
/* | |
* Plugin Name: wpMandrill MS | |
* Plugin URI: trepmal.com | |
* Description: Network-wide settings for wpMandrill. | |
* Version: 2013.04.01 | |
* Author: Kailey Lampert | |
* Author URI: kaileylampert.com | |
* License: GPLv2 or later | |
* TextDomain: wpmandrill-ms | |
* DomainPath: | |
* Network: true | |
*/ | |
$wpmandrill_ms = new WPMandrill_MS(); | |
class WPMandrill_MS { | |
function __construct() { | |
add_action( 'admin_menu', array( &$this, 'admin_menu' ), 11 ); | |
add_action( 'network_admin_menu', array( &$this, 'network_admin_menu' ) ); | |
add_filter( 'pre_option_wpmandrill', array( &$this, 'pre_option_wpmandrill' ) ); | |
} | |
function admin_menu() { | |
remove_submenu_page( 'options-general.php', 'wpmandrill' ); | |
} | |
function network_admin_menu() { | |
add_submenu_page( 'settings.php', __( 'wpMandrill MS', 'wpmandrill-ms' ), __( 'wpMandrill MS', 'wpmandrill-ms' ), 'edit_posts', __CLASS__, array( &$this, 'network_page' ) ); | |
} | |
function network_page() { | |
?><div class="wrap"> | |
<h2><?php _e( 'wpMandrill MS', 'wpmandrill-ms' ); ?></h2> | |
<?php | |
if ( isset( $_POST['save_wpmandrill_ms'] ) ) { | |
if ( wp_verify_nonce( $_POST['save_wpmandrill_ms'], 'save_wpmandrill_ms' ) ) { | |
$options = array_map( 'strip_tags', $_POST['wpmandrill_ms'] ); | |
update_site_option( 'wpmandrill_ms', $options ); | |
echo '<div class="updated"><p>Saved.</p></div>'; | |
} else { | |
echo '<div class="updated"><p>Failed nonce check.</p></div>'; | |
} | |
} | |
$d = array( 'api_key' => '' , 'from_name' => '', 'from_username' => '', 'from_domain' => '', 'reply_to' => '', 'tags' => '' ); | |
$options = get_site_option( 'wpmandrill_ms', $d ); | |
?> | |
<form method="post"> | |
<p><label>API Key | |
<input type="text" name="wpmandrill_ms[api_key]" value="<?php echo esc_attr( $options['api_key'] ); ?>" /> | |
</label></p> | |
<p><label>From Name | |
<input type="text" name="wpmandrill_ms[from_name]" value="<?php echo esc_attr( $options['from_name'] ); ?>" /> | |
</label></p> | |
<p><label>From Username (from_username@from_domain) | |
<input type="text" name="wpmandrill_ms[from_username]" value="<?php echo esc_attr( $options['from_username'] ); ?>" /> | |
</label></p> | |
<p><label>From Domain (from_username@from_domain) | |
<input type="text" name="wpmandrill_ms[from_domain]" value="<?php echo esc_attr( $options['from_domain'] ); ?>" /> | |
</label></p> | |
<p><label>Reply To | |
<input type="text" name="wpmandrill_ms[reply_to]" value="<?php echo esc_attr( $options['reply_to'] ); ?>" /> | |
</label></p> | |
<p><label>Convert line-breaks | |
<input type="checkbox" name="wpmandrill_ms[nl2br]" value="1" <?php checked( isset( $options['nl2br'] ) ); ?> /> | |
</label></p> | |
<p><label>Tags | |
<input type="text" name="wpmandrill_ms[tags]" value="<?php echo esc_attr( $options['tags'] ); ?>" /> | |
</label></p> | |
<?php | |
wp_nonce_field( 'save_wpmandrill_ms', 'save_wpmandrill_ms' ); | |
submit_button(); | |
?> | |
</form> | |
</div><?php | |
} | |
function pre_option_wpmandrill( $return ) { | |
return get_site_option('wpmandrill_ms'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment