Skip to content

Commit

Permalink
Remove unused imports;
Browse files Browse the repository at this point in the history
Use `str_starts_with()` function
  • Loading branch information
janschoenherr committed Dec 20, 2024
1 parent 1b59589 commit bd2f85d
Show file tree
Hide file tree
Showing 28 changed files with 40 additions and 74 deletions.
2 changes: 0 additions & 2 deletions commonsbooking.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/

use CommonsBooking\Plugin;

defined('ABSPATH') or die("Thanks for visiting");
define('COMMONSBOOKING_VERSION', '2.9.4');
define('COMMONSBOOKING_VERSION_COMMENT', 'master'); // Empty for release - Used to mark development versions
Expand Down
21 changes: 10 additions & 11 deletions includes/OptionsArray.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php


use CommonsBooking\Helper;
use CommonsBooking\Service\BookingRule;
use CommonsBooking\View\Migration;
use CommonsBooking\Helper\Wordpress;
Expand All @@ -15,11 +14,11 @@

// We need static types, because german month names don't work for datepicker
$dateFormat = "d/m/Y";
if ( strpos( get_locale(), 'de_' ) !== false ) {
if ( str_starts_with( get_locale(), 'de_' ) ) {
$dateFormat = "d.m.Y";
}

if ( strpos( get_locale(), 'en_' ) !== false ) {
if ( str_starts_with( get_locale(), 'en_' ) ) {
$dateFormat = "m/d/Y";
}

Expand Down Expand Up @@ -468,7 +467,7 @@
)
),
/* image options end */

/* field group color setting */

'colorscheme' => array(
Expand Down Expand Up @@ -536,7 +535,7 @@
'desc' => commonsbooking_sanitizeHTML( __( 'The color used for the background of tables and similar elements', 'commonsbooking' ) ),
'default' => '#f6f6f6',
),

array(
'name' => commonsbooking_sanitizeHTML( __( 'Notice Background Color', 'commonsbooking' ) ),
'id' => 'colorscheme_noticebackgroundcolor',
Expand Down Expand Up @@ -784,7 +783,7 @@
'id' => 'pre-booking-reminder-activate',
'type' => 'checkbox',
),
// E-Mail pre booking reminder
// E-Mail pre booking reminder
array(
'name' => commonsbooking_sanitizeHTML( __( 'E-mail subject', 'commonsbooking' ) ),
'id' => 'pre-booking-reminder-subject',
Expand All @@ -807,7 +806,7 @@
{{booking:getEmailSignature}}', 'commonsbooking' ) ),
),

// settings pre booking reminder -- min days
// settings pre booking reminder -- min days
array(
'name' => commonsbooking_sanitizeHTML( __( 'Sent reminder x days before booking start', 'commonsbooking' ) ),
'id' => 'pre-booking-days-before',
Expand Down Expand Up @@ -881,7 +880,7 @@
'id' => 'post-booking-notice-activate',
'type' => 'checkbox',
),
// E-Mail post booking reminder
// E-Mail post booking reminder
array(
'name' => commonsbooking_sanitizeHTML( __( 'E-mail subject', 'commonsbooking' ) ),
'id' => 'post-booking-notice-subject',
Expand Down Expand Up @@ -1136,21 +1135,21 @@
),
array(
'name' => commonsbooking_sanitizeHTML( __( 'Location-Fields', 'commonsbooking' ) ),
'desc' => sprintf ( commonsbooking_sanitizeHTML( __( 'Just add field names, no matter if its a post- or a meta-field. Comma separated list. Beside the standard post fields and standard postmeta-fields, the following custom meta fields are available. Copy only the values in [] in the field without the brackets. %s', 'commonsbooking' ) ),
'desc' => sprintf ( commonsbooking_sanitizeHTML( __( 'Just add field names, no matter if its a post- or a meta-field. Comma separated list. Beside the standard post fields and standard postmeta-fields, the following custom meta fields are available. Copy only the values in [] in the field without the brackets. %s', 'commonsbooking' ) ),
commonsbooking_sanitizeHTML( Settings::returnFormattedMetaboxFields('cb_location') ) ),
'id' => TimeframeExport::LOCATION_FIELD,
'type' => 'text'
),
array(
'name' => commonsbooking_sanitizeHTML( __( 'Item-Fields', 'commonsbooking' ) ),
'desc' => sprintf ( commonsbooking_sanitizeHTML( __( 'Just add field names, no matter if its a post- or a meta-field. Comma separated list. Beside the standard post fields and standard postmeta-fields, the following custom meta fields are available. Copy only the values in [] in the field without the brackets. %s', 'commonsbooking' ) ),
'desc' => sprintf ( commonsbooking_sanitizeHTML( __( 'Just add field names, no matter if its a post- or a meta-field. Comma separated list. Beside the standard post fields and standard postmeta-fields, the following custom meta fields are available. Copy only the values in [] in the field without the brackets. %s', 'commonsbooking' ) ),
commonsbooking_sanitizeHTML( Settings::returnFormattedMetaboxFields('cb_item') ) ),
'id' => TimeframeExport::ITEM_FIELD,
'type' => 'text'
),
array(
'name' => commonsbooking_sanitizeHTML( __( 'User-Fields', 'commonsbooking' ) ),
'desc' => commonsbooking_sanitizeHTML( __( 'Just add field names, no matter if its a userfield or a meta-field. Comma separated list.', 'commonsbooking' ) ),
'desc' => commonsbooking_sanitizeHTML( __( 'Just add field names, no matter if its a userfield or a meta-field. Comma separated list.', 'commonsbooking' ) ),
'id' => TimeframeExport::USER_FIELD,
'type' => 'text'
),
Expand Down
5 changes: 0 additions & 5 deletions includes/Users.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
<?php

use CommonsBooking\Plugin;
use CommonsBooking\Wordpress\CustomPostType\Booking;
use CommonsBooking\Wordpress\CustomPostType\CustomPostType;
use CommonsBooking\Wordpress\CustomPostType\Item;
use CommonsBooking\Wordpress\CustomPostType\Location;
use CommonsBooking\Wordpress\CustomPostType\Restriction;
use CommonsBooking\Wordpress\CustomPostType\Timeframe;


/**
Expand Down
1 change: 0 additions & 1 deletion src/API/GBFS/SystemInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace CommonsBooking\API\GBFS;

use Exception;
use stdClass;
use WP_REST_Response;

Expand Down
3 changes: 0 additions & 3 deletions src/Map/MapAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

namespace CommonsBooking\Map;

use CommonsBooking\Wordpress\CustomPostType\Item;
use CommonsBooking\Wordpress\CustomPostType\Location;


/**
* This defines the map settings page in the admin area.
Expand Down
1 change: 0 additions & 1 deletion src/Map/MapFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace CommonsBooking\Map;

use DateTime;

class MapFilter {

Expand Down
1 change: 0 additions & 1 deletion src/Map/MapItemAvailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use CommonsBooking\View\Calendar;
use DateInterval;
use DatePeriod;
use DateTime;
use Exception;

class MapItemAvailable {
Expand Down
1 change: 0 additions & 1 deletion src/Messages/BookingReminderMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use CommonsBooking\Model\MessageRecipient;
use CommonsBooking\Repository\Booking;
use CommonsBooking\Service\Scheduler;
use CommonsBooking\Settings\Settings;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Model/Timeframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use CommonsBooking\Exception\OverlappingException;
use CommonsBooking\Exception\TimeframeInvalidException;
use CommonsBooking\Helper\Wordpress;
use CommonsBooking\Tests\Repository\TimeframeTest;
use DateTime;
use Exception;

Expand Down Expand Up @@ -898,7 +897,7 @@ public function getGrid(): int {
* Checks if timeframes are overlapping in time ranges or daily slots.
*
* Use {@see Timeframe::overlaps()} if you want to compute full-overlap between two timeframes.
*
*
* @param Timeframe $otherTimeframe
*
* @return bool If start-time and end-time overlaps, regardless of overlapping start-date and end-date.
Expand Down
1 change: 0 additions & 1 deletion src/Repository/PostRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


use CommonsBooking\Plugin;
use Exception;
use WP_Post;

abstract class PostRepository {
Expand Down
2 changes: 0 additions & 2 deletions src/View/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace CommonsBooking\View;

use CommonsBooking\CB\CB;
use CommonsBooking\Helper\Helper;
use CommonsBooking\Helper\Wordpress;
use CommonsBooking\Model\CustomPost;
Expand All @@ -14,7 +13,6 @@
use CommonsBooking\Wordpress\CustomPostType\Item;
use CommonsBooking\Wordpress\CustomPostType\Location;
use CommonsBooking\Wordpress\CustomPostType\Timeframe;
use DateInterval;
use DateTime;
use Exception;
use WP_Post;
Expand Down
1 change: 0 additions & 1 deletion src/View/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace CommonsBooking\View;

use CommonsBooking\Map\MapAdmin;
use CommonsBooking\Plugin;

/**
* The Map shortcode. Further logic is found in @see \CommonsBooking\Map\
Expand Down
6 changes: 2 additions & 4 deletions src/Wordpress/CustomPostType/Booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
namespace CommonsBooking\Wordpress\CustomPostType;

use CommonsBooking\Exception\BookingDeniedException;
use CommonsBooking\Exception\BookingRuleException;
use CommonsBooking\Exception\TimeframeInvalidException;
use CommonsBooking\Helper\Helper;
use CommonsBooking\Messages\BookingMessage;
use CommonsBooking\Service\BookingRuleApplied;
use CommonsBooking\Service\iCalendar;
use CommonsBooking\Settings\Settings;
use Exception;
use function wp_verify_nonce;

Expand Down Expand Up @@ -717,11 +715,11 @@ public function registerMetabox() {
protected function getCustomFields() {
// We need static types, because german month names dont't work for datepicker
$dateFormat = 'd/m/Y';
if ( strpos( get_locale(), 'de_' ) !== false ) {
if ( str_starts_with( get_locale(), 'de_' ) ) {
$dateFormat = 'd.m.Y';
}

if ( strpos( get_locale(), 'en_' ) !== false ) {
if ( str_starts_with( get_locale(), 'en_' ) ) {
$dateFormat = 'm/d/Y';
}

Expand Down
2 changes: 1 addition & 1 deletion src/Wordpress/CustomPostType/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,6 @@ public function registerMetabox() {
foreach ($cmb->meta_box['fields'] as $metabox_field) {
$metabox_fields[$metabox_field['id']] = $metabox_field['name'];
}
Settings::updateOption('commonsbooking_settings_metaboxfields', $this->getPostType(), $metabox_fields);
Settings::updateOption('commonsbooking_settings_metaboxfields', static::getPostType(), $metabox_fields);
}
}
2 changes: 1 addition & 1 deletion src/Wordpress/CustomPostType/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public function registerMetabox() {
foreach ($cmb->meta_box['fields'] as $metabox_field) {
$metabox_fields[$metabox_field['id']] = $metabox_field['name'];
}
Settings::updateOption('commonsbooking_settings_metaboxfields', $this->getPostType(), $metabox_fields);
Settings::updateOption('commonsbooking_settings_metaboxfields', static::getPostType(), $metabox_fields);
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/Wordpress/CustomPostType/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ class Map extends CustomPostType {
* Initiates needed hooks.
*/
public function initHooks() {
$cb_map_settings = new MapSettings();

// TODO check the following comment
// deactivated individual map settings because we don't need them righ now
// map setting should be integrated in CB settings in the future
//$cb_map_settings->prepare_settings();
if ( $cb_map_settings->get_option( 'booking_page_link_replacement' ) ) {

if ( MapSettings::get_option( 'booking_page_link_replacement' ) ) {
add_action( 'wp_enqueue_scripts', array( Map::class, 'replace_map_link_target' ), 11 );
}

Expand Down
8 changes: 4 additions & 4 deletions src/Wordpress/CustomPostType/Restriction.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static function addAdminLocationFilter() {
}

/**
* Adds filter dropdown // filter by status in restrictions list
* Adds filter dropdown // filter by status in restrictions list
*/
public static function addAdminStatusFilter() {
Filter::renderFilter(
Expand Down Expand Up @@ -220,7 +220,7 @@ public function setCustomColumnsData( $column, $post_id ) {
}

/**
* Filters admin list by type, timerange, user
* Filters admin list by type, timerange, user
*
* @param \WP_Query $query for admin list objects
*
Expand Down Expand Up @@ -404,11 +404,11 @@ public function registerMetabox() {
protected function getCustomFields(): array {
// We need static types, because german month names dont't work for datepicker
$dateFormat = "d/m/Y";
if ( strpos( get_locale(), 'de_' ) !== false ) {
if ( str_starts_with( get_locale(), 'de_' ) ) {
$dateFormat = "d.m.Y";
}

if ( strpos( get_locale(), 'en_' ) !== false ) {
if ( str_starts_with( get_locale(), 'en_' ) ) {
$dateFormat = "m/d/Y";
}

Expand Down
15 changes: 7 additions & 8 deletions src/Wordpress/CustomPostType/Timeframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use CommonsBooking\Model\BookingCode;
use WP_Post;
use Exception;
use CommonsBooking\CB\CB;
use CommonsBooking\View\Calendar;
use CommonsBooking\View\Admin\Filter;
use CommonsBooking\Repository\BookingCodes;
Expand Down Expand Up @@ -233,7 +232,7 @@ public static function getView() {
// @TODO implement view.
}


/**
* Adds filter dropdown // filter by type (eg. bookable, repair etc.) in timeframe List
*
Expand Down Expand Up @@ -304,7 +303,7 @@ public static function addAdminLocationFilter() {

/**
* Adds filter dropdown // filter by location in booking list
*
*
*/
public static function addAdminStatusFilter() {
$values = [];
Expand Down Expand Up @@ -387,7 +386,7 @@ public static function filterAdminList( $query ) {
$query->query_vars[ $key ] = sanitize_text_field( $_GET[ $filter ] );
}
}

// Timerange filtering
// Start date
if (
Expand Down Expand Up @@ -466,11 +465,11 @@ public function registerMetabox() {
protected function getCustomFields() {
// We need static types, because german month names dont't work for datepicker
$dateFormat = "d/m/Y";
if ( strpos( get_locale(), 'de_' ) !== false ) {
if ( str_starts_with( get_locale(), 'de_' ) ) {
$dateFormat = "d.m.Y";
}

if ( strpos( get_locale(), 'en_' ) !== false ) {
if ( str_starts_with( get_locale(), 'en_' ) ) {
$dateFormat = "m/d/Y";
}

Expand Down Expand Up @@ -1363,15 +1362,15 @@ public function initHooks() {
// Add custom cmb2 type for email booking codes by cron
add_action( 'cmb2_render_booking_codes_email_fields', ['\CommonsBooking\View\BookingCodes','renderCronEmailFields'], 10, 5 );
add_action("cmb2_save_field_" . \CommonsBooking\View\BookingCodes::CRON_EMAIL_CODES,['\CommonsBooking\View\BookingCodes','cronEmailCodesSaved'],10,3);

// Add Meta Boxes
add_action( 'cmb2_admin_init', array( $this, 'registerMetabox' ) );

// must be 'save_post' only because of priority in relation to cmb2
add_action( 'save_post', array( $this, 'savePost' ), 11, 2 );

add_action('updated_post_meta',array($this, 'updatedPostMeta'),11,4);

// Add type filter to backend list view
add_action( 'restrict_manage_posts', array( self::class, 'addAdminTypeFilter' ) );
add_action( 'restrict_manage_posts', array( self::class, 'addAdminItemFilter' ) );
Expand Down
4 changes: 1 addition & 3 deletions src/Wordpress/Options/OptionsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace CommonsBooking\Wordpress\Options;

use CommonsBooking\Messages\AdminMessage;
use CommonsBooking\Plugin;
use CommonsBooking\View\TimeframeExport;
use Exception;

/**
Expand Down Expand Up @@ -83,7 +81,7 @@ public function registerOptionsGroups() {

foreach ( $this->groups as $group ) {

$group = $this->prependTitle( $group ); /* prepend title + description html */
$group = static::prependTitle( $group ); /* prepend title + description html */

// Add Fields
$fields = $group['fields'];
Expand Down
Loading

0 comments on commit bd2f85d

Please sign in to comment.