Johan Steen
Forum Replies Created
-
How far do you get it working? You get the include file loaded, but not the variable injected?
As far as I know, and with my personal tests, it should work just fine with 4.5.x. If not let me know and I’ll look into it.
Cheers
JohanCurrently the plugin presents editors with a view of available snippets. That’s based on a previous request. I’m open to discuss how to handle different roles though.
@wood6994 Free support sucks? How many emails you sent? Good for you that you found another option. Closing this thread.
Forum: Plugins
In reply to: [Post Snippets - Custom WordPress Code Snippets Customizer] Bulk editHi,
Yes, when you export the snippets, they are exported as a serialized PHP array. A serialized array can be edited, but it’s quite tricky and easy to corrupt it. Each string in the export is prefixed with the length of the string. ie.
s:3:"foo";
which defines that a string of 3 characters would follow. If just replacing with another string of the same length, it would work out of the box. i.e..
s:3:"bar";
and it still works fine, but if changing the length of the string, also the string length value needs to be updated. ie.
s:3:"foobar";
will not work, while
s:6:"foobar";
will work.
Cheers,
JohanPieter:
A space can be used in the title of the snippet, if the snippet is not a shortcode. Only shortcode snippets are affected. I’d guess the snippets you refer to are not shortcode snippets?Oh, I see it’s a paid plugin. Then I’ll not be able to download it and see what the problem might be. You’ll have to check with the author of that plugin, there should probably be support included.
Cheers,
JohanHi,
In your example, you can change it to this, and it will work as you expect (i.e., replace
"
with'
for your href).[test description="Blabla some text - find more info at <a href='https://www.address.com/'>some site</a>"]
Cheers,
JohanHi,
This is outside the plugin’s control. The shortcode variables gets parsed by WordPress before the plugin receives them. WordPress’ shortcode system is not able to handle
"..."
inside shortcode variables already encapsulated in"..."
. So the plugin never receives any variables in that case as WordPress can’t handle it. WordPress shortcode shortcode system needs to be updated to handle what you request, so it is out of the scope of this plugin.For what you are looking for to work, WordPress needs to update the
do_shortcode_tag()
function in the Shortcodes API. Posting a request for that here might be a start, or creating a ticket in trac.In you specific examples, you can always go with a workaround, and use
'
to encapsulate the variable.
ie.
[shortcode variable='I am "testing" quotation marks']
which would work.Hi,
Do you have a link to the Woocommerce Product Feed plugin?
Cheers,
JohanHi,
The variables you define for shortcodes are under the same constraints and restrictions as if you would create a shortcode traditionally in WordPress. So
-
are not allowed to be used as a shortcode variable in WordPress. Though WordPress allows you to create shortcode variables using_
. So if you need a separator character, use_
instead.In your example
<strong>Hello, {variable_name}!</strong> [hello variable_name="John"]
Will work fine.
WordPress shortcode variables falls under the same rules as ordinary PHP variables. Which would be: “A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores”. Nothing else is allowed.
Hope this helps.
Cheers,
JohanI could take a look at
Media File Manager Advanced
and see what the problem is. Though that plugin seems to be removed from www.remarpro.com plugin repository. All links to it here are now dead it seems like.
Did you get it from somewhere else, or did it just recently get removed from here?Hi,
What you’re seeing is normal. If you declare a PHP function in a snippet, and use that snippet twice in a page, would be the same as writing the same function twice in a PHP file. Which PHP does not allow.
An idea how you can work around this, depending on scenario, if you want to keep the functions in the snippet library so they can export/import with the rest of the snippets.
First, create a PHP snippet that will only contain the functions you want to have. Let’s say you call that snippet
functions
, then it will look something like this.function foo() { echo 'foo'; } function bar() { echo 'bar'; }
And then let’s create a PHP snippet that uses a function, let’s call that snippet
foo
.foo();
Now when you write a page, you can use the snippet foo multiple times by first using the functions snippet. So the page would look something like this.
[functions] some text [foo] some more text [foo]
This solution has one gotcha though. And that is if you use this in posts, and output those posts in a loop,
functions
might be called twice, and then you get the redeclare problem again. For single pages this solution works though. If you want to be able to use it in a loop for instance. Then you can do like this instead. Never call thefunctions
snippet from a page or post, instead use thegetSnippet()
method in the plugin. And add this line of code to your theme’s functions.phpeval(PostSnippets::getSnippet('functions'));
And all functions you have declared in your functions snippet will be available too all other php snippets whenever you insert them in posts and pages.
Hope this helps.
Cheers,
JohanThanks for the report. This is caused by a bug that sneaked in with the last update where I changed a few fundamental things behind the scenes in the plugin.
This is now corrected, and a minor update will be released today with the fix included.Cheers,
JohanThanks for the report. This is caused by a bug that sneaked in with the last update where I changed a few fundamental things behind the scenes in the plugin.
This is now corrected, and a minor update will be released today with the fix included.Cheers,
Johan