This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmycred.php
785 lines (663 loc) · 22.8 KB
/
mycred.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
<?php
/**
* Plugin Name: myCRED
* Plugin URI: http://mycred.me
* Description: <strong>my</strong>CRED is an adaptive points management system for WordPress powered websites, giving you full control on how points are gained, used, traded, managed, logged or presented.
* Version: 1.5.1
* Tags: points, tokens, credit, management, reward, charge, buddypress, bbpress, jetpack, woocommerce, marketpress, wp e-commerce, gravity forms, simplepress
* Author: Gabriel S Merovingi
* Author URI: http://www.merovingi.com
* Author Email: [email protected]
* Requires at least: WP 3.8
* Tested up to: WP 4.0
* Text Domain: mycred
* Domain Path: /lang
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* SSL Compatible: yes
* bbPress Compatible: yes
* WordPress Compatible: yes
* BuddyPress Compatible: yes
* Forum URI: http://mycred.me/support/forums/
*/
define( 'myCRED_VERSION', '1.5.1' );
define( 'myCRED_SLUG', 'mycred' );
define( 'myCRED_NAME', '<strong>my</strong>CRED' );
define( 'myCRED_THIS', __FILE__ );
define( 'myCRED_ROOT_DIR', plugin_dir_path( myCRED_THIS ) );
define( 'myCRED_ABSTRACTS_DIR', myCRED_ROOT_DIR . 'abstracts/' );
define( 'myCRED_ADDONS_DIR', myCRED_ROOT_DIR . 'addons/' );
define( 'myCRED_ASSETS_DIR', myCRED_ROOT_DIR . 'assets/' );
define( 'myCRED_INCLUDES_DIR', myCRED_ROOT_DIR . 'includes/' );
define( 'myCRED_LANG_DIR', myCRED_ROOT_DIR . 'lang/' );
define( 'myCRED_MODULES_DIR', myCRED_ROOT_DIR . 'modules/' );
define( 'myCRED_PLUGINS_DIR', myCRED_ROOT_DIR . 'plugins/' );
require_once( myCRED_INCLUDES_DIR . 'mycred-functions.php' );
require_once( myCRED_INCLUDES_DIR . 'mycred-depreciated.php' );
require_once( myCRED_INCLUDES_DIR . 'mycred-about.php' );
require_once( myCRED_ABSTRACTS_DIR . 'mycred-abstract-hook.php' );
require_once( myCRED_ABSTRACTS_DIR . 'mycred-abstract-module.php' );
/**
* myCRED_Core Class
* Removed in 1.3 but defined since some customizations
* use this to check that myCRED exists or is installed.
* @since 1.3
* @version 1.0
*/
if ( ! class_exists( 'myCRED_Core' ) ) {
final class myCRED_Core {
/**
* Construct
*/
function __construct() {
_deprecated_function( __CLASS__, '1.3', 'mycred_load()' );
}
}
}
/**
* Required
* @since 1.3
* @version 1.1
*/
if ( ! function_exists( 'mycred_load' ) ) :
function mycred_load()
{
require_once( myCRED_INCLUDES_DIR . 'mycred-remote.php' );
require_once( myCRED_INCLUDES_DIR . 'mycred-log.php' );
require_once( myCRED_INCLUDES_DIR . 'mycred-network.php' );
require_once( myCRED_INCLUDES_DIR . 'mycred-protect.php' );
include_once( myCRED_INCLUDES_DIR . 'mycred-update.php' );
// Bail now if the setup needs to run
if ( is_mycred_ready() === false ) return;
require_once( myCRED_INCLUDES_DIR . 'mycred-leaderboard.php' );
require_once( myCRED_INCLUDES_DIR . 'mycred-widgets.php' );
// Add-ons
require_once( myCRED_MODULES_DIR . 'mycred-module-addons.php' );
$addons = new myCRED_Addons_Module();
$addons->load();
$addons->run_addons();
do_action( 'mycred_ready' );
add_action( 'plugins_loaded', 'mycred_plugin_start_up', 999 );
add_action( 'init', 'mycred_init', 5 );
add_action( 'widgets_init', 'mycred_widgets_init' );
add_action( 'admin_init', 'mycred_admin_init' );
add_action( 'mycred_reset_key', 'mycred_reset_key' );
register_activation_hook( myCRED_THIS, 'mycred_plugin_activation' );
register_deactivation_hook( myCRED_THIS, 'mycred_plugin_deactivation' );
register_uninstall_hook( myCRED_THIS, 'mycred_plugin_uninstall' );
add_action( 'in_plugin_update_message-mycred/mycred.php', 'mycred_update_warning' );
}
endif;
mycred_load();
/**
* Plugin Activation
* @since 1.3
* @version 1.0
*/
if ( ! function_exists( 'mycred_plugin_activation' ) ) :
function mycred_plugin_activation()
{
// Load Installer
require_once( myCRED_INCLUDES_DIR . 'mycred-install.php' );
$install = new myCRED_Install();
// Compatibility check
$install->compat();
// First time activation
if ( $install->ver === false )
$install->activate();
// Re-activation
else
$install->reactivate();
// Add Cron Schedule
if ( ! wp_next_scheduled( 'mycred_reset_key' ) ) {
$frequency = apply_filters( 'mycred_cron_reset_key', 'daily' );
wp_schedule_event( date_i18n( 'U' ), $frequency, 'mycred_reset_key' );
}
}
endif;
/**
* Runs when the plugin is deactivated
* @since 1.3
* @version 1.0
*/
if ( ! function_exists( 'mycred_plugin_deactivation' ) ) :
function mycred_plugin_deactivation()
{
// Clear Cron
wp_clear_scheduled_hook( 'mycred_reset_key' );
wp_clear_scheduled_hook( 'mycred_banking_recurring_payout' );
wp_clear_scheduled_hook( 'mycred_banking_interest_compound' );
wp_clear_scheduled_hook( 'mycred_banking_interest_payout' );
do_action( 'mycred_deactivation' );
}
endif;
/**
* Runs when the plugin is deleted
* @since 1.3
* @version 1.0
*/
if ( ! function_exists( 'mycred_plugin_uninstall' ) ) :
function mycred_plugin_uninstall()
{
// Load Installer
require_once( myCRED_INCLUDES_DIR . 'mycred-install.php' );
$install = new myCRED_Install();
do_action( 'mycred_before_deletion', $install );
// Run uninstaller
$install->uninstall();
do_action( 'mycred_after_deletion', $install );
unset( $install );
}
endif;
/**
* myCRED Plugin Startup
* @since 1.3
* @version 1.5
*/
if ( ! function_exists( 'mycred_plugin_start_up' ) ) :
function mycred_plugin_start_up()
{
global $mycred, $mycred_types, $mycred_modules;
$mycred = new myCRED_Settings();
$mycred_types = mycred_get_types();
require_once( myCRED_INCLUDES_DIR . 'mycred-shortcodes.php' );
// Load Translation
$locale = apply_filters( 'plugin_locale', get_locale(), 'mycred' );
load_textdomain( 'mycred', WP_LANG_DIR . "/mycred/mycred-$locale.mo" );
load_plugin_textdomain( 'mycred', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
// Adjust the plugin links
add_filter( 'plugin_action_links_mycred/mycred.php', 'mycred_plugin_links', 10, 4 );
add_filter( 'plugin_row_meta', 'mycred_plugin_description_links', 10, 2 );
// Lets start with Multisite
if ( is_multisite() ) {
if ( ! function_exists( 'is_plugin_active_for_network' ) )
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
if ( is_plugin_active_for_network( 'mycred/mycred.php' ) ) {
$network = new myCRED_Network_Module();
$network->load();
}
}
// Load Settings
require_once( myCRED_MODULES_DIR . 'mycred-module-settings.php' );
foreach ( $mycred_types as $type => $title ) {
$mycred_modules[ $type ]['settings'] = new myCRED_Settings_Module( $type );
$mycred_modules[ $type ]['settings']->load();
}
// Load only hooks that we have use of
if ( defined( 'JETPACK__PLUGIN_DIR' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-jetpack.php' );
if ( class_exists( 'bbPress' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-bbPress.php' );
if ( function_exists( 'invite_anyone_init' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-invite-anyone.php' );
if ( function_exists( 'wpcf7' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-contact-form7.php' );
if ( class_exists( 'BadgeOS' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-badgeOS.php' );
if ( function_exists( 'vote_poll' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-wp-polls.php' );
if ( function_exists( 'wp_favorite_posts' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-wp-favorite-posts.php' );
if ( function_exists( 'bp_em_init' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-events-manager-light.php' );
if ( defined( 'STARRATING_DEBUG' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-gd-star-rating.php' );
if ( defined( 'SFTOPICS' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-simplepress.php' );
if ( function_exists( 'bp_links_setup_root_component' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-buddypress-links.php' );
if ( function_exists( 'bpa_init' ) || function_exists( 'bpgpls_init' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-buddypress-gallery.php' );
if ( class_exists( 'GFForms' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-gravityforms.php' );
if ( function_exists( 'rtmedia_autoloader' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-buddypress-media.php' );
if ( function_exists( 'install_ShareThis' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-sharethis.php' );
if ( class_exists( 'WooCommerce' ) )
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-woocommerce.php' );
// Load hooks
require_once( myCRED_MODULES_DIR . 'mycred-module-hooks.php' );
foreach ( $mycred_types as $type => $title ) {
$mycred_modules[ $type ]['hooks'] = new myCRED_Hooks_Module( $type );
$mycred_modules[ $type ]['hooks']->load();
}
// Load log
require_once( myCRED_MODULES_DIR . 'mycred-module-log.php' );
foreach ( $mycred_types as $type => $title ) {
$mycred_modules[ $type ]['log'] = new myCRED_Log_Module( $type );
$mycred_modules[ $type ]['log']->load();
}
// BuddyPress
if ( class_exists( 'BuddyPress' ) ) {
require_once( myCRED_PLUGINS_DIR . 'mycred-hook-buddypress.php' );
require_once( myCRED_MODULES_DIR . 'mycred-module-buddypress.php' );
$mycred_modules['mycred_default']['buddypress'] = new myCRED_BuddyPress_Module( 'mycred_default' );
$mycred_modules['mycred_default']['buddypress']->load();
}
// Load admin
require_once( myCRED_INCLUDES_DIR . 'mycred-admin.php' );
$admin = new myCRED_Admin();
$admin->load();
do_action( 'mycred_pre_init' );
}
endif;
/**
* Init
* @since 1.3
* @version 1.2
*/
if ( ! function_exists( 'mycred_init' ) ) :
function mycred_init()
{
// Enqueue scripts & styles
add_action( 'wp_enqueue_scripts', 'mycred_enqueue_front' );
add_action( 'admin_enqueue_scripts', 'mycred_enqueue_admin' );
add_action( 'admin_head', 'mycred_admin_head', 999 );
add_action( 'admin_menu', 'mycred_admin_menu', 9 );
add_action( 'admin_bar_menu', 'mycred_hook_into_toolbar' );
// Shortcodes
add_shortcode( 'mycred_history', 'mycred_render_shortcode_history' );
add_shortcode( 'mycred_leaderboard', 'mycred_render_shortcode_leaderboard' );
add_shortcode( 'mycred_my_ranking', 'mycred_render_shortcode_my_ranking' );
add_shortcode( 'mycred_my_balance', 'mycred_render_shortcode_my_balance' );
add_shortcode( 'mycred_give', 'mycred_render_shortcode_give' );
add_shortcode( 'mycred_send', 'mycred_render_shortcode_send' );
add_shortcode( 'mycred_total_balance', 'mycred_render_shortcode_total' );
add_shortcode( 'mycred_exchange', 'mycred_render_shortcode_exchange' );
// Let others play
do_action( 'mycred_init' );
}
endif;
/**
* Widgets Init
* @since 1.3
* @version 1.1
*/
if ( ! function_exists( 'mycred_widgets_init' ) ) :
function mycred_widgets_init()
{
// Register Widgets
register_widget( 'myCRED_Widget_Balance' );
register_widget( 'myCRED_Widget_Leaderboard' );
$mycred_types = mycred_get_types();
if ( count( $mycred_types ) > 1 )
register_widget( 'myCRED_Widget_Wallet' );
// Let others play
do_action( 'mycred_widgets_init' );
}
endif;
/**
* Admin Init
* @since 1.3
* @version 1.2
*/
if ( ! function_exists( 'mycred_admin_init' ) ) :
function mycred_admin_init()
{
// Dashboard Overview
require_once( myCRED_INCLUDES_DIR . 'mycred-overview.php' );
// Register importers
if ( defined( 'WP_LOAD_IMPORTERS' ) )
require_once( myCRED_INCLUDES_DIR . 'mycred-importer.php' );
// Let others play
do_action( 'mycred_admin_init' );
if ( get_transient( '_mycred_activation_redirect' ) === apply_filters( 'mycred_active_redirect', false ) )
return;
delete_transient( '_mycred_activation_redirect' );
$url = add_query_arg( array( 'page' => 'mycred' ), admin_url( 'index.php' ) );
wp_safe_redirect( $url );
die;
}
endif;
/**
* Remove About Page
* @since 1.3.2
* @version 1.1
*/
if ( ! function_exists( 'mycred_admin_head' ) ) :
function mycred_admin_head()
{
remove_submenu_page( 'index.php', 'mycred' );
remove_submenu_page( 'index.php', 'mycred-credit' );
remove_submenu_page( 'users.php', 'mycred-edit-balance' );
}
endif;
/**
* Adjust the Tool Bar
* @since 1.3
* @version 1.4.1
*/
if ( ! function_exists( 'mycred_hook_into_toolbar' ) ) :
function mycred_hook_into_toolbar( $wp_admin_bar )
{
if ( ! is_user_logged_in() ) return;
$user_id = get_current_user_id();
global $bp, $mycred, $mycred_types;
// Start by making sure we have usable point types
$usable = 0;
foreach ( $mycred_types as $type => $type_label ) {
$point_type = mycred( $type );
if ( ! $point_type->exclude_user( $user_id ) )
$usable ++;
}
if ( $usable == 0 ) return;
$main_label = __( 'Balance', 'mycred' );
if ( count( $mycred_types ) == 1 )
$main_label = $mycred->plural();
// BuddyPress
if ( is_object( $bp ) )
$wp_admin_bar->add_menu( array(
'parent' => 'my-account-buddypress',
'id' => 'mycred-account',
'title' => $main_label,
'href' => false
) );
// Default
else
$wp_admin_bar->add_menu( array(
'parent' => 'my-account',
'id' => 'mycred-account',
'title' => $main_label,
'meta' => array(
'class' => 'ab-sub-secondary'
)
) );
$my_balance_label = apply_filters( 'mycred_label_my_balance', '%label%: %cred_f%', $user_id, $mycred );
$mycred_history_label = __( '%label% History', 'mycred' );
$counter = 0;
foreach ( $mycred_types as $type => $type_label ) {
$point_type = mycred( $type );
if ( $point_type->exclude_user( $user_id ) ) continue;
$counter++;
$balance = $point_type->get_users_cred( $user_id, $type );
$mycred_history_url = apply_filters( 'mycred_my_history_url', admin_url( 'users.php?page=' . $type . '_history' ), $type );
$bp_query = '';
if ( $type != 'mycred_default' )
$bp_query = '?show-ctype=' . $type;
if ( isset( $mycred->buddypress['history_url'] ) && function_exists( 'bp_loggedin_user_domain' ) )
$mycred_history_url = bp_loggedin_user_domain() . $mycred->buddypress['history_url'] . '/' . $bp_query;
if ( $type == 'mycred_default' )
$type_label = $point_type->plural();
$my_balance_label = str_replace( '%label%', $type_label, $my_balance_label );
$mycred_history_label = str_replace( '%label%', $type_label, $mycred_history_label );
$id = str_replace( '_', '-', $type ) . $counter;
$wp_admin_bar->add_menu( array(
'parent' => 'mycred-account',
'id' => 'mycred-account-balance-' . $id,
'title' => $point_type->template_tags_amount( $my_balance_label, $balance ),
'href' => false
) );
if ( ( function_exists( 'bp_loggedin_user_domain' ) && isset( $mycred->buddypress['visibility']['history'] ) && $mycred->buddypress['visibility']['history'] ) || ( ! function_exists( 'bp_loggedin_user_domain' ) ) || $mycred->can_edit_creds() )
$wp_admin_bar->add_menu( array(
'parent' => 'mycred-account',
'id' => 'mycred-account-history-' . $id,
'title' => $mycred_history_label,
'href' => $mycred_history_url
) );
$my_balance_label = str_replace( $type_label, '%label%', $my_balance_label );
$mycred_history_label = str_replace( $type_label, '%label%', $mycred_history_label );
}
if ( $counter == 0 )
$wp_admin_bar->remove_menu( array( 'id' => 'mycred-account' ) );
// Let others play
do_action( 'mycred_tool_bar', $wp_admin_bar, $mycred );
}
endif;
/**
* Add myCRED Admin Menu
* @uses add_menu_page()
* @since 1.3
* @version 1.2
*/
if ( ! function_exists( 'mycred_admin_menu' ) ) :
function mycred_admin_menu()
{
$mycred = mycred();
$name = mycred_label( true );
global $mycred_types, $wp_version;
$pages = array();
$slug = 'myCRED';
$menu_icon = 'dashicons-star-filled';
if ( version_compare( $wp_version, '3.8', '<' ) )
$menu_icon = '';
foreach ( $mycred_types as $type => $title ) {
$type_slug = 'myCRED';
if ( $type != 'mycred_default' )
$type_slug = 'myCRED_' . trim( $type );
$pages[] = add_menu_page(
$title,
$title,
$mycred->edit_creds_cap(),
$type_slug,
'',
$menu_icon
);
}
$about_label = sprintf( __( 'About %s', 'mycred' ), $name );
$pages[] = add_dashboard_page(
$about_label,
$about_label,
'moderate_comments',
'mycred',
'mycred_about_page'
);
$cred_label = __( 'Awesome People', 'mycred' );
$pages[] = add_dashboard_page(
$cred_label,
$cred_label,
'moderate_comments',
'mycred-credit',
'mycred_about_credit_page'
);
$pages = apply_filters( 'mycred_admin_pages', $pages, $mycred );
foreach ( $pages as $page )
add_action( 'admin_print_styles-' . $page, 'mycred_admin_page_styles' );
// Let others play
do_action( 'mycred_add_menu', $mycred );
}
endif;
/**
* Enqueue Front
* @filter 'mycred_remove_widget_css'
* @since 1.3
* @version 1.0
*/
if ( ! function_exists( 'mycred_enqueue_front' ) ) :
function mycred_enqueue_front()
{
global $mycred_sending_points;
// Send Points Shortcode
wp_register_script(
'mycred-send-points',
plugins_url( 'assets/js/send.js', myCRED_THIS ),
array( 'jquery' ),
myCRED_VERSION . '.1',
true
);
// Widget Style (can be disabled)
if ( apply_filters( 'mycred_remove_widget_css', false ) === false ) {
wp_register_style(
'mycred-widget',
plugins_url( 'assets/css/widget.css', myCRED_THIS ),
false,
myCRED_VERSION . '.1',
'all'
);
wp_enqueue_style( 'mycred-widget' );
}
// Let others play
do_action( 'mycred_front_enqueue' );
}
endif;
/**
* Enqueue Admin
* @since 1.3
* @version 1.2.1
*/
if ( ! function_exists( 'mycred_enqueue_admin' ) ) :
function mycred_enqueue_admin()
{
$mycred = mycred();
// General Admin Script
wp_register_script(
'mycred-admin',
plugins_url( 'assets/js/accordion.js', myCRED_THIS ),
array( 'jquery', 'jquery-ui-core', 'jquery-ui-accordion' ),
myCRED_VERSION . '.1'
);
// Management Admin Script
wp_register_script(
'mycred-manage',
plugins_url( 'assets/js/management.js', myCRED_THIS ),
array( 'jquery', 'mycred-admin', 'jquery-ui-core', 'jquery-ui-dialog', 'jquery-effects-core', 'jquery-effects-slide' ),
myCRED_VERSION . '.1'
);
wp_localize_script(
'mycred-manage',
'myCREDmanage',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'token' => wp_create_nonce( 'mycred-management-actions' ),
'working' => __( 'Processing...', 'mycred' ),
'confirm_log' => __( 'Warning! All entries in your log will be permanently removed! This can not be undone!', 'mycred' ),
'confirm_clean' => __( 'All log entries belonging to deleted users will be permanently deleted! This can not be undone!', 'mycred' ),
'confirm_reset' => __( 'Warning! All user balances will be set to zero! This can not be undone!', 'mycred' ),
'done' => __( 'Done!', 'mycred' ),
'export_close' => __( 'Close', 'mycred' ),
'export_title' => $mycred->template_tags_general( __( 'Export users %plural%', 'mycred' ) )
)
);
// Inline Editing Script
wp_register_script(
'mycred-inline-edit',
plugins_url( 'assets/js/inline-edit.js', myCRED_THIS ),
array( 'jquery', 'jquery-ui-core', 'jquery-ui-dialog', 'jquery-effects-core', 'jquery-effects-slide' ),
myCRED_VERSION . '.1'
);
wp_localize_script(
'mycred-inline-edit',
'myCREDedit',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'title' => __( 'Edit Users Balance', 'mycred' ),
'close' => __( 'Close', 'mycred' ),
'working' => __( 'Processing...', 'mycred' )
)
);
// Log Edit Script
wp_register_script(
'mycred-edit-log',
plugins_url( 'assets/js/edit-log.js', myCRED_THIS ),
array( 'jquery', 'jquery-ui-core', 'jquery-ui-dialog', 'jquery-effects-core', 'jquery-effects-slide' ),
myCRED_VERSION . '.1'
);
wp_localize_script(
'mycred-edit-log',
'myCREDLog',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'title' => __( 'Edit Log Entry', 'mycred' ),
'close' => __( 'Close', 'mycred' ),
'working' => __( 'Processing...', 'mycred' ),
'messages' => array(
'delete_row' => __( 'Are you sure you want to delete this log entry? This can not be undone!', 'mycred' ),
'updated_row' => __( 'Log entry updated', 'mycred' )
),
'tokens' => array(
'delete_row' => wp_create_nonce( 'mycred-delete-log-entry' ),
'update_row' => wp_create_nonce( 'mycred-update-log-entry' )
)
)
);
// Admin Style
wp_register_style(
'mycred-admin',
plugins_url( 'assets/css/admin.css', myCRED_THIS ),
false,
myCRED_VERSION . '.1',
'all'
);
wp_register_style(
'mycred-inline-edit',
plugins_url( 'assets/css/inline-edit.css', myCRED_THIS ),
false,
myCRED_VERSION . '.1',
'all'
);
// Let others play
do_action( 'mycred_admin_enqueue' );
}
endif;
/**
* Enqueue Admin Styling
* @since 1.3
* @version 1.0
*/
if ( ! function_exists( 'mycred_admin_page_styles' ) ) :
function mycred_admin_page_styles()
{
wp_enqueue_style( 'mycred-admin' );
}
endif;
/**
* myCRED Plugin Links
* @since 1.3
* @version 1.1
*/
if ( ! function_exists( 'mycred_plugin_links' ) ) :
function mycred_plugin_links( $actions, $plugin_file, $plugin_data, $context )
{
// Link to Setup
if ( ! is_mycred_ready() )
$actions['_setup'] = '<a href="' . admin_url( 'plugins.php?page=myCRED-setup' ) . '">' . __( 'Setup', 'mycred' ) . '</a>';
else
$actions['_settings'] = '<a href="' . admin_url( 'admin.php?page=myCRED' ) . '" >' . __( 'Settings', 'mycred' ) . '</a>';
ksort( $actions );
return $actions;
}
endif;
/**
* myCRED Plugin Description Links
* @since 1.3.3.1
* @version 1.1
*/
if ( ! function_exists( 'mycred_plugin_description_links' ) ) :
function mycred_plugin_description_links( $links, $file )
{
if ( $file != plugin_basename( myCRED_THIS ) ) return $links;
// Link to Setup
if ( ! is_mycred_ready() ) {
$links[] = '<a href="' . admin_url( 'plugins.php?page=myCRED-setup' ) . '">' . __( 'Setup', 'mycred' ) . '</a>';
return $links;
}
$links[] = '<a href="' . admin_url( 'index.php?page=mycred' ) . '">About</a>';
$links[] = '<a href="http://mycred.me/support/tutorials/" target="_blank">Tutorials</a>';
$links[] = '<a href="http://codex.mycred.me/" target="_blank">Codex</a>';
$links[] = '<a href="http://mycred.me/store/" target="_blank">Store</a>';
return $links;
}
endif;
/**
* Update Warning
* Remind users to always backup before updating.
* @since 1.4
* @version 1.0
*/
if ( ! function_exists( 'mycred_update_warning' ) ) :
function mycred_update_warning() {
echo '<div style="color:#cc0000;">' . __( 'Make sure to backup your database and files before updating, in case anything goes wrong!', 'mycred' ) . '</div>';
}
endif;
/**
* Reset Key
* @since 1.3
* @version 1.0
*/
if ( ! function_exists( 'mycred_reset_key' ) ) :
function mycred_reset_key()
{
$protect = mycred_protect();
$protect->reset_key();
}
endif;