• Resolved popat123

    (@popat123)


    Hii,

    I am using Sage theme in that when i pass custom parameter in wordpress Default search via url like this “/?s={{9*9}}” it gives output as ‘Search results for “81” ‘ , in this i want to stop that evaluates how can i do that , i am searching for that but could`t find any thing to stop that ??.

    • This topic was modified 3 weeks ago by popat123.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    Either your theme or a plugin is causing {{9*9}} to be evaluated. Probably not your theme, but it’s remotely conceivable it could be. Most likely a plugin. Default behavior is to not evaluate and to search for the string literal '{{9*9}}'.

    Identify what’s responsible for evaluating the math function by deactivating all plugins and switching to a default Twenty* theme for good measure. The search request should no longer be evaluated. You should get something like ‘Search results for “{{9*9}}”‘. Restore your normal theme and plugins, one at a time, testing after each. When the unwanted behavior returns, the last module activated is the cause. Seek advice on how to prevent evaluation through that module’s dedicated support channel.

    Thread Starter popat123

    (@popat123)

    Thanks For Reply @bcworkz

    The issue is being caused by the theme. When I debugged using die(), I got the same value in the variable that I searched for on the page where the content is being rendered. I have not written any code to manipulate that value. However, I am unable to figure out where the value is being evaluated. Any suggestions would be helpful.

    Below is the code for that page:

    @extends('layouts.app')

    @section('content')
    <x-section>
    <x-breadcrumb></x-breadcrumb>
    @include('partials.page-header')

    <header class="flex w-full content-center justify-between">
    @include('partials.search-form', ['postType' => 'post', 'placeholder' => 'Search news'])
    </header>

    @if (!have_posts())
    <x-alert type="default">
    {!! __('Sorry, no results were found.', 'sage') !!}
    </x-alert>
    @endif

    <x-article class="text-white">
    <x-grid
    class="not-prose !mt-12 grid-cols-1 gap-6 gap-y-6 will-change-auto max-sm:relative max-sm:flex max-sm:w-full max-sm:snap-x max-sm:snap-mandatory max-sm:overflow-x-auto max-sm:px-8 md:grid-cols-2 lg:grid-cols-3">
    @while (have_posts())
    @php(the_post())
    @includeFirst(['partials.content-' . get_post_type(), 'partials.content'])
    @endwhile
    </x-grid>
    </x-article>

    <footer class="heir-h2:hidden heir-a:hover:text-amber-400 mt-6">
    {!! the_posts_navigation([
    'prev_text' => '← Prev',
    'next_text' => 'Next →',
    'screen_reader_text' => 'Posts Navigation',
    ]) !!}
    </footer>

    </x-section>
    @endsection

    And this is the breadcrumb code:

    @if (!empty($items))
    <nav class="-mx-2 mb-6 hidden w-full items-center space-x-3 divide-x divide-black py-2 leading-3 xl:flex"
    typeof="BreadcrumbList" aria-label="Breadcrumb" vocab="https://schema.org/">
    @foreach ($items as $item)
    @if (empty($item['url']))
    <span class="cursor-default pl-3">
    {!! $item['label'] !!}
    </span>
    @else
    <span class="pl-3" typeof="ListItem" property="itemListElement">
    <a class="transition-colors hover:text-blue-700" typeof="WebPage" href="{{ $item['url'] }}"
    title="Go to {!! $item['label'] !!}." property="item">
    <span property="name">
    @if ($loop->first)
    @svg('images.icons.x-home', 'w-4 h-4', ['aria-label' => 'Home'])
    @else
    {!! $item['label'] !!}
    @endif
    </span>
    </a>
    <meta property="position" content="{{ $loop->iteration }}">
    </span>
    @endif
    @endforeach
    </nav>
    @endif

    I got the value at {!! $item['label'] !!} as I had searched for in breadcrumb.

    Thank you!

    • This reply was modified 2 weeks, 6 days ago by popat123.
    Moderator bcworkz

    (@bcworkz)

    The syntax used in that code is unfamiliar to me. It’s not normal PHP though there is a striking similarity. I’m guessing this code is pre-processed by some module before it’s passed on to PHP. This pre-processor is likely the reason for the undesired evaluation. Apparently {curly braces} have some special meaning in this scheme. There’s possibly a way to escape these when actual curly braces are what we want. It might be possible to “pre-pre-process” search terms and escape any curly braces found in search terms. I don’t know how they would be escaped, but a \backslash\ is often used to escape characters. It’s a wild guess, but I wonder what you would get if you searched for \{\{9*9\}\}. In normal WP they do nothing, we’d end up with ‘Search results for “\{\{9*9\}\}”‘. YMMV

    Thread Starter popat123

    (@popat123)

    Thanks for reply @bcworkz

    I now understand why it’s being evaluated; it’s due to Vue.js. I sincerely appreciate you for giving time to discuss this topic with me.

    Thank`s

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.