added css and functions to make some acf fields read-only
This commit is contained in:
@@ -42,6 +42,7 @@ include_once(Plgntls::root_path() . 'php/partners_handle_offers.php');
|
|||||||
// utils
|
// utils
|
||||||
include_once(Plgntls::root_path() . 'php/_utils_acf_fields.php');
|
include_once(Plgntls::root_path() . 'php/_utils_acf_fields.php');
|
||||||
include_once(Plgntls::root_path() . 'php/_utils_acf_dates.php');
|
include_once(Plgntls::root_path() . 'php/_utils_acf_dates.php');
|
||||||
|
include_once(Plgntls::root_path() . 'php/_utils_acf_fields_disabled.php');
|
||||||
include_once(Plgntls::root_path() . 'php/_utils_redirections.php');
|
include_once(Plgntls::root_path() . 'php/_utils_redirections.php');
|
||||||
include_once(Plgntls::root_path() . 'php/_utils_display_css.php');
|
include_once(Plgntls::root_path() . 'php/_utils_display_css.php');
|
||||||
include_once(Plgntls::root_path() . 'php/_utils_checks_roles.php');
|
include_once(Plgntls::root_path() . 'php/_utils_checks_roles.php');
|
||||||
@@ -53,6 +54,7 @@ include_once(Plgntls::root_path() . 'php/_actions_emails.php');
|
|||||||
// admin
|
// admin
|
||||||
include_once(Plgntls::root_path() . 'php/admin_hide_bar.php');
|
include_once(Plgntls::root_path() . 'php/admin_hide_bar.php');
|
||||||
include_once(Plgntls::root_path() . 'php/admin_user_profil.php');
|
include_once(Plgntls::root_path() . 'php/admin_user_profil.php');
|
||||||
|
include_once(Plgntls::root_path() . 'php/admin_partner.php');
|
||||||
include_once(Plgntls::root_path() . 'php/admin_menu.php');
|
include_once(Plgntls::root_path() . 'php/admin_menu.php');
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
17
plugins/cipf_plugin/css/acf_fields.css
Normal file
17
plugins/cipf_plugin/css/acf_fields.css
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
.read_only_cipf {
|
||||||
|
.acf-input {
|
||||||
|
position: relative;
|
||||||
|
* {
|
||||||
|
cursor: default;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
> * {
|
||||||
|
color: #666;
|
||||||
|
background-color: #f0f0f1;
|
||||||
|
filter: grayscale(100%);
|
||||||
|
}
|
||||||
|
textarea {
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,13 +7,14 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hide all acf fields with the class 'hide-for-fipf'
|
* hide all acf fields with the class 'hide_for_fipfrole_cipf'
|
||||||
|
* also hide the title if class 'hide_group_for_fipfrole_cipf'
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
form#your-profile h2:has(+ .form-table .hide-group-for-fipf) {
|
form#your-profile h2:has(+ .form-table .hide_group_for_fipfrole_cipf) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
form#your-profile .hide-for-fipf {
|
form#your-profile .hide_for_fipfrole_cipf {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
80
plugins/cipf_plugin/php/_utils_acf_fields_disabled.php
Normal file
80
plugins/cipf_plugin/php/_utils_acf_fields_disabled.php
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* it means someone outside wp is accessing the file, in this case kill it.
|
||||||
|
*/
|
||||||
|
if (!defined('ABSPATH')) {
|
||||||
|
die('You can not access this file!');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* checks if the acf field contains the class 'read_only_cipf'
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function is_acf_field_disabled($field) {
|
||||||
|
Plgntls::debug_infos();
|
||||||
|
|
||||||
|
if (!isset($field['wrapper'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isset($field['wrapper']['class'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$class = $field['wrapper']['class'];
|
||||||
|
if (!str_contains($class, 'read_only_cipf')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if acf field has class to be disabled
|
||||||
|
* -> add the 'disabled' value to object after it is loaded
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function disable_acf_field_CIPF($field) {
|
||||||
|
Plgntls::debug_infos();
|
||||||
|
|
||||||
|
if (!is_acf_field_disabled($field)) {
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
|
||||||
|
$field['disabled'] = 1;
|
||||||
|
//$field['readonly'] = 1;
|
||||||
|
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
add_filter('acf/load_field', 'disable_acf_field_CIPF');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if acf field has class to be disabled
|
||||||
|
* -> dont update the values
|
||||||
|
* -> should work for all acf fields
|
||||||
|
* 200 : ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/advanced-custom-fields/includes/acf-value-functions.php
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function disable_all_acf_field_CIPF($null, $value, $post_id, $field) {
|
||||||
|
Plgntls::debug_infos();
|
||||||
|
|
||||||
|
if (!isset($_POST['acf'])) {
|
||||||
|
return $null;
|
||||||
|
}
|
||||||
|
if (!is_acf_field_disabled($field)) {
|
||||||
|
return $null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
add_filter('acf/pre_update_value', 'disable_all_acf_field_CIPF', 10, 4);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -120,4 +120,6 @@ function display_states_css_CIPF($user_id = null) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
30
plugins/cipf_plugin/php/admin_partner.php
Normal file
30
plugins/cipf_plugin/php/admin_partner.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* it means someone outside wp is accessing the file, in this case kill it.
|
||||||
|
*/
|
||||||
|
if (!defined('ABSPATH')) {
|
||||||
|
die('You can not access this file!');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* load css for user profil admin page
|
||||||
|
* if fipf is weing user profil in admin, hide some fields
|
||||||
|
* 278 : ../../../wordpress_docker/volumes/wp_volume/wp-admin/user-edit.php
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function admin_partner_page_css_CIPF() {
|
||||||
|
Plgntls::debug_infos();
|
||||||
|
|
||||||
|
Plgntls::add_to_front(array('css/acf_fields.css'));
|
||||||
|
|
||||||
|
}
|
||||||
|
add_action('admin_enqueue_scripts', 'admin_partner_page_css_CIPF');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -12,10 +12,9 @@ if (!defined('ABSPATH')) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* load css for when fipf is weing user profil in admin
|
* load css for user profil admin page
|
||||||
|
* if fipf is weing user profil in admin, hide some fields
|
||||||
* 278 : ../../../wordpress_docker/volumes/wp_volume/wp-admin/user-edit.php
|
* 278 : ../../../wordpress_docker/volumes/wp_volume/wp-admin/user-edit.php
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -27,7 +26,7 @@ function admin_user_profil_css_CIPF() {
|
|||||||
* for everyone viewing user profil
|
* for everyone viewing user profil
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Plgntls::add_to_front(array('css/user_profile.css'));
|
Plgntls::add_to_front(array('css/user_profile.css', 'css/acf_fields.css'));
|
||||||
|
|
||||||
if (!current_user_can($role_fipf)) {
|
if (!current_user_can($role_fipf)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user