<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][13924] trunk/docs/developer: Documentation: inform developers about the BP Theme Compat features</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/13924">13924</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/13924","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-06-12 01:32:32 +0000 (Wed, 12 Jun 2024)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Documentation: inform developers about the BP Theme Compat features
Props vapvarun
Closes https://github.com/buddypress/buddypress/pull/298</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkdocsdevelopermanifestjson">trunk/docs/developer/manifest.json</a></li>
<li><a href="#trunkdocsdeveloperthemecompatREADMEmd">trunk/docs/developer/theme-compat/README.md</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkdocsdeveloperthemecompatfeaturesmd">trunk/docs/developer/theme-compat/features.md</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkdocsdevelopermanifestjson"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/docs/developer/manifest.json</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/docs/developer/manifest.json 2024-06-11 06:40:54 UTC (rev 13923)
+++ trunk/docs/developer/manifest.json 2024-06-12 01:32:32 UTC (rev 13924)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,6 +36,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "parent": null
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "title": "Theme compatibility features",
+ "slug": "bp-theme-compat-features",
+ "markdown_source": "../developer/theme-compat/features.md",
+ "parent": null
+ },
+ {
</ins><span class="cx" style="display: block; padding: 0 10px"> "title": "BuddyPress execution contexts",
</span><span class="cx" style="display: block; padding: 0 10px"> "slug": "bp-execution-contexts",
</span><span class="cx" style="display: block; padding: 0 10px"> "markdown_source": "../developer/execution-contexts/README.md",
</span></span></pre></div>
<a id="trunkdocsdeveloperthemecompatREADMEmd"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/docs/developer/theme-compat/README.md</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/docs/developer/theme-compat/README.md 2024-06-11 06:40:54 UTC (rev 13923)
+++ trunk/docs/developer/theme-compat/README.md 2024-06-12 01:32:32 UTC (rev 13924)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,3 +1,3 @@
</span><span class="cx" style="display: block; padding: 0 10px"> # BuddyPress Theme compatibility
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-TBD.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+- [Theme compatibility features](./features.md)
</ins></span></pre></div>
<a id="trunkdocsdeveloperthemecompatfeaturesmd"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/docs/developer/theme-compat/features.md</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/docs/developer/theme-compat/features.md (rev 0)
+++ trunk/docs/developer/theme-compat/features.md 2024-06-12 01:32:32 UTC (rev 13924)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,119 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+# Theme compatibility features
+
+BuddyPress allows members and groups to upload and manage their Cover Images. This feature enhances the visual appeal of profiles and group pages by providing a customizable background image.
+
+**Under the hood** it uses the BP Theme Compat Features API which was developed in order to transpose the WP Theme Supports API into the BP Template Packs world.
+
+## Theme compatibility feature registration
+
+Just like WordPress is allowing Themes to opt-in for specific functionalities (eg: the [custom header](https://developer.wordpress.org/themes/functionality/custom-headers/)) using the `add_theme_support()` function inside a `'after_setup_theme'` hook callback function, you need to wait for the `'bp_after_setup_theme'` hook to be fired to register your Theme Compat feature using the `bp_set_theme_compat_feature()` function.
+
+```php
+function set_my_template_pack_features() {
+ $template_pack_id = 'my-template-pack-id';
+ $feature_args = array(
+ 'name' => 'my_theme_compat_feature',
+ 'settings' => array(
+ 'components' => array( 'groups', 'members' ),
+ ),
+ );
+
+ // Registers the Theme Compat feature into your template pack.
+ bp_set_theme_compat_feature( $template_pack_id, $feature_args );
+}
+add_action( 'bp_after_setup_theme', 'set_my_template_pack_features' );
+```
+
+### `bp_set_theme_compat_feature()`
+Use this function to set a Theme compatibility feature.
+
+_This function was introduced in version 2.4.0_
+
+#### Arguments
+
+`bp_members_get_user_url()` accepts two arguments: the Template Pack ID and an associative array of settings.
+
+| Argument | Type | Required | Defaults | Description |
+|---|---|---|---|---|
+|`$template_pack_id`|`string`|Yes|`''`|The Template Pack ID to set the feature for|
+|`$feature_args`|`array`|No|`[]`|This associative array of arguments is described below|
+
+`$feature_args` list of arguments:
+
+| Array key | Type | Required | Defaults | Description |
+|---|---|---|---|---|
+|`name`|`string`|No|`''`|The name key of the feature.|
+|`settings`|`array`|No|`[]`|Used to pass as many as needed additional variables. **NB** using a `components` key with an array listing component IDs that the feature is targeting will link it to these components. In this case you can use `bp_is_active( 'members', 'my_theme_compat_feature' )` to check whether you should load the feature's code or not.|
+
+## Getting the Theme compatibility feature settings
+
+When you need to get the settings of a registered Theme Compat feature, you can use the `bp_get_theme_compat_feature()` function.
+
+### `bp_get_theme_compat_feature()`
+
+Use this function to get a Theme compatibility feature's settings. It returns `false` if something went wrong or an object keyed with the settings argument keys containing the settings values.
+
+_This function was introduced in version 2.4.0_
+
+#### Arguments
+
+`bp_get_theme_compat_feature()` accepts one argument: `$name`.
+
+| Argument | Type | Required | Defaults | Description |
+|---|---|---|---|---|
+|`$name`|`string`|Yes|`''`|the name key of the feature|
+
+## Get inspired by the Cover Image Theme compatibility feature
+
+Just like this feature does, including extra filters into your code to let advanced users to customize it to better match their Theme can be a good idea.
+
+Below are examples to feed your imagination about how it's possible to modify the BP built-in Cover Image Theme compat feature default settings or completely disable it.
+
+### Changing Cover Image Sizes
+
+You can change the default Cover Image sizes by adding a filter in your `bp-custom.php` file.
+
+```php
+/**
+ * PS: The Cover Image feature is using the `bp_parse_args()` function.
+ */
+function my_custom_cover_image_dimensions( $settings = array() ) {
+ $settings['width'] = 1400;
+ $settings['height'] = 300;
+
+ return $settings;
+}
+add_filter( 'bp_before_members_cover_image_settings_parse_args', 'my_custom_cover_image_dimensions' );
+add_filter( 'bp_before_groups_cover_image_settings_parse_args', 'my_custom_cover_image_dimensions' );
+```
+
+### Changing default Cover Image
+
+When users haven't customized their Cover Images yet, this image will be used as a fallback.
+
+```php
+/**
+ * PS: The Cover Image feature is using the `bp_parse_args()` function.
+ */
+function my_custom_cover_xprofile_cover_image( $settings = array() ) {
+ $settings['default_cover'] = 'https://site.url/to/your/default_cover_image.jpg';
+
+ return $settings;
+}
+add_filter( 'bp_before_members_cover_image_settings_parse_args', 'my_custom_cover_xprofile_cover_image', 10, 1 );
+```
+
+### Disable Cover Images for members or groups
+
+You can disable Cover Images by adding a filter to your `bp-custom.php` file.
+
+```php
+// For members :
+add_filter( 'bp_is_members_cover_image_active', '__return_false' );
+
+// For groups :
+add_filter( 'bp_is_groups_cover_image_active', '__return_false' );
+```
+
+> [!NOTE]
+> Using a `bp_is_{$component_id}_{$feature}_active` filter is made possible by the fact the Cover Image feature is using the `$components` feature argument to set it to `members` & `groups`.
</ins></span></pre>
</div>
</div>
</body>
</html>