| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The Pro Integrations |
| 5 |
*/ |
| 6 |
class WeForms_Pro_Upgrades { |
| 7 |
|
| 8 |
/** |
| 9 |
* Initialize |
| 10 |
*/ |
| 11 |
function __construct() { |
| 12 |
|
| 13 |
if ( class_exists( 'WeForms_Pro' ) ) { |
| 14 |
return; |
| 15 |
} |
| 16 |
|
| 17 |
add_filter( 'weforms_integrations', array( $this, 'register_pro_integrations' ) ); |
| 18 |
|
| 19 |
// form fields |
| 20 |
add_filter( 'weforms_field_get_js_settings', array( $this, 'add_conditional_field_prompt' ) ); |
| 21 |
add_filter( 'weforms_form_fields', array( $this, 'register_pro_fields' ) ); |
| 22 |
add_filter( 'weforms_field_groups_custom', array( $this, 'add_to_custom_fields' ) ); |
| 23 |
add_filter( 'weforms_field_groups_others', array( $this, 'add_to_others_fields' ) ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Register the pro integrations |
| 28 |
* |
| 29 |
* @param array $integrations |
| 30 |
* |
| 31 |
* @return array |
| 32 |
*/ |
| 33 |
public function register_pro_integrations( $integrations ) { |
| 34 |
require_once WEFORMS_INCLUDES . '/admin/class-pro-upgrade-integrations.php'; |
| 35 |
|
| 36 |
$pro = array( |
| 37 |
'WeForms_Pro_Integration_MailChimp', |
| 38 |
'WeForms_Pro_Integration_CM', |
| 39 |
'WeForms_Pro_Integration_CC', |
| 40 |
'WeForms_Pro_Integration_AWeber', |
| 41 |
'WeForms_Pro_Integration_ConvertKit' |
| 42 |
); |
| 43 |
|
| 44 |
return array_merge( $integrations, $pro ); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Register pro fields |
| 49 |
* |
| 50 |
* @param array $fields |
| 51 |
* |
| 52 |
* @return array |
| 53 |
*/ |
| 54 |
public function register_pro_fields( $fields ) { |
| 55 |
if ( ! class_exists( 'WeForms_Form_Field_Pro' ) ) { |
| 56 |
require_once WEFORMS_INCLUDES . '/fields/class-fields-pro.php'; |
| 57 |
} |
| 58 |
|
| 59 |
require_once WEFORMS_INCLUDES . '/admin/class-pro-upgrade-fields.php'; |
| 60 |
|
| 61 |
$fields['repeat_field'] = new WeForms_Form_Field_Repeat(); |
| 62 |
$fields['file_upload'] = new WeForms_Form_Field_File(); |
| 63 |
$fields['country_list_field'] = new WeForms_Form_Field_Country(); |
| 64 |
$fields['numeric_text_field'] = new WeForms_Form_Field_Numeric(); |
| 65 |
$fields['address_field'] = new WeForms_Form_Field_Address(); |
| 66 |
$fields['google_map'] = new WeForms_Form_Field_GMap(); |
| 67 |
$fields['shortcode'] = new WeForms_Form_Field_Shortcode(); |
| 68 |
$fields['action_hook'] = new WeForms_Form_Field_Hook(); |
| 69 |
$fields['toc'] = new WeForms_Form_Field_Toc(); |
| 70 |
$fields['ratings'] = new WeForms_Form_Field_Rating(); |
| 71 |
$fields['linear_scale'] = new WeForms_Form_Field_Linear_Scale(); |
| 72 |
$fields['checkbox_grid'] = new WeForms_Form_Field_Checkbox_Grid(); |
| 73 |
$fields['multiple_choice_grid'] = new WeForms_Form_Field_Multiple_Choice_Grid(); |
| 74 |
$fields['step_start'] = new WeForms_Form_Field_Step(); |
| 75 |
|
| 76 |
return $fields; |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Register fields to custom field section |
| 81 |
* |
| 82 |
* @param array $fields |
| 83 |
*/ |
| 84 |
public function add_to_custom_fields( $fields ) { |
| 85 |
$pro_fields = array( |
| 86 |
'repeat_field', 'date_field', 'file_upload', 'country_list_field', |
| 87 |
'numeric_text_field', 'address_field', 'google_map', 'step_start' |
| 88 |
); |
| 89 |
|
| 90 |
return array_merge( $fields, $pro_fields ); |
| 91 |
} |
| 92 |
|
| 93 |
/** |
| 94 |
* Register fields to others field section |
| 95 |
* |
| 96 |
* @param array $fields |
| 97 |
*/ |
| 98 |
public function add_to_others_fields( $fields ) { |
| 99 |
$pro_fields = array( |
| 100 |
'shortcode', 'action_hook', 'toc', 'ratings', 'linear_scale', 'checkbox_grid', 'multiple_choice_grid' |
| 101 |
); |
| 102 |
|
| 103 |
return array_merge( $fields, $pro_fields ); |
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* Add conditional logic prompt |
| 108 |
* |
| 109 |
* @param array $settings |
| 110 |
*/ |
| 111 |
public function add_conditional_field_prompt( $settings ) { |
| 112 |
|
| 113 |
$settings['settings'][] = array( |
| 114 |
'name' => 'wpuf_cond', |
| 115 |
'title' => __( 'Conditional Logic', 'weforms' ), |
| 116 |
'type' => 'option-pro-feature-alert', |
| 117 |
'section' => 'advanced', |
| 118 |
'priority' => 30, |
| 119 |
'help_text' => '', |
| 120 |
'is_pro_feature' => true |
| 121 |
); |
| 122 |
|
| 123 |
return $settings; |
| 124 |
} |
| 125 |
} |
| 126 |
|