Skip to content

Instantly share code, notes, and snippets.

View wpchannel's full-sized avatar
:octocat:

Aurélien Denis wpchannel

:octocat:
View GitHub Profile
@wpchannel
wpchannel / mu-sanitize-filename.php
Last active April 21, 2024 14:51
Clean file name when uploading in WordPress
<?php if ( ! defined( 'ABSPATH' ) ) {
die( 'Restricted Area' );
}
/*
* Plugin Name: Sanitize File Name
* Description: Clean file name when uploading files in WordPress.
* Version: 20240103
* Author: Mickaël Gris (Saipafo) & Aurélien Denis (WP channel)
* Author URI: https://wpchannel.com/wordpress/tutoriels-wordpress/renommer-automatiquement-fichiers-accentues-wordpress/
@wpchannel
wpchannel / mu-yoast-seo-disable-notifications.php
Last active April 16, 2023 08:33
Hide annoying notifications after each upgrade of Yoast SEO plugin and others admin notices
<?php if (!defined('ABSPATH')) die('Restricted Area');
/*
* Plugin Name: Disable Yoast SEO Notifications
* Description: Hide annoying notifications after each upgrade of Yoast SEO plugin and others admin notices.
* Version: 1.1
* Author: Aurélien Denis
* Author URI: https://wpchannel.com/
*/
@wpchannel
wpchannel / import-media-polylang-wordpress.php
Last active February 28, 2023 07:44
Custom script to import CSV file containing images into a WordPress site using Polylang as multilingual plugin.
<?php
require_once( 'wp/wp-load.php' );
// Set the path to the CSV file
$file_path = 'products_images.csv';
$count = 0;
$csv_data = array();
@wpchannel
wpchannel / import-products-polylang-wordpress.php
Last active February 28, 2023 07:44
Custom script to import CSV file containing products into a WordPress site using Polylang as multilingual plugin.
<?php
require_once('wp/wp-load.php');
// Set the path to the CSV file
$file_path = 'products.csv';
$count = 0;
$csv_data = array();
@wpchannel
wpchannel / import-terms-taxonomy-polylang-wordpress.php
Last active February 28, 2023 07:43
Custom script to import CSV file containing terms into a WordPress site using Polylang as multilingual plugin.
<?php
require_once('wp/wp-load.php');
// Set the path to the CSV file
$file_path = 'brands.csv';
// Open the CSV file
if (($handle = fopen($file_path, 'r')) !== FALSE) {
// Loop through each row in the CSV file
@wpchannel
wpchannel / filter-wordpress-recent-posts-widget.php
Last active December 12, 2022 08:50
Filter WordPress Recent Posts Widget
function wpc_filter_recent_posts_widget_parameters($params) {
$params['orderby'] = 'date';
$params['tax_query'] = array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array('post-format-movie', 'post-format-aside'),
'operator' => 'NOT IN'
)
);
@wpchannel
wpchannel / mu-disable-password-notification.php
Last active August 7, 2022 15:23
Disable password change notification
/* Disable User Password Change Notification */
add_filter('send_password_change_email', '__return_false');
/* Disable Admin Password Change Notification */
remove_action('after_password_reset', 'wp_password_change_notification');
@wpchannel
wpchannel / mu-gravity-forms.php
Last active April 30, 2022 08:06
Best tweaks for Gravity Forms plugin for creating forms with WordPress. Enhance Bootstrap 4 compatibility and increase performances. More informations in this tutorial: https://wpchannel.com/wordpress/tutoriels-wordpress/astuces-optimiser-formulaires-gravity-forms
<?php if (!defined('ABSPATH')) die('Restricted Area');
/*
* Plugin Name: Gravity Forms Enhancements
* Description: Tweaks for Gravity Forms plugin.
* Version: 20191102
* Author: Aurélien Denis
* Author URI: https://wpchannel.com/
*/
@wpchannel
wpchannel / wp_list_children_terms.php
Created August 19, 2018 12:45
List children terms of current taxonomy term
<?php
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
$taxonomy_name = 'category';
$term_children = get_term_children($term_id, $taxonomy_name);
echo '<ul class="nav nav-pills">';
foreach ($term_children as $child) {
$term = get_term_by('id', $child, $taxonomy_name);
@wpchannel
wpchannel / wp_has_children_pages.php
Last active February 18, 2018 19:08
Test if a page has children or not
<?php
$parent_ID = $post->post_parent ? @ array_pop(get_post_ancestors($post)) : $post->ID;
$children = wp_list_pages(
array(
'child_of' => $parent_ID,
'title_li' => '',
'echo' => false,
)
);
?>