allowLinker out of ga create function - google-analytics

We've got a shop plugin which handles the e-commerce codes for us. However, it is not capable of setting up multidomain.
we can call the require, linker function ourselfes, but the plugin already runs the 'create' function which needs the allowLinker option.
Is it possible to add this after the creation? I've found this resource, which says otherwise - but I am hoping for a hack someone might know.
https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#allowLinker

Related

Wordpress Plugin - Why is WP altering "[i]" (and others)?

First off, I'll say that I do have a lot of experience programming, but I'm incredibly inexperienced with WordPress. I'm guessing there's a correct WordPress way to do what I want and maybe I'm not using the right method, which is why I'm having trouble.
In a nutshell, my plugin reaches out to my company's server via CURL and retrieves a bunch of code (html, css, and javascript) to put on the page. It's been working fine for many years, but recently our customers have started to complain about broken functionality. Turns out it's javascript errors.
Digging deeper, we discovered that wordpress (or something) is replacing seemingly arbitrary bracketed text with seemingly arbitrary content. I see no rhyme or reason to this. For example, within the following javascript that my plugin pulled in from our server, it replaced the [i] with some random html.
Original code:
var optname = order_other_options[oname][i][optid];
After wordpress munged it:
var optname = order_other_options[oname]<div class='iconfa' style='text-align: left;'><iclass=''></i></div>[optid];
It replaced [i] with <div class='iconfa' style='text-align: left;'><iclass=''></i></div>
What's weird is that there are probably a dozen instances of [i] throughout the same javascript function, but it was only replacing four instance. ???
For another customer, it's replacing an instance of [n] with [n], yet it doesn't try to replace the brackets with &# codes in other instances within that js function.
As a temporary solution for the first customer complaint, we changed the code on our server to be [x] instead of [i] and that fixed the problem. But now I see that it seems somewhat indiscriminate about what it replaces.
I could probably write something that prepends js array variables with ersVar_ or something, something like "[ersVar_x]", but that's such a hack, I'd much rather get to the bottom of the problem.
The way my plugin works is by using add_filter(), and our customers utilize the plugin by adding a merge field [store: <account ID>], the plugin then just str-replaces that merge field with our content.
Maybe add_filter() isn't the best option? Is there another function I can use instead that would guarantee that nothing would ever attempt to modify the content my plugin generates?
And if you do recognize what's happening here, I'd be really curious to know, since none of the developers at my office could find any discernible pattern about when and why it replaces things.
Any insights are appreciated.
The issue here was the hook and the priority used on that hook.
To understand things better, please see the below explanation of the parameters in add_filter
Hook: This is the event that triggers the callback function. In Adam's case the hook was the_content.
Callback: The callback function to be triggered whenever apply_filters is called on the respective hook.
Priority: This helps you specify on how early or how late to trigger the callback function. Defaults to 10. The lower the number, the earlier the callback is called for execution. That turned out to be a problem for Adam as by using the default priority of 10, he was allowing other functions to be called after his has finished execution. It was solved by changing the priority to 999.
Parameter Count: This is the number of parameters accepted by the callback function. Defaults to 1.

Woocommerce API whitout curl.. Is it possible?

I'm creating a plugin for Wordpress/Woocommerce and I was wondering if there is a simple way to call the Woocommerce API without going through the hassle of the whole REST API thing (curl, authentication, keys, secrets, etc). Since the code runs on the same server as Woocommerce it seems like a much easier and cleaner solution to just call some woocommerce function immediately.
So I'm looking for something like $myProducts = WC->getProducts();
Instead of having to make a Curl request to /wp-json/wc/v2/products
Is there a nice way to do this? Or is the next best option just to start querying the database (since this code is already somewhere in Woocommerce it seems a bit redundant to program it again)?
PS besides getting all the products I have a lot of other calls too so I'm looking for a general approach (the getProducts is just an example).
Hooray! I finally found a way to do this, thanks to this blog: https://blog.wallacetheme.com/wordpress-theme-rest-api
$request = new WP_REST_Request('GET', '/wc/v2/products');
$result = rest_get_server()->dispatch($request);
return $result->data;
This just bypasses the whole curl request.
Optionally you can use set_query_params and set_body_params for sending optional GET and POST data.

how to implement in wordpress a signup flow that requires a secret activation code

I'm trying to implement a signup flow in wordpress with the additional requirement that a user, to sign up, must use a secret activation code. Such code is valid only once, it's consumed after signup.
Many such codes are available (manually imported in DB is fine).
The use case is to let sign up only users who bought a (paper) book containing the secret activation code. In each book, the code will be different.
Before writing the whole thing manually, is there a plugin with a similar functionality? If not, what is the suggested implementation strategy?
There are a number of modules that already have this functionality, one that I've used before is simply "EasyInvitationCodes". There's also another one called "WP-Invites". If you use "invite" or "invitation" as your search keyword there are a few others available.
For EIC: https://wordpress.org/plugins/baw-invitation-codes/
For WP-Invites: https://wordpress.org/plugins/wp-invites/
Let me know if you've got any questions or if these aren't quite what you're after!

Frama-C: access to the cil/src/ext modules data and few others questions as well

first of all, i will explain what i would like to do here : given a C big programm, i would like to output a list of producers/consumers for a data and a list of calling/called-by functions of the function where this data is.
for doing this, i am thinking about using what computes some modules of frama-c, like dataflow.ml or callgraph.ml in my own plugin.
however, as i read the plugin developper doc, i can't manage to see how we can have access to the data of those modules.
is a "open.cyl_type" sufficient here in my own plugin?
moreover, here are my other questions :
i tried using by the way pdg plugin for my purposes but when i call it and it says "pdg graph computed", how can i access it?
is there any more documented thing about "impact" plugin than the official webpage, in depth, how it works fondamentally? (i have to say that i'm in like a pre-project phase, and that i installed frama-c with the apt-get on ubuntu and that i did not get an impact plugin working (i'll see by compiling the sources))
by the way, do you think i'm using the right method to get to my purposes?
Your question is quite unclear, and this answer is thus very generic. As mentioned in the developer documentation, there are two main classes of plugins: static plugins, compiled with the kernel and whose API is exposed in a module (usually of the same name of the plugin) in Db. Dynamic plugins, such as Semantic_callgraph register dynamically their entry points through the Dynamic module.
If you do make doc in Frama-C sources (I'm not sure that there is a corresponding package in Ubuntu) you can access documentation for the Db module in FRAMAC_SOURCE_DIR/doc/code/html/Db.html and the list of functions registered by dynamic plugins in FRAMAC_SOURCE_DIR/doc/code/dynamic_plugins/Dynamic_plugins.html.
I think that, following Virgile's advice, you should get the source code anyway because you will most of the time need to browse the code to find what you are looking for. Beside, you can have a look at the hello_word plug-in (in src/dummy/hello_world) to have an example of a very simple plug-in. You can also find some examples on my web site at https://anne.pacalet.fr/Notes/doku.php?id=notes:0061_frama_c_scripts to find out how to have access to some information in the AST.

Require extra information in Meteor account sign up

I'm working a Meteor app which uses accounts-password, and linking to other services wouldn't make sense. However, I would like to be able to require additional information, specifically their real name. From reading the docs, the data should be stored in user.profile. How can I require information at signup? My best guess is extend accounts-password and accounts-ui, but it seems like a common enough problem, so there might be a better way.
There isn't a great way to do this currently that I know of. Extending Accounts-UI is a nightmare. I strongly suggest just doing it yourself, it's not very hard. Meteor provides the Accounts.createUser function you could use for this, as well as other related simple to use functions in the Passwords documentation. The createUser function actually accepts an options object, which can specifically contain a profile object for the additional information you would like to add. Set up a template yourself with all the html form fields you want, make a submit event hook for it that calls either Accounts.createUser or a Meteor function that does some other stuff first. This method gives you styling flexibility also, which is a pain in the neck with the Accounts-UI package.
Use Accounts.createUser() and something like:
Accounts.validateNewUser( function( user ) {
return !!user.profile.name;
});
You'll probably want to make your own form for this - the accounts-ui package is great for prototyping, but when you need custom requirements like this it's easier to roll your own. See BenjaminRH's answer for the basics of creating a custom login form.

Resources