plugin = 'woocommerce/woocommerce.php';
add_action( 'admin_menu', array( $this, 'admin_menus') );
add_action( 'admin_head', array( $this, 'admin_head' ) );
add_action( 'admin_init', array( $this, 'welcome' ) );
}
/**
* Add admin menus/screens
*
* @access public
* @return void
*/
public function admin_menus() {
$welcome_page_title = __( 'Welcome to WooCommerce', 'woocommerce' );
// About
$about = add_dashboard_page( $welcome_page_title, $welcome_page_title, 'manage_options', 'wc-about', array( $this, 'about_screen' ) );
// Credits
$credits = add_dashboard_page( $welcome_page_title, $welcome_page_title, 'manage_options', 'wc-credits', array( $this, 'credits_screen' ) );
add_action( 'admin_print_styles-'. $about, array( $this, 'admin_css' ) );
add_action( 'admin_print_styles-'. $credits, array( $this, 'admin_css' ) );
}
/**
* admin_css function.
*
* @access public
* @return void
*/
public function admin_css() {
wp_enqueue_style( 'woocommerce-activation', plugins_url( '/assets/css/activation.css', dirname( dirname( __FILE__ ) ) ) );
}
/**
* Add styles just for this page, and remove dashboard page links.
*
* @access public
* @return void
*/
public function admin_head() {
global $woocommerce;
remove_submenu_page( 'index.php', 'wc-about' );
remove_submenu_page( 'index.php', 'wc-credits' );
// Badge for welcome page
$badge_url = $woocommerce->plugin_url() . '/assets/images/welcome/wc-badge.png';
?>
version, 0, 3 );
?>
version ); ?>
intro(); ?>
get_product() function.', 'woocommerce' ); ?>
WC-API now has real endpoints, and we\'ve optimised the gateways API significantly by only loading gateways when needed.', 'woocommerce' ); ?>
intro(); ?>
Contribute to WooCommerce.', 'woocommerce' ); ?>
contributors(); ?>
get_contributors();
if ( empty( $contributors ) )
return '';
$contributor_list = '';
return $contributor_list;
}
/**
* Retreive list of contributors from GitHub.
*
* @access public
* @return void
*/
public function get_contributors() {
$contributors = get_transient( 'woocommerce_contributors' );
if ( false !== $contributors )
return $contributors;
$response = wp_remote_get( 'https://api.github.com/repos/woothemes/woocommerce/contributors', array( 'sslverify' => false ) );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
return array();
$contributors = json_decode( wp_remote_retrieve_body( $response ) );
if ( ! is_array( $contributors ) )
return array();
set_transient( 'woocommerce_contributors', $contributors, 3600 );
return $contributors;
}
/**
* Sends user to the welcome page on first activation
*/
public function welcome() {
// Bail if no activation redirect transient is set
if ( ! get_transient( '_wc_activation_redirect' ) )
return;
// Delete the redirect transient
delete_transient( '_wc_activation_redirect' );
// Bail if we are waiting to install or update via the interface update/install links
if ( get_option( '_wc_needs_update' ) == 1 || get_option( '_wc_needs_pages' ) == 1 )
return;
// Bail if activating from network, or bulk, or within an iFrame
if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) )
return;
if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] ) && ( isset( $_GET['plugin'] ) && strstr( $_GET['plugin'], 'woocommerce.php' ) ) )
return;
wp_safe_redirect( admin_url( 'index.php?page=wc-about' ) );
exit;
}
}
new WC_Admin_Welcome();