PluginProbe
Polylang / 2.5
Polylang v2.5
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | js/post.js +77 -134 2.82.5 View file →
@@ -1,161 +1,104 @@
1 -/**
2 - * @package Polylang
3 - */
4 -
5 -/**
6 - * Tag suggest in quick edit
7 - */
1 +// tag suggest in quick edit
8 2 (function( $ ){
9 - $.ajaxPrefilter(
10 - function( options, originalOptions, jqXHR ) {
11 - if ( 'string' === typeof options.data && -1 !== options.data.indexOf( 'action=ajax-tag-search' ) && ( lang = $( ':input[name="inline_lang_choice"]' ).val() ) ) {
12 - options.data = 'lang=' + lang + '&' + options.data;
13 - }
3 + $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
4 + if ( 'string' === typeof options.data && -1 !== options.data.indexOf( 'action=ajax-tag-search' ) && ( lang = $( ':input[name="inline_lang_choice"]' ).val() ) ) {
5 + options.data = 'lang=' + lang + '&' + options.data;
14 6 }
15 - );
7 + });
16 8 })( jQuery );
17 9
18 -/**
19 - * Quick edit
20 - */
10 +// quick edit
21 11 (function( $ ) {
22 - $( document ).bind(
23 - 'DOMNodeInserted',
24 - function( e ) {
25 - var t = $( e.target );
12 + $( document ).bind( 'DOMNodeInserted', function( e ) {
13 + var t = $( e.target );
26 14
27 - // WP inserts the quick edit from
28 - if ( 'inline-edit' == t.attr( 'id' ) ) {
29 - var post_id = t.prev().attr( 'id' ).replace( "post-", "" );
15 + // WP inserts the quick edit from
16 + if ( 'inline-edit' == t.attr( 'id' ) ) {
17 + var post_id = t.prev().attr( 'id' ).replace( "post-", "" );
30 18
31 - if ( post_id > 0 ) {
32 - // language dropdown
33 - var select = t.find( ':input[name="inline_lang_choice"]' );
34 - var lang = $( '#lang_' + post_id ).html();
35 - select.val( lang ); // populates the dropdown
19 + if ( post_id > 0 ) {
20 + // language dropdown
21 + var select = t.find( ':input[name="inline_lang_choice"]' );
22 + var lang = $( '#lang_' + post_id ).html();
23 + select.val( lang ); // populates the dropdown
36 24
37 - filter_terms( lang ); // initial filter for category checklist
38 - filter_pages( lang ); // initial filter for parent dropdown
25 + filter_terms( lang ); // initial filter for category checklist
26 + filter_pages( lang ); // initial filter for parent dropdown
39 27
40 - // modify category checklist an parent dropdown on language change
41 - select.change(
42 - function() {
43 - filter_terms( $( this ).val() );
44 - filter_pages( $( this ).val() );
45 - }
46 - );
47 - }
28 + // modify category checklist an parent dropdown on language change
29 + select.change(function() {
30 + filter_terms( $( this ).val() );
31 + filter_pages( $( this ).val() );
32 + });
48 33 }
34 + }
49 35
50 - // filter category checklist
51 - function filter_terms( lang ) {
52 - if ( "undefined" != typeof( pll_term_languages ) ) {
53 - $.each(
54 - pll_term_languages,
55 - function( lg, term_tax ) {
56 - $.each(
57 - term_tax,
58 - function( tax, terms ) {
59 - $.each(
60 - terms,
61 - function( i ) {
62 - id = '#' + tax + '-' + pll_term_languages[ lg ][ tax ][ i ];
63 - lang == lg ? $( id ).show() : $( id ).hide();
64 - }
65 - );
66 - }
67 - );
68 - }
69 - );
70 - }
36 + // filter category checklist
37 + function filter_terms( lang ) {
38 + if ( "undefined" != typeof( pll_term_languages ) ) {
39 + $.each( pll_term_languages, function( lg, term_tax ) {
40 + $.each( term_tax, function( tax, terms ) {
41 + $.each( terms, function( i ) {
42 + id = '#' + tax + '-' + pll_term_languages[ lg ][ tax ][ i ];
43 + lang == lg ? $( id ).show() : $( id ).hide();
44 + });
45 + });
46 + });
71 47 }
48 + }
72 49
73 - // filter parent page dropdown list
74 - function filter_pages( lang ) {
75 - if ( "undefined" != typeof( pll_page_languages ) ) {
76 - $.each(
77 - pll_page_languages,
78 - function( lg, pages ) {
79 - $.each(
80 - pages,
81 - function( i ) {
82 - v = $( '#post_parent option[value="' + pll_page_languages[ lg ][ i ] + '"]' );
83 - lang == lg ? v.show() : v.hide();
84 - }
85 - );
86 - }
87 - );
88 - }
50 + // filter parent page dropdown list
51 + function filter_pages( lang ) {
52 + if ( "undefined" != typeof( pll_page_languages ) ) {
53 + $.each( pll_page_languages, function( lg, pages ) {
54 + $.each( pages, function( i ) {
55 + v = $( '#post_parent option[value="' + pll_page_languages[ lg ][ i ] + '"]' );
56 + lang == lg ? v.show() : v.hide();
57 + });
58 + });
89 59 }
90 60 }
91 - );
61 + });
92 62 })( jQuery );
93 63
94 -/**
95 - * Update rows of translated posts when the language is modified in quick edit
96 - * Acts on ajaxSuccess event
97 - */
64 +// update rows of translated posts when the language is modified in quick edit
65 +// acts on ajaxSuccess event
98 66 (function( $ ) {
99 - $( document ).ajaxSuccess(
100 - function( event, xhr, settings ) {
101 - function update_rows( post_id ) {
102 - // collect old translations
103 - var translations = new Array();
104 - $( '.translation_' + post_id ).each(
105 - function() {
106 - translations.push( $( this ).parent().parent().attr( 'id' ).substring( 5 ) );
107 - }
108 - );
67 + $( document ).ajaxSuccess(function( event, xhr, settings ) {
68 + function update_rows( post_id ) {
69 + // collect old translations
70 + var translations = new Array;
71 + $( '.translation_' + post_id ).each(function() {
72 + translations.push( $( this ).parent().parent().attr( 'id' ).substring( 5 ) );
73 + });
109 74
110 - var data = {
111 - action: 'pll_update_post_rows',
112 - post_id: post_id,
113 - translations: translations.join( ',' ),
114 - post_type: $( "input[name='post_type']" ).val(),
115 - screen: $( "input[name='screen']" ).val(),
116 - _pll_nonce: $( "input[name='_inline_edit']" ).val() // reuse quick edit nonce
117 - };
75 + var data = {
76 + action: 'pll_update_post_rows',
77 + post_id: post_id,
78 + translations: translations.join( ',' ),
79 + post_type: $( "input[name='post_type']" ).val(),
80 + screen: $( "input[name='screen']" ).val(),
81 + _pll_nonce: $( "input[name='_inline_edit']" ).val() // reuse quick edit nonce
82 + }
118 83
119 - // get the modified rows in ajax and update them
120 - $.post(
121 - ajaxurl,
122 - data,
123 - function( response ) {
124 - if ( response ) {
125 - var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
126 - $.each(
127 - res.responses,
128 - function() {
129 - if ( 'row' == this.what ) {
130 - $( "#post-" + this.supplemental.post_id ).replaceWith( this.data );
131 - }
132 - }
133 - );
84 + // get the modified rows in ajax and update them
85 + $.post( ajaxurl, data, function( response ) {
86 + if ( response ) {
87 + var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
88 + $.each( res.responses, function() {
89 + if ( 'row' == this.what ) {
90 + $( "#post-" + this.supplemental.post_id ).replaceWith( this.data );
134 91 }
135 - }
136 - );
137 - }
138 -
139 - if ( 'string' == typeof( settings.data ) ) { // Need to check the type due to block editor sometime sending FormData objects
140 - var data = wpAjax.unserialize( settings.data ); // what were the data sent by the ajax request?
141 - if ( 'undefined' != typeof( data['action'] ) && 'inline-save' == data['action'] ) {
142 - update_rows( data['post_ID'] );
92 + });
143 93 }
144 - }
94 + });
145 95 }
146 - );
147 -})( jQuery );
148 96
149 -/**
150 - * Media list table
151 - * When clicking on attach link, filters find post list per media language
152 - */
153 -(function( $ ){
154 - $.ajaxPrefilter(
155 - function ( options, originalOptions, jqXHR ) {
156 - if ( 'string' === typeof options.data && -1 !== options.data.indexOf( 'action=find_posts' ) ) {
157 - options.data = 'pll_post_id=' + $( '#affected' ).val() + '&' + options.data;
97 + if ( 'string' == typeof( settings.data ) ) { // Need to check the type due to Gutenberg sometime sending FormData objects
98 + var data = wpAjax.unserialize( settings.data ); // what were the data sent by the ajax request?
99 + if ( 'undefined' != typeof( data['action'] ) && 'inline-save' == data['action'] ) {
100 + update_rows( data['post_ID'] );
158 101 }
159 102 }
160 - );
103 + });
161 104 })( jQuery );