Skip to content

Instantly share code, notes, and snippets.

View larbous's full-sized avatar

Luiz Sobral larbous

View GitHub Profile
@larbous
larbous / options-values-in-code.php
Created July 10, 2024 14:51 — forked from MjHead/options-values-in-code.php
Get option values for JetEngine options pages inside the PHP code
<?php
/**
* Method 1
* Can be used for: Any storage type
*
* page-slug - replace this with your Option Page slug
* option-name - replace this with your option Name/ID
*/
$value = jet_engine()->listings->data->get_option( 'page-slug::option-name' );
@larbous
larbous / shortcode_pagina_html.php
Created July 10, 2024 13:30
WP JetEngine - Shortcode que imprime um campo com html puro com JS, CSS sem remover as tags html
<?php
//use para imprimir um campo JetEngine Textarea com somente html
function pagina_html_shortcode() {
//campo meta
$meta_key = '_pagina_html';
//recupera o campo
$value = get_post_meta(get_the_ID(), $meta_key, true);
return $value;
@larbous
larbous / custom-dynamic-field-callback.php
Created July 9, 2024 01:11 — forked from Crocoblock/custom-dynamic-field-callback.php
JetEngine Dynamic Field add custom callback (for example, add callback that partially masks an email with * or other symbols)
<?php
//filter to add a callback to the list
add_filter( 'jet-engine/listings/allowed-callbacks', 'add_custom_dynamic_field_callbacks' );
//filter to specify which arguments will the callback have
add_filter( 'jet-engine/listing/dynamic-field/callback-args', 'add_custom_dynamic_field_callbacks_args', 0, 3 );
//filter to add controls
//controls arguments are set as in Elementor controls
@larbous
larbous / Contador de Views para WordPress Posts e CPT.php
Created July 4, 2024 12:34
Contador de Views para WordPress Posts e CPT
/*Desenvolvido por Dante Testa + ASK Jarvis*/
/*Coloque esse código no functions.php do seu tema */
/*https://www.youtube.com/watch?v=NKxyNbJbee4 */
function views_shortcode( $atts ) {
$a = shortcode_atts( array(
'print' => '0',
'count' => '0',
), $atts );
<?php
/*
* Fatal error: Unparenthesized a ? b : c ? d : e is not supported. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e) in /var/www/wp- * content/plugins/js_composer/include/classes/editors/class-vc-frontend-editor.php on line 646
*
*Como resolver
*O erro indica que a versão do WPBakery usada não é compatível com a versão do PHP atualmente ativa. Você precisaria baixar a versão
*mais recente do WPBakery para corrigir isso. Como WPBakery é um produto comercial, entre em contato com o suporte para mais dúvidas:
*https://wpbakery.com – perguntas sobre produtos comerciais não são permitidas aqui no fórum.
*
@larbous
larbous / funcoes_php8createfunction.php
Last active April 9, 2024 16:52
PHP 8 create_function replacement
/*
* PHP 8 create_function replacement.
* Use apenas como um paliativo para o sistema antigo voltar
* a funcionar e atualize em seguida.
* coloque este trecho dentro do arquivo functions.php do tema ativo.
*/
if ( ! function_exists( "create_function" ) ) {
function create_function( $arg, $body ) {
static $cache = array();
static $max_cache_size = 64;
@larbous
larbous / import_users_msa_to-wp.php
Created February 7, 2024 20:55
Importando dados do MS-Access para a tabela users do WordPress
<?php
// Conexão com o banco de dados MS-Access
$db = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=Caminho/Para/Seu/Arquivo.mdb");
// Consulta para obter os usuários do MS-Access
$query = "SELECT * FROM usuarios";
$result = $db->query($query);
// Loop através dos resultados
foreach ($result as $row) {
@larbous
larbous / formcep.html
Created January 10, 2024 14:24
Código jQuery completo para CEP automático e máscaras para campos de formulário
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.15/jquery.mask.min.js"></script>
<script type="text/javascript" >
jQuery(document).ready(function( $ ) {
function limpa_formulario_cep() {
$("#form-field-endereco").val("");
$("#form-field-cidade").val("");
$("#form-field-estado").val("");
}
@larbous
larbous / redirect_registration_page.php
Created November 3, 2023 13:50
Redirect User Registration to Custom Registration Page
<?php
// Redirect Registration Page
function my_registration_page_redirect()
{
global $pagenow;
if ( ( strtolower($pagenow) == 'wp-login.php') && ( strtolower( $_GET['action']) == 'register' ) ) {
wp_redirect( home_url('/registration-url'));
}
}
@larbous
larbous / mautic-form-preload.js
Last active June 15, 2023 20:48 — forked from stevedrobinson/mautic-form-preload.js
Pre-populate Mautic Form Data from Query String Parameters
<script>
(function(document){
function populateForms(){
if (document.readyState == 'interactive') {
if (document.forms.length !== 0 && location.search) {
var query = location.search.substr(1);
query.split('&').forEach(function (part) {
if (part.indexOf('=') !== -1) {
var item = part.split('=');
var key = item[0];