PluginProbe
Polylang / trunk
Polylang vtrunk
3.8.10 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 All 234 releases
← All changes | src/translatable-object.php +5 -41 3.8.10 → trunk View file →
@@ -245,9 +245,9 @@
245 245 * @return bool True when successfully assigned. False otherwise (or if the given language is already assigned to
246 246 * the object).
247 247 */
248 248 public function set_language( $id, $lang ) {
249 - $id = $this->sanitize_int_id( $id );
249 + $id = pll_sanitize_id( $id );
250 250
251 251 if ( empty( $id ) ) {
252 252 return false;
253 253 }
@@ -279,9 +279,9 @@
279 279 * @return PLL_Language|false A `PLL_Language` object. `false` if no language is associated to that object or if the
280 280 * ID is invalid.
281 281 */
282 282 public function get_language( $id ) {
283 - $id = $this->sanitize_int_id( $id );
283 + $id = pll_sanitize_id( $id );
284 284
285 285 if ( empty( $id ) ) {
286 286 return false;
287 287 }
@@ -304,9 +304,9 @@
304 304 * @param int $id Term ID.
305 305 * @return void
306 306 */
307 307 public function delete_language( $id ) {
308 - $id = $this->sanitize_int_id( $id );
308 + $id = pll_sanitize_id( $id );
309 309
310 310 if ( empty( $id ) ) {
311 311 return;
312 312 }
@@ -323,9 +323,9 @@
323 323 * @param string $taxonomy Taxonomy name.
324 324 * @return array<int,WP_Term> Array of terms with object ID as key.
325 325 */
326 326 protected function get_object_terms( array $object_ids, string $taxonomy ) {
327 - $object_ids = $this->sanitize_int_ids_list( $object_ids );
327 + $object_ids = pll_sanitize_ids( $object_ids );
328 328 if ( empty( $object_ids ) ) {
329 329 return array();
330 330 }
331 331
@@ -534,9 +534,9 @@
534 534 }
535 535
536 536 $object_ids = $this->query_objects_with_no_lang( $language_ids, $limit, $args );
537 537
538 - return array_values( $this->sanitize_int_ids_list( $object_ids ) );
538 + return array_values( pll_sanitize_ids( $object_ids ) );
539 539 }
540 540
541 541 /**
542 542 * Returns object IDs without language.
@@ -566,44 +566,8 @@
566 566 $object_ids = $this->get_raw_objects_with_no_lang( $language_ids, $limit, $args );
567 567 $this->set_to_cache( $key, $object_ids );
568 568
569 569 return $object_ids;
570 - }
571 -
572 - /**
573 - * Sanitizes an ID as positive integer.
574 - * Kind of similar to `absint()`, but rejects negative integers instead of making them positive.
575 - *
576 - * @since 3.2
577 - *
578 - * @param mixed $id A supposedly numeric ID.
579 - * @return int A positive integer. `0` for non numeric values and negative integers.
580 - *
581 - * @phpstan-return int<0,max>
582 - */
583 - public function sanitize_int_id( $id ) {
584 - return is_numeric( $id ) && $id >= 1 ? abs( (int) $id ) : 0;
585 - }
586 -
587 - /**
588 - * Sanitizes an array of IDs as positive integers.
589 - * `0` values are removed.
590 - *
591 - * @since 3.2
592 - *
593 - * @param mixed $ids An array of numeric IDs.
594 - * @return int[]
595 - *
596 - * @phpstan-return array<positive-int>
597 - */
598 - public function sanitize_int_ids_list( $ids ) {
599 - if ( empty( $ids ) || ! is_array( $ids ) ) {
600 - return array();
601 - }
602 -
603 - $ids = array_map( array( $this, 'sanitize_int_id' ), $ids );
604 -
605 - return array_filter( $ids );
606 570 }
607 571
608 572 /**
609 573 * Fetches the IDs of the objects without language.