| @@ -181,9 +181,8 @@ | ||
| 181 | 181 | $this->cache->set( 'language:' . $lang->term_id, $lang ); |
| 182 | 182 | $this->cache->set( 'language:' . $lang->tl_term_id, $lang ); |
| 183 | 183 | $this->cache->set( 'language:' . $lang->slug, $lang ); |
| 184 | 184 | $this->cache->set( 'language:' . $lang->locale, $lang ); |
| 185 | - $this->cache->set( 'language:' . $lang->w3c, $lang ); | |
| 186 | 185 | } |
| 187 | 186 | $return = $this->cache->get( 'language:' . $value ); |
| 188 | 187 | } |
| 189 | 188 | |
| @@ -385,9 +384,9 @@ | ||
| 385 | 384 | $lang = $this->get_language( $lang ); |
| 386 | 385 | |
| 387 | 386 | // create a new category |
| 388 | 387 | // FIXME this is translated in admin language when we would like it in $lang |
| 389 | - $cat_name = __( 'Uncategorized', 'polylang' ); | |
| 388 | + $cat_name = __( 'Uncategorized' ); | |
| 390 | 389 | $cat_slug = sanitize_title( $cat_name . '-' . $lang->slug ); |
| 391 | 390 | $cat = wp_insert_term( $cat_name, 'category', array( 'slug' => $cat_slug ) ); |
| 392 | 391 | |
| 393 | 392 | // check that the category was not previously created ( in case the language was deleted and recreated ) |
| @@ -427,9 +426,8 @@ | ||
| 427 | 426 | public function term_exists( $term_name, $taxonomy, $parent, $language ) { |
| 428 | 427 | global $wpdb; |
| 429 | 428 | |
| 430 | 429 | $term_name = trim( wp_unslash( $term_name ) ); |
| 431 | - $term_name = _wp_specialchars( $term_name ); | |
| 432 | 430 | |
| 433 | 431 | $select = "SELECT t.term_id FROM $wpdb->terms AS t"; |
| 434 | 432 | $join = " INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id"; |
| 435 | 433 | $join .= $this->term->join_clause(); |
| @@ -444,20 +442,20 @@ | ||
| 444 | 442 | return $wpdb->get_var( $select . $join . $where ); |
| 445 | 443 | } |
| 446 | 444 | |
| 447 | 445 | /** |
| 448 | - * Gets the number of posts per language in a date, author or post type archive. | |
| 446 | + * Gets the number of posts per language in a date, author or post type archive | |
| 449 | 447 | * |
| 450 | 448 | * @since 1.2 |
| 451 | 449 | * |
| 452 | - * @param object $lang PLL_Language instance. | |
| 453 | - * @param array $q WP_Query arguments ( accepted: post_type, m, year, monthnum, day, author, author_name, post_format, post_status ). | |
| 450 | + * @param object $lang | |
| 451 | + * @param array $q WP_Query arguments ( accepted: post_type, m, year, monthnum, day, author, author_name, post_format ) | |
| 454 | 452 | * @return int |
| 455 | 453 | */ |
| 456 | 454 | public function count_posts( $lang, $q = array() ) { |
| 457 | 455 | global $wpdb; |
| 458 | 456 | |
| 459 | - $q = wp_parse_args( $q, array( 'post_type' => 'post', 'post_status' => 'publish' ) ); | |
| 457 | + $q = wp_parse_args( $q, array( 'post_type' => 'post' ) ); | |
| 460 | 458 | |
| 461 | 459 | if ( ! is_array( $q['post_type'] ) ) { |
| 462 | 460 | $q['post_type'] = array( $q['post_type'] ); |
| 463 | 461 | } |
| @@ -468,18 +466,18 @@ | ||
| 468 | 466 | } |
| 469 | 467 | } |
| 470 | 468 | |
| 471 | 469 | if ( empty( $q['post_type'] ) ) { |
| 472 | - $q['post_type'] = array( 'post' ); // We *need* a post type. | |
| 470 | + $q['post_type'] = array( 'post' ); // we *need* a post type | |
| 473 | 471 | } |
| 474 | 472 | |
| 475 | - $cache_key = 'pll_count_posts_' . md5( maybe_serialize( $q ) ); | |
| 476 | - $counts = wp_cache_get( $cache_key, 'counts' ); | |
| 473 | + $cache_key = md5( serialize( $q ) ); | |
| 474 | + $counts = wp_cache_get( $cache_key, 'pll_count_posts' ); | |
| 477 | 475 | |
| 478 | 476 | if ( false === $counts ) { |
| 479 | 477 | $select = "SELECT pll_tr.term_taxonomy_id, COUNT( * ) AS num_posts FROM {$wpdb->posts}"; |
| 480 | 478 | $join = $this->post->join_clause(); |
| 481 | - $where = sprintf( " WHERE post_status = '%s'", esc_sql( $q['post_status'] ) ); | |
| 479 | + $where = " WHERE post_status = 'publish'"; | |
| 482 | 480 | $where .= sprintf( " AND {$wpdb->posts}.post_type IN ( '%s' )", join( "', '", esc_sql( $q['post_type'] ) ) ); |
| 483 | 481 | $where .= $this->post->where_clause( $this->get_languages_list() ); |
| 484 | 482 | $groupby = ' GROUP BY pll_tr.term_taxonomy_id'; |
| 485 | 483 | |
| @@ -516,9 +514,9 @@ | ||
| 516 | 514 | if ( ! empty( $q['author'] ) ) { |
| 517 | 515 | $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_author = %d", $q['author'] ); |
| 518 | 516 | } |
| 519 | 517 | |
| 520 | - // Filtered taxonomies ( post_format ). | |
| 518 | + // filtered taxonomies ( post_format ) | |
| 521 | 519 | foreach ( $this->get_filtered_taxonomies_query_vars() as $tax_qv ) { |
| 522 | 520 | |
| 523 | 521 | if ( ! empty( $q[ $tax_qv ] ) ) { |
| 524 | 522 | $join .= " INNER JOIN {$wpdb->term_relationships} AS tr ON tr.object_id = {$wpdb->posts}.ID"; |
| @@ -533,9 +531,9 @@ | ||
| 533 | 531 | foreach ( (array) $res as $row ) { |
| 534 | 532 | $counts[ $row['term_taxonomy_id'] ] = $row['num_posts']; |
| 535 | 533 | } |
| 536 | 534 | |
| 537 | - wp_cache_set( $cache_key, $counts, 'counts' ); | |
| 535 | + wp_cache_set( $cache_key, $counts, 'pll_count_posts' ); | |
| 538 | 536 | } |
| 539 | 537 | |
| 540 | 538 | return empty( $counts[ $lang->term_taxonomy_id ] ) ? 0 : $counts[ $lang->term_taxonomy_id ]; |
| 541 | 539 | } |
| @@ -611,19 +609,19 @@ | ||
| 611 | 609 | } |
| 612 | 610 | |
| 613 | 611 | if ( ! empty( $o ) && is_object( $this->$o ) && method_exists( $this->$o, $f ) ) { |
| 614 | 612 | if ( WP_DEBUG ) { |
| 615 | - $debug = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions | |
| 613 | + $debug = debug_backtrace(); | |
| 616 | 614 | $i = 1 + empty( $debug[1]['line'] ); // the file and line are in $debug[2] if the function was called using call_user_func |
| 617 | 615 | |
| 618 | - trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions | |
| 616 | + trigger_error( | |
| 619 | 617 | sprintf( |
| 620 | 618 | '%1$s was called incorrectly in %4$s on line %5$s: the call to $polylang->model->%1$s() has been deprecated in Polylang 1.8, use PLL()->model->%2$s->%3$s() instead.' . "\nError handler", |
| 621 | - esc_html( $func ), | |
| 622 | - esc_html( $o ), | |
| 623 | - esc_html( $f ), | |
| 624 | - esc_html( $debug[ $i ]['file'] ), | |
| 625 | - absint( $debug[ $i ]['line'] ) | |
| 619 | + $func, | |
| 620 | + $o, | |
| 621 | + $f, | |
| 622 | + $debug[ $i ]['file'], | |
| 623 | + $debug[ $i ]['line'] | |
| 626 | 624 | ) |
| 627 | 625 | ); |
| 628 | 626 | } |
| 629 | 627 | return call_user_func_array( array( $this->$o, $f ), $args ); |
| @@ -628,16 +626,8 @@ | ||
| 628 | 626 | } |
| 629 | 627 | return call_user_func_array( array( $this->$o, $f ), $args ); |
| 630 | 628 | } |
| 631 | 629 | |
| 632 | - $debug = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions | |
| 633 | - trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions | |
| 634 | - sprintf( | |
| 635 | - 'Call to undefined function PLL()->model->%1$s() in %2$s on line %3$s' . "\nError handler", | |
| 636 | - esc_html( $func ), | |
| 637 | - esc_html( $debug[0]['file'] ), | |
| 638 | - absint( $debug[0]['line'] ) | |
| 639 | - ), | |
| 640 | - E_USER_ERROR | |
| 641 | - ); | |
| 630 | + $debug = debug_backtrace(); | |
| 631 | + trigger_error( sprintf( 'Call to undefined function PLL()->model->%1$s() in %2$s on line %3$s' . "\nError handler", $func, $debug[0]['file'], $debug[0]['line'] ), E_USER_ERROR ); | |
| 642 | 632 | } |
| 643 | 633 | } |