ACF Photo Gallery Field - Version 1.8.0

Version Description

Download this release

Release Info

Developer navzme
Plugin Icon 128x128 ACF Photo Gallery Field
Version 1.8.0
Comparing to
See all releases

Code changes from version 1.7.9 to 1.8.0

assets/js/acf-photo-gallery-field.js CHANGED
@@ -37,7 +37,7 @@
37
  * @param {{ index: number, splice: number }} options
38
  */
39
  function acf_photo_gallery_html(attachment, field, options) {
40
- var html, id, url, title, caption;
41
  id = attachment.id;
42
  url = attachment.url;
43
  title = attachment.title;
@@ -46,16 +46,16 @@
46
  var JsonField = jQuery.parseJSON(field);
47
 
48
  if (typeof attachment.sizes.thumbnail != 'undefined') { url = attachment.sizes.thumbnail.url; }
49
- html = acf_photo_gallery_edit(id, url, title, caption);
50
- $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-edit').append(html);
51
  var $list = $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list');
52
- 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>';
53
  if (options.index) {
54
  var $cursor = $list.children().eq(options.index);
55
- $cursor.before(html);
56
  if (options.splice) { $cursor.remove(); }
57
  } else {
58
- $list.prepend(html);
59
  }
60
  }
61
 
@@ -75,7 +75,7 @@
75
  //On click of the add images button, check if the image limit has been reached
76
  var pre_selected_list = $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-mediabox');
77
  var images_limit = $('.acf-photo-gallery-group-' + JsonField.key + ' input[name=\'acf-photo-gallery-images_limit\']').val();
78
- console.log(images_limit);
79
  if (images_limit != "" && pre_selected_list.length == images_limit) {
80
  swal('Limit has been reached', 'Your website administrator has set a limit of ' + images_limit + ' images that can be added to this gallery.', 'error')
81
  return false;
37
  * @param {{ index: number, splice: number }} options
38
  */
39
  function acf_photo_gallery_html(attachment, field, options) {
40
+ var edit_box_html, presentation_html, id, url, title, caption;
41
  id = attachment.id;
42
  url = attachment.url;
43
  title = attachment.title;
46
  var JsonField = jQuery.parseJSON(field);
47
 
48
  if (typeof attachment.sizes.thumbnail != 'undefined') { url = attachment.sizes.thumbnail.url; }
49
+ edit_box_html = acf_photo_gallery_edit(id, url, title, caption);
50
+ $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-edit').append(edit_box_html);
51
  var $list = $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list');
52
+ 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>';
53
  if (options.index) {
54
  var $cursor = $list.children().eq(options.index);
55
+ $cursor.before(presentation_html);
56
  if (options.splice) { $cursor.remove(); }
57
  } else {
58
+ $list.prepend(presentation_html);
59
  }
60
  }
61
 
75
  //On click of the add images button, check if the image limit has been reached
76
  var pre_selected_list = $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-mediabox');
77
  var images_limit = $('.acf-photo-gallery-group-' + JsonField.key + ' input[name=\'acf-photo-gallery-images_limit\']').val();
78
+
79
  if (images_limit != "" && pre_selected_list.length == images_limit) {
80
  swal('Limit has been reached', 'Your website administrator has set a limit of ' + images_limit + ' images that can be added to this gallery.', 'error')
81
  return false;
assets/js/input.js DELETED
@@ -1,196 +0,0 @@
1
- (function($) {
2
-
3
- function initialize_field($el) {
4
- //$el.doStuff();
5
- }
6
-
7
- $(document).ready(function() {
8
- $(".acf-photo-gallery-metabox-list").sortable({
9
- containment: "parent",
10
- placeholder: "acf-photo-gallery-sortable-placeholder",
11
- tolerance: 'pointer'
12
- }).disableSelection();
13
- });
14
-
15
- /*function acf_photo_gallery_limit_images( $el ){
16
- var field = $el.context.id;
17
- $(document).on('click', '.attachments-browser ul.attachments li.attachment', function(){
18
- var max = $('#' + field + ' input[name="acf-photo-gallery-field-max"]').val();
19
- var selCount = $('#' + field + ' .acf-photo-gallery-metabox-list li').length;
20
- var count = $('.attachments-browser ul.attachments li.attachment[aria-checked=true]').length;
21
- var finalCount = selCount + +count;
22
- if( finalCount > max ){
23
- alert('You are only allowed to select maximum of ' + max + ' images.');
24
- $(this).attr('aria-checked', false).removeClass('selected details');
25
- return false;
26
- }
27
- });
28
- }*/
29
-
30
- function acf_photo_gallery_edit(id, url, title, caption) {
31
- var html;
32
- html = '<div id="acf-photo-gallery-metabox-edit-' + id + '" class="acf-edit-photo-gallery">';
33
- html += '<h3>Edit Image</h3>';
34
- html += '<label>URL</label><input type="text" value="' + url + '"/>';
35
- html += '<label><input type="checkbox" value="1"/>Open in new tab</label>';
36
- html += '<label>Title</label><input type="text" value="' + title + '"/>';
37
- html += '<label>Caption</label><textarea>' + caption + '</textarea>';
38
- html += '<button class="button button-primary button-large" type="button">Save Changes</button>';
39
- html += '<button class="button button-large button-close" type="button" data-close="' + id + '">Close</button>';
40
- html += '</div>';
41
- return html;
42
- }
43
-
44
- function acf_photo_gallery_html(attachment, field) {
45
- var html, id, url, title, caption;
46
- id = attachment.id;
47
- url = attachment.url;
48
- title = attachment.title;
49
- caption = attachment.caption;
50
-
51
- if (typeof attachment.sizes.thumbnail != 'undefined') {
52
- url = attachment.sizes.thumbnail.url
53
- }
54
-
55
- html = acf_photo_gallery_edit(id, url, title, caption);
56
- $('#acf-' + field + ' .acf-photo-gallery-metabox-edit').append(html);
57
- $('#acf-' + field + ' .acf-photo-gallery-metabox-list').prepend('<li class="acf-photo-gallery-mediabox" id="acf-photo-gallery-mediabox-' + id + '" data-id="' + id + '"><a class="dashicons dashicons-edit" href="#" title="Edit" data-id="' + id + '"></a><a class="dashicons dashicons-dismiss" href="#" data-id="' + id + '" data-field="' + field + '" title="Remove this photo from the gallery"></a><input type="hidden" name="' + field + '[]" value="' + id + '"/><img src="' + url + '"/></li>');
58
- }
59
-
60
- function acf_photo_gallery_add_media($el) {
61
- var acf_photo_gallery_ids = new Array();
62
- if ($('#acf-photo-gallery-metabox-add-images').length > 0) {
63
- if (typeof wp !== 'undefined' && wp.media && wp.media.editor) {
64
- $('.wrap').on('click', '#acf-photo-gallery-metabox-add-images', function(e) {
65
- e.preventDefault();
66
- var button = $(this);
67
- var id = button.prev();
68
- var field = button.attr('data-id');
69
-
70
- var pre_selected_list = $('#acf-' + field + ' .acf-photo-gallery-metabox-list li');
71
- var pre_selected = pre_selected_list.length;
72
-
73
- wp.media.editor.send.attachment = function(props, attachment){
74
- acf_photo_gallery_html(attachment, field);
75
- };
76
-
77
- wp.media.editor.open( button, function(){} );
78
- if ($('#acf-' + field + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').length > 0) {
79
- $('#acf-' + field + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').remove();
80
- }
81
-
82
- /*if( pre_selected > 0 ){
83
- pre_selected_list.each(function( key, item ){
84
- var pre_selected_id = $(this).attr('data-id');
85
- //$('.attachments-browser ul.attachments li[data-id=' + pre_selected_id + ']').attr('aria-checked', true).addClass('details selected');
86
- console.log( $('.attachments-browser ul.attachments li[data-id=269]').attr('class') );
87
- $('.attachments-browser ul.attachments li[data-id="' + pre_selected_id + '"]').attr('aria-checked', true);
88
- });
89
- }*/
90
-
91
- return false;
92
- });
93
- }
94
- };
95
- }
96
-
97
- $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-dismiss', function() {
98
- var url = $(this).attr('href');
99
- var id = $(this).attr('data-id');
100
- var field = $(this).attr('data-field');
101
- if (confirm('You are about to remove this photo from the gallery. Are you sure?')) {
102
- $.get(url, function(data) {
103
- $('#acf-' + field + ' #acf-photo-gallery-mediabox-' + id).fadeOut('fast').remove();
104
- if ($('#acf-' + field + ' .acf-photo-gallery-metabox-list li').length < 1) {
105
- $('#acf-' + field + ' .acf-photo-gallery-metabox-list').append('<li class="acf-photo-gallery-media-box-placeholder"><span class="dashicons dashicons-format-image"></span></li>');
106
- }
107
- });
108
- }
109
- return false;
110
- });
111
-
112
- $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-close', function() {
113
- var id;
114
- id = $(this).attr('data-close');
115
- $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + id).fadeOut('fast');
116
- return false;
117
- });
118
-
119
- $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-primary', function() {
120
- var button, field, data, post, attachment, action, nonce, form = {};
121
- action = 'acf_photo_gallery_edit_save';
122
- attachment = $(this).attr('data-id');
123
-
124
- $('#acf-photo-gallery-metabox-edit-' + attachment + ' .acf-photo-gallery-edit-field').each(function(i, obj) {
125
- if (obj.name == 'acf-pg-hidden-action') {
126
- form['action'] = obj.value;
127
- } else {
128
- form[obj.name] = obj.value;
129
- }
130
- });
131
-
132
- button = $(this);
133
- button.attr('disabled', true).html('Saving...');
134
- $.post(acf.ajaxurl, form, function(data) {
135
- button.attr('disabled', false).html('Save Changes');
136
- $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + attachment).fadeOut('fast');
137
- });
138
- return false;
139
- });
140
-
141
- $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-edit', function() {
142
- var id, field;
143
- id = $(this).attr('data-id');
144
- field = $(this).attr('data-field');
145
- $('#acf-' + field + ' #acf-photo-gallery-metabox-edit-' + id).fadeToggle('fast');
146
- return false;
147
- });
148
-
149
- if (typeof acf.add_action !== 'undefined') {
150
- /*
151
- * ready append (ACF5)
152
- *
153
- * These are 2 events which are fired during the page load
154
- * ready = on page load similar to $(document).ready()
155
- * append = on new DOM elements appended via repeater field
156
- *
157
- * @type event
158
- * @date 20/07/13
159
- *
160
- * @param $el (jQuery selection) the jQuery element which contains the ACF fields
161
- * @return n/a
162
- */
163
- acf.add_action('ready append', function($el) {
164
- // search $el for fields of type 'photo_gallery'
165
- acf.get_fields({ type: 'photo_gallery' }, $el).each(function() {
166
- initialize_field($(this));
167
- acf_photo_gallery_add_media( $(this) );
168
- //acf_photo_gallery_edit_popover( $(this) );
169
- //acf_photo_gallery_limit_images( $(this) );
170
- });
171
- });
172
- } else {
173
- /*
174
- * acf/setup_fields (ACF4)
175
- *
176
- * This event is triggered when ACF adds any new elements to the DOM.
177
- *
178
- * @type function
179
- * @since 1.0.0
180
- * @date 01/01/12
181
- *
182
- * @param event e: an event object. This can be ignored
183
- * @param Element postbox: An element which contains the new HTML
184
- *
185
- * @return n/a
186
- */
187
- $(document).on('acf/setup_fields', function(e, postbox) {
188
- $(postbox).find('.field[data-field_type="photo_gallery"]').each(function() {
189
- initialize_field($(this));
190
- acf_photo_gallery_add_media( $(this) );
191
- //acf_photo_gallery_edit_popover( $(this) );
192
- //acf_photo_gallery_limit_images( $(this) );
193
- });
194
- });
195
- }
196
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/acf_photo_gallery_save.php CHANGED
@@ -40,7 +40,6 @@ add_action( 'save_post', 'acf_photo_gallery_save' );
40
 
41
  add_action( 'profile_update', 'my_profile_update', 10, 2 );
42
  function my_profile_update( $user_id, $old_user_data ){
43
- $field = $_POST['acf-photo-gallery-field'];
44
  $group = $_POST['acf-photo-gallery-groups'];
45
  if( is_array($group) && count($group) > 0 ){
46
  foreach($group as $item){
40
 
41
  add_action( 'profile_update', 'my_profile_update', 10, 2 );
42
  function my_profile_update( $user_id, $old_user_data ){
 
43
  $group = $_POST['acf-photo-gallery-groups'];
44
  if( is_array($group) && count($group) > 0 ){
45
  foreach($group as $item){
includes/render_field.php CHANGED
@@ -20,7 +20,7 @@
20
  $value = $field['value'];
21
  $key = $field['key'];
22
  $edit_model = (!empty($field['edit_modal']))? esc_attr($field['edit_modal']):'Default';
23
- } else if( ACF_VERSION >= 5 and ACF_VERSION < 6 ){
24
  $fieldname = $field['_name'];
25
  $value = $field['value'];
26
  $key = $field['key'];
20
  $value = $field['value'];
21
  $key = $field['key'];
22
  $edit_model = (!empty($field['edit_modal']))? esc_attr($field['edit_modal']):'Default';
23
+ } else if( ACF_VERSION >= 5){
24
  $fieldname = $field['_name'];
25
  $value = $field['value'];
26
  $key = $field['key'];
navz-photo-gallery.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: ACF Photo Gallery Field
5
  Plugin URI: http://www.navz.me/
6
  Description: An extension for Advance Custom Fields which lets you add photo gallery functionality on your websites.
7
- Version: 1.7.9
8
  Author: Navneil Naicker
9
  Author URI: http://www.navz.me/
10
  License: GPLv2 or later
@@ -38,7 +38,7 @@ if( !class_exists('acf_plugin_photo_gallery') ) :
38
 
39
  function __construct() {
40
  $this->settings = array(
41
- 'version' => '1.7.9',
42
  'url' => plugin_dir_url( __FILE__ ),
43
  'path' => plugin_dir_path( __FILE__ )
44
  );
@@ -80,7 +80,6 @@ if( !class_exists('acf_plugin_photo_gallery') ) :
80
  */
81
 
82
  function include_field_types( $version = false ) {
83
-
84
  // support empty $version
85
  if( !$version ) $version = 4;
86
 
4
  Plugin Name: ACF Photo Gallery Field
5
  Plugin URI: http://www.navz.me/
6
  Description: An extension for Advance Custom Fields which lets you add photo gallery functionality on your websites.
7
+ Version: 1.8.0
8
  Author: Navneil Naicker
9
  Author URI: http://www.navz.me/
10
  License: GPLv2 or later
38
 
39
  function __construct() {
40
  $this->settings = array(
41
+ 'version' => '1.8.0',
42
  'url' => plugin_dir_url( __FILE__ ),
43
  'path' => plugin_dir_path( __FILE__ )
44
  );
80
  */
81
 
82
  function include_field_types( $version = false ) {
 
83
  // support empty $version
84
  if( !$version ) $version = 4;
85
 
readme.txt CHANGED
@@ -2,8 +2,9 @@
2
  Contributors: navzme
3
  Tags: acf, advanced, custom, fields, photo, gallery, album, fancybox, litebox, lightbox
4
  Requires at least: 4.7.0
5
- Tested up to: 5.8.1
6
- Stable tag: 1.7.9
 
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -116,6 +117,7 @@ When you receive the response, see the ACF item which contains ACF photo gallery
116
  This ACF field type is compatible with:
117
  * ACF 4
118
  * ACF 5
 
119
 
120
  = Issues =
121
  Just like any other WordPress plugin, this plugin can also cause issues with other themes and plugins. If you are facing issues making this plugin work on your WordPress site, please do ask for help in the support forum. This way we can help you out and prevent this issue from happening to someone else. If you want to talk to me directly, you can contact me via my website <http://www.navz.me/>
@@ -128,6 +130,9 @@ Just like any other WordPress plugin, this plugin can also cause issues with oth
128
  4. Please refer to the description for more info regarding the field type settings
129
 
130
  == Changelog ==
 
 
 
131
  =1.7.9=
132
  * [Bugfix] Elementor Pro gallery images preview
133
  * [Added] Support for user profile
2
  Contributors: navzme
3
  Tags: acf, advanced, custom, fields, photo, gallery, album, fancybox, litebox, lightbox
4
  Requires at least: 4.7.0
5
+ Tested up to: 6.1
6
+ Requires PHP: 5.6
7
+ Stable tag: 1.8.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
117
  This ACF field type is compatible with:
118
  * ACF 4
119
  * ACF 5
120
+ * ACF 6
121
 
122
  = Issues =
123
  Just like any other WordPress plugin, this plugin can also cause issues with other themes and plugins. If you are facing issues making this plugin work on your WordPress site, please do ask for help in the support forum. This way we can help you out and prevent this issue from happening to someone else. If you want to talk to me directly, you can contact me via my website <http://www.navz.me/>
130
  4. Please refer to the description for more info regarding the field type settings
131
 
132
  == Changelog ==
133
+ =1.8.0=
134
+ * [Added] Support for ACF 6
135
+
136
  =1.7.9=
137
  * [Bugfix] Elementor Pro gallery images preview
138
  * [Added] Support for user profile