Skip to content

Instantly share code, notes, and snippets.

View mrfoxtalbot's full-sized avatar
🥐

Alvaro Gómez Velasco mrfoxtalbot

🥐
View GitHub Profile
@mrfoxtalbot
mrfoxtalbot / cpt-block-prepopulate.php
Created May 30, 2023 11:35
Prepopulate CPTs with a reusable block and convert it to a regular block automatically
function convert_reusable_block_to_regular_block($data, $postarr) {
// Check if it's a new custom post type
if ($data['post_type'] === 'your_custom_post_type' && $data['post_status'] === 'auto-draft') {
$reusable_block_post = get_page_by_title('your_reusable_block_name', OBJECT, 'wp_block');
// Check if the reusable block exists
if ($reusable_block_post !== null) {
$reusable_block_content = $reusable_block_post->post_content;
// Convert the reusable block into a regular block
@mrfoxtalbot
mrfoxtalbot / Showallthreads.user.js
Last active June 29, 2023 13:50
Show all threads in WP.org
// ==UserScript==
// @name WordPress topic redirect
// @namespace WordPress_topic_redirect
// @description Forces https, adds view=all to topic urls and redirects if needed.
// @version 1
// @grant none
// @run-at document-start
// @include *://*wordpress.org/support/topic/*
// @include https://wordpress.org/support/plugin/*
// @include https://wordpress.org/support/theme/*
@mrfoxtalbot
mrfoxtalbot / wporg-forums-highlighter.js
Created October 1, 2022 05:51
WordPress.org plugins topic highlighter
// ==UserScript==
// @name WordPress.org plugins topic highlighter
// @namespace http://clorith.net/
// @version 0.1
// @description Add status highlights to topics for easy overviews.
// @author Clorith
// @match https://wordpress.org/support/*
// @require https://code.jquery.com/jquery-1.11.0.min.js
// @grant none
// ==/UserScript==
@mrfoxtalbot
mrfoxtalbot / replace-menu-icon-tt2.php
Created September 16, 2022 09:57
Replace Burger menu with a different SVG icon in the Twenty Twenty-Two theme
<?php function custom_render_block_core_navigation (string $block_content, array $block)
{
if (
$block['blockName'] === 'core/navigation' &&
!is_admin() &&
!wp_is_json_request()
) {
return preg_replace('/\<svg width(.*?)\<\/svg\>/', 'add your SVG here', $block_content);
}
@mrfoxtalbot
mrfoxtalbot / term-description-image-2.php
Last active July 15, 2022 10:56
Salimos de Bilbao Archives
<?php
get_header();
$term = get_queried_object();
$term_title = single_term_title();
$term_description = term_description();
$term_children = get_term_children( $term->term_id, $term->taxonomy );
$has_children = ! is_wp_error( $term_children ) && ! empty( $term_children );
@mrfoxtalbot
mrfoxtalbot / Eva-guillamon.css
Last active June 14, 2022 23:10
Custom CSS Styles for evaguillamon.com
/* Ajustes Generales */
body {
font-size: 12px;
color: #666;
}
@media screen and (min-width: 1120px) {
.site {
margin-top: 0;
}
@mrfoxtalbot
mrfoxtalbot / gist:9bd39a4bd9af6c7af18455ca2ef19b19
Created June 9, 2022 22:24
Archive of Hierarchical terms
// parent theme: Benevolent
// author: igmoweb
<?php
get_header();
$term = get_queried_object();
$term_children = get_term_children( $term->term_id, $term->taxonomy );
$has_children = ! is_wp_error( $term_children ) && ! empty( $term_children );
@mrfoxtalbot
mrfoxtalbot / Benevolent-archive.php
Created April 8, 2022 15:30
List child terms. If no child terms, list posts
<?php
/**
* The template for displaying archive pages.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package Benevolent
*/
get_header(); ?>
@mrfoxtalbot
mrfoxtalbot / projectaon-mobile-friendly.css
Last active August 26, 2021 12:28
Mobile friendly CSS styles for projectaon
// Here is a video explaining the code https://d.pr/v/WQ6w7R
// We need to incluide this <meta> tag inside the <head> HTML tag:
// <meta name="viewport" content="width=device-width, initial-scale=1.0">
// Below are the actual CSS styles that need to be added to the "more.css" stylesheet
/* Prevent horizontal overflow */
html {
max-width: 100%;
overflow-x: hidden
@mrfoxtalbot
mrfoxtalbot / single.php
Last active May 10, 2021 15:09
Error in lines 31 & 53
// Warning: Illegal string offset 'alt' in /usr/home/josemorraja.com/web/wp-content/themes/josemorraja-v4/single.php on line 53
// Warning: Illegal string offset 'id' in /usr/home/josemorraja.com/web/wp-content/themes/josemorraja-v4/single.php on line 31
<?php get_template_part('parts/header'); ?>
<div class="container">
<div class="row">