Created
August 11, 2022 18:54
-
-
Save asllanmaciel/a829e874eeb52c9cef3059a30d6bd0d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*** | |
* Para usar o shortcode como Tag Dinâmica (Site > Shortcode) na URL do botão | |
* [btn-assinar plano=00] - 00 é o ID do Plano | |
* | |
* Se quiser, pode redirecionar para outra base, da seguinte forma: | |
* [btn-assinar base="https://dominio.com.br/xpto?parametro=valor" plano=00] | |
* | |
* Usar no functions.php no tema filho (não usar no pai) | |
* Ou, através de um plugin, por exemplo, https://br.wordpress.org/plugins/code-snippets/ | |
*/ | |
function url_botao( $atts ) { | |
$a = shortcode_atts( array( | |
'base' => 'https://sistema.valemovel.com.br/cadastro.php?plano=', //Ex de URL de base | |
'plano' => 0, | |
), $atts ); | |
$pos = strpos($a['base'], '?'); | |
if ($pos === false) { | |
$a['base'] = $a['base'] . '?plano='.$a['plano']; | |
$a['plano'] = ''; | |
} | |
$ref = ($_GET['ref']) ? '&ref='. $_GET['ref'] : ''; | |
$src = ($_GET['src']) ? '&src='. $_GET['src'] : ''; | |
$url = $a['base'] . $a['plano'] . $ref . $src; | |
return $url; | |
} | |
add_shortcode( 'btn-assinar', 'url_botao' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment