Skip to content

Instantly share code, notes, and snippets.

View gin0115's full-sized avatar

Glynn Quelch gin0115

View GitHub Profile
"require-dev": {
"phpunit/phpunit": "^7.0",
"roots/wordpress": "^5.5",
"wp-phpunit/wp-phpunit": "^5.0",
"symfony/var-dumper": "4.*",
"phpstan/phpstan": "^0.12.6",
"szepeviktor/phpstan-wordpress": "^0.7.2",
"php-stubs/wordpress-stubs": "^5.6.0",
@gin0115
gin0115 / Enqueue.php
Last active April 20, 2020 10:48
Enqueue
<?php declare(strict_types=1);
namespace Perique\Loader;
/**
* Wordpress Script and Style enqueuing class.
*
* @author Glynn Quelch <glynn.quelch@gmail.com>
*/
class Enqueue {
@gin0115
gin0115 / sql.sql
Created August 7, 2019 12:14
GQ WP-conf
This file has been truncated, but you can view the full file.
-- phpMyAdmin SQL Dump
-- version 4.6.6deb5
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Aug 07, 2019 at 01:12 PM
-- Server version: 5.7.26-0ubuntu0.18.10.1
-- PHP Version: 7.2.17-0ubuntu0.18.10.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
@gin0115
gin0115 / functions.php
Last active June 14, 2019 13:45
gq_set_new_password
/**
* Sets a new password and returns a bool if changed.
*
* @param integer $user_id The users id
* @param string $new_password The users new password
* @return bool Returns true/false if password set.
*/
function gq_set_new_password( int $user_id, string $new_password ): bool {
// Update the password.
@gin0115
gin0115 / order-history-controller.js
Created February 1, 2019 13:10
Protrade web app order_histopry cotnroller
/**
* Order History controller.
* Used to show the order histoy on daily and monthly routes.
*/
dipt_app.controller('replenishment_controller', ['$scope', '$routeParams', '$timeout', '$q', '$location', '$mdToast', '$window', '$mdSidenav', '$mdDialog', 'dipt_app_action',
function ($scope, $routeParams, $timeout, $q, $location, $mdToast, $window, $mdSidenav, $mdDialog, dipt_app_action) {
// Init vars.
$scope.page_title = 'DIPT WebApp';
// The factory data object.
$scope.factory_data = {
@gin0115
gin0115 / text.sql
Created December 1, 2018 11:25
SQL TEST 1
SELECT p.ID AS product, p.post_name, t.name, tt.parent, t.term_id, pm.meta_value AS price
FROM wp_posts AS p
INNER JOIN wp_postmeta AS pm ON (p.ID = pm.post_id AND pm.meta_key = '_price' )
INNER JOIN wp_term_relationships AS tr ON ('p.ID' = tr.object_id)
INNER JOIN wp_term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
INNER JOIN wp_terms AS t ON (t.term_id = tt.term_id AND t.term_id = 63)
WHERE p.post_status = 'publish'
AND p.post_type = 'product' OR 'product_variation'
AND tt.taxonomy = 'product_cat'
ORDER BY p.ID DESC
@gin0115
gin0115 / gist:b9f72490a35c647d74c6b23a04d04223
Last active January 1, 2018 12:55
Pass Checkbox fields between GravityForms and WP-Types custom post field. Using the 'gform_after_submission' hook
<?php
//After Submission hook & function
add_action("gform_after_submission", "after_submission", 10, 2);
function after_submission($entry, $form){
//For this example, i was creating a simple post (of course it can be used for anything from complex woocommerce production creation to user registration.
$my_post = array(
'post_title' => wp_strip_all_tags( 'test' ),
@gin0115
gin0115 / variable_excerpt
Last active May 18, 2017 10:10
Custom excerpt
function variable_excerpt($text, $length, $url = ''){
$clean = strip_tags($text);
echo substr($clean,0,$length);
if (strlen($clean) > $length) {
if ($url !== '') {
echo '...<span class="variable-excerpt-readmore"><a href="'.get_the_permalink($url).'">continue reading</a></span>';
} else {
echo '...<span class="variable-excerpt-readmore">continue reading</span>';
}
}