-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkebo-so.php
220 lines (160 loc) · 6.4 KB
/
kebo-so.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
<?php
/*
* Plugin Name: Kebo Social
* Plugin URI: http://kebopowered.com/plugins/kebo-social/
* Description: User-friendly and Business focused social integration. Improve your business by leveraging social media.
* Version: 0.1.0
* Author: Kebo
* Author URI: http://kebopowered.com
* Text Domain: kbso
* Domain Path: languages
*/
// Block direct access
if ( ! defined( 'ABSPATH' ) )
die( 'Sorry, no direct access.' );
define( 'KBSO_VERSION', '0.1.0' );
define( 'KBSO_URL', plugin_dir_url(__FILE__) );
define( 'KBSO_PATH', plugin_dir_path(__FILE__) );
define( 'KBSO_API_URL', 'http://auth.kebopowered.com/request/request.php' );
/*
* Load textdomain early, as we need it for the PHP version check.
*/
function kbso_load_textdomain() {
load_plugin_textdomain( 'kbso', false, KBSO_PATH . '/languages' );
}
add_filter( 'wp_loaded', 'kbso_load_textdomain' );
/*
* Check for the required version of PHP
*/
if ( version_compare( PHP_VERSION, '5.2', '<' ) ) {
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
deactivate_plugins(__FILE__);
wp_die( __( 'Kebo Social requires PHP 5.2 or higher, as does WordPress 3.2 and higher.', 'kbso' ) );
} else {
return;
}
}
/*
* Load Relevant Internal Files
*/
function kbso_plugin_setup() {
/*
* Include Options.
*/
require_once( KBSO_PATH . 'inc/options.php' );
/*
* Include Menu page.
*/
require_once( KBSO_PATH . 'inc/menu.php' );
/*
* Include oAuth Connection Functions.
*/
require_once( KBSO_PATH . 'inc/connections.php' );
/*
* Include AJAX Functions.
*/
require_once( KBSO_PATH . 'inc/ajax.php' );
/*
* Include Share Link Functions.
*/
require_once( KBSO_PATH . 'inc/sharelinks.php' );
/*
* Include Misc Functions.
*/
require_once( KBSO_PATH . 'inc/misc.php' );
/*
* Include all Classes
*/
foreach ( glob( KBSO_PATH . 'inc/classes/*.php' ) as $filename ) {
include_once( $filename );
}
/*
* Include all Widget files
*/
$widgets = array( 'twitter', 'facebook', 'linkedin', 'pinterest' );
foreach ( $widgets as $widget ) {
require_once( KBSO_PATH . 'inc/widgets/' . $widget . '.php' );
}
unset( $widgets );
}
add_action( 'plugins_loaded', 'kbso_plugin_setup', 15 );
if ( ! function_exists( 'kbso_register_files' ) ) :
/**
* Register plugin scripts and styles.
*/
function kbso_register_files() {
// Register Styles
wp_register_style( 'kbso-admin-css', KBSO_URL . 'assets/css/admin.css', array(), KBSO_VERSION, 'all' );
wp_register_style( 'kbso-widgets-css', KBSO_URL . 'assets/css/widgets.css', array(), KBSO_VERSION, 'all' );
wp_register_style( 'kbso-sharelinks-css', KBSO_URL . 'assets/css/sharelinks.css', array(), KBSO_VERSION, 'all' );
// Register Scripts
wp_register_script( 'kbso-admin-js', KBSO_URL . 'assets/js/admin.js', array(), KBSO_VERSION, true );
wp_register_script( 'kbso-flot-js', KBSO_URL . 'assets/js/vendor/jquery.flot.min.js', array('jquery'), KBSO_VERSION, false );
wp_register_script( 'kbso-flot-cats-js', KBSO_URL . 'assets/js/vendor/jquery.flot.categories.min.js', array('kbso-flot-js'), KBSO_VERSION, false );
wp_register_script( 'kbso-flot-resize-js', KBSO_URL . 'assets/js/vendor/jquery.flot.resize.min.js', array('kbso-flot-js'), KBSO_VERSION, false );
wp_register_script( 'kbso-flot-pie-js', KBSO_URL . 'assets/js/vendor/jquery.flot.pie.min.js', array('kbso-flot-js'), KBSO_VERSION, false );
}
add_action('wp_enqueue_scripts', 'kbso_register_files');
add_action('admin_enqueue_scripts', 'kbso_register_files');
endif;
/**
* Enqueue frontend plugin scripts and styles.
*/
function kbso_enqueue_frontend() {
// Register Styles
}
add_action('wp_enqueue_scripts', 'kbso_enqueue_frontend');
/**
* Enqueue backend plugin scripts and styles.
*/
function kbso_enqueue_backend( $hook_suffix ) {
// Enqueue on all pages
wp_enqueue_style( 'kbso-admin-css' );
// Enqueue files for dashboard page
if ( 'toplevel_page_kbso-dashboard' == $hook_suffix ) {
wp_enqueue_script( 'kbso-flot-js' );
wp_enqueue_script( 'kbso-flot-cats-js' );
wp_enqueue_script( 'kbso-flot-resize-js' );
wp_enqueue_script( 'kbso-flot-pie-js' );
wp_enqueue_script( 'jquery-ui-sortable' );
}
// Enqueue files for connections page
if ( 'kebo-social_page_kbso-connections' == $hook_suffix ) {
wp_enqueue_script( 'kbso-admin-js' );
}
// Enqueue files for sharing page
if ( 'kebo-social_page_kbso-sharing' == $hook_suffix ) {
wp_enqueue_script( 'jquery-ui-sortable' );
}
}
add_action( 'admin_enqueue_scripts', 'kbso_enqueue_backend' );
/**
* Add a link to the plugin screen, to allow users to jump straight to the settings page.
*/
function kbso_plugin_meta( $links ) {
$links[] = '<a href="' . admin_url( 'options-general.php?page=kebo-twitter' ) . '">' . __( 'Settings', 'kbso' ) . '</a>';
return $links;
}
add_filter( 'plugin_action_links_kebo-so/kebo-so.php', 'kbso_plugin_meta' );
/**
* Adds a WordPress Pointer to Kebo SE options page.
*/
function kbso_pointer_script_style() {
// Assume pointer shouldn't be shown
$enqueue_pointer_script_style = false;
// Get array list of dismissed pointers for current user and convert it to array
$dismissed_pointers = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
// Check if our pointer is not among dismissed ones
if ( ! in_array( 'kbso_settings_pointer', $dismissed_pointers ) ) {
$enqueue_pointer_script_style = true;
// Add footer scripts using callback function
add_action( 'admin_print_footer_scripts', 'kbso_pointer_script_style' );
}
// Enqueue pointer CSS and JS files, if needed
if ( $enqueue_pointer_script_style ) {
wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' );
}
}
add_action( 'admin_enqueue_scripts', 'kbso_pointer_script_style' );