Skip to content

Instantly share code, notes, and snippets.

View Preciousomonze's full-sized avatar
🤡
Coding on the bicycle 😎🚴🏽‍♂️

Precious Omonzejele Preciousomonze

🤡
Coding on the bicycle 😎🚴🏽‍♂️
View GitHub Profile
@Preciousomonze
Preciousomonze / update.php
Last active August 8, 2023 06:00 — forked from adejorosam/gist:db0e015acb85e58c20eeaaded49a11fa
Extended code to help calculate Marginal interest and overdraft for Nigeria stock exchange.
<?php
$jsonData = '{
"data": [
{
"ValueDate": "7/3/2023 12:00:00 AM",
"Description": "Opening Balance",
"Debit": "0.0000",
"Credit": "5905.1135",
"Label": "credit",
@Preciousomonze
Preciousomonze / extra.html
Last active June 24, 2023 13:15
Adding plus and minus to the input quantity field
<div class="pekky-stm-quantity">
<div class="pekky-stm-minus fff"><a class="pekky-stm-btn-change" href="#" data-multi="-1">-</a></div>
<div class="pekky-stm-input">
<input type="number" class="stm_quantity_input" value="1" />
</div>
<div class="spekky-stm-plus fff"><a class="pekky-stm-btn-change" href="#" data-multi="1">+</a></div>
</div>
@Preciousomonze
Preciousomonze / Test_With_Method_injector.php
Last active May 22, 2023 17:48
Trying to use Containers in a WP way
<?php
/**
* Main Plugin
* @version 1.0.0
*/
namespace Backcourt;
use Backcourt\Vendor\League\Container\Container as Container;
use Backcourt\Vendor\League\Container\Definition\Definition as BaseDefinition;
@Preciousomonze
Preciousomonze / file.php
Created March 21, 2023 14:37
Snippet to log errors in wp functions, also valid for php
###
function pekky_var_error_log( $object=null ){
ob_start(); // start buffer capture
var_dump( $object ); // dump the values
$contents = ob_get_contents(); // put the buffer into a variable
ob_end_clean(); // end capture
error_log( $contents ); // log contents of the result of var_dump( $object )
}
############
@Preciousomonze
Preciousomonze / file.js
Last active February 21, 2023 16:36
Fix for a site
<script>
jQuery( function($) {
$( document ).on( 'click', '.ld-expand-button', function( event ) {
// Get the clicked element section cover.
let $_ParentEl = $(this).closest( '.ld-item-lesson-item' );
// Check if it's the parent expand all.
if ( $_ParentEl.length < 1 ) { // It's da big one.
let $_Expanded = $( '.ld-item-list .ld-item-list-item-expanded' ); // trigger all.
@Preciousomonze
Preciousomonze / p.js
Last active January 26, 2023 21:41
Basic js to help in a “readmore” scenario for a friend.
jQuery( function($) {
$( document ).on( 'click', '.ola-section-readmore', function( event ) {
event.preventDefault();
console.log("workssss");
// Get the clicked element section cover.
$_ParentEl = $(this).closest( '.ola-section-cover' );
// Now trigger the necessary for the clicked item.
$_ParentEl.find( '.short-d' ).css( 'display', 'none' );
@Preciousomonze
Preciousomonze / pekky-wc-file.php
Created May 9, 2022 14:15
Pre-select WooCommerce first variation option. Copy code and put in your child theme's function.php or anywhere you see fit. Use at your risk, enjoy! I mean, what's life without taking risks? 🚀
<?php
/**
* Pre-selects first variation option.
*
* @param array $args
* return array
*/
function pekky_wc_select_first_variation_option( $args ) {
$args['selected'] = $args['options'][0];
return $args;
@Preciousomonze
Preciousomonze / pekky-wc-file.php
Last active May 9, 2022 14:15
Disable WooCommerce Product variation dropdown. Copy code and put in your child theme's function.php or anywhere you see fit. Use at your risk, enjoy! I mean, what's life without taking risks? 🚀
<?php
/**
* Disable variation dropdown.
*
* Adds the disable attribute to the select tag.
*
* @param string $html
* @param array $args
* return string
*/
@Preciousomonze
Preciousomonze / pekky-wc-change-out-of-stock-text.php
Last active May 12, 2022 17:31
This MU-Plugin helps change "out of stock" text to what you want either on single product page or loop page, or both. make sure you edit the $out_of_stock_span_class to your use case. Use at your risk, enjoy! I mean, what's life without taking risks? 🚀 Inspired by: https://woocommercecommunity.slack.com/archives/CV9AF72PR/p1651253141682729
<?php
/**
* WooCommerce Change "out of stock" text.
*
* @package pekky-wc-change-out-of-stock-text
* @author Precious Omonzejele (CodeXplorer 🤾🏽‍♂️🥞🦜🤡)
*
* @wordpress-plugin
* Plugin Name: WooCommerce Change "out of stock" text
* Plugin URI: https://gist.github.com/Preciousomonze/c0d49effe8e3d613f838aa35f352bfc9
@Preciousomonze
Preciousomonze / pekky-wc-change-session-country-state.php
Last active May 7, 2022 21:43
This MU-Plugin helps preset or preselect a country/state based on checkout. It can be shipping or billing. All you need to do is call the function 'CLASS::process_selected_country_or_state_etc('NG')' to set the value. Inspired by https://wordpress.org/support/topic/change-session-shipping-country-on-product-page-collection-page-2/ . Use at your …
<?php
/**
* WooCommerce Change Session Country/State for checkout.
*
* @package pekky-wc-change-session-country-state
* @author Precious Omonzejele (CodeXplorer 🤾🏽‍♂️🥞🦜🤡)
*
* @wordpress-plugin
* Plugin Name: WooCommerce Change Session Country/State for checkout
* Plugin URI: https://gist.github.com/Preciousomonze/58a1e85557a74a4094f245adb0f8786f