Plugin Directory

Changeset 3244757


Ignore:
Timestamp:
02/22/2025 02:58:26 AM (10 months ago)
Author:
navzme
Message:
  • [Added] Support for ACF Group and Repeater fields.
  • [Added] Mobile device support.
Location:
acf-galerie-4/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • acf-galerie-4/trunk/acf-galerie-4.php

    r3237616 r3244757  
    99 * License: GPL v2 or later
    1010 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
    11  * Version: 1.4.0
     11 * Version: 1.4.1
    1212 * Domain Path: /lang
    1313 * Requires PHP: 7.4
     
    2424
    2525        public function initialize() {
    26             $this->define( 'ACFG4_VERSION', '1.4.0' );
     26            $this->define( 'ACFG4_VERSION', '1.4.1' );
    2727            $this->define( 'ACFG4_PLUGIN', __FILE__ );
    2828            $this->define( 'ACFG4_PLUGIN_BASENAME', plugin_basename( ACFG4_PLUGIN ) );
  • acf-galerie-4/trunk/assets/css/acf-galerie-4.css

    r3163273 r3244757  
    1212  box-sizing: border-box;
    1313  border: 1px solid #ccc;
    14   border-radius: 3px;
     14  border-radius: 5px;
    1515  overflow: hidden;
    1616  background-color: #fff;
    17   padding: 3px;
     17  padding: 5px;
    1818  text-align: center;
    1919  position: relative;
     20  transition: box-shadow 0.3s ease-in-out;
    2021}
    2122
     
    2526  object-fit: cover;
    2627  display: block;
    27   border-radius: 3px;
     28  border-radius: 5px;
    2829}
    2930
     
    4041
    4142.acf-galerie-4-container:last-child {
    42   margin-bottom: 0px;
     43  margin-bottom: 0;
    4344}
    4445
    4546.acf-field-galerie-4 .acf-galerie-4-add-media span.dashicons {
    46   vertical-align: sub;
     47  vertical-align: middle;
    4748  font-size: 18px;
    4849}
     
    5152  position: absolute;
    5253  background: rgba(0, 0, 0, 0.6);
    53   width: 92%;
     54  width: calc(100% - 6px);
    5455  bottom: 2px;
    5556  color: #fff;
    5657  padding: 7px 5px;
    5758  left: 3px;
    58   right: 0px;
    59   min-height: 16px;
    60   max-height: 16px;
     59  text-align: center;
     60  font-size: 12px;
     61  line-height: 16px;
     62  white-space: nowrap;
     63  overflow: hidden;
     64  text-overflow: ellipsis;
     65  border-radius: 3px;
    6166}
    6267
     
    6469  position: absolute;
    6570  cursor: pointer;
    66   background: #000;
     71  background: rgba(0, 0, 0, 0.8);
    6772  color: #fff;
    6873  border-radius: 50%;
    69   top: 40%;
    70   left: 40%;
     74  top: 50%;
     75  left: 50%;
    7176  height: 40px;
    7277  width: 40px;
    7378  border: none;
    7479  opacity: 0;
    75   transition: opacity 0.3s ease-in-out;
    76   font-size: revert;
    77   padding: 0px;
     80  transition: opacity 0.3s ease-in-out, transform 0.2s ease-in-out;
     81  font-size: 16px;
     82  padding: 0;
     83  display: flex;
     84  align-items: center;
     85  justify-content: center;
     86  transform: translate(-50%, -50%);
     87  outline: none;
    7888}
    7989
    8090.acf-field-galerie-4
    8191  .attachment-thumbnail-container:hover
     92  > .acf-galerie-4-remove-attachment,
     93.acf-field-galerie-4
     94  .attachment-thumbnail-container:focus-within
    8295  > .acf-galerie-4-remove-attachment {
    8396  opacity: 1;
     97  display: flex;
    8498}
     99
     100.acf-field-galerie-4 .acf-galerie-4-remove-attachment:hover {
     101  background: rgba(255, 0, 0, 0.9);
     102  transform: translate(-50%, -50%) scale(1.1);
     103}
  • acf-galerie-4/trunk/assets/js/acf-galerie-4.js

    r3179670 r3244757  
    5757
    5858  $(document).on("click", ".acf-galerie-4-add-media", function (e) {
    59     var container = $(this)
     59    const container = $(this)
    6060      .closest(".acf-galerie-4-container")
    6161      .find(".acf-galerie-4-attachments");
    6262
    63     var key = container
     63    const field_name = $(this)
     64      .closest(".acf-galerie-4-container")
     65      .find('input[type="hidden"]')[0].name;
     66
     67    const key = container
    6468      .attr("class")
    6569      .match(/acf-galerie-4-attachments-(\w+)/)[1];
    6670
    67     var dataset = datasets.find((x) => x.key === key);
     71    const dataset = datasets.find((x) => x.key === key);
     72    dataset["field_name"] = field_name;
    6873
    6974    wp_media_library(container, dataset);
     
    8489      $html += `<div data-id="${attachment.id}" class="${thumbnail_class}">`;
    8590      $html += `<img src='${icon}'/>`;
    86       $html += `<input type="hidden" value="${attachment.id}" name="${dataset.type}[${dataset.name}][]"/>`;
     91      $html += `<input type="hidden" value="${attachment.id}" name="${dataset.field_name}[]"/>`;
    8792      $html += `</div>`;
    8893    });
     
    9297
    9398  $(document).on(
    94     "click",
    95     ".acf-field-galerie-4 .acf-galerie-4-remove-attachment ",
     99    "click touchend",
     100    ".acf-field-galerie-4 .acf-galerie-4-remove-attachment",
    96101    function () {
    97102      var id = $(this).closest(".attachment-thumbnail-container").data("id");
     
    108113  );
    109114
     115  $(document).on(
     116    "touchstart",
     117    ".acf-field-galerie-4 .attachment-thumbnail-container img",
     118    function (event) {
     119      event.stopPropagation();
     120
     121      let $button = $(this)
     122        .closest(".attachment-thumbnail-container")
     123        .find(".acf-galerie-4-remove-attachment");
     124
     125      if ($button.css("opacity") === "1") {
     126        $button.css("opacity", "0");
     127        $button.css("display", "none");
     128      } else {
     129        $(".acf-galerie-4-remove-attachment").css("opacity", "0");
     130        $button.css("opacity", "1");
     131        $button.css("display", "inline-block");
     132      }
     133    }
     134  );
     135
    110136  if (typeof acf.add_action !== "undefined") {
    111137    /**
  • acf-galerie-4/trunk/providers/class.register-field-type.php

    r3237616 r3244757  
    137137    ?>
    138138        <div>
    139             <input type="hidden" name="<?php echo esc_attr( $field['name'] ); ?>" value="" />
    140             <input type="hidden" name="_<?php echo esc_attr( $this->name ); ?>_nonce[<?php echo esc_attr( $field['key'] ); ?>]" value="<?php echo esc_attr( wp_create_nonce( esc_attr( $field['key'] ) ) ); ?>" />
    141139            <div class="<?php echo esc_attr( $this->add_class('container') ); ?>">
    142                 <div class="<?php echo esc_attr( $this->add_class('attachments') ); ?> <?php echo esc_attr( $this->add_class('attachments') ); ?>-<?php echo esc_attr( $field['key'] ); ?>">
     140                <input type="hidden" name="<?php echo esc_attr( $field['name'] ); ?>" value="" />
     141                <div
     142                    class="<?php echo esc_attr( $this->add_class('attachments') ); ?>
     143                           <?php echo esc_attr( $this->add_class('attachments') ); ?>-<?php echo esc_attr( $field['key'] ); ?>"
     144                    data-name="<?php echo esc_attr( $field['name'] ); ?>">
    143145                    <?php if ( $attachments ) : ?>
    144146                        <?php
     
    154156                        ?>
    155157                            <div data-id="<?php echo esc_attr( $attachment_id ); ?>" class="<?php echo esc_attr( 'attachment-thumbnail-container' ); ?> <?php echo esc_attr( "attachment-thumbnail-container-{$attachment_id}" ); ?> <?php echo esc_attr( $thumbnail_class ); ?>">
     158                                <input type="hidden" name="<?php echo esc_attr( $field['name'] ); ?>[]" value="<?php echo esc_attr( $attachment_id ); ?>" />
    156159                                <button
    157160                                    type="button"
     
    160163                                    <span class="dashicons dashicons-trash"></span>
    161164                                </button>
    162                                 <input type="hidden" name="<?php echo esc_attr( $field['type'] ); ?>[<?php echo esc_attr( $field['_name'] ); ?>][]" value="<?php echo esc_attr( $attachment_id ); ?>" />
    163165                                <img
    164166                                    src="<?php echo esc_url( $thumbnail ); ?>"
     
    201203     * @return array An array of sanitized integer values representing the field's data.
    202204     */
    203     function update_value( $value, $post_id, $field ) {
    204         $field_type = $field['type'];
    205         $field_key = $field['key'];
    206         $nonce_key = "_{$field_type}_nonce";
    207 
    208         if(
    209             empty( $_POST[$nonce_key] ) or
    210             empty( $_POST[$nonce_key][$field_key] ) ) die();
    211 
    212         $nonce_key = sanitize_text_field( wp_unslash( $_POST[$nonce_key][$field_key] ) );
    213        
    214         if( ! wp_verify_nonce( $nonce_key, $field_key ) ) die();
    215 
    216         if ( empty( $_POST[$field_type] ) or empty( $_POST[$field_type][$field['name']] ) ){
     205    function update_value( $value, $post_id, $field ) {     
     206        if ( empty( $value ) ) {
    217207            return array();
    218208        }
    219        
    220         $value = array_map( 'sanitize_text_field', wp_unslash( $_POST[$field_type][$field['name']] ) );
    221209
    222210        return array_map( 'intval', $value );
  • acf-galerie-4/trunk/readme.txt

    r3237618 r3244757  
    55Requires at least: 5.8
    66Tested up to: 6.7
    7 Stable tag: 1.4.0
     7Stable tag: 1.4.1
    88Requires PHP: 7.0
    99License: GPLv2 or later
     
    4646
    4747== Changelog ==
     48= 1.4.1 =
     49* [Added] Support for ACF Group and Repeater fields.
     50* [Added] Mobile device support.
     51
    4852= 1.4.0 =
    4953* [Added] Wrapped the main function inside a class to prevent conflicts with other WordPress functions.
Note: See TracChangeset for help on using the changeset viewer.