| 1 |
<?php |
| 2 |
|
| 3 |
// General plugin logic, feature toggles, repository/service getters, plugin state, etc. |
| 4 |
|
| 5 |
function easy_invoice_should_show_quote_adjust_field(): bool { |
| 6 |
return \EasyInvoice\Controllers\SettingsController::shouldShowQuoteAdjustField(); |
| 7 |
} |
| 8 |
function easy_invoice_should_show_invoice_adjust_field(): bool { |
| 9 |
return \EasyInvoice\Controllers\SettingsController::shouldShowInvoiceAdjustField(); |
| 10 |
} |
| 11 |
function easy_invoice_get_quote_prefix(): string { |
| 12 |
return \EasyInvoice\Controllers\SettingsController::getQuotePrefix(); |
| 13 |
} |
| 14 |
function easy_invoice_get_quote_starting_number(): int { |
| 15 |
return \EasyInvoice\Controllers\SettingsController::getQuoteStartingNumber(); |
| 16 |
} |
| 17 |
function easy_invoice_get_quote_terms_conditions(): string { |
| 18 |
return \EasyInvoice\Controllers\SettingsController::getQuoteTermsConditions(); |
| 19 |
} |
| 20 |
function easy_invoice_get_quote_footer_text(): string { |
| 21 |
return \EasyInvoice\Controllers\SettingsController::getQuoteFooterText(); |
| 22 |
} |
| 23 |
function easy_invoice_should_show_quote_accept_button(): bool { |
| 24 |
return \EasyInvoice\Controllers\SettingsController::shouldShowQuoteAcceptButton(); |
| 25 |
} |
| 26 |
function easy_invoice_get_quote_accept_action(): string { |
| 27 |
return \EasyInvoice\Controllers\SettingsController::getQuoteAcceptAction(); |
| 28 |
} |
| 29 |
function easy_invoice_get_quote_accept_text(): string { |
| 30 |
return \EasyInvoice\Controllers\SettingsController::getQuoteAcceptText(); |
| 31 |
} |
| 32 |
function easy_invoice_get_accepted_quote_message(): string { |
| 33 |
return \EasyInvoice\Controllers\SettingsController::getAcceptedQuoteMessage(); |
| 34 |
} |
| 35 |
function easy_invoice_is_decline_reason_required(): bool { |
| 36 |
return \EasyInvoice\Controllers\SettingsController::isDeclineReasonRequired(); |
| 37 |
} |
| 38 |
function easy_invoice_get_declined_quote_message(): string { |
| 39 |
return \EasyInvoice\Controllers\SettingsController::getDeclinedQuoteMessage(); |
| 40 |
} |
| 41 |
function easy_invoice_get_invoice_prefix(): string { |
| 42 |
return \EasyInvoice\Controllers\SettingsController::getInvoicePrefix(); |
| 43 |
} |
| 44 |
function easy_invoice_get_invoice_starting_number(): int { |
| 45 |
return \EasyInvoice\Controllers\SettingsController::getInvoiceStartingNumber(); |
| 46 |
} |
| 47 |
function easy_invoice_get_invoice_terms_conditions(): string { |
| 48 |
return \EasyInvoice\Controllers\SettingsController::getInvoiceTermsConditions(); |
| 49 |
} |
| 50 |
function easy_invoice_get_invoice_footer_text(): string { |
| 51 |
return \EasyInvoice\Controllers\SettingsController::getInvoiceFooterText(); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Get invoice repository helper function. |
| 56 |
* |
| 57 |
* @since 1.0.0 |
| 58 |
* @return \EasyInvoice\Interfaces\InvoiceRepositoryInterface |
| 59 |
*/ |
| 60 |
function easy_invoice_get_repository() { |
| 61 |
return \EasyInvoice\Providers\InvoiceServiceProvider::getInvoiceRepository(); |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Get client repository helper function. |
| 66 |
* |
| 67 |
* @since 1.0.0 |
| 68 |
* @return \EasyInvoice\Interfaces\ClientRepositoryInterface |
| 69 |
*/ |
| 70 |
function easy_invoice_get_client_repository() { |
| 71 |
return \EasyInvoice\Providers\ClientServiceProvider::getClientRepository(); |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Get invoice item repository helper function. |
| 76 |
* |
| 77 |
* @since 1.0.0 |
| 78 |
* @return \EasyInvoice\Interfaces\InvoiceItemRepositoryInterface |
| 79 |
*/ |
| 80 |
function easy_invoice_get_invoice_item_repository() { |
| 81 |
return \EasyInvoice\Providers\InvoiceItemServiceProvider::getInvoiceItemRepository(); |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Get invoice number service helper function. |
| 86 |
* |
| 87 |
* @since 1.0.0 |
| 88 |
* @return \EasyInvoice\Services\InvoiceNumberService |
| 89 |
*/ |
| 90 |
function easy_invoice_get_invoice_number_service() { |
| 91 |
$provider = new \EasyInvoice\Providers\InvoiceNumberServiceProvider(); |
| 92 |
return $provider->getInvoiceNumberService(); |
| 93 |
} |
| 94 |
|
| 95 |
/** |
| 96 |
* Get quote number service helper function. |
| 97 |
* |
| 98 |
* @since 1.0.0 |
| 99 |
* @return \EasyInvoice\Services\QuoteNumberService |
| 100 |
*/ |
| 101 |
function easy_invoice_get_quote_number_service() { |
| 102 |
return \EasyInvoice\Providers\QuoteNumberServiceProvider::getQuoteNumberServiceStatic(); |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* Check if Easy Invoice Pro is installed and active |
| 107 |
* |
| 108 |
* @since 1.0.0 |
| 109 |
* @return bool |
| 110 |
*/ |
| 111 |
function easy_invoice_has_pro(): bool { |
| 112 |
return class_exists('EasyInvoicePro'); |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* Convert various boolean values to a consistent boolean |
| 117 |
* |
| 118 |
* @since 1.0.0 |
| 119 |
* @param mixed $value The value to convert to boolean |
| 120 |
* @return bool |
| 121 |
*/ |
| 122 |
function easy_invoice_boolean($value): bool { |
| 123 |
return \EasyInvoice\Helpers\BooleanHelper::toBoolean($value); |
| 124 |
} |
| 125 |
function easy_invoice_str_replace($search, $replace, $subject, $count = null) { |
| 126 |
// Ensure $subject is not null |
| 127 |
$subject = $subject ?? ''; |
| 128 |
|
| 129 |
if($count === null) { |
| 130 |
return str_replace($search, $replace, $subject); |
| 131 |
} |
| 132 |
return str_replace($search, $replace, $subject, $count); |
| 133 |
} |