Skip to content

Commit

Permalink
Massively improve functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevalk committed Apr 25, 2024
1 parent 15d1129 commit 7df41cb
Show file tree
Hide file tree
Showing 6 changed files with 291 additions and 48 deletions.
17 changes: 11 additions & 6 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
text-align: left;
}
.aaa_option_table .actions {
text-align: center;
text-align: right;
}
.aaa_option_table .actions .button {
margin-right: 20px;
width: 150px;
}
.aaa_option_table .actions .button-delete {
margin-right: 0;
color: #a00;
border-color: #a00;
}
.aaa_option_table .actions .button span.dashicons, .aaa_option_table .button.dashicon span.dashicons {
padding: 3px 0;
margin: 0;
padding: 0;
margin: 0 3px 0 0;
vertical-align: middle;
}
.aaa_option_table td span.num {
font-family: monospace;
Expand All @@ -43,16 +43,21 @@ div.dt-container .dt-input {
overflow: visible;
padding: 40px 40px 20px 20px;
position: fixed;
word-wrap: break-word;
max-width: 80%;
min-height: 200px;
max-height: 80%;
}
.aaa-option-optimizer-popover pre {
padding: 10px;
min-width: 300px;
max-width: 100%;
max-height: 60vh;
border: 1px solid #ccc;
background-color: #eee;
overflow: auto;
overflow: scroll;
text-align: left;
white-space: pre-wrap;
word-wrap: anywhere;
}
.aaa-option-optimizer-popover::backdrop {
background: rgba(0, 0, 0, 0.75);
Expand Down
160 changes: 155 additions & 5 deletions js/admin-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,124 @@
jQuery( document ).ready(
function ($) {
if ( $( '#unused_options_table' ).length ) {
var table1 = new DataTable( '#unused_options_table', { pageLength: 25, columns: [ null, null, { searchable: false}, { searchable: false, orderable: false} ] } );
var table1 = new DataTable(
'#unused_options_table',
{
pageLength: 25,
columns: [
{ name: 'name' },
{ name: 'source' },
{ searchable: false},
{ searchable: false, orderable: false}
],
initComplete: function () {
this.api()
.columns( 'source:name' )
.every(
function () {
let column = this;
console.log( this.name );

let select = document.createElement( 'select' );
select.placeholder = 'Filter by source';
filterOption = new Option( 'Filter by source', '',true,true );
filterOption.disabled = true;
select.add( filterOption );
column.footer().replaceChildren( select );

// Apply listener for user change in value.
select.addEventListener(
'change',
function () {
column
.search( select.value, {exact: true} )
.draw();
}
);

// Add list of options.
column
.data()
.unique()
.sort()
.each(
function (d, j) {
select.add( new Option( d ) );
}
);
}
);
}
}
);
}
if ( $( '#used_not_autloaded_table' ).length ) {
var table2 = new DataTable( '#used_not_autloaded_table', { pageLength: 25, columns: [ null, null, { searchable: false }, { searchable: false }, { searchable: false, orderable: false } ] } );
var table2 = new DataTable(
'#used_not_autloaded_table',
{
pageLength: 25,
columns: [
{ name: 'name' },
{ name: 'source' },
{ searchable: false },
{ searchable: false },
{ searchable: false, orderable: false }
],
initComplete: function () {
this.api()
.columns( 'source:name' )
.every(
function () {
let column = this;
console.log( this.name );

// Create select element.
let select = document.createElement( 'select' );
select.placeholder = 'Filter by source';
filterOption = new Option( 'Filter by source', '',true,true );
filterOption.disabled = true;
select.add( filterOption );
column.footer().replaceChildren( select );

// Apply listener for user change in value.
select.addEventListener(
'change',
function () {
column
.search( select.value, {exact: true} )
.draw();
}
);

// Add list of options.
column
.data()
.unique()
.sort()
.each(
function (d, j) {
select.add( new Option( d ) );
}
);
}
);
}
}
);
}
if ( $( '#requested_do_not_exist_table' ).length ) {
var table3 = new DataTable( '#requested_do_not_exist_table', { pageLength: 25, columns: [ null, null, { searchable: false }, { searchable: false, orderable: false } ] } );
var table3 = new DataTable(
'#requested_do_not_exist_table',
{
pageLength: 25,
columns: [
null,
null,
{ searchable: false },
{ searchable: false, orderable: false }
]
}
);
}

$( '#aaa_get_all_options' ).on(
Expand All @@ -33,7 +144,7 @@ jQuery( document ).ready(
rowId: 'row_id',
columns: [
{ data: 'name' },
{ data: 'plugin' },
{ name: 'source', data: 'plugin' },
{
data: 'size',
render: function (data, type, row, meta) {
Expand Down Expand Up @@ -65,7 +176,46 @@ jQuery( document ).ready(
orderable: false,
className: 'actions',
},
]
],
initComplete: function () {
this.api()
.columns( 'source:name' )
.every(
function () {
let column = this;
console.log( this.name );

// Create select element.
let select = document.createElement( 'select' );
select.placeholder = 'Filter by source';
filterOption = new Option( 'Filter by source', '',true,true );
filterOption.disabled = true;
select.add( filterOption );
column.footer().replaceChildren( select );

// Apply listener for user change in value.
select.addEventListener(
'change',
function () {
column
.search( select.value, {exact: true} )
.draw();
}
);

// Add list of options.
column
.data()
.unique()
.sort()
.each(
function (d, j) {
select.add( new Option( d ) );
}
);
}
);
}
}
);
$( this ).hide();
Expand Down
75 changes: 73 additions & 2 deletions known-plugins/known-plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,86 @@
},
"yoast": {
"name": "Yoast SEO",
"option_prefixes": ["wpseo_", "yoast_"]
"option_prefixes": ["wpseo", "yoast_"]
},
"woocommerce": {
"name": "WooCommerce",
"option_prefixes": ["wc_", "_transient__woocommerce_"]
},
"wordpress": {
"name": "WordPress",
"option_prefixes": ["_site_transient_update_core", "_site_transient_timeout_theme_roots", "_site_transient_timeout_available_translations"]
"option_prefixes": [
"admin_email",
"new_admin_email",
"adminhash",
"blogdescription",
"blogname",
"date_format",
"gmt_offset",
"home",
"siteurl",
"start_of_week",
"time_format",
"timezone_string",
"users_can_register",
"default_role",
"auto_update_core_major",
"auto_update_core_minor",
"auto_update_core_dev",
"upload_path",
"upload_url_path",
"uploads_use_yearmonth_folders",
"thumbnail_size_w",
"thumbnail_size_h",
"thumbnail_crop",
"medium_size_w",
"medium_size_h",
"large_size_w",
"large_size_h",
"medium_large_size_w",
"medium_large_size_h",
"embed_size_w",
"embed_size_h",
"default_pingback_flag",
"default_comment_status",
"default_ping_status",
"require_name_email",
"comment_registration",
"close_comments_for_old_posts",
"close_comments_days_old",
"show_comments_cookies_opt_in",
"thread_comments",
"thread_comments_depth",
"page_comments",
"comments_per_page",
"default_comments_page",
"comment_order",
"comments_notify",
"moderation_notify",
"comment_moderation",
"comment_whitelist",
"comment_max_links",
"moderation_keys",
"blacklist_keys",
"show_avatars",
"avatar_rating",
"avatar_default",
"permalink_structure",
"category_base",
"category_children",
"tag_base",
"default_category",
"default_post_format",
"use_smilies",
"use_balancetags",
"use_trackback",
"blog_public",
"blog_charset",
"_site_transient_update_core",
"_site_transient_timeout_theme_roots",
"_site_transient_timeout_available_translations"
]

},
"wpml": {
"name": "WPML",
Expand Down
Loading

0 comments on commit 7df41cb

Please sign in to comment.