Skip to content

Commit 8bbf15c

Browse files
committed
Initial release. Plugin "Ultimate Member - Optimize".
1 parent e6a1006 commit 8bbf15c

File tree

10 files changed

+1112
-99
lines changed

10 files changed

+1112
-99
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Ultimate Member - Optimize
2+
3+
Optimize loading for sites with the Ultimate Member plugin.
4+
5+
## Key Features
6+
- Removes CSS and JS files that belongs to Ultimate Member and its extensions from pages where there are no Ultimate Member elements.
7+
- Combines CSS and JS files that belongs to Ultimate Member and its extensions on pages with Ultimate Member elements.
8+
- Minifies combined files.
9+
10+
## Installation
11+
12+
__Note:__ This plugin requires the [Ultimate Member](https://wordpress.org/plugins/ultimate-member/) plugin to be installed first.
13+
14+
### How to install from GitHub
15+
Open git bash, navigate to the **plugins** folder and execute this command:
16+
17+
`git clone --branch=main git@github.com:umdevelopera/um-optimize.git um-optimize`
18+
19+
Once the plugin is cloned, enter your site admin dashboard and go to _wp-admin > Plugins > Installed Plugins_. Find the "Ultimate Member - Optimize" plugin and click the "Activate" link.
20+
21+
### How to install from ZIP archive
22+
You can install this plugin from the [ZIP file](https://drive.google.com/file/d/1It6F176qYjLV3FaQ0b8pXrGdaOAfYJ6H/view) as any other plugin. Follow [this instruction](https://wordpress.org/support/article/managing-plugins/#upload-via-wordpress-admin).
23+
24+
## How to use
25+
Go to *wp-admin > Ultimate Member > Settings > General > Optimize* to manage settings:
26+
- Dequeue unused CSS files - Dequeue CSS files queued by the Ultimate Member plugin from pages where there are no Ultimate Member elements.
27+
- Dequeue unused JS files - Dequeue JS files queued by the Ultimate Member plugin from pages where there are no Ultimate Member elements.
28+
- Combine CSS files - Combine CSS files queued by the Ultimate Member plugin and its extensions.
29+
- Combine JS files - Combine JS files queued by the Ultimate Member plugin and its extensions.
30+
- Minify CSS files - *(optional)* Minify combined CSS files.
31+
- Minify JS files - *(optional)* Minify combined JS files.
32+
33+
__Note:__ Settings "Minify CSS files" and "Minify JS files" are hidden if original files are minified.
34+
35+
### Screenshots
36+
37+
## Support
38+
39+
This is a free extension created for the community. The Ultimate Member team does not provide any support for this extension. Open new [issue](https://github.com/umdevelopera/um-optimize/issues) if you face a problem.
40+
41+
## Related links
42+
Ultimate Member home page: https://ultimatemember.com
43+
44+
Ultimate Member documentation: https://docs.ultimatemember.com
45+
46+
Ultimate Member download: https://wordpress.org/plugins/ultimate-member
47+
48+
Article: [How to remove CSS and JS on non UM pages](https://docs.ultimatemember.com/article/1490-how-to-remove-css-and-js-on-non-um-pages)

includes/admin/class-admin.php

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
/**
3+
* Admin features.
4+
*
5+
* @package um_ext\um_optimize\admin
6+
*/
7+
8+
namespace um_ext\um_optimize\admin;
9+
10+
if ( ! defined( 'ABSPATH' ) ) {
11+
exit;
12+
}
13+
14+
if ( ! class_exists( 'um_ext\um_optimize\admin\Admin' ) ) {
15+
16+
/**
17+
* Class Admin.
18+
*
19+
* @package um_ext\um_optimize\admin
20+
*/
21+
class Admin {
22+
23+
24+
/**
25+
* Admin constructor.
26+
*/
27+
public function __construct() {
28+
add_filter( 'um_settings_structure', array( &$this, 'extend_settings' ) );
29+
}
30+
31+
32+
/**
33+
* Add fields to the page
34+
*
35+
* @param array $settings
36+
* @return array
37+
*/
38+
public function extend_settings( $settings ) {
39+
40+
$fields = array(
41+
array(
42+
'id' => 'um_optimize_assets_info',
43+
'type' => 'info_text',
44+
'label' => __( 'CSS and JS', 'um-optimize' ),
45+
'value' => __( 'Optimize CSS and JS files loading', 'um-optimize' ),
46+
),
47+
array(
48+
'id' => 'um_optimize_css_dequeue',
49+
'type' => 'checkbox',
50+
'label' => __( 'Dequeue unused CSS files', 'um-optimize' ),
51+
'tooltip' => __( 'Dequeue CSS files queued by the Ultimate Member plugin from pages where there are no Ultimate Member elements.', 'um-optimize' ),
52+
),
53+
array(
54+
'id' => 'um_optimize_js_dequeue',
55+
'type' => 'checkbox',
56+
'label' => __( 'Dequeue unused JS files', 'um-optimize' ),
57+
'tooltip' => __( 'Dequeue JS files queued by the Ultimate Member plugin from pages where there are no Ultimate Member elements.', 'um-optimize' ),
58+
),
59+
array(
60+
'id' => 'um_optimize_css_combine',
61+
'type' => 'checkbox',
62+
'label' => __( 'Combine CSS files', 'um-optimize' ),
63+
'tooltip' => __( 'Combine CSS files queued by the Ultimate Member plugin and its extensions.', 'um-optimize' ),
64+
),
65+
array(
66+
'id' => 'um_optimize_js_combine',
67+
'type' => 'checkbox',
68+
'label' => __( 'Combine JS files', 'um-optimize' ),
69+
'tooltip' => __( 'Combine JS files queued by the Ultimate Member plugin and its extensions.', 'um-optimize' ),
70+
),
71+
);
72+
73+
if ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) || ( defined( 'UM_SCRIPT_DEBUG' ) && UM_SCRIPT_DEBUG ) ) {
74+
$fields[] = array(
75+
'id' => 'um_optimize_css_minify',
76+
'type' => 'checkbox',
77+
'label' => __( 'Minify CSS files', 'um-optimize' ),
78+
'tooltip' => __( 'Minify combined CSS files.', 'um-optimize' ),
79+
'conditional' => array( 'um_optimize_css_combine', '=', '1' ),
80+
);
81+
$fields[] = array(
82+
'id' => 'um_optimize_js_minify',
83+
'type' => 'checkbox',
84+
'label' => __( 'Minify JS files', 'um-optimize' ),
85+
'tooltip' => __( 'Minify combined JS files.', 'um-optimize' ),
86+
'conditional' => array( 'um_optimize_js_combine', '=', '1' ),
87+
);
88+
}
89+
90+
$section = array(
91+
'title' => __( 'Optimize', 'um-optimize' ),
92+
'fields' => $fields,
93+
);
94+
95+
$settings['']['sections']['optimize'] = $section;
96+
97+
return $settings;
98+
}
99+
100+
}
101+
}

0 commit comments

Comments
 (0)