Skip to content

Commit b4e1e3b

Browse files
committed
Prepare version 1.2.0
- fixed the load_textdomain php notice.
1 parent 211bff2 commit b4e1e3b

12 files changed

+393
-240
lines changed

README.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ Optimize loading for sites with the Ultimate Member plugin.
44

55
## Key Features
66

7-
- Removes CSS and JS files that belongs to Ultimate Member and its extensions from pages where there are no Ultimate Member elements.
8-
- Combines CSS and JS files that belongs to Ultimate Member and its extensions on pages with Ultimate Member elements.
7+
- Removes CSS and JS files that belongs to Ultimate Member and its extensions on pages that do not have Ultimate Member components.
8+
- Combines CSS and JS files that belongs to Ultimate Member and its extensions on pages with Ultimate Member components.
9+
- Allows using Profile Photo and Cover Photo images from the browser cache.
910
- Optimizes SQL queries to get posts and users faster.
1011

1112
## Installation
@@ -22,25 +23,49 @@ Once the plugin is cloned, enter your site admin dashboard and go to _wp-admin >
2223

2324
### How to install from ZIP archive
2425

25-
You can install this plugin from the [ZIP file](https://drive.google.com/file/d/11oT04a0zRPo0wshpBs6Mm22URLVTJmZs/view) as any other plugin. Follow [this instruction](https://wordpress.org/support/article/managing-plugins/#upload-via-wordpress-admin).
26+
You can install this plugin from the [ZIP file](https://drive.google.com/file/d/1s4AI1BPF4eNSTbQSZPO4Tz2tS1NBmc4S/view) as any other plugin. Follow [this instruction](https://wordpress.org/support/article/managing-plugins/#upload-via-wordpress-admin).
2627

2728
## How to use
2829

29-
Go to *wp-admin > Ultimate Member > Settings > General > Optimize* to manage settings:
30+
Go to *wp-admin > Ultimate Member > Settings > General > Optimize* to manage settings.
3031

31-
- **Dequeue unused CSS files** - Dequeue CSS files queued by the Ultimate Member plugin from pages where there are no Ultimate Member elements.
32-
- **Dequeue unused JS files** - Dequeue JS files queued by the Ultimate Member plugin from pages where there are no Ultimate Member elements.
33-
- **Combine CSS files** - Combine CSS files queued by the Ultimate Member plugin and its extensions.
34-
- **Combine JS files** - Combine JS files queued by the Ultimate Member plugin and its extensions.
32+
![UM Settings, General, Optimize (v1 2 0)](https://github.com/user-attachments/assets/4eb8dae7-ae59-49c6-8f8a-b3f0111ef601)
3533

34+
### CSS and JS
35+
36+
Ultimate Member loads various styles and scripts that are necessary for its components to work. Extensions can also load their own styles and scripts. Loading many styles and scripts can slow down page rendering.
37+
It is recommended to disable loading of Ultimate Member styles and scripts on pages that do not have its components.
38+
39+
Loading one large style or script file has less impact on page rendering delay than loading multiple files.
40+
It is recommended to combine multiple Ultimate Member styles and scripts into one style file and one script file.
41+
42+
- **Dequeue unused styles** - Dequeue CSS files on pages that do not have Ultimate Member components.
43+
- **Dequeue unused scripts** - Dequeue JS files on pages that do not have Ultimate Member components.
44+
- **Combine styles** - Combine CSS files queued by the Ultimate Member plugin and its extensions.
45+
- **Combine scripts** - Combine JS files queued by the Ultimate Member plugin and its extensions.
46+
47+
### Images
48+
49+
Ultimate Member does not allow using Cover Photo and Profile Photo images from the browser cache. This approach is safe and secure, but it slows down rendering pages with Ultimate Member components and loading the member directory.
50+
It is recommended to allow using images from the browser cache if your site is public.
51+
52+
Ultimate Member uses the largest Cover Photo thumbnail in the member directory on the desktop. Such large images are usually not necessary.
53+
It is recommended to use an image that is 500px wide or slightly larger.
54+
55+
- **Profile Photo caching** - Allow using Profile Photo images from the browser cache.
56+
- **Cover Photo caching** - Allow using Cover Photo images from the browser cache.
57+
- **Cover Photo size in directory** - Select the size of the Cover Photo thumbnail for the member directory.
58+
59+
### SQL queries
60+
61+
Ultimate Member uses the standard WP_Query and WP_User_Query classes to build database queries. Queries built this way are reliable and stable, but not optimized. This slows down retrieving users in the user directory and posts in extensions that use custom post type, which slows down page rendering.
62+
It is recommended to enable SQL queries optimization to get posts and users faster.
63+
64+
- **Speed up member directories** - *(optional)* Optimize the SQL query that retrieves users for the member directory.
3665
- **Speed up Activity** - *(optional)* Optimize the SQL query that retrieves posts for the [Social Activity](https://ultimatemember.com/extensions/social-activity/) extension.
3766
- **Speed up Groups** - *(optional)* Optimize the SQL query that retrieves posts for the [Groups](https://ultimatemember.com/extensions/groups/) extension.
3867
- **Speed up Notes** - *(optional)* Optimize the SQL query that retrieves notes for the [User Notes](https://ultimatemember.com/extensions/user-notes/) extension.
3968
- **Speed up Photos** - *(optional)* Optimize the SQL query that retrieves albums for the [User Photos](https://ultimatemember.com/extensions/user-photos/) extension.
40-
- **Speed up member directories** - *(optional)* Optimize the SQL query that retrieves users for the member directory.
41-
42-
Image - Optimize settings.
43-
![UM Settings, General, Optimize ()](https://github.com/user-attachments/assets/cd9873a0-332d-48ab-ba4d-8f28fcba803e)
4469

4570
## Support
4671

includes/admin/class-admin.php

Lines changed: 124 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22
/**
33
* Admin features.
4-
*
5-
* @package um_ext\um_optimize\admin
64
*/
75

86
namespace um_ext\um_optimize\admin;
@@ -37,130 +35,159 @@ public function __construct() {
3735
*/
3836
public function extend_settings( $settings ) {
3937

40-
$fields = array();
41-
42-
// CSS and JS.
43-
$fields[] = array(
44-
'id' => 'um_optimize_assets_info',
45-
'type' => 'info_text',
46-
'label' => __( 'CSS and JS', 'um-optimize' ),
47-
'value' => __( 'Optimize CSS and JS files loading', 'um-optimize' ),
48-
);
49-
$fields[] = array(
50-
'id' => 'um_optimize_css_dequeue',
51-
'type' => 'checkbox',
52-
'label' => __( 'Dequeue unused CSS files', 'um-optimize' ),
53-
'tooltip' => __( 'Dequeue CSS files queued by the Ultimate Member plugin from pages where there are no Ultimate Member elements.', 'um-optimize' ),
54-
);
55-
$fields[] = array(
56-
'id' => 'um_optimize_js_dequeue',
57-
'type' => 'checkbox',
58-
'label' => __( 'Dequeue unused JS files', 'um-optimize' ),
59-
'tooltip' => __( 'Dequeue JS files queued by the Ultimate Member plugin from pages where there are no Ultimate Member elements.', 'um-optimize' ),
60-
);
61-
$fields[] = array(
62-
'id' => 'um_optimize_css_combine',
63-
'type' => 'checkbox',
64-
'label' => __( 'Combine CSS files', 'um-optimize' ),
65-
'tooltip' => __( 'Combine CSS files queued by the Ultimate Member plugin and its extensions.', 'um-optimize' ),
66-
);
67-
$fields[] = array(
68-
'id' => 'um_optimize_js_combine',
69-
'type' => 'checkbox',
70-
'label' => __( 'Combine JS files', 'um-optimize' ),
71-
'tooltip' => __( 'Combine JS files queued by the Ultimate Member plugin and its extensions.', 'um-optimize' ),
38+
$sections = array(
39+
$this->settings_section_assets(),
40+
$this->settings_section_images(),
41+
$this->settings_section_queries(),
7242
);
7343

74-
// Images.
75-
$fields[] = array(
76-
'id' => 'um_optimize_images_info',
77-
'type' => 'info_text',
78-
'label' => __( 'Images', 'um-optimize' ),
79-
'value' => __( 'Optimize images loading', 'um-optimize' ),
44+
$settings['']['sections']['optimize'] = array(
45+
'title' => __( 'Optimize', 'um-optimize' ),
46+
'form_sections' => $sections,
8047
);
81-
$fields[] = array(
82-
'id' => 'um_optimize_profile_photo',
83-
'type' => 'checkbox',
84-
'label' => __( 'Profile Photo caching', 'um-optimize' ),
85-
'description' => __( 'Ultimate Member does not allow caching Profile Photo in the browser. This is secure but slows your website. It is recommended to enable the Profile Photo caching if your website is public.', 'um-optimize' ),
48+
49+
return $settings;
50+
}
51+
52+
53+
/**
54+
* Section "CSS and JS".
55+
*
56+
* @return array
57+
*/
58+
public function settings_section_assets() {
59+
60+
$fields = array(
61+
array(
62+
'id' => 'um_optimize_css_dequeue',
63+
'type' => 'checkbox',
64+
'label' => __( 'Dequeue unused styles', 'um-optimize' ),
65+
'description' => __( 'Dequeue CSS files on pages that do not have Ultimate Member components.', 'um-optimize' ),
66+
),
67+
array(
68+
'id' => 'um_optimize_js_dequeue',
69+
'type' => 'checkbox',
70+
'label' => __( 'Dequeue unused scripts', 'um-optimize' ),
71+
'description' => __( 'Dequeue JS files on pages that do not have Ultimate Member components.', 'um-optimize' ),
72+
),
73+
array(
74+
'id' => 'um_optimize_css_combine',
75+
'type' => 'checkbox',
76+
'label' => __( 'Combine styles', 'um-optimize' ),
77+
'description' => __( 'Combine CSS files queued by the Ultimate Member plugin and its extensions.', 'um-optimize' ),
78+
),
79+
array(
80+
'id' => 'um_optimize_js_combine',
81+
'type' => 'checkbox',
82+
'label' => __( 'Combine scripts', 'um-optimize' ),
83+
'description' => __( 'Combine JS files queued by the Ultimate Member plugin and its extensions.', 'um-optimize' ),
84+
),
8685
);
87-
$fields[] = array(
88-
'id' => 'um_optimize_cover_photo',
89-
'type' => 'checkbox',
90-
'label' => __( 'Cover Photo caching', 'um-optimize' ),
91-
'description' => __( 'Ultimate Member does not allow caching Cover Photo in the browser. This is secure but slows your website. It is recommended to enable the Cover Photo caching if your website is public.', 'um-optimize' ),
86+
87+
return array(
88+
'title' => __( 'CSS and JS', 'um-optimize' ),
89+
'description' => __( 'Ultimate Member loads various styles and scripts that are necessary for its components to work. Extensions can also load their own styles and scripts. Loading many styles and scripts can slow down page rendering. It is recommended to disable loading of Ultimate Member styles and scripts on pages that do not have its components. Loading one large style or script file has less impact on page rendering delay than loading multiple files. It is recommended to combine multiple Ultimate Member styles and scripts into one style file and one script file.', 'um-optimize' ),
90+
'fields' => $fields,
9291
);
92+
}
93+
9394

95+
/**
96+
* Section "Images".
97+
*
98+
* @return array
99+
*/
100+
public function settings_section_images(){
94101
$sizes = UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' );
95102
$sizes[''] = __( 'Default', 'um-optimize' );
96-
$fields[] = array(
97-
'id' => 'um_optimize_cover_photo_size',
98-
'type' => 'select',
99-
'size' => 'small',
100-
'label' => __( 'Cover Photo size in directory', 'um-optimize' ),
101-
'default' => UM()->options()->get( 'profile_coversize' ),
102-
'options' => $sizes,
103-
'description' => __( 'Ultimate Member uses the greatest cover photo thumbnail in the member directory on the desktop. So big images are unnecessary. It is enough to use the 500px width image. Here you can select the cover photo thumbnail for the member directory.', 'um-optimize' ),
104-
);
105103

104+
$fields = array(
105+
array(
106+
'id' => 'um_optimize_profile_photo',
107+
'type' => 'checkbox',
108+
'label' => __( 'Profile Photo caching', 'um-optimize' ),
109+
'description' => __( 'Allow using Profile Photo images from the browser cache.', 'um-optimize' ),
110+
),
111+
array(
112+
'id' => 'um_optimize_cover_photo',
113+
'type' => 'checkbox',
114+
'label' => __( 'Cover Photo caching', 'um-optimize' ),
115+
'description' => __( 'Allow using Cover Photo images from the browser cache.', 'um-optimize' ),
116+
),
117+
array(
118+
'id' => 'um_optimize_cover_photo_size',
119+
'type' => 'select',
120+
'size' => 'small',
121+
'label' => __( 'Cover Photo size in directory', 'um-optimize' ),
122+
'default' => UM()->options()->get( 'profile_coversize' ),
123+
'options' => $sizes,
124+
'description' => __( 'Select the size of the Cover Photo thumbnail for the member directory.', 'um-optimize' ),
125+
),
126+
);
106127

107-
// SQL queries.
108-
$fields[] = array(
109-
'id' => 'um_optimize_queries_info',
110-
'type' => 'info_text',
111-
'label' => __( 'SQL queries', 'um-optimize' ),
112-
'value' => __( 'Optimize SQL queries to get posts and users faster', 'um-optimize' ),
128+
return array(
129+
'title' => __( 'Images', 'um-optimize' ),
130+
'description' => __( 'Ultimate Member does not allow using Cover Photo and Profile Photo images from the browser cache. This approach is safe and secure, but it slows down rendering pages with Ultimate Member components and loading the member directory. It is recommended to allow using images from the browser cache if your site is public. Ultimate Member uses the largest Cover Photo thumbnail in the member directory on the desktop. Such large images are usually not necessary. It is recommended to use an image that is 500px wide or slightly larger.', 'um-optimize' ),
131+
'fields' => $fields,
113132
);
133+
}
134+
135+
136+
/**
137+
* Section "SQL queries".
138+
*
139+
* @return array
140+
*/
141+
public function settings_section_queries(){
142+
143+
$fields = array();
144+
145+
if ( UM()->options()->get( 'members_page' ) ) {
146+
$fields[] = array(
147+
'id' => 'um_optimize_members',
148+
'type' => 'checkbox',
149+
'label' => __( 'Speed up member directories', 'um-optimize' ),
150+
'description' => __( 'Optimize the SQL query that retrieves users for the member directory.', 'um-optimize' ),
151+
);
152+
}
114153
if ( defined( 'um_activity_version' ) ) {
115154
$fields[] = array(
116-
'id' => 'um_optimize_activity',
117-
'type' => 'checkbox',
118-
'label' => __( 'Speed up Activity', 'um-optimize' ),
119-
'tooltip' => __( 'Optimize the SQL query that retrieves posts for the Social Activity extension.', 'um-optimize' ),
155+
'id' => 'um_optimize_activity',
156+
'type' => 'checkbox',
157+
'label' => __( 'Speed up Activity', 'um-optimize' ),
158+
'description' => __( 'Optimize the SQL query that retrieves posts for the Social Activity extension.', 'um-optimize' ),
120159
);
121160
}
122161
if ( defined( 'um_groups_version' ) ) {
123162
$fields[] = array(
124-
'id' => 'um_optimize_groups',
125-
'type' => 'checkbox',
126-
'label' => __( 'Speed up Groups', 'um-optimize' ),
127-
'tooltip' => __( 'Optimize the SQL query that retrieves posts for the Groups extension.', 'um-optimize' ),
163+
'id' => 'um_optimize_groups',
164+
'type' => 'checkbox',
165+
'label' => __( 'Speed up Groups', 'um-optimize' ),
166+
'description' => __( 'Optimize the SQL query that retrieves posts for the Groups extension.', 'um-optimize' ),
128167
);
129168
}
130169
if ( defined( 'um_user_notes_version' ) ) {
131170
$fields[] = array(
132-
'id' => 'um_optimize_notes',
133-
'type' => 'checkbox',
134-
'label' => __( 'Speed up Notes', 'um-optimize' ),
135-
'tooltip' => __( 'Optimize the SQL query that retrieves notes for the User Notes extension.', 'um-optimize' ),
171+
'id' => 'um_optimize_notes',
172+
'type' => 'checkbox',
173+
'label' => __( 'Speed up Notes', 'um-optimize' ),
174+
'description' => __( 'Optimize the SQL query that retrieves notes for the User Notes extension.', 'um-optimize' ),
136175
);
137176
}
138177
if ( defined( 'um_user_photos_version' ) ) {
139178
$fields[] = array(
140-
'id' => 'um_optimize_photos',
141-
'type' => 'checkbox',
142-
'label' => __( 'Speed up Photos', 'um-optimize' ),
143-
'tooltip' => __( 'Optimize the SQL query that retrieves albums for the User Photos extension.', 'um-optimize' ),
144-
);
145-
}
146-
if ( UM()->options()->get( 'members_page' ) ) {
147-
$fields[] = array(
148-
'id' => 'um_optimize_members',
149-
'type' => 'checkbox',
150-
'label' => __( 'Speed up member directories', 'um-optimize' ),
151-
'tooltip' => __( 'Optimize the SQL query that retrieves users for the member directory.', 'um-optimize' ),
179+
'id' => 'um_optimize_photos',
180+
'type' => 'checkbox',
181+
'label' => __( 'Speed up Photos', 'um-optimize' ),
182+
'description' => __( 'Optimize the SQL query that retrieves albums for the User Photos extension.', 'um-optimize' ),
152183
);
153184
}
154185

155-
$section = array(
156-
'title' => __( 'Optimize', 'um-optimize' ),
157-
'fields' => $fields,
186+
return empty( $fields ) ? null : array(
187+
'title' => __( 'SQL queries', 'um-optimize' ),
188+
'description' => __( 'Ultimate Member uses the standard WP_Query and WP_User_Query classes to build database queries. Queries built this way are reliable and stable, but not optimized. This slows down retrieving users in the user directory and posts in extensions that use custom post type, which slows down page rendering. It is recommended to enable SQL queries optimization to get posts and users faster.', 'um-optimize' ),
189+
'fields' => $fields,
158190
);
159-
160-
$settings['']['sections']['optimize'] = $section;
161-
162-
return $settings;
163191
}
164-
165192
}
166193
}

includes/core/class-assets.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22
/**
33
* Optimize assets.
4-
*
5-
* @package um_ext\um_optimize\core
64
*/
75

86
namespace um_ext\um_optimize\core;
@@ -19,6 +17,8 @@
1917
* How to get an instance:
2018
* UM()->classes['um_optimize_assets']
2119
* UM()->Optimize()->assets()
20+
*
21+
* @package um_ext\um_optimize\core
2222
*/
2323
class Assets {
2424

includes/core/class-images.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22
/**
33
* Optimize images.
4-
*
5-
* @package um_ext\um_optimize\core
64
*/
75

86
namespace um_ext\um_optimize\core;
@@ -13,13 +11,14 @@
1311

1412
if ( ! class_exists( 'um_ext\um_optimize\core\Images' ) ) {
1513

16-
1714
/**
1815
* Class Images
1916
*
2017
* How to get an instance:
2118
* UM()->classes['um_optimize_images']
2219
* UM()->Optimize()->images()
20+
*
21+
* @package um_ext\um_optimize\core
2322
*/
2423
class Images {
2524

@@ -40,7 +39,7 @@ public function __construct() {
4039
}
4140

4241
$cover_photo_size = UM()->options()->get( 'um_optimize_cover_photo_size' );
43-
if ( $cover_photo_size && ! UM()->mobile()->isTablet() ) {
42+
if ( $cover_photo_size ) {
4443
add_action( 'um_members_after_user_name', array( $this, 'cover_photo_size' ), 10, 2 );
4544
}
4645
}
@@ -126,7 +125,9 @@ public function cover_photo_uri( $cover_uri, $is_default, $attrs ) {
126125
* @param array $directory_data Directory settings.
127126
*/
128127
public function cover_photo_size( $user_id, $directory_data ) {
129-
UM()->member_directory()->cover_size = UM()->options()->get( 'um_optimize_cover_photo_size' );
128+
if ( ! UM()->mobile()->isTablet() ) {
129+
UM()->member_directory()->cover_size = UM()->options()->get( 'um_optimize_cover_photo_size' );
130+
}
130131
}
131132

132133
}

0 commit comments

Comments
 (0)