Found a Customizer setting that did not have a sanitization callback function error on theme-check plugin - sanitization

Getting the error on my WordPress theme in theme-check plugin.
"Found a Customizer setting that did not have a sanitization callback function. Every call to the add_setting() method needs to have a sanitization callback function passed"
I know what does it mean but can't figure out the location of the add_setting() function. In fact I don't have any as far as I can see.
Redux had an issue, the latest version should resolve it.
I'm using underscore as boilerplate.
Does any know how to fix this?
Thanks in advance

Related

SolidJS: "computations created outside a `createRoot` or `render` will never be disposed" messages in the console log

When working on a SolidJS project you might start seeing the following warning message in your JS console:
computations created outside a `createRoot` or `render` will never be disposed
There are some information available on this in SolidJS' Github repository issues. But after reading them I was still not quite sure what this was all about and whether my code was really doing something wrong.
I managed to track down where it came from and find a fix for it based on the documentation. So I'm providing the explanation and the solution for those Googling this warning message.
In essence this is a warning about a possibility of a memory leak due to a reactive computation being created without the proper context which would dispose of it when no longer needed.
A proper context is created a couple of different ways. Here are the ones I know about:
By using the render function.
By using the createRoot function. Under the hood render uses this.
By using the createContext function.
The first is by far the most common way, because each app has at least one render function call to get the whole show started.
So what makes the code go "out of context"?
Probably the most common way is via async calls. The context creation with its dependency tree happens only when the synchronous portion of the code finishes running. This includes all the export default function in your modules and the main app function.
But code that runs at a later time because of a setTimeout or by being in an async function will be outside of this context and any reactive computations created will not be tracked and might stick around without being garbage collected.
An example
Let's say you have a data input screen and have a Save button on it that makes an API call to your server to save the data. And you want to provide a feedback to the user whether the operation succeeded or not, with a nice HTML formatted message.
[msg,setMsg] = createSignal(<></>)
async function saveForm(){
...
setMsg(<p>Saving your data.<i>Please stand by...</i></p>)
const result=await callApi('updateUser',formData)
if(result.ok){
setMsg(<p>Your changes were <b>successfully</b> saved!</p> )
} else {
setMsg(<p>There was a problem saving your data! <br>Error: </p><pre>{result.error}</pre> )
}
}
...
<div>
...
<button onClick={saveForm} >Save</button>
{msg()}
</div>
This will produce the above mentioned warning when the API call returns an error, but not the other times. Why?
The reason for this is that SolidJS considers the code inserts inside JSX to be reactive, ie: need to be watched and re-evaluated. So inserting the error message from the API call creates a reactive computation.
The solution
I found the solution at the very end of the SolidJS doc. It's a special JSX modifier: /*#once*/
It can be used at the beginning of a curly brace expression and it tells the SolidJS compiler to explicitly not to make this a reactive expression. In other words: it will evaluated once and only once when the DOM nodes are created from the JSX.
In the above example here's how to use it:
setMsg(<p>There was a problem saving your data! <br>Error: </p><pre>{/*#once*/ result.error}</pre> )
After this there will be no more warning messages :)
In my case, I had an input and when that input changed I re-created an SVG drawing. Because the SVG creation was an expensive operation, I added a debounce in the createEffect function which ran when the input changed. debounce is a technique to defer the processing until the input stops changing for at least X amount of time. It involved running the SVG generation code inside the setTimeout function, thus being outside of the main context. Using the /*#once*/ modifier everywhere where I inserted an expression in the generated JSX has fixed the problem.

Make PhpStorm add a warning if calling a function with more arguments than declared

Using PhpStorm 8.0.3.
Let's say I have this function:
public function myFunction($argA, $argB) {
// ...
}
And I'm calling it from somewhere else in the project with one extra argument, like:
$myClass->myFunction($arg1, $arg2, $arg3);
I know this is not considered an error in PHP, and it can be useful in some scenarios... but it is wrong according to my own coding standards, so I just wanted to know if there's a way to make PhpStorm to warn me if I'm doing it somewhere...
You cannot do anything about it in PhpStorm v8.0.3.
But PhpStorm v9 already has separate inspection for that. If you want -- try v9 EAP build now.

Application happend unavailable parameter in excute runtime

After Install shield, I create a application complete and I excute it,
But something like follow picture. I cant debug it, and I cant fint the error what happend.
Someone can tell me, what method to solve it...
1) Like function parameter no use?
Well, I find a rule.
When run the application, the OnCommand Function is early than OnInitDialog function,
the OnCommand will handle static, buttom, listcontrol, color etc.
but My initial variable is in OninitDialog,
So it will append this result.
The solution is declare a variable to avoid into the function, when complete the OninitDialog.

.get mootools method not working in joomla 1.5

i have a problem in joomla 1.5.18. i'm trying to get text from an element using for instance
var divContent = $$('#myDiv').get('text');
but each time i get the error, in chrome: Uncaught TypeError: Object #<HTMLDivElement> has no method 'get'; in firefox: divContent.get is not a function. why i'm getting this error?
even following samples in mootools i get the same.
i know how to do it for each object in the collection. i got doing $$('.') and using the "each" method:
$$('p.classname').each(function (el){
el.addEvent('click', function() {
var txt = el.get('text');
...
});
});
and obviously i add the function onto domready. i don't use jquery 'cause mootools & jquery stops the events each one... -i tried once & what i needed didn't work- and i wish to use all joomla resources including mootools.
checking the version in mootools.js it says 1.13 (?)
not sure which version of mootools comes in joomla 1.5.18, it may be 1.2.5. if so, .get should work but not as you expect it to.
You are probably a jquery user, used to $("#myid") and find that the only way to get similar results with the # in there in mootools is via document.getElements, aka, $$.
the problem is, to get a single item by id in mootools, you actually do document.id("mydiv") or even $("mydiv"). $$("#mydiv") will actually return a COLLECTION of elements with a single member, so [obj], so the real element is $$("#mydiv")[0].
if you apply a .get method to a COLLECTION, the getter normally iterates via a .each through all members and performs the get individually. it will return a new array member for each member of the collection - i.e. ["innertext"]; - though there should be a method for the collection, make sure that the element is there, it's in domready / onload and it's a unique id.
Still, I'd swap to using the $("mydiv").get("text"), it ought to be fine. This is all all too common assumption of jquery users that don't read the manual, in my experience. It results in bad and un-performant code due to all the .each iterations mootools has to silently do to work with the collection for you. Just saying.
You can also (and should) upgrade your Joomla to the latest version (security fixes, etc) and I believe it was about version 1.5.20 they included a newer version of mootools right out of the box (also there is a plugin for mootools upgrade you can enable). I believe the version included out of 1.5.20 is like 1.2.5 or something...
That may help!

How to detect exception when executing Javascript in NPAPI plugin?

In a plug-in I am using NPN_Evaluate() to execute some Javascript. How can I detect wether the Javascript raises an exception? Basically I want to execute any piece of Javascript and get the result from it or detect if it raised an exception.
I tried wrapping my Javascript code like this:
try {
// Injected Javascript code here
}
catch (exc) {
exc;
}
That way the result from NPN_Evaluate() will be an NPObject* containing a property "message" with the exception message if something goes wrong. But how can I know that it is an exception? It might as well be a result from the injected Javascript code.
Am I approaching this the wrong way? Can I detect an exception without catching it in Javascript and returning the exception as the result?
Personally I've never been a fan of using NPN_Evaluate; If I needed to do something that couldn't be done using other methods (NPN_Invoke, NPN_GetProperty, etc) I'd use NPN_Evaluate to inject a javascript function into the DOM and then call it using NPN_Invoke; then if it returns false you know it failed. There isn't any really good exception handling across that bridge, unfortunately, but the return value of true or false will tell you if it succeeded -- I suspect this holds true even for just using NPN_Evaluate.
Remember that anything declared global in javascript is a property of the window; thus, if you inject "function foo(bar) { alert(bar); }" with NPN_Evaluate you can use NPN_GetValue to get the Window NPObject and then call GetProperty("foo") to get the foo function. You can then call InvokeDefault on that bar method to call it, passing in whatever value you want for bar as a parameter.