Plugin Author
kontur
(@kontur)
Hey,
see the github documentation for more info.
E.g.:
[fontsampler fonts="{"woff":"json-encoded/path-to/fontfile.woff", "name":"Display name of the font", "initial":true},{"woff":"json-encoded/path-to/another-fontfile.woff", "name":"Display name of the other font", "initial":false}"]
Does this help? Do you have a (private) link to the page where you are trying to add the shortcode, and what is the code you are using?
Hello, thanks for the quick response!
I’m not very good at php. Here is the page where the code – http://seokitchen.ru/sdgsd/.
Here is the source code:
<hr />
<hr />
<hr />
<?php
$fonts[] = array(
'woff' => 'http://seokitchen.ru/wp-content/uploads/2018/11/Xiomara-Script.ttf',
'name' => 'v',
'initial' => true
);
$fa = str_replace(array('[', ']'), '', htmlspecialchars(json_encode($fonts, JSON_UNESCAPED_SLASHES), ENT_NOQUOTES));
print_r($fa);
echo do_shortcode('[fontsampler fonts="'.$fa.'"]');
?>
<hr />
<hr />
<hr />
The shortcode is simply not displayed.
Plugin Author
kontur
(@kontur)
Try this instead:
$fa = substr(json_encode($fonts, JSON_UNESCAPED_UNICODE), 1, -1);
I changed that line. You can see the output of the $fa
variable on the page. But the shortcode didn’t work.
Below the lines, for the test, I inserted the following code:
$dd = 1;
echo do_shortcode('[fontsampler id='.$dd.']');
and it works.
Plugin Author
kontur
(@kontur)
Instead of:
echo do_shortcode('[fontsampler fonts="'.$fa.'"]');
Try:
echo do_shortcode("[fontsampler fonts='".$fa.'"]");
Since the $fa variable contains json that has “-quotes, it would “write out” [fontsampler fonts=”…”…”…”], so you need to use [fontsampler fonts=’…’] so that the “-quotes in the actual fonts value does not break the do_shortcode.
My God, it’s working! Thank you very, very much!
Still, the error was in my carelessness to the code.
Your plugin is the best and you are a great developer.
Thank you again!
-
This reply was modified 6 years ago by screamson. Reason: Need mark as resolved
Plugin Author
kontur
(@kontur)
Great that it’s working now. Passing in the json is not really an ideal solution, but for the rare cases someone wanted to programmatically pass the fonts it it works. Thanks for the review 😉