-
Notifications
You must be signed in to change notification settings - Fork 3
/
ocean-demo-import.php
230 lines (202 loc) · 5.61 KB
/
ocean-demo-import.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
/**
* Plugin Name: Ocean Demo Import
* Plugin URI: https://oceanwp.org/extension/ocean-demo-import/
* Description: Import the OceanWP demo content, widgets and customizer settings with one click.
* Version: 1.0.11
* Author: OceanWP
* Author URI: https://oceanwp.org/
* Requires at least: 4.0.0
* Tested up to: 5.2
*
* Text Domain: ocean-demo-import
* Domain Path: /languages/
*
* @package Ocean_Demo_Import
* @category Core
* @author OceanWP
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Returns the main instance of Ocean_Demo_Import to prevent the need to use globals.
*
* @since 1.0.0
* @return object Ocean_Demo_Import
*/
function Ocean_Demo_Import() {
return Ocean_Demo_Import::instance();
} // End Ocean_Demo_Import()
Ocean_Demo_Import();
/**
* Main Ocean_Demo_Import Class
*
* @class Ocean_Demo_Import
* @version 1.0.0
* @since 1.0.0
* @package Ocean_Demo_Import
*/
final class Ocean_Demo_Import {
/**
* Ocean_Demo_Import The single instance of Ocean_Demo_Import.
* @var object
* @access private
* @since 1.0.0
*/
private static $_instance = null;
/**
* The token.
* @var string
* @access public
* @since 1.0.0
*/
public $token;
/**
* The version number.
* @var string
* @access public
* @since 1.0.0
*/
public $version;
// Admin - Start
/**
* The admin object.
* @var object
* @access public
* @since 1.0.0
*/
public $admin;
/**
* Constructor function.
* @access public
* @since 1.0.0
* @return void
*/
public function __construct( $widget_areas = array() ) {
$this->token = 'ocean-demo-import';
$this->plugin_url = plugin_dir_url( __FILE__ );
$this->plugin_path = plugin_dir_path( __FILE__ );
$this->version = '1.0.11';
define( 'ODI_PATH', $this->plugin_path );
define( 'ODI_URL', $this->plugin_url );
register_activation_hook( __FILE__, array( $this, 'install' ) );
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
add_action( 'admin_notices', array( $this, 'admin_notice' ) );
}
/**
* Main Ocean_Demo_Import Instance
*
* Ensures only one instance of Ocean_Demo_Import is loaded or can be loaded.
*
* @since 1.0.0
* @static
* @see Ocean_Demo_Import()
* @return Main Ocean_Demo_Import instance
*/
public static function instance() {
if ( is_null( self::$_instance ) )
self::$_instance = new self();
return self::$_instance;
} // End instance()
/**
* Load the localisation file.
* @access public
* @since 1.0.0
* @return void
*/
public function load_plugin_textdomain() {
load_plugin_textdomain( 'ocean-demo-import', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Cloning is forbidden.
*
* @since 1.0.0
*/
public function __clone() {
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?' ), '1.0.0' );
}
/**
* Unserializing instances of this class is forbidden.
*
* @since 1.0.0
*/
public function __wakeup() {
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?' ), '1.0.0' );
}
/**
* Installation.
* Runs on activation. Logs the version number and assigns a notice message to a WordPress option.
* @access public
* @since 1.0.0
* @return void
*/
public function install() {
$this->_log_version_number();
}
/**
* Log the plugin version number.
* @access private
* @since 1.0.0
* @return void
*/
private function _log_version_number() {
// Log the version number.
update_option( $this->token . '-version', $this->version );
}
/**
* Display admin notice
*
* @since 1.2.6
*/
public static function admin_notice() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
} ?>
<div class="notice notice-warning">
<p><?php echo esc_html__( 'All free demos have been incorporated to the latest version of the Ocean Extra plugin, so the Ocean Demo Import plugin can be removed from your website.', 'ocean-extra' ); ?></p>
</div>
<?php
}
} // End Class
#--------------------------------------------------------------------------------
#region Freemius
#--------------------------------------------------------------------------------
if ( ! function_exists( 'ocean_demo_import_fs' ) ) {
// Create a helper function for easy SDK access.
function ocean_demo_import_fs() {
global $ocean_demo_import_fs;
if ( ! isset( $ocean_demo_import_fs ) ) {
$ocean_demo_import_fs = OceanWP_EDD_Addon_Migration::instance( 'ocean_demo_import_fs' )->init_sdk( array(
'id' => '3811',
'slug' => 'ocean-demo-import',
'public_key' => 'pk_28285e0f391b4955f4460589da147',
'is_premium' => false,
'is_premium_only' => false,
'has_paid_plans' => false,
) );
}
return $ocean_demo_import_fs;
}
function ocean_demo_import_fs_addon_init() {
if ( class_exists( 'Ocean_Extra' ) ) {
OceanWP_EDD_Addon_Migration::instance( 'ocean_demo_import_fs' )->init();
}
}
if ( 0 == did_action( 'owp_fs_loaded' ) ) {
// Init add-on only after parent theme was loaded.
add_action( 'owp_fs_loaded', 'ocean_demo_import_fs_addon_init', 15 );
} else {
if ( class_exists( 'Ocean_Extra' ) ) {
/**
* This makes sure that if the theme was already loaded
* before the plugin, it will run Freemius right away.
*
* This is crucial for the plugin's activation hook.
*/
ocean_demo_import_fs_addon_init();
}
}
}
#endregion