WordPress.org

Plugin Directory

Changeset 1495181


Ignore:
Timestamp:
09/13/16 13:34:49 (13 months ago)
Author:
cyrilbatillat
Message:

v2.0

  • Now supporting 'Post Object' fields ! :)
  • Fix CSS bugs in tooltip positioning
Location:
quick-and-easy-post-creation-for-acf-relationship-fields/trunk
Files:
1 added
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/acf-relationship-create.php

    r1462110 r1495181  
    22/* 
    33Plugin Name: Quick and easy Post creation for ACF Relationship Fields 
    4 Description: Quick & Easy post creation on your Advanced Custom Fields (ACF) Relationship Fields (free version) 
     4Description: Quick & Easy post creation on your Advanced Custom Fields (ACF) 'Relationship' & 'Post Object' Fields (free version) 
    55Author: Bazalt 
    6 Version: 1.2 
     6Version: 2.0 
    77Author URI: http://bazalt.fr/ 
    88License: GPL2 
     
    147147                plugins_url('assets/js/acf-relationship-create' . ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' ) . '.js', __FILE__), 
    148148                array('jquery'), 
    149                 '1.0' 
     149                '2.0' 
    150150            ); 
    151151 
     
    155155                plugins_url('assets/js/acf-relationship-create-field' . ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' ) . '.js', __FILE__), 
    156156                array( 'acf-relationship-create', 'thickbox', 'acf-input' ), 
    157                 '1.0' 
     157                '2.0' 
    158158            ); 
    159159 
     
    163163                plugins_url('assets/js/acf-relationship-create-iframe' . ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' ) . '.js', __FILE__), 
    164164                array('acf-relationship-create'), 
    165                 '1.0' 
     165                '2.0' 
    166166            ); 
    167167 
     
    170170                plugins_url( 'assets/css/acf-relationship-create.css', __FILE__ ), 
    171171                array('acf-input'), 
    172                 '1.0' 
     172                '2.0' 
    173173            ); 
    174174 
     
    201201            // Alter markup of ACF relationship fields 
    202202            add_action( 'acf/create_field', array( $this, 'acf_render_relationship_field' ), 10, 1 ); 
    203             /*add_action( 'acf/create_field', function( $field) { 
    204                 echo '<pre>'; 
    205                 var_dump( $field); 
    206                 echo '</pre>'; 
    207             }, 10, 1 );*/ 
    208203        } 
    209204 
     
    217212        public function admin_scripts( $hook ) { 
    218213            // This script will only be enqueued on saved posts. Not on post-new.php 
    219             if( in_array( $hook, array( 'post.php') ) ) { 
     214            if( in_array( $hook, array( 'post.php' ) ) ) { 
    220215                wp_enqueue_script( 'acf-relationship-create-iframe' ); 
    221216            } 
     
    228223         */ 
    229224        public function enqueue_acf_assets() { 
     225            // CSS 
     226            wp_enqueue_style( 'acf-relationship-create' ); 
     227 
     228            // JS 
    230229            wp_enqueue_script( 'acf-relationship-create-field' ); 
    231             wp_enqueue_style( 'acf-relationship-create' ); 
     230 
     231            // JS: pass Post Types labels 
     232            $post_types_labels = array(); 
     233            $post_types = get_post_types( array(), 'objects' ); 
     234            foreach( $post_types as $post_type ) 
     235                $post_types_labels[$post_type->name] = $post_type->labels->name; 
     236 
     237            wp_localize_script( 
     238                'acf-relationship-create-field', 
     239                'acf_relationship_create_field', 
     240                array( 
     241                    'post_types_labels' => $post_types_labels, 
     242                    'i18n' => array( 
     243                        'no_title' => __( '(No title)', 'acf-relationship-create' ) 
     244                    ) 
     245                ) 
     246            ); 
    232247        } 
    233248 
     
    265280         */ 
    266281        public function acf_render_relationship_field( $field ) { 
    267             if( empty( $field['type'] ) || $field['type'] != 'relationship' ) return; 
     282 
     283            if( empty( $field['class'] ) || !in_array( $field['class'], array( 'relationship', 'post_object' ) ) ) return; 
    268284            if( empty( $field['acf_relationship_create'] ) ) return; 
    269285 
     
    307323 
    308324            <script type="text-html" class="acf-rc-popup-wrapper"> 
    309                 <div class="acf-rc-popup"> 
     325                <div id="acf-rc-popup"> 
    310326                    <ul> 
    311327                        <li> 
     
    335351         */ 
    336352        public function acf_relationship_settings( $field ) { 
    337             if( empty( $field['type'] ) || $field['type'] != 'relationship' ) 
     353            if( empty( $field['type'] ) || !in_array( $field['type'], array( 'relationship', 'post_object' ) ) ) 
    338354                return; 
    339355 
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/assets/css/acf-relationship-create.css

    r1460606 r1495181  
    2323/** 
    2424 * Tooltip 
     25 * 
     26 * Duplicated & adapted from .acf-fc-popup 
    2527 */ 
    26 .acf-rc-popup { 
     28#acf-rc-popup { 
    2729  position: absolute; 
     30  left: 0; 
     31  top: 0; 
    2832  border-radius: 3px; 
    2933  background: #333739; 
    3034  box-shadow: 0 0 2px rgba(0, 0, 0, 0.1); 
    3135  min-width: 135px; 
    32   z-index: 9999; } 
    33   .acf-rc-popup:before { 
     36  z-index: 9999999999999; } 
     37  #acf-rc-popup:before { 
    3438    content: ""; 
    3539    display: block; 
     
    4347    border-top-color: #333739; 
    4448    z-index: 2; } 
    45   .acf-rc-popup.bottom:before { 
     49  #acf-rc-popup.bottom:before { 
    4650    top: auto; 
    4751    bottom: 100%; 
    4852    border-top-color: transparent; 
    4953    border-bottom-color: #333739; } 
    50   .acf-rc-popup ul, 
    51   .acf-rc-popup ul li { 
     54  #acf-rc-popup ul, 
     55  #acf-rc-popup ul li { 
    5256    list-style: none; 
    5357    display: block; 
    5458    margin: 0; 
    5559    padding: 0; 
    56     white-space: nowrap; 
    57     text-align: left; } 
    58   .acf-rc-popup ul li { 
     60    white-space: nowrap; } 
     61  #acf-rc-popup ul li { 
    5962    position: relative; 
    6063    float: none; 
    6164    border-top: #2B2F31 solid 1px; } 
    62     .acf-rc-popup ul li:first-child { 
     65    #acf-rc-popup ul li:first-child { 
    6366      margin: 0; 
    6467      border-top: 0 none; } 
    65     .acf-rc-popup ul li a { 
     68    #acf-rc-popup ul li a { 
     69      position: relative; 
     70      display: block; 
    6671      color: #F9F9F9; 
    6772      font-size: 12px; 
    6873      line-height: 14px; 
    6974      padding: 6px 8px; 
    70       display: block; 
    7175      text-decoration: none; 
    72       position: relative; 
     76      text-align: left; 
    7377      text-shadow: none; } 
    74       .acf-rc-popup ul li a:hover { 
     78      #acf-rc-popup ul li a:hover { 
    7579        color: #fff; 
    7680        background: #288FBC; 
    7781        text-shadow: #1E698B 0 1px 0; } 
    78       .acf-rc-popup ul li a .status { 
     82      #acf-rc-popup ul li a .status { 
    7983        display: block; 
    8084        position: absolute; 
     
    9094        color: #DFDFDF; 
    9195        display: none; } 
    92         .acf-rc-popup ul li a .status.warning { 
     96        #acf-rc-popup ul li a .status.warning { 
    9397          border-color: #e86740; } 
    94       .acf-rc-popup ul li a:hover .status { 
     98      #acf-rc-popup ul li a:hover .status { 
    9599        border-color: #fff; 
    96100        color: #fff; } 
    97     .acf-rc-popup ul li:first-child a { 
     101    #acf-rc-popup ul li:first-child a { 
    98102      border-radius: 3px 3px 0 0; } 
    99     .acf-rc-popup ul li:last-child a { 
     103    #acf-rc-popup ul li:last-child a { 
    100104      border-radius: 0 0 3px 3px; } 
    101     .acf-rc-popup ul li:only-child a { 
     105    #acf-rc-popup ul li:only-child a { 
    102106      border-radius: 3px; } 
    103   .acf-rc-popup a.focus { 
     107  #acf-rc-popup a.focus { 
    104108    position: absolute; 
    105109    width: 0; 
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/assets/css/acf-relationship-create.css.map

    r1460606 r1495181  
    11{ 
    22"version": 3, 
    3 "mappings": "AAAA,wCAAyC;EACvC,QAAQ,EAAC,OAAO;;AAMd,gEAAM;EACJ,OAAO,EAAC,YAAY;AAGtB,yFAA+B;EAC7B,OAAO,EAAC,YAAY;EACpB,KAAK,EAAC,KAAK;EACX,eAAe,EAAC,IAAI;;AAK1B;;GAEG;AAIC,4DAAM;EACJ,OAAO,EAAC,YAAY;AAGtB,qFAA+B;EAC7B,OAAO,EAAC,YAAY;EACpB,KAAK,EAAC,KAAK;EACX,eAAe,EAAC,IAAI;EACpB,WAAW,EAAC,GAAG;EACf,UAAU,EAAC,GAAG;;AAKpB;;GAEG;AACH,aAAc;EACZ,QAAQ,EAAE,QAAQ;EAClB,aAAa,EAAE,GAA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B;QACzB,UAAU,EAAE,MAAM;QAClB,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,IAAI;QAEb,qCAAU;UACR,YAAY,EAAE,OAAO;MAIzB,mCAAgB;QACd,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,IAAI;IAIf,iCAAgB;MACd,aAAa,EAAE,WAAW;IAG5B,gCAAe;MACb,aAAa,EAAE,WAAW;IAG5B,gCAAe;MACb,aAAa,EAAE,GAAG;EAItB,qBAAQ;IACN,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,CAAC;IACN,OAAO,EAAE,CAAC;;AAKd;;GAEG;AACH,WAAY;EACV,OAAO,EAAC,MAAM;;AAEhB,UAAW;EACT,OAAO,EAAC,MAAM", 
    44"sources": ["acf-relationship-create.scss"], 
    55"names": [], 
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/assets/css/acf-relationship-create.scss

    r1460606 r1495181  
    3838} 
    3939 
     40 
    4041/** 
    4142 * Tooltip 
     43 * 
     44 * Duplicated & adapted from .acf-fc-popup 
    4245 */ 
    43 .acf-rc-popup { 
     46#acf-rc-popup { 
    4447  position: absolute; 
     48  left:0; 
     49  top:0; 
    4550  border-radius: 3px; 
    4651  background: #333739; 
    4752  box-shadow: 0 0 2px rgba(0, 0, 0, 0.1); 
    4853  min-width: 135px; 
    49   z-index: 9999; 
     54  z-index: 9999999999999; 
    5055 
    5156  &:before { 
     
    7883    padding: 0; 
    7984    white-space: nowrap; 
    80     text-align: left; 
    8185  } 
    8286 
     
    9296 
    9397    a { 
     98      position: relative; 
     99      display: block; 
    94100      color: #F9F9F9; 
    95101      font-size: 12px; 
    96102      line-height: 14px; 
    97103      padding: 6px 8px; 
    98       display: block; 
    99104      text-decoration: none; 
    100       position: relative; 
     105      text-align:left; 
    101106      text-shadow: none; 
    102107 
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/assets/js/acf-relationship-create-field.js

    r1460606 r1495181  
    66 
    77    /** 
     8     * Common function to close tooltip on Relationship & Post Object fields 
     9     **/ 
     10    var close_tooltip = function() { 
     11        setTimeout(function(){ 
     12            $('#acf-rc-popup').remove(); 
     13        }, 200); 
     14    }; 
     15 
     16    /** 
    817     * Open a tooltip to choose which kind of CPT to create 
    918     * Inspired from flexible_content field 
     
    1726        e.preventDefault(); 
    1827 
     28        // Eventually close other tooltips 
     29        $('#acf-rc-popup').remove(); 
     30 
    1931        var $event_target = $(e.target); 
    20         if( !$event_target.is('.acf-relationship-create-link') ) { 
     32        if( !$event_target.is('.acf-relationship-create-link') ) 
    2133            $event_target = $event_target.parents('.acf-relationship-create-link:first'); 
    22         } 
     34 
    2335        if( $event_target.length != 1 ) return; 
    2436 
     
    2941        } 
    3042 
     43        // Get ACF $field for Relationship field 
    3144        var $el = $field_wrapper.find('.acf_relationship'); 
    32         if( $el.length != 1 ) return; 
    33  
     45 
     46        // Get ACF $field for Post object field 
     47        if( $el.length != 1 ) { 
     48            $el = $field_wrapper.find('select.post_object'); 
     49            if( $el.length != 1 ) 
     50                return; 
     51        } 
     52 
     53        // Make ACF focus on this field 
    3454        acf.fields.relationship.set({ $el : $el }); 
    3555 
    3656        // Prevent the user to create a new content 
    3757        // if the maximum number of items is already reached. 
    38         if( acf.fields.relationship.$right.find('a').length >= acf.fields.relationship.o.max ) 
    39         { 
    40             alert( acf.l10n.relationship.max.replace('{max}', acf.fields.relationship.o.max) ); 
    41             return false; 
    42         } 
    43  
    44         var $popup = $( $field_wrapper.find('.acf-rc-popup-wrapper').html() ); 
    45         $event_target.after( $popup ); 
    46  
    47         // vars 
    48         $popup.css({ 
    49             'margin-top' : 0 - $popup.height() - $event_target.outerHeight() - 14, 
    50             'margin-left' : $event_target.position().left + ($event_target.width()/2) - ( $popup.width() ) / 2 
     58        if( typeof acf.fields.relationship.o.max != 'undefined' ) { 
     59            if (acf.fields.relationship.$right.find('a').length >= acf.fields.relationship.o.max) { 
     60                alert(acf.l10n.relationship.max.replace('{max}', acf.fields.relationship.o.max)); 
     61                return false; 
     62            } 
     63        } 
     64 
     65        var $tooltip = $( $field_wrapper.find('.acf-rc-popup-wrapper').html() ); 
     66 
     67        // Position tooltip 
     68        var $media_modal = $event_target.parents('.media-modal:first'); 
     69        var context_media_modal = $media_modal.length == 1; 
     70        if( context_media_modal ) { 
     71            $media_modal.find('div.media-frame-content div.settings').prepend($tooltip); 
     72            $tooltip.css({ 
     73                'top': $event_target.position().top - $tooltip.height() - 6 + ( $event_target.outerHeight(true) - $event_target.innerHeight() ), 
     74                'left': $event_target.position().left - ( $tooltip.width() / 2 ) + $event_target.outerWidth( true ) / 2 
     75            }); 
     76        } else { 
     77            $('body').prepend($tooltip); 
     78            $tooltip.css({ 
     79                'top': $event_target.offset().top - $tooltip.height() - 6, 
     80                'left': $event_target.offset().left - ( $tooltip.width() / 2 ) + ( $event_target.outerWidth( true ) /2 ) 
     81            }); 
     82        } 
     83 
     84        // Take focus 
     85        var $tooltip_focus = $tooltip.children('.focus'); 
     86        $tooltip_focus.trigger('focus'); 
     87 
     88        // Event to close tooltip 
     89        $tooltip_focus.on('blur', function() { 
     90            close_tooltip(); 
    5191        }); 
    5292 
    53         // check distance to top 
    54         var offset = $popup.offset().top; 
    55  
    56         if( offset < 30 ) { 
    57  
    58             $popup.css({ 
    59                 'margin-top' : 15 
    60             }); 
    61  
    62             $popup.find('.bit').addClass('top'); 
    63         } 
    64  
    65         // focus 
    66         $popup.children('.focus').trigger('focus'); 
     93        // Handle click on a tooltip link 
     94        $tooltip.on('click', 'a', function(e) { 
     95            e.preventDefault(); 
     96 
     97            // Store link data into ACF field 
     98            $field_wrapper.data( 
     99                'acfRcOpenUrl', 
     100                { 
     101                    'url':$(this).attr('data-create-url'), 
     102                    'title':$(this).attr('title') 
     103                } 
     104            ); 
     105 
     106            // Trigger lightbox opening 
     107            acf.fields.relationship.acf_rc_lightbox_open(); 
     108        }); 
    67109    }; 
    68110 
     
    75117 
    76118    /** 
    77      * Close the tooltip 
    78      * Inspired from flexible_content field 
    79      * 
    80      * @see acf.fields.flexible_content._close 
    81      * @event blur .acf-fc-popup .focus 
     119     * Open post creation in UI, in an iframe, in a lightbox 
     120     * 
     121     * @event click .acf-fc-popup a 
    82122     * 
    83123     * @param e Event 
    84124     */ 
    85     acf.fields.relationship.acf_rc_tooltip_close = function(e) { 
    86         var $popup = $(e.target).parents('.acf-rc-popup:first'); 
    87  
    88         // remove popup 
    89         setTimeout(function(){ 
    90             $popup.remove(); 
    91         }, 200); 
    92     }; 
    93  
    94     // Custom event to close tooltip 
    95     $(document).on('blur', '.acf-rc-popup .focus', function(e){ 
    96         acf.fields.relationship.acf_rc_tooltip_close(e); 
    97     }); 
    98  
    99  
    100  
    101     /** 
    102      * Open post creation in UI, in an iframe, in a lightbox 
    103      * 
    104      * @event click .acf-fc-popup a 
    105      * 
    106      * @param e Event 
    107      */ 
    108125    acf.fields.relationship.acf_rc_lightbox_open = function(e) { 
    109         e.preventDefault(); 
    110  
    111         var $field_wrapper = acf.fields.relationship.acf_rc_get_field_wrapper( $(e.target) ); 
     126        var $field_wrapper = acf.fields.relationship.acf_rc_get_field_wrapper( this.$el ); 
    112127        if( $field_wrapper.length != 1 ) { 
    113128            console.warn('[acf-relationship-create | acf_rc_lightbox_open ] No wrapper found', $(e.target)); 
     
    115130        } 
    116131 
    117         var $input_uniqid = $field_wrapper.find('input[name="acf-relationship-created_post_id"]'); 
    118         if( $input_uniqid.length != 1 ) return; 
    119  
    120         var url = $(e.target).attr('data-create-url'); 
    121         url = url.replace( 
     132        var url = $field_wrapper.data('acfRcOpenUrl').url.replace( 
    122133            '__acf_rc_original_field_uniqid__', 
    123             $input_uniqid.attr('data-uniqid') 
     134            $field_wrapper.attr('data-acf-rc-uniqid') 
    124135        ); 
    125136 
    126137        // Check whether we are in a media modal 
    127         var $media_modal = $(e.target).parents('.media-modal:first'); 
     138        var $media_modal = $field_wrapper.parents('.media-modal:first'); 
    128139        if( $media_modal.length == 1 ) { // Yes we are! 
    129140            url = url.replace( 
     
    146157        } 
    147158 
    148         tb_show( $(e.target).attr('title'), url ); 
    149     }; 
    150  
    151     // Custom event to open iframe in Thickbox 
    152     $(document).on('click', '.acf-rc-popup a', function(e){ 
    153         acf.fields.relationship.acf_rc_lightbox_open(e); 
    154     }); 
     159        tb_show( $field_wrapper.data('acfRcOpenUrl').title, url ); 
     160    }; 
    155161 
    156162 
     
    159165     * 
    160166     * @param e 
    161      * @param new_post_id 
    162      * @param $input_from 
    163      */ 
    164     acf.fields.relationship.acf_rc_on_content_created = function(e, new_post_id, $input_from) { 
    165         var $field_wrapper = acf.fields.relationship.acf_rc_get_field_wrapper( $input_from ); 
    166         if( $field_wrapper.length != 1 ) { 
    167             console.warn('[acf-relationship-create | acf_rc_on_content_created ] No wrapper found', $input_from); 
    168             return; 
    169         } 
    170  
     167     * @param field_uniq_id 
     168     * @param post_data 
     169     */ 
     170    acf.fields.relationship.acf_rc_on_content_created = function(e, field_uniq_id, post_data) { 
     171        if( typeof field_uniq_id == 'undefined' ) return; 
     172 
     173        var $field_wrapper = $('[data-acf-rc-uniqid="' + field_uniq_id + '"]'); 
     174        if( $field_wrapper.length != 1 ) { 
     175            return; 
     176        } 
     177 
     178        if( typeof post_data.post_title == 'undefined' || post_data.post_title == '' ) { 
     179            post_data.post_title = window.acf_relationship_create_field.i18n.no_title; 
     180        } 
     181 
     182        // Relationship field 
     183        var field_type = 'relationship'; 
    171184        var $el = $field_wrapper.find('.acf_relationship'); 
    172         if( $el.length != 1 ) return; 
    173  
    174         // data-* attributes are automatically added to AJAX params 
    175         $el.attr('data-acf_relationship_created_post_id', new_post_id + '-' + $input_from.attr('data-uniqid')); 
    176  
    177         // fetch 
    178         acf.fields.relationship.set({ $el : $el }).fetch(); 
     185 
     186        // Post Object field 
     187        if( $el.length != 1 ) { 
     188            $el = $field_wrapper.find('select.post_object'); 
     189            if( $el.length != 1 ) 
     190                return; 
     191 
     192            field_type = 'post_object'; 
     193        } 
     194 
     195        switch( field_type ) { 
     196            case 'relationship': 
     197                // data-* attributes are automatically added to AJAX params 
     198                $el.attr('data-acf_relationship_created_post_id', post_data.post_id + '-' + field_uniq_id); 
     199 
     200                // fetch 
     201                acf.fields.relationship.set({ $el : $el }).fetch(); 
     202                break; 
     203            case 'post_object': 
     204                // Create DOM <option> for newly created content 
     205                var $new_option = $('<option></option>').val(post_data.post_id).text( post_data.post_title ); 
     206                $el.find('optgroup[label="' + acf_relationship_create.get_post_type_label( post_data.post_type ) + '"]') 
     207                    .prepend( $new_option ); 
     208 
     209                // Select new option 
     210                $new_option.prop('selected', 'selected'); 
     211 
     212                $el.trigger('change'); 
     213                break; 
     214        } 
    179215    }; 
    180216 
     
    187223     */ 
    188224    acf.fields.relationship.acf_rc_get_field_wrapper = function( $elt ) { 
     225 
     226        if( $elt.is('[data-acf-relationship-create-enabled="true"]') ) 
     227            return $elt; 
     228 
    189229        // Special treatment when working with relationship fields on attachments 
    190230        var $field_wrapper = $elt.parents('tr[class^="compat-field-fields"]:first'); 
    191231 
    192         // Classic CPT 
     232        // Relationship field 
    193233        if( $field_wrapper.length != 1 ) { 
    194234            $field_wrapper = $elt.parents('.field_type-relationship:first'); 
    195235        } 
    196236 
     237        // Post Object field 
     238        if( $field_wrapper.length != 1 ) { 
     239            $field_wrapper = $elt.parents('.field_type-post_object:first'); 
     240        } 
     241 
    197242        return $field_wrapper; 
    198243    }; 
    199244 
    200245 
    201     // Default AJAX callback for completed AJAX requests 
     246    // Default AJAX callback for completed AJAX requests on Relationship fields 
    202247    $(document).ajaxComplete(function(event, xhr, ajaxOptions, data) { 
    203248        var ajax_request_data = acf_relationship_create.parse_query_string( 'foobar?' + decodeURIComponent(ajaxOptions.data) ); 
     
    208253        if( typeof splitted_value[1] == 'undefined' ) return; 
    209254 
    210         var $input = $('[data-uniqid="' + splitted_value[1] + '"]'); 
    211         if( $input.length != 1 ) return; 
    212  
    213         var $field_wrapper = acf.fields.relationship.acf_rc_get_field_wrapper( $input ); 
    214         if( $field_wrapper.length != 1 ) { 
    215             console.warn('[acf-relationship-create | ajaxComplete ] No wrapper found', $input); 
    216             return; 
    217         } 
    218  
     255        var $field_wrapper = $('[data-acf-rc-uniqid="' + splitted_value[1] + '"]'); 
     256        if( $field_wrapper.length != 1 ) { 
     257            console.warn('[acf-relationship-create | ajaxComplete ] No wrapper found', splitted_value[1]); 
     258            return; 
     259        } 
     260 
     261        // Relationship fields only. We don't need to do anything here for Post Object fields 
    219262        var $el = $field_wrapper.find('.acf_relationship'); 
    220263        if( $el.length != 1 ) return; 
     
    236279     * Listen to the event triggered from the `create-on-the-fly` iframe 
    237280     */ 
    238     $(document).on('acf-relationship-create/created', function(e, newly_created_content_id, field_uniq_id) { 
    239         if( typeof field_uniq_id == 'undefined' ) return; 
    240  
    241         var $input_filter = $('input[name="acf-relationship-created_post_id"][data-uniqid="' + field_uniq_id + '"]'); 
    242         if( $input_filter.length != 1 ) return; 
    243  
     281    $(document).on('acf-relationship-create/created', function(e, field_uniq_id, post_data ) { 
    244282        // Dispatch the event 
    245         acf.fields.relationship.acf_rc_on_content_created( e, newly_created_content_id, $input_filter ); 
     283        acf.fields.relationship.acf_rc_on_content_created( e, field_uniq_id, post_data ); 
    246284 
    247285        // Close Thickbox 
     
    269307            if( $link.length != 1 ) return; 
    270308 
    271             // Regenerate uniqid 
    272             $el.find('input[name="acf-relationship-created_post_id"]').attr( 
    273                 'data-uniqid', 
    274                 acf_relationship_create.generate_random_id() 
    275             ); 
    276  
    277             // Add a class (just for CSS purpose) 
     309            // Add a unique ID for the field 
     310            $el.attr('data-acf-rc-uniqid', acf_relationship_create.generate_random_id() ); 
     311 
     312            // Add a custom attr (mainly for CSS purpose) 
    278313            $el.attr('data-acf-relationship-create-enabled', true); 
    279314 
     
    283318 
    284319        $(document).on('acf/setup_fields', function(e, el){ 
    285             $(el).find('.acf_relationship').each(function(){ 
     320            $(el).find('.acf_relationship, select.post_object').each(function(){ 
    286321                acf.fields.relationship.set({ $el : $(this) }).init(); 
    287322 
    288323                var $field_wrapper = acf.fields.relationship.acf_rc_get_field_wrapper( $( this ) ); 
    289  
    290324                if( $field_wrapper.length != 1 ) { 
    291325                    console.warn('[acf-relationship-create | acf/setup_fields ] No wrapper found for this relationship field', $(this)); 
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/assets/js/acf-relationship-create-field.min.js

    r1460606 r1495181  
    1 !function(e,t,a){"undefined"!=typeof acf&&(acf.fields.relationship.acf_rc_tooltip_open=function(t){t.preventDefault();var a=e(t.target);if(a.is(".acf-relationship-create-link")||(a=a.parents(".acf-relationship-create-link:first")),1==a.length){var i=acf.fields.relationship.acf_rc_get_field_wrapper(a);if(1!=i.length)return void console.warn("[acf-relationship-create | acf_rc_tooltip_open ] No wrapper found",a);var r=i.find(".acf_relationship");if(1==r.length){if(acf.fields.relationship.set({$el:r}),acf.fields.relationship.$right.find("a").length>=acf.fields.relationship.o.max)return alert(acf.l10n.relationship.max.replace("{max}",acf.fields.relationship.o.max)),!1;var n=e(i.find(".acf-rc-popup-wrapper").html());a.after(n),n.css({"margin-top":0-n.height()-a.outerHeight()-14,"margin-left":a.position().left+a.width()/2-n.width()/2});var o=n.offset().top;o<30&&(n.css({"margin-top":15}),n.find(".bit").addClass("top")),n.children(".focus").trigger("focus")}}},e(document).on("click",".acf-relationship-create-link",function(e){acf.fields.relationship.acf_rc_tooltip_open(e)}),acf.fields.relationship.acf_rc_tooltip_close=function(t){var a=e(t.target).parents(".acf-rc-popup:first");setTimeout(function(){a.remove()},200)},e(document).on("blur",".acf-rc-popup .focus",function(e){acf.fields.relationship.acf_rc_tooltip_close(e)}),acf.fields.relationship.acf_rc_lightbox_open=function(t){t.preventDefault();var a=acf.fields.relationship.acf_rc_get_field_wrapper(e(t.target));if(1!=a.length)return void console.warn("[acf-relationship-create | acf_rc_lightbox_open ] No wrapper found",e(t.target));var i=a.find('input[name="acf-relationship-created_post_id"]');if(1==i.length){var r=e(t.target).attr("data-create-url");r=r.replace("__acf_rc_original_field_uniqid__",i.attr("data-uniqid"));var n=e(t.target).parents(".media-modal:first");1==n.length?(r=r.replace("__acf_rc_from_content_type__","attachment"),r=r.replace("__acf_rc_from_content_ID__",n.find("div.media-frame-content div.attachment-details").attr("data-id"))):(r=r.replace("__acf_rc_from_content_type__",e('form#post input[name="post_type"]').val()),r=r.replace("__acf_rc_from_content_ID__",e('form#post input[name="post_ID"]').val())),tb_show(e(t.target).attr("title"),r)}},e(document).on("click",".acf-rc-popup a",function(e){acf.fields.relationship.acf_rc_lightbox_open(e)}),acf.fields.relationship.acf_rc_on_content_created=function(e,t,a){var i=acf.fields.relationship.acf_rc_get_field_wrapper(a);if(1!=i.length)return void console.warn("[acf-relationship-create | acf_rc_on_content_created ] No wrapper found",a);var r=i.find(".acf_relationship");1==r.length&&(r.attr("data-acf_relationship_created_post_id",t+"-"+a.attr("data-uniqid")),acf.fields.relationship.set({$el:r}).fetch())},acf.fields.relationship.acf_rc_get_field_wrapper=function(e){var t=e.parents('tr[class^="compat-field-fields"]:first');return 1!=t.length&&(t=e.parents(".field_type-relationship:first")),t},e(document).ajaxComplete(function(a,i,r,n){var o=t.parse_query_string("foobar?"+decodeURIComponent(r.data));if("undefined"!=typeof o.acf_relationship_created_post_id){var f=o.acf_relationship_created_post_id.split("-");if("undefined"!=typeof f[1]){var c=e('[data-uniqid="'+f[1]+'"]');if(1==c.length){var l=acf.fields.relationship.acf_rc_get_field_wrapper(c);if(1!=l.length)return void console.warn("[acf-relationship-create | ajaxComplete ] No wrapper found",c);var p=l.find(".acf_relationship");if(1==p.length){var _=p.find(".relationship_left .relationship_list li:not(.hide) a");1==_.length&&_.trigger("click"),p.attr("data-acf_relationship_created_post_id",""),acf.fields.relationship.set({$el:p}).fetch()}}}}}),e(document).on("acf-relationship-create/created",function(t,a,i){if("undefined"!=typeof i){var r=e('input[name="acf-relationship-created_post_id"][data-uniqid="'+i+'"]');1==r.length&&(acf.fields.relationship.acf_rc_on_content_created(t,a,r),tb_remove())}}),e(document).ready(function(){function a(e){var a=e.find("a.acf-relationship-create-link");1==a.length&&(e.find('input[name="acf-relationship-created_post_id"]').attr("data-uniqid",t.generate_random_id()),e.attr("data-acf-relationship-create-enabled",!0),a.detach().appendTo(e.find(".label")))}t.get_parent_iframe()!==!1&&(t.hide_admin_bar(),t.hide_admin_menu()),e(document).on("acf/setup_fields",function(t,i){e(i).find(".acf_relationship").each(function(){acf.fields.relationship.set({$el:e(this)}).init();var t=acf.fields.relationship.acf_rc_get_field_wrapper(e(this));return 1!=t.length?void console.warn("[acf-relationship-create | acf/setup_fields ] No wrapper found for this relationship field",e(this)):void a(t)})})}))}(jQuery,window.acf_relationship_create||{}); 
     1!function(e,t,i){if("undefined"!=typeof acf){var a=function(){setTimeout(function(){e("#acf-rc-popup").remove()},200)};acf.fields.relationship.acf_rc_tooltip_open=function(t){t.preventDefault(),e("#acf-rc-popup").remove();var i=e(t.target);if(i.is(".acf-relationship-create-link")||(i=i.parents(".acf-relationship-create-link:first")),1==i.length){var n=acf.fields.relationship.acf_rc_get_field_wrapper(i);if(1!=n.length)return void console.warn("[acf-relationship-create | acf_rc_tooltip_open ] No wrapper found",i);var r=n.find(".acf_relationship");if(1==r.length||(r=n.find("select.post_object"),1==r.length)){if(acf.fields.relationship.set({$el:r}),"undefined"!=typeof acf.fields.relationship.o.max&&acf.fields.relationship.$right.find("a").length>=acf.fields.relationship.o.max)return alert(acf.l10n.relationship.max.replace("{max}",acf.fields.relationship.o.max)),!1;var o=e(n.find(".acf-rc-popup-wrapper").html()),f=i.parents(".media-modal:first"),c=1==f.length;c?(f.find("div.media-frame-content div.settings").prepend(o),o.css({top:i.position().top-o.height()-6+(i.outerHeight(!0)-i.innerHeight()),left:i.position().left-o.width()/2+i.outerWidth(!0)/2})):(e("body").prepend(o),o.css({top:i.offset().top-o.height()-6,left:i.offset().left-o.width()/2+i.outerWidth(!0)/2}));var l=o.children(".focus");l.trigger("focus"),l.on("blur",function(){a()}),o.on("click","a",function(t){t.preventDefault(),n.data("acfRcOpenUrl",{url:e(this).attr("data-create-url"),title:e(this).attr("title")}),acf.fields.relationship.acf_rc_lightbox_open()})}}},e(document).on("click",".acf-relationship-create-link",function(e){acf.fields.relationship.acf_rc_tooltip_open(e)}),acf.fields.relationship.acf_rc_lightbox_open=function(t){var i=acf.fields.relationship.acf_rc_get_field_wrapper(this.$el);if(1!=i.length)return void console.warn("[acf-relationship-create | acf_rc_lightbox_open ] No wrapper found",e(t.target));var a=i.data("acfRcOpenUrl").url.replace("__acf_rc_original_field_uniqid__",i.attr("data-acf-rc-uniqid")),n=i.parents(".media-modal:first");1==n.length?(a=a.replace("__acf_rc_from_content_type__","attachment"),a=a.replace("__acf_rc_from_content_ID__",n.find("div.media-frame-content div.attachment-details").attr("data-id"))):(a=a.replace("__acf_rc_from_content_type__",e('form#post input[name="post_type"]').val()),a=a.replace("__acf_rc_from_content_ID__",e('form#post input[name="post_ID"]').val())),tb_show(i.data("acfRcOpenUrl").title,a)},acf.fields.relationship.acf_rc_on_content_created=function(i,a,n){if("undefined"!=typeof a){var r=e('[data-acf-rc-uniqid="'+a+'"]');if(1==r.length){"undefined"!=typeof n.post_title&&""!=n.post_title||(n.post_title=window.acf_relationship_create_field.i18n.no_title);var o="relationship",f=r.find(".acf_relationship");if(1!=f.length){if(f=r.find("select.post_object"),1!=f.length)return;o="post_object"}switch(o){case"relationship":f.attr("data-acf_relationship_created_post_id",n.post_id+"-"+a),acf.fields.relationship.set({$el:f}).fetch();break;case"post_object":var c=e("<option></option>").val(n.post_id).text(n.post_title);f.find('optgroup[label="'+t.get_post_type_label(n.post_type)+'"]').prepend(c),c.prop("selected","selected"),f.trigger("change")}}}},acf.fields.relationship.acf_rc_get_field_wrapper=function(e){if(e.is('[data-acf-relationship-create-enabled="true"]'))return e;var t=e.parents('tr[class^="compat-field-fields"]:first');return 1!=t.length&&(t=e.parents(".field_type-relationship:first")),1!=t.length&&(t=e.parents(".field_type-post_object:first")),t},e(document).ajaxComplete(function(i,a,n,r){var o=t.parse_query_string("foobar?"+decodeURIComponent(n.data));if("undefined"!=typeof o.acf_relationship_created_post_id){var f=o.acf_relationship_created_post_id.split("-");if("undefined"!=typeof f[1]){var c=e('[data-acf-rc-uniqid="'+f[1]+'"]');if(1!=c.length)return void console.warn("[acf-relationship-create | ajaxComplete ] No wrapper found",f[1]);var l=c.find(".acf_relationship");if(1==l.length){var p=l.find(".relationship_left .relationship_list li:not(.hide) a");1==p.length&&p.trigger("click"),l.attr("data-acf_relationship_created_post_id",""),acf.fields.relationship.set({$el:l}).fetch()}}}}),e(document).on("acf-relationship-create/created",function(e,t,i){acf.fields.relationship.acf_rc_on_content_created(e,t,i),tb_remove()}),e(document).ready(function(){function i(e){var i=e.find("a.acf-relationship-create-link");1==i.length&&(e.attr("data-acf-rc-uniqid",t.generate_random_id()),e.attr("data-acf-relationship-create-enabled",!0),i.detach().appendTo(e.find(".label")))}t.get_parent_iframe()!==!1&&(t.hide_admin_bar(),t.hide_admin_menu()),e(document).on("acf/setup_fields",function(t,a){e(a).find(".acf_relationship, select.post_object").each(function(){acf.fields.relationship.set({$el:e(this)}).init();var t=acf.fields.relationship.acf_rc_get_field_wrapper(e(this));return 1!=t.length?void console.warn("[acf-relationship-create | acf/setup_fields ] No wrapper found for this relationship field",e(this)):void i(t)})})})}}(jQuery,window.acf_relationship_create||{}); 
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/assets/js/acf-relationship-create-iframe.js

    r1458759 r1495181  
    1616                'acf-relationship-create/created', 
    1717                [ 
    18                     parseInt( $post_id_input.val() ), // The post ID 
    19                     parent_acf_field_identifier // the original ACF field identifier 
     18                    parent_acf_field_identifier, // the original ACF field identifier 
     19                    { 
     20                        post_id: parseInt( $post_id_input.val() ), 
     21                        post_type: $('form#post input[name="post_type"]').val(), 
     22                        post_title: $('form#post input[name="post_title"]').val() 
     23                    } 
    2024                ] 
    2125            ); 
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/assets/js/acf-relationship-create-iframe.min.js

    r1458759 r1495181  
    1 !function(e,t,a){e(document).ready(function(){var a=t.get_parent_acf_field_identifier();if(a){var r=t.get_parent_jQuery();if(r){var i=e('form#post input[name="post_ID"]');1===i.length&&""!=i.val()&&r("body").trigger("acf-relationship-create/created",[parseInt(i.val()),a])}}})}(jQuery,window.acf_relationship_create||{}); 
     1!function(t,e,a){t(document).ready(function(){var a=e.get_parent_acf_field_identifier();if(a){var i=e.get_parent_jQuery();if(i){var r=t('form#post input[name="post_ID"]');1===r.length&&""!=r.val()&&i("body").trigger("acf-relationship-create/created",[a,{post_id:parseInt(r.val()),post_type:t('form#post input[name="post_type"]').val(),post_title:t('form#post input[name="post_title"]').val()}])}}})}(jQuery,window.acf_relationship_create||{}); 
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/assets/js/acf-relationship-create.js

    r1458759 r1495181  
    9898            $('#adminmenumain').hide(); 
    9999            $('#wpcontent, #wpfooter').css('margin-left', 0); 
     100        }, 
     101 
     102        /** 
     103         * Get Post Type label given its name 
     104         * 
     105         * @param post_type 
     106         * @returns {*} 
     107         */ 
     108        get_post_type_label: function( post_type ) { 
     109            if( typeof window.acf_relationship_create_field == 'undefined' ) return ''; 
     110            if( typeof window.acf_relationship_create_field['post_types_labels'] == 'undefined' ) return ''; 
     111            if( typeof window.acf_relationship_create_field['post_types_labels'][post_type] == 'undefined' ) return ''; 
     112            return window.acf_relationship_create_field['post_types_labels'][post_type]; 
    100113        } 
    101114    }; 
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/assets/js/acf-relationship-create.min.js

    r1458759 r1495181  
    1 !function(e,n,r){e.acf_relationship_create={parse_query_string:function(e){var n=e.replace(/^[^\?]+\??/,""),r={};if(!n)return r;for(var i=n.split(/[;&]/),t=0;t<i.length;t++){var a=i[t].split("=");if(a&&2==a.length){var d=decodeURI(a[0]),f=decodeURI(a[1]);f=f.replace(/\+/g," "),r[d]=f}}return r},generate_random_id:function(){return Math.random().toString(36).substr(2,18)},get_parent_jQuery:function(){return"undefined"!=typeof e.parent.window.jQuery&&e.parent.window.jQuery},get_parent_iframe:function(){if("undefined"==typeof e.parent)return!1;if(e.parent.window===e)return!1;var n=this.get_parent_jQuery();if(!n)return!1;var r=n("body #TB_window iframe");return 1==r.length&&r},get_parent_acf_field_identifier:function(){var e=this.get_parent_iframe();if(!e)return!1;var n=this.parse_query_string(e.attr("src"));return"undefined"!=typeof n.acf_rc_original_field_uniqid&&n.acf_rc_original_field_uniqid},hide_admin_bar:function(){n("#wpadminbar").hide(),n("html").css("padding-top",0)},hide_admin_menu:function(){n("#adminmenumain").hide(),n("#wpcontent, #wpfooter").css("margin-left",0)}}}(window,jQuery); 
     1!function(e,n,t){e.acf_relationship_create={parse_query_string:function(e){var n=e.replace(/^[^\?]+\??/,""),t={};if(!n)return t;for(var r=n.split(/[;&]/),i=0;i<r.length;i++){var a=r[i].split("=");if(a&&2==a.length){var _=decodeURI(a[0]),f=decodeURI(a[1]);f=f.replace(/\+/g," "),t[_]=f}}return t},generate_random_id:function(){return Math.random().toString(36).substr(2,18)},get_parent_jQuery:function(){return"undefined"!=typeof e.parent.window.jQuery&&e.parent.window.jQuery},get_parent_iframe:function(){if("undefined"==typeof e.parent)return!1;if(e.parent.window===e)return!1;var n=this.get_parent_jQuery();if(!n)return!1;var t=n("body #TB_window iframe");return 1==t.length&&t},get_parent_acf_field_identifier:function(){var e=this.get_parent_iframe();if(!e)return!1;var n=this.parse_query_string(e.attr("src"));return"undefined"!=typeof n.acf_rc_original_field_uniqid&&n.acf_rc_original_field_uniqid},hide_admin_bar:function(){n("#wpadminbar").hide(),n("html").css("padding-top",0)},hide_admin_menu:function(){n("#adminmenumain").hide(),n("#wpcontent, #wpfooter").css("margin-left",0)},get_post_type_label:function(n){return"undefined"==typeof e.acf_relationship_create_field?"":"undefined"==typeof e.acf_relationship_create_field.post_types_labels?"":"undefined"==typeof e.acf_relationship_create_field.post_types_labels[n]?"":e.acf_relationship_create_field.post_types_labels[n]}}}(window,jQuery); 
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/languages/acf-relationship-create-fr_FR.po

    r1462110 r1495181  
    11msgid "" 
    22msgstr "" 
    3 "Project-Id-Version: Advanced Custom Fields Relationship Create - For ACF " 
    4 "free version\n" 
     3"Project-Id-Version: Quick and easy Post creation for ACF Relationship Fields\n" 
    54"Report-Msgid-Bugs-To: \n" 
    6 "POT-Creation-Date: Mon Jul 11 2016 17:51:01 GMT+0200 (CEST)\n" 
    7 "PO-Revision-Date: Thu Jul 28 2016 11:47:48 GMT+0200 (CEST)\n" 
     5"POT-Creation-Date: Tue Sep 13 2016 14:55:45 GMT+0200 (CEST)\n" 
     6"PO-Revision-Date: Tue Sep 13 2016 15:26:39 GMT+0200 (CEST)\n" 
    87"Last-Translator: bazalt <contact@bazalt.fr>\n" 
    98"Language-Team: \n" 
     
    4241msgstr "" 
    4342 
     43#: ../acf-relationship-create.php:243 
     44msgid "(No title)" 
     45msgstr "(Aucun titre)" 
     46 
     47#: ../acf-relationship-create.php:115 
     48msgid "You are using the PRO version of Advanced Custom Fields plugin." 
     49msgstr "You utilisez la version PRO du plugin Advanced Custom Fields." 
     50 
    4451#: ../acf-relationship-create.php:116 
    4552msgid "" 
     
    5057"creation for ACF Relationship Fields` !" 
    5158 
    52 #: ../acf-relationship-create.php:115 
    53 msgid "You are using the PRO version of Advanced Custom Fields plugin." 
    54 msgstr "You utilisez la version PRO du plugin Advanced Custom Fields." 
    55  
    5659#: ../acf-relationship-create.php:117 
    5760msgid "Download the PRO version" 
    5861msgstr "Téléchargez la version PRO" 
    5962 
    60 #: ../acf-relationship-create.php:303 
     63#: ../acf-relationship-create.php:319 
    6164msgid "Create" 
    6265msgstr "Créer" 
    6366 
    64 #: ../acf-relationship-create.php:315 
     67#: ../acf-relationship-create.php:331 
    6568#, php-format 
    6669msgid "Create new %s" 
    6770msgstr "Créer un nouveau %s" 
    6871 
    69 #: ../acf-relationship-create.php:344 
     72#: ../acf-relationship-create.php:360 
    7073msgid "Display a link to create content on the fly?" 
    7174msgstr "Afficher un bouton pour créer un contenu à la volée ?" 
    7275 
    73 #: ../acf-relationship-create.php:354 
     76#: ../acf-relationship-create.php:370 
    7477msgid "No" 
    7578msgstr "Non" 
    7679 
    77 #: ../acf-relationship-create.php:355 
     80#: ../acf-relationship-create.php:371 
    7881msgid "Yes" 
    7982msgstr "Oui" 
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/readme.txt

    r1476431 r1495181  
    22Contributors: cyrilbatillat 
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LU5K2FXVMYCUS 
    4 Tags:  acf, advanced custom fields, relationship, field, post creation, shortcut, workflow, admin, administration 
     4Tags:  acf, advanced custom fields, relationship, post object, field, post creation, shortcut, workflow, admin, administration 
    55Requires at least: 4.5 
    66Tested up to: 4.6 
     
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    1010 
    11 Quick & Easy Post creation on your Advanced Custom Fields (ACF) Relationship Fields 
     11Quick & Easy Post creation on your Advanced Custom Fields (ACF) 'Relationship' & 'Post Object' Fields 
    1212 
    1313== Description == 
     
    1515This plugin is a excellent companion of ACF (Advanced Custom Fields). 
    1616 
    17 When dealing with relationship fields (which links a post to one or multiple other posts), you often stumble on having to link to a post that does not exist yet. This is a frustrating and time-consuming experience: you have to save the content you were working on, then create the new post, and finally reload your primary content to be able to link to the newly created post. 
     17When dealing with 'Relationship' or 'Post Object' fields (which links a post to one or multiple other posts), you often stumble on having to link to a post that does not exist yet. This is a frustrating and time-consuming experience: you have to save the content you were working on, then create the new post, and finally reload your primary content to be able to link to the newly created post. 
    1818 
    1919This plugin simplifies this process by allowing you to create the related posts on the fly. 
     
    3232 
    3333= Support = 
    34 Please use the dedicated forum for any bug or improvement suggestion. 
     34Please use [the dedicated forum](https://wordpress.org/support/plugin/quick-and-easy-post-creation-for-acf-relationship-fields) for any bug or improvement suggestion. 
    3535 
    3636== Installation == 
     
    8282== Screenshots == 
    8383 
    84 1. Enable post creation on your Relationship Field, in ACF settings 
     841. Enable post creation on your 'Relationship' or 'Post Object' Field, in ACF settings 
    8585 
    86862. Notice the button that allows you to create a new content (in this case, a new album) 
     
    9292 
    9393== Changelog == 
     94 
     95= 2.0 = 
     96* Now supporting 'Post Object' fields ! :) 
     97* Fix CSS bugs in tooltip positioning 
    9498 
    9599= 1.2 = 
Note: See TracChangeset for help on using the changeset viewer.