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 | modules/sync/admin-sync.php +14 -34 2.7.12.5 View file →
@@ -33,16 +33,10 @@
33 33 * @param array $postarr Array of parsed post data
34 34 * @return int
35 35 */
36 36 public function wp_insert_post_parent( $post_parent, $post_id, $postarr ) {
37 - if ( isset( $_GET['from_post'], $_GET['new_lang'], $_GET['post_type'] ) ) {
38 - check_admin_referer( 'new-post-translation' );
39 - // Make sure not to impact media translations created at the same time
40 - if ( $_GET['post_type'] === $postarr['post_type'] && ( $id = wp_get_post_parent_id( (int) $_GET['from_post'] ) ) && $parent = $this->model->post->get_translation( $id, sanitize_key( $_GET['new_lang'] ) ) ) {
41 - $post_parent = $parent;
42 - }
43 - }
44 - return $post_parent;
37 + // Make sure not to impact media translations created at the same time
38 + return isset( $_GET['from_post'], $_GET['new_lang'], $_GET['post_type'] ) && $_GET['post_type'] === $postarr['post_type'] && ( $id = wp_get_post_parent_id( (int) $_GET['from_post'] ) ) && ( $parent = $this->model->post->get_translation( $id, $_GET['new_lang'] ) ) ? $parent : $post_parent;
45 39 }
46 40
47 41 /**
48 42 * Copy menu order, comment, ping status and optionally the date when creating a new tanslation
@@ -53,10 +47,8 @@
53 47 * @return array
54 48 */
55 49 public function wp_insert_post_data( $data ) {
56 50 if ( isset( $GLOBALS['pagenow'], $_GET['from_post'], $_GET['new_lang'] ) && 'post-new.php' === $GLOBALS['pagenow'] && $this->model->is_translated_post_type( $data['post_type'] ) ) {
57 - check_admin_referer( 'new-post-translation' );
58 -
59 51 $from_post_id = (int) $_GET['from_post'];
60 52 $from_post = get_post( $from_post_id );
61 53
62 54 foreach ( array( 'menu_order', 'comment_status', 'ping_status' ) as $property ) {
@@ -63,9 +55,9 @@
63 55 $data[ $property ] = $from_post->$property;
64 56 }
65 57
66 58 // Copy the date only if the synchronization is activated
67 - if ( in_array( 'post_date', $this->options['sync'] ) ) {
59 + if ( in_array( 'post_date', PLL()->options['sync'] ) ) {
68 60 $data['post_date'] = $from_post->post_date;
69 61 $data['post_date_gmt'] = $from_post->post_date_gmt;
70 62 }
71 63 }
@@ -82,13 +74,11 @@
82 74 global $post;
83 75 static $done = array();
84 76
85 77 if ( isset( $GLOBALS['pagenow'], $_GET['from_post'], $_GET['new_lang'] ) && 'post-new.php' === $GLOBALS['pagenow'] && $this->model->is_translated_post_type( $post->post_type ) ) {
86 - check_admin_referer( 'new-post-translation' );
87 -
88 78 // Capability check already done in post-new.php
89 79 $from_post_id = (int) $_GET['from_post'];
90 - $lang = $this->model->get_language( sanitize_key( $_GET['new_lang'] ) );
80 + $lang = $this->model->get_language( $_GET['new_lang'] );
91 81
92 82 if ( ! $from_post_id || ! $lang || ! empty( $done[ $from_post_id ] ) ) {
93 83 return;
94 84 }
@@ -118,10 +108,8 @@
118 108 $postarr = parent::get_fields_to_sync( $post );
119 109
120 110 // For new drafts, save the date now otherwise it is overriden by WP. Thanks to JoryHogeveen. See #32.
121 111 if ( in_array( 'post_date', $this->options['sync'] ) && isset( $GLOBALS['pagenow'], $_GET['from_post'], $_GET['new_lang'] ) && 'post-new.php' === $GLOBALS['pagenow'] ) {
122 - check_admin_referer( 'new-post-translation' );
123 -
124 112 unset( $postarr['post_date'] );
125 113 unset( $postarr['post_date_gmt'] );
126 114
127 115 $original = get_post( (int) $_GET['from_post'] );
@@ -137,9 +125,9 @@
137 125
138 126 if ( isset( $GLOBALS['post_type'] ) ) {
139 127 $post_type = $GLOBALS['post_type'];
140 128 } elseif ( isset( $_REQUEST['post_type'] ) ) {
141 - $post_type = sanitize_key( $_REQUEST['post_type'] ); // 2nd case for quick edit
129 + $post_type = $_REQUEST['post_type']; // 2nd case for quick edit
142 130 }
143 131
144 132 // Make sure not to impact media translations when creating them at the same time as post
145 133 if ( in_array( 'post_parent', $this->options['sync'] ) && ( ! isset( $post_type ) || $post_type !== $post->post_type ) ) {
@@ -163,9 +151,9 @@
163 151
164 152 // Sticky posts
165 153 if ( in_array( 'sticky_posts', $this->options['sync'] ) ) {
166 154 $stickies = get_option( 'sticky_posts' );
167 - if ( isset( $_REQUEST['sticky'] ) && 'sticky' === $_REQUEST['sticky'] ) { // phpcs:ignore WordPress.Security.NonceVerification
155 + if ( isset( $_REQUEST['sticky'] ) && 'sticky' === $_REQUEST['sticky'] ) {
168 156 $stickies = array_merge( $stickies, array_values( $translations ) );
169 157 } else {
170 158 $stickies = array_diff( $stickies, array_values( $translations ) );
171 159 }
@@ -188,18 +176,18 @@
188 176 $obj = substr( $func, 5 );
189 177
190 178 if ( is_object( $this->$obj ) && method_exists( $this->$obj, 'copy' ) ) {
191 179 if ( WP_DEBUG ) {
192 - $debug = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions
180 + $debug = debug_backtrace();
193 181 $i = 1 + empty( $debug[1]['line'] ); // The file and line are in $debug[2] if the function was called using call_user_func
194 182
195 - trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions
183 + trigger_error(
196 184 sprintf(
197 185 '%1$s was called incorrectly in %3$s on line %4$s: the call to PLL()->sync->%1$s() has been deprecated in Polylang 2.3, use PLL()->sync->%2$s->copy() instead.' . "\nError handler",
198 - esc_html( $func ),
199 - esc_html( $obj ),
200 - esc_html( $debug[ $i ]['file'] ),
201 - absint( $debug[ $i ]['line'] )
186 + $func,
187 + $obj,
188 + $debug[ $i ]['file'],
189 + $debug[ $i ]['line']
202 190 )
203 191 );
204 192 }
205 193 return call_user_func_array( array( $this->$obj, 'copy' ), $args );
@@ -204,16 +192,8 @@
204 192 }
205 193 return call_user_func_array( array( $this->$obj, 'copy' ), $args );
206 194 }
207 195
208 - $debug = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions
209 - trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions
210 - sprintf(
211 - 'Call to undefined function PLL()->sync->%1$s() in %2$s on line %3$s' . "\nError handler",
212 - esc_html( $func ),
213 - esc_html( $debug[0]['file'] ),
214 - absint( $debug[0]['line'] )
215 - ),
216 - E_USER_ERROR
217 - );
196 + $debug = debug_backtrace();
197 + trigger_error( sprintf( 'Call to undefined function PLL()->sync->%1$s() in %2$s on line %3$s' . "\nError handler", $func, $debug[0]['file'], $debug[0]['line'] ), E_USER_ERROR );
218 198 }
219 199 }