Skip to content

Instantly share code, notes, and snippets.

View MaximeCulea's full-sized avatar
🇨🇭
Life going on!

Maxime CULEA MaximeCulea

🇨🇭
Life going on!
View GitHub Profile

Installation

To install, you need to have the WordPress i18n library on your computer. Check it out using SVN:

sudo svn co http://i18n.svn.wordpress.org/tools/trunk/ /usr/lib/wpi18n

You don't have to put the library in /usr/lib/wpi18n, but if you don't put it there, make sure to set the $WP_I18N_LIB environment variable in your .bashrc or .bash_profile file (with no trailing slash):

export WP_I18N_LIB="/path/to/i18n/lib"

@MaximeCulea
MaximeCulea / wp-media-api-not-in-collection.php
Last active September 6, 2017 09:09
WP Media API - not in collection case
<?php
/**
* Here the element is an input with the media ID that we hide to keep the value for POST
* But we still want an other display, so add html after
* @author Maxime CULEA
*/
function transform_qrcode_p2p_meta(element) {
element.hide();
/**
@MaximeCulea
MaximeCulea / fix-locotranslate.php
Last active March 27, 2020 14:35
Manage to add mu plugins folders to be translated and fix rights when using `DISALLOW_FILE_MODS`.
<?php
/**
* Manage to add mu plugins folders to be translated and fix rights when using `DISALLOW_FILE_MODS`.
*
* Class BEA_Fix_Locotranslate
*
* Version 1.1.0
*/
class BEA_Fix_Locotranslate {
@MaximeCulea
MaximeCulea / correct-rights.sh
Last active January 6, 2021 21:59
Apply correct rights on folder, files and mo/pot files for WordPress.
# Folders
find ~/public_html/ -type d -exec chmod 755 {} +
# Files
find ~/public_html/ -type f -exec chmod 644 {} +
# MO & POT
find ~/public_html/ -type f -name "*.mo" -exec chmod 775 {} +
find ~/public_html/ -type f -name "*.pot" -exec chmod 775 {} +
# When the root is web
find web/ -type d -exec chmod 755 {} +
@MaximeCulea
MaximeCulea / default-add-to-any.php
Created October 16, 2017 06:58
Default Add To Any config.
<?php
/**
* Disable autodisplay after `the_content`
* @author Maxime Culea
*/
function addtoany_disable_sharing_on_my_custom_post_type() {
return true;
}
add_filter( 'addtoany_sharing_disabled', 'addtoany_disable_sharing_on_my_custom_post_type' );
@MaximeCulea
MaximeCulea / default-mlp.php
Created October 16, 2017 07:00
Default Multilingual Press config.
<?php
/**
* Deactivate almost all network options.
* @author Maxime Culea
*/
add_filter( 'pre_site_option_state_modules', function () {
return [
'class-Mlp_Cpt_Translator' => 'off',
'class-Mlp_Advanced_Translator' => 'off',
'class-Mlp_Alternative_Language_Title_Module' => 'off',
@MaximeCulea
MaximeCulea / default-pto.php
Created October 16, 2017 07:01
Default Post Types Order config.
<?php
/**
* Add default options for post type order.
* Custom cases with my post types, maybe use a filterable option.
*
* @author Maxime CULEA
*/
add_filter( 'pto/get_options', function () {
return [
'show_reorder_interfaces' => [
@MaximeCulea
MaximeCulea / back-top.js
Last active October 22, 2017 16:01
Change the back-top div's position depending on current scroll in order to not overwrite the footer.
$(window).scroll(function () {
// This is the div ( class="container-full site-info" ) not to overwrite
var footer_height = $(".container-full.site-info").outerHeight();
// This it the button margin from bottom of the window
var margin_to_footer = 3;
// Dynamicly set the fixed bottom with the margin :
// - window height - ( footer div height + footermargin )
// - just the footer margin
@MaximeCulea
MaximeCulea / clean_mac_zip.sh
Last active August 24, 2018 14:48
Clean a mac zip.
#!/bin/sh
zip -d $1 __MACOSX/\*
zip -d $1 \*/.DS_Store
zip -d $1 \*/._\*
@MaximeCulea
MaximeCulea / date.php
Last active October 27, 2017 12:23
Sample for playing with dates.
<?php
// In one line, get the last day (date formatted in Y-m-d) of the previous current month
$last_day_of_previous_month = date(
'Y-m-d',
mktime(
0,
0,
0,
date( 'm' ) - 1,
date( 't',