Skip to content

Instantly share code, notes, and snippets.

View groupewibi's full-sized avatar

Wibi groupewibi

  • Groupe Wibi
  • France
View GitHub Profile
@groupewibi
groupewibi / vc_removal_toolbox.php
Last active January 11, 2023 01:03
Remove Visual Composer Shortcake from content in Wordpress
<?php
/**
* Afficher les statistiques des shortcodes dans le contenu
* (?) Permettre de pouvoir passer dans une variable les Shortcode à supprimer.
* $post_id : string
* $mycontent : String
* (? $shortcodes : Array
*/
@groupewibi
groupewibi / gist:1ca20dc2ef5ad378bf009cd92c034ba3
Created August 30, 2022 14:23
Wordpress - Change Urls in Database
UPDATE wp_options SET option_value = replace(option_value, '[previous-url]', '[next-url]') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, '[previous-url]', '[next-url]');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'[previous-url]','[next-url]');
UPDATE wp_usermeta SET meta_value = replace(meta_value, '[previous-url]','[next-url]');
UPDATE wp_links SET link_url = replace(link_url, '[previous-url]L','[next-url]');
UPDATE wp_comments SET comment_content = replace(comment_content , '[previous-url]','[next-url]');
/* For images in a single post */
UPDATE wp_posts SET post_content = replace(post_content, '[previous-url]', '[next-url]');
/* For attached images in a post: */
UPDATE wp_posts SET guid = replace(guid, '[previous-url]','[next-url]');
@groupewibi
groupewibi / gist:8940ca96c5bcf0b5ca7ad59054357b34
Created February 3, 2022 17:13
Extend get terms with post type parameter
/**
* Extend get terms with post type parameter.
*
* @global $wpdb
* @param string $clauses
* @param string $taxonomy
* @param array $args
* @return string
*/
function df_terms_clauses( $clauses, $taxonomy, $args ) {
@groupewibi
groupewibi / gist:bd50883002ae04e0d3fbdff839cb75ff
Created February 21, 2021 04:58 — forked from shreyans94/gist:05b10194cf2f57cf054a5cf3da3fd931
Display ACF for woocommerce variations in backend
// Render fields at the bottom of variations - does not account for field group order or placement.
add_action( 'woocommerce_product_after_variable_attributes', function( $loop, $variation_data, $variation ) {
global $abcdefgh_i; // Custom global variable to monitor index
$abcdefgh_i = $loop;
// Add filter to update field name
add_filter( 'acf/prepare_field', 'acf_prepare_field_update_field_name' );
// Loop through all field groups
$acf_field_groups = acf_get_field_groups();
foreach( $acf_field_groups as $acf_field_group ) {
@groupewibi
groupewibi / include-js.php
Created May 14, 2019 23:39 — forked from fburatti/include-js.php
Open street map with ACF
function properties_map_script() {
wp_register_style(
'leaflet',
"https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.css",
array(),
null
);
wp_register_script(
@groupewibi
groupewibi / acf-to-excerpt.php
Created April 14, 2019 09:13 — forked from micjamking/acf-to-excerpt.php
[WordPress Plugin] Copy ACF field to Post Excerpt
<?php
/**
* Plugin Name: ACF Field to Excerpt
* Plugin URI: http://wordpress.stackexchange.com/q/70990/12615
*/
function acf_to_excerpt(){
$post_type = 'post';
$field = 'summary';
@groupewibi
groupewibi / popular-posts-functions.php
Created April 14, 2019 09:13 — forked from micjamking/popular-posts-functions.php
[WordPress] Display Popular Posts by Page Views
@groupewibi
groupewibi / encodeGPolyline.js
Created May 18, 2018 02:29 — forked from abarth500/encodeGPolyline.js
Generate Encoded Polyline Algorithm Format for Google Static Maps API (JavaScript)
//Generate Encoded Polyline Algorithm Format for Google Static Maps API
// http://bit.ly/sw3deL (Japanese)
// http://bit.ly/tnKt4m (English)
function encodeGPolyline(path){
var enc = "";
var old = true;
for(c in path){
var latlng = path[c];
if(old === true){
@groupewibi
groupewibi / gist:2c459ce26154f43e53d283bebb2b213f
Created April 22, 2018 23:52 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@groupewibi
groupewibi / gf-to-acf-file.php
Created April 22, 2018 23:46 — forked from joshuadavidnelson/gf-to-acf-file.php
Connect a Gravity Form upload field to ACF Gallery Field without a *New* Post Creation on Submission, requires the JDN_Create_Media_File class from https://gist.github.com/joshuadavidnelson/164a0a0744f0693d5746
<?php
/**
* Attach images uploaded through Gravity Form to ACF Gallery Field
*
* @author Joshua David Nelson, josh@joshuadnelson.com
* @return void
*/
$gravity_form_id = 1; // gravity form id, or replace {$gravity_form_id} below with this number
add_filter( "gform_after_submission_{$gravity_form_id}", 'jdn_set_post_acf_gallery_field', 10, 2 );
function jdn_set_post_acf_gallery_field( $entry, $form ) {