removing unecessary files and renaming gravity example templates
This commit is contained in:
parent
7f247b015c
commit
e3ebe7e34b
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
|
||||
if (class_exists('GF_Field')) {
|
||||
class FoodDelivery extends GF_Field {
|
||||
public $type = 'food_delivery';
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
<?php
|
||||
|
||||
if (class_exists('GF_Field')) {
|
||||
class OrderPaperPublications extends GF_Field
|
||||
{
|
||||
public $type = 'order_paper_publications';
|
||||
|
||||
private $brochures_query; // Déplacez la déclaration de la propriété ici
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$post_query = new WP_Query(array(
|
||||
'post_type' => 'brochures',
|
||||
'posts_per_page' => -1,
|
||||
'post_status' => 'publish',
|
||||
));;
|
||||
$this->brochures_query = $post_query;
|
||||
|
||||
$choices = [];
|
||||
foreach ($this->brochures_query->posts as $post) {
|
||||
$choices[] = ['text' => $post->post_title];
|
||||
}
|
||||
}
|
||||
|
||||
public function get_form_editor_field_title()
|
||||
{
|
||||
return esc_attr__('Commande de publications papier', 'txtdomain');
|
||||
}
|
||||
public function get_form_editor_button()
|
||||
{
|
||||
return [
|
||||
'group' => 'advanced_fields',
|
||||
'text' => $this->get_form_editor_field_title(),
|
||||
];
|
||||
}
|
||||
public function get_form_editor_field_icon()
|
||||
{
|
||||
return 'gform-icon--multi-select';
|
||||
}
|
||||
public function get_form_editor_field_settings()
|
||||
{
|
||||
return [
|
||||
'label_setting',
|
||||
'choices_setting',
|
||||
'description_setting',
|
||||
'rules_setting',
|
||||
'error_message_setting',
|
||||
'css_class_setting',
|
||||
'conditional_logic_field_setting'
|
||||
];
|
||||
}
|
||||
|
||||
public $choices = [
|
||||
['text' => 'Publication 1'],
|
||||
['text' => 'Publication 2'],
|
||||
['text' => 'Publication 3'],
|
||||
];
|
||||
public function is_value_submission_array()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get_field_input($form, $value = '', $entry = null)
|
||||
{
|
||||
|
||||
// if ($this->is_form_editor()) {
|
||||
// return '';
|
||||
// }
|
||||
$form_id = $form['id'];
|
||||
$is_entry_detail = $this->is_entry_detail();
|
||||
$id = (int) $this->id;
|
||||
|
||||
write_log($id);
|
||||
write_log($form_id);
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
|
||||
|
||||
<fieldset id='<?php echo "field_" . $id . "[]" ?>' class="field-order-paper-publications gfield gfield--type-checkbox gfield--type-choice gfield--input-type-checkbox gf_list_2col gfield_contains_required">
|
||||
|
||||
<div class="gfield_checkbox" id='<?php echo "field_" . $form_id . "_" . $id ?>'>
|
||||
|
||||
<?php foreach ($this->brochures_query->posts as $index => $brochurePost) { ?>
|
||||
|
||||
|
||||
<div class="gchoice">
|
||||
<input id='<?php echo "field_" . $id . "_" . $index ?>' class="gfield-choice-input" name="<?php echo "input_" . $id . "" . $index ?> " type="checkbox" value="<?php echo $brochurePost->post_title ?>">
|
||||
<label id='<?php echo "field_" . $id . "_" . $index ?>' for="choice_18_18_1" class="gform-field-label gform-field-label--type-inline"><?php echo $brochurePost->post_title ?></label>
|
||||
|
||||
<input class="publications-amount-fr" type="number" size="1" name="<?php echo "amount_fr" ?>" />
|
||||
<input class="publications-amount-nl" type="number" size="1" name="<?php echo "amount_nl" ?>" />
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
|
||||
</fieldset>
|
||||
|
||||
<?php
|
||||
|
||||
$table_html = ob_get_clean();
|
||||
return $table_html;
|
||||
|
||||
// .. Rest of code for frontend and edit entry here...
|
||||
}
|
||||
private function translateValueArray($value)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return [];
|
||||
}
|
||||
$table_value = [];
|
||||
$counter = 0;
|
||||
foreach ($this->choices as $course) {
|
||||
foreach ($this->delivery_days as $day) {
|
||||
$table_value[$course['text']][$day] = $value[$counter++];
|
||||
}
|
||||
}
|
||||
return $table_value;
|
||||
}
|
||||
}
|
||||
GF_Fields::register(new OrderPaperPublications());
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user