Skip to content

Instantly share code, notes, and snippets.

View AladinDridi's full-sized avatar
🎯
Focusing

Aladin Dridi AladinDridi

🎯
Focusing
  • Montréal
View GitHub Profile
<?php
$product_id=359;
$url='';
//check if product already in cart
if (WC()->cart->get_cart_contents_count() == 0 ) {
WC()->cart->add_to_cart($product_id);
wp_redirect($url);
exit();
}
else{
function iframe_loggedout($msg){
$msg = shortcode_atts(
array(
'lien' => '',
), $msg, 'iframe_loggedout_link');
if(wp_is_mobile()){
return '<iframe width="560" height="315" src="'.$msg['lien'].'" frameborder="0" allowfullscreen></iframe>';
}
}
add_shortcode('iframe_loggedout_link','iframe_loggedout');
add_filter('woocommerce_available_payment_gateways','filter_gateways',1);
function filter_gateways($gateways){
global $woocommerce;
$inarray = false;
$specialItem=array(492496,492551,492563,492583,492589,492606,492623,492636,492690,492702,492708,492832,492840,492887,492903,492914,492926,492939,493010,493019,493027,493293,493460,493467);//array contains ids of many products //
foreach ($woocommerce->cart->cart_contents as $key => $values ) {//enumerate over all cart contents
if(in_array($values['product_id'],$specialItem)){//if special item is in it
$inarray = true;//set inarray to true
}
<?php
if(!is_user_logged_in()){
wp_redirect('https://www.kademia.tn/wp-login.php');
exit;
}
$msg="";
$url= bp_learndash_adminbar_nav_link(bp_learndash_profile_courses_slug());
$user_id = get_current_user_id();
if($_POST){
if ((trim($_POST['question1'])=="9789938210132")&&(trim($_POST['question2'])=="171")&&($_POST['choices']=="valeur1")){
<html>
<head>
<title>Emoticone cry</title>
<meta charset="utf-8"/>
<style>
canvas{
border :1px dotted blue;
width:600px;
height: 300px;
}
@AladinDridi
AladinDridi / gist:655f2483a24dc4887bfefba70839368c
Created December 19, 2017 10:19
json php gist-working code
<?php
$mysql_db_hostname = "localhost";
$mysql_db_user = "root";
$mysql_db_password = "";
$mysql_db_database = "calendar";
$con = @mysqli_connect($mysql_db_hostname, $mysql_db_user, $mysql_db_password,
$mysql_db_database);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
.element2{
border: 1px solid black;
}
</style>
.thim-right-bg-secondary-color:before {
background: #28317c;
}
.textwidget:nth-child(2) > p{
display:none;
}
footer#colophon {
background: #28317c;
}
.thim-footer-info-4 .info .heading {
<script>
var textarray = [
"Question 1",
"Question 2",
"Question 3"
// pas virgule aprés dernier champs du tableau //
];
function RndText() {
var rannum= Math.floor(Math.random()*textarray.length);
<script>
var table = document.getElementsByTagName("html");
statu=table[0].getAttribute("lang");
if(statu=="fr-FR"){
var idcourses = document.getElementById("user-cours");
idcourses.textContent="Mes cours";
}
</script>