PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.5
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.5
8.0.5 8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 All 47 releases
← All changes | integrations/woocommerce/woocommerce.php +164 -0 7.9.3 → 8.0.5 View file →
@@ -1,0 +1,164 @@
1 +<?php
2 +/**
3 + * Plugin Name: GamiPress - WooCommerce integration
4 + * Plugin URI: https://wordpress.org/plugins/gamipress-woocommerce-integration/
5 + * Description: Connect GamiPress with WooCommerce.
6 + * Version: 1.4.3
7 + * Author: GamiPress
8 + * Author URI: https://gamipress.com/
9 + * Text Domain: gamipress-woocommerce-integration
10 + * Domain Path: /languages/
11 + * Requires at least: 4.4
12 + * Tested up to: 7.0
13 + * WC requires at least: 3.0
14 + * WC tested up to: 7.4
15 + * License: GNU AGPL v3.0 (http://www.gnu.org/licenses/agpl.txt)
16 + *
17 + * @package GamiPress\WooCommerce
18 + * @author GamiPress
19 + * @copyright Copyright (c) GamiPress
20 + */
21 +
22 +final class GamiPress_Integration_WooCommerce {
23 +
24 + /**
25 + * @var GamiPress_Integration_WooCommerce $instance The one true GamiPress_Integration_WooCommerce
26 + * @since 1.0.0
27 + */
28 + private static $instance;
29 +
30 + /**
31 + * Get active instance
32 + *
33 + * @access public
34 + * @since 1.0.0
35 + * @return GamiPress_Integration_WooCommerce self::$instance The one true GamiPress_Integration_WooCommerce
36 + */
37 + public static function instance() {
38 + if( !self::$instance ) {
39 + self::$instance = new GamiPress_Integration_WooCommerce();
40 + self::$instance->constants();
41 + self::$instance->includes();
42 + self::$instance->hooks();
43 +
44 + }
45 +
46 + return self::$instance;
47 + }
48 +
49 + /**
50 + * Setup plugin constants
51 + *
52 + * @access private
53 + * @since 1.0.0
54 + * @return void
55 + */
56 + private function constants() {
57 + // Plugin version
58 + define( 'GAMIPRESS_WC_VER', '1.4.3' );
59 +
60 + // Plugin path
61 + define( 'GAMIPRESS_WC_DIR', plugin_dir_path( __FILE__ ) );
62 +
63 + // Plugin URL
64 + define( 'GAMIPRESS_WC_URL', plugin_dir_url( __FILE__ ) );
65 + }
66 +
67 + /**
68 + * Include plugin files
69 + *
70 + * @access private
71 + * @since 1.0.0
72 + * @return void
73 + */
74 + private function includes() {
75 +
76 + if( $this->meets_requirements() ) {
77 +
78 + require_once GAMIPRESS_WC_DIR . 'includes/admin.php';
79 + require_once GAMIPRESS_WC_DIR . 'includes/ajax-functions.php';
80 + require_once GAMIPRESS_WC_DIR . 'includes/functions.php';
81 + require_once GAMIPRESS_WC_DIR . 'includes/listeners.php';
82 + require_once GAMIPRESS_WC_DIR . 'includes/requirements.php';
83 + require_once GAMIPRESS_WC_DIR . 'includes/rules-engine.php';
84 + require_once GAMIPRESS_WC_DIR . 'includes/triggers.php';
85 + require_once GAMIPRESS_WC_DIR . 'includes/scripts.php';
86 +
87 + }
88 + }
89 +
90 + /**
91 + * Setup plugin hooks
92 + *
93 + * @access private
94 + * @since 1.0.0
95 + * @return void
96 + */
97 + private function hooks() {
98 + // Setup our activation and deactivation hooks
99 + register_activation_hook( __FILE__, array( $this, 'activate' ) );
100 + register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
101 +
102 +
103 + }
104 +
105 + /**
106 + * Activation hook for the plugin.
107 + *
108 + * @since 1.0.0
109 + */
110 + function activate() {
111 +
112 + if( $this->meets_requirements() ) {
113 +
114 + }
115 +
116 + }
117 +
118 + /**
119 + * Deactivation hook for the plugin.
120 + *
121 + * @since 1.0.0
122 + */
123 + function deactivate() {
124 +
125 + }
126 +
127 + /**
128 + * Check if there are all plugin requirements
129 + *
130 + * @since 1.0.0
131 + *
132 + * @return bool True if installation meets all requirements
133 + */
134 + private function meets_requirements() {
135 +
136 + if ( ! class_exists( 'GamiPress' ) )
137 + return false;
138 +
139 + // Requirements on multisite install
140 + if( is_multisite() && is_main_site() && function_exists('gamipress_is_network_wide_active') && gamipress_is_network_wide_active() ) {
141 + // On main site, need to check if integrated plugin is installed on any sub site to load all configuration files
142 + if( gamipress_is_plugin_active_on_network( 'woocommerce/woocommerce.php' ) )
143 + return true;
144 + }
145 +
146 + if ( ! class_exists( 'WooCommerce' ) )
147 + return false;
148 +
149 + return true;
150 +
151 + }
152 +
153 +}
154 +
155 +/**
156 + * The main function responsible for returning the one true GamiPress_Integration_WooCommerce instance to functions everywhere
157 + *
158 + * @since 1.0.0
159 + * @return \GamiPress_Integration_WooCommerce The one true GamiPress_Integration_WooCommerce
160 + */
161 +function GamiPress_WC() {
162 + return GamiPress_Integration_WooCommerce::instance();
163 +}
164 +add_action( 'gamipress_pre_init', 'GamiPress_WC' );