Skip to content

Instantly share code, notes, and snippets.

View Jany-M's full-sized avatar
🎯
Focusing

Jany Martelli Jany-M

🎯
Focusing
View GitHub Profile
@petertwise
petertwise / debug-givewp.php
Last active March 2, 2018 19:00
Give givewp.com Donation Plugin - list of all actions and filters for testing.
<?php
/*
Plugin Name: Debug Give Wp
Plugin URI: https://gist.github.com/squarecandy/8ed8265bde0c39e42ab8a19c062bf534
Description: Help discover where all of Give's action can plop in some content, and what all the filters do
Version: 1.0
Author: Square Candy
Author URI: http://squarecandy.net
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl.txt
@ciorici
ciorici / index.php
Created April 27, 2017 08:10
Featured Products Loop in WooCommerce 3.0
<ul class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12,
'tax_query' => array(
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
@Jany-M
Jany-M / .htaccess
Last active March 27, 2024 12:14
[WP] htacces for best security & caching settings
####################################################
#
# MIMETYPES
#
####################################################
AddType video/mp4 mp4 m4v
AddType audio/mp4 m4a
AddType video/ogg ogv
<?php
/*
Plugin Name: CF7 form to all products (after short description, with add_action)
Plugin URI: http://www.damiencarbery.com
Description: Append a Contact Form 7 form to the Short Description section of all Woocommerce products.
Author: Damien Carbery
Version: 0.1
WC tested up to: 8.0.2
*/
@jacobdubail
jacobdubail / php
Created January 30, 2017 23:44
Function to auto-set your ACF5 Pro license key
function jtd_acf_auto_set_license_keys() {
if ( !get_option('acf_pro_license') && defined('ACF_5_KEY') ) {
$save = array(
'key' => ACF_5_KEY,
'url' => home_url()
);
$save = maybe_serialize($save);
@gemmadlou
gemmadlou / remove-visual-composer-shortcodes.md
Last active April 20, 2024 14:56
Removing Visual Composer & Shortcodes From Wordpress Content

Adding @k1sul1's suggestion from the comments as it's more concise than what I had before:

I just wanted them all gone, so I ran this in the MySQL shell.

UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, "\\[\/?vc(.*?)\]", "");

Note the double backslash. If you forget it, you'll replace all v's and c's with nothing, and the shortcodes will still be there. This works for other shortcode as well, just replace vc.

@kellenmace
kellenmace / remove-custom-post-type-slug-from-permalinks.php
Last active June 6, 2021 03:19
Remove custom post type slug from permalinks in WordPress
<?php
/**
* Remove the slug from published post permalinks. Only affect our custom post type, though.
*/
function gp_remove_cpt_slug( $post_link, $post ) {
if ( 'race' === $post->post_type && 'publish' === $post->post_status ) {
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
}
@soderlind
soderlind / dropzonejs-wp-rest-api.js
Last active March 27, 2024 19:38
DropzoneJS & WordPress REST API
/*
Uploading images is a two step process (from https://github.com/WP-API/WP-API/issues/1768#issuecomment-160540932):
POST the data to /wp/v2/media - this can either be as the request body, or in multipart format. This will upload the file, and give you a 201 Created response with a Location header. This header points to the post object for the attachment that has just been created.
PUT the post data to the endpoint returned in the Location header (which will look something like /wp/v2/media/{id}).
I do step 2 (PUT), if POST is a success, in myDropzone.on("success", function(file, response){}
*/
// dropzoneWordpressRestApiForm is the configuration for the element that has an id attribute
@kellenmace
kellenmace / remove-custom-post-type-slug-from-permalinks-2.php
Last active July 2, 2023 16:18
Remove custom post type slug from permalinks 2
<?php
/**
* Have WordPress match postname to any of our public post types (post, page, race).
* All of our public post types can have /post-name/ as the slug, so they need to be unique across all posts.
* By default, WordPress only accounts for posts and pages where the slug is /post-name/.
*
* @param $query The current query.
*/
function gp_add_cpt_post_names_to_main_query( $query ) {
@mattradford
mattradford / licence activation.php
Last active October 28, 2023 19:25
ACF5 Pro licence activation. Could be adapted for any other plugin that requires a licence key, but doesn't yet support defining it in wp-config. Fires on theme activation.
// Place this in wp-config
define( 'ACF_5_KEY', 'yourkeyhere' );
// Set ACF 5 license key on theme activation. Stick in your functions.php or equivalent.
function auto_set_license_keys() {
if ( ! get_option( 'acf_pro_license' ) && defined( 'ACF_5_KEY' ) ) {
$save = array(
'key' => ACF_5_KEY,