//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); })();
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
// 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
foreach ($_POST as $key => $value) { echo "$key : $value \n"; }
Basic PDO Queries
// 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.'); } });
$('.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>[/code] [code language="html" light="true"][/code]<!-- 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; }
$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', 'cpt_archive_query' ); function cpt_archive_query( $query ) { if( $query->is_main_query() && $query->is_post_type_archive('cpt_name') ) { $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' ); } };
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>
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 = "© " . $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; ?>
Loading...
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.