Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdiraized committed Sep 7, 2024
0 parents commit ab90430
Show file tree
Hide file tree
Showing 5 changed files with 599 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: WordPress Plugin Build Test

on:
push:
branches:
- main
- "releases/*"
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Get latest code
uses: actions/checkout@v4

- name: Run plugin check
uses: WordPress/plugin-check-action@v1.0.5
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Packages and Dependencies
/node_mudules
/vendor

# SVN Files
/svn

# Plugin Zip File
thumbnail-remover.zip
Binary file added assets/img/bmc-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
jQuery(document).ready(function ($) {
var sectionTemplate = $("#api_sections .api-section").first().clone();
var sectionCount = $("#api_sections .api-section").length;

// Add new section
$("#add_section").on("click", function () {
var newSection = sectionTemplate.clone();
sectionCount++;

newSection.find("h4").text("Section " + sectionCount);
newSection.find("select, input").each(function () {
var name = $(this).attr("name");
if (name) {
$(this).attr(
"name",
name.replace("[0]", "[" + (sectionCount - 1) + "]")
);
}
});

// Clear the section name field
newSection.find('input[name$="[name]"]').val(sectionCount);

newSection.attr("data-index", sectionCount - 1);
newSection.find(".remove-section").show();

$("#api_sections").append(newSection);
resetRemoveButtons();
});

// Remove section
$("#api_sections").on("click", ".remove-section", function () {
$(this).closest(".api-section").remove();
resetSectionIndexes();
resetRemoveButtons();
});

// Reset section indexes
function resetSectionIndexes() {
$("#api_sections .api-section").each(function (index) {
$(this)
.find("h4")
.text("Section " + (index + 1));
$(this).attr("data-index", index);
$(this)
.find("select, input")
.each(function () {
var name = $(this).attr("name");
if (name) {
$(this).attr("name", name.replace(/\[\d+\]/, "[" + index + "]"));
}
});
});
sectionCount = $("#api_sections .api-section").length;
}

// Reset remove buttons
function resetRemoveButtons() {
var sections = $("#api_sections .api-section");
sections.find(".remove-section").show();
if (sections.length === 1) {
sections.first().find(".remove-section").hide();
}
}

// Handle access type switch
$('input[name="custom_api_access_type"]').on("change", function () {
if ($(this).val() === "private") {
$("#custom_api_roles_row").show();
} else {
$("#custom_api_roles_row").hide();
}
});

// Initialize
resetRemoveButtons();
});
Loading

0 comments on commit ab90430

Please sign in to comment.