We have adapted our cookie banner service (Borlabs Cookie WordPress Plugin) to make Klaviyo compatible with it.
This was partly difficult because Klaviyo does not provide script handles everywhere.
e.g. for widgets or the general klaviyo script.
Please add the script handle to the function “kl_add_async” in wp-content/plugins/klaviyo/inc/kla-analytics.php.
This makes it easier for Cookie-Tols to work with Klaviyo.
Working code example:
public function kl_add_async( $tag, $handle, $src ) {
if ( self::KLAVIYO_JS_HANDLE !== $handle ) {
return $tag;
}
return "<script id=\"".esc_attr($handle)."\" async src='" . esc_url($src) . "'></script>"; // phpcs:ignore
}
We do not currently use the widget forms.
There, a unique ID can also be helpful to block the widget-HTML via Borlabs Cookie Content Blocker until the opt-in by the user.
But the widget issue is of secondary importance to us for now.
The klaviyo script is more important.
]]>I ran these tests, results in comments:
global $wpdb;
$table_name = $wpdb->prefix . 'mytable';
// Places table name in single quotes (') which is wrong.
$wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %s', $table_name ) );
// Produces error: Use placeholders and $wpdb->prepare(); found $table_name .
$wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS `' . $table_name . '` ) );
// Produces error: Use placeholders and $wpdb->prepare(); found interpolated variable $table_name at "DROP TABLE IF EXISTS `{$table_name}`" .
$wpdb->query( $wpdb->prepare( "DROP TABLE IF EXISTS `{$table_name}`" ) );
How to do it properly?
Solution:
global $wpdb;
$wpdb->mytable = $wpdb->prefix . 'mytable';
$wpdb->query( 'DROP TABLE IF EXISTS `' . $wpdb->mytable . '`' );
]]>You have a beautiful Warning with you custom method add_filter :
Warning: call_user_func_array() expects parameter 1 to be a valid callback, class ‘TwicPics’ does not have a method ‘__return_false’.
Best,
]]>But it works really well and I am impressed. Infinitely better than the WordPress default search, or Google Custom Search, or probably any other plugin you might consider for your site.
This is the one to go for.
After resolving the above issues, perhaps the authors could consider providing a search engine for the internet? Let’s face it, Google is rubbish and there is a gap in the market. You would have to ascribe downvotes to sites that carry adverts. Like all those blog sites that waffle on because Google liked ‘quality content’ but didn’t actually know what it was even if slapped across the face with it by a wet kipper. There could of course be a conflict of interest if you are also trying to sell to blog sites. But this is www.remarpro.com not wordpress.com… You know what you need to do
]]>I’m using this link below. I installed everything and now I have a problem, because when in the terminal I enter the phpcs –standard=WordPress my-file.php I have an error like:
ERROR: Referenced sniff “Generic.WhiteSpace.LanguageConstructSpacing” does not exist
I searched Google, but I did not find a solution. I’m fresh when it comes to phpcs, maybe the solution is easy, unfortunately I did not find it. Is there a missing library or plugin?
The same happens when I enter the WordPress-Extra standard. In the case of WordPress-Docs and WordPress-Core everything works.
Does anyone know any solution? Thank you.
]]>I know code readability is important by why would I write code in such manner I don’t even like? I like to use camelCase naming convention for my functions and I AVOID using underscores for my class names. I think underscores makes them look ugly lol.
The spacing inside the parentheses is kinda annoying too but not that bad.
My real question here is, what if I do not follow some of these standards by WordPress and try to submit my plugin here? Will it get rejected or these “rules” are just a recommendation?
Any help would be greatly appreciated!
]]>I often use(d) statements like this
if ( $from = any_function() ) {
// any code
}
But this throws an error:
Assignments must be the first block of code on a line
The following 2 variations would both validate, but especially variation A is ugly
Variation A
if (
$from = any_function()
) {
// any code
}
Variation B
$from = any_function()
if ( $from ) {
// any code
}
So the question is, which way is the suggested way to handle it? Or is it maybe an error that this error is thrown?
If this is the wrong place to ask, please notify and I will ask on the Git Repo again
I am a real fan of the Allman (BSD) coding indent style. However, when i review the top rated plugins on WordPress, i am finding them using the K&R coding indent style.
Is there a requirement from www.remarpro.com that forces users to use the K&R indent style when developing plugins or themes? I read all the manual but couldn’t get a clear answer on which indent style we are allowed to use.
Mainly, is the K&R the only accepted coding indent style? or we can use the Allman (BSD) coding indent style as well?
Your help will be greatly appreciated.
]]>Lately I have been running into errors such as:
Expected next thing to be an escaping function (see Codex for ‘Data Validation’), not ‘_x’
I essentially used the same line of code from the Twenty Sixteen theme that ships with WordPress. So, out of curiosity, I ran PHPCS against comments.php in the Twenty Sixteen theme and got the same errors.
So how important is it to use PHPCS with the WordPress/WordPress-VIP code standard tests?
]]>