Skip to content

Instantly share code, notes, and snippets.

View devuri's full-sized avatar

uri devuri

  • Mexico
View GitHub Profile
@devuri
devuri / .env-exampe
Last active February 1, 2021 05:18
WordPres ENV file example
WP_HOME=http://localhost
WP_SITEURL=http://localhost
DB_NAME=
DB_USER=root
DB_PASSWORD=
DB_HOST=127.0.0.1
DB_PREFIX=
WP_ENV=production
@devuri
devuri / composer.json
Last active February 1, 2021 04:19
Secure Your WordPress config file with environment variables using Composer
{
"require": {
"php": "^7.0",
"roots/wp-config": "1.0.0",
"symfony/error-handler": "^5.1",
"symfony/var-dumper": "^5.1.4",
"vlucas/phpdotenv": "^5.2"
},
"config": {
"optimize-autoloader": true,
@devuri
devuri / is_rest.php
Created January 17, 2021 09:20 — forked from matzeeable/is_rest.php
Checks if the current request is a WP REST API request.
<?php
if ( !function_exists( 'is_rest' ) ) {
/**
* Checks if the current request is a WP REST API request.
*
* Case #1: After WP_REST_Request initialisation
* Case #2: Support "plain" permalink settings
* Case #3: It can happen that WP_Rewrite is not yet initialized,
* so do this (wp-settings.php)
@devuri
devuri / wp-auto-update.php
Created November 5, 2020 20:11
How to extend core major versions auto-updates feature?
<?php
// https://make.wordpress.org/core/2020/11/02/introducing-auto-updates-interface-for-core-major-versions-in-wordpress-5-6/
function my_plugin_after_core_auto_updates_settings_fields( $auto_update_settings ) {
if ( isset( $_POST['core-auto-updates-settings'] ) && wp_verify_nonce( $_POST['set_core_auto_updates_settings'], 'core-auto-updates-nonce' ) ) {
if ( isset( $_POST['my-plugin-core-auto-updates-minor'] ) && 1 === (int) $_POST['my-plugin-core-auto-updates-minor'] ) {
update_site_option( 'my_plugin_auto_update_core_minor', 1 );
} else {
update_site_option( 'my_plugin_auto_update_core_minor', 0 );
}
@devuri
devuri / forms-with-tabs.markdown
Created August 22, 2020 15:44
Forms with Tabs
@devuri
devuri / wp_insert_attachment_from_url.php
Created August 9, 2020 07:46 — forked from m1r0/wp_insert_attachment_from_url.php
WP: Insert attachment from URL
<?php
/**
* Insert an attachment from an URL address.
*
* @param String $url
* @param Int $parent_post_id
* @return Int Attachment ID
*/
function crb_insert_attachment_from_url($url, $parent_post_id = null) {
@devuri
devuri / index.haml
Created August 4, 2020 19:19
Simple SCSS Loading Spinner with step() Animation
.loader
- 1..12.times do
.prong
.inner
@devuri
devuri / Contract Killer 3.md
Created June 15, 2020 23:58
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post