PluginProbe
Polylang / 2.5.2
Polylang v2.5.2
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 +31 -50 3.0.22.5.2 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Manages copy and synchronization of terms and post metas
8 5 *
@@ -61,18 +58,16 @@
61 58
62 59 $from_post_id = (int) $_GET['from_post'];
63 60 $from_post = get_post( $from_post_id );
64 61
65 - if ( $from_post instanceof WP_Post ) {
66 - foreach ( array( 'menu_order', 'comment_status', 'ping_status' ) as $property ) {
67 - $data[ $property ] = $from_post->$property;
68 - }
62 + foreach ( array( 'menu_order', 'comment_status', 'ping_status' ) as $property ) {
63 + $data[ $property ] = $from_post->$property;
64 + }
69 65
70 - // Copy the date only if the synchronization is activated
71 - if ( in_array( 'post_date', $this->options['sync'] ) ) {
72 - $data['post_date'] = $from_post->post_date;
73 - $data['post_date_gmt'] = $from_post->post_date_gmt;
74 - }
66 + // Copy the date only if the synchronization is activated
67 + if ( in_array( 'post_date', $this->options['sync'] ) ) {
68 + $data['post_date'] = $from_post->post_date;
69 + $data['post_date_gmt'] = $from_post->post_date_gmt;
75 70 }
76 71 }
77 72
78 73 return $data;
@@ -81,10 +76,8 @@
81 76 /**
82 77 * Copy post metas, and taxonomies when using "Add new" ( translation )
83 78 *
84 79 * @since 2.5
85 - *
86 - * @return void
87 80 */
88 81 public function new_post_translation() {
89 82 global $post;
90 83 static $done = array();
@@ -111,14 +104,14 @@
111 104 }
112 105 }
113 106
114 107 /**
115 - * Get post fields to synchronize.
108 + * Get post fields to synchronize
116 109 *
117 110 * @since 2.4
118 111 *
119 - * @param WP_Post $post Post object.
120 - * @return array Fields to synchronize.
112 + * @param object $post Post object
113 + * @return array
121 114 */
122 115 protected function get_fields_to_sync( $post ) {
123 116 global $wpdb;
124 117
@@ -131,19 +124,16 @@
131 124 unset( $postarr['post_date'] );
132 125 unset( $postarr['post_date_gmt'] );
133 126
134 127 $original = get_post( (int) $_GET['from_post'] );
135 -
136 - if ( $original instanceof WP_Post ) {
137 - $wpdb->update(
138 - $wpdb->posts,
139 - array(
140 - 'post_date' => $original->post_date,
141 - 'post_date_gmt' => $original->post_date_gmt,
142 - ),
143 - array( 'ID' => $post->ID )
144 - );
145 - }
128 + $wpdb->update(
129 + $wpdb->posts,
130 + array(
131 + 'post_date' => $original->post_date,
132 + 'post_date_gmt' => $original->post_date_gmt,
133 + ),
134 + array( 'ID' => $post->ID )
135 + );
146 136 }
147 137
148 138 if ( isset( $GLOBALS['post_type'] ) ) {
149 139 $post_type = $GLOBALS['post_type'];
@@ -159,15 +149,15 @@
159 149 return $postarr;
160 150 }
161 151
162 152 /**
163 - * Synchronizes post fields in translations.
153 + * Synchronizes post fields in translations
164 154 *
165 155 * @since 1.2
166 156 *
167 - * @param int $post_id Post id.
168 - * @param WP_Post $post Post object.
169 - * @param int[] $translations Post translations.
157 + * @param int $post_id post id
158 + * @param object $post post object
159 + * @param array $translations post translations
170 160 */
171 161 public function pll_save_post( $post_id, $post, $translations ) {
172 162 parent::pll_save_post( $post_id, $post, $translations );
173 163
@@ -173,9 +163,9 @@
173 163
174 164 // Sticky posts
175 165 if ( in_array( 'sticky_posts', $this->options['sync'] ) ) {
176 166 $stickies = get_option( 'sticky_posts' );
177 - if ( isset( $_REQUEST['sticky'] ) && 'sticky' === $_REQUEST['sticky'] ) { // phpcs:ignore WordPress.Security.NonceVerification
167 + if ( isset( $_REQUEST['sticky'] ) && 'sticky' === $_REQUEST['sticky'] ) {
178 168 $stickies = array_merge( $stickies, array_values( $translations ) );
179 169 } else {
180 170 $stickies = array_diff( $stickies, array_values( $translations ) );
181 171 }
@@ -192,9 +182,8 @@
192 182 * @since 2.3
193 183 *
194 184 * @param string $func Function name
195 185 * @param array $args Function arguments
196 - * @return mixed|void
197 186 */
198 187 public function __call( $func, $args ) {
199 188 $obj = substr( $func, 5 );
200 189
@@ -199,18 +188,18 @@
199 188 $obj = substr( $func, 5 );
200 189
201 190 if ( is_object( $this->$obj ) && method_exists( $this->$obj, 'copy' ) ) {
202 191 if ( WP_DEBUG ) {
203 - $debug = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions
192 + $debug = debug_backtrace();
204 193 $i = 1 + empty( $debug[1]['line'] ); // The file and line are in $debug[2] if the function was called using call_user_func
205 194
206 - trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions
195 + trigger_error(
207 196 sprintf(
208 197 '%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",
209 - esc_html( $func ),
210 - esc_html( $obj ),
211 - esc_html( $debug[ $i ]['file'] ),
212 - absint( $debug[ $i ]['line'] )
198 + $func,
199 + $obj,
200 + $debug[ $i ]['file'],
201 + $debug[ $i ]['line']
213 202 )
214 203 );
215 204 }
216 205 return call_user_func_array( array( $this->$obj, 'copy' ), $args );
@@ -215,16 +204,8 @@
215 204 }
216 205 return call_user_func_array( array( $this->$obj, 'copy' ), $args );
217 206 }
218 207
219 - $debug = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions
220 - trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions
221 - sprintf(
222 - 'Call to undefined function PLL()->sync->%1$s() in %2$s on line %3$s' . "\nError handler",
223 - esc_html( $func ),
224 - esc_html( $debug[0]['file'] ),
225 - absint( $debug[0]['line'] )
226 - ),
227 - E_USER_ERROR
228 - );
208 + $debug = debug_backtrace();
209 + 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 );
229 210 }
230 211 }