| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 4 |
|
| 5 |
/* |
| 6 |
* Function that adds the new GDPR Communication Preferences field to the fields list |
| 7 |
* and also the list of fields that skip the meta-name check |
| 8 |
* |
| 9 |
* @param array $fields - The names of all the fields |
| 10 |
* |
| 11 |
* @return array |
| 12 |
* |
| 13 |
*/ |
| 14 |
function wppb_gdprcp_manage_field_types( $fields ) { |
| 15 |
$fields[] = 'GDPR Communication Preferences'; |
| 16 |
return $fields; |
| 17 |
} |
| 18 |
add_filter( 'wppb_manage_fields_types', 'wppb_gdprcp_manage_field_types' ); |
| 19 |
|
| 20 |
|
| 21 |
/* Function adds the GDPR Communication Preferences option to set a maximum selection size |
| 22 |
* |
| 23 |
* @param array $fields - The current field properties |
| 24 |
* |
| 25 |
*/ |
| 26 |
function wppb_gdprcp_manage_fields( $fields ) { |
| 27 |
$fields[] = array( 'type' => 'checkbox', 'slug' => 'gdpr-communication-preferences', 'title' => __( 'Communication Preferences', 'profile-builder' ), 'options' => array( '%'.__( 'Email', 'profile-builder' ).'%email', '%'.__( 'Telephone', 'profile-builder' ).'%phone', '%'.__( 'SMS', 'profile-builder' ).'%sms', '%'.__( 'Post', 'profile-builder' ).'%post' ), 'description' => __( "Select which communication preferences are available on your site ( drag and drop to re-order )", 'profile-builder' ) ); |
| 28 |
$fields[] = array( 'type' => 'text', 'slug' => 'gdpr-communication-preferences-sort-order', 'title' => __( 'Communication Preferences Order', 'profile-builder' ), 'description' => __( "Save the communication preferences order", 'profile-builder' ) ); |
| 29 |
return $fields; |
| 30 |
} |
| 31 |
add_filter( 'wppb_manage_fields', 'wppb_gdprcp_manage_fields' ); |
| 32 |
|
| 33 |
|
| 34 |
/** |
| 35 |
* Function that calls the wppb_handle_gdprcp_field |
| 36 |
* |
| 37 |
* @param void |
| 38 |
* |
| 39 |
* @return string |
| 40 |
*/ |
| 41 |
function wppb_gdprcp_sortable_order( $meta_name, $id, $element_id ){ |
| 42 |
if ( $meta_name == 'wppb_manage_fields' ) { |
| 43 |
echo "<script type=\"text/javascript\">wppb_handle_gdprcp_field( '#container_wppb_manage_fields' );</script>"; |
| 44 |
} |
| 45 |
} |
| 46 |
add_action("wck_after_adding_form", "wppb_gdprcp_sortable_order", 10, 3); |
| 47 |
|