Skip to content

Instantly share code, notes, and snippets.

View Iulian33's full-sized avatar

Iulian Cirlig Iulian33

  • Personal Team
  • Chisinau
View GitHub Profile
@Iulian33
Iulian33 / fix-block-link.js
Created November 26, 2018 15:07
this function get an nodelist with selections of blocks you want to link
@Iulian33
Iulian33 / Hex to RGB Convert
Created August 30, 2018 12:23
Function that convert hex color into rgb
function hexToRgb($hex, $alpha = false) {
$hex = str_replace('#', '', $hex);
$length = strlen($hex);
$rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0));
$rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
$rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
if ($alpha) {
$rgb['a'] = $alpha;
}
return $rgb;
@Iulian33
Iulian33 / filter-admin-by-taxonomy
Created June 4, 2018 11:21
apears in a specific post type filter select for admin posts to filter it
function filter_cars_by_taxonomies( $post_type, $which ) {
// Apply this only on a specific post type
if ( 'page' !== $post_type )
return;
// A list of taxonomy slugs to filter by
$taxonomies = array( 'page_categ');
foreach ( $taxonomies as $taxonomy_slug ) {
@Iulian33
Iulian33 / dynamic-cart-totals.php
Created April 30, 2018 08:21
Ajax dynamic cart totals and count
function woocommerce_header_add_to_cart_fragment($fragments) {
global $woocommerce;
ob_start();
?>
<a class="cart-customlocation"
href="<?php echo $woocommerce->cart->get_cart_url(); ?>"
title="<?php _e('View your shopping cart', 'woothemes'); ?>">
<?php echo WC()->cart->get_cart_total(); ?>
@Iulian33
Iulian33 / remove-default-post.php
Last active March 24, 2018 19:45
Reve default post type Posts.
function remove_default_post_type() {
remove_menu_page('edit.php');
}
add_action('admin_menu','remove_default_post_type');
@Iulian33
Iulian33 / footer-admin-theme-version.php
Created February 6, 2018 11:57
This hook ads theme text in update section from footer
@Iulian33
Iulian33 / footer-admin-text.php
Created February 6, 2018 11:32
Change footer admin left text
@Iulian33
Iulian33 / remove-type.php
Created February 1, 2018 10:25
Remove theme import atribute type wich is depricsted
add_filter('style_loader_tag', 'remove_type_atribute', 10, 2);
add_filter('script_loader_tag', 'remove_type_atribute', 10, 2);
function remove_type_atribute($tag ) {
return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag );
}
@Iulian33
Iulian33 / admin-scripts.php
Created January 28, 2018 21:29
add admin scripts by using admin enque script hook
function jh_admin_scripts() {
if(is_admin()){
wp_enqueue_script('admin-script', get_bloginfo('template_url').'/js/admin.js', array('jquery'));
}
}
add_action('admin_enqueue_scripts', 'jh_admin_scripts');
@Iulian33
Iulian33 / disable-updates.php
Created January 28, 2018 20:58
put this code in your plugin root file and it wil disable chech updater
add_filter('site_transient_update_plugins', 'remove_update_notification');
function remove_update_notification($value) {
unset($value->response[ plugin_basename(__FILE__) ]);
return $value;
}