Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply phpcbf #1750

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
59340f68fb9c6d6e680ac3ad40a3d095e98837a6
10 changes: 10 additions & 0 deletions TECHNICAL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Formatter

We use .git-blame-ignore-revs to track repo-wide cosmetic refactorings by auto format tools like prettier/phpcbf.
See [Github Documentation](https://docs.github.com/de/repositories/working-with-files/using-files/viewing-and-understanding-files#ignore-commits-in-the-blame-view)

You can also configure your local git so it always ignores the revs in that file:

```bash
git config blame.ignoreRevsFile .git-blame-ignore-revs
```
56 changes: 26 additions & 30 deletions includes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ function commonsbooking_admin() {
// Additional info for CMB2 to handle booking rules
wp_add_inline_script(
'cb-scripts-admin',
'cb_booking_rules=' . \CommonsBooking\Service\BookingRule::getRulesJSON() . ';'
'cb_booking_rules=' . \CommonsBooking\Service\BookingRule::getRulesJSON() . ';'
. 'cb_applied_booking_rules=' . \CommonsBooking\Service\BookingRuleApplied::getRulesJSON() . ';',
);


//orphaned bookings migration - re-assign booking when timeframe has changed
// orphaned bookings migration - re-assign booking when timeframe has changed
wp_localize_script(
'cb-scripts-admin',
'cb_ajax_orphaned_booking_migration',
Expand All @@ -98,7 +97,6 @@ function commonsbooking_admin() {
)
);


/**
* Ajax - get location for item
*/
Expand Down Expand Up @@ -137,7 +135,7 @@ function commonsbooking_admin() {
function commonsbooking_sanitizeHTML( $string ): string {
global $allowedposttags;

if ( empty ( $string ) ) {
if ( empty( $string ) ) {
return '';
}
$allowed_atts = array(
Expand Down Expand Up @@ -237,7 +235,7 @@ function commonsbooking_filter_from_cmb2( $field_args ) {
/**
* Only return default value if we don't have a post ID (in the 'post' query variable)
*
* @param bool $default On/Off (true/false)
* @param bool $default On/Off (true/false)
* @return mixed Returns true or '', the blank default
*/
function cmb2_set_checkbox_default_for_new_post() {
Expand All @@ -252,24 +250,22 @@ function cmb2_set_checkbox_default_for_new_post() {
* Recursive sanitation for text or array
*
* @param mixed array_or_string (array|string)
* @param string $sanitize_function name of the sanitziation function, default = sanitize_text_field. You can use any method that accepts a string as parameter
* @param string $sanitize_function name of the sanitziation function, default = sanitize_text_field. You can use any method that accepts a string as parameter
*
* See more wordpress sanitization functions: https://developer.wordpress.org/themes/theme-security/data-sanitization-escaping/
* See more wordpress sanitization functions: https://developer.wordpress.org/themes/theme-security/data-sanitization-escaping/
*
* @return array|string
*/
function commonsbooking_sanitizeArrayorString( $data, $sanitizeFunction = 'sanitize_text_field' ) {
if ( is_array( $data ) ) {
foreach ( $data as $key => $value ) {
$data[ $key ] = commonsbooking_sanitizeArrayorString( $value, $sanitizeFunction );
}
} else {
$data = call_user_func( $sanitizeFunction, $data );
}

function commonsbooking_sanitizeArrayorString( $data, $sanitizeFunction = 'sanitize_text_field' ) {
if ( is_array( $data ) ) {
foreach ( $data as $key => $value ) {
$data[ $key ] = commonsbooking_sanitizeArrayorString( $value, $sanitizeFunction );
}
} else {
$data = call_user_func( $sanitizeFunction, $data );
}

return $data;

return $data;
}


Expand All @@ -278,28 +274,28 @@ function commonsbooking_sanitizeArrayorString( $data, $sanitizeFunction = 'sanit
* only active if DEBUG_LOG is on
*
* @param mixed $log can be a string, array or object
* @param bool $backtrace if set true the file-path and line of the calling file will be added to the error message
* @param bool $backtrace if set true the file-path and line of the calling file will be added to the error message
*
* @return void
*/
function commonsbooking_write_log( $log, $backtrace = true ) {

if ( ! WP_DEBUG_LOG ) {
return;
}
if ( ! WP_DEBUG_LOG ) {
return;
}

if ( is_array( $log ) || is_object( $log ) ) {
if ( is_array( $log ) || is_object( $log ) ) {
$logmessage = ( print_r( $log, true ) );
} else {
$logmessage = $log ;
$logmessage = $log;
}

if ( $backtrace ) {
$bt = debug_backtrace();
$file = $bt[0]['file'];
$line = $bt[0]['line'];
$logmessage = $file . ':' . $line . ' ' . $logmessage;
$bt = debug_backtrace();
$file = $bt[0]['file'];
$line = $bt[0]['line'];
$logmessage = $file . ':' . $line . ' ' . $logmessage;
}

error_log( $logmessage );
}
}
Loading
Loading