Skip to content

Instantly share code, notes, and snippets.

View bepatrickdavid's full-sized avatar

bepatrickdavid bepatrickdavid

View GitHub Profile
@bepatrickdavid
bepatrickdavid / functions.php
Last active February 15, 2023 08:04
Simple Captcha Login WordPress
//CAPTCHA
// function number to word
function number_to_word($number) {
$words = array(
'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine',
'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen',
'twenty', 30 => 'thirty', 40 => 'forty', 50 => 'fifty', 60 => 'sixty', 70 => 'seventy', 80 => 'eighty', 90 => 'ninety'
);
if(!is_numeric($number)) {
:root {
--brown: #5b534f;
}
.wpcf7-acceptance .wpcf7-list-item {
margin-left: 0px;
margin-top: 10px;
margin-bottom: 10px;
}
@bepatrickdavid
bepatrickdavid / functions.php
Created January 17, 2022 09:03
Add ACF to WP REST API
// add this to functions.php
//register acf fields to Wordpress API
//https://support.advancedcustomfields.com/forums/topic/json-rest-api-and-acf/
function acf_to_rest_api($response, $post, $request) {
if (!function_exists('get_fields')) return $response;
if (isset($post)) {
$acf = get_fields($post->id);
$response->data['acf'] = $acf;
@bepatrickdavid
bepatrickdavid / index.php
Created November 26, 2019 09:16
WP: [Query] exclude latest post from the wordpress post loop with pagination
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 8,
'paged' => $paged,
'post__not_in' => array($idPostToExlude) );
$the_query = new WP_Query( $args );
@bepatrickdavid
bepatrickdavid / .htaccess
Created October 16, 2019 11:59
.htaccess: rewrite html extension and redirect to subfolder lang
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# redirect to subfolder /it if language is it
RewriteCond %{HTTP:Accept-Language} ^it [NC]
RewriteRule ^/?$ https://domain.com/it/ [R,NC,L]
# remove the .html extension
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\ HTTP
RewriteRule (.*)\.html$ $1 [R=301]
@bepatrickdavid
bepatrickdavid / .htaccess
Created May 6, 2019 09:03
Simple .htaccess https redirect
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@bepatrickdavid
bepatrickdavid / gist:43788b11a82c11c3cbdaad9877c4edba
Created March 1, 2019 16:38
.htaccess - block specific url deny url
My url: https://www.test.com/inc/example.xml
RewriteRule ^inc/example.xml - [F]
@bepatrickdavid
bepatrickdavid / es3.php
Created April 10, 2018 17:36
PHP: ordinare array di oggetti
//$d è un oggetto stdClass
//$newd = new stdClass;
//$newd->ID = "MAIN";
//$newd->NAME = "Look - The Concept Factory";
//$newd->ADDRESS = "Zona industriale Villanova, 19 32013 Longarone (BL) ITALY";
//$newd->TEL = "+390437573060";
//$newd->MAIL = "[email protected]";
//$newd->WEBSITE = "www.lookocchiali.it";
//$newd->DISTANCE = "";
@bepatrickdavid
bepatrickdavid / index.php
Created December 31, 2017 11:11
PHP: redirect 301 only home
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: https://newlocation/" );
?>
@bepatrickdavid
bepatrickdavid / gist:60b6b1d7659afd99fec8919d8d313f11
Last active December 21, 2017 09:02
.htaccess redirect 301
RewriteEngine On
Redirect 301 pagina1.html http://www.miosito.com/pagina2.html