Skip to content

Instantly share code, notes, and snippets.

@ejntaylor
Created May 7, 2014 13:04
Show Gist options
  • Save ejntaylor/937c989b53648cb703c3 to your computer and use it in GitHub Desktop.
Save ejntaylor/937c989b53648cb703c3 to your computer and use it in GitHub Desktop.
<?php
// Settings
global $BambooPlugin; // we'll need this below
$default_plugins = $BambooPlugin->get_setting('req_plugins_arr','array');
// reset settings
if (isset($_GET["reset"])) { reset_settings(); exit; }
function reset_settings() {
global $BambooPlugin; // we'll need this below
echo '<p>Settings Have Been Reset</p><p><a href="/wp-admin/admin.php?page=bamboo-settings">Return to Settings</a>';
$BambooPlugin->update_setting('woo_custom_css', 'yes');
$BambooPlugin->update_setting('remove_woo_nav', 'yes');
$BambooPlugin->update_setting('req_plugins_arr', 'woocommerce/woocommerce.php; wordpress-seo/wp-seo.php; usersnap/usersnap.php; video-user-manuals/plugin.php;
woodojo/woodojo.php;
worker/functions.php;
advanced-custom-fields/acf.php;
admin-menu-editor-pro/menu-editor.php;
image-widget/image-widget.php ;
bwp-minify/bwp-minify.php;
cookies-for-comments/cookies-for-comments.php;
debug-bar/debug-bar.php;
woocommerce-debug-bar/woocommerce-debug-bar.php;
woothemes-updater');
}
?>
<script type="text/javascript">
// http://jesin.tk/dynamic-textbox-jquery-php/
jQuery(document).ready(function($){
$('.my-form .add-box').click(function(){
var n = $('.text-box').length + 1;
if( 20 < n ) {
alert('Limited to 20 Plugins - Come on you don\'t need that many!');
return false;
}
var box_html = $('<p class="text-box"><label for="box' + n + '">Plugin <span class="box-number">' + n + '</span></label> <input type="text" name="boxes[]" value="" id="box' + n + '" /> <a href="#" class="remove-box">Remove</a></p>');
box_html.hide();
$('.my-form p.text-box:last').after(box_html);
box_html.fadeIn('slow');
return false;
});
$('.my-form').on('click', '.remove-box', function(){
$(this).parent().css( 'background-color', '#FF6C6C' );
$(this).parent().fadeOut("slow", function() {
$(this).remove();
$('.box-number').each(function(index){
$(this).text( index + 1 );
});
});
return false;
});
});
</script>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<?php $BambooPlugin->the_nonce(); ?>
<table class="form-table">
<tbody>
<tr>
<th scope="row" valign="top">Add Woo Custom CSS</th>
<td>
<label>
<input type="hidden" name="<?php echo $BambooPlugin->get_field_name('enable_woo_custom_css'); ?>" value="no" />
<input type="checkbox" name="<?php echo $BambooPlugin->get_field_name('enable_woo_custom_css'); ?>" value="yes" <?php if ( $BambooPlugin->get_setting('enable_woo_custom_css') == "yes") echo 'checked="checked"'; ?> />Check this to add the WooFramework custom css
</label>
</td>
</tr>
<tr>
<th scope="row" valign="top">Remove Woo Nav</th>
<td>
<label>
<input type="hidden" name="<?php echo $BambooPlugin->get_field_name('remove_woo_nav'); ?>" value="no" />
<input type="checkbox" name="<?php echo $BambooPlugin->get_field_name('remove_woo_nav'); ?>" value="yes" <?php if ( $BambooPlugin->get_setting('remove_woo_nav') == "yes") echo 'checked="checked"'; ?> /> Check this to remove the Woo Navigation
</label>
</td>
</tr>
<tr class="my-form">
<th scope="row" valign="top">Required Plugins List</th>
<td>
<label>
<?php
// ******** MULTIPLE ITEMS SECTION *********
print_r ($default_plugins);
if (!empty($default_plugins)) {
foreach ($default_plugins as $key => $value) : ?>
<p class="text-box">
<label for="box<?php echo $key+1; ?>">Plugin <span class="box-number"><?php echo $key+1; ?></span></label>
<input type="text" name="<?php echo $BambooPlugin->get_field_name('req_plugins_arr'); ?>[]" value="<?php echo $value; ?>" id="box<?php echo $key+1; ?>" />
<?php echo ( 0 == $key ? '<a href="#" class="add-box">Add More</a>' : '<a href="#" class="remove-box">Remove</a>' ); ?>
</p>
<?php
endforeach;
} else {
?>
<p class="text-box">
<label for="box1">Box <span class="box-number">1</span></label>
<input type="text" name="boxes[]" value="" id="box1" />
<a class="add-box" href="#">Add More</a>
</p>
<?php
}
;
?>
</label>
</td>
</tr>
</tbody>
</table>
<input class="button-primary" type="submit" value="Save Settings" />
</form>
<p><a href="/wp-admin/admin.php?page=bamboo-settings&reset">RESET</a></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment