Skip to content

Instantly share code, notes, and snippets.

View pabamato's full-sized avatar

Pablo Amato pabamato

  • Montevideo, Uruguay
View GitHub Profile
@pabamato
pabamato / .phpcs.xml
Last active March 1, 2022 15:07
PHPCS safe to ignore rules
<?xml version="1.0"?>
<ruleset name="Project Rules">
<rule ref="WordPress" />
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/dist/</exclude-pattern>
<config name="testVersion" value="7.4-"/>
<rule ref="WordPress">
<exclude name="Generic.Classes.OpeningBraceSameLine.BraceOnNewLine"/>
<exclude name="Generic.Commenting.DocComment.Empty"/>
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
@pabamato
pabamato / reports.txt
Created November 24, 2021 21:30 — forked from zircote/reports.txt
phpcs report types
phpcs --standard=tests/build/phpcs.xml --report=summary .
PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------------
FILE ERRORS WARNINGS
--------------------------------------------------------------------------------
/usr/local/zend/apache2/htdocs/project/application/Bootstrap.php 1 4
...2/htdocs/Project/application/controllers/ActivityController.php 3 1
...
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
<?xml version="1.0"?>
<ruleset name="10up PHPCS">
<description>10up PHPCS extended.</description>
<rule ref="10up-Default" />
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/dist/</exclude-pattern>
<exclude-pattern>/wordpress-fieldmanager/</exclude-pattern>
<config name="testVersion" value="7.3-"/>
<?php
/**
* Check if post type uses classic editor.
* Used for adding tinyMCE buttons
*
* @return boolean
*/
public static function post_type_uses_classic_editor() {
$screen = get_current_screen();
if ( empty( $screen ) ) {
# UPDATE ADMIN EMAIL FOR SUB-SITES
wp site list --field=blog_id | \
xargs -n1 -I {} sh -c '\
if [ "1" != {} ]; then \
echo "Blog ID: {}" && \
wp db query '\''UPDATE wp_{}_options SET option_value="admin@domain.com" WHERE option_name="admin_email"'\'' --skip-column-names
fi \
'
# DISPLAY ADMIN EMAIL
@pabamato
pabamato / acf_support_default_param.php
Created January 6, 2020 21:58
Custom rewrite for ACF get_field / the_field, add support for default value
<?php
/**
* Custom rewrite for ACF get_field() with support for returning a default value.
*
* @param string $field_name ACF Field name.
* @param string $default Default value to return if empty setting.
* @param mixed $post_id The post_id of which the value is saved against.
* @param boolean $format_value Whether or not to format the value.
* @return string ACF field value or default.
*/
@pabamato
pabamato / export-acf-fields
Last active August 31, 2022 15:45
Export ACF fields to local json
<?php
add_action( 'wp_loaded', 'export_acf_fields' );
/**
* Export ACF fields to json.
*
* The "acf-json" folder must exists within your theme.
*
* @return void
<?php
$url = 'http://www.subdomain1.subdomain2.subdomain3.maindomain.co.uk/asdasdsad/?asdsad=0&asdad=1&sadsa=2';
pretty_debug( op_get_domain( $url ) );
/**
* Return main domain from URL
*
* @param string $url URL to extract from.
* @return mixed Domain | false
@pabamato
pabamato / movegfjstofooter.php
Created July 7, 2018 05:11 — forked from eriteric/movegfjstofooter.php
Load gravity forms JS in footer
// GF method: http://www.gravityhelp.com/documentation/gravity-forms/extending-gravity-forms/hooks/filters/gform_init_scripts_footer/
add_filter( 'gform_init_scripts_footer', '__return_true' );
// solution to move remaining JS from https://bjornjohansen.no/load-gravity-forms-js-in-footer
add_filter( 'gform_cdata_open', 'wrap_gform_cdata_open' );
function wrap_gform_cdata_open( $content = '' ) {
$content = 'document.addEventListener( "DOMContentLoaded", function() { ';
return $content;
}
add_filter( 'gform_cdata_close', 'wrap_gform_cdata_close' );