| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* Helper class for displaying upsell controls. |
| 8 |
* |
| 9 |
* @since 6.30 |
| 10 |
*/ |
| 11 |
class FrmSettingsUpsellHelper { |
| 12 |
/** |
| 13 |
* @since 6.30 |
| 14 |
* |
| 15 |
* @param array $field |
| 16 |
* |
| 17 |
* @return array |
| 18 |
*/ |
| 19 |
public static function get_unique_element_atts( $field ) { |
| 20 |
$unique_element_atts = array( |
| 21 |
'type' => 'checkbox', |
| 22 |
'name' => 'field_options[unique_' . $field['id'] . ']', |
| 23 |
'id' => 'frm_uniq_field_' . $field['id'], |
| 24 |
'value' => '1', |
| 25 |
'class' => 'frm_mark_unique', |
| 26 |
); |
| 27 |
|
| 28 |
if ( FrmAppHelper::pro_is_installed() ) { |
| 29 |
if ( ! empty( $field['unique'] ) ) { |
| 30 |
$unique_element_atts['checked'] = 'checked'; |
| 31 |
} |
| 32 |
|
| 33 |
return $unique_element_atts; |
| 34 |
} |
| 35 |
|
| 36 |
$unique_element_atts['data-upgrade'] = __( 'Unique fields', 'formidable' ); |
| 37 |
$unique_element_atts['disabled'] = '1'; |
| 38 |
$unique_element_atts['readonly'] = '1'; |
| 39 |
|
| 40 |
return $unique_element_atts; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* @since 6.30 |
| 45 |
* |
| 46 |
* @param array $field |
| 47 |
* |
| 48 |
* @return array |
| 49 |
*/ |
| 50 |
public static function get_read_only_element_atts( $field ) { |
| 51 |
$read_only_element_atts = array( |
| 52 |
'type' => 'checkbox', |
| 53 |
'name' => 'field_options[read_only_' . $field['id'] . ']', |
| 54 |
'id' => 'frm_read_only_field_' . $field['id'], |
| 55 |
'value' => '1', |
| 56 |
); |
| 57 |
|
| 58 |
if ( ! empty( $field['read_only'] ) ) { |
| 59 |
$read_only_element_atts['checked'] = 'checked'; |
| 60 |
} |
| 61 |
|
| 62 |
if ( ! FrmAppHelper::pro_is_installed() ) { |
| 63 |
$read_only_element_atts['data-upgrade'] = __( 'Read only fields', 'formidable' ); |
| 64 |
$read_only_element_atts['disabled'] = '1'; |
| 65 |
} |
| 66 |
|
| 67 |
return $read_only_element_atts; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* @since 6.30 |
| 72 |
* |
| 73 |
* @param array $atts |
| 74 |
* @param string $utm_content |
| 75 |
* @param string $upgrade_text |
| 76 |
* @param string $kb_slug |
| 77 |
* |
| 78 |
* @return array |
| 79 |
*/ |
| 80 |
public static function add_upgrade_modal_atts( $atts, $utm_content, $upgrade_text, $kb_slug = '' ) { |
| 81 |
if ( empty( $atts['class'] ) ) { |
| 82 |
$atts['class'] = ''; |
| 83 |
} |
| 84 |
|
| 85 |
$atts['class'] .= ' frm_show_upgrade'; |
| 86 |
$atts['data-medium'] = 'lite'; |
| 87 |
$atts['data-content'] = $utm_content; |
| 88 |
$atts['data-upgrade'] = $upgrade_text; |
| 89 |
$atts['data-learn-more'] = 'https://formidableforms.com/knowledgebase' . $kb_slug; |
| 90 |
|
| 91 |
return $atts; |
| 92 |
} |
| 93 |
} |
| 94 |
|