Skip to content

Instantly share code, notes, and snippets.

View MaximeCulea's full-sized avatar
🇨🇭
New life begining.

Maxime CULEA MaximeCulea

🇨🇭
New life begining.
View GitHub Profile
@MaximeCulea
MaximeCulea / local-with-debrock.md
Last active August 7, 2020 14:54
While using Bedrock, Git, work, sync and load the site under Local By Flywheel.
  1. Try to access the Local adminer in order to generate it

  2. Copy all credentials into the .env:
    WP_ENV=local

    DB_NAME=local
    DB_USER=root
    DB_PASSWORD=root
    DB_PREFIX=local_

  3. Delete everything into the Local docroot (app/public) folder

  4. Copy and sync the gited folder to the "app" Local folder

@MaximeCulea
MaximeCulea / bp-read-all-notifications.php
Created August 6, 2019 09:01
BuddyPress - Read all notifications buton
<?php
/**
* Class MC_BP_Notifications
* Handle the read all notifications without post / get method, based on unread notifications
*
* To be used in HTML : <a href="<?php echo Wide_Notifications::mark_notifications_as_read_url(); ?>">Read all notifications</a>
*
* @author Maxime CULEA
*/
@MaximeCulea
MaximeCulea / acf-customize.php
Created July 24, 2019 08:20
Customize ACF fields and options.
<?php
/**
* Hide ACF Edition buttons for repeater for publication_most_commented, etc
*/
function admin_print_scripts() {
echo "<script type='text/javascript'>jQuery(\"[data-name='publication_most_commented'], [data-name='publication_by_user'], [data-name='publication_most_liked']\").find('.acf-actions, .acf-row-handle').hide();</script>";
}
add_action( 'admin_print_footer_scripts', 'admin_print_scripts' );
@MaximeCulea
MaximeCulea / wp-all-export.php
Created July 23, 2019 15:14
WP All Export tweeks
<?php
/**
* Change on the fly an ACF value
* Here group id into group name
*
* @param $value : original value
* @param $field_name : field key name
* @param $post_id : post id
*
@MaximeCulea
MaximeCulea / bp-notifications.php
Created July 5, 2019 07:27
BuddyPress hacks !
<?php
/**
* Manage to "group" by new notifications first but still order all notifications by date
* @author Maxime CULEA
*/
// inside the notifications loop
$args = [ 'is_new' => 'both', 'order_by' => 'mc_custom_notification_order', 'sort_order' => 'DESC' ];
if ( bp_has_notifications( $args ) ) {
<?php
add_action( 'init', function() {
$check_list_of_caps = [ 'custom_capability_one', 'custom_capability_two', 'manage_options' ];
// Test one
$time_start = microtime( true );
// Get current user caps
$all_users_caps = wp_get_current_user()->allcaps;
<?php
/**
* Strip then trim a text around the cut $cut_length
*
* @param string $text
* @param int $cut_length
*
* @author Maxime CULEA
*
* @return string
@MaximeCulea
MaximeCulea / ms-files-rewriting.php
Created May 20, 2019 12:18
Rewrite to have only one folder for all files
<?php
/**
* For all files into one site folder.
*/
//add_filter( 'upload_dir', 'move_uploads' );
function move_uploads( $cache_key ) {
$blog_id = get_current_blog_id();
if ( 6 === $blog_id ) {
return $cache_key;
}
@MaximeCulea
MaximeCulea / beapi-searchwp.php
Created May 16, 2019 14:11 — forked from asadowski10/beapi-searchwp.php
Deactive Search WP on AJAX P2P search query
<?php
/*
Plugin Name: Be API - Search WP
Plugin URI: http://www.beapi.fr
Description: Deactive Search WP on AJAX P2P search query
Author: BeAPI
Author URI: http://www.beapi.fr
Version: 1.0.0
*/
@MaximeCulea
MaximeCulea / wc-tips.php
Created May 7, 2019 16:00
Some tips with WC
<?php
/**
* When using woocommerce_form_field api
* Some tips to maje custom things
*/
woocommerce_form_field( 'field_id', [
// make the field readonly
'custom_attributes' => [ 'readonly' => true ]
], 'value' );