Skip to content

Commit a5b5c12

Browse files
committed
gcn-add-page-icon.php: Updated header annotation with description and more docs.
1 parent 056a805 commit a5b5c12

File tree

2 files changed

+41
-33
lines changed

2 files changed

+41
-33
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Gravity Connect // Notion // Add Page Emoji Icon
4+
*
5+
* This snippet demonstrates how to add an emoji icon to a Notion page
6+
* when a form entry is being added to or edited in Notion.
7+
*
8+
* Instructions:
9+
* 1. Modify the filter name to scope as needed. (see filter reference https://gravitywiz.com/documentation/gcn_notion_page_data/)
10+
* 2. Update the $emoji variable to change the icon.
11+
*
12+
* Installation:
13+
* 1. Install per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
14+
*
15+
* References:
16+
* * GC Notion: https://gravitywiz.com/documentation/gravity-connect-notion/
17+
* * Notion page POST reference: https://developers.notion.com/reference/post-page
18+
*
19+
* @since 1.0-beta-1.9
20+
*/
21+
22+
/**
23+
* Alternatively, you can use the `gcn_notion_page_data_add` or `gcn_notion_page_data_update` filters
24+
* separately to add/change the icon only when adding or updating a page.
25+
*
26+
* The filter also supports FORM_ID and FEED_ID modifiers to allow easy scoping to specific forms and feeds.
27+
*/
28+
add_filter( 'gcn_notion_page_data', function( $page_data, $form, $entry, $feed ) {
29+
/**
30+
* Modify the $emoji variable to change the icon.
31+
* Note that the Notion API requires a single emoji character.
32+
*/
33+
$emoji = '🦚';
34+
35+
$page_data['icon'] = array(
36+
'type' => 'emoji',
37+
'emoji' => $emoji,
38+
);
39+
40+
return $page_data;
41+
}, 10, 4 );

gc-notion/gcn-add-page-icon.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)