Skip to content

Instantly share code, notes, and snippets.

@cyberwani
cyberwani / is_rest.php
Created March 30, 2023 17:38 — forked from matzeeable/is_rest.php
Checks if the current request is a WP REST API request.
<?php
if ( !function_exists( 'is_rest' ) ) {
/**
* Checks if the current request is a WP REST API request.
*
* Case #1: After WP_REST_Request initialisation
* Case #2: Support "plain" permalink settings and check if `rest_route` starts with `/`
* Case #3: It can happen that WP_Rewrite is not yet initialized,
* so do this (wp-settings.php)
@cyberwani
cyberwani / .gitlab-ci.yml
Created March 30, 2023 17:09 — forked from swashata/.gitlab-ci.yml
Deploy WordPress Plugin with GitLab CI/CD
# Our base image
image: registry.gitlab.com/wpquark/docker-containers/php-node:2.0.0-php-7.3-node-12.13.0
# Select what we should cache
cache:
key: "$CI_COMMIT_REF_SLUG-$CI_JOB_NAME"
paths:
- .yarn-cache
- .composer-cache
@cyberwani
cyberwani / SimpleICS.class.php
Created March 27, 2023 09:27 — forked from amattu2/SimpleICS.class.php
A simple ICS (iCalendar) event generator class.
<?php
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@cyberwani
cyberwani / Invoice.php
Created March 27, 2023 09:26 — forked from amattu2/Invoice.php
This is a FPDF class for generating a Billable invoice for itemized costs
<?php
/*
* Produced: Fri Jan 07 2022
* Author: Alec M.
* GitHub: https://amattu.com/links/github
* Copyright: (C) 2022 Alec M.
* License: License GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@cyberwani
cyberwani / wp-increase-timeout.php
Last active March 17, 2023 06:14 — forked from sudar/wp-increase-timeout.php
Increase the curl timeout in WordPress
<?php
/*
Copied from http://fatlabmusic.com/blog/2009/08/12/how-to-fix-wp-http-error-name-lookup-timed-out/
adjustments to wp-includes/http.php timeout values to workaround slow server responses
*/
/**
* Filters the arguments used in an HTTP request.
*
* @param array $parsed_args An array of HTTP request arguments.
<?php
if(!function_exists('wc_get_products')) {
return;
}
$paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
$ordering = WC()->query->get_catalog_ordering_args();
$ordering['orderby'] = array_shift(explode(' ', $ordering['orderby']));
$ordering['orderby'] = stristr($ordering['orderby'], 'price') ? 'meta_value_num' : $ordering['orderby'];
@cyberwani
cyberwani / test.php
Created October 27, 2021 20:28 — forked from claudiosanches/test.php
Regex for test credit card brand
<?php
// Test cards
$cards = array(
'378282246310005', // American Express
'371449635398431', // American Express
'5078601870000127985', // Aura
'5078601800003247449', // Aura
'30569309025904', // Diners Club
'38520000023237', // Diners Club
@cyberwani
cyberwani / woocommerce-installments-example.php
Created October 27, 2021 20:28 — forked from claudiosanches/woocommerce-installments-example.php
WooCommerce - Displays the price in 3 installments without interest.
<?php
/**
* Plugin Name: WooCommerce Installments Example
* Plugin URI: http://claudiosmweb.com/
* Description: Added the price with 3 installments without interest.
* Author: claudiosanches
* Author URI: http://www.claudiosmweb.com/
* Version: 1.0
* License: GPLv2 or later
*/
@cyberwani
cyberwani / add-to-cart.php
Created October 27, 2021 20:27 — forked from claudiosanches/add-to-cart.php
WooCommerce - Template add-to-cart.php with quantity and Ajax!
<?php
/**
* Custom Loop Add to Cart.
*
* Template with quantity and ajax.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
global $product;
@cyberwani
cyberwani / run.php
Created October 27, 2021 20:27 — forked from claudiosanches/run.php
Small script to migrate Bitbucket repositories to GitHub.
<?php
/**
* Migrate repositorioes from Bitbucket to GitHub.
*
* Usage: php run.php
*
* @package CS\Bitbucket_to_Github
* @license MIT License
*/
class CS_Bitbucket_to_Github