Skip to content

Instantly share code, notes, and snippets.

View pdo_db.php
<?php
/*
* PDO DATABASE CLASS
* Connects Database Using PDO
* Creates Prepeared Statements
* Binds params to values
* Returns rows and results
*/
class Database {
private $host = DB_HOST;
@weszty
weszty / gist:de4048668be130abc9b65de80d063e66
Created Dec 14, 2021 — forked from danielbachhuber/gist:7684646
How to integrate WordPress Core updates with your custom Plugin or Theme
View gist:de4048668be130abc9b65de80d063e66
<?php
/**
* How to integrate WordPress Core updates with your custom Plugin or Theme
*
* Filter the `update_plugins` transient to report your plugin as out of date.
* Themes have a similar transient you can filter.
*/
add_filter( 'site_transient_update_plugins', 'wprp_extend_filter_update_plugins' );
add_filter( 'transient_update_plugins', 'wprp_extend_filter_update_plugins' );
function wprp_extend_filter_update_plugins( $update_plugins ) {
@weszty
weszty / installed-plugin-details.php
Created Dec 14, 2021 — forked from bradyvercher/installed-plugin-details.php
WordPress Plugin: Show a "Details" link for installed plugins to view information from the WordPress.org plugin directory.
View installed-plugin-details.php
<?php
/**
* Plugin Name: Installed Plugin Details
* Description: Show a "Details" link for installed plugins to view information from the WordPress.org plugin directory.
* Version: 1.0.0
* Author: Blazer Six
* Author URI: http://www.blazersix.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
@weszty
weszty / defer-async-scripts.php
Created Dec 4, 2021 — forked from wpscholar/defer-async-scripts.php
Class that allows you to async and defer scripts in WordPress by adding data.
View defer-async-scripts.php
<?php
class WP_Scholar_Defer_Scripts {
public static function initialize() {
add_filter( 'script_loader_tag', array( __CLASS__, 'defer_scripts' ), 10, 2 );
add_filter( 'script_loader_tag', array( __CLASS__, 'async_scripts' ), 10, 2 );
}
public static function defer_scripts( $tag, $handle ) {
View impress.js 3D slide
<!doctype html>
<html>
<head>
<style>
body{
background-color: #dfdfdf;
}
.box {
display: block;
width: 800px;
@weszty
weszty / wl-api.php
Created Aug 3, 2021 — forked from ivandoric/wl-api.php
WordPress Rest API Custom Filters (Video Tutorials Notes) - Check out the video: https://www.youtube.com/watch?v=5rSfAkLO5eo
View wl-api.php
<?php
/**
* Plugin Name: Custom API
* Plugin URI: http://chrushingit.com
* Description: Crushing it!
* Version: 1.0
* Author: Art Vandelay
* Author URI: http://watch-learn.com
*/
@weszty
weszty / read_csv.php
Created Jul 22, 2021 — forked from selwynpolit/read_csv.php
Php code to read a csv file of any size without exhausting memory and let you process it in chunks
View read_csv.php
/*
Reads a CSV file in chunks of 10 lines at a time
and returns them in an array of objects for processing.
Assumes the first line of the CSV file has headings
that will be used as the object name for the item you are
processing. i.e. the heading is CurrentURL then refer to
$item->CurrentURL
View WooCommerce: How To Get WooCommerce Page IDs
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@weszty
weszty / wp-config.php
Created Mar 30, 2021 — forked from burstofcode/wp-config.php
There are two things to understand when uninstalling or removing WooCommerce. * If you deactivate and delete the plugin from WordPress, you only remove the plugin and its files. Your settings, orders, products, pages, etc… will still exist in the database. * If you need to remove ALL WooCommerce data, including products, order data, etc., you ne…
View wp-config.php
<?php
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Open your site’s wp-config file and add
* define( 'WC_REMOVE_ALL_DATA', true);
* on its own line above the
* That’s all, stop editing! Happy blogging. line.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
define( 'WC_REMOVE_ALL_DATA', true);
@weszty
weszty / add-custom-post-type-menu.php
Created Oct 7, 2019 — forked from tommcfarlin/add-custom-post-type-menu.php
[WordPress] Add a custom post type menu as a child of an existing custom post type menu.
View add-custom-post-type-menu.php
<?php
// Define the 'Portfolio' post type. This is used to represent galleries
// of photos. This will be our top-level custom post type menu
$args = array(
'labels' => array(
'all_items' => 'Gallery',
'menu_name' => 'Portfolio',
'singular_name' => 'Gallery',
'edit_item' => 'Edit Gallery',