Skip to content

Instantly share code, notes, and snippets.

View larodiel's full-sized avatar

Victor Larodiel larodiel

View GitHub Profile
@larodiel
larodiel / functions.php
Created November 13, 2023 11:50
Limit Wordpress RSS Items using parameters
<?php
add_action('pre_get_posts', function($query) {
if ($query->is_feed() && filter_input(INPUT_GET, 'count', FILTER_VALIDATE_INT) && filter_input(INPUT_GET, 'count', FILTER_VALIDATE_INT)) {
$query->set('posts_per_rss', filter_input(INPUT_GET, 'count', FILTER_VALIDATE_INT));
}
return $query;
});
@larodiel
larodiel / .gitignore_global
Created March 4, 2023 05:48
Global gitignore
# -----------------------------------------------------------------
# ver 1.1.0
#
# Change Log:
# 20160721 - First version
# 20171018 - error_log added
# -----------------------------------------------------------------
# ignore all files starting with . or ~
.*
@larodiel
larodiel / functions.php
Created December 13, 2022 01:53
Set the ACF SYNC path on sage template
<?php
add_filter('acf/settings/save_json', function($path) {
return get_stylesheet_directory() . '/acf-json';
});
add_filter('acf/settings/load_json', function($paths) {
unset($paths[0]);
$paths[] = get_stylesheet_directory() . '/acf-json';
return $paths;
@larodiel
larodiel / functions.php
Last active December 13, 2022 01:51
Add the colors that are on WP theme.json on ACF Color pick
<?php
add_action('acf/input/admin_footer', function() {
$themeJsonFile = get_stylesheet_directory() . '/theme.json';
if(file_exists($themeJsonFile)) {
$themeJson = json_decode(file_get_contents($themeJsonFile));
$colorsArray = [];
$colorsJson = '';
foreach($themeJson->settings->color->palette as $color) {
$colorsArray[] = $color->color;
@larodiel
larodiel / functions.php
Created April 2, 2022 05:48
Load a single post page based on the category (can be adapted to taxonomy)
<?php
/**
* Load Single Page by Category
*/
add_filter('single_template', function ($template) {
foreach ((array) get_the_category() as $cat) {
$templateFile = STYLESHEETPATH . "/single-category-{$cat->slug}.php";
if (file_exists($templateFile)) {
@larodiel
larodiel / .eslintrc.js
Created August 14, 2021 07:35
BasicGulp file to simple front end
module.exports = {
'root': true,
'extends': 'eslint:recommended',
'globals': {
'wp': true,
},
'env': {
'node': true,
'es6': true,
'amd': true,
@larodiel
larodiel / docker-compose.md
Last active July 30, 2021 23:46
Docker Compose to Wordpress, MySQL, wp-cli & phpMyAdmin

Wordpress, wordpress-cli, phpMyAdmin

This file will setup Wordpress, wordpress-cli & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yml" and run the command

#To Start
$ docker-compose up -d

# To Stop
@larodiel
larodiel / regex.txt
Last active November 11, 2021 20:37
Useful regEx
USER_NAME = "^[A-Za-z0-9_-]{min number of character,max number of character}$";
TELEPHONE = "(^\\+)?[0-9()-]*";
TELEPHONE_OPTIONAL = "^($|(^\\+)?[0-9()-]*)$"
EMAIL = "^([a-zA-Z0-9\.\_\+\-]+)@([a-zA-Z0-9\-]+)(\.[a-zA-Z]+)+$";
EMAIL_OPTIONAL = "^($|[a-zA-Z0-9_\\.\\+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-\\.]+)$";
@larodiel
larodiel / index.php
Created April 6, 2021 04:24
ACF meta query to exclude posts
<?php
// WP_Query arguments
$args = array(
'post_type' => 'post',
'post_status' => array( 'publish' ),
'posts_per_page' => -1,
'ignore_sticky_posts' => true,
'meta_query' => array(
'relation' => 'OR',
@larodiel
larodiel / settings.json
Last active February 25, 2020 05:50
Visual Studio Code
{
/*
Plugins
- phpfmt - PHP formatter <https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt>
- phpcs - <https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs>
- PHP IntelliSense - <https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-intellisense>
- PHP DocBlocker - <https://marketplace.visualstudio.com/items?itemName=neilbrayfield.php-docblocker>
- Sass - <https://marketplace.visualstudio.com/items?itemName=Syler.sass-indented>
- SCSS IntelliSense <https://marketplace.visualstudio.com/items?itemName=mrmlnc.vscode-scss>
- SCSS Everywhere <https://marketplace.visualstudio.com/items?itemName=gencer.html-slim-scss-css-class-completion>