5
I wonder how I can create shortcodes in pure php (I will not use wordpress and your plugins).
I don’t intend to use php functions for this purpose. I’d like to create a structure where I can name a code snippet in php and when I called him on the page he would return all the previously defined content.
For example, in the administrative area of the site would be like this:
Name of shortcode: en-so
Contents of the abovementioned shortcode:
<?php
// Aqui poderia usar qualquer coisa no php, usar while, functions, etc.
echo "<p>Bem-vindo ao Stack Overflow em Português!</p>";
?>
Php file
<html>
<head>
<title>Teste</title>
</head>
<body>
<!-- Chamando o shortcode -->
[pt-so]
</body>
</html>
In the php code where the shortcode call is located, it will print the welcome paragraph. As I will make a system with administrative area, this would be one of the resources that the same system would have. I just want to understand how I can make this call a shortcode on my system/site page that will be visible to the public.
Note: I tried to extract the answer in this question, but I could not
+1 for not using wordpress, you can do with includes/requires or functions
– rray
I was even guessing this, but what I want to understand is how that shortcode call on my page will call code definition back in the system.
– DiChrist
summarizing, you want to create your own template engine?
– Daniel Omine
Look, I think that’s it. Does it get really hard? because I could change, delete such shortcode if I wanted, and of course, I could add as many as I wanted tbm
– DiChrist
is a good question, I wouldn’t know how to make php scan all html by looking for the specific shortcotes to carry out the process.
– Gabriel Rodrigues