Add template debug mode option. First pass at #3941

This commit is contained in:
Scott Basgaard 2013-10-23 17:52:58 +02:00
parent f4d4a42ba7
commit 9c9bfe1f4c
3 changed files with 40 additions and 20 deletions

View File

@ -78,6 +78,7 @@ class WC_Admin_Menus {
*/
public function status_menu() {
add_submenu_page( 'woocommerce', __( 'WooCommerce Status', 'woocommerce' ), __( 'System Status', 'woocommerce' ) , 'manage_woocommerce', 'wc-status', array( $this, 'status_page' ) );
register_setting( 'woocommerce_status_settings_fields', 'woocommerce_status_options' );
}
/**

View File

@ -1,20 +1,38 @@
<table class="wc_status_table widefat" cellspacing="0">
<thead class="tools">
<tr>
<th colspan="2"><?php _e( 'Tools', 'woocommerce' ); ?></th>
</tr>
</thead>
<tbody class="tools">
<?php foreach( $tools as $action => $tool ) { ?>
<tr>
<td><?php echo esc_html( $tool['name'] ); ?></td>
<td>
<p>
<a href="<?php echo wp_nonce_url( admin_url('admin.php?page=wc-status&tab=tools&action=' . $action ), 'debug_action' ); ?>" class="button"><?php echo esc_html( $tool['button'] ); ?></a>
<span class="description"><?php echo wp_kses_post( $tool['desc'] ); ?></span>
<form method="post" action="options.php">
<?php settings_fields( 'woocommerce_status_settings_fields' ); ?>
<?php $options = get_option( 'woocommerce_status_options' ); ?>
<table class="wc_status_table widefat" cellspacing="0">
<thead class="tools">
<tr>
<th colspan="2"><?php _e( 'Tools', 'woocommerce' ); ?></th>
</tr>
</thead>
<tbody class="tools">
<?php foreach( $tools as $action => $tool ) { ?>
<tr>
<td><?php echo esc_html( $tool['name'] ); ?></td>
<td>
<p>
<a href="<?php echo wp_nonce_url( admin_url('admin.php?page=wc_status&tab=tools&action=' . $action ), 'debug_action' ); ?>" class="button"><?php echo esc_html( $tool['button'] ); ?></a>
<span class="description"><?php echo wp_kses_post( $tool['desc'] ); ?></span>
</p>
</td>
</tr>
<?php } ?>
<tr>
<td><?php _e( 'Template Debug Mode', 'woocommerce' ); ?></td>
<td>
<p>
<label><input type="checkbox" class="checkbox" name="woocommerce_status_options" value="1" <?php checked('1', $options); ?> /> <?php _e( 'Enabled', 'woocommerce' ); ?></label>
</p>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<p>
<span class="description"><?php _e( 'This tool will disable template overrides for logged-in administrators for debugging purposes.', 'woocommerce' ); ?></span>
</p>
</td>
</tr>
</tbody>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
</p>
</form>

View File

@ -63,7 +63,8 @@ class WC_Template_Loader {
if ( $file ) {
$template = locate_template( $find );
if ( ! $template ) $template = WC()->plugin_path() . '/templates/' . $file;
if ( ! $template || ( get_option( 'woocommerce_status_options' ) && current_user_can( 'manage_options' ) ) )
$template = WC()->plugin_path() . '/templates/' . $file;
}
return $template;