Skip to content

Commit

Permalink
fix #105
Browse files Browse the repository at this point in the history
  • Loading branch information
slaFFik committed Oct 15, 2016
1 parent 4638940 commit 1415c65
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 42 deletions.
4 changes: 2 additions & 2 deletions core/cpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ function bpge_delete_group(
$to_delete = false;
$pages = $fields = array();

if ( isset( $bp->groups->current_group->extras['gpage_id'] ) && ! empty( $bp->groups->current_group->extras['gpage_id'] ) ) {
$to_delete = $bp->groups->current_group->extras['gpage_id'];
if ( isset( $bp->groups->current_group->args['extras']['gpage_id'] ) && ! empty( $bp->groups->current_group->args['extras']['gpage_id'] ) ) {
$to_delete = $bp->groups->current_group->args['extras']['gpage_id'];
} else {
$bpge = groups_get_groupmeta( $group_obj->id, 'bpge' );
if ( $bpge && ! empty( $bpge['gpage_id'] ) ) {
Expand Down
2 changes: 1 addition & 1 deletion core/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,5 @@ function bpge_get_group_nav() {
* Display a new home name for group navigation.
*/
function bpge_get_home_name() {
return ! empty( buddypress()->groups->current_group->extras['home_name'] ) ? buddypress()->groups->current_group->extras['home_name'] : bpge_names( 'home' );
return ! empty( buddypress()->groups->current_group->args['extras']['home_name'] ) ? buddypress()->groups->current_group->args['extras']['home_name'] : bpge_names( 'home' );
}
69 changes: 36 additions & 33 deletions core/loader.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

/**
* Class BPGE
*/
class BPGE extends BP_Group_Extension {
public $bpge = false;

Expand Down Expand Up @@ -32,7 +35,7 @@ class BPGE extends BP_Group_Extension {

/**
* BPGE constructor.
* Initialize everything
* Initialize everything.
*/
public function __construct() {
global $bp;
Expand All @@ -44,20 +47,20 @@ public function __construct() {
// populate extras data in global var
$bpge = groups_get_groupmeta( $bp->groups->current_group->id, 'bpge' );
if ( ! empty( $bpge ) ) {
$bp->groups->current_group->extras = $bpge;
$bp->groups->current_group->args['extras'] = $bpge;
}
}

if ( ! empty( $bp->groups->current_group ) && ! empty( $bp->groups->current_group->extras['gpage_id'] ) ) {
$this->gpage_id = $bp->groups->current_group->extras['gpage_id'];
if ( ! empty( $bp->groups->current_group ) && ! empty( $bp->groups->current_group->args['extras']['gpage_id'] ) ) {
$this->gpage_id = $bp->groups->current_group->args['extras']['gpage_id'];
} elseif ( ! empty( $bp->groups->current_group ) ) {
$this->gpage_id = $this->get_gpage_by( 'group_id' );
}

// Display or Hide top custom Fields menu from group non-members
$this->visibility = isset( $bp->groups->current_group->extras['display_page'] ) ? $bp->groups->current_group->extras['display_page'] : 'public';
if ( isset( $bp->groups->current_group->extras['display_page'] ) &&
$bp->groups->current_group->extras['display_page'] == 'public' &&
$this->visibility = isset( $bp->groups->current_group->args['extras']['display_page'] ) ? $bp->groups->current_group->args['extras']['display_page'] : 'public';
if ( isset( $bp->groups->current_group->args['extras']['display_page'] ) &&
$bp->groups->current_group->args['extras']['display_page'] == 'public' &&
$bp->groups->current_group->user_has_access
) {
$this->enable_nav_item = true;
Expand All @@ -68,20 +71,20 @@ public function __construct() {
$this->enable_edit_item = true;
}

if ( bp_is_single_item() && ! empty( $bp->groups->current_group ) && empty( $bp->groups->current_group->extras['display_page_layout'] ) ) {
if ( isset( $bp->groups->current_group->extras ) ) {
$current_group_extras = $bp->groups->current_group->extras;
if ( bp_is_single_item() && ! empty( $bp->groups->current_group ) && empty( $bp->groups->current_group->args['extras']['display_page_layout'] ) ) {
if ( isset( $bp->groups->current_group->args['extras'] ) ) {
$current_group_extras = $bp->groups->current_group->args['extras'];
} else {
$current_group_extras = array();
}
$current_group_extras['display_page_layout'] = 'profile';
$bp->groups->current_group->extras = $current_group_extras;
$bp->groups->current_group->args['extras'] = $current_group_extras;
}

// gPages Page
$this->gpages_item_name = isset( $bp->groups->current_group->extras['gpage_name'] ) ? $bp->groups->current_group->extras['gpage_name'] : bpge_names( 'gpages' );
if ( isset( $bp->groups->current_group->extras['display_gpages'] ) &&
$bp->groups->current_group->extras['display_gpages'] == 'public' &&
$this->gpages_item_name = isset( $bp->groups->current_group->args['extras']['gpage_name'] ) ? $bp->groups->current_group->args['extras']['gpage_name'] : bpge_names( 'gpages' );
if ( isset( $bp->groups->current_group->args['extras']['display_gpages'] ) &&
$bp->groups->current_group->args['extras']['display_gpages'] == 'public' &&
$bp->groups->current_group->user_has_access
) {
$this->enable_gpages_item = true;
Expand All @@ -91,11 +94,11 @@ public function __construct() {
$this->name = bpge_names( 'nav' );

// Public page
$this->nav_item_name = isset( $bp->groups->current_group->extras['display_page_name'] ) ? $bp->groups->current_group->extras['display_page_name'] : bpge_names( 'nav' );
$this->nav_item_name = isset( $bp->groups->current_group->args['extras']['display_page_name'] ) ? $bp->groups->current_group->args['extras']['display_page_name'] : bpge_names( 'nav' );

// Home page
if ( isset( $bp->groups->current_group->extras ) && ! empty( $bp->groups->current_group->extras['home_name'] ) ) {
$this->home_name = $bp->groups->current_group->extras['home_name'];
if ( isset( $bp->groups->current_group->args['extras'] ) && ! empty( $bp->groups->current_group->args['extras']['home_name'] ) ) {
$this->home_name = $bp->groups->current_group->args['extras']['home_name'];

if ( bpge_is_bp_26() ) {
buddypress()->groups->nav->edit_nav( array( 'name' => $this->home_name ), 'home', bp_current_item() );
Expand Down Expand Up @@ -147,8 +150,8 @@ public function display( $group_id = null ) {
return;
}

if ( isset( $bp->groups->current_group->extras['display_page_layout'] ) &&
$bp->groups->current_group->extras['display_page_layout'] == 'plain'
if ( isset( $bp->groups->current_group->args['extras']['display_page_layout'] ) &&
$bp->groups->current_group->args['extras']['display_page_layout'] == 'plain'
) {
bpge_view( 'front/display_fields_plain',
array(
Expand Down Expand Up @@ -196,7 +199,7 @@ public function gpages_screen_nav() {
AND `post_status` = 'publish'
ORDER BY `menu_order` ASC
LIMIT 1",
(int) $bp->groups->current_group->extras['gpage_id'],
(int) $bp->groups->current_group->args['extras']['gpage_id'],
$this->page_slug ) );
}

Expand Down Expand Up @@ -235,7 +238,7 @@ public function gpages_screen_content() {
AND `post_parent` = %d",
$bp->action_variables[0],
$this->page_slug,
$bp->groups->current_group->extras['gpage_id']
$bp->groups->current_group->args['extras']['gpage_id']
) );

restore_current_blog();
Expand Down Expand Up @@ -449,14 +452,14 @@ public function edit_screen_general() {

$bp = buddypress();

if ( ! isset( $bp->groups->current_group->extras['display_page'] ) ) {
$bp->groups->current_group->extras['display_page'] = 'public';
if ( empty( $bp->groups->current_group->args['extras']['display_page'] ) ) {
$bp->groups->current_group->args['extras']['display_page'] = 'public';
}
if ( ! isset( $bp->groups->current_group->extras['display_gpages'] ) ) {
$bp->groups->current_group->extras['display_gpages'] = 'public';
if ( empty( $bp->groups->current_group->args['extras']['display_gpages'] ) ) {
$bp->groups->current_group->args['extras']['display_gpages'] = 'public';
}
if ( ! isset( $bp->groups->current_group->extras['display_page_layout'] ) ) {
$bp->groups->current_group->extras['display_page_layout'] = 'plain';
if ( empty( $bp->groups->current_group->args['extras']['display_page_layout'] ) ) {
$bp->groups->current_group->args['extras']['display_page_layout'] = 'plain';
}

$this->edit_screen_head( 'general' );
Expand Down Expand Up @@ -637,16 +640,16 @@ public function edit_screen_save( $group_id = null ) {
return false;
}

$meta = $bp->groups->current_group->extras;
$meta = $bp->groups->current_group->args['extras'];

$meta['display_page'] = $_POST['group-extras-display'];
$meta['display_page_name'] = stripslashes( strip_tags( $_POST['group-extras-display-name'] ) );
$meta['display_page_name'] = stripslashes( wp_strip_all_tags( $_POST['group-extras-display-name'] ) );
$meta['display_page_layout'] = $_POST['group-extras-display-layout'];

$meta['gpage_name'] = stripslashes( strip_tags( $_POST['group-gpages-display-name'] ) );
$meta['gpage_name'] = stripslashes( wp_strip_all_tags( $_POST['group-gpages-display-name'] ) );
$meta['display_gpages'] = $_POST['group-gpages-display'];

$meta['home_name'] = stripslashes( strip_tags( $_POST['group-extras-home-name'] ) );
$meta['home_name'] = stripslashes( wp_strip_all_tags( $_POST['group-extras-home-name'] ) );

// now save nav order
if ( ! empty( $_POST['bpge_group_nav_position'] ) ) {
Expand Down Expand Up @@ -745,7 +748,7 @@ public function edit_screen_save( $group_id = null ) {
'post_title' => $_POST['extra-page-title'],
'post_name' => isset( $_POST['extra-page-slug'] ) ? $_POST['extra-page-slug'] : '',
'post_content' => $_POST['extra-page-content'],
'post_parent' => $bp->groups->current_group->extras['gpage_id'],
'post_parent' => $bp->groups->current_group->args['extras']['gpage_id'],
'post_status' => $_POST['extra-page-status'],
'menu_order' => count( $this->get_all_gpages() ) + 1,
'post_type' => $this->page_slug
Expand Down Expand Up @@ -894,7 +897,7 @@ public function get_all_gpages( $post_status = 'any' ) {
switch_to_blog( bpge_get_main_site_id() );

$args = array(
'post_parent' => $bp->groups->current_group->extras['gpage_id'],
'post_parent' => $bp->groups->current_group->args['extras']['gpage_id'],
'post_type' => $this->page_slug,
'orderby' => 'menu_order',
'order' => 'ASC',
Expand Down
12 changes: 6 additions & 6 deletions views/front/extras_general.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
<p>
<label
for="group_extras_display"><?php echo sprintf( __( 'Do you want to make <strong>"%s"</strong> page public? Everyone will see this page.', 'buddypress-groups-extras' ), $nav_item_name ); ?></label>
<input type="radio" value="public" <?php echo checked( $bp->groups->current_group->extras['display_page'], 'public', false ); ?>
<input type="radio" value="public" <?php echo checked( $bp->groups->current_group->args['extras']['display_page'], 'public', false ); ?>
name="group-extras-display"> <?php _e( 'Show it', 'buddypress-groups-extras' ); ?><br/>
<input type="radio" value="private" <?php echo checked( $bp->groups->current_group->extras['display_page'], 'private', false ); ?>
<input type="radio" value="private" <?php echo checked( $bp->groups->current_group->args['extras']['display_page'], 'private', false ); ?>
name="group-extras-display"> <?php _e( 'Hide it', 'buddypress-groups-extras' ); ?>
</p>

<p>
<label
for="group_extras_display_layout"><?php echo sprintf( __( 'Please choose the layout for <strong>"%s"</strong> page', 'buddypress-groups-extras' ), $nav_item_name ); ?></label>
<input type="radio" value="plain" <?php echo checked( $bp->groups->current_group->extras['display_page_layout'], 'plain', false ); ?>
<input type="radio" value="plain" <?php echo checked( $bp->groups->current_group->args['extras']['display_page_layout'], 'plain', false ); ?>
name="group-extras-display-layout"> <?php _e( 'Plain (field title and its data below)', 'buddypress-groups-extras' ); ?><br/>
<input type="radio" value="profile" <?php echo checked( $bp->groups->current_group->extras['display_page_layout'], 'profile', false ); ?>
<input type="radio" value="profile" <?php echo checked( $bp->groups->current_group->args['extras']['display_page_layout'], 'profile', false ); ?>
name="group-extras-display-layout"> <?php _e( 'Profile style (in a table)', 'buddypress-groups-extras' ); ?>
</p>

Expand All @@ -33,9 +33,9 @@
<p>
<label
for="group_extras_display"><?php echo sprintf( __( 'Do you want to make <strong>"%s"</strong> page public (extra group pages will be displayed there)?', 'buddypress-groups-extras' ), $gpages_item_name ); ?></label>
<input type="radio" value="public" <?php echo checked( $bp->groups->current_group->extras['display_gpages'], 'public', false ); ?>
<input type="radio" value="public" <?php echo checked( $bp->groups->current_group->args['extras']['display_gpages'], 'public', false ); ?>
name="group-gpages-display"> <?php _e( 'Show it', 'buddypress-groups-extras' ); ?><br/>
<input type="radio" value="private" <?php echo checked( $bp->groups->current_group->extras['display_gpages'], 'private', false ); ?>
<input type="radio" value="private" <?php echo checked( $bp->groups->current_group->args['extras']['display_gpages'], 'private', false ); ?>
name="group-gpages-display"> <?php _e( 'Hide it', 'buddypress-groups-extras' ); ?>
</p>

Expand Down

0 comments on commit 1415c65

Please sign in to comment.