Skip to content

Commit ab90430

Browse files
committed
first commit
0 parents  commit ab90430

File tree

5 files changed

+599
-0
lines changed

5 files changed

+599
-0
lines changed

.github/workflows/php.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: WordPress Plugin Build Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "releases/*"
8+
pull_request:
9+
branches: [main]
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Get latest code
16+
uses: actions/checkout@v4
17+
18+
- name: Run plugin check
19+
uses: WordPress/plugin-check-action@v1.0.5

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Packages and Dependencies
2+
/node_mudules
3+
/vendor
4+
5+
# SVN Files
6+
/svn
7+
8+
# Plugin Zip File
9+
thumbnail-remover.zip

assets/img/bmc-button.png

11.3 KB
Loading

assets/js/script.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
jQuery(document).ready(function ($) {
2+
var sectionTemplate = $("#api_sections .api-section").first().clone();
3+
var sectionCount = $("#api_sections .api-section").length;
4+
5+
// Add new section
6+
$("#add_section").on("click", function () {
7+
var newSection = sectionTemplate.clone();
8+
sectionCount++;
9+
10+
newSection.find("h4").text("Section " + sectionCount);
11+
newSection.find("select, input").each(function () {
12+
var name = $(this).attr("name");
13+
if (name) {
14+
$(this).attr(
15+
"name",
16+
name.replace("[0]", "[" + (sectionCount - 1) + "]")
17+
);
18+
}
19+
});
20+
21+
// Clear the section name field
22+
newSection.find('input[name$="[name]"]').val(sectionCount);
23+
24+
newSection.attr("data-index", sectionCount - 1);
25+
newSection.find(".remove-section").show();
26+
27+
$("#api_sections").append(newSection);
28+
resetRemoveButtons();
29+
});
30+
31+
// Remove section
32+
$("#api_sections").on("click", ".remove-section", function () {
33+
$(this).closest(".api-section").remove();
34+
resetSectionIndexes();
35+
resetRemoveButtons();
36+
});
37+
38+
// Reset section indexes
39+
function resetSectionIndexes() {
40+
$("#api_sections .api-section").each(function (index) {
41+
$(this)
42+
.find("h4")
43+
.text("Section " + (index + 1));
44+
$(this).attr("data-index", index);
45+
$(this)
46+
.find("select, input")
47+
.each(function () {
48+
var name = $(this).attr("name");
49+
if (name) {
50+
$(this).attr("name", name.replace(/\[\d+\]/, "[" + index + "]"));
51+
}
52+
});
53+
});
54+
sectionCount = $("#api_sections .api-section").length;
55+
}
56+
57+
// Reset remove buttons
58+
function resetRemoveButtons() {
59+
var sections = $("#api_sections .api-section");
60+
sections.find(".remove-section").show();
61+
if (sections.length === 1) {
62+
sections.first().find(".remove-section").hide();
63+
}
64+
}
65+
66+
// Handle access type switch
67+
$('input[name="custom_api_access_type"]').on("change", function () {
68+
if ($(this).val() === "private") {
69+
$("#custom_api_roles_row").show();
70+
} else {
71+
$("#custom_api_roles_row").hide();
72+
}
73+
});
74+
75+
// Initialize
76+
resetRemoveButtons();
77+
});

0 commit comments

Comments
 (0)