custom html and slotfills working
This commit is contained in:
parent
bb197dd8bf
commit
094fa28f90
|
@ -13,6 +13,7 @@ import { SettingsCheckbox, SettingsInput } from './components';
|
||||||
|
|
||||||
export const Content = ( { data } ) => {
|
export const Content = ( { data } ) => {
|
||||||
const { settings } = data;
|
const { settings } = data;
|
||||||
|
console.log( settings );
|
||||||
const [ formData, setFormData ] = useState( {} );
|
const [ formData, setFormData ] = useState( {} );
|
||||||
const [ isBusy, setIsBusy ] = useState( false );
|
const [ isBusy, setIsBusy ] = useState( false );
|
||||||
const formRef = useRef( null );
|
const formRef = useRef( null );
|
||||||
|
@ -119,6 +120,20 @@ export const Content = ( { data } ) => {
|
||||||
return (
|
return (
|
||||||
<SettingsInput setting={ setting } key={ key } />
|
<SettingsInput setting={ setting } key={ key } />
|
||||||
);
|
);
|
||||||
|
case 'custom':
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={ key }
|
||||||
|
className="woocommerce-settings-element"
|
||||||
|
id={ setting.id }
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
dangerouslySetInnerHTML={ {
|
||||||
|
__html: setting.content,
|
||||||
|
} }
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,42 @@ if ( ! class_exists( 'WC_Settings_Page', false ) ) :
|
||||||
*/
|
*/
|
||||||
protected $label = '';
|
protected $label = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setting page label.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $types = array(
|
||||||
|
'title',
|
||||||
|
'info',
|
||||||
|
'sectionend',
|
||||||
|
'text',
|
||||||
|
'password',
|
||||||
|
'datetime',
|
||||||
|
'datetime-local',
|
||||||
|
'date',
|
||||||
|
'month',
|
||||||
|
'time',
|
||||||
|
'week',
|
||||||
|
'number',
|
||||||
|
'email',
|
||||||
|
'url',
|
||||||
|
'tel',
|
||||||
|
'color',
|
||||||
|
'textarea',
|
||||||
|
'select',
|
||||||
|
'multiselect',
|
||||||
|
'radio',
|
||||||
|
'checkbox',
|
||||||
|
'image_width',
|
||||||
|
'single_select_page',
|
||||||
|
'single_select_page_with_search',
|
||||||
|
'single_select_country',
|
||||||
|
'multi_select_countries',
|
||||||
|
'relative_date_selector',
|
||||||
|
'slotfill_placeholder',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -94,6 +130,7 @@ if ( ! class_exists( 'WC_Settings_Page', false ) ) :
|
||||||
public function get_settings_page_data( $pages ) {
|
public function get_settings_page_data( $pages ) {
|
||||||
$sections = $this->get_sections();
|
$sections = $this->get_sections();
|
||||||
$sections_data = array();
|
$sections_data = array();
|
||||||
|
|
||||||
foreach ( $sections as $section_id => $section_label ) {
|
foreach ( $sections as $section_id => $section_label ) {
|
||||||
$section_settings = $this->get_settings_for_section( $section_id );
|
$section_settings = $this->get_settings_for_section( $section_id );
|
||||||
$section_settings_data = array();
|
$section_settings_data = array();
|
||||||
|
@ -102,6 +139,17 @@ if ( ! class_exists( 'WC_Settings_Page', false ) ) :
|
||||||
if ( isset( $section_setting['id'] ) ) {
|
if ( isset( $section_setting['id'] ) ) {
|
||||||
$section_setting['value'] = isset( $section_setting['default'] ) ? get_option( $section_setting['id'], $section_setting['default'] ) : get_option( $section_setting['id'] );
|
$section_setting['value'] = isset( $section_setting['default'] ) ? get_option( $section_setting['id'], $section_setting['default'] ) : get_option( $section_setting['id'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! in_array( $section_setting['type'], $this->types ) ) {
|
||||||
|
ob_start();
|
||||||
|
do_action( 'woocommerce_admin_field_' . $section_setting['type'], $section_setting);
|
||||||
|
$html = ob_get_contents();
|
||||||
|
$section_setting['content'] = trim( $html );
|
||||||
|
$section_setting['id'] = $section_setting['type'];
|
||||||
|
$section_setting['type'] = 'custom';
|
||||||
|
ob_end_clean();
|
||||||
|
}
|
||||||
|
|
||||||
$section_settings_data[] = $section_setting;
|
$section_settings_data[] = $section_setting;
|
||||||
}
|
}
|
||||||
$sections_data[ $section_id ] = array(
|
$sections_data[ $section_id ] = array(
|
||||||
|
|
Loading…
Reference in New Issue