PageSourceSearch

https://fulltextsearch.org/docs/_next/static/chunks/pages/en/exten…fts_get_sentence_styles-99ce93b18ea2dbb3.js

js fulltextsearch.org collected 2026-09-25 21:08:26 UTC 9,827 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3516],{11536:function(e,s,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/en/extending/filters/wpfts_get_sentence_styles",function(){return n(93769)}])},93769:function(e,s,n){"use strict";n.r(s),n.d(s,{useTOC:function(){return useTOC}});var i=n(85893),t=n(37812),l=n(80390),h=n(38925);function useTOC(e){let s={code:"code",...(0,h.a)()};return[{value:"When Used",id:"when-used",depth:2},{value:"Arguments",id:"arguments",depth:2},{value:"Return Value",id:"return-value",depth:2},{value:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.code,{children:"$sentence_styles"})," Array Structure"]}),id:"sentence_styles-array-structure",depth:2},{value:"Example (Changing the URL Template)",id:"example-changing-the-url-template",depth:2},{value:"Important Notes",id:"important-notes",depth:2}]}s.default=(0,t.c)(function(e){let{toc:s=useTOC(e)}=e,n={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",span:"span",strong:"strong",ul:"ul",...(0,h.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(n.h1,{children:[(0,i.jsx)(n.code,{children:"wpfts_get_sentence_styles"})," (Filter)"]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"wpfts_get_sentence_styles"})," filter in WP Fast Total Search allows developers to modify the sentence styles used for creating Smart Excerpts. Smart Excerpts are text snippets displayed in search results that contain the found keywords. Sentence styles define how these snippets will be formatted, including adding links, headings, and other elements."]}),"\n",(0,i.jsx)(n.h2,{id:s[0].id,children:s[0].value}),"\n",(0,i.jsx)(n.p,{children:"This filter is useful if you need to change how Smart Excerpts are formatted, for example:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Change the format of links to sentences."}),"\n",(0,i.jsx)(n.li,{children:"Add or remove formatting elements, such as headings or captions."}),"\n",(0,i.jsx)(n.li,{children:"Change how keywords are highlighted."}),"\n",(0,i.jsx)(n.li,{children:"Dynamically change styles depending on the context."}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:s[1].id,children:s[1].value}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"$sentence_styles"})," (array): An array of sentence styles. Each element of the array represents a set of settings for a specific sentence type."]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:s[2].id,children:s[2].value}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"$sentence_styles"})," (array): The modified array of sentence styles."]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:s[3].id,children:s[3].value}),"\n",(0,i.jsxs)(n.p,{children:["Each element of the ",(0,i.jsx)(n.code,{children:"$sentence_styles"})," array is an associative array with the following keys:"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"is_on"})," (bool): A flag that enables or disables this style."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"is_regexp"})," (bool): A flag indicating whether to use a regular expression to match the cluster key."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"key_term"})," (string): The cluster key or regular expression to match."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"caption"})," (string): The heading or caption for the sentence. May contain templates such as ",(0,i.jsx)(n.code,{children:"{{post_url}}"}),", ",(0,i.jsx)(n.code,{children:"{{sentence}}"}),", ",(0,i.jsx)(n.code,{children:"{{word}}"}),", ",(0,i.jsx)(n.code,{children:"{{$1}}"}),", etc."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"newline_type"})," (int): The newline type (not used in the current plugin version)."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"url_type"})," (int): The link type for the sentence (0 - no links, 1 - heading only, 2 - words only, 3 - heading and words, 4 - sentence only, 5 - heading and sentence)."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"url_template"})," (string): The URL template for the sentence link. May contain templates."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"class_name"})," (string): The CSS class for the sentence."]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:s[4].id,children:s[4].value}),"\n",(0,i.jsx)(n.pre,{tabIndex:"0","data-language":"php","data-word-wrap":"","data-copy":"",children:(0,i.jsxs)(n.code,{children:[(0,i.jsxs)(n.span,{children:[(0,i.jsx)(n.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"add_filter"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"("}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"'wpfts_get_sentence_styles'"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:", "}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"'change_sentence_url_template'"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:");"})]}),"\n",(0,i.jsx)(n.span,{children:" "}),"\n",(0,i.jsxs)(n.span,{children:[(0,i.jsx)(n.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"function"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:" change_sentence_url_template"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"($sentence_styles) {"})]}),"\n",(0,i.jsxs)(n.span,{children:[(0,i.jsx)(n.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"	foreach"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:" ($sentence_styles "}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"as"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" &"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"$style) { "}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"// & - important, modifying the array by reference"})]}),"\n",(0,i.jsxs)(n.span,{children:[(0,i.jsx)(n.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"		if"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:" ($style["}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"'key_term'"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"] "}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"=="}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" 'post_content'"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:") {"})]}),"\n",(0,i.jsxs)(n.span,{children:[(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"			$style["}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"'url_template'"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"] "}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"="}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" '{{post_url}}#wpfts-sentence-{{sentence_id}}'"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"; "}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"// adds the sentence ID to the URL"})]}),"\n",(0,i.jsx)(n.span,{children:(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"		}"})}),"\n",(0,i.jsx)(n.span,{children:(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"	}"})}),"\n",(0,i.jsxs)(n.span,{children:[(0,i.jsx)(n.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"	return"}),(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:" $sentence_styles;"})]}),"\n",(0,i.jsx)(n.span,{children:(0,i.jsx)(n.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"}"})})]})}),"\n",(0,i.jsx)(n.h2,{id:s[5].id,children:s[5].value}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["The ",(0,i.jsx)(n.code,{children:"wpfts_get_sentence_styles"})," filter is called ",(0,i.jsx)(n.strong,{children:"before"})," creating Smart Excerpts."]}),"\n",(0,i.jsxs)(n.li,{children:["Changes made to the ",(0,i.jsx)(n.code,{children:"$sentence_styles"})," array affect the formatting of all Smart Excerpts on the page."]}),"\n",(0,i.jsxs)(n.li,{children:["Make sure you use templates correctly in the ",(0,i.jsx)(n.code,{children:"caption"})," and ",(0,i.jsx)(n.code,{children:"url_template"})," fields."]}),"\n",(0,i.jsxs)(n.li,{children:["Note that the ",(0,i.jsx)(n.code,{children:"newline_type"})," parameter is currently not used."]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"wpfts_get_sentence_styles"})," filter is a powerful tool for customizing the display of Smart Excerpts in WP Fast Total Search, allowing developers to create various formatting options for text snippets in search results."]})]})},"/en/extending/filters/wpfts_get_sentence_styles",{filePath:"pages/en/extending/filters/wpfts_get_sentence_styles.md",timestamp:1733329702e3,pageMap:l.v,frontMatter:{},title:"wpfts_get_sentence_styles (Filter)"},"undefined"==typeof RemoteContent?useTOC:RemoteContent.useTOC)}},function(e){e.O(0,[9993,9774,2888,179],function(){return e(e.s=11536)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.