Initial commit for feedback bar
This commit is contained in:
parent
4ea4c0298b
commit
a9b5c8917d
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Beta Tester Admin Menus class
|
||||||
|
*
|
||||||
|
* @package WC_Beta_Tester
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WC_Beta_Tester_Admin_Menus Main Class.
|
||||||
|
*/
|
||||||
|
class WC_Beta_Tester_Admin_Menus {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menus' ), 31 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the "Visit Store" link in admin bar main menu.
|
||||||
|
*
|
||||||
|
* @param WP_Admin_Bar $wp_admin_bar Admin bar instance.
|
||||||
|
*/
|
||||||
|
public function admin_bar_menus( $wp_admin_bar ) {
|
||||||
|
if ( ! is_admin() || ! is_user_logged_in() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show only when the user is a member of this site, or they're a super admin.
|
||||||
|
if ( ! is_user_member_of_blog() && ! is_super_admin() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the beta tester root node.
|
||||||
|
$wp_admin_bar->add_node( array(
|
||||||
|
'parent' => 0,
|
||||||
|
'id' => 'wc-beta-tester',
|
||||||
|
'title' => __( 'WC Beta Tester', 'woocommerce-beta-tester' ),
|
||||||
|
) );
|
||||||
|
|
||||||
|
// TODO: Retrieve this programmatically.
|
||||||
|
$current_channel = 'test';
|
||||||
|
|
||||||
|
$nodes = array(
|
||||||
|
array(
|
||||||
|
'parent' => 'wc-beta-tester',
|
||||||
|
'id' => 'current-channel',
|
||||||
|
'title' => sprintf( __( '<center><i>Current channel: %s</i></center>', 'woocommerce' ), $current_channel ),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'parent' => 'wc-beta-tester',
|
||||||
|
'id' => 'submit-gh-ticket',
|
||||||
|
'title' => __( 'Submit a bug ticket to GitHub', 'woocommerce' ),
|
||||||
|
'href' => admin_url( 'plugins.php' ),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'parent' => 'wc-beta-tester',
|
||||||
|
'id' => 'show-version-info',
|
||||||
|
'title' => __( 'Show version information', 'woocommerce' ),
|
||||||
|
'href' => admin_url( 'plugins.php' ),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'parent' => 'wc-beta-tester',
|
||||||
|
'id' => 'switch-version',
|
||||||
|
'title' => __( 'Switch Version', 'woocommerce' ),
|
||||||
|
'href' => admin_url( 'plugins.php' ),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'parent' => 'wc-beta-tester',
|
||||||
|
'id' => 'update-channel',
|
||||||
|
'title' => __( 'Update channel settings', 'woocommerce' ),
|
||||||
|
'href' => admin_url( 'plugins.php' ),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $nodes as $node ) {
|
||||||
|
$wp_admin_bar->add_node( $node );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new WC_Beta_Tester_Admin_Menus();
|
|
@ -60,6 +60,15 @@ class WC_Beta_Tester {
|
||||||
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'api_check' ) );
|
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'api_check' ) );
|
||||||
add_filter( 'plugins_api', array( $this, 'get_plugin_info' ), 10, 3 );
|
add_filter( 'plugins_api', array( $this, 'get_plugin_info' ), 10, 3 );
|
||||||
add_filter( 'upgrader_source_selection', array( $this, 'upgrader_source_selection' ), 10, 3 );
|
add_filter( 'upgrader_source_selection', array( $this, 'upgrader_source_selection' ), 10, 3 );
|
||||||
|
|
||||||
|
$this->includes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include any classes we need within admin.
|
||||||
|
*/
|
||||||
|
public function includes() {
|
||||||
|
include_once( dirname( __FILE__ ) . '/class-wc-beta-tester-admin-menus.php' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
* Requires at least: 4.4
|
* Requires at least: 4.4
|
||||||
* Tested up to: 4.9
|
* Tested up to: 4.9
|
||||||
*
|
*
|
||||||
|
* Text Domain: woocommerce-beta-tester
|
||||||
|
*
|
||||||
* @package WC_Beta_Tester
|
* @package WC_Beta_Tester
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue