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