Showing posts with label debugging. Show all posts
Showing posts with label debugging. Show all posts

Thursday, September 21, 2023

Why are you getting an error in httpdocs/wp-content/plugins/code-snippets/php/snippet-ops.php when trying to preview a page in elementor (SOLVED)

Well, how the hell should I know... :)
What I can tell you is why I was getting such an error and hopefully it might help you too.

In my case the page included a snippet that was registering a short code, this shortcode was expecting some parameters on the URL or POST, but since they would not be passed into the page when opened for viewing in elementor the shortcode was broken.

But I was not all to blame (I think...),
I did have code that checked:

	if(is_admin()) {
            return '<div id="app">SOME PLACEHOLDER CONTENT FOR ADMIN VIEW<</div>';
    }

I don't know when it broke but ir seems that it has something to do with elementor loading the content in an iframe where is_admin() returns false.
after cheching it turns out that the following is better and works also in the iframe....

	if(is_admin() || $_GET['elementor-preview']) {
            return '<div id="app">SOME PLACEHOLDER CONTENT FOR ADMIN VIEW</div>';
    }

Did this help you? leave me a comment....

Tuesday, March 04, 2014

"TypeError: Object has no method 'match'" using angularJs

I was getting the following error:

TypeError: Object 4 has no method 'match'

In some angular code I have written.
took some time to debug but it turns out the isolated scope of one of my directives had a property that was not a string. somewhere inside angular it seems that it is expected that the properties of the isolated scope would all be strings and thus have a .match method....

so
   .directive('myDirective',
      function() {
return {
restrict: "E",
replace: false,
scope: {
        x:4,
},


resulted in the said error.

just so that you will know...

Sunday, June 29, 2008

Two Tips For Debugging Flash Warnings

If you develop Flash widgets or application you might (and should) be familiar with the flash log.
One of the biggest issues with this log is that all the warnings and trace messages just pile up there regardless of what swf sent them.

Here are two simple tips to trace the "Warning: name is not a function" messages:

1. The reason you get those is because you are trying to call a function on some variable does not have such a function in its prototype chain.

2. To be able to identify what line in your code is causing those messages you can force the player to write out "Comments" into the log using the following syntax:

  ({}).THIS_IS_A_COMMENT_TO_THE_LOG()

This will trigget the same type of warning and so by placing several distinct such comments you can narrow the search and find the code line at fault.

Thursday, October 12, 2006

Javascript debugger hilites wrong line

You will probably see a lot of JavaScript related posts in this blog,
well, this is because I do lots of JavaScript.

This time I was trying to add FireFox Support to a web app I am working on.
Usually I work with IE and with VS2005 for debugging.

This time I had to do some debugging inside FF,so I tried both venkman and firebug and had the same problem.

I placed a debugger; statement inside a function I wanted to debug (obviously - why else),
and when the debugger came to life it would hilite the line that is two lines above the one containing the debugger; statement.

well for a while I said - well, I will just have to live with it, but after a while I discovered this was easier said then done.

Thinking why this could happen I decided that it must have something to do with the document being changed dynamically and hence the lack of synchronization between the reported lines numbers and the actual displayed code.

so I played with a few simple examples, suppose you have a page that has the following markup:

<script>
s='<div>hello\nworld\n</div>';
document.write(s);
</script>
<script>
function go(){
debugger;
alert('a');
alert('b');
}
</script>
Hello


We would expect it to break at the debugger statement, but see for your self:
Photobucket - Video and Image Hosting
(And no, I did not make it step ahead).

Playing with it for a while I suddenly relized that my original problem was exactly the opposite of this one, as in this case the line that is being hilited is below the actual line being debuged.

so I went to my page, added:
<script type="text/javascript">
document.write('\n\n');
</script>

And voila, debugging became a reasonable task again.

Still the mystery remains - what could cause the debugger to hilite the wrong line but ABOVE the correct line.

Any ideas anyone ?

 
Clicky Web Analytics