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....

Monday, October 31, 2022

When grepper answers are RTL

If you are not a developer, go away... no, I am just kidding, you can read on, however this is mainly targeted at developers. If you are not using Grepper that you migh consider using it, have a look at https://www.codegrepper.com/

Anyway, for me, even though grepper was finding great answers, It was unusable because it was displaying them with RTL alignment because that is the default for browsers set with hebrew prefrences.... (yes, I know... but its a computer used by the rest of the family too...) so as I was saying: the solution was in the shape of a chrome extention called "Javascript & Css auto injection" installed,

Added a rule set to run
when page starts with http
on page init
and has the following code:

window.setTimeout(function(){
    var el=document.getElementById('search')
    el.setAttribute("dir","LTR")
}, 1000);
and there you go... enjoy.

Monday, March 08, 2021

Eroror 404 saving Elementor Html Widget - Solution

Hi,

So, I encountered a situation where trying to save a piece of HTML & JS using an HTML widget in Elementor was returning a 404 error, not only that but after retrying several times I got blocked from the site.

Making a long story short, it turned out that the hosting company was running some software called mod security or modsec for short, and my code was interpreted as an sql injection attack on the site I was trying to edit.

So how do you work around this? how do you debug this if you encounter a similar issue?

1) Ask your hosting service to have alook in their modsec logs and find your ip to see why you are being blocked - they will send you something that looks like this (I did change the red parts and some of the numbers/tokens for security reasons).

[Sun Mar 07 14:11:15.331211 2021] [:error] [pid 119***5:tid 472*****20384] [client 11.22.33.44:5555] [client 11.22.33.44] ModSecurity: Access denied with code 403 (phase 2). Pattern match "LONG BUT INCOMPLETE REGEXP ..." at ARGS:actions. [file "/etc/apache2/conf.d/modsec/modsec/11_asl_adv_rules.conf"] [line "117"] [id "331028"] [rev "13"] [msg "Atomicorp.com WAF Rules:  Unauthorized SQL access to database Detected."] [data "SOME PART OF YOU HTML CODE"] [tag "SQLi"] [hostname "YOURDOMAINNAMEHERE"] [uri "/path-to-wp-admin/admin-ajax.php"] [unique_id "YETc4k********M1I-Ru7wACBwk"], referer: https://YOURDOMAINNAMEHERE/path-to-wp-admin/post.php?post=POSTIDHERE&action=elementor


2) You can see the file and line number of the rule  that you have hit and its id and revision,
     [file "/etc/apache2/conf.d/modsec/modsec/11_asl_adv_rules.conf"] [line "117"] [id "331028"] [rev "13"]

since it seems that those rules are being commercially sold by Atomicorp.com I am not publishing the actual pattern of the rule, but I did ask the hosting service and they where kind enough to share the full  rule with me - from the rule I extracted the Regex that comes after ARGS:wptextbox1 " in the full text for the rule up untill the " \ 

3) I went to https://regex101.com/  and pasted the regular expression in the appropriate text box and the code that I was trying to add to the site as part of the HTML widget. (make sure to remove surrounding " of the regexp pattern.

4) On the right side you will be able to see the match information showing you exactly what parts of your code trigger the security rule. (clicking a match will take you to the appropriate place in the code).

5) knowing this will hopefully allow you to go and modify your code so as not to trigger this rule.

In my case it was a JavaScript variable that the rule did not like its suffix together with the fact that there was an opening parenthesis less that 100 characters after it....

Good luck and leave me a not if it helped or if you have any additional Q's on this.

Eyal




Thursday, June 06, 2019

Prusa MK3 live Z calibration tips

Hi All,
Well its now maybe the 3rd or 4th time for me trying to wrap my head around the process of Live Z calibration so I though I would write a few words to help me remember whats waht next time...

So,

The process it self is designed to help fine tune to position of the nozzle relative to the bed to get good adhesion. It is performed by rotating the know during printing.

When rotating the knob COUNTER CLOCKWISE you make the negative value that is being displayed MORE NEGATIVE and you move the nozzle CLOSER TO THE PRINT BED.

You will probably need to repeat the process several times until you get it right.

I don't remember in which YouTube video I saw this so if you find it, leave a message in the comments, but it had the following tip:

While the lines pattern is being printed, move your finger gently perpendicular to the printed lines, when you are low enough the printed lines will not detach from the print bed.

It is also recommended that you make sure your print bed is clean before you do this as this also has a very significant influence on adhesion.

I hope this helps.

Monday, May 02, 2016

HP Officejet PRO 8500A A910 offline - Problem solved.

I am writing this post in hope that it will help some people.

The issue is that an HP Officejet PRO 8500A A910 shows as offline when you open the print queue dialog (in the caption it just says "HP Officejet PRO 8500A A910 - offline"), other then that I had network connectivity, ping, web interface was reachable and so on, It just would not print....

I have seen very long threads where people complain that their HP Officejet PRO 8500A A910 went offline and nothing helped.

They got many types of advice like switching from wireless to USB, changing IP and other network settings, disabling Power save mode , restart the printer or related router, use a different power cable and so on...

For me It turned out that the problem was that the cyan ink cartridge was just too old (two years and two months actually... - looks like I am not printing enough sea images...).

Changing the expired cartridge resolved the issue and the printer just came back online.

So how can you tell if that is the case with you ?

In the printer screen , press the ink icon (the one with the cyan, magenta, yellow & black circles on the top right).

You should see a yellow exclamation sign next to at least one of your ink cartridges.

Press the "More..." button and use the side arrows to brows through the cartridges.

If a cartridge is expired it will say so on the top line of the screen (above the ink level indicator).

Replace the expired cartridge and leave me a comment...

Eyal

1/1/2019: UPDATE (Another solution if the above is not the case for you):
[READ, BUT DONT DO THIS until you read the update below]
This was originally posted on Feb 5th 2106,
It is now Jan 1st 2019, and my printer went offline again....
I did remember that I have bloged about this in the past so I came back here,
only this time the cartridges seem o.k.
so I did some more reading and finnaly arrived at THIS LINK which had the sollution to my current "HP Officejet Pro 8500A Plus is offline" problem.

To sum up:
go to the printer properties, open the ports tab and press the configure port button.
then remove the check box from "SNMP Status Enabled".
printer should go online after you press "OK" and "Close".

I must add here the at first it did not wat to save my change and I deleted all the print jobs from the spooler and tried again and then it saved without a problem.

1/1/2019: UPDATE 2
well, I was too quick to go and blog about this,
although it did remove the offline notice on the printer,
the printer remained unavailable for printing,
digging further, it turned out that I did not have connectivity to my printer... (a cable got loose)
so, I now believe that what you should do if its not a cartridges issue is the following:
press the network icon on your printer, it should show the printer's IP address, try to ping it,
if it does not work... well, test all your cables...
personally I went beck to the SNMP checkbox and turned it back on...


 
Clicky Web Analytics