• Resolved harbran

    (@harbran)


    I get this warning, when using Recencio together with a plugin called Link Library. However, preg_match() seems to be a PHP function.

    Warning: preg_match() expects parameter 2 to be string, array given in /var/www/wp/htdocs/wp-content/plugins/recencio-book-reviews/admin/class-rcno-reviews-admin.php on line 825

    I tried to limit the input to the first element of the array:
    public function rcno_sort_admin_columns_by_taxonomy( $clauses, $wp_query ) {

    global $wpdb;

    if ( isset( $wp_query->query[‘orderby’] ) && preg_match( ‘/taxonomy-rcno_/’, $wp_query->query[‘orderby’][0] ) ) {
    $taxonomy = str_replace( ‘taxonomy-‘, ”, $wp_query->query[‘orderby’] );

    which removed the warning. No idea, what damage this does elsewhere.

    regards
    harald brandstetter

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Kemory Grubb

    (@w33zy)

    Hello @harbran,
    Thanks for catching this bug.

    Now I am a bit puzzled as to how the orderby param would get a array instead of the taxonomy string the admin columns are being sorted by. Can you share with me the URL of the page with this error?

    Normally it should be similar to

    .../wp-admin/edit.php?post_type=rcno_review&orderby=taxonomy-rcno_author&order=asc

    Thread Starter harbran

    (@harbran)

    Hello @w33zy,
    interestingly, this happens when I call another plugin short code – Link Library. Never seen this happen in other circumstances.

    In my page https://genussfaktor.at/service/links/ I call Link Library by short code [link-library settings=”1″].

    I’m not familiar with the internals of wordpress, so I can’t tell why this is connected to the preg_match() in your code… e.g. how come this error stems from wp-admin when its the front page not the admin?

    When I leave out that short code, the warning does not appear. On the side of preg_amtch it seems clear it does not take and array as second parameter.

    The array is returned by $wp_query->query[‘orderby’] – when i change to $wp_query->query[‘orderby’][0] of course it’s gone.

    Regars
    Harald

    Plugin Author Kemory Grubb

    (@w33zy)

    Hello again @harbran,
    Thanks for following up on this with me. I am going to try installing that plugin to see where the interference is coming from.

    The reason I haven’t implemented your fix is that I am not certain my custom taxonomy string will always be the first element in the orderby array. However I going to try adding another conditional so that my query is limited to rcno pages.

    Plugin Author Kemory Grubb

    (@w33zy)

    Fixed it!
    I was able to recreate the error with shortcode you provided.

    It was fixed by limiting my usages of the posts_clauses filter to my pages. I’ll add this patch to my next update.

    You can try it by adding this check above line 825

    if ( ! is_post_type_archive( 'rcno_review' ) && ! is_blog_admin() ) {
      return $clauses;
    }
    • This reply was modified 6 years, 6 months ago by Kemory Grubb.
    Thread Starter harbran

    (@harbran)

    thank you, that did the trick!
    I removed my hack and it now works!
    Bet regards & have a nice week-end
    Harald

    Plugin Author Kemory Grubb

    (@w33zy)

    You’re welcome

    Off-topic: As a non-vegan who works with a lot of vegan food bloggers, your “vegan free” post had me dying of laughter.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Warning for parameter in preg_match’ is closed to new replies.