Skip to content

Commit

Permalink
Merge pull request #1 from Automattic/master
Browse files Browse the repository at this point in the history
Code Review and Cleanup from WordPress.com VIP

git-svn-id: http://svn.wp-plugins.org/stipple@647950 b8457f37-d9ea-0310-8a92-e5e31aec5664
  • Loading branch information
stipple committed Jan 4, 2013
2 parents 2922a53 + 29b7713 commit 53869fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
18 changes: 10 additions & 8 deletions trunk/stipple.php
Expand Up @@ -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() ) {
Expand All @@ -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',
Expand All @@ -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');
}

Expand All @@ -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;
}

?>
27 changes: 13 additions & 14 deletions trunk/stipple_config_html_page.php
Expand Up @@ -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 = <<<EOS
_stippleq.push(['load', '{$site_id}', {
$stipple_load_data = "
_stippleq.push(['load', '". esc_js( $site_id ) . "', {
selector: 'img',
minWidth: 200,
minHeight: 200
}]);
EOS;
";
}
?>

Expand All @@ -45,23 +44,23 @@ function stipple_config_html_page() {

<table class="form-table">
<tr valign="top">
<th scope="row"><input id="stipple-no-custom-load" name="stipple_options[custom_stipple_load]" type="radio" value="0" <?php checked('0', $opts['custom_stipple_load']); ?> onclick="document.getElementById('stipple_site_id').disabled = false;document.getElementById('stipple_custom_load_data').disabled = true;" /> <label for="stipple-no-custom-load">Load Stipple with Site ID:</label></th>
<th scope="row"><input id="stipple-no-custom-load" name="stipple_options[custom_stipple_load]" type="radio" value="0" <?php checked('0', $stipple_load); ?> onclick="document.getElementById('stipple_site_id').disabled = false;document.getElementById('stipple_custom_load_data').disabled = true;" /> <label for="stipple-no-custom-load">Load Stipple with Site ID:</label></th>
<td>
<input name="stipple_options[site_id]" type="text" id="stipple_site_id"
value="<?php _e($opts['site_id']); ?>" <?php disabled(Array('1', '2'), $opts['custom_stipple_load']); ?> />
value="<?php echo esc_attr( $opts['site_id'] ); ?>" <?php disabled(Array('1', '2'), $stipple_load); ?> />
(e.g. 2XnALR)
</td>
</tr>

<tr valign="top">
<th scope="row"><input id="stipple-use-custom-load" name="stipple_options[custom_stipple_load]" type="radio" value="1" <?php checked('1', $opts['custom_stipple_load']); ?> onclick="document.getElementById('stipple_site_id').disabled = true;document.getElementById('stipple_custom_load_data').disabled = false;"/> <label for="stipple-use-custom-load">Use Custom <code>STIPPLE.load</code>:</label></th>
<th scope="row"><input id="stipple-use-custom-load" name="stipple_options[custom_stipple_load]" type="radio" value="1" <?php checked('1', $stipple_load); ?> onclick="document.getElementById('stipple_site_id').disabled = true;document.getElementById('stipple_custom_load_data').disabled = false;"/> <label for="stipple-use-custom-load">Use Custom <code>STIPPLE.load</code>:</label></th>
<td>
<textarea id="stipple_custom_load_data" rows="8" cols="26" name="stipple_options[custom_stipple_load_data]" <?php disabled(Array('0', '2'), $opts['custom_stipple_load']); ?>><?php _e($stipple_load); ?></textarea>
<textarea id="stipple_custom_load_data" rows="8" cols="26" name="stipple_options[custom_stipple_load_data]" <?php disabled(Array('0', '2'), $stipple_load); ?>><?php echo esc_html( $stipple_load_data ); ?></textarea>
</td>
</tr>

<tr valign="top">
<th scope="row"><input id="stipple-no-load" name="stipple_options[custom_stipple_load]" type="radio" value="2" <?php checked('2', $opts['custom_stipple_load']); ?> onclick="document.getElementById('stipple_site_id').disabled = true;document.getElementById('stipple_custom_load_data').disabled = true;"/> <label for="stipple-no-load">Install Stipple, but don't call <code>STIPPLE.load</code>. I will add <code>stippleit-sid</code> classes to my images.</label></th>
<th scope="row"><input id="stipple-no-load" name="stipple_options[custom_stipple_load]" type="radio" value="2" <?php checked('2', $stipple_load); ?> onclick="document.getElementById('stipple_site_id').disabled = true;document.getElementById('stipple_custom_load_data').disabled = true;"/> <label for="stipple-no-load">Install Stipple, but don't call <code>STIPPLE.load</code>. I will add <code>stippleit-sid</code> classes to my images.</label></th>
</tr>

</table>
Expand Down

0 comments on commit 53869fa

Please sign in to comment.