Skip to content

Instantly share code, notes, and snippets.

View algmelo's full-sized avatar

André Melo algmelo

View GitHub Profile
@algmelo
algmelo / gist:8092178652e7613e886af47cff7e3619
Created September 4, 2024 18:02
Altera a saída do block image, para adicionar o custom_credit
public function __construct()
{
add_filter('render_block', array($this, 'render_custom_image'), 10, 2);
}
public function render_custom_image($block_content, $block)
{
if ($block['blockName'] === 'core/image') {
$image_id = $block['attrs']['id'] ?? null;
@algmelo
algmelo / gist:a84d0ae9d4ad80644f5edec72b21a3d0
Last active September 2, 2024 22:33
Adiciona custom field ao attachment do wordpress
----------------------------------- functions.php -----------------------------------
/**
* Add Attachment Credit
*/
function CustomAttachmentFields( $form_fields, $post ) {
$form_fields['custom_credit'] = array(
'label' => __('Image credit', BOOTSTRAPTHEME_TEXTDOMAIN),
'input' => 'text',
'value' => get_post_meta( $post->ID, 'custom_credit', true ),
'helps' => __('If provided, photo credit will be displayed', BOOTSTRAPTHEME_TEXTDOMAIN),
@algmelo
algmelo / wp_rewrite_rules.log
Created January 28, 2023 14:42 — forked from thenbrent/wp_rewrite_rules.log
Default WordPress Rewrite Rules
[rules] => Array (
[category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2]
[category/(.+?)/?$] => index.php?category_name=$matches[1]
[tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/page/?([0-9]{1,})/?$] => index.php?tag=$matches[1]&paged=$matches[2]
[tag/([^/]+)/?$] => index.php?tag=$matches[1]
[type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_format=$matches[1]&feed=$matches[2]
@algmelo
algmelo / gist:6f650540a9269147b3a60e148e676d4a
Created November 24, 2022 20:30
Mautic - upgrade/update
php bin/console mautic:update:find
php bin/console mautic:update:apply
php bin/console mautic:update:apply --finish
php bin/console doctrine:migration:status
php bin/console doctrine:schema:update
php bin/console doctrine:schema:update --force
php bin/console cache:clear
rm -rf var/cache/
@algmelo
algmelo / gist:0c31c28b4fe039c18065835101fc31bc
Created November 24, 2022 20:21
Configuração do plugin jms post views analytics
Configuração do plugin JMS Post Views
- Precisa ter acesso para criação de Vistas de Propriedade
- Clique em Administrador e navegue até a conta e a propriedade às quais você quer adicionar a vista.
- Na coluna VISTA DA PROPRIEDADE, clique no menu e em Criar vista da propriedade.
- Selecione Site ou App para dispositivos móveis. Qual é a diferença?
- Insira um Nome.
- Use um nome específico e descritivo. Assim, é possível saber quais dados estão nessa vista ao ver o nome em uma lista.
- Selecione o Fuso horário dos relatórios.
- Marque o checkbox Filtragem de bots
@algmelo
algmelo / fix-wordpress-permissions.sh
Created August 5, 2020 18:04 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
UPDATE jp_blogs SET domain='blog.jovempan.uol.com.br';
UPDATE jp_site SET domain='blog.jovempan.uol.com.br';
UPDATE jp_options SET option_value='http://blog.jovempan.uol.com.br' WHERE option_name='siteurl';
UPDATE jp_options SET option_value='http://blog.jovempan.uol.com.br' WHERE option_name='home';
UPDATE jp_1_options SET option_value=replace(option_value, 'http://blog.jovempan.uol.com.br', 'http://blog.jovempan.uol.com.br') WHERE option_name='siteurl';
UPDATE jp_1_options SET option_value=replace(option_value, 'https://blog.jovempan.uol.com.br', 'http://blog.jovempan.uol.com.br') WHERE option_name='siteurl';
UPDATE jp_1_options SET option_value=replace(option_value, 'http://blog.jovempan.uol.com.br', 'http://blog.jovempan.uol.com.br') WHERE option_name='home';
@algmelo
algmelo / wp-fix-meta-serialization.php
Created July 26, 2018 21:49 — forked from kythin/wp-fix-meta-serialization.php
Fix wordpress serialized variables in custom meta data when running a migration
<?php
/*
* Wordpress postmeta find&replace code
*
* This file should be run on your source database to echo out update statements to run on your migrated database.
* It is to address the issue of when doing a find/replace on an sql file during a wordpress migration, that breaks
* any content changed within wordpress serialized meta values, particularly if you have custom post types etc.
*
* Do your normal find/replace over the exported sql, import it into your new database, then run this code and copy the resulting
* update SQL into your new database to fix it.
@algmelo
algmelo / run-all.sql
Created May 7, 2018 17:00 — forked from eduardopintor/run-all.sql
These are various SQL Queries to run to update urls within a WordPress Database. These queries assume the table prefix is the standard `wp_`, if you have a custom prefix you will need to update the queries. I also recommend changing the default urls using this method: https://codex.wordpress.org/Changing_The_Site_URL or http://codex.wordpress.or…
/* Set our Old and New URLS */
SET @oldurl := "http://www.oldsite.com";
SET @newurl := "http://www.newsite.com";
/* Replaces URL in WordPress Home and Site URL in wp_options */
UPDATE wp_options SET option_value = replace(option_value, @oldurl, @newurl) WHERE option_name = 'home' OR option_name = 'siteurl';
/* Replaces URL in GUID of all posts/cpt/etc */
/* https://deliciousbrains.com/wordpress-post-guids-sometimes-update/ */
UPDATE wp_posts SET guid = replace(guid, @oldurl, @newurl);
@algmelo
algmelo / gist:525ec35a0be84fb2e2d926d2ae76c39c
Created February 14, 2018 20:31
Wordpress - Criando arquivos de tradução para temas e plugins
Internacionalizando seu tema
Para tornar seu tema traduzível é necessário adicionar os seguintes comentários no arquivo style.css:
/**
* Theme Name: Apenas um exemplo
* Author: Autor do tema
* Text Domain: apenas-um-exemplo
* Domain Path: /languages
*/