Skip to content
This repository has been archived by the owner on Oct 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7 from RostiMelk/development
Browse files Browse the repository at this point in the history
Version 2.5.0
  • Loading branch information
RostiMelk authored Apr 13, 2020
2 parents d87b9ce + 158d602 commit d96ee78
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.DS_Store
dist/
*.zip
.idea
50 changes: 43 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
![ACF Tools - Advanced Custom Fields code made simple](https://user-images.githubusercontent.com/25268506/79060144-bd7e0700-7c81-11ea-958f-4de9aff2bc01.jpg)

This is a Google Chrome extension/Firefox add-on for Advanced Custom Fields to help with speeding up development. πŸ”₯

[![License](http://img.shields.io/:license-mit-semigreen.svg)](https://opensource.org/licenses/MIT)
[![Google Web Store version](https://img.shields.io/chrome-web-store/v/ogliegjmpalokmaaeckcdgbhdeedcnmf)](https://chrome.google.com/webstore/detail/acf-tools/ogliegjmpalokmaaeckcdgbhdeedcnmf)
[![Mozilla Firefox add-on libary version](https://img.shields.io/amo/v/ACF-Tools?color=orange)](https://addons.mozilla.org/en-US/firefox/addon/acf-tools/)

This is a Google Chrome extension/Firefox add-on for Advanced Custom Fields to help with speeding up development. πŸ”₯
## Table of content

- [What does it do?](#but-what-does-it-do)
- [Installation](#installation)
- [Chrome Web Store](#chrome-web-store)
- [Firefox browser add-ons](#firefox-browser-add-ons)
- [Contributing](#contributing)
- [Translation](#translation)
- [Development setup](#development-setup)
- [Google Chrome](#google-chrome)
- [Mozilla Firefox](#mozilla-firefox)
- [Contact Details](#contact-details)
- [License](#license)

---


### But what does it do?

Expand All @@ -26,22 +43,37 @@ You can [find the extension in the Firefox add-on libary](https://addons.mozilla

---

## Contributing

### Translation
I need your help with translations

1. Fork this repository.
2. Edit `messages.json` in `src/_locales/[localeCode]`. If it does not already exist, create a directory according to the [supported locales](https://developer.chrome.com/webstore/i18n?csw=1#localeTable).
3. Create a new pull request.

---

## Development setup

### Google Chrome

1. Clone repo
2. Go to chrome://extensions/
3. Drag and drop folder into this window
2. Go to `chrome://extensions/`
3. Drag and drop the `src` folder into this window
4. Write code
5. Refresh Chrome Extension to test and debug as you develop

### Mozilla Firefox

1. Clone repo
2. Go to about:debugging
3. Click "Load Temporary Add-on"
4. Refresh Firefox Add-on to test and debug as you develop
2. cd into `ACF-Tools` folder
3. Build Project with `$ sh build.sh`
4. Go to `about:debugging`
5. Click "This Firefox"
6. Click "Load Temporary Add-on"
7. Navigate into ACF-Tools/dist
8. Select `acf-tools-vX.X.X-firefox.zip` to test

---

Expand All @@ -51,4 +83,8 @@ Rostislav Melkumyan - @RostiMelk - [email protected] \
Project Link: https://github.com/RostiMelk/ACF-Tools \
Feeling generous? Donations are accepted on paypal: [email protected]

Distributed under the MIT license. See LICENSE for more information.
---

## License

Distributed under the MIT license. See `LICENSE` for more information.
30 changes: 30 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Colors
error='\033[0;31m'
warning='\033[0;33m'
success='\033[0;32m'
end='\033[0m'

if brew ls --versions jq > /dev/null; then
NAME="acf-tools"
VERSION=$(jq -r .version src/manifest.json)

mkdir -p dist
rm dist/*.zip

# for Chrome
zip -r "dist/${NAME}-v${VERSION}-chrome.zip" src -x "*.DS_Store"

# for Firefox
cd src
zip -r "../dist/${NAME}-v${VERSION}-firefox.zip" * -x "*.DS_Store"

echo ""
echo "${success}βœ… Finished build!${end}"
else
echo ""
echo "${error}❌ package jq not found.${end}"
echo "${warning}Try running: brew install jq${end}"
fi

35 changes: 35 additions & 0 deletions src/_locales/de/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"extDescription": {
"message": "Advanced Custom Fields Code einfach gemacht!"
},
"copyFieldName": {
"message": "Feldname in Zwischenablage kopieren"
},
"copiedFieldName": {
"message": "Feldname in Zwischenablage kopiert!"
},
"openDocsTitle": {
"message": "Γ–ffne die ACF Dokumentation fΓΌr dieses Feld"
},
"copyCodeBtn": {
"message": "Code kopieren"
},
"copyCodeBtnTitle": {
"message": "PHP Code fΓΌr dieses Feld kopieren"
},
"copyAllCodeBtn": {
"message": "Code mit Unterfeldern kopieren"
},
"copyAllCodeBtnTitle": {
"message": "PHP Code fΓΌr dieses Feld und Unterfelder kopieren"
},
"copiedCode": {
"message": "Code in Zwischenablage kopiert!"
},
"copiedCodeSub": {
"message": "Code mit Unterfeldern in Zwischenablage kopiert!"
},
"fieldError": {
"message": "Nicht unterstΓΌtztes Feld, reiche hier ein Issue ein: https://github.com/RostiMelk/ACF-Tools/issues"
}
}
35 changes: 35 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"extDescription": {
"message": "Advanced Custom Fields code made simple!"
},
"copyFieldName": {
"message": "Copy field name to clipboard"
},
"copiedFieldName": {
"message": "Copied field name to clipboard!"
},
"openDocsTitle": {
"message": "Open ACF documentation for this field"
},
"copyCodeBtn": {
"message": "Copy code"
},
"copyCodeBtnTitle": {
"message": "Copy PHP code for this field"
},
"copyAllCodeBtn": {
"message": "Copy code with sub fields"
},
"copyAllCodeBtnTitle": {
"message": "Copy PHP code for this field and inner fields"
},
"copiedCode": {
"message": "Copied code to clipboard!"
},
"copiedCodeSub": {
"message": "Copied code with sub fields to clipboard!"
},
"fieldError": {
"message": "Unsupported field, submit an issue on: https://github.com/RostiMelk/ACF-Tools/issues"
}
}
35 changes: 35 additions & 0 deletions src/_locales/no/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"extDescription": {
"message": "Advanced Custom Fields kode gjort enkelt!"
},
"copyFieldName": {
"message": "Kopier feltnavn til utklippstavlen"
},
"copiedFieldName": {
"message": "Kopierte feltnavn til utklippstavlen!"
},
"openDocsTitle": {
"message": "Γ…pne ACF dokumentasjonen for denne feltgruppen"
},
"copyCodeBtn": {
"message": "Kopier kode"
},
"copyCodeBtnTitle": {
"message": "Kopier PHP koden for dette feltet"
},
"copyAllCodeBtn": {
"message": "Kopier kode med underfelt"
},
"copyAllCodeBtnTitle": {
"message": "Kopier PHP koden for dette feltet med underfelt"
},
"copiedCode": {
"message": "Kopierte koden til utklippstavlen!"
},
"copiedCodeSub": {
"message": "Kopierte koden med underfelt til utklippstavlen!"
},
"fieldError": {
"message": "Dette feltet stΓΈttes. Send inn en issue her: https://github.com/RostiMelk/ACF-Tools/issues"
}
}
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
5 changes: 3 additions & 2 deletions manifest.json β†’ src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"manifest_version": 2,
"name": "ACF Tools",
"version": "2.4.2",
"description": "Advanced Custom Fields code made simple!",
"version": "2.5.0",
"description": "__MSG_extDescription__",
"default_locale": "en",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
Expand Down
21 changes: 14 additions & 7 deletions scripts/app.js β†’ src/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ $("body").on('click', function() {
function copyFieldName() {
$(".acf-tbody .li-field-name").each(function() {
if(!$(this).children('.copy-field-name').length) {
var str = $(this).text();
var str = $(this).text(),
title = chrome.i18n.getMessage('copyFieldName');
$(this).text('');
$(this).append('<a href="#" class="copy-field-name">'+str+'</a>');
$(this).append('<a href="#" class="copy-field-name" title="'+title+'">'+str+'</a>');
}
})
$("body").on("click", ".copy-field-name", function(e) {
e.preventDefault();
copyStringToClipboard(this);
copyMessage('Copied field name to clipboard!');
copyMessage(chrome.i18n.getMessage('copiedFieldName'));
});
}

Expand All @@ -35,20 +36,24 @@ function openDocs() {
$(".acf-tbody .li-field-type").each(function() {
if(!$(this).children('.open-field-docs').length) {
var str = $(this).text(),
title = chrome.i18n.getMessage('openDocsTitle'),
slug = $(this).closest('.acf-field-object').attr('data-type').replace("_", "-"),
url = "https://www.advancedcustomfields.com/resources/"+slug;
$(this).text('');
$(this).append('<a href="'+url+'" target="_blank" class="open-field-docs">'+str+'</a>');
$(this).append('<a href="'+url+'" target="_blank" title="'+title+'" class="open-field-docs">'+str+'</a>');
}
})
}

// Copy ACF meta field code feature:
function appendCopyCodeBtns() {
// Append copy field code button

function appendCopyCodeBtn() {
var btnStr = chrome.i18n.getMessage('copyCodeBtn'),
btnTitle = chrome.i18n.getMessage('copyCodeBtnTitle');
$('.acf-field-object:not([data-type="accordion"], [data-type="message"], [data-type="tab"]) .row-options')
.append('<a class="button button-primary button-small copy-field-code exclude-sub-fields" title="Copy PHP code for this field" href="#">Copy code</a>');
.append('<a class="button button-primary button-small copy-field-code exclude-sub-fields" title="'+btnTitle+'" href="#">'+btnStr+'</a>');
}
appendCopyCodeBtn();
// Append buttons to new fields
Expand All @@ -61,10 +66,12 @@ function appendCopyCodeBtns() {

// Append copy all fields code button
function appendCopyAllCodeBtn() {
var btnStr = chrome.i18n.getMessage('copyAllCodeBtn'),
btnTitle = chrome.i18n.getMessage('copyAllCodeBtnTitle');
$('.acf-field-object[data-type="repeater"], .acf-field-object[data-type="group"]')
.children(".handle")
.find(".row-options")
.append('<a class="button button-primary button-small copy-field-code include-sub-fields" title="Copy PHP code for this field and inner fields" href="#">Copy code with sub fields</a>');
.append('<a class="button button-primary button-small copy-field-code include-sub-fields" title="'+btnTitle+'" href="#">'+btnStr+'</a>');
}
appendCopyAllCodeBtn();

Expand Down Expand Up @@ -190,7 +197,7 @@ function appendFieldNameOnEdit() {
});
$('body').on('click', '.post-edit-field-name-info', function(e) {
e.preventDefault();
copyMessage('Copied field name to clipboard!');
copyMessage(chrome.i18n.getMessage('copiedFieldName'));
copyStringToClipboard($(this));
})
}
File renamed without changes.
10 changes: 5 additions & 5 deletions scripts/misc.js β†’ src/scripts/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ function copyCodeToClipboard(fieldCode, subFields) {
temp.remove();

if(subFields.length) {
copyMessage('Copied code with sub fields to clipboard!');
copyMessage(chrome.i18n.getMessage('copiedCodeSub'));
} else {
copyMessage('Copied code to clipboard!');
copyMessage(chrome.i18n.getMessage('copiedCode'));
}
}

function fieldError() {
alert("Unsupported field, submit an issue on: \nhttps://github.com/RostiMelk/ACF-Tools");
throw new Error("Unsupported field, submit an issue on: https://github.com/RostiMelk/ACF-Tools");
}
alert(chrome.i18n.getMessage('fieldError'));
throw new Error(chrome.i18n.getMessage('fieldError'));
}
File renamed without changes.

0 comments on commit d96ee78

Please sign in to comment.