Skip to content

Instantly share code, notes, and snippets.

View kristjankoppel's full-sized avatar

Kristjan Koppel kristjankoppel

View GitHub Profile
@Nerd-Rush
Nerd-Rush / Client editing disclaimer PHP snippet
Last active January 29, 2024 00:15
Dismissable WordPress message to your clients.
// Client editing disclaimer
function custom_admin_notice_with_logo() {
$user_id = get_current_user_id();
if (get_user_meta($user_id, 'custom_notice_dismissed', true) !== 'yes') {
if (current_user_can('administrator') || current_user_can('editor') || current_user_can('author')) {
$nonce = wp_create_nonce('custom_notice_dismiss_nonce');
$image_url = 'https://nerdrush.com/wp-content/uploads/2023/08/Nerd-Rush-Logo-Blue-2023.svg'; // External image URL
?>
<div class="notice notice-warning custom-notice" style="padding-top: 20px;">
<img src="<?php echo esc_url( $image_url ); ?>" alt="Logo" style="width: 120px; display: block; margin-bottom: 10px;">
@alphasider
alphasider / woo_add_product_programmatically.php
Created September 21, 2020 11:23
Add woocommerce product programmaticaly (with attributes)
<?php
/**
* SOURCE: https://stackoverflow.com/questions/52937409/create-programmatically-a-product-using-crud-methods-in-woocommerce-3
*/
/* THE CODE FUNCTION */
// Custom function for product creation (For Woocommerce 3+ only)
function create_product( $args ){
global $woocommerce;
@mishterk
mishterk / class-view.php
Last active May 14, 2021 06:28
Using generic views inside WordPress for a more flexible UI system. For more info see https://philkurth.com.au/articles/use-generic-views-with-data-arrays-for-a-flexible-context-independent-ui-system/
<?php
class View {
public static $view_dir = '';
/**
* Render View Template With Data
<p class="body--lead">This is some test lead text.</p>
<hr />
<p>OK, so images can get quite complicated as we have a few variables to work with! For example the image below has had a caption entered in the WordPress image upload dialog box, this creates a [caption] shortcode which then in turn wraps the whole thing in a <code>div</code> with inline styling! Maybe one day they'll be able to use the <code>figure</code> and <code>figcaption</code> elements for all this. Additionally, images can be wrapped in links which, if you're using anything other than <code>color</code> or <code>text-decoration</code> to style your links can be problematic.</p>
<div id="attachment_28" class="wp-caption alignnone" style="width: 510px"><a href="#"><img src="http://www.wpfill.me.s3-website-us-east-1.amazonaws.com/img/img_large.png" alt="Your Alt Tag" title="bmxisbest" width="500" height="300" class="size-large wp-image-28"></a><p class="wp-caption-text">This is the optional caption.</p></div>
<p>The next issue we face is imag
@prasetyop
prasetyop / admin.css
Last active March 13, 2023 13:33
Flexible Content Preview Pop Up
.acf-fc-popup .preview {
position: absolute;
right: 100%;
margin-right: 0px;
top: 0;
background: #383c44;
min-height: 100%;
border-radius: 5px;
align-content: center;
display: grid;
@anschaef
anschaef / bootstrap-4-sass-mixins-cheat-sheet.scss
Last active April 12, 2024 08:49
Bootstrap 4 Sass Mixins [Cheat sheet with examples]
/* -------------------------------------------------------------------------- */
// All Bootstrap 4 Sass Mixins [Cheat sheet]
// Updated to Bootstrap v4.5.x
// @author https://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/master/scss/mixins
/* -------------------------------------------------------------------------- */
/*
// ########################################################################## */
// New cheat sheet for Bootstrap 5:
@roborourke
roborourke / nf-gtm.js
Last active October 24, 2020 23:16
Ninja Forms Google Tag Manager Trigger
<script>
jQuery( document ).on( 'nfFormReady', function() {
nfRadio.channel('forms').on('submit:response', function(form) {
window.dataLayer = window.dataLayer||[];
dataLayer.push({
event: 'ninjaFormSubmission',
eventData: form.data,
formID: form.data.form_id,
formTitle: form.data.settings.title
})
@jessepearson
jessepearson / adding_new_webhook_topics.php
Last active September 14, 2023 10:27
How to add a new custom Webhook topic in WooCommerce, with example of order filtering.
<?php // do not copy this line
/**
* add_new_topic_hooks will add a new webhook topic hook.
* @param array $topic_hooks Esxisting topic hooks.
*/
function add_new_topic_hooks( $topic_hooks ) {
// Array that has the topic as resource.event with arrays of actions that call that topic.
@nathanaelnsmith
nathanaelnsmith / DomBasedRouter.js
Last active November 23, 2023 09:52
ES6 module implementation of Paul Irish's DOM based routing
export default (routes) => {
return {
fire (func,funcname, args){
funcname = (funcname === undefined) ? 'init' : funcname;
if (func !== '' && routes[func] && typeof routes[func][funcname] == 'function'){
routes[func][funcname](args);
}
},
load() {
var bodyId = document.body.id;
@seoagentur-hamburg
seoagentur-hamburg / .htaccess
Last active May 5, 2024 06:11
UPDATE 2024/03: Perfect .htaccess file for highspeed and security. You can use it for every WordPress-Website without problems. Highspeed and Security - testet on hundreds of Websites. If you are using a WordPress Multisite, change the last part of this file.
########################################################################
# OPTIMAL .htaccess FILE FOR SPEED AND SECURITY @Version 2.0.9 - 03/2024
# ----------------------------------------------------------------------
# @Author: Andreas Hecht
# @Author URI: https://seoagentur-hamburg.com
# License: GNU General Public License v2 or later
# License URI: http://www.gnu.org/licenses/gpl-2.0.html
########################################################################