Skip to content

Instantly share code, notes, and snippets.

View herbie4's full-sized avatar
🏠
Working from office

herbert herbie4

🏠
Working from office
View GitHub Profile
@m1r0
m1r0 / wp_insert_attachment_from_url.php
Last active April 11, 2024 12:33
WP: Insert attachment from URL
<?php
/**
* Insert an attachment from a URL address.
*
* @param string $url The URL address.
* @param int|null $parent_post_id The parent post ID (Optional).
* @return int|false The attachment ID on success. False on failure.
*/
function wp_insert_attachment_from_url( $url, $parent_post_id = null ) {
@Neo23x0
Neo23x0 / wpwatcher.py
Last active November 26, 2022 15:42
Wordpress Watcher - WPScan Vulnerabilty Scan on Wordpress Sites and Reporting
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
# -*- coding: utf-8 -*-
#
# Wordpress Watcher
# Automating WPscan to scan and report vulnerable Wordpress sites
# Florian Roth
# v0.1
# March 2015
#
@vielhuber
vielhuber / .htaccess
Last active February 24, 2023 06:01
Apache: htaccess force www and https ssl #server
# force HTTPS and www.
RewriteEngine On
RewriteCond %{HTTP_HOST} (?!^www\.)^(.+)$ [OR]
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
# alternative way
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
@roytanck
roytanck / autoautoptimize.php
Last active January 25, 2023 06:45
Auto-configure Autoptimize across a WordPress network
<?php
/**
* Plugin Name: RT Autoautoptimize
* Plugin URI: http://www.this-play.nl
* Description: Automatically configures default settings for the Autoptimize plugin across a WordPress network
* Version: 0.9
* Author: Roy Tanck
* Author URI: http://www.this-play.nl
* License: GPL2
*/
@jdevalk
jdevalk / logging-helper.php
Last active December 9, 2021 16:25
This little hack enables fatal error logging for your site, without creating an error log that is insanely big.
<?php
/**
* This changes logging to only log fatal errors. This file should go in your mu-plugins directory.
*/
// Set the error logging to only log fatal errors
error_reporting( E_ERROR );
// Optional: change the location of your error log, it might be wise to put it outside your WP content dir.
// If you don't change it, the default place for this log is debug.log in your WP_CONTENT_DIR.
@greenbicycle
greenbicycle / gist:abceafbec3be09969ad5
Last active April 9, 2020 14:47
Quick script to scan multiple domains with wpscan
#!/bin/bash
#
# Use WPScan to scan sites running Wordpress
# and Store the output somewhere
#
domains='domain1.com example2.com example.com'
# Where do you want output to go? Better without trailing slash
@spivurno
spivurno / gw-gravity-forms-all-fields-template.php
Last active June 8, 2021 19:10
Gravity Wiz // Gravity Forms // All Fields Template
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-all-fields-template.php
*/
/**
* Gravity Wiz // Gravity Forms // All Fields Template
*
* Modify the {all_fields} merge tag output via a template file.
@byronrode
byronrode / add-sup-decimals.woocommerce.php
Created August 29, 2015 11:39
Add <sup></sup> wrapper around decimals for WooCommerce prices.
<?php
add_filter( 'woocommerce_get_price_html', 'themeprefix_add_sup_decimals_to_pricing' );
if(!function_exists( 'themeprefix_add_sup_decimals_to_pricing' )){
function themeprefix_add_sup_decimals_to_pricing( $price )
{
if(!is_admin()){ // Check that we're not in the admin
$price = strip_tags($price);
$price_exploded = explode('&ndash;', $price);
if(count($price_exploded) > 1) { // Variable Pricing
@rveitch
rveitch / next_prev_post.php
Last active December 5, 2023 20:04
Get next and prev posts in Wordpress by alphabetical order.
<?PHP
/*
* Sort Next/Previous Post Link Buttons Alphabetically
*/
function filter_next_post_sort($sort) {
if (get_post_type($post) == 'portfolio_page') {
$sort = "ORDER BY p.post_title ASC LIMIT 1";
}
else{
$sort = "ORDER BY p.post_date ASC LIMIT 1";
@bekarice
bekarice / wc-disable-any-repeat-purchase.php
Last active July 26, 2023 12:19
Disables Repeat Purchase for any WooCommerce product
<?php
/**
* Disables repeat purchase for products / variations
*
* @param bool $purchasable true if product can be purchased
* @param \WC_Product $product the WooCommerce product
* @return bool $purchasable the updated is_purchasable check
*/
function sv_disable_repeat_purchase( $purchasable, $product ) {