Skip to content

Instantly share code, notes, and snippets.

View krasenslavov's full-sized avatar
Work in progress

Krasen Slavov krasenslavov

Work in progress
View GitHub Profile
@krasenslavov
krasenslavov / object.scss
Last active April 26, 2020 15:44
Sass mixin to customize object fit and position. Visit blog posts https://bit.ly/3bg4Rqs
// _object.scss
@mixin object($uid: object) {
$fit: (
'-contain': contain,
'-cover': cover,
'-fill': fill,
'-none': none,
'-scale-down': scale-down
);
@each $prop, $value in $fit {
@krasenslavov
krasenslavov / margin.scss
Last active April 26, 2020 15:45
Sass mixin to customize margin and padding. Visit blog posts https://bit.ly/3bg4Rqs
// _margin.scss
@mixin margin($uid: margin, $unit: px, $step: 10, $from: 0, $through: 3) {
$base: (
'': '',
't': '-top',
'r': '-right',
'b': '-bottom',
'l': '-left',
'x': ('-left', '-right'),
'y': ('-top', '-bottom')
@krasenslavov
krasenslavov / columns.scss
Last active April 26, 2020 15:45
Sass mixin to customize containers & columns. Visit blog posts https://bit.ly/3bg4Rqs
// _columns.scss
@mixin columns($uid: column, $gap: 16px, $columns: 12) {
@for $i from 1 through $columns {
.#{$uid}-#{$i} {
margin: 0 $gap;
width: 100% / $columns * $i;
}
.#{$uid}-offset-#{$i} {
margin-left: 100% / $columns * $i;
}
@krasenslavov
krasenslavov / api_license_key_plugin_form.php
Last active March 18, 2022 16:08
API license key plugin form. Visit blog post https://bit.ly/2xlZKGx
<h1>License Key</h1>
<?php if ($error_message):?>
<div class="notice notice-error is-dismissible">
<p><strong><?php echo $error_message;?></strong></p>
<button type="button" class="notice-dismiss">
<span class="screen-reader-text">Dismiss this notice.</span>
</button>
</div>
<?php endif; ?>
@krasenslavov
krasenslavov / api_license_key_plugin.php
Last active March 18, 2022 16:11
API license key plugin verification. Visit blog post https://bit.ly/2xlZKGx
<?php
require_once 'vendor/autoload.php';
$http_client = new \GuzzleHttp\Client();
$base_url = 'https://api.example.com/';
$error_message = '';
$success_message = '';
$logged_in = false;
@krasenslavov
krasenslavov / send_email_actions.php
Last active April 26, 2020 15:33
Sending custom emails in WordPress. Visit blog post https://bit.ly/2xlZG9L
<?php
add_action('wp_mail_content_type', function() {
return "text/html";
}, 10, 1);
add_action('retrieve_password_message', function($message, $reset_key, $user_login, $user_data) {
$logo_url = esc_url('https://cdn-domain-name.com/assets/img/logo.png');
@krasenslavov
krasenslavov / send_email_template.php
Last active March 18, 2022 16:16
Sending custom emails in WordPress. Visit blog post https://bit.ly/2xlZG9L
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php echo $email_custom_data['title'];?> - Company Name</title>
<style>
@font-face {
font-family: 'Roboto';
font-style: normal;
@krasenslavov
krasenslavov / send_email_functions.php
Last active April 26, 2020 15:33
Sending custom emails in WordPress. Visit blog post https://bit.ly/2xlZG9L
<?php
/**
$email_custom_data = array(
'title' => '',
'content' => '',
'logo_url' => '',
'featured_image_url' => '',
'cta_button_url' => '',
'cta_button_text' => '',
@krasenslavov
krasenslavov / api_license_key_server_options.php
Last active April 26, 2020 15:29
API license key functions/options. Visit blog posts https://bit.ly/2XziqNy
<?php
/* 1. Generate initial license key data. */
function generate_license_key(string $user_name, string $password, int $total_installs = 1) {
if (!strstr($user_name, '_license_key')) {
$user_name .= '_license_key';
}
// Shouldn't be able to continue if there is license key found.
@krasenslavov
krasenslavov / dashboard_plugin_tracker_widget.php
Last active April 26, 2020 15:31
WordPress.org plugin tracker dashboard widget. Visit blog post https://bit.ly/2xy3dSj
<?php
add_action('admin_enqueue_scripts', function() {
wp_add_inline_style('dashboard', '
.plugin-box-container {
display: flex;
flex-wrap: wrap;
max-height: 288px;
overflow-y: auto;