Skip to content

Instantly share code, notes, and snippets.

🇨🇭
New life begining.

Maxime CULEA MaximeCulea

🇨🇭
New life begining.
Block or report user

Report or block MaximeCulea

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View better-gutenberg.php
<?php
add_action( 'enqueue_block_editor_assets', 'disable_editor_fullscreen' );
function disable_editor_fullscreen() {
if ( ! is_admin() ) {
return;
}
wp_add_inline_script( 'wp-blocks', "jQuery( window ).load(function() { const isFullscreenMode = wp.data.select( 'core/edit-post' ).isFeatureActive( 'fullscreenMode' ); if ( isFullscreenMode ) { wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'fullscreenMode' ); } });" );
}
@MaximeCulea
MaximeCulea / file_mod_allowed.php
Created Apr 3, 2020
Allow to download a lang despite DISALLOW_FILE_MODS to true
View file_mod_allowed.php
<?php
/**
* Allow to download a lang despite DISALLOW_FILE_MODS to true
* @author Maxime Culea
*/
add_filter( 'file_mod_allowed', function ( $value, $context ) {
if ( $context == 'can_install_language_pack' ) {
return true;
}
@MaximeCulea
MaximeCulea / admin-menu.php
Created Feb 28, 2020
Create a custom admin menu in order to attach a post type and taxonomy.
View admin-menu.php
<?php class Custom_Admin_Menu {
/**
* I have an e-sport section with is related to a program and players (as post types)
* Also related to theses, we specify scenes and games (as taxonomies)
* In fine the idea is to gather all this into a single admin menu :
* E-Sport
* |-- Programs
* |-- Players
* |-- Scenes
* |-- Games
@MaximeCulea
MaximeCulea / social.php
Created Feb 17, 2020
Get social icon depending on the social network (for wp)
View social.php
<?php
function get_social_icon( $social_url ) {
$default_icon = 'access';
if ( empty( $social_url ) ) {
return sprintf( 'icon-%s', $default_icon );
}
$parse_social = wp_parse_url( $social_url );
// Get the social's sld in order to use the corresponding icon
@MaximeCulea
MaximeCulea / template-part.php
Created Feb 17, 2020
Handle variables when working with template parts.
View template-part.php
<?php class MC_Template_Part_Var {
/**
* @author Maxime Culea
* @var MC_Template_Part_Var
*/
public static $instance;
/**
* Vars to store
*
@MaximeCulea
MaximeCulea / body-class.php
Last active Feb 17, 2020
Ease the use of body classes into template.
View body-class.php
<?php class MC_Body_Class {
private static $instance;
private $body_class = [];
private $delete_class = [];
private function __construct() {
self::$instance = $this;
add_filter( 'body_class', array( $this, 'body_class' ) );
@MaximeCulea
MaximeCulea / local-on-windows.md
Last active Feb 13, 2020
Git, work, sync and load the site with Local By Flywheel
View local-on-windows.md
  1. Delete everything into the Local app folder except the phpadminer.php file
  2. Copy and Sync the local gited folder to the app Local folder
  3. Finnaly map the "public" folder with the application root folder (web) with a mklink : mklink /D "public" "web"
@MaximeCulea
MaximeCulea / bp-read-all-notifications.php
Created Aug 6, 2019
BuddyPress - Read all notifications buton
View bp-read-all-notifications.php
<?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 Jul 24, 2019
Customize ACF fields and options.
View acf-customize.php
<?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' );
View wp-all-export.php
<?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
*
You can’t perform that action at this time.