| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Plugin Name: BP Group Extension Tester One
|
|---|
| 4 | Description: Test the hook that will load an extension.
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | function group_extension_hook_start(){
|
|---|
| 8 | error_log( "running group_extension_hook_start");
|
|---|
| 9 |
|
|---|
| 10 | class Group_Extension_Example_2 extends BP_Group_Extension {
|
|---|
| 11 | /**
|
|---|
| 12 | * Here you can see more customization of the config options
|
|---|
| 13 | */
|
|---|
| 14 | function __construct() {
|
|---|
| 15 | $args = array(
|
|---|
| 16 | 'slug' => 'group-extension-example-2',
|
|---|
| 17 | 'name' => 'New Tab',
|
|---|
| 18 | 'nav_item_position' => 101,
|
|---|
| 19 | 'screens' => array(
|
|---|
| 20 | 'edit' => array(
|
|---|
| 21 | 'name' => 'GE Example 2',
|
|---|
| 22 | // Changes the text of the Submit button
|
|---|
| 23 | // on the Edit page
|
|---|
| 24 | 'submit_text' => 'Submit, suckaz',
|
|---|
| 25 | ),
|
|---|
| 26 | 'create' => array(
|
|---|
| 27 | 'position' => 100,
|
|---|
| 28 | ),
|
|---|
| 29 | ),
|
|---|
| 30 | );
|
|---|
| 31 | parent::init( $args );
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | function display( $group_id = NULL ) {
|
|---|
| 35 | $group_id = bp_get_group_id();
|
|---|
| 36 | echo 'This plugin is 2x cooler!';
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | function settings_screen( $group_id = NULL ) {
|
|---|
| 40 | $setting = groups_get_groupmeta( $group_id, 'group_extension_example_2_setting' );
|
|---|
| 41 |
|
|---|
| 42 | ?>
|
|---|
| 43 | Save your plugin setting here: <input type="text" name="group_extension_example_2_setting" value="<?php echo esc_attr( $setting ) ?>" />
|
|---|
| 44 | <?php
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | function settings_screen_save( $group_id = NULL ) {
|
|---|
| 48 | $setting = isset( $_POST['group_extension_example_2_setting'] ) ? $_POST['group_extension_example_2_setting'] : '';
|
|---|
| 49 | groups_update_groupmeta( $group_id, 'group_extension_example_2_setting', $setting );
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | /**
|
|---|
| 53 | * create_screen() is an optional method that, when present, will
|
|---|
| 54 | * be used instead of settings_screen() in the context of group
|
|---|
| 55 | * creation.
|
|---|
| 56 | *
|
|---|
| 57 | * Similar overrides exist via the following methods:
|
|---|
| 58 | * * create_screen_save()
|
|---|
| 59 | * * edit_screen()
|
|---|
| 60 | * * edit_screen_save()
|
|---|
| 61 | * * admin_screen()
|
|---|
| 62 | * * admin_screen_save()
|
|---|
| 63 | */
|
|---|
| 64 | function create_screen( $group_id = NULL ) {
|
|---|
| 65 | $setting = groups_get_groupmeta( $group_id, 'group_extension_example_2_setting' );
|
|---|
| 66 |
|
|---|
| 67 | ?>
|
|---|
| 68 | Welcome to your new group! You are neat.
|
|---|
| 69 | Save your plugin setting here: <input type="text" name="group_extension_example_2_setting" value="<?php echo esc_attr( $setting ) ?>" />
|
|---|
| 70 | <?php
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | }
|
|---|
| 74 | bp_register_group_extension( 'Group_Extension_Example_2' );
|
|---|
| 75 |
|
|---|
| 76 | class Group_Extension_Example_3 extends BP_Group_Extension {
|
|---|
| 77 | /**
|
|---|
| 78 | * Here you can see more customization of the config options
|
|---|
| 79 | */
|
|---|
| 80 | function __construct() {
|
|---|
| 81 | $args = array(
|
|---|
| 82 | 'slug' => 'group-extension-example-3',
|
|---|
| 83 | 'name' => 'New Tab 2',
|
|---|
| 84 | 'nav_item_position' => 105,
|
|---|
| 85 | 'screens' => array(
|
|---|
| 86 | 'edit' => array(
|
|---|
| 87 | 'name' => 'GE Example 3',
|
|---|
| 88 | // Changes the text of the Submit button
|
|---|
| 89 | // on the Edit page
|
|---|
| 90 | ),
|
|---|
| 91 | 'create' => array(
|
|---|
| 92 | 'position' => 100,
|
|---|
| 93 | ),
|
|---|
| 94 | ),
|
|---|
| 95 | );
|
|---|
| 96 | parent::init( $args );
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | function display( $group_id = NULL ) {
|
|---|
| 100 | $group_id = bp_get_group_id();
|
|---|
| 101 | echo 'This plugin is 3x cooler!';
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | function settings_screen( $group_id = NULL ) {
|
|---|
| 105 | $setting = groups_get_groupmeta( $group_id, 'group_extension_example_3_setting' );
|
|---|
| 106 |
|
|---|
| 107 | ?>
|
|---|
| 108 | Save your plugin setting here: <input type="text" name="group_extension_example_3_setting" value="<?php echo esc_attr( $setting ) ?>" />
|
|---|
| 109 | <?php
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | function settings_screen_save( $group_id = NULL ) {
|
|---|
| 113 | $setting = isset( $_POST['group_extension_example_3_setting'] ) ? $_POST['group_extension_example_3_setting'] : '';
|
|---|
| 114 | groups_update_groupmeta( $group_id, 'group_extension_example_3_setting', $setting );
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | /**
|
|---|
| 118 | * create_screen() is an optional method that, when present, will
|
|---|
| 119 | * be used instead of settings_screen() in the context of group
|
|---|
| 120 | * creation.
|
|---|
| 121 | *
|
|---|
| 122 | * Similar overrides exist via the following methods:
|
|---|
| 123 | * * create_screen_save()
|
|---|
| 124 | * * edit_screen()
|
|---|
| 125 | * * edit_screen_save()
|
|---|
| 126 | * * admin_screen()
|
|---|
| 127 | * * admin_screen_save()
|
|---|
| 128 | */
|
|---|
| 129 | function create_screen( $group_id = NULL ) {
|
|---|
| 130 | $setting = groups_get_groupmeta( $group_id, 'group_extension_example_3_setting' );
|
|---|
| 131 |
|
|---|
| 132 | ?>
|
|---|
| 133 | Welcome to your new group! You are neat.
|
|---|
| 134 | Save your plugin setting here: <input type="text" name="group_extension_example_3_setting" value="<?php echo esc_attr( $setting ) ?>" />
|
|---|
| 135 | <?php
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | }
|
|---|
| 139 | bp_register_group_extension( 'Group_Extension_Example_3' );
|
|---|
| 140 |
|
|---|
| 141 | class Group_Extension_Example_4 extends BP_Group_Extension {
|
|---|
| 142 | /**
|
|---|
| 143 | * Here you can see more customization of the config options
|
|---|
| 144 | */
|
|---|
| 145 | function __construct() {
|
|---|
| 146 | $args = array(
|
|---|
| 147 | 'slug' => 'group-extension-example-4',
|
|---|
| 148 | 'name' => 'New Tab 3',
|
|---|
| 149 | 'nav_item_position' => 112,
|
|---|
| 150 | 'screens' => array(
|
|---|
| 151 | 'edit' => array(
|
|---|
| 152 | 'name' => 'GE Example 4',
|
|---|
| 153 | // Changes the text of the Submit button
|
|---|
| 154 | // on the Edit page
|
|---|
| 155 | ),
|
|---|
| 156 | 'create' => array(
|
|---|
| 157 | 'position' => 100,
|
|---|
| 158 | ),
|
|---|
| 159 | ),
|
|---|
| 160 | );
|
|---|
| 161 | parent::init( $args );
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | function display( $group_id = NULL ) {
|
|---|
| 165 | $group_id = bp_get_group_id();
|
|---|
| 166 | echo 'This plugin is 4x cooler!';
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | function settings_screen( $group_id = NULL ) {
|
|---|
| 170 | $setting = groups_get_groupmeta( $group_id, 'group_extension_example_4_setting' );
|
|---|
| 171 |
|
|---|
| 172 | ?>
|
|---|
| 173 | Save your plugin setting here: <input type="text" name="group_extension_example_4_setting" value="<?php echo esc_attr( $setting ) ?>" />
|
|---|
| 174 | <?php
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | function settings_screen_save( $group_id = NULL ) {
|
|---|
| 178 | $setting = isset( $_POST['group_extension_example_4_setting'] ) ? $_POST['group_extension_example_4_setting'] : '';
|
|---|
| 179 | groups_update_groupmeta( $group_id, 'group_extension_example_4_setting', $setting );
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | /**
|
|---|
| 183 | * create_screen() is an optional method that, when present, will
|
|---|
| 184 | * be used instead of settings_screen() in the context of group
|
|---|
| 185 | * creation.
|
|---|
| 186 | *
|
|---|
| 187 | * Similar overrides exist via the following methods:
|
|---|
| 188 | * * create_screen_save()
|
|---|
| 189 | * * edit_screen()
|
|---|
| 190 | * * edit_screen_save()
|
|---|
| 191 | * * admin_screen()
|
|---|
| 192 | * * admin_screen_save()
|
|---|
| 193 | */
|
|---|
| 194 | function create_screen( $group_id = NULL ) {
|
|---|
| 195 | $setting = groups_get_groupmeta( $group_id, 'group_extension_example_4_setting' );
|
|---|
| 196 |
|
|---|
| 197 | ?>
|
|---|
| 198 | Welcome to your new group! You are neat.
|
|---|
| 199 | Save your plugin setting here: <input type="text" name="group_extension_example_4_setting" value="<?php echo esc_attr( $setting ) ?>" />
|
|---|
| 200 | <?php
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | }
|
|---|
| 204 | bp_register_group_extension( 'Group_Extension_Example_4' );
|
|---|
| 205 | }
|
|---|
| 206 | add_action( 'bp_init', 'group_extension_hook_start' );
|
|---|
| 207 |
|
|---|
| 208 | function change_group_default_tab_2( $default_tab ) {
|
|---|
| 209 | return 'group-extension-example-2';
|
|---|
| 210 | }
|
|---|
| 211 | // Set the group home page as the default page if one exists.
|
|---|
| 212 | // add_filter( 'bp_groups_default_extension', 'change_group_default_tab_2' );
|
|---|