Skip to content

Instantly share code, notes, and snippets.

Avatar
🔌
Contributing to #BuddyPress

imath imath

🔌
Contributing to #BuddyPress
View GitHub Profile
@imath
imath / functions.php
Created January 29, 2023 21:50
Workaround to make sure query pagination labels are translated when a block pattern is used to display the `core/query-pagination-previous` && `core/query-pagination-next` WordPress blocks
View functions.php
<?php
/**
* Workaround to make sure query pagination labels are translated.
*
* This function hooks `render_block_context` to transport the `core/query-pagination` block
* context inside the 'ensemble/pagination' pattern so that the `core/query-pagination-previous`
* & the `core/query-pagination-next` blocks can use it.
*
* @since 1.0.0
*
@imath
imath / single.html
Created January 29, 2023 19:36
WordPress template part to use to have previous and next post displayed into the pagination of the single template
View single.html
<!-- wp:group {"tagName":"nav","className":"single-footer-pagination","layout":{"type":"flex","justifyContent":"space-between"}} -->
<nav class="wp-block-group single-footer-pagination">
<!-- wp:post-navigation-link {"type":"previous","showTitle":true} /-->
<!-- wp:post-navigation-link {"showTitle":true} /-->
</nav>
<!-- /wp:group -->
@imath
imath / mu-plugins-functions.php
Last active January 11, 2023 21:35
Workaround to remove BuddyPress registration overrides
View mu-plugins-functions.php
<?php
/**
* Put this file into the `wp-content/mu-plugins` directory.
*/
function restore_wp_registration_url() {
return site_url( 'wp-login.php?action=register', 'login' );
}
function use_a_specific_wordpress_page() {
@imath
imath / bp-custom.php
Created July 19, 2022 05:26
Force the full size featured image to be used by the BP Media Extractor for `new_blog_post` activity types (See BP Trac ticket 8052)
View bp-custom.php
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Force the full size featured image to be used by the BP Media Extractor for `new_blog_post` activity types.
*
@imath
imath / bp-custom.php
Created January 8, 2022 04:42
Code used to check the BuddyPress WP xProfile field type works as expected, see https://buddypress.org/support/topic/wordpress-specific-xprofile-meta-fields-not-saving/
View bp-custom.php
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function maelscuttle_twitter_xprofile( $methods = array() ) {
$methods['twitter'] = __( 'Twitter', 'maelscuttle-textdomain' );
return $methods;
@imath
imath / bp-custom-1.php
Last active November 14, 2020 11:59
Examples to show BP REST API 7.0.0 improvements.
View bp-custom-1.php
<?php
/**
* Showing the `friendship_status_slug` Members Endpoint's schema property.
*/
function test_bp_rest_api() {
wp_enqueue_script( 'bp-api-request' );
wp_add_inline_script(
'bp-api-request',
'bp.apiRequest( {
@imath
imath / bp-custom.php
Last active April 6, 2020 18:08
Outputs the content of the Activity WordPress page into the BP Activity directory.
View bp-custom.php
<?php
/**
* BP Custom function file.
*
* Add this file into /wp-content/plugins/ to customize BuddyPress.
*
* @see https://codex.buddypress.org/themes/bp-custom-php/
*/
// Exit if accessed directly.
@imath
imath / post-taxonomy-panel.js
Created March 1, 2020 03:52
Example of use of the filter to replace the PostTaxonomy panel of the WordPress Block Editor
View post-taxonomy-panel.js
const { createElement, Component } = wp.element;
const { compose } = wp.compose;
const { RadioControl } = wp.components;
const { withSelect, withDispatch } = wp.data;
const { addFilter } = wp.hooks;
const { apiFetch } = wp;
const { __ } = wp.i18n;
class RiskDomain extends Component {
constructor() {
@imath
imath / post_content.html
Created February 25, 2020 04:33
Exemple de bloc WordPress sauvegardé dans le champ `post_content` d'un type de publication
View post_content.html
<!-- wp:wpqba/block {"wpqbaAttributeOne":"Un","wpqbaAttributeTwo":1} -->
<div class="wp-block-wpqba-block">
<h2>Test inputs</h2>
<div class="row">
<div class="label">
<span>Test input One</span>
</div>
<div class="value">
<span>Un</span>
</div>
@imath
imath / mu-plugins-functions.php
Created January 12, 2020 17:05
Deactivate or move the trackback URI control
View mu-plugins-functions.php
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Ajouter ce code dans un fichier du répertoire /wp-content/mu-plugins
* de votre WordPress pour désactiver l'insertion du contrôle pour afficher
* l'URL de trackback de l'article affiché.