E-Learning

Here are 4 Marketo Templates that I delivered to the agency Otowui.com for its client, an e-learning provider.

Custom Button Shortcode #wordpress
// functions.php
function custom_button_shortcode( $atts, $content = null ) {
	extract( shortcode_atts( array(
		'url'    => '',
		'title'  => '',
		'target' => '',
		'text'   => '',
	), $atts ) );
	$content = $text ? $text : $content;
	if ( $url ) {
		$link_attr = array(
			'href'   => esc_url( $url ),
			'title'  => esc_attr( $title ),
			'target' => ( 'blank' == $target ) ? '_blank' : '',
			'class'  => 'custombutton'
		);
		$link_attrs_str = '';
		foreach ( $link_attr as $key => $val ) {
			if ( $val ) {
				$link_attrs_str .= ' ' . $key . '="' . $val . '"';
			}
		}
		return '<a' . $link_attrs_str . '>' . do_shortcode( $content ) . '</a>';
	} else {
		return '<span class="custombutton"><span>' . do_shortcode( $content ) . '</span></span>';
	}
}
add_shortcode( 'custombutton', 'custom_button_shortcode' );
function register_button( $buttons ) {
   array_push( $buttons, "|", "custombutton" );
   return $buttons;
}
function add_plugin_custom_button( $plugin_array ) {
	$plugin_array['custombutton'] = get_template_directory_uri() . '/js/custombutton.js';
   return $plugin_array;
}
function my_custom_button_shortcode() {
   if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
	  return;
   }
   if ( get_user_option('rich_editing') == 'true' ) {
	  add_filter( 'mce_external_plugins', 'add_plugin_custom_button' );
	  add_filter( 'mce_buttons', 'register_button' );
   }
}
add_action('init', 'my_custom_button_shortcode');
// custombutton.js
(function() {
   tinymce.create('tinymce.plugins.custombutton', {
	  init : function(ed, url) {
		 ed.addButton('custombutton', {
			title : 'Custom Button',
			image : url+'/custombutton.svg',
			onclick : function() {
			   	var href = prompt("Href", "https://go.merlinleonard.com/");
				var title = prompt("Title", "Call to Action");
				var target = prompt("Target", "_blank");
				ed.execCommand('mceInsertContent', false, '[custombutton url="'+href+'" target="'+target+'" text="'+title+'"]');
			}
		 });
	  },
	  createControl : function(n, cm) {
		 return null;
	  },
	  getInfo : function() {
		 return {
			longname : "Custom Button",
			author : 'Otowui.com',
			authorurl : 'https://www.otowui.com',
			version : "1.0"
		 };
	  }
   });
   tinymce.PluginManager.add('custombutton', tinymce.plugins.custombutton);
})();
// custombutton.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M384 32H64C28.65 32 0 60.65 0 96v320c0 35.34 28.65 64 64 64h320c35.35 0 64-28.66 64-64V96C448 60.65 419.3 32 384 32zM330.5 323.9c0 6.473-3.889 12.3-9.877 14.78c-5.979 2.484-12.86 1.105-17.44-3.469l-45.25-45.25l-67.92 67.92c-12.5 12.5-32.72 12.46-45.21-.0411l-22.63-22.63C109.7 322.7 109.6 302.5 122.1 289.1l67.92-67.92L144.8 176.8C140.2 172.2 138.8 165.3 141.3 159.4c2.477-5.984 8.309-9.875 14.78-9.875h158.4c8.835 0 15.1 7.163 15.1 15.1V323.9z"/></svg>
   Otowui

Custom website of a web application allowing users to generate their email templates for many providers such as Marketo, Pardot, Mailchimp…

   Cyber Security

Here are 2 Marketo Templates & a polygon generator that I delivered to the agency Otowui.com for its client, an online security provider.

Custom Image Shortcode #wordpress
//functions.php
function customimage_shortcode( $atts, $content = null ) {
	extract( shortcode_atts( array(
		'url'    => '',
		'text'   => '',
	), $atts ) );
	$imgurl = $url ? $url : $imgurl;
	$content = $text ? $text : $content;
	if ( $url ) {
		foreach ( $link_attr as $key => $val ) {
			if ( $val ) {
				$link_attrs_str .= ' ' . $key . '="' . $val . '"';
			}
		}
		return '<figure class="customimage"><img src="' . $imgurl . '"/><figcaption>' . do_shortcode( $content ) . '</figcaption></figure>';
		
	}
}
add_shortcode( 'customimage', 'customimage_shortcode' );
function register_customimage( $buttons ) {
   array_push( $buttons, "", "customimage" );
   return $buttons;
}
function add_plugin_customimage( $plugin_array ) {
	$plugin_array['customimage'] = get_template_directory_uri() . '/js/customimage.js';
   return $plugin_array;
}
function my_customimage_shortcode() {
   if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
	  return;
   }
   if ( get_user_option('rich_editing') == 'true' ) {
	  add_filter( 'mce_external_plugins', 'add_plugin_customimage' );
	  add_filter( 'mce_buttons', 'register_customimage' );
   }
}
add_action('init', 'my_customimage_shortcode');
// customimage.js
(function() {
   tinymce.create('tinymce.plugins.customimage', {
	  init : function(ed, url) {
		 ed.addButton('customimage', {
			title : 'Custom Image',
			image : url+'/customimage.svg',
			onclick : function() {
				var title = prompt("Text", "Call to Action");
				var target = prompt("Target", "_blank");
				ed.execCommand('mceInsertContent', false, '[customimage url="'+href+'" text="'+title+'"]');
			}
		 });
	  },
	  createControl : function(n, cm) {
		 return null;
	  },
	  getInfo : function() {
		 return {
			longname : "Custom Image",
			author : 'Otowui.com',
			authorurl : 'https://www.otowui.com',
			version : "1.0"
		 };
	  }
   });
   tinymce.PluginManager.add('customimage', tinymce.plugins.customimage);
})();
// customimage.svg
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 448 512" style="enable-background:new 0 0 448 512;" xml:space="preserve"><path d="M146.7,228.1l-46.7,64c-3.5,4.9-4.1,11.3-1.3,16.7c2.8,5.3,7.4,8.7,14.3,8.7h224c5.9,0,11.3-3.2,14.1-8.4 c2.8-5.2,2.5-11.5-0.8-16.4l-85.3-128c-3-4.4-8-7.1-13.3-7.1s-10.4,2.7-13.3,7.1l-53.6,80.3l-12.2-16.8c-3-4.2-7.8-6.6-12.9-6.6 S149.8,223.9,146.7,228.1z M401,29.5H49c-26.4,0-48,21.6-48,48v352c0,26.4,21.6,48,48,48h352c26.4,0,48-21.6,48-48v-352 C449,51.1,427.4,29.5,401,29.5z M385,349.5H65v-256h320V349.5z M129,189.5c17.6,0,32-14.4,32-32s-14.4-32-32-32s-32,14.4-32,32 S111.4,189.5,129,189.5z"/></svg>
Fetch .json file #Javascript
function fetchJSONFile(path, callback) {
    var httpRequest = new XMLHttpRequest();
    httpRequest.onreadystatechange = function() {
        if (httpRequest.readyState === 4) {
            if (httpRequest.status === 200) {
                var data = JSON.parse(httpRequest.responseText);
                if (callback) callback(data);
            }
        }
    };
    httpRequest.open('GET', path);
    httpRequest.send(); 
}

fetchJSONFile('file.json', function(data){
	// Do something with Data
    console.log(data);
});
Unregister widgets #wordpress
// unregister all widgets
function unregister_default_widgets() {
	unregister_widget('WP_Widget_Pages');
	unregister_widget('WP_Widget_Calendar');
	unregister_widget('WP_Widget_Archives');
	unregister_widget('WP_Widget_Links');
	unregister_widget('WP_Widget_Meta');
	unregister_widget('WP_Widget_Search');
	unregister_widget('WP_Widget_Text');
	unregister_widget('WP_Widget_Categories');
	unregister_widget('WP_Widget_Recent_Posts');
	unregister_widget('WP_Widget_Recent_Comments');
	unregister_widget('WP_Widget_RSS');
	unregister_widget('WP_Widget_Tag_Cloud');
	unregister_widget('WP_Nav_Menu_Widget');
	unregister_widget('Twenty_Eleven_Ephemera_Widget');
	unregister_widget('WP_Widget_Media_Audio');
	unregister_widget('WP_Widget_Media_Image');
	unregister_widget('WP_Widget_Media_Video');
	//unregister_widget('WP_Widget_Custom_HTML');
}
add_action('widgets_init', 'unregister_default_widgets', 11);
   Trésors des Bibliothèques Universitaires d’Aix-Marseille

Custom WordPress theme made for the University of Aix-Marseille in France, design provided by the agency Check Ca!.

Pdo Query for noobs #PHP
<?php
// Set
global $pdo;
if (isset($pdo)) {return;} 
mysqli_report(MYSQLI_REPORT_STRICT);
$pdo = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME);
// Set the PDO::ATTR_EMULATE_PREPARES Attribute to false
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
if (mysqli_connect_errno()) {		
  die(sprintf("Connect failed: %s\n", mysqli_connect_error()));
}
// Prepared Statements
$firstname = "bruce";
$sql = "SELECT * FROM users WHERE firstname =:fname ;";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(":fname", $firstname);
$stmt->execute();
if(!$result = $stmt->fetch(PDO::FETCH_OBJ)){
    echo "Credentials do no match";
} else {
    echo"Id: ".$result->id. " Name: ".$result->firstname." ".$result->lastname;
}
// Prepared Statements With Parameterized Query
$firstname = "jeff";
$sql = "SELECT * FROM users WHERE firstname = ?";
$stmt = $pdo->prepare($sql);
$stmt->bind_param("s", $firstname);
$stmt->execute();
$result = $stmt->get_result();
if($result->num_rows === 0) exit('No rows');
while($row = $result->fetch_assoc()) {
    echo"Id: ".$row['id']. " Name: ".$row['firstname']." ".$row['lastname'];
}

No more items to load