Skip to content

Commit 1c7f3ac

Browse files
committed
Released version 4.2 with a lot of changes
1 parent e5a5707 commit 1c7f3ac

26 files changed

Lines changed: 181 additions & 93 deletions

README.md

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,71 @@
1-
# Twee 4.1
2-
3-
**Twee** is the advanced WordPress starter theme focused on simplifying the theme development and support
1+
# Twee 4.2
42

3+
**Twee** is a powerful WordPress theme framework built for high-performance, large-scale projects. It is finely tuned for Advanced Custom Fields, features an
4+
alternative metadata storage API, and leverages object caching to minimize database load and maximize speed.
55

66
## Features
77

8-
* Asset management library allowing to manage scripts, stylesheets, and localization strings
9-
* Resize and cache thumbnails with or without registering a new image size
10-
* Base widget class with custom settings
11-
* Taxonomy and terms processing libraries
12-
* Breadcrumbs with built-in JSON-LD and microdata support
13-
* Pagination with custom query support
14-
* Modules to load more posts and process the contact form with attachments
15-
* One file configuration. It allows you to specify all your image sizes, assets, menu locations, sidebars, custom post types, taxonomies, and other things in
16-
one place
8+
### 1. Ultrafast Metadata Storage for Advanced Custom Fields
9+
10+
- Stores metadata for Repeater, Group, or Clone fields in a single row instead of multiple rows
11+
- Fully compatible with the WordPress Metadata API, even for complex field types
12+
- Stores field keys in a single field, instead of duplicating keys for each row as in the default ACF behavior
13+
- Fully supports the ACF API and all ACF plugins
14+
- Enables dynamic rendering for ACF Flexible Content fields when using the ACF Extended plugin
15+
- Supports automatic section preview generation for ACF Flexible Content fields via Puppeteer
16+
17+
### 2. Highly Optimized Metadata API
18+
19+
- Includes a performance-optimized metadata API that remains fully compatible with WordPress
20+
- Reduces heavy database queries by preloading metadata into memory
21+
- Uses cache partitioning to minimize data transfer from cache
22+
- Implements advanced techniques like binary search to speed up metadata access
23+
- Fully integrates with WordPress metadata caching
24+
- Performs fast metadata updates by checking for changes before writing to the database
25+
26+
### 3. High-Performance Post and Term Libraries
27+
28+
- Enables bulk fetching of post data to avoid N+1 query issues
29+
- Retrieves post terms and term posts in a single request for improved performance
30+
- Builds and caches term trees, with the ability to flatten them if needed
31+
- Includes term threading to easily retrieve full parent-child term hierarchies
32+
- Supports fetching post IDs associated with specific terms
33+
34+
### 4. Advanced Asset Management
35+
36+
- Automatically scans, resolves, and registers assets and their dependencies
37+
- Includes only required styles based on section class names
38+
- Injects essential base styles and fonts into the head for improved loading speed
39+
- Automates versioning to eliminate manual version bumps when unnecessary
40+
- Loads required assets for Flexible Content section previews automatically
41+
42+
### 5. Efficient Image Processing and Thumbnail Generation
43+
44+
- Supports hidden image sizes that generate thumbnails on demand to avoid clutter
45+
- Integrates with popular image minification plugins for optimized output
46+
- Allows SVG uploads and generates proper metadata
47+
- Automatically generates correct srcset and sizes based on layout settings
48+
- Uses high-performance caching for faster thumbnail generation
49+
- Provides built-in WebP conversion support
50+
51+
### 6. Additional Tools and Utilities
52+
53+
- Includes a custom pagination library with support for custom queries
54+
- Offers a breadcrumbs library with JSON-LD structured data support
55+
- Fixes common accessibility issues in menus
56+
- Built-in Load More post handler for dynamic content loading
57+
- Integrated logging system with WooCommerce compatibility
58+
- Provides a base class for building widgets
59+
- Centralized configuration within functions.php for easy management
60+
61+
### 7. Build Tools and Styles
62+
63+
- Uses Gulp to build all assets, automatically generating separate block styles, injecting CSS properties into the head, and applying additional optimizations
64+
- Assumes that all styles for a single block are located in one SCSS or CSS file, with the base class ending in _box. Learn more about this approach
65+
here: [CSS_BOX: A Better Way to Write CSS](https://www.reddit.com/r/css/comments/1apomz1/css_box_a_better_way_to_write_css/)
66+
- The HTML/CSS starter kit is available in a separate repository: [CSS_BOX Starter Kit](https://github.com/TwistedAndy/starter-kit)
67+
- Uses the Bigger Picture library for popup images and videos: [Bigger Picture](https://github.com/TwistedAndy/bigger-picture). This library is optimized for
68+
maximum browser performance and a smooth user experience
1769

1870

1971
## About

theme/includes/core/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @author Andrii Toniievych <toniyevych@gmail.com>
66
* @package Twee
7-
* @version 4.1
7+
* @version 4.2
88
*/
99

1010
global $twee_cache;

theme/includes/core/asset.php

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,27 @@
44
*
55
* @author Andrii Toniievych <toniyevych@gmail.com>
66
* @package Twee
7-
* @version 4.1
7+
* @version 4.2
88
*/
99

1010
/**
11-
* Register assets from the plugins and blocks folders
11+
* Add an asset placeholder
12+
*/
13+
add_action('wp_head', 'tw_asset_placeholder', 6);
14+
15+
16+
/**
17+
* Scan and register assets from the plugins and blocks folders
18+
* It's important to do this before the 'wp_enqueue_scripts' call
1219
*/
13-
add_action('init', function() {
20+
add_action('wp_head', 'tw_asset_init', 0);
21+
add_action('admin_enqueue_scripts', 'tw_asset_init', 0);
22+
23+
function tw_asset_init() {
1424

25+
/**
26+
* Register assets from the plugins folder
27+
*/
1528
$base = TW_ROOT . 'assets/plugins/';
1629

1730
$files = scandir($base);
@@ -54,6 +67,9 @@
5467

5568
}
5669

70+
/**
71+
* Register styles from the blocks folder
72+
*/
5773
$base = TW_ROOT . 'assets/build/blocks/';
5874

5975
$files = scandir($base);
@@ -93,22 +109,56 @@
93109
return;
94110
}
95111

96-
tw_app_set('registered', $assets, 'assets');
112+
/**
113+
* Normalize assets and collect dependencies
114+
*/
115+
$available = [
116+
'style' => [],
117+
'script' => [],
118+
];
97119

98120
foreach ($assets as $name => $asset) {
99121

100122
if (!is_string($name) or empty($asset)) {
123+
unset($assets[$name]);
101124
continue;
102125
}
103126

104127
$asset = tw_asset_normalize($asset);
105128

106129
if (!is_array($asset)) {
107-
continue;
130+
unset($assets[$name]);
131+
}
132+
133+
if (!empty($asset['style'])) {
134+
$available['style'][] = $name;
135+
}
136+
137+
if (!empty($asset['script'])) {
138+
$available['script'][] = $name;
108139
}
109140

110141
$assets[$name] = $asset;
111142

143+
}
144+
145+
tw_app_set('registered', $assets, 'assets');
146+
147+
/**
148+
* Check dependencies and register assets in WordPress
149+
*/
150+
foreach ($assets as $name => $asset) {
151+
152+
/**
153+
* Remove unavailable internal dependencies
154+
*/
155+
foreach ($asset['deps'] as $type => $deps) {
156+
if ($deps and array_diff($deps, $available[$type])) {
157+
$asset['deps'][$type] = array_intersect($deps, $available[$type]);
158+
$assets[$name] = $asset;
159+
}
160+
}
161+
112162
if (!empty($asset['prefix'])) {
113163
$asset_name = $asset['prefix'] . $name;
114164
} else {
@@ -173,13 +223,7 @@
173223
ob_start('tw_asset_inject');
174224
}
175225

176-
}, 30);
177-
178-
179-
/**
180-
* Add an asset placeholder
181-
*/
182-
add_action('wp_head', 'tw_asset_placeholder', 6);
226+
}
183227

184228

185229
/**

theme/includes/core/content.php

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @author Andrii Toniievych <toniyevych@gmail.com>
66
* @package Twee
7-
* @version 4.1
7+
* @version 4.2
88
*/
99

1010
/**
@@ -39,17 +39,17 @@ function tw_content_title($object, $length = 0) {
3939

4040

4141
/**
42-
* Get the short description for a given post or text
42+
* Get a short description for a given object or a string
4343
*
44-
* @param bool|string|WP_Post|WP_Term|WP_User $object Post or text to find and strip the text
45-
* @param int $length Required length of the text
46-
* @param bool|string $allowed_tags List of tags separated by "|"
47-
* @param string $find Symbol to find for proper strip
48-
* @param bool $force_cut Strip the post excerpt
44+
* @param string|WP_Post|WP_Term|WP_User $object Post, Term, User, or a string
45+
* @param int $length Required length of the text
46+
* @param bool|string $allowed_tags List of tags separated by "|"
47+
* @param string $find Symbol to find for proper strip
48+
* @param bool $force_cut Strip the post excerpt
4949
*
5050
* @return bool|string
5151
*/
52-
function tw_content_text($object = false, $length = 250, $allowed_tags = false, $find = ' ', $force_cut = true) {
52+
function tw_content_text($object, $length = 250, $allowed_tags = false, $find = ' ', $force_cut = true) {
5353

5454
$excerpt = false;
5555
$text = '';
@@ -131,29 +131,27 @@ function tw_content_link($link, $class = 'button', $hidden = '') {
131131

132132
$result = '';
133133

134-
if (is_array($link) and !empty($link['url']) and isset($link['title'])) {
135-
136-
if ($class) {
137-
$class = ' class="' . $class . '"';
138-
} else {
139-
$class = '';
140-
}
141-
142-
if (!empty($link['target'])) {
143-
$target = ' target="' . $link['target'] . '"';
144-
} else {
145-
$target = '';
146-
}
134+
if (!is_array($link) or empty($link['url']) or !isset($link['title'])) {
135+
return $result;
136+
}
147137

148-
if ($hidden) {
149-
$hidden = '<span class="sr-hidden">' . $hidden . '</span>';
150-
}
138+
if ($class) {
139+
$class = ' class="' . $class . '"';
140+
} else {
141+
$class = '';
142+
}
151143

152-
$result = '<a href="' . esc_url($link['url']) . '"' . $class . $target . '>' . $link['title'] . $hidden . '</a>';
144+
if (!empty($link['target'])) {
145+
$target = ' target="' . $link['target'] . '"';
146+
} else {
147+
$target = '';
148+
}
153149

150+
if ($hidden) {
151+
$hidden = '<span class="sr-hidden">' . $hidden . '</span>';
154152
}
155153

156-
return $result;
154+
return '<a href="' . esc_url($link['url']) . '"' . $class . $target . '>' . $link['title'] . $hidden . '</a>';
157155

158156
}
159157

theme/includes/core/image.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @author Andrii Toniievych <toniyevych@gmail.com>
66
* @package Twee
7-
* @version 4.1
7+
* @version 4.2
88
*/
99

1010
/**

theme/includes/core/legacy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @author Andrii Toniievych <toniyevych@gmail.com>
66
* @package Twee
7-
* @version 4.1
7+
* @version 4.2
88
*/
99

1010
/**

theme/includes/core/logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @author Andrii Toniievych <toniyevych@gmail.com>
66
* @package Twee
7-
* @version 4.1
7+
* @version 4.2
88
*/
99

1010
/**

theme/includes/core/widget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @author Andrii Toniievych <toniyevych@gmail.com>
66
* @package Twee
7-
* @version 4.1
7+
* @version 4.2
88
*/
99

1010
namespace Twee;

theme/includes/theme/acfe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @author Andrii Toniievych <toniyevych@gmail.com>
1212
* @package Twee
13-
* @version 4.1
13+
* @version 4.2
1414
*/
1515

1616
/**

theme/includes/theme/block.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @author Andrii Toniievych <toniyevych@gmail.com>
66
* @package Twee
7-
* @version 4.1
7+
* @version 4.2
88
*/
99

1010
/**

0 commit comments

Comments
 (0)