refactor(autoload): migrate theme classes to Composer PSR-4
Move 288 types from global AKSRT_* + inc/classes manual requires into
namespace AKSRT\{Domain} under src/AKSRT/, wire composer.json psr-4,
and slim bootstrap to helpers/modules/hooks only. Split multi-class
widget/gateway files, update admin contract audit paths, and document
the layout in ADR/README.
This commit is contained in:
1 parent
8f349b40fb
commit
aaf458af1c
404 files changed
+13602
-7705
No files matched your search
+19
-19
@@ -19,8 +19,8 @@ add_action('admin_menu', function () {
|
||||
// ============================================================
|
||||
|
||||
function aksrt_get_gravatar_source() {
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
return AKSRT_Settings::avatar_source();
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
return \AKSRT\Settings\Settings::avatar_source();
|
||||
}
|
||||
|
||||
$source = aksrt_get_setting('avatar_source', 'cn.cravatar.com');
|
||||
@@ -87,8 +87,8 @@ add_action('phpmailer_init', function ($phpmailer) {
|
||||
if (!empty($mail['from_address'])) {
|
||||
$from_name = isset($mail['from_name']) ? $mail['from_name'] : '';
|
||||
// mail_showname 覆盖 from_name
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
$branding = AKSRT_Settings::get_mail_branding();
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$branding = \AKSRT\Settings\Settings::get_mail_branding();
|
||||
if ($branding['showname'] !== '') {
|
||||
$from_name = $branding['showname'];
|
||||
}
|
||||
@@ -99,8 +99,8 @@ add_action('phpmailer_init', function ($phpmailer) {
|
||||
$phpmailer->FromName = $mail['from_name'];
|
||||
}
|
||||
// mail_showname 全局覆盖 FromName
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
$branding = AKSRT_Settings::get_mail_branding();
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$branding = \AKSRT\Settings\Settings::get_mail_branding();
|
||||
if ($branding['showname'] !== '') {
|
||||
$phpmailer->FromName = $branding['showname'];
|
||||
}
|
||||
@@ -109,8 +109,8 @@ add_action('phpmailer_init', function ($phpmailer) {
|
||||
|
||||
// mail_title_prefix:为所有邮件主题添加前缀
|
||||
add_filter('wp_mail', function ($atts) {
|
||||
if (!class_exists('AKSRT_Settings') || empty($atts['subject'])) return $atts;
|
||||
$branding = AKSRT_Settings::get_mail_branding();
|
||||
if (!class_exists('\AKSRT\Settings\Settings') || empty($atts['subject'])) return $atts;
|
||||
$branding = \AKSRT\Settings\Settings::get_mail_branding();
|
||||
if ($branding['title_prefix'] !== '' && strpos($atts['subject'], $branding['title_prefix']) !== 0) {
|
||||
$atts['subject'] = $branding['title_prefix'] . ' ' . $atts['subject'];
|
||||
}
|
||||
@@ -198,8 +198,8 @@ function aksrt_save_category_meta(int $term_id) {
|
||||
delete_term_meta($term_id, 'aksrt_category_recommend_desc');
|
||||
}
|
||||
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
AKSRT_Settings::flush_category_recommend_cache();
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
\AKSRT\Settings\Settings::flush_category_recommend_cache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,11 +301,11 @@ add_action('pre_get_posts', function ($query) {
|
||||
|
||||
$orderby = isset($_GET['orderby']) ? sanitize_key((string) $_GET['orderby']) : 'date';
|
||||
if ($orderby === 'downloads') {
|
||||
$query->set('meta_key', AKSRT_Domain_Model::RESOURCE_DOWNLOAD_COUNT_KEY);
|
||||
$query->set('meta_key', \AKSRT\Core\DomainModel::RESOURCE_DOWNLOAD_COUNT_KEY);
|
||||
$query->set('orderby', 'meta_value_num');
|
||||
$query->set('order', 'DESC');
|
||||
} elseif ($orderby === 'views') {
|
||||
$query->set('meta_key', AKSRT_Domain_Model::RESOURCE_VIEW_COUNT_KEY);
|
||||
$query->set('meta_key', \AKSRT\Core\DomainModel::RESOURCE_VIEW_COUNT_KEY);
|
||||
$query->set('orderby', 'meta_value_num');
|
||||
$query->set('order', 'DESC');
|
||||
}
|
||||
@@ -317,7 +317,7 @@ add_action('pre_get_posts', function ($query) {
|
||||
$meta_query = [
|
||||
'relation' => 'AND',
|
||||
[
|
||||
'key' => AKSRT_Domain_Model::RESOURCE_MARKER_KEY,
|
||||
'key' => \AKSRT\Core\DomainModel::RESOURCE_MARKER_KEY,
|
||||
'value' => '1',
|
||||
'compare' => '=',
|
||||
],
|
||||
@@ -327,19 +327,19 @@ add_action('pre_get_posts', function ($query) {
|
||||
$meta_query[] = [
|
||||
'relation' => 'OR',
|
||||
[
|
||||
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
|
||||
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
|
||||
'value' => 0,
|
||||
'compare' => '=',
|
||||
'type' => 'NUMERIC',
|
||||
],
|
||||
[
|
||||
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
|
||||
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
|
||||
'compare' => 'NOT EXISTS',
|
||||
],
|
||||
];
|
||||
} elseif ($price_filter === 'paid') {
|
||||
$meta_query[] = [
|
||||
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
|
||||
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
|
||||
'value' => 0,
|
||||
'compare' => '>',
|
||||
'type' => 'NUMERIC',
|
||||
@@ -349,21 +349,21 @@ add_action('pre_get_posts', function ($query) {
|
||||
if ($price_min !== null || $price_max !== null) {
|
||||
if ($price_min !== null && $price_max !== null) {
|
||||
$meta_query[] = [
|
||||
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
|
||||
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
|
||||
'value' => [$price_min, $price_max],
|
||||
'compare' => 'BETWEEN',
|
||||
'type' => 'NUMERIC',
|
||||
];
|
||||
} elseif ($price_min !== null) {
|
||||
$meta_query[] = [
|
||||
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
|
||||
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
|
||||
'value' => $price_min,
|
||||
'compare' => '>=',
|
||||
'type' => 'NUMERIC',
|
||||
];
|
||||
} else {
|
||||
$meta_query[] = [
|
||||
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
|
||||
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
|
||||
'value' => $price_max,
|
||||
'compare' => '<=',
|
||||
'type' => 'NUMERIC',
|
||||
|
||||
Reference in new issue
Block a user