Skip to content

Instantly share code, notes, and snippets.

View dantetesta's full-sized avatar

DANTE TESTA dantetesta

View GitHub Profile
/*
Limita a seleção de opções de um Checkbox
Desenvolvido por: Dante Testa
Sugestão de Aluno: Felipe Flip
*/
<script>
document.addEventListener("DOMContentLoaded", function() {
function limitCheckboxSelection(groupName, limit) {
const checkboxes = document.querySelectorAll(`input[name="${groupName}"]`);
<script>
function limitCheckboxSelection(CheckBoxName, hidden_limit_field) {
const checkboxes = document.querySelectorAll(`input[name="${CheckBoxName}"]`);
const hiddenField = document.querySelector(`input[name="${hidden_limit_field}"]`);
const limit = parseInt(hiddenField.value, 10);
checkboxes.forEach((checkbox) => {
checkbox.addEventListener('change', () => {
const checkedCount = document.querySelectorAll(`input[name="${CheckBoxName}"]:checked`).length;
<?php
function delete_user_and_posts() {
$user_id = get_current_user_id();
$cpts_with_author = array('cpt_slug1,cpt_slug2');
remove_user_and_posts($user_id, $cpts_with_author);
// Redireciona para a home e desloga o usuário
wp_logout();
wp_redirect(home_url());
<script>
// obter a data atual
var dataAtual = new Date();
// adicionar 7 dias à data atual
var dataTrocaFotos = new Date(dataAtual.getTime() + (7 * 24 * 60 * 60 * 1000));
// formatar a data no padrão Y-m-d
var ano = dataTrocaFotos.getFullYear();
var mes = (dataTrocaFotos.getMonth() + 1 < 10 ? '0' + (dataTrocaFotos.getMonth() + 1) : dataTrocaFotos.getMonth() + 1); // o valor do mês começa em 0, então é necessário adicionar 1
<script>
document.addEventListener("DOMContentLoaded", function() {
const checkboxes = document.querySelectorAll('input[name="esteticas[]"]');
const maxChecked = 5;
checkboxes.forEach((checkbox) => {
checkbox.addEventListener('change', () => {
// Adiciona a coluna de imagem do autor na lista de posts do CPT Professor
add_filter('manage_professor_posts_columns', 'add_author_image_column');
function add_author_image_column($columns) {
$columns['author_image'] = __('Author Image', 'text-domain');
return $columns;
}
// Mostra a imagem do autor na coluna de imagem do autor da lista de posts do CPT Professor
add_action('manage_professor_posts_custom_column', 'show_author_image_column', 10, 2);
function show_author_image_column($column, $post_id) {
<?php
/*
Plugin Name: Text to HTML
Description: Converte um texto em HTML usando um shortcode [text_to_html field="nome_do_campo_meta"]
Version: 1.0
Author: Dante Testa
*/
function text_to_html_shortcode( $atts ) {
$atts = shortcode_atts( array(
<?php
function select_cct_downloads($atts) {
// Define o ID padrão como 2
$atts = shortcode_atts( array(
'id' => '2'
), $atts );
<script>
jQuery(document).ready(function(jQuery) {
jQuery('.select-download').on('change', function() {
var selectedValue = jQuery(this).val();
var $parent = jQuery(this).closest('.card-download');
var $downloadBtn = $parent.find('.btn-download a');
if (selectedValue) {
$downloadBtn.attr({
href: selectedValue,
<?php /*
SOMA VALORES DE UM CAMPO DE CPT DO USUÁRIO CORRENTE
PARA USAR ==> [total_cpt cpt='lancamentos' key='_valor' query='_tipo' valor='Receita']
*/
function soma_valores_cpt_dante_testa($atts) {
$user_id = get_current_user_id(); // Obtenha o ID do usuário corrente
// Obtenha o nome do metafield a partir dos parâmetros do shortcode