Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[WordPress] WooCommerce Menu, Part 2: A WooCommerce Page
<?php
public function __construct() {
$this->plugins_dir = trailingslashit( dirname( plugin_dir_path( dirname( __FILE__ ) ) ) );
$this->woocommerce_dir = trailingslashit( $this->plugins_dir . 'woocommerce' );
$this->woo_template_dir = trailingslashit( $this->woocommerce_dir ) . 'templates/myaccount/acme.php';
$this->woo_template = $this->woocommerce_dir . 'acme.php';
$this->template_path = '';
}
<?php
private function woocommerce_exists() {
return (
file_exists( $this->woocommerce_dir ) &&
is_writable( $this->woocommerce_dir )
);
}
<?php
public function move_template() {
if ( ! $this->woocommerce_exists() ) {
// Throw an exception or display a custom message to the user.
return;
}
$this->template_path = trailingslashit( dirname( dirname( ( __FILE__ ) ) ) ) . 'storefront/views/videos.php';
if ( ! copy( $this->template_path, $this->woo_template_dir ) ) {
// Throw an exception or display a custom message to the user.
}
$this->flush_rules();
}
<?php
public function endpoint_content() {
include_once $this->template_locator->get_template_path();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.