diff --git a/Fieldtypes/CheckBox.php b/Fieldtypes/CheckBox.php index c1c731d..0176872 100644 --- a/Fieldtypes/CheckBox.php +++ b/Fieldtypes/CheckBox.php @@ -42,15 +42,16 @@ protected function render_additional_settings() { } public static function register() { - $types = array( - 'ccbox' => array(__('CC: option for user', 'cforms2'), true), - 'checkbox' => array(__('Check Box', 'cforms2'), false) - ); - foreach ($types as $id => $label) { - $t = new CheckBox($id, $label[0], $label[1]); - $t->register_at_filter(); - } - + add_action('init', function() { + $types = array( + 'ccbox' => array(__('CC: option for user', 'cforms2'), true), + 'checkbox' => array(__('Check Box', 'cforms2'), false) + ); + foreach ($types as $id => $label) { + $t = new CheckBox($id, $label[0], $label[1]); + $t->register_at_filter(); + } + }); } } diff --git a/Fieldtypes/CheckBoxGroup.php b/Fieldtypes/CheckBoxGroup.php index c877f16..70fdca4 100644 --- a/Fieldtypes/CheckBoxGroup.php +++ b/Fieldtypes/CheckBoxGroup.php @@ -51,15 +51,16 @@ protected function render_additional_settings() { } public static function register() { - $types = array( - 'checkboxgroup' => __('Check Box Group', 'cforms2'), - 'radiobuttons' => __('Radio Buttons', 'cforms2') - ); - foreach ($types as $id => $label) { - $t = new CheckBoxGroup($id, $label); - $t->register_at_filter(); - } - + add_action('init', function() { + $types = array( + 'checkboxgroup' => __('Check Box Group', 'cforms2'), + 'radiobuttons' => __('Radio Buttons', 'cforms2') + ); + foreach ($types as $id => $label) { + $t = new CheckBoxGroup($id, $label); + $t->register_at_filter(); + } + }); } } diff --git a/Fieldtypes/Html5.php b/Fieldtypes/Html5.php index 1332b1e..d9dafdb 100644 --- a/Fieldtypes/Html5.php +++ b/Fieldtypes/Html5.php @@ -74,25 +74,26 @@ protected function render_additional_settings() { } public static function register() { - $types = array( - 'html5color' => 'HTML5 ' . __('Color Field', 'cforms2'), - 'html5date' => 'HTML5 ' . __('Date Field', 'cforms2'), - 'html5datetime-local' => 'HTML5 ' . __('Date/Time (local) Field', 'cforms2'), - 'html5email' => 'HTML5 ' . __('Email Field', 'cforms2'), - 'html5month' => 'HTML5 ' . __('Month Field', 'cforms2'), - 'html5number' => 'HTML5 ' . __('Number Field', 'cforms2'), - 'html5range' => 'HTML5 ' . __('Range Field', 'cforms2'), - 'html5search' => 'HTML5 ' . __('Search Field', 'cforms2'), - 'html5time' => 'HTML5 ' . __('Time Field', 'cforms2'), - 'html5url' => 'HTML5 ' . __('URL Field', 'cforms2'), - 'html5week' => 'HTML5 ' . __('Week Field', 'cforms2'), - 'html5tel' => 'HTML5 ' . __('Telephone Number Field', 'cforms2') - ); - foreach ($types as $id => $label) { - $t = new Html5($id, $label); - $t->register_at_filter(); - } - + add_action('init', function() { + $types = array( + 'html5color' => 'HTML5 ' . __('Color Field', 'cforms2'), + 'html5date' => 'HTML5 ' . __('Date Field', 'cforms2'), + 'html5datetime-local' => 'HTML5 ' . __('Date/Time (local) Field', 'cforms2'), + 'html5email' => 'HTML5 ' . __('Email Field', 'cforms2'), + 'html5month' => 'HTML5 ' . __('Month Field', 'cforms2'), + 'html5number' => 'HTML5 ' . __('Number Field', 'cforms2'), + 'html5range' => 'HTML5 ' . __('Range Field', 'cforms2'), + 'html5search' => 'HTML5 ' . __('Search Field', 'cforms2'), + 'html5time' => 'HTML5 ' . __('Time Field', 'cforms2'), + 'html5url' => 'HTML5 ' . __('URL Field', 'cforms2'), + 'html5week' => 'HTML5 ' . __('Week Field', 'cforms2'), + 'html5tel' => 'HTML5 ' . __('Telephone Number Field', 'cforms2') + ); + foreach ($types as $id => $label) { + $t = new Html5($id, $label); + $t->register_at_filter(); + } + }); } } diff --git a/Fieldtypes/MultiId.php b/Fieldtypes/MultiId.php index b928362..26de08c 100644 --- a/Fieldtypes/MultiId.php +++ b/Fieldtypes/MultiId.php @@ -46,9 +46,9 @@ public function is_special() { } public static function register() { - $t = new MultiId('fieldsetend', __('End Fieldset', 'cforms2'), false); - $t->register_at_filter(); - + add_action('init', function() { + $t = new MultiId('fieldsetend', __('End Fieldset', 'cforms2'), false); + $t->register_at_filter(); + }); } - } diff --git a/Fieldtypes/SelectBox.php b/Fieldtypes/SelectBox.php index 17cc596..d418b92 100644 --- a/Fieldtypes/SelectBox.php +++ b/Fieldtypes/SelectBox.php @@ -46,16 +46,17 @@ protected function render_additional_settings() { } public static function register() { - $types = array( - 'emailtobox' => array(__('Multiple Recipients', 'cforms2'), true), - 'selectbox' => array(__('Select Box', 'cforms2'), false), - 'multiselectbox' => array(__('Multi Select Box', 'cforms2'), false) - ); - foreach ($types as $id => $label) { - $t = new SelectBox($id, $label[0], $label[1]); - $t->register_at_filter(); - } - + add_action('init', function() { + $types = array( + 'emailtobox' => array(__('Multiple Recipients', 'cforms2'), true), + 'selectbox' => array(__('Select Box', 'cforms2'), false), + 'multiselectbox' => array(__('Multi Select Box', 'cforms2'), false) + ); + foreach ($types as $id => $label) { + $t = new SelectBox($id, $label[0], $label[1]); + $t->register_at_filter(); + } + }); } } diff --git a/Fieldtypes/Text.php b/Fieldtypes/Text.php index b95db56..b428754 100644 --- a/Fieldtypes/Text.php +++ b/Fieldtypes/Text.php @@ -37,18 +37,19 @@ protected function get_text_inputs() { } public static function register() { - $types = array( - 'textfield' => array(__('Single line of text', 'cforms2'), false), - 'upload' => array(__('File Upload Box', 'cforms2'), false), - 'textarea' => array(__('Multiple lines of text', 'cforms2'), false), - 'pwfield' => array(__('Password Field', 'cforms2'), false), - 'hidden' => array(__('Hidden Field', 'cforms2'), false) - ); - foreach ($types as $id => $label) { - $t = new Text($id, $label[0], $label[1]); - $t->register_at_filter(); - } - + add_action('init', function() { + $types = array( + 'textfield' => array(__('Single line of text', 'cforms2'), false), + 'upload' => array(__('File Upload Box', 'cforms2'), false), + 'textarea' => array(__('Multiple lines of text', 'cforms2'), false), + 'pwfield' => array(__('Password Field', 'cforms2'), false), + 'hidden' => array(__('Hidden Field', 'cforms2'), false) + ); + foreach ($types as $id => $label) { + $t = new Text($id, $label[0], $label[1]); + $t->register_at_filter(); + } + }); } }