PluginProbe
WP Ultimate Post Grid / 2.3
WP Ultimate Post Grid v2.3
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
← All changes | js/admin_post.js +50 -16 1.82.3 View file →
@@ -1,13 +1,14 @@
1 -jQuery('#wpupg_add_custom_image').on('click', function(e) {
2 - e.preventDefault();
1 +jQuery(document).ready(function ($) {
2 + jQuery('#wpupg_add_custom_image').on('click', function(e) {
3 + e.preventDefault();
3 4
4 - var button = jQuery(this);
5 - var input_url = button.parents('#wpupg_form_post').find('#wpupg_custom_image');
6 - var input_id = button.parents('#wpupg_form_post').find('#wpupg_custom_image_id');
5 + var button = jQuery(this);
6 + var input_url = button.parents('#wpupg_form_post').find('#wpupg_custom_image');
7 + var input_id = button.parents('#wpupg_form_post').find('#wpupg_custom_image_id');
7 8
8 - if(typeof wp.media == 'function') {
9 - var custom_uploader = wp.media({
9 + if(typeof wp.media == 'function') {
10 + var custom_uploader = wp.media({
10 11 title: 'Insert Media',
11 12 button: {
12 13 text: 'Set Custom Image'
13 14 },
@@ -12,16 +13,49 @@
12 13 text: 'Set Custom Image'
13 14 },
14 15 multiple: false
15 16 })
16 - .on('select', function() {
17 - var attachment = custom_uploader.state().get('selection').first().toJSON();
18 - input_url.val(attachment.url);
19 - input_id.val(attachment.id);
17 + .on('select', function() {
18 + var attachment = custom_uploader.state().get('selection').first().toJSON();
19 + input_url.val(attachment.url);
20 + input_id.val(attachment.id);
21 + })
22 + .open();
23 + }
24 + });
25 +
26 + jQuery('#wpupg_custom_image').on('keyup change', function() {
27 + jQuery(this).siblings('#wpupg_custom_image_id').val('');
28 + });
29 +
30 + jQuery('.term-custom-image').on('click', '#wpupg_custom_image_button.button-add', function (e) {
31 + console.log(wp.media);
32 + if(typeof wp.media == 'function') {
33 + var custom_uploader = wp.media({
34 + title: wpupg_admin_post.text_add_grid_image,
35 + button: {
36 + text: wpupg_admin_post.text_add_grid_image
37 + },
38 + multiple: false
20 39 })
21 - .open();
22 - }
23 -});
40 + .on('select', function() {
41 + var attachment = custom_uploader.state().get('selection').first().toJSON();
42 + jQuery('#wpupg_custom_image_img').attr('src', attachment.url);
43 + jQuery('#wpupg_custom_image').val(attachment.id);
44 + jQuery('#wpupg_custom_image_button')
45 + .removeClass('button-add')
46 + .addClass('button-remove')
47 + .val(wpupg_admin_post.text_remove_grid_image);
48 + })
49 + .open();
50 + }
51 + });
24 52
25 -jQuery('#wpupg_custom_image').on('keyup change', function() {
26 - jQuery(this).siblings('#wpupg_custom_image_id').val('');
53 + jQuery('.term-custom-image').on('click', '#wpupg_custom_image_button.button-remove', function (e) {
54 + jQuery('#wpupg_custom_image_img').attr('src', '');
55 + jQuery('#wpupg_custom_image').val('');
56 + jQuery('#wpupg_custom_image_button')
57 + .removeClass('button-remove')
58 + .addClass('button-add')
59 + .val(wpupg_admin_post.text_add_grid_image);
60 + });
27 61 });