Created
October 6, 2019 17:18
-
-
Save tradesouthwest/edfe005a66e057b86a9bc91fb1e5396f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Parse HTML for 'checkbox' field | |
* @input type checkbox | |
*/ | |
function unitizr_removestyles_field_cb($args) | |
{ | |
$checked = ''; | |
$options = get_option($args['option_name']); | |
$value = ( !isset( $options[$args['name']] ) ) | |
? null : $options[$args['name']]; | |
if($value) { $checked = ' checked="checked" '; } | |
$html = ''; | |
$html .= '<input id="' . $args['name'] . '" | |
name="' . esc_attr( $args['option_name'] . '['.$args['name'].']') .'" | |
type="checkbox" ' . $checked . '/>'; | |
$html .= '<span class="wndspan">' . $args['description'] .'</span>'; | |
$html .= '<b class="wntip" data-title="'. $args['tip'] .'"> ? </b>'; | |
echo $html; | |
} | |
/* The settings arguments */ | |
// c9.) settings checkbox | |
add_settings_field( | |
'unitizr_removestyles_field', | |
esc_attr__('Remove Unitizr Styles', 'unitizr'), | |
'unitizr_removestyles_field_cb', | |
'unitizr_options', | |
'unitizr_options_section', | |
array( | |
'type' => 'checkbox', | |
'option_name' => 'unitizr_options', | |
'name' => 'unitizr_removestyles_field', | |
'label_for' => 'unitizr_removestyles_field', | |
'value' => (empty(get_option('unitizr_options')['unitizr_removestyles_field'])) | |
? 0 : get_option('unitizr_options')['unitizr_removestyles_field'], | |
'description' => esc_html__( 'Check to remove Unitizr premade Woocommerce overrides.', 'unitizr' ), | |
'checked' => (!isset(get_option('unitizr_options')['unitizr_removestyles_field'])) | |
? 0 : get_option('unitizr_options')['unitizr_removestyles_field'], | |
'tip' => esc_attr__( 'Use if Woocommerce fields drastically changed when installing this plugin.', 'unitizr' ) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment