Skip to content

Instantly share code, notes, and snippets.

View imath's full-sized avatar
🔌
Contributing to #BuddyPress

imath imath

🔌
Contributing to #BuddyPress
View GitHub Profile
@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.
<?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
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
<!-- 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
<?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é.
@imath
imath / members-loop.php
Last active December 22, 2019 23:20
Display profile field within BP Nouveau using the template hierarchy. Put the following into a /buddypress/members/ subfolder of your theme and replace `Name of your xProfile field` with the name of your profile field :)
<?php
/**
* BuddyPress - Members Loop
*
* @since 3.0.0
* @version 3.0.0
*/
bp_nouveau_before_loop(); ?>
@imath
imath / bp-custom.php
Created September 13, 2019 04:21
Activate "Activités de publication" for all new page items by default. (Requires https://github.com/imath/activites-de-publication/)
<?php
/**
* For more information about how to use the bp-custom.php file
* @see https://codex.buddypress.org/themes/bp-custom-php/
*/
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
/**
@imath
imath / bp-example-block.php
Created July 31, 2019 05:16
BuddyPress example block: Put this two file into a `bp-example-block` folder before dropping it into `/wp-content/plugins/`
<?php
/**
* Plugin Name: BP Example Block
* Plugin URI: https://buddypress.org/
* Description: Example of BuddyPress block.
* Author: The BuddyPress Community
* Author URI: https://buddypress.org/
* Version: 1.0.0
* Text Domain: buddypress
* Domain Path: /languages/
@imath
imath / bp-custom.php
Created July 12, 2019 14:17
Registering REST Fields for the BP REST API
<?php
// Registers a REST field for the Activity Endpoints.
function example_register_activity_rest_field() {
bp_rest_register_field(
'activity', // Id of the BuddyPress component the REST field is about
'example_field', // Used into the REST response/request
array(
'get_callback' => 'example_get_rest_field_callback', // The function to use to get the value of the REST Field
'update_callback' => 'example_update_rest_field_callback', // The function to use to update the value of the REST Field
@imath
imath / tickets.php
Last active October 9, 2023 03:47
Using WP Statuses for custom Post Types.
<?php
/**
* Using WP Statuses for custom Post Types.
*
* @link http://github.com/imath/wp-statuses
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
@imath
imath / wp-idea-stream-custom.php
Created February 24, 2017 06:37
Anonymise Idea authors in WP Idea Stream
<?php
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
/**
* Référencer un Idea Meta !
*/
function uana_custom_register_metas() {
// A very simple way to add a custom field (for text field only)
wp_idea_stream_ideas_register_meta( 'anonymous', array(