Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	admin/views/main/html_admin_shop_tabs.php
#	class/core/wc4bp-redirect.php
#	class/wc4bp-manager.php
#	readme.txt
  • Loading branch information
gfirem committed Jul 6, 2018
2 parents fb349ef + 5b3e043 commit 2c9bbd4
Show file tree
Hide file tree
Showing 31 changed files with 841 additions and 569 deletions.
2 changes: 1 addition & 1 deletion admin/admin-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@ public function wc4bp_change_xprofile_allow_custom_visibility() {
WC4BP_Loader::get_exception_handler()->save_exception( $exception->getTrace() );
}
}
}
}
19 changes: 11 additions & 8 deletions admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public static function getSlug() {
*/
public function wc4bp_admin_menu() {
add_menu_page( __( 'WooCommerce for BuddyPress', 'wc4bp' ), __( 'WC4BP Settings', 'wc4bp' ), 'manage_options', self::getSlug(), array( $this, 'wc4bp_screen' ) );
/**
* SubMenu Page added
*/
do_action( 'wc4bp_add_submenu_page' );
}

Expand Down Expand Up @@ -270,7 +273,7 @@ public function wc4bp_overwrite_default_shop_home_tab() {
}

if ( WC4BP_Loader::getFreemius()->is_plan_or_trial__premium_only( wc4bp_base::$professional_plan_id ) ) {
$woo_my_account = WC4BP_MyAccount::get_active_endpoints__premium_only();
$woo_my_account = WC4BP_MyAccount::get_active_endpoints();
if ( ! empty( $woo_my_account ) ) {
foreach ( $woo_my_account as $active_page_key => $active_page_name ) {
$wc4bp_pages_options['selected_pages'][ $active_page_key ] = array(
Expand All @@ -281,17 +284,17 @@ public function wc4bp_overwrite_default_shop_home_tab() {
// Add the shop tab to the array
if ( empty( $wc4bp_options['tab_cart_disabled'] ) ) {
$wc4bp_pages_options['selected_pages']['cart'] = array(
'tab_name' => 'Cart',
'tab_name' => __('Cart', 'wc4bp'),
);
}
if ( empty( $wc4bp_options['tab_checkout_disabled'] ) ) {
$wc4bp_pages_options['selected_pages']['checkout'] = array(
'tab_name' => 'Checkout',
'tab_name' => __('Checkout', 'wc4bp'),
);
}
if ( empty( $wc4bp_options['tab_track_disabled'] ) ) {
$wc4bp_pages_options['selected_pages']['track'] = array(
'tab_name' => 'Track my order',
'tab_name' => __('Track my order', 'wc4bp'),
);
}
//If wc4bp['tab_shop_default'] is empty add a default value to avoid offset warning
Expand Down Expand Up @@ -344,7 +347,7 @@ public function get_pages_option() {
}

//Add the actives my account pages to the option array
$woo_my_account = WC4BP_MyAccount::get_active_endpoints__premium_only();
$woo_my_account = WC4BP_MyAccount::get_active_endpoints();
if ( ! empty( $woo_my_account ) ) {
foreach ( $woo_my_account as $active_page_key => $active_page_name ) {
$wc4bp_pages_options['selected_pages'][ $active_page_key ] = array(
Expand All @@ -355,17 +358,17 @@ public function get_pages_option() {
// Add the shop tabs to the array
if ( empty( $wc4bp_options['tab_cart_disabled'] ) ) {
$wc4bp_pages_options['selected_pages']['cart'] = array(
'tab_name' => 'Cart',
'tab_name' => __('Cart', 'wc4bp'),
);
}
if ( empty( $wc4bp_options['tab_checkout_disabled'] ) ) {
$wc4bp_pages_options['selected_pages']['checkout'] = array(
'tab_name' => 'Checkout',
'tab_name' => __('Checkout', 'wc4bp'),
);
}
if ( empty( $wc4bp_options['tab_track_disabled'] ) ) {
$wc4bp_pages_options['selected_pages']['track'] = array(
'tab_name' => 'Track my order',
'tab_name' => __('Track my order', 'wc4bp'),
);
}

Expand Down
2 changes: 1 addition & 1 deletion admin/views/main/html_admin_my_account_tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
$tab_select = $this->wc4bp_options[ 'wc4bp_endpoint_' . $end_point_key ];
}

$text = sprintf( 'Turn off %s tab.', $end_point_name );
$text = sprintf( __('Turn off %s tab.', 'wc4bp'), $end_point_name );
echo "<p " . $this->disable_class_tag( 'p' ) . "><label><input " . $this->disable_input_tag( 'checkbox' ) . " name='wc4bp_options[wc4bp_endpoint_" . $end_point_key . "]' type='checkbox' value='1' " . checked( $tab_select, 1, false ) . " /> <b>" . $text . "</b></label></p>";
}
2 changes: 1 addition & 1 deletion admin/views/main/html_admin_shop_tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<p <?php echo $this->disable_class_tag( 'p', wc4bp_base::$starter_plan_id ); ?>>
<label>
<input <?php echo $this->disable_input_tag( 'checkbox', wc4bp_base::$starter_plan_id ); ?> name='wc4bp_options[disable_woo_profile_override]' type='checkbox' value='1' <?php checked( $disable_woo_profile_override, 1 ); ?> />
<b><?php _e( 'Turn off \'Woocommerce User Profile \' override.', 'wc4bp' ); ?></b>&nbsp; <?php _e( 'This option is useful to stop Woocommerce override User Profile First Name, Last Name and Display Name.', 'wc4bp' ); ?>
<b><?php _e( 'Turn off \'WooCommerce User Profile \' override.', 'wc4bp' ); ?></b>&nbsp; <?php _e( 'This option is useful to stop WooCommerce override User Profile First Name, Last Name and Display Name.', 'wc4bp' ); ?>
</label>
</p>
<p <?php echo $this->disable_class_tag( 'p' ); ?>>
Expand Down
4 changes: 2 additions & 2 deletions admin/wc4bp-revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function ask_for_revision() {

public function revision_script( $hook ) {
try {
wp_enqueue_style( 'wc4bp_admin_revision_css', WC4BP_CSS . 'wc4bp-revision.css' );
wp_enqueue_script( 'wc4bp_admin_revision_js', WC4BP_JS . 'wc4bp-revision.js', array( 'jquery' ) );
wp_enqueue_style( 'wc4bp_admin_revision_css', wc4bp_Manager::assets_path('wc4bp-revision','css') );
wp_enqueue_script( 'wc4bp_admin_revision_js', wc4bp_Manager::assets_path( 'wc4bp-revision'), array( 'jquery' ) );
wp_localize_script( 'wc4bp_admin_revision_js', 'wc4bp_admin_revision_js', array(
'nonce' => wp_create_nonce( 'wc4bp_review_nonce' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
Expand Down
95 changes: 48 additions & 47 deletions class/core/wc4bp-component.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WC4BP_Component extends BP_Component {
public $template_directory;
private $wc4bp_pages_options;
private $wc4bp_options;

/**
* Start the shop component creation process
*
Expand All @@ -48,7 +48,7 @@ function __construct() {
add_action( 'bp_register_activity_actions', array( $this, 'register_activity_actions' ) );
add_filter( 'bp_located_template', array( $this, 'wc4bp_members_load_template_filter' ), 10, 2 );
}

/**
* Include files
*
Expand All @@ -75,14 +75,13 @@ function includes( $includes = array() ) {
}
new wc4bp_Sync();
new wc4bp_redirect();
}
catch ( Exception $exception ) {
} catch ( Exception $exception ) {
WC4BP_Loader::get_exception_handler()->save_exception( $exception->getTrace() );
}
}

/**
* Register acctivity actions
* Register activity actions
*
* @since 1.0.4
*/
Expand All @@ -93,19 +92,21 @@ function register_activity_actions() {
}
bp_activity_set_action( $this->id, 'new_shop_review', __( 'New review created', 'wc4bp' ) );
bp_activity_set_action( $this->id, 'new_shop_purchase', __( 'New purchase made', 'wc4bp' ) );
/**
* New activity register
*/
do_action( 'wc4bp_register_activity_actions' );
}
catch ( Exception $exception ) {
} catch ( Exception $exception ) {
WC4BP_Loader::get_exception_handler()->save_exception( $exception->getTrace() );
}
}

/**
* Setup globals
*
* @since 1.0
*
* @param array $globals
* @param array $globals
*
* @global object $bp
*/
Expand All @@ -118,16 +119,15 @@ function setup_globals( $globals = array() ) {
'has_directory' => false,
);
parent::setup_globals( $globals );
}
catch ( Exception $exception ) {
} catch ( Exception $exception ) {
WC4BP_Loader::get_exception_handler()->save_exception( $exception->getTrace() );
}
}

public function get_nav_item( $shop_link, $slug, $title, $screen_function = '' ) {
$id = str_replace( '-', '_', $slug );
$screen_function = empty( $screen_function ) ? 'wc4bp_screen_' . $id : $screen_function;

return array(
'name' => $title,
'slug' => $slug,
Expand All @@ -136,31 +136,28 @@ public function get_nav_item( $shop_link, $slug, $title, $screen_function = '' )
/**
* Filter the function used to process the screen.
*
* @param string $screen_function The function name to apply to the tab.
* @param integer $id The slug of the tab.
* @param string $screen_function The function name to apply to the tab.
* @param integer $id The slug of the tab.
*/
'screen_function' => apply_filters( 'wc4bp_screen_function', $screen_function, $id ),
'position' => 10,
'item_css_id' => 'shop-' . $id,
'user_has_access' => bp_is_my_profile(),
);
}

/**
* Setup BuddyBar navigation
*
* @since 1.0
*
* @param array $main_nav
* @param array $sub_nav
* @param array $main_nav
* @param array $sub_nav
*
* @global object $bp
*/
function setup_nav( $main_nav = array(), $sub_nav = array() ) {
try {
if ( ! function_exists( 'bp_get_settings_slug' ) ) {
return;
}
if ( ! empty( $this->wc4bp_options['tab_activity_disabled'] ) ) {
return;
}
Expand All @@ -175,7 +172,7 @@ function setup_nav( $main_nav = array(), $sub_nav = array() ) {
*
* @param String The current label.
*/
$name = apply_filters( 'bp_shop_link_label', wc4bp_Manager::get_shop_label() );
$name = apply_filters( 'bp_shop_link_label', wc4bp_Manager::get_shop_label() );
} else {
$name = __( 'Shop', 'wc4bp' );
}
Expand All @@ -189,11 +186,11 @@ function setup_nav( $main_nav = array(), $sub_nav = array() ) {
'show_for_displayed_user' => false,
);
$shop_link = trailingslashit( bp_loggedin_user_domain() . $this->slug );

$sub_nav = $this->get_endpoints( $sub_nav, $shop_link );

// Add shop settings sub page
if ( ! isset( $this->wc4bp_options['disable_shop_settings_tab'] ) ) {
if ( ! isset( $this->wc4bp_options['disable_shop_settings_tab'] ) && function_exists( 'bp_get_settings_slug' ) ) {
if ( WC4BP_Loader::getFreemius()->is_plan_or_trial__premium_only( wc4bp_base::$professional_plan_id ) ) {
/**
* Get the label for the BuddyPress Navigation inside the settings
Expand Down Expand Up @@ -234,14 +231,16 @@ function setup_nav( $main_nav = array(), $sub_nav = array() ) {
* @param string Unique slug for the component, for use in query strings and URLs.
*/
$sub_nav = apply_filters( 'bp_shop_sub_nav', $sub_nav, $shop_link, $this->slug );
/**
* The navigation of the plugin is ready for setup
*/
do_action( 'bp_shop_setup_nav' );
parent::setup_nav( $main_nav, $sub_nav );
}
catch ( Exception $exception ) {
} catch ( Exception $exception ) {
WC4BP_Loader::get_exception_handler()->save_exception( $exception->getTrace() );
}
}

public function get_admin_bar_item( $parent, $slug, $title ) {
$id = str_replace( '-', '_', $slug );
$result = array(
Expand All @@ -250,14 +249,14 @@ public function get_admin_bar_item( $parent, $slug, $title ) {
'title' => $title,
'href' => trailingslashit( $parent . $slug ),
);

return $result;
}

/**
* Set up the Toolbar
*
* @param array $wp_admin_nav
* @param array $wp_admin_nav
*
* @return bool|void
* @global BuddyPress $bp The one true BuddyPress instance
Expand All @@ -274,9 +273,9 @@ function setup_admin_bar( $wp_admin_nav = array() ) {
}
$wp_admin_nav = array();
if ( is_user_logged_in() ) {
$user_domain = bp_loggedin_user_domain();
$settings_link = trailingslashit( $user_domain . BP_SETTINGS_SLUG );
if ( ! isset( $this->wc4bp_options['disable_shop_settings_tab'] ) ) {
$user_domain = bp_loggedin_user_domain();
if ( ! isset( $this->wc4bp_options['disable_shop_settings_tab'] ) && function_exists( 'bp_get_settings_slug' ) ) {
$settings_link = trailingslashit( $user_domain . bp_get_settings_slug() );
if ( WC4BP_Loader::getFreemius()->is_plan_or_trial__premium_only( wc4bp_base::$professional_plan_id ) ) {
/**
* Get the label for the Setting inside BP
Expand Down Expand Up @@ -329,12 +328,11 @@ function setup_admin_bar( $wp_admin_nav = array() ) {
}
parent::setup_admin_bar( $wp_admin_nav );
}
}
catch ( Exception $exception ) {
} catch ( Exception $exception ) {
WC4BP_Loader::get_exception_handler()->save_exception( $exception->getTrace() );
}
}

/**
* WC4BP template loader.
* @since 1.0
Expand All @@ -350,7 +348,7 @@ function wc4bp_members_load_template_filter( $found_template, $templates ) {
if ( ! bp_is_current_component( wc4bp_Manager::get_shop_slug() ) ) {
return $found_template;
}
$path = 'shop/member/plugin';
$path = 'shop/member/plugin';
/**
* Filter the path to the directory of the templates.
*
Expand Down Expand Up @@ -407,20 +405,22 @@ function wc4bp_members_load_template_filter( $found_template, $templates ) {
$path = $this->get_endpoint_path( $bp->current_action );
}
add_action( 'bp_template_content',
create_function( '', "bp_get_template_part( '" . $path . "' );" )
function () use ( $path ) {
bp_get_template_part( $path );
}
);

/**
* Filter the founded template.
*
* @param string The template filename.
*/
return apply_filters( 'wc4bp_members_load_template_filter_founded', $found_template );
}
catch ( Exception $exception ) {
} catch ( Exception $exception ) {
WC4BP_Loader::get_exception_handler()->save_exception( $exception->getTrace() );
}
}

public function get_endpoint_path( $endpoint ) {
global $bp;
switch ( $endpoint ) {
Expand Down Expand Up @@ -461,17 +461,18 @@ public function get_endpoint_path( $endpoint ) {
default:
$path = 'shop/member/plugin';
break;

}

/**
* Filter the template path.
*
* @param string $path The path route used to match one tab.
* @param string $path The path route used to match one tab.
* @param string The path to the template directory. Get more info in /wc4bp-premium/class/core/wc4bp-component.php:355
*/
return apply_filters( 'wc4bp_load_template_path', $path, $this->template_directory );
}

/**
* Get the WC4BP template directory
*
Expand All @@ -484,7 +485,7 @@ public function get_endpoint_path( $endpoint ) {
public function wc4bp_members_get_template_directory() {
return $this->template_directory;
}

/**
* @param $sub_nav
* @param $parent
Expand Down Expand Up @@ -529,7 +530,7 @@ public function get_endpoints( $sub_nav, $parent, $is_tabs = true ) {
}
}
}

return $sub_nav;
}
}
Loading

0 comments on commit 2c9bbd4

Please sign in to comment.