-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwoocommerce-book-chapter-tab.php
83 lines (63 loc) · 2.68 KB
/
woocommerce-book-chapter-tab.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
<?php
/*
* Plugin Name: E-Commerce Book Chapter Tab
* Plugin URI: https://code.recuweb.com/download/woocommerce-book-chapter-tab/
* Description: Extends WC to allow you to display the Chapters and Sections of a book, ebook or documentation in a new tab on the single product page.
* Version: 3.0.8
* Author: Rafasashi
* Author URI: https://code.recuweb.com/about-us/
* Requires at least: 4.6
* Tested up to: 6.1.1
*
* Text Domain: wc_book_chapter
* Domain Path: /lang/
*
* Copyright: © 2018 Recuweb.
* License: GNU General Public License v3.0
* License URI: https://code.recuweb.com/product-licenses/
*/
if(!defined('ABSPATH')) exit; // Exit if accessed directly
/**
* Minimum version required
*
*/
if ( get_bloginfo('version') < 3.3 ) return;
// Load plugin class files
require_once( 'includes/class-ecommerce-book-chapter-tab.php' );
require_once( 'includes/class-ecommerce-book-chapter-tab-settings.php' );
// Load plugin libraries
require_once( 'includes/lib/class-ecommerce-book-chapter-tab-admin-api.php' );
require_once( 'includes/lib/class-ecommerce-book-chapter-tab-admin-notices.php' );
require_once( 'includes/lib/class-ecommerce-book-chapter-tab-post-type.php' );
require_once( 'includes/lib/class-ecommerce-book-chapter-tab-taxonomy.php' );
/**
* Returns the main instance of ECommerce_Book_Chapter_Tab to prevent the need to use globals.
*
* @since 1.0.0
* @return object ECommerce_Book_Chapter_Tab
*/
function ECommerce_Book_Chapter_Tab() {
$instance = ECommerce_Book_Chapter_Tab::instance( __FILE__, '1.0.7' );
if ( is_null( $instance->notices ) ) {
$instance->notices = ECommerce_Book_Chapter_Tab_Admin_Notices::instance( $instance );
}
if ( is_null( $instance->settings ) ) {
$instance->settings = ECommerce_Book_Chapter_Tab_Settings::instance( $instance );
}
return $instance;
}
// Checks if the ECommerce plugins is installed and active.
$plugins = apply_filters('active_plugins', get_option('active_plugins'));
if(in_array('woocommerce/woocommerce.php', $plugins)){
if(!in_array('woo-book-chapter-tab-premium/ecommerce-book-chapter-tab-premium.php', $plugins)){
ECommerce_Book_Chapter_Tab();
}
}
else{
add_action('admin_notices', function(){
global $current_screen;
if($current_screen->parent_base == 'plugins'){
echo '<div class="error"><p>Book Chapter Tab '.__('requires <a href="http://www.woothemes.com/woocommerce/" target="_blank">ECommerce</a> to be activated in order to work. Please install and activate <a href="'.admin_url('plugin-install.php?tab=search&type=term&s=ECommerce').'" target="_blank">ECommerce</a> first.', 'wc_book_chapter').'</p></div>';
}
});
}