//Append url parameters to links with classname
(function() {
var domainsToDecorate = ['domain.com'], queryParams = ['utm_medium','utm_source','utm_campaign','utm_term','utm_content'];
var links = document.querySelectorAll('.rewrite-url'); 
for (var linkIndex = 0; linkIndex < links.length; linkIndex++) {
 for (var domainIndex = 0; domainIndex < domainsToDecorate.length; domainIndex++) { 
   if (links[linkIndex].href.indexOf(domainsToDecorate[domainIndex]) > -1 && links[linkIndex].href.indexOf("#") === -1) {
	 links[linkIndex].href = decorateUrl(links[linkIndex].href);
   }
 }
}
function decorateUrl(urlToDecorate) {
 urlToDecorate = (urlToDecorate.indexOf('?') === -1) ? urlToDecorate + '?' : urlToDecorate + '&';
 var collectedQueryParams = [];
 for (var queryIndex = 0; queryIndex < queryParams.length; queryIndex++) {
   if (getQueryParam(queryParams[queryIndex])) {
	 collectedQueryParams.push(queryParams[queryIndex] + '=' + getQueryParam(queryParams[queryIndex]))
   }
 }
 return urlToDecorate + collectedQueryParams.join('&');
}
function getQueryParam(name) {
 if (name = (new RegExp('[?&]' + encodeURIComponent(name) + '=([^&]*)')).exec(window.location.search))
   return decodeURIComponent(name[1]);
}
// http://jsfiddle.net/jnelsonin/ctfy158o/
$("#pixels").keyup(function(){      		
 var point = ($(this).val() * 3) / 4;
 var yem = point / 12;
 var percent = yem * 100;
      		
 $("#point").text(point+"pt");
 $("#yem").text(yem+"em");
 $("#percent").text(percent+"%");
});
<?php
$pagelist = get_pages("child_of=".$post->post_parent."&parent=".$post->post_parent."&sort_column=menu_order&sort_order=asc");
$pages = array();
foreach ($pagelist as $page) {
   $pages[] += $page->ID; 
}
$current = array_search($post->ID, $pages);
$prevID = $pages[$current-1];
$nextID = $pages[$current+1];

if (!empty($prevID) || !empty($nextID)) { ?>
<div class="navigation-wrapper">
	<div class="navigation">
		<?php if (!empty($prevID)) { ?>
		<div class="cell cell-previous">
			<a href="<?php echo get_permalink($prevID); ?>" title="<?php echo get_the_title($prevID); ?>">
				Précédent<br>
				<strong><?php echo get_the_title($prevID); ?></strong>
			</a>
		</div>
		<?php } ?>
		<?php if (!empty($nextID)) { ?>
		<div class="cell cell-next">
			<a href="<?php echo get_permalink($nextID); ?>" title="<?php echo get_the_title($nextID); ?>">
				Suivant<br>
				<strong><?php echo get_the_title($nextID); ?></strong>
			</a>
		</div>
		<?php } ?>
	</div>
</div>
// https://legacydocs.hubspot.com/global-form-events
// onBeforeFormInit - onFormReady - onFormSubmit - onFormSubmitted
window.addEventListener('message', event => {
 if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
  // Form Ready
 } else if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') {
  // Form Submit
 }
});
//FUNC FROM https://jsfiddle.net/asheroto/u7hfjm9k/
function IP6to4(ip6) {
    function parseIp6(ip6str) {
        const str = ip6str.toString();

        // Initialize
        const ar = new Array();
        for (var i = 0; i < 8; i++) ar[i] = 0;

        // Check for trivial IPs
        if (str == '::') return ar;
        
        // Parse
        const sar = str.split(':');
        let slen = sar.length;
        if (slen > 8) slen = 8;
        let j = 0;
        i = 0
        for (i = 0; i < slen; i++) {
            // This is a "::", switch to end-run mode
            if (i && sar[i] == '') {
                j = 9 - slen + i;
                continue;
            }
            ar[j] = parseInt(`0x0${sar[i]}`);
            j++;
        }

        return ar;
    }

    var ip6parsed = parseIp6(ip6);
    const ip4 = `${ip6parsed[6] >> 8}.${ip6parsed[6] & 0xff}.${ip6parsed[7] >> 8}.${ip6parsed[7] & 0xff}`;
    return ip4;
}
// define the woocommerce_created_customer callback 
function action_woocommerce_created_customer( $customer_id, $new_customer_data, $password_generated ) { 
    // make action magic happen here... 
};
// add the action 
add_action( 'woocommerce_created_customer', 'action_woocommerce_created_customer', 10, 3 ); 
//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>
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);
});
# Mod_Security Error Response body too large
# Domains > domain.com > Apache & nginx Settings > Additional directives for HTTPS
<IfModule mod_security2.c>
    SecResponseBodyLimit 546870912
</IfModule>
// Iframe Container
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
jQuery(function() {
	var oldIframe = jQuery('#iframe');
	if (oldIframe.length) {
		var src = oldIframe.attr('src');
		if (src) {
			var iframeContent = $('<iframe id="iframe-new" src="' + src + location.search + '" style="border: none;width: 100%;background-color:#fff;"></iframe>');
			oldIframe.replaceWith(iframeContent);
		}
	}
});
</script>
<iframe id="iframe" src="https://go.domain.com/form.html"></iframe>
// 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);

Output http headers values

<?php 			
// GET HTTP HEADERS VALUES
// SINGLE VALUE - Replace XXXXXX_XXXX with the name of the header you need in UPPERCASE (and with '-' replaced by '_')
$headerStringValue = $_SERVER['HTTP_XXXXXX_XXXX'];
echo $headerStringValue;
// GET ALL HEADERS			
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
    echo "$header : $value \n";
} ?>

Output POST key and values

<?php foreach ($_POST as $key => $value) {
        echo "$key : $value \n";
    }
?>

Basic PDO Queries

<?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'];
}
/* Create iFrame from Textarea Content Html */
function setFrame() {
    var HTMLval = TextareaContentID.value;
    var iframe = document.getElementById('iframeID');
    iframe.contentWindow.document.open();
    iframe.contentWindow.document.write(HTMLval);
    iframe.contentWindow.document.close();
}
/* Download Textarea Content as Html File.js */
$('#download-button').click(function() {
    if ('Blob' in window) {
        var fileName = prompt('Please enter file name to save', 'Untitled.html');
        if (fileName) {
            var textValue = $('textarea').html();
            var textToWrite = htmlDecode(textValue);
            var textFileAsBlob = new Blob([textToWrite], {
                type: 'application/xhtml+xml'
            });
            if ('msSaveOrOpenBlob' in navigator) {
                navigator.msSaveOrOpenBlob(textFileAsBlob, fileName);
            } else {
                var downloadLink = document.createElement('a');
                downloadLink.download = fileName;
                downloadLink.innerHTML = 'Download File';
                if ('webkitURL' in window) {
                    downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
                } else {
                    downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
                    downloadLink.click(function() {
                        document.body.removeChild(event.target);
                    });
                    downloadLink.style.display = 'none';
                    document.body.appendChild(downloadLink);
                }
                downloadLink.click();
            }
        }
    } else {
        alert('Your browser does not support the HTML5 Blob.');
    }
});
/* trim-whitespace-input.js*/
$('.no-spaces-field').keyup(function() {
  $(this).val($(this).val().replace(/ +?/g, ''));
});
# increase timeout response( 504 Gateway Time-out)
# Domains > example.com > Apache & nginx Settings.
FcgidIdleTimeout 1200
FcgidProcessLifeTime 1200
FcgidConnectTimeout 1200
FcgidIOTimeout 1200
Timeout 1200
ProxyTimeout 1200
<!-- Iframe Container -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var Iframe = jQuery('#iframe');
window.addEventListener('message', function(e) { 
	var eventName = e.data[0]; 
	var data = e.data[1]; 
	switch(eventName) { 
		case 'setHeight': 
			newIframe.height(data); 
		break;
	} 
}, false);
</script>
<iframe id="iframe" src="https://go.domain.com/form.html"></iframe>
<!-- Iframe Content -->
<script>
var StatusResizing = 'on';
setInterval(function() {
	if(StatusResizing == 'on') {
		resize();
	}
}, 1000);
function resize() {
	var height = $('body').outerHeight();
	window.parent.postMessage(["setHeight", height], "*"); 
}</script>
 // Hide Div when Click Outside of the Element using jQuery / https://www.codexworld.com/
$(document).mouseup(function(e){
    var container = $("#elementID");
    // If the target of the click isn't the container
    if(!container.is(e.target) && container.has(e.target).length === 0){
        container.hide();
    }
});
// REORDER MENU
add_filter('custom_menu_order', function() { return true; });
add_filter('menu_order', 'my_new_admin_menu_order');
function my_new_admin_menu_order( $menu_order ) {
  $new_positions = array('index.php' => 1, 'edit.php' => 2, 'upload.php' => 7, 'edit.php?post_type=page' => 3, 'edit-comments.php' => 8);
  function move_element(&$array, $a, $b) {
    $out = array_splice($array, $a, 1);
    array_splice($array, $b, 0, $out);
  }
  foreach( $new_positions as $value => $new_index ) {
    if( $current_index = array_search( $value, $menu_order ) ) {
      move_element($menu_order, $current_index, $new_index);
    }
  }
  return $menu_order;
};
<?php $terms = get_the_terms( $post->ID , 'yourtaxonomyhere' ); 
                    foreach ( $terms as $term ) {
                        $term_link = get_term_link( $term, 'yourtaxonomyhere' );
                        if( is_wp_error( $term_link ) )
                        continue;
                    echo '<a href="' . $term_link . '">' . $term->name . '</a>';
                    } 
?>
// Remove custom post types from search result
add_action('pre_get_posts', 'remove_cpts_from_search_results');
function remove_cpts_from_search_results($query) {
	if (is_admin() || !$query->is_main_query() || !$query->is_search()) {
		return $query;
	}
	$post_types_to_exclude = array('custom-post-type-1', 'custom-post-type-2');
	if ($query->get('post_type')) {
		$query_post_types = $query->get('post_type');
		if (is_string($query_post_types)) {
			$query_post_types = explode(',', $query_post_types);
		}
	} else {
		$query_post_types = get_post_types(array('exclude_from_search' => false));
	}
	if (sizeof(array_intersect($query_post_types, $post_types_to_exclude))) {
		$query->set('post_type', array_diff($query_post_types, $post_types_to_exclude));
	}
	return $query;
}
# /etc/apache2/mods-available/alias.conf
# Comment out the folllowing lines
Alias /icons/ "/usr/share/apache2/icons/"
<Directory "/usr/share/apache2/icons">
    Options FollowSymlinks
    AllowOverride None
    Require all granted
</Directory>
add_filter( 'pre_get_posts', 'be_archive_query' );
function be_archive_query( $query ) {
	if( $query->is_main_query() && $query->is_post_type_archive('code') ) {
		$query->set( 'posts_per_page', 24 );
		$query->set( 'orderby', 'name' );
		$query->set( 'order', 'asc' );
	}
}
// Change add to cart text on archives depending on product type
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
function custom_woocommerce_product_add_to_cart_text() {
	global $product;
	$product_type = $product->product_type;
	switch ( $product_type ) {
		case 'external':
			return __( 'Add to cart', 'woocommerce' );
		break;
		case 'grouped':
			return __( 'Add to cart', 'woocommerce' );
		break;
		case 'simple':
			return __( 'Add to cart', 'woocommerce' );
		break;
		case 'variable':
			return __( 'Add to cart', 'woocommerce' );
		break;
		default:
			return __( 'Add to cart', 'woocommerce' );
	}
	
};
<?php // Loop
$recent = new WP_Query('post_type=event&post_status=future&order=ASC&orderby=date'); 
while($recent->;have_posts()) : $recent->the_post(); ?>
<div>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?> - <?php the_date('l, F j, Y');?></a>
</div>
<?php endwhile; ?>
<?php 
// Functions.php
add_filter('the_posts', 'show_future_posts');
function show_future_posts($posts){
    global $wp_query, $wpdb;
    if(is_single() && $wp_query->post_count == 0){
        $posts = $wpdb->get_results($wp_query->request);
    }
    return $posts;
}; ?>
<center>
<div style="margin: 0 auto;"><!--[if mso]>
 <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:50px;v-text-anchor:middle;width:250px;" arcsize="16%" strokecolor="#ed7014" fill="t">
    <v:fill type="tile" src="https://www.emailonacid.com/images/orange_btn_bg.jpg" color="#ed7014" />
    <w:anchorlock/>
    <center style="color:#ffffff;font-family:sans-serif;font-size:18px;font-weight:bold;">Click the Button!</center>
  </v:rect>
<![endif]-->
<div style="margin: 0 auto;mso-hide:all;">
<table align="center" cellpadding="0" cellspacing="0" height="50" width="250" style="margin: 0 auto; mso-hide:all;">
	<tbody>
		<tr>
			<td align="center" bgcolor="#ed7014" height="50" style="vertical-align:middle;color: #ffffff; display: block;background-color:#ed7014;background-image:url(https://www.emailonacid.com/images/orange_btn_bg.jpg);border:1px solid #ed7014;mso-hide:all;" width="250">
				<a class="cta_button" href="#" style="font-size:16px;-webkit-text-size-adjust:none; font-weight: bold; font-family:sans-serif; text-decoration: none; line-height:50px; width:250px; display:inline-block;" title="Button">
					<span style="color:#ffffff">Click the Button!</span>
				</a>
			</td>
		</tr>
	</tbody>
</table>
</div>
</div>
</center>
<?php 
function yoolk_copyright() {
	global $wpdb;
	$copyright_dates = $wpdb->get_results("SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM $wpdb->posts WHERE post_status = 'publish'");
	$output = '';
	if($copyright_dates) {
		$copyright = "&copy; " . $copyright_dates[0]->firstdate;
		if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
			$copyright .= '-' . $copyright_dates[0]->lastdate;
		}
		$output = $copyright.' - Website made by Yoolk';
	}
	return $output;
} ?>
// Show Excerpt on Shop Page
add_action( 'woocommerce_after_shop_loop_item', 'woo_show_excerpt_shop_page', 5 );
function woo_show_excerpt_shop_page() {
	global $product;
	echo '<div class="text">'.$product->post->post_excerpt.'</div>';
}
<!--[if mso]>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td>Outlook content</td>
    </tr>
</table>
<![endif]-->

<table border="0" cellpadding="0" cellspacing="0" width="100%" style="mso-hide:all;">
    <tr>
        <td>Other clients</td>
    </tr>
</table>
<?php /* Show thumbnails in WordPress Posts Pagination */ ?>
<?php if( $prev_post = get_previous_post() ): ?>
    <div class="nav-box previous">
        <?php $prevthumbnail = get_the_post_thumbnail($prev_post->ID, 'thumbnail' );?>
        <?php previous_post_link('%link',"$prevthumbnail  <p>%title</p>", TRUE); ?>
    </div>
<?php endif; ?>
<?php if( $next_post = get_next_post() ): ?>
    <div class="nav-box next">
        <?php $nextthumbnail = get_the_post_thumbnail($next_post->ID, 'thumbnail' );  ?>
        <?php next_post_link('%link',"$nextthumbnail  <p>%title</p>", TRUE); ?>
    </div>
<?php endif; ?>

No more items to load

My website may contain fan art inspired by existing characters from movies or tv shows, I dont own any rights. Any copyright owner willing to remove those fan arts can contact me here. This is a personal portfolio, the sole use of cookies are for analysing my traffic through Google Analytics, if you're ok with that please accept this terms by closing this disclaimer.