PageSourceSearch

https://fulltextsearch.org/docs/_next/static/chunks/pages/en/exten…/wpfts_get_option-35c24e0d9008b90a.js

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

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7086],{48750:function(i,e,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/en/extending/filters/wpfts_get_option",function(){return s(56033)}])},56033:function(i,e,s){"use strict";s.r(e),s.d(e,{useTOC:function(){return useTOC}});var n=s(85893),t=s(37812),h=s(80390),l=s(38925);function useTOC(i){return[{value:"When to Use",id:"when-to-use",depth:2},{value:"Arguments",id:"arguments",depth:2},{value:"Return Value",id:"return-value",depth:2},{value:"Example (Changing the Results Page URL)",id:"example-changing-the-results-page-url",depth:2},{value:"Important Notes",id:"important-notes",depth:2}]}e.default=(0,t.c)(function(i){let{toc:e=useTOC(i)}=i,s={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",span:"span",strong:"strong",ul:"ul",...(0,l.a)(),...i.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(s.h1,{children:"wpfts_get_option (Filter)"}),"\n",(0,n.jsxs)(s.p,{children:["The ",(0,n.jsx)(s.code,{children:"wpfts_get_option"})," filter in WP Fast Total Search allows developers to modify plugin option values before they are used. This enables dynamic configuration of plugin behavior without directly altering settings in the database or through the administrative interface."]}),"\n",(0,n.jsx)(s.h2,{id:e[0].id,children:e[0].value}),"\n",(0,n.jsx)(s.p,{children:"This filter can be useful in the following scenarios:"}),"\n",(0,n.jsxs)(s.ul,{children:["\n",(0,n.jsxs)(s.li,{children:[(0,n.jsx)(s.strong,{children:"Dynamic setting changes depending on context:"})," For example, you can change the search results page URL based on the current page or post type."]}),"\n",(0,n.jsxs)(s.li,{children:[(0,n.jsx)(s.strong,{children:"Temporary setting changes for testing:"})," You can use this filter to temporarily change settings without altering them in the database."]}),"\n",(0,n.jsxs)(s.li,{children:[(0,n.jsx)(s.strong,{children:"Adding settings from other plugins:"})," If your plugin integrates with WPFTS, you can use this filter to add your own settings."]}),"\n"]}),"\n",(0,n.jsx)(s.h2,{id:e[1].id,children:e[1].value}),"\n",(0,n.jsxs)(s.ul,{children:["\n",(0,n.jsxs)(s.li,{children:[(0,n.jsx)(s.code,{children:"$v"})," (mixed): The current value of the option. The value type depends on the option type."]}),"\n",(0,n.jsxs)(s.li,{children:[(0,n.jsx)(s.code,{children:"$optname"})," (string): The name of the option."]}),"\n",(0,n.jsxs)(s.li,{children:[(0,n.jsx)(s.code,{children:"$is_force_reread"})," (bool): A flag indicating whether to force rereading the option value from the database."]}),"\n"]}),"\n",(0,n.jsx)(s.h2,{id:e[2].id,children:e[2].value}),"\n",(0,n.jsxs)(s.ul,{children:["\n",(0,n.jsxs)(s.li,{children:[(0,n.jsx)(s.code,{children:"$v"})," (mixed): The modified value of the option."]}),"\n"]}),"\n",(0,n.jsx)(s.h2,{id:e[3].id,children:e[3].value}),"\n",(0,n.jsx)(s.pre,{tabIndex:"0","data-language":"php","data-word-wrap":"","data-copy":"",children:(0,n.jsxs)(s.code,{children:[(0,n.jsxs)(s.span,{children:[(0,n.jsx)(s.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"add_filter"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"("}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"'wpfts_get_option'"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:", "}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"'change_search_results_url'"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:", "}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"10"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:", "}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"3"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:");"})]}),"\n",(0,n.jsxs)(s.span,{children:[(0,n.jsx)(s.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"function"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:" change_search_results_url"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"($v, $optname, $is_force_reread) {"})]}),"\n",(0,n.jsxs)(s.span,{children:[(0,n.jsx)(s.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"	if"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:" ($optname "}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"==="}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" 'results_url'"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" &&"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:" is_singular"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"("}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"'product'"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:")) {"})]}),"\n",(0,n.jsx)(s.span,{children:(0,n.jsx)(s.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"		// If on a product page, change the URL to the product archive page"})}),"\n",(0,n.jsxs)(s.span,{children:[(0,n.jsx)(s.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"		return"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:" get_post_type_archive_link"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"("}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"'product'"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:");"})]}),"\n",(0,n.jsx)(s.span,{children:(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"	}"})}),"\n",(0,n.jsxs)(s.span,{children:[(0,n.jsx)(s.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"	return"}),(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:" $v;"})]}),"\n",(0,n.jsx)(s.span,{children:(0,n.jsx)(s.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"}"})})]})}),"\n",(0,n.jsx)(s.h2,{id:e[4].id,children:e[4].value}),"\n",(0,n.jsxs)(s.ul,{children:["\n",(0,n.jsxs)(s.li,{children:["The ",(0,n.jsx)(s.code,{children:"wpfts_get_option"})," filter is called every time the plugin retrieves an option value using the ",(0,n.jsx)(s.code,{children:"WPFTS_Core::get_option()"})," method."]}),"\n",(0,n.jsx)(s.li,{children:"Be cautious when modifying option values, as this may affect plugin functionality."}),"\n",(0,n.jsx)(s.li,{children:"If you modify the option value, ensure the returned value has the correct data type."}),"\n",(0,n.jsxs)(s.li,{children:["The ",(0,n.jsx)(s.code,{children:"$is_force_reread"})," parameter is usually not used in addon code."]}),"\n"]}),"\n",(0,n.jsxs)(s.p,{children:["The ",(0,n.jsx)(s.code,{children:"wpfts_get_option"})," filter is a powerful tool for dynamically configuring WP Fast Total Search, allowing you to adapt the plugin to various requirements without modifying the plugin’s code itself."]})]})},"/en/extending/filters/wpfts_get_option",{filePath:"pages/en/extending/filters/wpfts_get_option.md",timestamp:1733329702e3,pageMap:h.v,frontMatter:{},title:"wpfts_get_option (Filter)"},"undefined"==typeof RemoteContent?useTOC:RemoteContent.useTOC)}},function(i){i.O(0,[9993,9774,2888,179],function(){return i(i.s=48750)}),_N_E=i.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.