Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
@dexit
dexit / wordpress-upload-base64.php
Created June 4, 2019 18:29 — forked from modemlooper/wordpress-upload-base64.php
Upload a base64 string as image to the WordPress media library
/**
* Save the image on the server.
*/
function save_image( $base64_img, $title ) {
// Upload dir.
$upload_dir = wp_upload_dir();
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR;
$img = str_replace( 'data:image/jpeg;base64,', '', $base64_img );
@dexit
dexit / bbpress-badgeos-user-achievements-under-avatar
Created June 6, 2019 20:09 — forked from mohsinrasool/bbpress-badgeos-user-achievements-under-avatar
This gists adds User's badges earned with badgeos plugin under his avatar in topics and replies of bbpress.
<?php
add_filter( 'bbp_get_reply_author_link', 'my_append_badges_via_filter', 10, 2 );
function my_append_badges_via_filter($author_link = '', $args) {
# Needed to get the user ID of the person intended to be displayed.
$user_id = bbp_get_reply_author_id( $args['post_id'] );
#Construct your output here.
$badge_output = '';
@dexit
dexit / woocommerce-category-toggle.css
Created July 25, 2019 10:23 — forked from Garconis/woocommerce-category-toggle.css
WooCommerce | Expand and collapse child categories with custom toggle in the sidebar widget | https://i.gyazo.com/e1a39ed551096444134324bb429722bb.mp4
/* - woo cat toggling elements, injected via jQuery - */
/* make list item be relative, to be able to position toggle within this item, if desired */
#sidebar .widget_product_categories ul.product-categories > li.cat-parent {
position: relative;
}
/* the new toggle element wrapper, which is added via jQuery */
#sidebar .widget_product_categories ul.product-categories > li.cat-parent .woo-cat-toggle {
cursor: pointer;
display: inline-block;
<?php
/**
* Plugin Name: Custom Fields for WooCommerce
* Description: Add custom fields to WooCommerce products
* Version: 1.0.0
* Author: Gareth Harris
* Author URI: https://pluginrepublic.com/
* Text Domain: cfwc
* WC requires at least: 3.4.0
* WC tested up to: 3.4.2
@dexit
dexit / check-ftp.php
Created September 17, 2019 10:36 — forked from fordnox/check-ftp.php
Check ftp connection with PHP
<?php
$host = 'example.com';
$password = 'pass';
$username = 'username';
try {
$result = checkFtp($host, $username, $password);
} catch(Exception $e) {
$result = $e->getMessage();
}
@dexit
dexit / divi-mobile-submenu-toggles.css
Created October 8, 2019 19:09 — forked from Garconis/divi-mobile-submenu-toggles.css
Divi | WordPress Theme | Mobile Menu Collapsible Submenus via Toggles | CSS & jQuery Tweaks in action: https://i.gyazo.com/93557e9ef5d4aad260e22c6d5896de3b.mp4
/* when mobile menu is open, change hamburger icon to x icon */
#et_mobile_nav_menu .mobile_nav.opened .mobile_menu_bar::before {
content: '\4d';
}
/* makes sub sub menu icon be right arrow instead of down arrow */
#top-menu .menu-item-has-children .menu-item-has-children > a:first-child::after,
#et-secondary-nav .menu-item-has-children .menu-item-has-children > a:first-child::after {
content: '5';
}
@dexit
dexit / AddALTtagFromImageName.js
Created October 22, 2019 10:26
Automatically add ALT from Image file name
jQuery( document ).ready(function() {
String.prototype.filename=function(extension){
var s= this.replace(/\\/g, '/');
s= s.substring(s.lastIndexOf('/')+ 1);
return extension? s.replace(/[?#].+$/, ''): s.split('.')[0];
}
jQuery("img").each(function () {
var alt = jQuery(this).attr('alt');
if(alt === ""){
var namefile = jQuery(this).attr('src').filename();
@dexit
dexit / index.html
Created October 30, 2019 12:58 — forked from jo-fu/index.html
Advent Calendar
<html>
<head>
<title>Adventskalender</title>
<link href='https://fonts.googleapis.com/css?family=Mountains+of+Christmas:400,700' rel='stylesheet' type='text/css'>
<link href="style.css" rel="stylesheet" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="script.js" type="text/javascript"></script>
</head>
<body>
@dexit
dexit / search-new.php
Created November 6, 2019 10:52 — forked from neilgee/search-new.php
WooCommerce Product Search Filter Markup
<?php
add_filter( 'get_product_search_form' , 'me_custom_product_searchform' );
/**
* Filter WooCommerce Search Field
*
*/
function me_custom_product_searchform( $form ) {
<style>
/* customizable snowflake styling */
.snowflake {
color: #fff;
font-size: 1em;
font-family: Arial, sans-serif;
text-shadow: 0 0 5px #000;
}
@-webkit-keyframes snowflakes-fall{0%{top:-10%}100%{top:100%}}@-webkit-keyframes snowflakes-shake{0%,100%{-webkit-transform:translateX(0);transform:translateX(0)}50%{-webkit-transform:translateX(80px);transform:translateX(80px)}}@keyframes snowflakes-fall{0%{top:-10%}100%{top:100%}}@keyframes snowflakes-shake{0%,100%{transform:translateX(0)}50%{transform:translateX(80px)}}.snowflake{position:fixed;top:-10%;z-index:9999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default;-webkit-animation-name:snowflakes-fall,snowflakes-shake;-webkit-animation-duration:10s,3s;-webkit-animation-timing-function:linear,ease-in-out;-webkit-animation-iteration-count:infinite,infinite;-webkit-animation-play-state:running,running;animation-name:snowflakes-fall,snowflakes-shake;animation-duration:10s,3s;animation-timing-function:line