Skip to content

Instantly share code, notes, and snippets.

View UVLabs's full-sized avatar
🏠
Probably coding

Uriahs Victor UVLabs

🏠
Probably coding
View GitHub Profile
@UVLabs
UVLabs / wp-custom-admin-pointers.php
Created November 17, 2018 20:46
Add admin pointers to WordPress dashboard, great for simple plugin/theme onboarding
<?php
class prefixPointers{
// Code adopted from WooCommerce product setup:
// https://github.com/woocommerce/woocommerce/blob/3.5.1/includes/admin/class-wc-admin-pointers.php
// For smooth scrolling add html{ scroll-behavior: smooth; } to your admin CSS.
// Only equeue CSS on your plugin/theme's admin pages.
public function __construct() {
<?php
/*
Plugin Name: WC Map Guest Orders and Downloads
Plugin URI: https://www.wptechguides.com/
Description: Maps WooCommerce guest orders and downloads to an account with the same e-mail on account creation or login
Version: 1.0
Author: duplaja
Author URI: https://convexcode.com
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@UVLabs
UVLabs / wp_magic_tags.php
Last active March 26, 2017 06:26
WordPress, creating magic tags example
//get your data with the magic tags
$prefix_old_body = $_POST["field"];
//create the replacement variables
$magic_tag1 = "Data";
$magic_tag2 = "Data2";
//create the list of magic tags you're looking for
$prefix_magic_tags = array( "{magic_tag1}", "{magic_tag2}" );
@UVLabs
UVLabs / render_textwidget_shortcode.php
Created March 6, 2017 17:34
Allow shortcode rendering in WordPress text widget
<?php
add_filter('widget_text','do_shortcode');
?>
@UVLabs
UVLabs / shortlink.php
Created January 28, 2017 06:33
add shortlink back to wordpress
@UVLabs
UVLabs / woocommerce_check.php
Last active October 27, 2021 16:02
Check if WooCommerce is active on a website and output admin notice if not
<?php
// check if WooCommerce is activated
function tld_wc_check(){
if ( class_exists( 'woocommerce' ) ) {
global $tld_wc_active;
$tld_wc_active = 'yes';
} else {
@UVLabs
UVLabs / redirect_http_to_https
Created May 4, 2016 13:12
Automatically Redirect HTTP to HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
@UVLabs
UVLabs / fix_jquery_issue_wordpress.php
Created April 28, 2016 21:55
Fix WordPress jQuery issue. Add snippet to functions.php
add_action( 'wp_enqueue_scripts', 'load_old_jquery_fix', 100 ); function load_old_jquery_fix() { if ( ! is_admin() ) { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', ( "//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" ), false, '1.11.3' ); wp_enqueue_script( 'jquery' ); }
@UVLabs
UVLabs / custom-domain-localhost-xampp
Created April 24, 2016 18:01 — forked from oozman/custom-domain-localhost-xampp
How to add a custom domain name on your localhost using XAMPP. Codes are based on Windows, but Step 2 onwards are pretty much applicable on other operating system.
Step 1:
Go to: C:\Windows\System32\Drivers\etc\hosts
And add this to the bottom of the file:
=============
127.0.0.1 your.domain.com
=============
Step 2:
Go to [your XAMPP directory]/apache/conf/httpd-xampp.conf
@UVLabs
UVLabs / get_cats_n_child
Created April 7, 2016 21:48
This snippet gets all categories including it's children, snippet could be easily customized to customize output. Change 'course' in get_terms() to get custom post type of choice.
<?php
$parent = get_terms( 'course', 'parent=0&hide_empty=0');
foreach( $parent as $cat_parent ){
echo '<div class="courses-container" style="float: left; border: 1px solid;">';
echo '<h2><a href="' . get_term_link( $cat_parent ) . '">'.$cat_parent->name.'</a></h2>';