Skip to content

Instantly share code, notes, and snippets.

// 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' );
@tschoffelen
tschoffelen / install.php
Last active February 12, 2024 09:20
A simple PHP script that automatically downloads and unzips the latest version of Wordpress in the current directory (./), so that I don't have to download it and upload it to my server through FTP manually.
<?php
echo '<pre>';
echo '<span style="color:blue">DOWNLOADING...</span>'.PHP_EOL;
// Download file
file_put_contents('wp.zip', file_get_contents('https://wordpress.org/latest.zip'));
$zip = new ZipArchive();
$res = $zip->open('wp.zip');
if ($res === TRUE) {
@gabrielmerovingi
gabrielmerovingi / mycred-woo-coupon
Last active June 28, 2020 15:19
This custom shortcode allows your users to convert their myCRED points into a WooCommerce coupon, in order to give themselves a discount or partial payment on their order. In order for this to work, you need to set an exchange rate between points and your store currency and select. Requires myCRED 1.6+ and WooCommerce 2.4+
/**
* Convert myCRED Points into WooCommerce Coupon
* Requires myCRED 1.4 or higher!
* @version 1.3.1
*/
add_shortcode( 'mycred_to_woo_coupon', 'mycred_pro_render_points_to_coupon' );
function mycred_pro_render_points_to_coupon( $atts, $content = NULL ) {
// Users must be logged in
if ( ! is_user_logged_in() )
@paulcollett
paulcollett / functions.php
Last active December 19, 2023 04:42
Remove Yoast HTML Comments “This site is optimized with the Yoast WordPress SEO plugin”
// For Yoast SEO Plugin Version: 14.1+ add to your Wordpress Theme's functions.php...
// Remove All Yoast HTML Comments
// https://gist.github.com/paulcollett/4c81c4f6eb85334ba076
// Credit @devendrabhandari (https://gist.github.com/paulcollett/4c81c4f6eb85334ba076#gistcomment-3303423)
add_filter( 'wpseo_debug_markers', '__return_false' );
// For Yoast SEO Plugin Version: < 14.1 add to your Wordpress Theme's functions.php...
@jennimckinnon
jennimckinnon / .htaccess
Last active January 30, 2023 13:04
Restrict Direct Access to Plugin and Theme PHP files in WordPress. Source: https://www.acunetix.com/websitesecurity/wordpress-security-top-tips-secure-wordpress-application/
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/directory/to/exclude/
RewriteRule wp-content/plugins/(.*\.php)$ - [R=404,L]
RewriteCond %{REQUEST_URI} !^/wp-content/themes/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/themes/directory/to/exclude/
RewriteRule wp-content/themes/(.*\.php)$ - [R=404,L]
@txemaleon
txemaleon / functions.php
Last active March 26, 2021 17:26
Allow HTML Tags in WordPress Excerpts
<?php
/**
* Allow HTML Tags in Wordpress Excerpt
*
* @link http://wordpress.stackexchange.com/questions/141125/allow-html-in-excerpt/141136
*/
if ( ! function_exists( 'wpse_custom_wp_trim_excerpt' ) ) :
function wpse_custom_wp_trim_excerpt( $wpse_excerpt ) {
@WPprodigy
WPprodigy / functions.php
Last active December 4, 2022 16:17
Change add to cart button text in WooCommerce if product is on backorder.
add_filter( 'woocommerce_product_single_add_to_cart_text', 'wc_ninja_change_backorder_button', 10, 2 );
function wc_ninja_change_backorder_button( $text, $product ){
if ( $product->is_on_backorder( 1 ) ) {
$text = __( 'Pre-Order', 'woocommerce' );
}
return $text;
}
@seoagentur-hamburg
seoagentur-hamburg / .htaccess
Last active July 23, 2024 10:22
UPDATE 2024/03: Perfect .htaccess file for highspeed and security. You can use it for every WordPress-Website without problems. Highspeed and Security - testet on hundreds of Websites. If you are using a WordPress Multisite, change the last part of this file.
########################################################################
# OPTIMAL .htaccess FILE FOR SPEED AND SECURITY @Version 2.0.9 - 03/2024
# ----------------------------------------------------------------------
# @Author: Andreas Hecht
# @Author URI: https://seoagentur-hamburg.com
# License: GNU General Public License v2 or later
# License URI: http://www.gnu.org/licenses/gpl-2.0.html
########################################################################
@bekarice
bekarice / filter-wc-orders-by-gateway.php
Last active August 3, 2023 13:37
Filters WooCommerce Orders by Payment Gateway Used
<?php
/**
* Plugin Name: Filter WooCommerce Orders by Payment Method
* Plugin URI: http://skyverge.com/
* Description: Filters WooCommerce orders by the payment method used :)
* Author: SkyVerge
* Author URI: http://www.skyverge.com/
* Version: 1.0.0
* Text Domain: wc-filter-orders-by-payment
*
@roborourke
roborourke / nf-gtm.js
Last active October 24, 2020 23:16
Ninja Forms Google Tag Manager Trigger
<script>
jQuery( document ).on( 'nfFormReady', function() {
nfRadio.channel('forms').on('submit:response', function(form) {
window.dataLayer = window.dataLayer||[];
dataLayer.push({
event: 'ninjaFormSubmission',
eventData: form.data,
formID: form.data.form_id,
formTitle: form.data.settings.title
})