Skip to content

Instantly share code, notes, and snippets.

View racmanuel's full-sized avatar
💡
Making new things!

Manuel Ramirez Coronel racmanuel

💡
Making new things!
View GitHub Profile
@racmanuel
racmanuel / Query external database
Created March 15, 2022 20:40 — forked from rvgpl/Query external database
Query external database from Wordpress
###################################################################################################
Query regular Wordpress database
###################################################################################################
//Declaring $wpdb as global and using it to execute an SQL query statement that returns a PHP object
global $wpdb;
$result = $wpdp->get_results('SELECT * FROM wp_options, OBJECT);
########################################################################################################
Querying a different database
########################################################################################################
@racmanuel
racmanuel / embedded-file-viewer.md
Created March 18, 2022 23:06 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

// Enable WP_DEBUG mode
define('WP_DEBUG', true);
// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);
// Disable display of errors and warnings
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);
@racmanuel
racmanuel / gist:8df1031fc9de7ed28b3cbceee1051a22
Created April 21, 2022 17:13 — forked from bueltge/gist:757903
This WordPress Plugin demonstrates how you can build your own plugin pages using the WordPress provided draggable metaboxes, requires WordPress 2.7 version, supports WordPress 2.8 changed boxing layout engine
<?php
/*
Plugin Name: HowTo Plugin
Plugin URI:
Description: This Plugin demonstrates how you can build your own plugin pages using the WordPress provided draggable metaboxes, requires WordPress 2.7 version, supports WordPress 2.8 changed boxing layout engine
Author: Heiko, Frank
Author URI: http://bueltge.de
Version: 0.1
License:
<?php
add_action( 'woocommerce_before_single_product', 'bbloomer_show_video_not_image' );
function bbloomer_show_video_not_image() {
// Do this for product ID = 282 only
if ( is_single( '282' ) ) {
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
@racmanuel
racmanuel / cf7_external_db2018.php
Created September 27, 2022 17:01 — forked from jc4316son/cf7_external_db2018.php
Contact Form 7 to External DB 2018
<?php
/*
Plugin Name: Contact Form 7 to External DB
Plugin URI:
Description: This plugin uses the wpcf7_before_send_mail hook to post a specific form to an external database. Upon use the details for your external database will need to be entered. Private use only.
Author:
Version: 0.2
Author URI:
*/
<?php
/**
*
* You can find the complete tutorial for this here:
* https://pluginrepublic.com/woocommerce-custom-fields
*
* Alternatively, check out the plugin
* https://pluginrepublic.com/wordpress-plugins/woocommerce-product-add-ons-ultimate/
*
<?php
/*
Plugin Name: Add Gift Card as Custom Product Type
Description: A simple demo plugin on how to add Gift Card as your custom product type
Author: Bhavik Kiri
Version: 1.0
*/
add_action( 'plugins_loaded', 'wcpt_register_gift_card_type' );
@racmanuel
racmanuel / one-million-posts.md
Created October 31, 2022 23:26 — forked from xhrix/one-million-posts.md
One Million Posts - Wordpress

One million posts

Let's create one million posts to see the performance of a Wordpress site.

Creation of a post

The purpose of this document is to find out what is the underlying data that gets modified in a wordpress database when a post with an image are created.

What I did

@racmanuel
racmanuel / woo-update-product-stock-qty.php
Created November 25, 2022 19:20 — forked from stuart-lambon/woo-update-product-stock-qty.php
Updates WooCommerce product stock quantity programmatically. $sku and $qty variables need to be filled.
<?php
$sku = 'ITEM001';
$qty = 1;
// Get product_id from SKU — returns null if not found
$product_id = wc_get_product_id_by_sku( $sku );
// Process if product found
if ( $product_id != null ) {