first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
.acf-photo-gallery-metabox-list li {
display: inline-table;
padding: 3px;
border: 1px solid #ccc;
margin: 8px;
position: relative;
vertical-align: top;
width: 202px;
height: 202px;
}
.acf-photo-gallery-metabox-list li img {
width: 100%;
}
.acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder {
width: 150px;
height: 150px;
border: 1px dashed #ccc;
}
.acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder .dashicons-format-image {
font-size: 150px;
color: #ccc;
}
.acf-photo-gallery-metabox-list li .dashicons-dismiss {
position: absolute;
top: -9px;
right: -9px;
color: #fff;
background: #000000;
border-radius: 50%;
}
.acf-photo-gallery-metabox-list li .dashicons-edit {
position: absolute;
top: -9px;
right: 12px;
color: #fff;
background: #000000;
border-radius: 50%;
}
#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery {
display: none;
background: #F3F3F3;
border: 2px solid #ccc;
width: 380px;
position: fixed;
top: 10%;
right: 0;
z-index: 9999;
padding: 15px;
left: 43%;
}
#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery h3{
background: #f1f1f1;
padding: 12px 15px;
margin-top: -17px;
margin-left: -17px;
width: 101%;
border-bottom: 1px solid #ccc;
}
#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery .save-changes-wrap {
margin-top: 15px;
}
#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery label {
margin-top: 10px;
display: block;
}
#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery textarea {
min-height: 100px;
width: 100%;
}
.acf-photo-gallery-metabox-list li.acf-photo-gallery-sortable-placeholder {
border: 1px dashed #ccc;
width: 150px;
height: 150px;
display: inline-block;
}
.acf-gallery-backdrop{
background: #000000;
opacity: 0.5;
position: fixed;
z-index: 9999;
width: 100%;
height: 100%;
top: 0%;
bottom: 0%;
left: 0%;
right: 0%;
}

View File

@@ -0,0 +1,122 @@
.modal-open {
overflow: hidden;
}
.modal {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1050;
display: none;
overflow: hidden;
-webkit-overflow-scrolling: touch;
outline: 0;
}
.modal.fade .modal-dialog {
-webkit-transform: translate(0, -25%);
-ms-transform: translate(0, -25%);
-o-transform: translate(0, -25%);
transform: translate(0, -25%);
-webkit-transition: -webkit-transform 0.3s ease-out;
-o-transition: -o-transform 0.3s ease-out;
transition: transform 0.3s ease-out;
}
.modal.in .modal-dialog {
-webkit-transform: translate(0, 0);
-ms-transform: translate(0, 0);
-o-transform: translate(0, 0);
transform: translate(0, 0);
}
.modal-open .modal {
overflow-x: hidden;
overflow-y: auto;
}
.modal-dialog {
position: relative;
width: auto;
margin: 10px;
}
.modal-content {
position: relative;
background-color: #ffffff;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border: 1px solid #999999;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
outline: 0;
}
.modal-backdrop {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1040;
background-color: #000000;
}
.modal-backdrop.fade {
filter: alpha(opacity=0);
opacity: 0;
}
.modal-backdrop.in {
filter: alpha(opacity=50);
opacity: 0.5;
}
.modal-header {
padding: 15px;
border-bottom: 1px solid #e5e5e5;
}
.modal-header .close {
margin-top: -2px;
}
.modal-title {
margin: 0;
line-height: 1.42857143;
}
.modal-body {
position: relative;
padding: 15px;
}
.modal-footer {
padding: 15px;
text-align: right;
border-top: 1px solid #e5e5e5;
}
.modal-footer .btn + .btn {
margin-bottom: 0;
margin-left: 5px;
}
.modal-footer .btn-group .btn + .btn {
margin-left: -1px;
}
.modal-footer .btn-block + .btn-block {
margin-left: 0;
}
.modal-scrollbar-measure {
position: absolute;
top: -9999px;
width: 50px;
height: 50px;
overflow: scroll;
}
@media (min-width: 768px) {
.modal-dialog {
width: 600px;
margin: 30px auto;
}
.modal-content {
-webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}
.modal-sm {
width: 300px;
}
}
@media (min-width: 992px) {
.modal-lg {
width: 900px;
}
}

View File

@@ -0,0 +1,75 @@
.acf-photo-gallery-metabox-list li {
display: inline-table;
padding: 3px;
border: 1px solid #ccc;
margin: 8px;
position: relative;
vertical-align: top;
width: 202px;
height: 202px;
}
.acf-photo-gallery-metabox-list li img {
width: 100%;
}
.acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder {
width: 150px;
height: 150px;
border: 1px dashed #ccc;
}
.acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder .dashicons-format-image {
font-size: 150px;
color: #ccc;
}
.acf-photo-gallery-metabox-list li .dashicons-dismiss {
position: absolute;
top: -9px;
right: -9px;
color: #fff;
background: #000000;
border-radius: 50%;
}
.acf-photo-gallery-metabox-list li .dashicons-edit {
position: absolute;
top: -9px;
right: 12px;
color: #fff;
background: #000000;
border-radius: 50%;
}
#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery {
display: none;
background: #F3F3F3;
border: 2px solid #ccc;
width: 308px;
position: absolute;
top: 0px;
right: 0;
z-index: 9999;
padding: 15px;
}
#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery .save-changes-wrap {
margin-top: 15px;
}
#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery label {
margin-top: 10px;
display: block;
}
#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery textarea {
min-height: 100px
}
.acf-photo-gallery-metabox-list li.acf-photo-gallery-sortable-placeholder {
border: 1px dashed #ccc;
width: 150px;
height: 150px;
display: inline-block;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,259 @@
(function($) {
function initialize_field($el) {
//$el.doStuff();
}
function acf_photo_gallery_remove_media(id, field) {
$('.acf-photo-gallery-group-' + field + ' .acf-photo-gallery-mediabox-' + id).fadeOut('fast').remove();
if ($('.acf-photo-gallery-group-' + field + ' .acf-photo-gallery-metabox-list li').length < 1) {
$('.acf-photo-gallery-group-' + field + ' .acf-photo-gallery-metabox-list').append('<li class="acf-photo-gallery-media-box-placeholder"><span class="dashicons dashicons-format-image"></span></li>');
}
}
$(document).ready(function() {
$(".acf-photo-gallery-metabox-list").sortable({
containment: "parent",
placeholder: "acf-photo-gallery-sortable-placeholder",
tolerance: 'pointer'
}).disableSelection();
});
function acf_photo_gallery_edit(id, url, title, caption) {
var html;
html = '<div id="acf-photo-gallery-metabox-edit-' + id + '" class="acf-edit-photo-gallery">';
html += '<h3>Edit Image</h3>';
html += '<label>URL</label><input type="text" value="' + url + '"/>';
html += '<label><input type="checkbox" value="1"/>Open in new tab</label>';
html += '<label>Title</label><input type="text" value="' + title + '"/>';
html += '<label>Caption</label><textarea>' + caption + '</textarea>';
html += '<button class="button button-primary button-large" type="button">Save Changes</button>';
html += '<button class="button button-large button-close" type="button" data-close="' + id + '">Close</button>';
html += '</div>';
return html;
}
/**
* @param {{ index: number, splice: number }} options
*/
function acf_photo_gallery_html(attachment, field, options) {
var edit_box_html, presentation_html, id, url, title, caption;
id = attachment.id;
url = attachment.url;
title = attachment.title;
caption = attachment.caption;
var JsonField = jQuery.parseJSON(field);
if (typeof attachment.sizes.thumbnail != 'undefined') { url = attachment.sizes.thumbnail.url; }
edit_box_html = acf_photo_gallery_edit(id, url, title, caption);
$('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-edit').append(edit_box_html);
var $list = $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list');
presentation_html = '<li class="acf-photo-gallery-mediabox acf-photo-gallery-mediabox-' + id + '" data-id="' + id + '"><a class="dashicons dashicons-dismiss" href="#" data-id="' + id + '" data-field="' + JsonField.key + '" title="Remove this photo from the gallery"></a><input type="hidden" name="' + JsonField._name + '[]" value="' + id + '"/><img src="' + url + '"/></li>';
if (options.index) {
var $cursor = $list.children().eq(options.index);
$cursor.before(presentation_html);
if (options.splice) { $cursor.remove(); }
} else {
$list.prepend(presentation_html);
}
}
function acf_photo_gallery_add_media($el) {
var acf_photo_gallery_ids = new Array();
if ($('.acf-photo-gallery-metabox-add-images').length > 0) {
if (typeof wp !== 'undefined' && wp.media && wp.media.editor) {
$(document).on('click', '.acf-photo-gallery-metabox-add-images', function(e) {
e.preventDefault();
var button = $(this);
var id = button.prev();
var field = button.attr('data-field');
var JsonField = jQuery.parseJSON(field);
//On click of the add images button, check if the image limit has been reached
var pre_selected_list = $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-mediabox');
var images_limit = $('.acf-photo-gallery-group-' + JsonField.key + ' input[name=\'acf-photo-gallery-images_limit\']').val();
if (images_limit != "" && pre_selected_list.length == images_limit) {
swal('Limit has been reached', 'Your website administrator has set a limit of ' + images_limit + ' images that can be added to this gallery.', 'error')
return false;
}
$(document).on('click', '.media-modal-content .attachments-browser .attachments li', function() {
var selection_list = $('.media-modal-content .attachments-browser .attachments li[aria-checked=true]').length;
var check_image_limit = pre_selected_list.length + selection_list;
console.log(images_limit);
if (images_limit != "" && check_image_limit > images_limit) {
$(this).click();
swal('Limit has been reached', 'Your website administrator has set a limit of ' + images_limit + ' images that can be added to this gallery.', 'error')
return false;
}
});
wp.media.editor.send.attachment = function(props, attachment) {
acf_photo_gallery_html(attachment, field, { index: 0, splice: 0 });
};
wp.media.editor.open(button, function() {});
if ($('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').length > 0) {
$('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').remove();
}
return false;
});
}
};
}
$(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-dismiss', function() {
var id = $(this).attr('data-id');
var field = $(this).attr('data-field');
if (confirm('You are about to remove this photo from the gallery. Are you sure?')) {
acf_photo_gallery_remove_media(id, field);
}
return false;
});
$(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-close', function() {
var id;
id = $(this).attr('data-close');
$('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + id).fadeOut('fast');
$('.acf-gallery-backdrop').remove();
$('body').css('overflow', 'auto');
return false;
});
$(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-primary', function() {
var button, field, data, post, attachment, action, nonce, fieldname, form = {};
button = $(this);
url = $(this).attr('data-ajaxurl');
action = 'acf_photo_gallery_edit_save';
attachment = $(this).attr('data-id');
fieldname = button.attr('data-fieldname');
$('div.acf-photo-gallery-group-' + fieldname + ' #acf-photo-gallery-metabox-edit-' + attachment + ' .acf-photo-gallery-edit-field').each(function(i, obj) {
if (obj.name == 'acf-pg-hidden-action') {
form['action'] = obj.value;
} else if (obj.type == 'checkbox') {
if ($(this).prop("checked")) {
form[obj.name] = obj.value;
} else {
form[obj.name] = null;
}
} else {
form[obj.name] = obj.value;
}
});
button.attr('disabled', true).html('Saving...');
$.post(url, form, function(data) {
button.attr('disabled', false).html('Save Changes');
$('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + attachment).fadeOut('fast');
$('.acf-gallery-backdrop').remove();
$('body').css('overflow', 'auto');
});
return false;
});
$(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-edit', function() {
var $btn = $(this);
var id = $btn.attr('data-id');
var field = $btn.attr('data-field');
var modal = $('.acf-photo-gallery-group-' + field + ' input[name="acf-photo-gallery-edit-modal"]').val();
var $list = $('.acf-photo-gallery-group-' + field + ' ul.acf-photo-gallery-metabox-list');
var index = $('.acf-photo-gallery-group-' + field + ' ul.acf-photo-gallery-metabox-list li').index();
$('body').prepend('<div class=\'acf-gallery-backdrop\'></div>');
$('body').css('overflow', 'hidden');
if (modal === 'Native') {
wp.media.editor.send.attachment = function(_, attachment) {
acf_photo_gallery_html(attachment, field, {
index: index,
splice: 1
});
};
var editor = wp.media.editor.open($btn, function() {}).state();
editor.set('menu', false);
var selection = editor.get('selection');
selection.multiple = false;
selection.reset([wp.media.attachment(id)]);
/**
* @param {{ id: number }} deleted
*/
var handleDestroy = function(deleted) {
$list.children().each(function() {
var $elem = $(this);
if ($elem.data('id') === deleted.id) {
remove($elem.find('.dashicons-dismiss'));
}
});
};
var library = editor.get('library');
library.on('destroy', handleDestroy);
editor.on('close', function() {
library.off('destroy', handleDestroy);
});
$('.acf-photo-gallery-group-' + field + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').remove();
} else {
$('.acf-photo-gallery-group-' + field + ' #acf-photo-gallery-metabox-edit-' + id).fadeToggle('fast');
}
return false;
});
if (typeof acf.add_action !== 'undefined') {
/*
* ready append (ACF5)
*
* These are 2 events which are fired during the page load
* ready = on page load similar to $(document).ready()
* append = on new DOM elements appended via repeater field
*
* @type event
* @date 20/07/13
*
* @param $el (jQuery selection) the jQuery element which contains the ACF fields
* @return n/a
*/
acf.add_action('ready append', function($el) {
// search $el for fields of type 'photo_gallery'
acf.get_fields({ type: 'photo_gallery' }, $el).each(function() {
initialize_field($(this));
acf_photo_gallery_add_media($(this));
});
});
} else {
/*
* acf/setup_fields (ACF4)
*
* This event is triggered when ACF adds any new elements to the DOM.
*
* @type function
* @since 1.0.0
* @date 01/01/12
*
* @param event e: an event object. This can be ignored
* @param Element postbox: An element which contains the new HTML
*
* @return n/a
*/
$(document).on('acf/setup_fields', function(e, postbox) {
$(postbox).find('.field[data-field_type="photo_gallery"]').each(function() {
initialize_field($(this));
acf_photo_gallery_add_media($(this));
//acf_photo_gallery_edit_popover( $(this) );
//acf_photo_gallery_limit_images( $(this) );
});
});
}
})(jQuery);

File diff suppressed because one or more lines are too long