false, ]); } /** * @filter acf/validate_value */ public function validate_value( $valid, $value, $field, $input ) { if ( $operation = $this->get_bulk_operation( $field['key'] ) ) { $valid = Fields\Field::getFieldObject( $field )->validate_bulk_operation_value( $valid, $value, $operation ); } return $valid; } /** * Get value for do-not-change chackbox * * @return string */ public function get_dont_change_value() { return $this->dont_change_value; } /** * Get key for bulk operation * * @return string */ public function get_bulk_operation_key() { return $this->bulk_operation_key; } /** * @inheritdoc */ protected function is_saving() { return ( isset( $_GET['action'] ) && $_GET['action'] === 'edit') || ( isset( $_GET['action2'] ) && $_GET['action2'] === 'edit'); } /** * @inheritdoc */ public function get_type() { return 'bulkedit'; } /** * @inheritdoc */ public function get_fieldgroup_option() { return 'allow_bulkedit'; } /** * @inheritdoc */ public function init_fields() { add_filter( 'acf/validate_value', [ $this, 'validate_value' ], 10, 4 ); $is_active = parent::init_fields(); if ( $is_active ) { add_action( 'bulk_edit_custom_box', [ $this , 'display_bulk_edit' ], 200, 2 ); } return $is_active; } /** * @return boolean */ public function is_bulk_operation( $field_key ) { return isset( $_REQUEST['acf'] ) && is_array( $_REQUEST['acf'] ) && isset( $_REQUEST['acf'][ $this->get_bulk_operation_key() ] ) && is_array( $_REQUEST['acf'][ $this->get_bulk_operation_key() ] ) && isset( $_REQUEST['acf'][ $this->get_bulk_operation_key() ][ $field_key ] ) && ! empty( $_REQUEST['acf'][ $this->get_bulk_operation_key() ][ $field_key ] ); } /** * @return boolean */ public function get_bulk_operation( $field_key ) { return $this->is_bulk_operation( $field_key ) ? sanitize_text_field( wp_unslash( $_REQUEST['acf'][ $this->get_bulk_operation_key() ][ $field_key ] ) ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- already checked in is_bulk_operation() : false; } /** * @action bulk_edit_custom_box */ public function display_bulk_edit( $wp_column_slug, $post_type ) { if ( $this->did_render ) { return; } $column = str_replace(' qef-thumbnail','', $wp_column_slug ); foreach ( $this->fieldsets as $field_group_key => $fields ) { $field_group = acf_get_field_group( $field_group_key ); // we need a div here because WP is prepending tags input to the fieldset:last in the editor printf( "\n", sanitize_key( $field_group_key ) ); echo '