-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgears-engine.php
212 lines (152 loc) · 5.8 KB
/
gears-engine.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
<?php
/**
* Gears
*
* @since 1.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Gears' ) )
{
class Gears {
/**
* initialize plugin modules, admin styles, and buddypress setup
*/
function __construct() {
// modules
add_action('init', array( $this,'load_modules'));
// front-end stylesheet
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
// admin stylesheets
add_action('admin_init', array( $this, 'admin_styles' ));
// BuddyPress config
add_action('bp_init', array($this, 'bp_setup'), 0);
// Loads the Gears Widgets.
$this->load_widgets_instance();
return;
}
/**
* Loads the stylehsheet
*/
public function enqueue_scripts()
{
wp_enqueue_style( 'gears-stylesheet', plugins_url('assets/style.css', __FILE__), array(), 1 );
wp_enqueue_script( 'gears-vendor-js', plugins_url('assets/vendor.js', __FILE__), array(), '1.0', true );
return $this;
}
/**
* Includes all the files needed to kick-start the modules
*/
public function load_modules() {
// Cover Photo Module
$coverphoto_module = apply_filters('gears_cover_photo', '__return_true', 10, 1);
// Facebook Connect Module
$facebook_connect_module = apply_filters( 'gears_is_fb_enabled',
$this->ot_theme_option( 'is_fb_enabled' ) );
// Google Connect Module
$google_connect_module = apply_filters( 'gears_is_g+_enabled', '__return_true', 10, 1);
// Testimonial Module
$testimonial_module = apply_filters( 'gears_testimonial_enabled', '__return_false', 10, 1 );
// Portfolio Module
$portfolio_module = apply_filters( 'gears_portfolio_enabled', '__return_false', 10, 1 );
// Load bp cover photo
if ( $coverphoto_module ) {
require_once GEARS_APP_PATH . '/modules/bp-cover-photo/index.php';
}
// Load bp cover photo
if ( true === $testimonial_module ) {
require_once GEARS_APP_PATH . '/modules/testimonials/testimonials.php';
}
// Load Gears Portfolio
if ( true === $portfolio_module ) {
require_once GEARS_APP_PATH . '/modules/portfolio/portfolio.php';
}
if ( $google_connect_module ) {
// load google plus connect
require_once GEARS_APP_PATH . '/modules/google-login/index.php';
// Google+ Connect
if ( ! is_user_logged_in() && get_option( 'users_can_register' ) ) {
if ( function_exists( 'curl_version' ) ) {
$google_connect = new GearsGooglePlusConnect();
} else {
add_action( 'gears_login_form', array( $this, 'curl_not_installed' ) );
}
}
}
// Load login form shortcode
require_once GEARS_APP_PATH . '/modules/login-form/login-form.php';
// load the shortcodes
require_once GEARS_APP_PATH . '/modules/shortcodes/library.php'; new Gears_Shortcodes();
if( ! is_user_logged_in() && $facebook_connect_module && get_option('users_can_register') ) {
// if facebook login is enabled
// require the essential plugin
// we need to check if there is curl installed/activated in the server
// added in 2.1.0
if ( function_exists('curl_version') ) {
require_once GEARS_APP_PATH . '/modules/facebook-login/index.php';
$app_id = apply_filters( 'gears_fb_app_id', $this->ot_theme_option( 'application_id', '' ) );
$app_secret = apply_filters( 'gears_fb_app_secret', $this->ot_theme_option( 'application_secret', '' ) );
$registrant_settings = apply_filters( 'gears_register_settings', $this->ot_theme_option( 'registrant_setting', 'not_unique' ) );
$button_label = apply_filters ( 'gears_button_label', $this->ot_theme_option( 'gears_fb_btn_label' , __('Connect w/ Facebook','gears') ) );
new GearsModulesFacebookLogin(
$app_id,
$app_secret,
$registrant_settings,
$button_label
);
} else {
add_action( 'gears_login_form', array( $this, 'curl_not_installed' ) );
}
}
// Login Modal
$is_ce_module_login_modal = true;
}
public function curl_not_installed() {
?>
<div class="gears-alert gears-alert-danger gears-clearfix">
<?php esc_html_e( 'PHP Curl Extention must be enabled for Social Connect to work properly', 'gears'); ?>
</div>
<?php
}
/**
* admin styling
*/
public function admin_styles(){
//register our admin stylesheet
wp_register_style( 'gears-admin-css', plugins_url('assets/admin.css', __FILE__) );
wp_enqueue_style( 'gears-admin-css' );
}
/**
* option tree helper method
*/
public function ot_theme_option( $option_id, $default = '' ){
// get the saved options
$options = get_option( 'option_tree' );
// look for the saved value
if ( isset( $options[$option_id] ) && '' != $options[$option_id] ) {
return $options[$option_id];
}
return $default;
}
/**
* buddypress configs
*/
function bp_setup(){
// define avatar thumbnail width and height
// define buddypress contants
// that are used in Gears to avoid notices
if (!defined('BP_AVATAR_FULL_HEIGHT')){ DEFINE( 'BP_AVATAR_THUMB_WIDTH', 100 ); }
if (!defined('BP_AVATAR_THUMB_HEIGHT')){ DEFINE( 'BP_AVATAR_THUMB_HEIGHT', 100 ); }
if (!defined('BP_AVATAR_FULL_WIDTH')){ DEFINE( 'BP_AVATAR_FULL_WIDTH', 325 ); }
if (!defined('BP_AVATAR_FULL_HEIGHT')){ DEFINE( 'BP_AVATAR_FULL_HEIGHT', 325 ); }
if (!defined('BP_AVATAR_ORIGINAL_MAX_WIDTH')){ DEFINE( 'BP_AVATAR_ORIGINAL_MAX_WIDTH', 1000 ); }
if (!defined('BP_AVATAR_ORIGINAL_MAX_HEIGHT')){ DEFINE( 'BP_AVATAR_ORIGINAL_MAX_HEIGHT', 1000 ); }
return;
}
function load_widgets_instance() {
require_once GEARS_APP_PATH . '/modules/widgets/widgets.php';
return;
}
}
}
?>