Skip to content

Instantly share code, notes, and snippets.

@marushu
Last active October 3, 2016 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marushu/8091071a07b478219b0560ea5705a6f0 to your computer and use it in GitHub Desktop.
Save marushu/8091071a07b478219b0560ea5705a6f0 to your computer and use it in GitHub Desktop.
Add shortcode to ACF specific field. :)
( function( $ ) {
$( '#acf-image_ba td:nth-child(4) input[type="text"]' ).attr({
'readonly': true,
'onclick': 'this.select()',
'title': '選択部分をコピー( ctrl + c )して貼り付けたい部分へペーストします。'
});
$( '#acf-image_ba .acf-button' ).on( 'click', function( event ) {
var target = $( 'td:nth-child(4)' ).find( 'input[type="text"]' );
var targetCount = $(target).length - 1;
var addValue = '[ba_image num="' + targetCount + '"]';
$( target ).eq( targetCount ).attr({
'readonly': true,
'value': addValue,
'onclick': 'this.select()',
'title': '選択部分をコピー( ctrl + c )して貼り付けたい部分へペーストします。'
});
});
var targetElm = $( '#acf-image_ba tbody' );
$( targetElm ).attr( 'id', 'ba_sort' );
$( '#ba_sort' ).sortable({
update: function( event, ui ) {
var trCount = $( '#ba_sort tr' ).not( '.row-clone' ).length;
for ( i = 0; i <= trCount; i++ ) {
var updateTarget = $( '#ba_sort tr' ).eq( i -1 ).find( 'td:nth-child(4) input[type="text"]' );
var addValue = '[ba_image num="' + ( i -1 ) + '"]';
$( updateTarget ).attr({
'value': addValue
});
}
}
});
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment