Skip to content

Instantly share code, notes, and snippets.

View rafasashi's full-sized avatar
👍
Happy

Raphaël Dartigues rafasashi

👍
Happy
View GitHub Profile
@rafasashi
rafasashi / example_feed_xml_rss.xml
Created November 2, 2021 09:18 — forked from marcosnakamine/example_feed_xml_rss.xml
Google Merchant - Feed example in xml
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>Example - Online Store</title>
<link>http://www.example.com</link>
<description>
This is a sample feed containing the required and recommended attributes for a variety of different products
</description>
<!--
First example shows what attributes are required and recommended for items that are not in the apparel category
if( !is_admin() ):
add_filter('pre_get_posts','my_filter_the_search',10,1);
endif;
function my_filter_the_search($query){
$general_site_search = filter_input(INPUT_GET, 's', FILTER_SANITIZE_STRING);
if(!empty($general_site_search)):
add_filter( 'posts_search', '__search_by_title_only', 500, 2 );
@rafasashi
rafasashi / Wordpress Language Switcher Setting.php
Last active September 21, 2018 10:15
Add the following code in wp-config.php before requesting wp-settings.php https://code.recuweb.com/get/language-switcher/
// setup the main language from cookies
// to be added in wp-config.php before wp-settings
if( !empty($_COOKIE['lsw_main_lang']) ){
$locale = $_COOKIE['lsw_main_lang'] . '_' . strtoupper($_COOKIE['lsw_main_lang']);
if(!defined('WPLANG'))
define ('WPLANG', $locale);
}
@rafasashi
rafasashi / thousandsCurrencyFormat.php
Created September 1, 2018 15:25
Here comes a PHP function to format numbers to nearest thousands such as Kilos, Millions, Billions, and Trillions with comma https://code.recuweb.com/2018/php-format-numbers-to-nearest-thousands/
function thousandsCurrencyFormat($num) {
if( $num > 1000 ) {
$x = round($num);
$x_number_format = number_format($x);
$x_array = explode(',', $x_number_format);
$x_parts = array('k', 'm', 'b', 't');
$x_count_parts = count($x_array) - 1;
$x_display = $x;
@rafasashi
rafasashi / register_sidebar.php
Last active September 1, 2018 12:05
The register_sidebar() function in wordpress https://code.recuweb.com/
register_sidebar (array(
'name' => 'RightSideBar',
'id' => 'right-sidebar',
'description' => 'Widgets in this area will be shown on the right-hand side.',
'before_widget'=> '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
@rafasashi
rafasashi / php languages array
Created July 7, 2018 08:52
PHP var_export of 180+ languages with data including name, native, iso codes, language family, language script, language cultures, and other attributes
array (
'aa' =>
array (
'name' => 'Afar',
'native' => 'Afaraf',
'iso_639_1' => 'aa',
'iso_639_2' => 'aar',
'iso_639_3' => 'aar',
'script' =>
@rafasashi
rafasashi / index.php
Created April 11, 2017 11:53 — forked from amfeng/index.php
Stripe OAuth Example -- PHP
<?php
define('CLIENT_ID', 'YOUR_CLIENT_ID');
define('API_KEY', 'YOUR_API_KEY');
define('TOKEN_URI', 'https://connect.stripe.com/oauth/token');
define('AUTHORIZE_URI', 'https://connect.stripe.com/oauth/authorize');
if (isset($_GET['code'])) { // Redirect w/ code
$code = $_GET['code'];
@rafasashi
rafasashi / youtubeID.js
Created March 26, 2017 12:58 — forked from takien/youtubeID.js
Get YouTube ID from various YouTube URL using JavaScript
/**
* Get YouTube ID from various YouTube URL
* @author: takien
* @url: http://takien.com
* For PHP YouTube parser, go here http://takien.com/864
*/
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
@rafasashi
rafasashi / youtubeID.js
Created March 26, 2017 12:58 — forked from takien/youtubeID.js
Get YouTube ID from various YouTube URL using JavaScript
/**
* Get YouTube ID from various YouTube URL
* @author: takien
* @url: http://takien.com
* For PHP YouTube parser, go here http://takien.com/864
*/
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
@rafasashi
rafasashi / stripe_js_bootstrap.html
Created January 11, 2017 13:38 — forked from adamjstevenson/stripe_js_bootstrap.html
Stripe.js bootstrap example -- simple
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Stripe.js example form</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<h1>A simple Bootstrap Stripe.js payment form</h1>