diff --git a/trunk/stipple.php b/trunk/stipple.php index feb11ba..2e1329a 100644 --- a/trunk/stipple.php +++ b/trunk/stipple.php @@ -26,10 +26,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - include 'stipple_config_html_page.php'; + include dirname( __FILE__ ) . '/stipple_config_html_page.php'; register_deactivation_hook(__FILE__, 'stipple_deactivate' ); - add_action('wp_print_scripts', 'stipple_enable'); + add_action('wp_enqueue_scripts', 'stipple_enable'); /* admin settings setup */ if ( is_admin() ) { @@ -42,8 +42,7 @@ function stipple_deactivate() { } function stipple_enable() { - $plugin_path = WP_PLUGIN_URL . '/' . - str_replace(basename(__FILE__), "", plugin_basename(__FILE__)); + $plugin_path = plugins_url( '/', __FILE__ ); wp_enqueue_script('stipple', $plugin_path . 'js/async_init.js', @@ -69,7 +68,7 @@ function stipple_enable() { } function stipple_admin_menu() { - add_options_page('Stipple Configuration', 'Stipple', 'administrator', + add_options_page('Stipple Configuration', 'Stipple', 'manage_options', 'stipple', 'stipple_config_html_page'); } @@ -78,17 +77,20 @@ function stipple_register_options() { } function stipple_validate($v) { - $v['site_id'] = wp_filter_nohtml_kses($v['site_id']); + $out = array(); + $out['site_id'] = isset( $v['site_id'] ) ? wp_filter_nohtml_kses( $v['site_id'] ) : ''; switch($v['custom_stipple_load']) { case 0: case 1: case 2: + $out['custom_stipple_load'] = $v['custom_stipple_load']; break; default: - $v['custom_stipple_load'] = 0; + $out['custom_stipple_load'] = 0; } + $out['custom_stipple_load_data'] = isset( $v['custom_stipple_load_data'] ) ? wp_filter_nohtml_kses( $v['custom_stipple_load_data'] ) : ''; - return $v; + return $out; } ?> diff --git a/trunk/stipple_config_html_page.php b/trunk/stipple_config_html_page.php index f962872..6075ff8 100644 --- a/trunk/stipple_config_html_page.php +++ b/trunk/stipple_config_html_page.php @@ -19,21 +19,20 @@ function stipple_config_html_page() { $opts = get_option('stipple_options'); - $stipple_load = ""; - $site_id = $opts['site_id']; - if(!$site_id) - $site_id = 'SITE_ID_HERE'; + $stipple_load = isset( $opts['custom_stipple_load'] ) ? intval( $opts['custom_stipple_load'] ) : 0; + $site_id = ! empty( $opts['site_id'] ) ? $opts['site_id'] : ''; + - if($opts['custom_stipple_load_data']) { - $stipple_load = $opts['custom_stipple_load_data']; + if( ! empty( $opts['custom_stipple_load_data'] ) ) { + $stipple_load_data = $opts['custom_stipple_load_data']; } else { - $stipple_load = << @@ -45,23 +44,23 @@ function stipple_config_html_page() { - + - + - +
onclick="document.getElementById('stipple_site_id').disabled = false;document.getElementById('stipple_custom_load_data').disabled = true;" /> onclick="document.getElementById('stipple_site_id').disabled = false;document.getElementById('stipple_custom_load_data').disabled = true;" /> /> + value="" /> (e.g. 2XnALR)
onclick="document.getElementById('stipple_site_id').disabled = true;document.getElementById('stipple_custom_load_data').disabled = false;"/> onclick="document.getElementById('stipple_site_id').disabled = true;document.getElementById('stipple_custom_load_data').disabled = false;"/> - +
onclick="document.getElementById('stipple_site_id').disabled = true;document.getElementById('stipple_custom_load_data').disabled = true;"/> onclick="document.getElementById('stipple_site_id').disabled = true;document.getElementById('stipple_custom_load_data').disabled = true;"/>