-
Notifications
You must be signed in to change notification settings - Fork 24
/
woocommerce-external-product-embed.php
116 lines (93 loc) · 3.2 KB
/
woocommerce-external-product-embed.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/**
* Plugin Name: WooCommerce External Product Embed
* Plugin URI: http://calebburks.com/plugins
* Description: Provides a shortcode to embed products from another store.
* Version: 3.0.0
* Author: Caleb Burks
* Author URI: http://calebburks.com
* Copyright: (c) 2017 Caleb Burks
* License: GPL v3 or later
* License URI: http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
* Text Domain: woocommerce-external-product-embed
* Domain Path: /languages/
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Woocommerce_External_Product_Embed' ) ) :
class Woocommerce_External_Product_Embed {
/**
* Plugin version, used for styles/scripts.
*/
public $version = '3.0.0';
/**
* The single instance of the class.
*/
protected static $_instance = null;
/**
* Ensures only one instance of this class is loaded or can be loaded.
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct() {
// Load Text Domain
add_action( 'init', array( $this, 'load_text_domain' ) );
// Add plugin action links
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
// Autoloader for the external "WooCommerce API - PHP Client".
include_once( __DIR__ . '/vendor/autoload.php' );
// Frontend Only
if ( ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ) ) {
// Register Styles
add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) );
// Shortcodes Class
include_once( dirname( __FILE__ ) . '/classes/class-wcepe-shortcodes.php' );
add_action( 'init', array( 'WCEPE_Shortcodes', 'init' ) );
// Deprecated Class - Backwards Compatability
include_once( dirname( __FILE__ ) . '/classes/class-wcepe-deprecated.php' );
add_action( 'init', array( 'WCEPE_Deprecated', 'init' ) );
}
// Load Admin
include_once( dirname( __FILE__ ) . '/classes/class-wcepe-admin.php' );
add_action( 'init', array( 'WCEPE_Admin', 'init' ) );
do_action( 'wcepe_loaded' );
}
/**
* Load Text Domain
*/
public function load_text_domain() {
load_plugin_textdomain( 'woocommerce-external-product-embed', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
/**
* Show action links on the plugin screen.
*/
public function plugin_action_links( $links ) {
$action_links = array(
'settings' => '<a href="' . admin_url( 'options-general.php?page=wc_external_product_embed' ) . '" aria-label="' . esc_attr( __( 'View settings', 'woocommerce-external-product-embed' ) ) . '">' . __( 'Settings', 'woocommerce-external-product-embed' ) . '</a>',
);
return array_merge( $action_links, $links );
}
/**
* Register the stylesheet
*/
public function register_styles() {
wp_register_style( 'wcepe-styles', plugins_url( 'assets/styles/styles.css', plugin_basename( __FILE__ ) ) );
}
}
endif;
/**
* Main instance of Woocommerce_External_Product_Embed.
*
* Returns the main instance of this class to prevent the need to use globals.
*/
function WCEPE() {
return Woocommerce_External_Product_Embed::instance();
}
// Run this thing.
WCEPE();