| @@ -1,131 +1,125 @@ | ||
| 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 | -} | |
| 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 | +} | |