rtMedia for WordPress, BuddyPress and bbPress - Version 3.7.3

Version Description

  • Change media title before upload
  • New gallery shortcode attributes ( Enable/disable lightbox: lightbox
Download this release

Release Info

Developer rtcamp
Plugin Icon 128x128 rtMedia for WordPress, BuddyPress and bbPress
Version 3.7.3
Comparing to
See all releases

Code changes from version 3.7.2 to 3.7.3

Files changed (45) hide show
  1. app/admin/RTMediaAdmin.php +393 -110
  2. app/admin/RTMediaFormHandler.php +589 -405
  3. app/assets/css/main.css +1 -1
  4. app/assets/js/admin.js +0 -7
  5. app/assets/js/rtMedia.backbone.js +125 -54
  6. app/assets/js/rtMedia.js +13 -1
  7. app/assets/sass/main.scss +13 -2
  8. app/helper/BPMediaBranding.php +2 -2
  9. app/helper/BPMediaLog.php +69 -69
  10. app/helper/RTMediaAddon.php +182 -141
  11. app/helper/RTMediaAdminWidget.php +26 -23
  12. app/helper/RTMediaCommentModel.php +47 -10
  13. app/helper/RTMediaFeed.php +55 -47
  14. app/helper/RTMediaInteractionModel.php +63 -30
  15. app/helper/RTMediaModel.php +324 -295
  16. app/helper/RTMediaSettings.php +208 -141
  17. app/helper/RTMediaSupport.php +88 -5
  18. app/helper/RTMediaThemes.php +59 -26
  19. app/helper/RTMediaUploadException.php +16 -16
  20. app/helper/db/RTDBModel.php +192 -192
  21. app/helper/db/RTDBUpdate.php +173 -115
  22. app/helper/db/rt_plugin_info.php +78 -50
  23. app/helper/rtDimensions.php +146 -102
  24. app/helper/rtForm.php +521 -261
  25. app/helper/rtFormInvalidArgumentsException.php +3 -3
  26. app/helper/rtPluginUpdateChecker.php +1 -1
  27. app/helper/rtProgress.php +32 -9
  28. app/main/RTMedia.php +12 -2
  29. app/main/controllers/activity/RTMediaBuddyPressActivity.php +35 -34
  30. app/main/controllers/api/RTMediaJsonApi.php +5 -0
  31. app/main/controllers/media/RTMediaComment.php +2 -2
  32. app/main/controllers/media/RTMediaMeta.php +64 -45
  33. app/main/controllers/privacy/RTMediaPrivacy.php +1 -1
  34. app/main/controllers/template/RTMediaNav.php +1 -1
  35. app/main/controllers/template/RTMediaTemplate.php +4 -4
  36. app/main/controllers/template/rt-template-functions.php +88 -8
  37. app/main/controllers/upload/processors/RTMediaUploadFile.php +1 -1
  38. app/main/routers/query/RTMediaQuery.php +21 -1
  39. index.php +1 -1
  40. readme.txt +8 -3
  41. templates/media/album-gallery-item.php +9 -8
  42. templates/media/album-gallery.php +1 -1
  43. templates/media/media-gallery-item.php +8 -11
  44. templates/media/media-gallery.php +1 -1
  45. templates/media/media-single.php +2 -2
app/admin/RTMediaAdmin.php CHANGED
@@ -8,6 +8,9 @@
8
*/
9
if ( ! class_exists( 'RTMediaAdmin' ) ){
10
11
class RTMediaAdmin {
12
13
public $rtmedia_upgrade;
@@ -16,8 +19,16 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
16
public $rtmedia_support;
17
public $rtmedia_feed;
18
19
public function __construct() {
20
global $rtmedia;
21
add_action( 'init', array( $this, 'video_transcoding_survey_response' ) );
22
add_action( 'admin_init', array( $this, 'presstrends_plugin' ) );
23
@@ -43,7 +54,9 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
43
add_filter( "attachment_fields_to_save", array( $this, "save_video_thumbnail" ), null, 2 );
44
add_action( 'wp_ajax_rtmedia_hide_video_thumb_admin_notice', array( $this, 'rtmedia_hide_video_thumb_admin_notice' ), 1 );
45
add_action( 'wp_ajax_rtmedia_hide_addon_update_notice', array( $this, 'rtmedia_hide_addon_update_notice' ), 1 );
46
$obj_encoding = new RTMediaEncoding( true );
47
if ( $obj_encoding->api_key ){
48
add_filter( "media_row_actions", array( $this, "add_reencode_link" ), null, 2 );
49
add_action( 'admin_head-upload.php', array( $this, 'add_bulk_actions_regenerate' ) );
@@ -51,10 +64,13 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
51
add_action( 'admin_action_bulk_video_regenerate_thumbnails', array( $this, 'bulk_action_handler' ) );
52
add_action( 'admin_action_-1', array( $this, 'bulk_action_handler' ) );
53
}
54
add_action( 'wp_ajax_rt_media_regeneration', array( $this, 'rt_media_regeneration' ), 1 );
55
if ( ! isset( $rtmedia->options ) ){
56
$rtmedia->options = rtmedia_get_site_option( 'rtmedia-options' );
57
}
58
if ( isset ( $_POST[ "rtmedia-options" ] ) ){
59
if ( isset ( $_POST[ "rtmedia-options" ][ "general_showAdminMenu" ] ) && $_POST[ "rtmedia-options" ][ "general_showAdminMenu" ] == "1" ){
60
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100, 1 );
@@ -70,10 +86,13 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
70
//bp_core_admin_hook();
71
add_action( 'admin_menu', array( $this, 'menu' ), 1 );
72
add_action( 'init', array( $this, 'bp_admin_tabs' ) );
73
if ( is_multisite() ){
74
add_action( 'network_admin_edit_rtmedia', array( $this, 'save_multisite_options' ) );
75
}
76
}
77
$this->rtmedia_settings = new RTMediaSettings();
78
$this->rtmedia_encoding = new RTMediaEncoding();
79
// show rtmedia advertisement
@@ -92,13 +111,27 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
92
93
}
94
95
- function rtmedia_network_admin_notices() {
96
if ( is_multisite() ){
97
$this->upload_filetypes_error();
98
}
99
}
100
101
- function rtmedia_admin_notices() {
102
$this->upload_filetypes_error();
103
$this->rtmedia_regenerate_thumbnail_notice();
104
$this->rtmedia_addon_update_notice();
@@ -106,7 +139,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
106
$this->rtmedia_inspirebook_release_notice();
107
}
108
109
- function rtmedia_inspirebook_release_notice() {
110
$site_option = rtmedia_get_site_option( "rtmedia_inspirebook_release_notice" );
111
if ( ( ! $site_option || $site_option != "hide" ) && ( get_stylesheet() != 'inspirebook' ) ){
112
rtmedia_update_site_option( "rtmedia_inspirebook_release_notice", "show" );
@@ -132,7 +172,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
132
}
133
}
134
135
- function rtmedia_hide_inspirebook_release_notice() {
136
if ( rtmedia_update_site_option( "rtmedia_inspirebook_release_notice", "hide" ) ){
137
echo "1";
138
} else {
@@ -141,26 +188,54 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
141
die();
142
}
143
144
- function rtmedia_bp_add_update_type() {
145
if ( class_exists( 'BuddyPress' ) && function_exists( 'bp_activity_set_action' ) ){
146
bp_activity_set_action( 'rtmedia_update', 'rtmedia_update', 'rtMedia Update' );
147
}
148
}
149
150
- function check_permalink_admin_notice() {
151
global $wp_rewrite;
152
if ( empty( $wp_rewrite->permalink_structure ) ){
153
add_action( 'admin_notices', array( $this, 'rtmedia_permalink_notice' ) );
154
}
155
}
156
157
- function rtmedia_permalink_notice() {
158
echo '<div class="error rtmedia-permalink-change-notice">
159
<p> <b>' . __( 'rtMedia:' ) . '</b> ' . __( ' You must ' ) . '<a href="' . admin_url( 'options-permalink.php' ) . '">' . __( 'update permalink structure' ) . '</a>' . __( ' to something other than the default for it to work.', 'rtmedia' ) . ' </p>
160
</div>';
161
}
162
163
- function rtmedia_addon_update_notice() {
164
if ( ! $this->check_for_addon_update_notice() ){
165
return;
166
}
@@ -190,8 +265,16 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
190
}
191
}
192
193
- function check_for_addon_update_notice() {
194
$return_falg = false;
195
if ( defined( 'RTMEDIA_INSTAGRAM_PATH' ) ){
196
$plugin_info = get_plugin_data( RTMEDIA_INSTAGRAM_PATH . 'index.php' );
197
if ( isset( $plugin_info[ 'Version' ] ) && $plugin_info[ 'Version' ] < "2.1.2" ){
@@ -230,13 +313,27 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
230
return $return_falg;
231
}
232
233
- function bp_admin_tabs() {
234
if ( current_user_can( 'manage_options' ) ){
235
add_action( 'bp_admin_tabs', array( $this, 'tab' ) );
236
}
237
}
238
239
- function rtmedia_advertisement() {
240
$src = RTMEDIA_URL . "app/assets/img/rtMedia-pro-ad.png"
241
?>
242
<div class='rtmedia-admin-ad'>
@@ -247,9 +344,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
247
<?php
248
}
249
250
- // Create the function to output the contents of our Dashboard Widget
251
-
252
- function rtMedia_dashboard_widget_function() {
253
?>
254
255
<div class="inside">
@@ -328,9 +430,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
328
<?php
329
}
330
331
- // Create the function use in the action hook
332
-
333
- function add_dashboard_widgets() {
334
wp_add_dashboard_widget( 'rtmedia_dashboard_widget', __( 'Right Now in rtMedia', 'rtmedia' ), array( &$this, 'rtMedia_dashboard_widget_function' ) );
335
global $wp_meta_boxes;
336
@@ -353,7 +460,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
353
$wp_meta_boxes[ 'dashboard' ][ 'normal' ][ 'core' ] = $sorted_dashboard;
354
}
355
356
- function plugin_add_settings_link( $links ) {
357
$settings_link = '<a href="' . admin_url( 'admin.php?page=rtmedia-settings' ) . '">Settings</a>';
358
array_push( $links, $settings_link );
359
$settings_link = '<a href="' . admin_url( 'admin.php?page=rtmedia-support' ) . '">Support</a>';
@@ -362,7 +476,15 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
362
return $links;
363
}
364
365
- function add_reencode_link( $actions, $post ) {
366
367
$mime_type_array = explode( "/", $post->post_mime_type );
368
if ( is_array( $mime_type_array ) && $mime_type_array != "" && $mime_type_array[ 0 ] == "video" ){
@@ -372,14 +494,28 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
372
return $actions;
373
}
374
375
- function bulk_action_handler() {
376
if ( $_REQUEST[ 'action' ] == "bulk_video_regenerate_thumbnails" && $_REQUEST[ 'media' ] != "" ){
377
wp_safe_redirect( add_query_arg( array( "media_ids" => urlencode( implode( ",", $_REQUEST[ "media" ] ) ) ), admin_url( "admin.php?page=rtmedia-regenerate" ) ) );
378
exit;
379
}
380
}
381
382
- function admin_bar_menu( $admin_bar ) {
383
if ( ! current_user_can( 'manage_options' ) ){
384
return;
385
}
@@ -419,19 +555,19 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
419
/**
420
* Generates the Admin UI.
421
*
422
- * @param string $hook
423
- */
424
-
425
- /**
426
- *
427
- * @param type $hook
428
*/
429
public function ui( $hook ) {
430
$admin_pages = array(
431
'rtmedia_page_rtmedia-migration', 'rtmedia_page_rtmedia-kaltura-settings', 'rtmedia_page_rtmedia-ffmpeg-settings', 'toplevel_page_rtmedia-settings', 'rtmedia_page_rtmedia-addons', 'rtmedia_page_rtmedia-support', 'rtmedia_page_rtmedia-themes', 'rtmedia_page_rtmedia-hire-us', 'rtmedia_page_rtmedia-importer', 'rtmedia_page_rtmedia-regenerate', 'rtmedia_page_rtmedia-premium'
432
);
433
$admin_pages = apply_filters( 'rtmedia_filter_admin_pages_array', $admin_pages );
434
if ( in_array( $hook, $admin_pages ) || strpos( $hook, 'rtmedia-migration' ) ){
435
$admin_ajax = admin_url( 'admin-ajax.php' );
436
437
wp_enqueue_script( 'bootstrap-switch', RTMEDIA_URL . 'app/assets/js/bootstrap-switch.js', array( 'jquery' ), RTMEDIA_VERSION );
@@ -443,6 +579,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
443
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_ajax', $admin_ajax );
444
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_url', admin_url() );
445
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_url', admin_url() );
446
if ( isset( $_REQUEST[ 'page' ] ) && ( in_array( $_REQUEST[ 'page' ], array( "rtmedia-settings", "rtmedia-addons", "rtmedia-themes", "rtmedia-support", "rtmedia-hire-us" ) ) ) ){
447
wp_enqueue_script( 'rtmedia-foundation-modernizr', RTMEDIA_URL . 'lib/foundation/custom.modernizr.js', array( 'jquery' ), RTMEDIA_VERSION );
448
wp_enqueue_script( 'rtmedia-foundation', RTMEDIA_BOWER_COMPONENTS_URL . 'js/foundation.js', array( 'jquery' ), RTMEDIA_VERSION );
@@ -452,6 +589,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
452
$rtmedia_admin_strings = array(
453
'no_refresh' => __( 'Please do not refresh this page.', 'rtmedia' ), 'something_went_wrong' => __( 'Something went wronng. Please <a href onclick="location.reload();">refresh</a> page.', 'rtmedia' ), 'are_you_sure' => __( 'This will subscribe you to the free plan.', 'rtmedia' ), 'disable_encoding' => __( 'Are you sure you want to disable the encoding service? Make sure you note your api key before disabling it incase you want to activate it in future.', 'rtmedia' )
454
);
455
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_strings', $rtmedia_admin_strings );
456
wp_localize_script( 'rtmedia-admin', 'settings_url', add_query_arg( array( 'page' => 'rtmedia-settings' ), ( is_multisite() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) ) ) . '#privacy_enabled' );
457
wp_localize_script( 'rtmedia-admin', 'settings_rt_album_import_url', add_query_arg( array( 'page' => 'rtmedia-settings' ), ( is_multisite() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) ) ) );
@@ -461,19 +599,25 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
461
wp_enqueue_style( 'grid-foundation', RTMEDIA_URL . 'app/assets/css/grid-foundation.css', '', RTMEDIA_VERSION );
462
wp_enqueue_style( 'rtmedia-main', RTMEDIA_URL . 'app/assets/css/main.css', '', RTMEDIA_VERSION );
463
wp_enqueue_style( 'rtmedia-admin', RTMEDIA_URL . 'app/assets/css/admin.css', '', RTMEDIA_VERSION );
464
if ( isset( $_REQUEST[ 'page' ] ) && ( in_array( $_REQUEST[ 'page' ], array( "rtmedia-settings", "rtmedia-addons", "rtmedia-themes", "rtmedia-support", "rtmedia-hire-us" ) ) ) ){
465
wp_enqueue_style( 'foundation-admin-css', RTMEDIA_URL . 'app/assets/css/settings.css', '', RTMEDIA_VERSION );
466
}
467
wp_enqueue_style( 'wp-jquery-ui-dialog' );
468
} else {
469
wp_enqueue_style( 'rtmedia-widget', RTMEDIA_URL . 'app/assets/css/widget.css', '', RTMEDIA_VERSION );
470
}
471
}
472
473
/**
474
- * Admin Menu
475
*
476
* @global string 'rtmedia'
477
*/
478
public function menu() {
479
add_menu_page( 'rtMedia', 'rtMedia', 'manage_options', 'rtmedia-settings', array( $this, 'settings_page' ), RTMEDIA_URL . "app/assets/img/rtmedia-logo.png", "40.1111" );
@@ -482,11 +626,13 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
482
add_submenu_page( 'rtmedia-settings', __( 'Support', 'rtmedia' ), __( 'Support', 'rtmedia' ), 'manage_options', 'rtmedia-support', array( $this, 'support_page' ) );
483
add_submenu_page( 'rtmedia-settings', __( 'Themes', 'rtmedia' ), __( 'Themes', 'rtmedia' ), 'manage_options', 'rtmedia-themes', array( $this, 'theme_page' ) );
484
add_submenu_page( 'rtmedia-settings', __( 'Hire Us', 'rtmedia' ), __( 'Hire Us', 'rtmedia' ), 'manage_options', 'rtmedia-hire-us', array( $this, 'hire_us_page' ) );
485
if ( ! defined( "RTMEDIA_PRO_VERSION" ) ){
486
add_submenu_page( 'rtmedia-settings', __( 'Premium', 'rtmedia' ), __( 'Premium ', 'rtmedia' ), 'manage_options', 'rtmedia-premium', array( $this, 'premium_page' ) );
487
}
488
489
$obj_encoding = new RTMediaEncoding( true );
490
if ( $obj_encoding->api_key ){
491
add_submenu_page( 'rtmedia-settings', __( 'Regenerate Thumbnail', 'rtmedia' ), __( 'Regen. Thumbnail ', 'rtmedia' ), 'manage_options', 'rtmedia-regenerate', array( $this, 'rt_regenerate_thumbnail' ) );
492
}
@@ -497,12 +643,19 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
497
// }
498
}
499
500
- function rt_regenerate_thumbnail() {
501
$prog = new rtProgress();
502
$done = 0;
503
?>
504
<div class="wrap">
505
- <h2> <?php _e( 'Regenerate Video Thumbnails', 'rtmedia' ); ?> </h2>
506
<?php
507
if ( isset( $_REQUEST[ "media_ids" ] ) && trim( $_REQUEST[ "media_ids" ] ) != "" ){
508
$requested = false;
@@ -519,9 +672,11 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
519
<?php
520
if ( ! isset( $requested ) ){
521
?>
522
- <br/> <br/>
523
- <input type="button" class="button button-primary" id="rt-start-media-regenerate"
524
- value="<?php _e( 'Regenerate Pending Thumbnails', 'rtmedia' ); ?>"/>
525
<?php } ?>
526
<div id="rt-migration-progress">
527
<br/> <br/>
@@ -529,17 +684,13 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
529
$temp = $prog->progress( $done, $total );
530
$prog->progress_ui( $temp, true );
531
?>
532
- <p> <?php _e( 'Total Videos', 'rtmedia' ) ?> : <span class='rt-total'><?php echo $total; ?></span>
533
- </p>
534
535
<p> <?php _e( 'Sent of regenerate thumbails', 'rtmedia' ) ?> : <span class='rt-done'>0</span></p>
536
537
<p> <?php _e( 'Fail to regenerate thumbails', 'rtmedia' ) ?> : <span class='rt-fail'>0</span></p>
538
539
</div>
540
- <?php
541
-
542
- ?>
543
<script>
544
545
var db_done = 0;
@@ -547,7 +698,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
547
var db_total = <?php echo $total; ?>;
548
var indx = 0;
549
function db_start_regenrate() {
550
- if ( indx < db_total ) {
551
jQuery.ajax( {
552
url: rtmedia_admin_ajax,
553
type: 'post',
@@ -558,12 +709,12 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
558
success: function ( data ) {
559
data = JSON.parse( data );
560
561
- if ( data.status == false ) {
562
handle_regenrate_fail();
563
} else {
564
db_done++;
565
var progw = Math.ceil( (db_done / db_total) * 100 );
566
- if ( progw > 100 ) {
567
progw = 100;
568
}
569
jQuery( '#rtprogressbar>div' ).css( 'width', progw + '%' );
@@ -584,7 +735,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
584
jQuery( 'span.rt-fail' ).html( db_fail );
585
db_start_regenrate();
586
}
587
- if ( jQuery( "#rt-start-media-regenerate" ).length > 0 ) {
588
jQuery( "#rt-migration-progress" ).hide()
589
jQuery( "#rt-start-media-regenerate" ).click( function () {
590
jQuery( this ).hide();
@@ -601,7 +752,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
601
</div> <?php
602
}
603
604
- function rtmedia_regenerate_thumbnail_notice() {
605
$obj_encoding = new RTMediaEncoding( true );
606
if ( $obj_encoding->api_key ){
607
$site_option = rtmedia_get_site_option( "rtmedia-video-thumb-notice" );
@@ -632,7 +790,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
632
}
633
}
634
635
- function rtmedia_hide_video_thumb_admin_notice() {
636
if ( rtmedia_update_site_option( "rtmedia-video-thumb-notice", "hide" ) ){
637
echo "1";
638
} else {
@@ -641,7 +806,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
641
die();
642
}
643
644
- function rtmedia_hide_addon_update_notice() {
645
if ( rtmedia_update_site_option( "rtmedia-addon-update-notice", "hide" ) ){
646
echo "1";
647
} else {
@@ -650,7 +822,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
650
die();
651
}
652
653
- function rt_media_regeneration() {
654
if ( isset( $_POST[ 'media_id' ] ) ){
655
$model = new RTMediaModel();
656
$media = $model->get_media( array( 'media_id' => $_POST[ 'media_id' ] ), 0, 1 );
@@ -671,7 +850,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
671
}
672
673
674
- function get_video_without_thumbs() {
675
$rtmedia_model = new RTMediaModel();
676
$sql = "select media_id from {$rtmedia_model->table_name} where media_type = 'video' and blog_id = '" . get_current_blog_id() . "' and cover_art is null";
677
global $wpdb;
@@ -681,52 +867,109 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
681
}
682
683
/**
684
- * Render the BuddyPress Media Settings page
685
*/
686
public function settings_page() {
687
$this->render_page( 'rtmedia-settings', 'rtmedia' );
688
}
689
690
public function privacy_page() {
691
$this->render_page( 'rtmedia-privacy' );
692
}
693
694
public function rt_importer_page() {
695
$this->render_page( 'rtmedia-importer' );
696
}
697
698
public function convert_videos_page() {
699
$this->render_page( 'rtmedia-convert-videos' );
700
}
701
702
/**
703
- * Render the BuddyPress Media Addons page
704
*/
705
public function addons_page() {
706
$this->render_page( 'rtmedia-addons' );
707
}
708
709
/**
710
- * Render the BuddyPress Media Support page
711
*/
712
public function support_page() {
713
$this->render_page( 'rtmedia-support' );
714
}
715
716
public function premium_page() {
717
$this->render_page( 'rtmedia-premium' );
718
}
719
720
public function theme_page() {
721
$this->render_page( 'rtmedia-themes' );
722
}
723
724
public function hire_us_page() {
725
$this->render_page( 'rtmedia-hire-us' );
726
}
727
728
/**
729
*
730
* @return type
731
*/
732
static function get_current_tab() {
@@ -734,15 +977,13 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
734
}
735
736
/**
737
- * Render BPMedia Settings
738
*
739
* @global string 'rtmedia'
740
- */
741
-
742
- /**
743
- *
744
- * @param type $page
745
- * @param type $option_group
746
*/
747
public function render_page( $page, $option_group = null ) {
748
?>
@@ -770,27 +1011,27 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
770
<?php if ( $option_group ){ //$option_group if ($page == "bp-media-settings") action="<?php echo $settings_url; ?>
771
<form id="bp_media_settings_form" name="bp_media_settings_form" method="post"
772
enctype="multipart/form-data">
773
- <div class="bp-media-metabox-holder"><?php
774
- settings_fields( $option_group );
775
- if ( $page == "rtmedia-settings" ){
776
777
778
- echo '<div id="rtm-settings-tabs">';
779
- $sub_tabs = $this->settings_sub_tabs();
780
- RTMediaFormHandler::rtForm_settings_tabs_content( $page, $sub_tabs );
781
- echo '</div>';
782
- } else {
783
- do_settings_sections( $page );
784
- }
785
- ?>
786
- <div class="clearfix">&nbsp;</div>
787
- <div class="row">
788
- <input type="hidden" name="rtmedia-options-save" value="true">
789
- <input type="submit" id="rtmedia-settings-submit"
790
- class="rtmedia-settings-submit button button-primary button-big"
791
- value="<?php _e( 'Save Settings', 'rtmedia' ); ?>">
792
</div>
793
- </div>
794
</form><?php
795
} else {
796
?>
@@ -834,7 +1075,11 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
834
/**
835
* Adds a tab for Media settings in the BuddyPress settings page
836
*
837
* @global type $bp_media
838
*/
839
public function tab() {
840
@@ -857,6 +1102,13 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
857
echo $tabs_html;
858
}
859
860
public function rtmedia_tabs( $active_tab = '' ) {
861
// Declare local variables
862
$tabs_html = '';
@@ -889,9 +1141,11 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
889
foreach ( array_values( $tabs ) as $tab_data ) {
890
$is_current = ( bool )( $tab_data[ 'slug' ] == $this->get_current_tab() );
891
$tab_class = $is_current ? $active_class : $idle_class;
892
if ( isset( $tab_data[ 'class' ] ) && is_array( $tab_data[ 'class' ] ) ){
893
$tab_class .= " " . implode( " ", $tab_data[ 'class' ] );
894
}
895
$tabs_html .= '<a href="' . $tab_data[ 'href' ] . '" class="' . $tab_class . '">' . $tab_data[ 'name' ] . '</a>';
896
}
897
@@ -902,6 +1156,13 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
902
// do_action('bp_media_admin_tabs');
903
}
904
905
public function settings_content_tabs( $page ) {
906
global $wp_settings_sections, $wp_settings_fields;
907
@@ -918,9 +1179,11 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
918
call_user_func( $section[ 'callback' ], $section );
919
}
920
921
- if ( ! isset ( $wp_settings_fields ) || ! isset ( $wp_settings_fields[ $page ] ) || ! isset ( $wp_settings_fields[ $page ][ $section[ 'id' ] ] ) ){
922
continue;
923
}
924
echo '<table class="form-table">';
925
do_settings_fields( $page, $section[ 'id' ] );
926
echo '</table>';
@@ -930,7 +1193,10 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
930
/**
931
* Adds a sub tabs to the BuddyPress Media settings page
932
*
933
* @global type $bp_media
934
*/
935
public function settings_sub_tabs() {
936
$tabs_html = '';
@@ -945,7 +1211,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
945
);
946
947
948
- if ( class_exists( "BuddyPress" ) ){
949
$tabs[ 20 ] = array(
950
'href' => '#rtmedia-bp', 'icon' => 'rtmicon-group', 'title' => __( 'rtMedia BuddyPress', 'rtmedia' ), 'name' => __( 'BuddyPress', 'rtmedia' ), 'callback' => array( 'RTMediaFormHandler', 'buddypress_content' ) //change it to BuddyPress Content
951
);
@@ -975,37 +1241,40 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
975
return $tabs;
976
}
977
978
- /*
979
- * Updates the media count of all users.
980
- */
981
-
982
/**
983
*
984
* @global type $wpdb
985
* @return boolean
986
*/
987
public function update_count() {
988
global $wpdb;
989
990
$query = "SELECT
991
- p.post_author,pmp.meta_value,
992
- SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
993
- SUM(CASE WHEN post_mime_type LIKE 'music%' THEN 1 ELSE 0 END) as Music,
994
- SUM(CASE WHEN post_mime_type LIKE 'video%' THEN 1 ELSE 0 END) as Videos,
995
- SUM(CASE WHEN post_type LIKE 'bp_media_album' THEN 1 ELSE 0 END) as Albums
996
- FROM
997
- $wpdb->posts p inner join $wpdb->postmeta pm on pm.post_id = p.id INNER JOIN $wpdb->postmeta pmp
998
- on pmp.post_id = p.id WHERE
999
- pm.meta_key = 'bp-media-key' AND
1000
- pm.meta_value > 0 AND
1001
- pmp.meta_key = 'bp_media_privacy' AND
1002
- ( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'music%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
1003
- GROUP BY p.post_author,pmp.meta_value order by p.post_author";
1004
$result = $wpdb->get_results( $query );
1005
if ( ! is_array( $result ) ){
1006
return false;
1007
}
1008
$formatted = array();
1009
foreach ( $result as $obj ) {
1010
$formatted[ $obj->post_author ][ $obj->meta_value ] = array(
1011
'image' => $obj->Images, 'video' => $obj->Videos, 'music' => $obj->Music, 'album' => $obj->Albums,
@@ -1019,11 +1288,13 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
1019
return true;
1020
}
1021
1022
- /* Multisite Save Options - http://wordpress.stackexchange.com/questions/64968/settings-api-in-multisite-missing-update-message#answer-72503 */
1023
-
1024
/**
1025
*
1026
- * @global type $bp_media_admin
1027
*/
1028
public function save_multisite_options() {
1029
global $rtmedia_admin;
@@ -1035,17 +1306,19 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
1035
if ( isset ( $_POST[ 'rtmedia_options' ] ) ){
1036
rtmedia_update_site_option( 'rtmedia_options', $_POST[ 'rtmedia_options' ] );
1037
//
1038
- // // redirect to settings page in network
1039
wp_redirect( add_query_arg( array( 'page' => 'rtmedia-settings', 'updated' => 'true' ), ( is_multisite() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) ) ) );
1040
exit;
1041
}
1042
}
1043
1044
- /* Admin Sidebar */
1045
-
1046
/**
1047
*
1048
* @global type $bp_media
1049
*/
1050
public function admin_sidebar() {
1051
do_action( 'rtmedia_before_default_admin_widgets' );
@@ -1187,13 +1460,15 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
1187
jQuery( '.update-network-settings-upload-filetypes' ).siblings( 'img' ).show();
1188
jQuery( '.update-network-settings-upload-filetypes' ).prop( 'disabled', true );
1189
jQuery.post( ajaxurl, {action: 'rtmedia_correct_upload_filetypes'}, function ( response ) {
1190
- if ( response ) {
1191
jQuery( '.upload-filetype-network-settings-error:first' ).after( '<div style="display: none;" class="updated rtmedia-network-settings-updated-successfully"><p><?php _e( 'Network settings updated successfully.', 'rtmedia' ); ?></p></div>' )
1192
jQuery( '.upload-filetype-network-settings-error' ).remove();
1193
jQuery( '.bp-media-network-settings-updated-successfully' ).show();
1194
}
1195
} );
1196
- } );</script><?php
1197
}
1198
}
1199
@@ -1241,6 +1516,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
1241
$video_thumb_html = "";
1242
if ( is_array( $thumbnail_array ) ){
1243
$video_thumb_html .= '<ul> ';
1244
foreach ( $thumbnail_array as $key => $thumbnail_src ) {
1245
$checked = checked( $thumbnail_src, $rtmedia_media[ 0 ]->cover_art, false );
1246
$count = $key + 1;
@@ -1280,21 +1556,20 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
1280
function rtmedia_regenerate_thumb_js() {
1281
global $pagenow;
1282
1283
- if ( $pagenow == 'upload.php' ){
1284
?>
1285
<script type="text/javascript">
1286
function rtmedia_regenerate_thumbs( post_id ) {
1287
- if ( post_id != "" ) {
1288
var data = {
1289
action: 'rt_media_regeneration',
1290
media_id: post_id
1291
};
1292
jQuery.post( ajaxurl, data, function ( data ) {
1293
data = JSON.parse( data );
1294
- if ( data.status === true ) {
1295
alert( "<?php _e('Video is sent to generate thumbnails.', 'rtmedia') ?>" );
1296
- }
1297
- else {
1298
alert( "<?php _e('Video can\'t be sent to generate thumbnails.', 'rtmedia') ?>" );
1299
}
1300
} );
@@ -1330,12 +1605,14 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
1330
// Start of Metrics
1331
global $wpdb;
1332
$data = get_transient( 'presstrends_cache_data' );
1333
if ( ! $data || $data == '' ){
1334
$api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update?auth=';
1335
$url = $api_base . $auth . '&api=' . $api_key . '';
1336
$count_posts = wp_count_posts();
1337
$count_pages = wp_count_posts( 'page' );
1338
$comments_count = wp_count_comments();
1339
if ( function_exists( 'wp_get_theme' ) ){
1340
$theme_data = wp_get_theme();
1341
$theme_name = urlencode( $theme_data->Name );
@@ -1343,28 +1620,34 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
1343
$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
1344
$theme_name = $theme_data[ 'Name' ];
1345
}
1346
$plugin_name = '&';
1347
foreach ( get_plugins() as $plugin_info ) {
1348
$plugin_name .= $plugin_info[ 'Name' ] . '&';
1349
}
1350
// CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
1351
$plugin_data = get_plugin_data( __FILE__ );
1352
$posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
1353
$data = array(
1354
'url' => base64_encode( site_url() ), 'posts' => $count_posts->publish, 'pages' => $count_pages->publish, 'comments' => $comments_count->total_comments, 'approved' => $comments_count->approved, 'spam' => $comments_count->spam, 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ), 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0, 'theme_version' => $plugin_data[ 'Version' ], 'theme_name' => $theme_name, 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ), 'plugins' => count( get_option( 'active_plugins' ) ), 'plugin' => urlencode( $plugin_name ), 'wpversion' => get_bloginfo( 'version' ),
1355
);
1356
foreach ( $data as $k => $v ) {
1357
$url .= '&' . $k . '=' . $v . '';
1358
}
1359
wp_remote_get( $url );
1360
set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
1361
}
1362
}
1363
1364
function rtmedia_update_template_notice() {
1365
- $site_option = rtmedia_get_site_option( "rtmedia-update-template-notice-v3_7_2" );
1366
if ( ! $site_option || $site_option != "hide" ){
1367
- rtmedia_update_site_option( "rtmedia-update-template-notice-v3_7_2", "show" );
1368
if ( is_dir( get_template_directory() . '/rtmedia' ) ){
1369
echo '<div class="error rtmedia-update-template-notice"><p>' . __( 'Please update rtMedia template files if you have overridden the default rtMedia templates in your theme. If not, you can ignore and hide this notice.' ) . '<a href="#" onclick="rtmedia_hide_template_override_notice()" style="float:right">' . __( 'Hide', 'rtmedia' ) . '</a>' . ' </p></div>';
1370
?>
@@ -1385,7 +1668,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
1385
1386
function rtmedia_hide_template_override_notice() {
1387
1388
- if ( rtmedia_update_site_option( "rtmedia-update-template-notice-v3_7_2", "hide" ) ){
1389
echo "1";
1390
} else {
1391
echo "0";
8
*/
9
if ( ! class_exists( 'RTMediaAdmin' ) ){
10
11
+ /**
12
+ * RTMediaAdmin class.
13
+ */
14
class RTMediaAdmin {
15
16
public $rtmedia_upgrade;
19
public $rtmedia_support;
20
public $rtmedia_feed;
21
22
+ /**
23
+ * Constructor - get the plugin hooked in and ready
24
+ *
25
+ * @access public
26
+ * @return void
27
+ */
28
public function __construct() {
29
global $rtmedia;
30
+
31
+ // Actions and filters
32
add_action( 'init', array( $this, 'video_transcoding_survey_response' ) );
33
add_action( 'admin_init', array( $this, 'presstrends_plugin' ) );
34
54
add_filter( "attachment_fields_to_save", array( $this, "save_video_thumbnail" ), null, 2 );
55
add_action( 'wp_ajax_rtmedia_hide_video_thumb_admin_notice', array( $this, 'rtmedia_hide_video_thumb_admin_notice' ), 1 );
56
add_action( 'wp_ajax_rtmedia_hide_addon_update_notice', array( $this, 'rtmedia_hide_addon_update_notice' ), 1 );
57
+
58
$obj_encoding = new RTMediaEncoding( true );
59
+
60
if ( $obj_encoding->api_key ){
61
add_filter( "media_row_actions", array( $this, "add_reencode_link" ), null, 2 );
62
add_action( 'admin_head-upload.php', array( $this, 'add_bulk_actions_regenerate' ) );
64
add_action( 'admin_action_bulk_video_regenerate_thumbnails', array( $this, 'bulk_action_handler' ) );
65
add_action( 'admin_action_-1', array( $this, 'bulk_action_handler' ) );
66
}
67
+
68
add_action( 'wp_ajax_rt_media_regeneration', array( $this, 'rt_media_regeneration' ), 1 );
69
+
70
if ( ! isset( $rtmedia->options ) ){
71
$rtmedia->options = rtmedia_get_site_option( 'rtmedia-options' );
72
}
73
+
74
if ( isset ( $_POST[ "rtmedia-options" ] ) ){
75
if ( isset ( $_POST[ "rtmedia-options" ][ "general_showAdminMenu" ] ) && $_POST[ "rtmedia-options" ][ "general_showAdminMenu" ] == "1" ){
76
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100, 1 );
86
//bp_core_admin_hook();
87
add_action( 'admin_menu', array( $this, 'menu' ), 1 );
88
add_action( 'init', array( $this, 'bp_admin_tabs' ) );
89
+
90
if ( is_multisite() ){
91
add_action( 'network_admin_edit_rtmedia', array( $this, 'save_multisite_options' ) );
92
}
93
+
94
}
95
+
96
$this->rtmedia_settings = new RTMediaSettings();
97
$this->rtmedia_encoding = new RTMediaEncoding();
98
// show rtmedia advertisement
111
112
}
113
114
+ /**
115
+ * Show rtmedia network admin notices.
116
+ *
117
+ * @access public
118
+ * @param void
119
+ * @return void
120
+ */
121
+ public function rtmedia_network_admin_notices() {
122
if ( is_multisite() ){
123
$this->upload_filetypes_error();
124
}
125
}
126
127
+ /**
128
+ * Show rtmedia admin notices.
129
+ *
130
+ * @access public
131
+ * @param void
132
+ * @return void
133
+ */
134
+ public function rtmedia_admin_notices() {
135
$this->upload_filetypes_error();
136
$this->rtmedia_regenerate_thumbnail_notice();
137
$this->rtmedia_addon_update_notice();
139
$this->rtmedia_inspirebook_release_notice();
140
}
141
142
+ /**
143
+ * Show rtmedia inspirebook release notice.
144
+ *
145
+ * @access public
146
+ * @param void
147
+ * @return void
148
+ */
149
+ public function rtmedia_inspirebook_release_notice() {
150
$site_option = rtmedia_get_site_option( "rtmedia_inspirebook_release_notice" );
151
if ( ( ! $site_option || $site_option != "hide" ) && ( get_stylesheet() != 'inspirebook' ) ){
152
rtmedia_update_site_option( "rtmedia_inspirebook_release_notice", "show" );
172
}
173
}
174
175
+ /**
176
+ * Hide rtmedia inspirebook release notice.
177
+ *
178
+ * @access public
179
+ * @param void
180
+ * @return void
181
+ */
182
+ public function rtmedia_hide_inspirebook_release_notice() {
183
if ( rtmedia_update_site_option( "rtmedia_inspirebook_release_notice", "hide" ) ){
184
echo "1";
185
} else {
188
die();
189
}
190
191
+ /**
192
+ * Set rtmedia buddypress update type.
193
+ *
194
+ * @access public
195
+ * @param void
196
+ * @return void
197
+ */
198
+ public function rtmedia_bp_add_update_type() {
199
if ( class_exists( 'BuddyPress' ) && function_exists( 'bp_activity_set_action' ) ){
200
bp_activity_set_action( 'rtmedia_update', 'rtmedia_update', 'rtMedia Update' );
201
}
202
}
203
204
+ /**
205
+ * Show rtmedia check permalink admin notice.
206
+ *
207
+ * @access public
208
+ * @param void
209
+ * @return void
210
+ */
211
+ public function check_permalink_admin_notice() {
212
global $wp_rewrite;
213
if ( empty( $wp_rewrite->permalink_structure ) ){
214
add_action( 'admin_notices', array( $this, 'rtmedia_permalink_notice' ) );
215
}
216
}
217
218
+ /**
219
+ * Define rtmedia permalink notice.
220
+ *
221
+ * @access public
222
+ * @param void
223
+ * @return void
224
+ */
225
+ public function rtmedia_permalink_notice() {
226
echo '<div class="error rtmedia-permalink-change-notice">
227
<p> <b>' . __( 'rtMedia:' ) . '</b> ' . __( ' You must ' ) . '<a href="' . admin_url( 'options-permalink.php' ) . '">' . __( 'update permalink structure' ) . '</a>' . __( ' to something other than the default for it to work.', 'rtmedia' ) . ' </p>
228
</div>';
229
}
230
231
+ /**
232
+ * Define rtmedia addon update notice.
233
+ *
234
+ * @access public
235
+ * @param void
236
+ * @return void
237
+ */
238
+ public function rtmedia_addon_update_notice() {
239
if ( ! $this->check_for_addon_update_notice() ){
240
return;
241
}
265
}
266
}
267
268
+ /**
269
+ * Show rtmedia addon update notice.
270
+ *
271
+ * @access public
272
+ * @param void
273
+ * @return bool $return_falg
274
+ */
275
+ public function check_for_addon_update_notice() {
276
$return_falg = false;
277
+
278
if ( defined( 'RTMEDIA_INSTAGRAM_PATH' ) ){
279
$plugin_info = get_plugin_data( RTMEDIA_INSTAGRAM_PATH . 'index.php' );
280
if ( isset( $plugin_info[ 'Version' ] ) && $plugin_info[ 'Version' ] < "2.1.2" ){
313
return $return_falg;
314
}
315
316
+ /**
317
+ * Show buddypress admin tabs.
318
+ *
319
+ * @access public
320
+ * @param void
321
+ * @return void
322
+ */
323
+ public function bp_admin_tabs() {
324
if ( current_user_can( 'manage_options' ) ){
325
add_action( 'bp_admin_tabs', array( $this, 'tab' ) );
326
}
327
}
328
329
+ /**
330
+ * Show rtmedia advertisement.
331
+ *
332
+ * @access public
333
+ * @param void
334
+ * @return void
335
+ */
336
+ public function rtmedia_advertisement() {
337
$src = RTMEDIA_URL . "app/assets/img/rtMedia-pro-ad.png"
338
?>
339
<div class='rtmedia-admin-ad'>
344
<?php
345
}
346
347
+ /**
348
+ * Create the function to output the contents of our Dashboard Widget
349
+ *
350
+ * @access public
351
+ * @param void
352
+ * @return void
353
+ */
354
+ public function rtMedia_dashboard_widget_function() {
355
?>
356
357
<div class="inside">
430
<?php
431
}
432
433
+ /**
434
+ * Create the function use in the action hook
435
+ *
436
+ * @access public
437
+ * @param void
438
+ * @return void
439
+ */
440
+ public function add_dashboard_widgets() {
441
wp_add_dashboard_widget( 'rtmedia_dashboard_widget', __( 'Right Now in rtMedia', 'rtmedia' ), array( &$this, 'rtMedia_dashboard_widget_function' ) );
442
global $wp_meta_boxes;
443
460
$wp_meta_boxes[ 'dashboard' ][ 'normal' ][ 'core' ] = $sorted_dashboard;
461
}
462
463
+ /**
464
+ * Add the plugin settings links
465
+ *
466
+ * @access public
467
+ * @param array $links
468
+ * @return array $links
469
+ */
470
+ public function plugin_add_settings_link( $links ) {
471
$settings_link = '<a href="' . admin_url( 'admin.php?page=rtmedia-settings' ) . '">Settings</a>';
472
array_push( $links, $settings_link );
473
$settings_link = '<a href="' . admin_url( 'admin.php?page=rtmedia-support' ) . '">Support</a>';
476
return $links;
477
}
478
479
+ /**
480
+ * Add the reencode link
481
+ *
482
+ * @access public
483
+ * @param array $actions
484
+ * @param object $post
485
+ * @return array $actions
486
+ */
487
+ public function add_reencode_link( $actions, $post ) {
488
489
$mime_type_array = explode( "/", $post->post_mime_type );
490
if ( is_array( $mime_type_array ) && $mime_type_array != "" && $mime_type_array[ 0 ] == "video" ){
494
return $actions;
495
}
496
497
+ /**
498
+ * Do the bulk video/media handler.
499
+ *
500
+ * @access public
501
+ * @param void
502
+ * @return void
503
+ */
504
+ public function bulk_action_handler() {
505
if ( $_REQUEST[ 'action' ] == "bulk_video_regenerate_thumbnails" && $_REQUEST[ 'media' ] != "" ){
506
wp_safe_redirect( add_query_arg( array( "media_ids" => urlencode( implode( ",", $_REQUEST[ "media" ] ) ) ), admin_url( "admin.php?page=rtmedia-regenerate" ) ) );
507
exit;
508
}
509
}
510
511
+ /**
512
+ * Add admin bar menu
513
+ *
514
+ * @access public
515
+ * @param type $admin_bar
516
+ * @return void
517
+ */
518
+ public function admin_bar_menu( $admin_bar ) {
519
if ( ! current_user_can( 'manage_options' ) ){
520
return;
521
}
555
/**
556
* Generates the Admin UI.
557
*
558
+ * @access public
559
+ * @param string $hook
560
+ * @return void
561
*/
562
public function ui( $hook ) {
563
$admin_pages = array(
564
'rtmedia_page_rtmedia-migration', 'rtmedia_page_rtmedia-kaltura-settings', 'rtmedia_page_rtmedia-ffmpeg-settings', 'toplevel_page_rtmedia-settings', 'rtmedia_page_rtmedia-addons', 'rtmedia_page_rtmedia-support', 'rtmedia_page_rtmedia-themes', 'rtmedia_page_rtmedia-hire-us', 'rtmedia_page_rtmedia-importer', 'rtmedia_page_rtmedia-regenerate', 'rtmedia_page_rtmedia-premium'
565
);
566
+
567
$admin_pages = apply_filters( 'rtmedia_filter_admin_pages_array', $admin_pages );
568
+
569
if ( in_array( $hook, $admin_pages ) || strpos( $hook, 'rtmedia-migration' ) ){
570
+
571
$admin_ajax = admin_url( 'admin-ajax.php' );
572
573
wp_enqueue_script( 'bootstrap-switch', RTMEDIA_URL . 'app/assets/js/bootstrap-switch.js', array( 'jquery' ), RTMEDIA_VERSION );
579
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_ajax', $admin_ajax );
580
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_url', admin_url() );
581
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_url', admin_url() );
582
+
583
if ( isset( $_REQUEST[ 'page' ] ) && ( in_array( $_REQUEST[ 'page' ], array( "rtmedia-settings", "rtmedia-addons", "rtmedia-themes", "rtmedia-support", "rtmedia-hire-us" ) ) ) ){
584
wp_enqueue_script( 'rtmedia-foundation-modernizr', RTMEDIA_URL . 'lib/foundation/custom.modernizr.js', array( 'jquery' ), RTMEDIA_VERSION );
585
wp_enqueue_script( 'rtmedia-foundation', RTMEDIA_BOWER_COMPONENTS_URL . 'js/foundation.js', array( 'jquery' ), RTMEDIA_VERSION );
589
$rtmedia_admin_strings = array(
590
'no_refresh' => __( 'Please do not refresh this page.', 'rtmedia' ), 'something_went_wrong' => __( 'Something went wronng. Please <a href onclick="location.reload();">refresh</a> page.', 'rtmedia' ), 'are_you_sure' => __( 'This will subscribe you to the free plan.', 'rtmedia' ), 'disable_encoding' => __( 'Are you sure you want to disable the encoding service? Make sure you note your api key before disabling it incase you want to activate it in future.', 'rtmedia' )
591
);
592
+
593
wp_localize_script( 'rtmedia-admin', 'rtmedia_admin_strings', $rtmedia_admin_strings );
594
wp_localize_script( 'rtmedia-admin', 'settings_url', add_query_arg( array( 'page' => 'rtmedia-settings' ), ( is_multisite() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) ) ) . '#privacy_enabled' );
595
wp_localize_script( 'rtmedia-admin', 'settings_rt_album_import_url', add_query_arg( array( 'page' => 'rtmedia-settings' ), ( is_multisite() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) ) ) );
599
wp_enqueue_style( 'grid-foundation', RTMEDIA_URL . 'app/assets/css/grid-foundation.css', '', RTMEDIA_VERSION );
600
wp_enqueue_style( 'rtmedia-main', RTMEDIA_URL . 'app/assets/css/main.css', '', RTMEDIA_VERSION );
601
wp_enqueue_style( 'rtmedia-admin', RTMEDIA_URL . 'app/assets/css/admin.css', '', RTMEDIA_VERSION );
602
+
603
if ( isset( $_REQUEST[ 'page' ] ) && ( in_array( $_REQUEST[ 'page' ], array( "rtmedia-settings", "rtmedia-addons", "rtmedia-themes", "rtmedia-support", "rtmedia-hire-us" ) ) ) ){
604
wp_enqueue_style( 'foundation-admin-css', RTMEDIA_URL . 'app/assets/css/settings.css', '', RTMEDIA_VERSION );
605
}
606
+
607
wp_enqueue_style( 'wp-jquery-ui-dialog' );
608
+
609
} else {
610
wp_enqueue_style( 'rtmedia-widget', RTMEDIA_URL . 'app/assets/css/widget.css', '', RTMEDIA_VERSION );
611
}
612
}
613
614
/**
615
+ * Add Admin Menu.
616
*
617
+ * @access public
618
* @global string 'rtmedia'
619
+ * @param void
620
+ * @return void
621
*/
622
public function menu() {
623
add_menu_page( 'rtMedia', 'rtMedia', 'manage_options', 'rtmedia-settings', array( $this, 'settings_page' ), RTMEDIA_URL . "app/assets/img/rtmedia-logo.png", "40.1111" );
626
add_submenu_page( 'rtmedia-settings', __( 'Support', 'rtmedia' ), __( 'Support', 'rtmedia' ), 'manage_options', 'rtmedia-support', array( $this, 'support_page' ) );
627
add_submenu_page( 'rtmedia-settings', __( 'Themes', 'rtmedia' ), __( 'Themes', 'rtmedia' ), 'manage_options', 'rtmedia-themes', array( $this, 'theme_page' ) );
628
add_submenu_page( 'rtmedia-settings', __( 'Hire Us', 'rtmedia' ), __( 'Hire Us', 'rtmedia' ), 'manage_options', 'rtmedia-hire-us', array( $this, 'hire_us_page' ) );
629
+
630
if ( ! defined( "RTMEDIA_PRO_VERSION" ) ){
631
add_submenu_page( 'rtmedia-settings', __( 'Premium', 'rtmedia' ), __( 'Premium ', 'rtmedia' ), 'manage_options', 'rtmedia-premium', array( $this, 'premium_page' ) );
632
}
633
634
$obj_encoding = new RTMediaEncoding( true );
635
+
636
if ( $obj_encoding->api_key ){
637
add_submenu_page( 'rtmedia-settings', __( 'Regenerate Thumbnail', 'rtmedia' ), __( 'Regen. Thumbnail ', 'rtmedia' ), 'manage_options', 'rtmedia-regenerate', array( $this, 'rt_regenerate_thumbnail' ) );
638
}
643
// }
644
}
645
646
+ /**
647
+ * Define regenerate thumbnail functionality.
648
+ *
649
+ * @access public
650
+ * @param void
651
+ * @return void
652
+ */
653
+ public function rt_regenerate_thumbnail() {
654
$prog = new rtProgress();
655
$done = 0;
656
?>
657
<div class="wrap">
658
+ <h2> rtMedia: <?php _e( 'Regenerate Video Thumbnails', 'rtmedia' ); ?> </h2>
659
<?php
660
if ( isset( $_REQUEST[ "media_ids" ] ) && trim( $_REQUEST[ "media_ids" ] ) != "" ){
661
$requested = false;
672
<?php
673
if ( ! isset( $requested ) ){
674
?>
675
+ <br/>
676
+ <p>You can see this page because you have <a href="<?php echo admin_url('admin.php?page=rtmedia-addons') ?>">subscribed</a> for <a href="https://rtcamp.com/rtmedia/docs/admin/addons/audio-video-encoding/" target="_blank">rtMedia audio/video encoding service</a>.</p>
677
+ <p>You can regenerate thumbnails of specific video by visiting <a href="<?php echo admin_url('upload.php?post_mime_type=video'); ?>" >media page</a> and click on <b>Regenerate Thumbnail</b> option for that particular video.</p>
678
+ <p>Press <b>Regenerate Pending Thumbnails</b> button to regenerate thumbnails of pending videos.</p>
679
+ <p><input type="button" class="button button-primary" id="rt-start-media-regenerate" value="<?php echo __( 'Regenerate Pending Thumbnails', 'rtmedia' ) . ' (' . $total . ')'; ?>"/></p>
680
<?php } ?>
681
<div id="rt-migration-progress">
682
<br/> <br/>
684
$temp = $prog->progress( $done, $total );
685
$prog->progress_ui( $temp, true );
686
?>
687
+ <p> <?php _e( 'Total Videos', 'rtmedia' ) ?> : <span class='rt-total'><?php echo $total; ?></span></p>
688
689
<p> <?php _e( 'Sent of regenerate thumbails', 'rtmedia' ) ?> : <span class='rt-done'>0</span></p>
690
691
<p> <?php _e( 'Fail to regenerate thumbails', 'rtmedia' ) ?> : <span class='rt-fail'>0</span></p>
692
693
</div>
694
<script>
695
696
var db_done = 0;
698
var db_total = <?php echo $total; ?>;
699
var indx = 0;
700
function db_start_regenrate() {
701
+ if ( indx < db_total ){
702
jQuery.ajax( {
703
url: rtmedia_admin_ajax,
704
type: 'post',
709
success: function ( data ) {
710
data = JSON.parse( data );
711
712
+ if ( data.status == false ){
713
handle_regenrate_fail();
714
} else {
715
db_done++;
716
var progw = Math.ceil( (db_done / db_total) * 100 );
717
+ if ( progw > 100 ){
718
progw = 100;
719
}
720
jQuery( '#rtprogressbar>div' ).css( 'width', progw + '%' );
735
jQuery( 'span.rt-fail' ).html( db_fail );
736
db_start_regenrate();
737
}
738
+ if ( jQuery( "#rt-start-media-regenerate" ).length > 0 ){
739
jQuery( "#rt-migration-progress" ).hide()
740
jQuery( "#rt-start-media-regenerate" ).click( function () {
741
jQuery( this ).hide();
752
</div> <?php
753
}
754
755
+ /**
756
+ * Generate rtmedia thumbnail notice.
757
+ *
758
+ * @access public
759
+ * @param void
760
+ * @return void
761
+ */
762
+ public function rtmedia_regenerate_thumbnail_notice() {
763
$obj_encoding = new RTMediaEncoding( true );
764
if ( $obj_encoding->api_key ){
765
$site_option = rtmedia_get_site_option( "rtmedia-video-thumb-notice" );
790
}
791
}
792
793
+ /**
794
+ * Hide rtmedia video thumb admin notice.
795
+ *
796
+ * @access public
797
+ * @param void
798
+ * @return void
799
+ */
800
+ public function rtmedia_hide_video_thumb_admin_notice() {
801
if ( rtmedia_update_site_option( "rtmedia-video-thumb-notice", "hide" ) ){
802
echo "1";
803
} else {
806
die();
807
}
808
809
+ /**
810
+ * Hide rtmedia addon update notice.
811
+ *
812
+ * @access public
813
+ * @param void
814
+ * @return void
815
+ */
816
+ public function rtmedia_hide_addon_update_notice() {
817
if ( rtmedia_update_site_option( "rtmedia-addon-update-notice", "hide" ) ){
818
echo "1";
819
} else {
822
die();
823
}
824
825
+ /**
826
+ * Define rt_media_regeneration.
827
+ *
828
+ * @access public
829
+ * @param void
830
+ * @return void
831
+ */
832
+ public function rt_media_regeneration() {
833
if ( isset( $_POST[ 'media_id' ] ) ){
834
$model = new RTMediaModel();
835
$media = $model->get_media( array( 'media_id' => $_POST[ 'media_id' ] ), 0, 1 );
850
}
851
852
853
+ /**
854
+ * Get video without thumbs.
855
+ *
856
+ * @access public
857
+ * @param void
858
+ * @return object $results
859
+ */
860
+ public function get_video_without_thumbs() {
861
$rtmedia_model = new RTMediaModel();
862
$sql = "select media_id from {$rtmedia_model->table_name} where media_type = 'video' and blog_id = '" . get_current_blog_id() . "' and cover_art is null";
863
global $wpdb;
867
}
868
869
/**
870
+ * Render the BuddyPress Media Settings page.
871
+ *
872
+ * @access public
873
+ * @param void
874
+ * @return void
875
*/
876
public function settings_page() {
877
$this->render_page( 'rtmedia-settings', 'rtmedia' );
878
}
879
880
+ /**
881
+ * Render the BuddyPress Privacy Settings page.
882
+ *
883
+ * @access public
884
+ * @param void
885
+ * @return void
886
+ */
887
public function privacy_page() {
888
$this->render_page( 'rtmedia-privacy' );
889
}
890
891
+ /**
892
+ * Render the rtmedia Importer Page.
893
+ *
894
+ * @access public
895
+ * @param void
896
+ * @return void
897
+ */
898
public function rt_importer_page() {
899
$this->render_page( 'rtmedia-importer' );
900
}
901
902
+ /**
903
+ * Render the rtmedia convert videos page.
904
+ *
905
+ * @access public
906
+ * @param void
907
+ * @return void
908
+ */
909
public function convert_videos_page() {
910
$this->render_page( 'rtmedia-convert-videos' );
911
}
912
913
/**
914
+ * Render the BuddyPress Media Addons page.
915
+ *
916
+ * @access public
917
+ * @param void
918
+ * @return void
919
*/
920
public function addons_page() {
921
$this->render_page( 'rtmedia-addons' );
922
}
923
924
/**
925
+ * Render the BuddyPress Media Support page.
926
+ *
927
+ * @access public
928
+ * @param void
929
+ * @return void
930
*/
931
public function support_page() {
932
$this->render_page( 'rtmedia-support' );
933
}
934
935
+ /**
936
+ * Render the rtmedia premium page.
937
+ *
938
+ * @access public
939
+ * @param void
940
+ * @return void
941
+ */
942
public function premium_page() {
943
$this->render_page( 'rtmedia-premium' );
944
}
945
946
+ /**
947
+ * Render the rtmedia theme page.
948
+ *
949
+ * @access public
950
+ * @param void
951
+ * @return void
952
+ */
953
public function theme_page() {
954
$this->render_page( 'rtmedia-themes' );
955
}
956
957
+ /**
958
+ * Render the rtmedia hire us page.
959
+ *
960
+ * @access public
961
+ * @param void
962
+ * @return void
963
+ */
964
public function hire_us_page() {
965
$this->render_page( 'rtmedia-hire-us' );
966
}
967
968
/**
969
+ * Render the rtmedia hire us page.
970
*
971
+ * @access static
972
+ * @param void
973
* @return type
974
*/
975
static function get_current_tab() {
977
}
978
979
/**
980
+ * Render BPMedia Settings.
981
*
982
+ * @access public
983
* @global string 'rtmedia'
984
+ * @param type $page
985
+ * @param type $option_group
986
+ * @return void
987
*/
988
public function render_page( $page, $option_group = null ) {
989
?>
1011
<?php if ( $option_group ){ //$option_group if ($page == "bp-media-settings") action="<?php echo $settings_url; ?>
1012
<form id="bp_media_settings_form" name="bp_media_settings_form" method="post"
1013
enctype="multipart/form-data">
1014
+ <div class="bp-media-metabox-holder"><?php
1015
+ settings_fields( $option_group );
1016
+ if ( $page == "rtmedia-settings" ){
1017
1018
1019
+ echo '<div id="rtm-settings-tabs">';
1020
+ $sub_tabs = $this->settings_sub_tabs();
1021
+ RTMediaFormHandler::rtForm_settings_tabs_content( $page, $sub_tabs );
1022
+ echo '</div>';
1023
+ } else {
1024
+ do_settings_sections( $page );
1025
+ }
1026
+ ?>
1027
+ <div class="clearfix">&nbsp;</div>
1028
+ <div class="row">
1029
+ <input type="hidden" name="rtmedia-options-save" value="true">
1030
+ <input type="submit" id="rtmedia-settings-submit"
1031
+ class="rtmedia-settings-submit button button-primary button-big"
1032
+ value="<?php _e( 'Save Settings', 'rtmedia' ); ?>">
1033
+ </div>
1034
</div>
1035
</form><?php
1036
} else {
1037
?>
1075
/**
1076
* Adds a tab for Media settings in the BuddyPress settings page
1077
*
1078
+ * @access public
1079
* @global type $bp_media
1080
+ * @param void
1081
+ * @param void
1082
+ * @return type $tabs_html
1083
*/
1084
public function tab() {
1085
1102
echo $tabs_html;
1103
}
1104
1105
+ /**
1106
+ * Create core admin tabs.
1107
+ *
1108
+ * @access public
1109
+ * @param type $active_tab
1110
+ * @return void
1111
+ */
1112
public function rtmedia_tabs( $active_tab = '' ) {
1113
// Declare local variables
1114
$tabs_html = '';
1141
foreach ( array_values( $tabs ) as $tab_data ) {
1142
$is_current = ( bool )( $tab_data[ 'slug' ] == $this->get_current_tab() );
1143
$tab_class = $is_current ? $active_class : $idle_class;
1144
+
1145
if ( isset( $tab_data[ 'class' ] ) && is_array( $tab_data[ 'class' ] ) ){
1146
$tab_class .= " " . implode( " ", $tab_data[ 'class' ] );
1147
}
1148
+
1149
$tabs_html .= '<a href="' . $tab_data[ 'href' ] . '" class="' . $tab_class . '">' . $tab_data[ 'name' ] . '</a>';
1150
}
1151
1156
// do_action('bp_media_admin_tabs');
1157
}
1158
1159
+ /**
1160
+ * Create settings content tabs.
1161
+ *
1162
+ * @access public
1163
+ * @param type $page
1164
+ * @return void
1165
+ */
1166
public function settings_content_tabs( $page ) {
1167
global $wp_settings_sections, $wp_settings_fields;
1168
1179
call_user_func( $section[ 'callback' ], $section );
1180
}
1181
1182
+ if ( ! isset ( $wp_settings_fields ) || ! isset ( $wp_settings_fields[ $page ] )
1183
+ || ! isset ( $wp_settings_fields[ $page ][ $section[ 'id' ] ] ) ){
1184
continue;
1185
}
1186
+
1187
echo '<table class="form-table">';
1188
do_settings_fields( $page, $section[ 'id' ] );
1189
echo '</table>';
1193
/**
1194
* Adds a sub tabs to the BuddyPress Media settings page
1195
*
1196
+ * @access public
1197
* @global type $bp_media
1198
+ * @param void
1199
+ * @return array $tabs
1200
*/
1201
public function settings_sub_tabs() {
1202
$tabs_html = '';
1211
);
1212
1213
1214
+ if ( class_exists( "BuddyPress" ) ) {
1215
$tabs[ 20 ] = array(
1216
'href' => '#rtmedia-bp', 'icon' => 'rtmicon-group', 'title' => __( 'rtMedia BuddyPress', 'rtmedia' ), 'name' => __( 'BuddyPress', 'rtmedia' ), 'callback' => array( 'RTMediaFormHandler', 'buddypress_content' ) //change it to BuddyPress Content
1217
);
1241
return $tabs;
1242
}
1243
1244
/**
1245
+ * Updates the media count of all users.
1246
*
1247
+ * @access public
1248
* @global type $wpdb
1249
+ * @param void
1250
* @return boolean
1251
*/
1252
public function update_count() {
1253
global $wpdb;
1254
1255
$query = "SELECT
1256
+ p.post_author,pmp.meta_value,
1257
+ SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
1258
+ SUM(CASE WHEN post_mime_type LIKE 'music%' THEN 1 ELSE 0 END) as Music,
1259
+ SUM(CASE WHEN post_mime_type LIKE 'video%' THEN 1 ELSE 0 END) as Videos,
1260
+ SUM(CASE WHEN post_type LIKE 'bp_media_album' THEN 1 ELSE 0 END) as Albums
1261
+ FROM
1262
+ $wpdb->posts p inner join $wpdb->postmeta pm on pm.post_id = p.id INNER JOIN $wpdb->postmeta pmp
1263
+ on pmp.post_id = p.id WHERE
1264
+ pm.meta_key = 'bp-media-key' AND
1265
+ pm.meta_value > 0 AND
1266
+ pmp.meta_key = 'bp_media_privacy' AND
1267
+ ( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'music%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
1268
+ GROUP BY p.post_author,pmp.meta_value order by p.post_author";
1269
+
1270
$result = $wpdb->get_results( $query );
1271
+
1272
if ( ! is_array( $result ) ){
1273
return false;
1274
}
1275
+
1276
$formatted = array();
1277
+
1278
foreach ( $result as $obj ) {
1279
$formatted[ $obj->post_author ][ $obj->meta_value ] = array(
1280
'image' => $obj->Images, 'video' => $obj->Videos, 'music' => $obj->Music, 'album' => $obj->Albums,
1288
return true;
1289
}
1290
1291
/**
1292
+ * Multisite Save Options - http://wordpress.stackexchange.com/questions/64968/settings-api-in-multisite-missing-update-message#answer-72503
1293
*
1294
+ * @access public
1295
+ * @global type $rtmedia_admin
1296
+ * @param void
1297
+ * @return void
1298
*/
1299
public function save_multisite_options() {
1300
global $rtmedia_admin;
1306
if ( isset ( $_POST[ 'rtmedia_options' ] ) ){
1307
rtmedia_update_site_option( 'rtmedia_options', $_POST[ 'rtmedia_options' ] );
1308
//
1309
+ // redirect to settings page in network
1310
wp_redirect( add_query_arg( array( 'page' => 'rtmedia-settings', 'updated' => 'true' ), ( is_multisite() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) ) ) );
1311
exit;
1312
}
1313
}
1314
1315
/**
1316
+ * Admin Sidebar
1317
*
1318
+ * @access public
1319
* @global type $bp_media
1320
+ * @param void
1321
+ * @return void
1322
*/
1323
public function admin_sidebar() {
1324
do_action( 'rtmedia_before_default_admin_widgets' );
1460
jQuery( '.update-network-settings-upload-filetypes' ).siblings( 'img' ).show();
1461
jQuery( '.update-network-settings-upload-filetypes' ).prop( 'disabled', true );
1462
jQuery.post( ajaxurl, {action: 'rtmedia_correct_upload_filetypes'}, function ( response ) {
1463
+ if ( response ){
1464
jQuery( '.upload-filetype-network-settings-error:first' ).after( '<div style="display: none;" class="updated rtmedia-network-settings-updated-successfully"><p><?php _e( 'Network settings updated successfully.', 'rtmedia' ); ?></p></div>' )
1465
jQuery( '.upload-filetype-network-settings-error' ).remove();
1466
jQuery( '.bp-media-network-settings-updated-successfully' ).show();
1467
}
1468
} );
1469
+ } );
1470
+ </script>
1471
+ <?php
1472
}
1473
}
1474
1516
$video_thumb_html = "";
1517
if ( is_array( $thumbnail_array ) ){
1518
$video_thumb_html .= '<ul> ';
1519
+
1520
foreach ( $thumbnail_array as $key => $thumbnail_src ) {
1521
$checked = checked( $thumbnail_src, $rtmedia_media[ 0 ]->cover_art, false );
1522
$count = $key + 1;
1556
function rtmedia_regenerate_thumb_js() {
1557
global $pagenow;
1558
1559
+ if ( $pagenow == 'upload.php' ) {
1560
?>
1561
<script type="text/javascript">
1562
function rtmedia_regenerate_thumbs( post_id ) {
1563
+ if ( post_id != "" ){
1564
var data = {
1565
action: 'rt_media_regeneration',
1566
media_id: post_id
1567
};
1568
jQuery.post( ajaxurl, data, function ( data ) {
1569
data = JSON.parse( data );
1570
+ if ( data.status === true ){
1571
alert( "<?php _e('Video is sent to generate thumbnails.', 'rtmedia') ?>" );
1572
+ } else {
1573
alert( "<?php _e('Video can\'t be sent to generate thumbnails.', 'rtmedia') ?>" );
1574
}
1575
} );
1605
// Start of Metrics
1606
global $wpdb;
1607
$data = get_transient( 'presstrends_cache_data' );
1608
+
1609
if ( ! $data || $data == '' ){
1610
$api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update?auth=';
1611
$url = $api_base . $auth . '&api=' . $api_key . '';
1612
$count_posts = wp_count_posts();
1613
$count_pages = wp_count_posts( 'page' );
1614
$comments_count = wp_count_comments();
1615
+
1616
if ( function_exists( 'wp_get_theme' ) ){
1617
$theme_data = wp_get_theme();
1618
$theme_name = urlencode( $theme_data->Name );
1620
$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
1621
$theme_name = $theme_data[ 'Name' ];
1622
}
1623
+
1624
$plugin_name = '&';
1625
+
1626
foreach ( get_plugins() as $plugin_info ) {
1627
$plugin_name .= $plugin_info[ 'Name' ] . '&';
1628
}
1629
+
1630
// CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
1631
$plugin_data = get_plugin_data( __FILE__ );
1632
$posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
1633
$data = array(
1634
'url' => base64_encode( site_url() ), 'posts' => $count_posts->publish, 'pages' => $count_pages->publish, 'comments' => $comments_count->total_comments, 'approved' => $comments_count->approved, 'spam' => $comments_count->spam, 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ), 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0, 'theme_version' => $plugin_data[ 'Version' ], 'theme_name' => $theme_name, 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ), 'plugins' => count( get_option( 'active_plugins' ) ), 'plugin' => urlencode( $plugin_name ), 'wpversion' => get_bloginfo( 'version' ),
1635
);
1636
+
1637
foreach ( $data as $k => $v ) {
1638
$url .= '&' . $k . '=' . $v . '';
1639
}
1640
+
1641
wp_remote_get( $url );
1642
set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
1643
}
1644
}
1645
1646
function rtmedia_update_template_notice() {
1647
+ $site_option = rtmedia_get_site_option( "rtmedia-update-template-notice-v3_7_3" );
1648
+
1649
if ( ! $site_option || $site_option != "hide" ){
1650
+ rtmedia_update_site_option( "rtmedia-update-template-notice-v3_7_3", "show" );
1651
if ( is_dir( get_template_directory() . '/rtmedia' ) ){
1652
echo '<div class="error rtmedia-update-template-notice"><p>' . __( 'Please update rtMedia template files if you have overridden the default rtMedia templates in your theme. If not, you can ignore and hide this notice.' ) . '<a href="#" onclick="rtmedia_hide_template_override_notice()" style="float:right">' . __( 'Hide', 'rtmedia' ) . '</a>' . ' </p></div>';
1653
?>
1668
1669
function rtmedia_hide_template_override_notice() {
1670
1671
+ if ( rtmedia_update_site_option( "rtmedia-update-template-notice-v3_7_3", "hide" ) ){
1672
echo "1";
1673
} else {
1674
echo "0";
app/admin/RTMediaFormHandler.php CHANGED
@@ -12,7 +12,7 @@
12
*/
13
class RTMediaFormHandler {
14
15
- public static function selectBox($args) {
16
global $rtmedia;
17
$options = $rtmedia->options;
18
$defaults = array(
@@ -22,58 +22,74 @@ class RTMediaFormHandler {
22
'show_desc' => false,
23
'selects' => array()
24
);
25
- $args = wp_parse_args($args, $defaults);
26
- extract($args);
27
28
- if (!empty($key)) {
29
$args['name'] = 'rtmedia-options[' . $key . ']';
30
}
31
32
$args['rtForm_options'] = array();
33
- foreach ($selects as $value => $key) {
34
$args['rtForm_options'][] = array(
35
$key => $value,
36
- 'selected' => ($default == $value) ? true : false
37
);
38
}
39
40
$chkObj = new rtForm();
41
- echo $chkObj->get_select($args);
42
}
43
44
- public static function textarea($args, $echo = true) {
45
global $rtmedia;
46
$options = $rtmedia->options;
47
$defaults = array(
48
- 'id' => '',
49
'key' => '',
50
'desc' => '',
51
'show_desc' => false
52
);
53
- $args = wp_parse_args($args, $defaults);
54
- extract($args);
55
56
- if (!isset($value)) {
57
- trigger_error(__('Please provide "value" in the argument.', 'rtmedia'));
58
return;
59
}
60
61
- if (!empty($key)) {
62
$args['name'] = 'rtmedia-options[' . $key . ']';
63
}
64
65
- $args['rtForm_options'] = array(array('' => 1, 'checked' => $value));
66
67
$chkObj = new rtForm();
68
- if( $echo ) {
69
- echo $chkObj->get_textarea($args);
70
- } else {
71
- return $chkObj->get_textarea($args);
72
- }
73
- }
74
75
- public static function checkbox($args, $echo = true) {
76
77
global $rtmedia;
78
$options = $rtmedia->options;
79
$defaults = array(
@@ -81,243 +97,292 @@ class RTMediaFormHandler {
81
'desc' => '',
82
'show_desc' => false
83
);
84
- $args = wp_parse_args($args, $defaults);
85
- extract($args);
86
87
- if (!isset($value)) {
88
- trigger_error(__('Please provide "value" in the argument.', 'rtmedia'));
89
return;
90
}
91
92
- if (!empty($key)) {
93
$args['name'] = 'rtmedia-options[' . $key . ']';
94
}
95
96
- $args['rtForm_options'] = array(array('' => 1, 'checked' => $value));
97
98
$chkObj = new rtForm();
99
// echo $chkObj->get_checkbox($args);
100
- if( $echo )
101
- echo $chkObj->get_switch($args);
102
- else
103
- return $chkObj->get_switch($args);
104
// echo $chkObj->get_switch_square($args);
105
}
106
107
- public static function radio($args) {
108
-
109
global $rtmedia;
110
- $options = $rtmedia->options;
111
$defaults = array(
112
'key' => '',
113
'radios' => array(),
114
'default' => '',
115
'show_desc' => false
116
);
117
- $args = wp_parse_args($args, $defaults);
118
- extract($args);
119
120
- if (2 > count($radios)) {
121
- trigger_error(__('Need to specify atleast to radios else use a checkbox instead', 'rtmedia'));
122
return;
123
}
124
125
- if (!empty($key))
126
$args['name'] = 'rtmedia-options[' . $key . ']';
127
128
$args['rtForm_options'] = array();
129
- foreach ($radios as $value => $key) {
130
$args['rtForm_options'][] = array(
131
$key => $value,
132
- 'checked' => ($default == $value) ? true : false
133
);
134
}
135
136
$objRad = new rtForm();
137
- echo $objRad->get_radio($args);
138
}
139
140
- public static function dimensions($args) {
141
-
142
$dmnObj = new rtDimensions();
143
- echo $dmnObj->get_dimensions($args);
144
}
145
146
- public static function number($args) {
147
global $rtmedia;
148
$options = $rtmedia->options;
149
$defaults = array(
150
'key' => '',
151
'desc' => ''
152
);
153
- $args = wp_parse_args($args, $defaults);
154
- extract($args);
155
156
- if (!isset($value)) {
157
- trigger_error(__('Please provide "value" in the argument.', 'rtmedia'));
158
return;
159
}
160
161
- if (!empty($key)) {
162
$args['name'] = 'rtmedia-options[' . $key . ']';
163
}
164
165
$args['value'] = $value;
166
167
$numObj = new rtForm();
168
- echo $numObj->get_number($args);
169
}
170
171
- public static function textbox($args) {
172
global $rtmedia;
173
$options = $rtmedia->options;
174
$defaults = array(
175
'key' => '',
176
'desc' => ''
177
);
178
- $args = wp_parse_args($args, $defaults);
179
- extract($args);
180
181
- if (!isset($value)) {
182
- trigger_error(__('Please provide "value" in the argument.', 'rtmedia'));
183
return;
184
}
185
186
- if (!empty($key)) {
187
$args['name'] = 'rtmedia-options[' . $key . ']';
188
}
189
190
$args['value'] = $value;
191
192
$numObj = new rtForm();
193
- echo $numObj->get_textbox($args);
194
}
195
196
- static function extract_settings($section_name,$options) {
197
$section = array();
198
- foreach ($options as $key => $value) {
199
- if(strncmp($key, $section_name, strlen($section_name))==0)
200
$section[$key] = $value;
201
}
202
return $section;
203
}
204
205
- static function display_render_options($options) {
206
- $radios = array();
207
- $radios[ 'load_more' ] = "<strong>Load More</strong>";
208
- $radios[ 'pagination' ] = "<strong>Pagination</strong>";
209
-
210
- if (is_plugin_active('regenerate-thumbnails/regenerate-thumbnails.php')) {
211
- $regenerate_link = admin_url('/tools.php?page=regenerate-thumbnails');
212
- }
213
- elseif (array_key_exists('regenerate-thumbnails/regenerate-thumbnails.php', get_plugins())) {
214
- $regenerate_link = admin_url('/plugins.php#regenerate-thumbnails');
215
}
216
- else {
217
- $regenerate_link = wp_nonce_url(admin_url('update.php?action=install-plugin&plugin=regenerate-thumbnails'), 'install-plugin_regenerate-thumbnails');
218
- }
219
- $render = array(//
220
'general_enableComments' => array(
221
- 'title' => __('Allow user to comment on uploaded media','rtmedia'),
222
- 'callback' => array('RTMediaFormHandler', 'checkbox'),
223
'args' => array(
224
'key' => 'general_enableComments',
225
'value' => $options['general_enableComments'],
226
- 'desc' => __('This will display comment form and comment listing on single media pages as well as inside lightbox (if lightbox is enabled).','rtmedia')
227
),
228
'group' => "10"
229
),
230
'general_enableLightbox' => array(
231
- 'title' => __('Use lightbox to display media','rtmedia'),
232
- 'callback' => array('RTMediaFormHandler', 'checkbox'),
233
'args' => array(
234
'key' => 'general_enableLightbox',
235
'value' => $options['general_enableLightbox'],
236
- 'desc' => __('View single media in facebook style lightbox.','rtmedia')
237
),
238
'group' => "15"
239
),
240
'general_perPageMedia' => array(
241
- 'title' => __('Number of media per page','rtmedia'),
242
- 'callback' => array('RTMediaFormHandler', 'number'),
243
'args' => array(
244
'key' => 'general_perPageMedia',
245
'value' => $options['general_perPageMedia'],
246
- 'class' => array('rtmedia-setting-text-box'),
247
- 'desc' => __('Number of media you want to show per page on front end.','rtmedia'),
248
'min' => 1
249
),
250
'group' => "15"
251
),
252
'general_display_media' => array(
253
- 'title' => __('Media display pagination option','rtmedia'),
254
- 'callback' => array('RTMediaFormHandler', 'radio'),
255
'args' => array(
256
'key' => 'general_display_media',
257
'radios' => $radios,
258
'default' => $options['general_display_media'],
259
- 'desc' => __('Choose whether you want load more button or pagination buttons.','rtmedia'),
260
'class' => array( 'rtmedia-load-more-radio' )
261
),
262
'group' => "15"
263
),
264
'general_masonry_layout' => array(
265
- 'title' => __('Enable','rtmedia') . ' <a href="http://masonry.desandro.com/" target="_blank">Masonry</a> '. __( 'Cascading grid layout', 'rtmedia'),
266
- 'callback' => array('RTMediaFormHandler', 'checkbox'),
267
'args' => array(
268
'key' => 'general_masonry_layout',
269
'value' => $options['general_masonry_layout'],
270
- 'desc' => __('Masonry works by placing elements in optimal position based on available vertical space, sort of like a mason fitting stones in a wall.','rtmedia'),
271
- 'class' => array('rtm_enable_masonry_view'),
272
),
273
'group' => "18",
274
- 'after_content' => __( 'You might need to', 'rtmedia') . ' <a id="rtm-masonry-change-thumbnail-info" href="' . get_admin_url() . 'admin.php?page=rtmedia-settings#rtmedia-sizes">' . __( 'change thumbnail size', 'rtmedia' ) . '</a> ' . __( 'and uncheck the crop box for thumbnails.', 'rtmedia' ) . '<br />' . __( 'If you enable masonry view, it is advisable to', 'rtmedia' ) . ' <a href="'.$regenerate_link.'">regenerate thumbnail</a> ' . __( 'for masonry view.', 'rtmedia' ) . '<br />' . __( 'To set gallery for fixed width, set image height to 0 and width as per your requirement and vice-versa.', 'rtmedia'),
275
),
276
);
277
278
return $render;
279
}
280
281
public static function display_content() {
282
global $rtmedia;
283
// $options = self::extract_settings('general', $rtmedia->options);
284
$options = $rtmedia->options;
285
- $render_options = self::display_render_options($options);
286
// $render_options = apply_filters('rtmedia_general_content_single_view_add_itmes',$render_options, $options);
287
- $render_options = apply_filters("rtmedia_display_content_add_itmes",$render_options, $options);
288
$general_group = array();
289
$general_group[10] = "Single Media View";
290
$general_group[15] = "List Media View";
291
$general_group[18] = "Masonry View";
292
- $general_group = apply_filters("rtmedia_display_content_groups", $general_group);
293
- ksort($general_group);
294
$html = '';
295
- foreach($general_group as $key => $value) {
296
?>
297
<div class="postbox metabox-holder">
298
<h3 class="hndle"><span><?php echo $value; ?></span></h3>
299
<?php
300
- foreach ($render_options as $tab => $option) {
301
302
- if(!isset($option['group'])) {
303
- $option['group'] = "20";
304
- }
305
306
- if($option['group'] != $key) {
307
- continue;
308
- }
309
- ?>
310
- <div class="row section">
311
- <div class="columns large-9">
312
- <?php echo $option['title']; ?>
313
- </div>
314
- <div class="columns large-3">
315
- <?php call_user_func($option['callback'], $option['args']); ?>
316
- <span data-tooltip class="has-tip" title="<?php echo (isset($option['args']['desc'])) ? $option['args']['desc'] : "NA"; ?>"><i class="rtmicon-info-circle"></i></span>
317
</div>
318
- </div>
319
<?php
320
- if( isset( $option['after_content'] ) ) {
321
?>
322
<div class="row">
323
<div class="columns large-12">
@@ -326,7 +391,7 @@ class RTMediaFormHandler {
326
</p>
327
</div>
328
</div>
329
- <?php
330
}
331
}
332
?>
@@ -336,115 +401,130 @@ class RTMediaFormHandler {
336
337
}
338
339
- static function render_general_content($options) {
340
$render = array(
341
'general_AllowUserData' => array(
342
- 'title' => __('Allow usage data tracking','rtmedia'),
343
- 'callback' => array('RTMediaFormHandler', 'checkbox'),
344
'args' => array(
345
'key' => 'general_AllowUserData',
346
'value' => $options['general_AllowUserData'],
347
- 'desc' => __('You can help rtMedia team learn what themes and plugins you are using to make rtMedia better compatible with your sites. No private information about your setup will be sent during tracking.','rtmedia')
348
)
349
),
350
'general_showAdminMenu' => array(
351
- 'title' => __('Admin bar menu integration','rtmedia'),
352
- 'callback' => array('RTMediaFormHandler', 'checkbox'),
353
'args' => array(
354
'key' => 'general_showAdminMenu',
355
'value' => $options['general_showAdminMenu'],
356
- 'desc' => __('Add rtMedia menu to WordPress admin bar for easy access to settings and moderation page (if enabled).','rtmedia')
357
),
358
'group' => 10
359
),//
360
'rtmedia_add_linkback' => array(
361
- 'title' => __('Add a link to rtMedia in footer','rtmedia'),
362
- 'callback' => array('RTMediaFormHandler', 'checkbox'),
363
'args' => array(
364
'key' => 'rtmedia_add_linkback',
365
'value' => $options['rtmedia_add_linkback'],
366
- 'desc' => __('Help us to promote rtMedia.','rtmedia')
367
),
368
'group' => 100
369
),//
370
'rtmedia_affiliate_id' => array(
371
- 'title' => __('Also add my affiliate-id to rtMedia footer link','rtmedia'),
372
- 'callback' => array('RTMediaFormHandler', 'textbox'),
373
'args' => array(
374
'key' => 'rtmedia_affiliate_id',
375
'value' => $options['rtmedia_affiliate_id'],
376
- 'desc' => __('Add your affiliate-id along with footer link and get benefited from our affiliation program.','rtmedia')
377
),
378
'group' => 100,
379
- 'after_content' => __('You can signup for rtMedia affiliate program from <a href="https://rtcamp.com/affiliates">here</a>'),
380
),//
381
'rtmedia_enable_api' => array(
382
- 'title' => __('Enable JSON API','rtmedia'),
383
- 'callback' => array('RTMediaFormHandler', 'checkbox'),
384
'args' => array(
385
'key' => 'rtmedia_enable_api',
386
'value' => $options['rtmedia_enable_api'],
387
- 'desc' => __('This will allow handling API requests for rtMedia sent through any mobile app.','rtmedia')
388
),
389
'group' => 80,
390
- 'after_content' => __('You can refer API document from <a href="https://rtcamp.com/rtmedia/docs/developer/json-api/">here</a>'),
391
),//
392
);
393
394
return $render;
395
}
396
- static function general_content($options) {
397
global $rtmedia;
398
// $options = self::extract_settings('general', $rtmedia->options);
399
$options = $rtmedia->options;
400
$render_options = self::render_general_content($options);
401
- $render_options = apply_filters("rtmedia_general_content_add_itmes",$render_options, $options);
402
$general_group = array();
403
$general_group[10] = "Admin Settings";
404
$general_group[80] = "API Settings";
405
$general_group[90] = "Miscellaneous";
406
$general_group[100] = "Footer Link";
407
- $general_group = apply_filters("rtmedia_general_content_groups", $general_group);
408
- ksort($general_group);
409
$html = '';
410
- foreach($general_group as $key => $value) {
411
?>
412
<div class="postbox metabox-holder">
413
<h3 class="hndle"><span><?php echo $value; ?></span></h3>
414
<?php
415
- foreach ($render_options as $tab => $option) {
416
417
- if(!isset($option['group'])) {
418
- $option['group'] = "90";
419
- }
420
421
- if($option['group'] != $key) {
422
- continue;
423
- }
424
- ?>
425
- <div class="row section">
426
- <div class="columns large-7">
427
- <?php echo $option['title']; ?>
428
- </div>
429
- <div class="columns large-5">
430
- <?php call_user_func($option['callback'], $option['args']); ?>
431
- <span data-tooltip class="has-tip" title="<?php echo (isset($option['args']['desc'])) ? $option['args']['desc'] : "NA"; ?>"><i class="rtmicon-info-circle"></i></span>
432
- </div>
433
- </div>
434
- <?php
435
- if( isset( $option['after_content'] ) ) {
436
- ?>
437
- <div class="row">
438
- <div class="columns large-12">
439
- <p class="rtmedia-info rtmedia-admin-notice">
440
- <?php echo $option['after_content']; ?>
441
- </p>
442
</div>
443
- </div>
444
- <?php
445
- }
446
- ?>
447
- <?php
448
}
449
?>
450
</div>
@@ -452,176 +532,217 @@ class RTMediaFormHandler {
452
}
453
}
454
455
- static function get_type_details($allowed_types, $key) {
456
- foreach ($allowed_types as $type) {
457
- if($type['name']==$key) {
458
$data = array(
459
'name' => $type['label'],
460
'extn' => $type['extn']
461
);
462
- if ( isset ( $type['settings_visibility'] ) ) {
463
- $data['settings_visibility'] = $type['settings_visibility'];
464
}
465
return $data;
466
}
467
}
468
}
469
470
- static function types_render_options($options) {
471
global $rtmedia;
472
473
$render = array();
474
$allowed_media_type = $rtmedia->allowed_types;
475
- $allowed_media_type = apply_filters("rtmedia_allowed_types", $allowed_media_type);
476
477
- foreach ($options as $key => $value) {
478
- $data = explode('_', $key);
479
- if(!isset($render[$data[1]])) {
480
- $render[$data[1]] = self::get_type_details($allowed_media_type, $data[1]);
481
}
482
}
483
- foreach ($options as $key => $value) {
484
- $data = explode('_', $key);
485
$render[$data[1]][$data[2]] = $value;
486
}
487
488
return $render;
489
}
490
491
public static function types_content() {
492
-
493
global $rtmedia;
494
- $options = self::extract_settings('allowedTypes', $rtmedia->options);
495
496
- $render_data = self::types_render_options($options);
497
- ?>
498
<div class="postbox metabox-holder">
499
<h3 class="hndle">
500
<span>Media Types Settings</span>
501
- <?php do_action( 'rtmedia_media_type_setting_message' ); ?>
502
</h3>
503
</div>
504
<div class="rt-table large-12">
505
<div class="row rt-header">
506
- <?php do_action("rtmedia_type_settings_before_heading"); ?>
507
- <div class="columns large-4"><h4><?php _e("Media Type","rtmedia") ?></h4></div>
508
- <div class="columns large-4"><h4 data-tooltip class="has-tip" title="<?php _e("Allows you to upload a particular media type on your post.","rtmedia"); ?>"><abbr><?php _e("Allow Upload","rtmedia"); ?></abbr></h4></div>
509
- <div class="columns large-4"><h4 data-tooltip class="has-tip" title="<?php _e("Put a specific media as a featured content on the post.","rtmedia"); ?>"><abbr><?php _e("Set Featured","rtmedia"); ?></abbr></h4></div>
510
511
- <?php do_action("rtmedia_type_settings_after_heading"); ?>
512
</div>
513
514
- <?php
515
$even = 0;
516
- foreach ($render_data as $key=>$section) {
517
- if( isset($section['settings_visibility']) && $section['settings_visibility'] == true ) {
518
- if( ++$even%2 ) {
519
- echo '<div class="row rt-odd">';
520
- }
521
- else {
522
- echo '<div class="row rt-even">';
523
- }
524
525
- do_action("rtmedia_type_settings_before_body");
526
- echo '<div class="columns large-4">' . $section['name'] . '</div>';
527
- $args = array('key' => 'allowedTypes_'.$key.'_enabled', 'value' => $section['enabled']);
528
- echo '<div class="columns large-4">';
529
- $allow_upload_checkbox = self::checkbox($args, $echo = false );
530
- $allow_upload_checkbox = apply_filters('rtmedia_filter_allow_upload_checkbox', $allow_upload_checkbox , $key, $args);
531
- echo $allow_upload_checkbox;
532
- echo '</div>';
533
- $args = array('key' => 'allowedTypes_'.$key.'_featured', 'value' => $section['featured']);
534
- echo '<div class="columns large-4">';
535
- $featured_checkbox = self::checkbox($args , $echo = false );
536
- $featured_checkbox = apply_filters('rtmedia_filter_featured_checkbox', $featured_checkbox, $key);
537
- echo $featured_checkbox;
538
- echo ' </div>';
539
- if(!isset($section['extn']) || !is_array($section['extn'])) {
540
$section['extn'] = array();
541
- }
542
- $extensions = implode(', ', $section['extn']);
543
- $extensions = apply_filters('rtmedia_type_settings_filter_extension', $extensions , $key) ;
544
- do_action("rtmedia_type_settings_after_body",$key, $section);
545
echo '</div>';
546
echo '<div class="row rtmedia-file-extension-wrap">';
547
- echo '<label class="columns large-3">'.__("File Extensions","rtmedia").':</label>';
548
echo '<label class="columns large-9 rtmedia_type_settings_filter_extension">' . $extensions . '</label>';
549
echo '</div>';
550
551
- } else {
552
- echo "<input type='hidden' value='1' name='rtmedia-options[allowedTypes_" . $key . "_enabled]'>";
553
- echo "<input type='hidden' value='0' name='rtmedia-options[allowedTypes_" . $key . "_featured]'>";
554
- }
555
}
556
echo '</div>';
557
- do_action('rtmedia_after_bp_settings');
558
- do_action('rtmedia_after_media_types_settings');
559
}
560
561
- static function sizes_render_options($options) {
562
-
563
$render = array();
564
- foreach ($options as $key => $value) {
565
- $data = explode('_', $key);
566
- if(!isset($render[$data[1]])) {
567
$render[$data[1]] = array();
568
- $render[$data[1]]['title'] = __($data[1],"rtmedia");
569
}
570
- if(!isset($render[$data[1]][$data[2]])) {
571
$render[$data[1]][$data[2]] = array();
572
- $render[$data[1]][$data[2]]['title'] = __($data[2],"rtmedia");
573
}
574
$render[$data[1]][$data[2]][$data[3]] = $value;
575
}
576
return $render;
577
}
578
579
public static function sizes_content() {
580
-
581
global $rtmedia;
582
- $options = self::extract_settings('defaultSizes',$rtmedia->options);
583
- $render_data = self::sizes_render_options($options);
584
?>
585
- <div class="postbox metabox-holder">
586
- <h3 class="hndle"><span>Media Size Settings</span></h3>
587
- </div>
588
<?php
589
//container
590
echo '<div class="rt-table large-12 rtmedia-size-content-setting">';
591
592
//header
593
echo '<div class="rt-header row">';
594
- echo '<h4 class="columns large-3">' . __("Category","rtmedia") . '</h4>';
595
- echo '<h4 class="columns large-3">' . __("Entity","rtmedia") . '</h4>';
596
- echo '<h4 class="columns large-6"><span class="large-offset-2">' . __("Width","rtmedia") . '</span><span class="large-offset-2">' . __("Height","rtmedia") . '</span><span class="large-offset-2">' . __("Crop","rtmedia") . '</span></h4>';
597
echo'</div>';
598
599
//body
600
$even = 0;
601
- foreach ($render_data as $parent_key => $section) {
602
- if( ++$even%2 )
603
echo '<div class="row rt-odd">';
604
- else
605
echo '<div class="row rt-even">';
606
- echo '<div class="columns large-3">' . ucfirst($section['title']) . '</div>';
607
$entities = $section;
608
- unset($entities['title']);
609
echo '<div class="columns large-3">';
610
- foreach ($entities as $entity) {
611
- echo '<div class="row">' . ucfirst($entity['title']) . '</div>';
612
}
613
echo '</div>';
614
echo '<div class="columns large-6">';
615
- foreach ($entities as $entity) {
616
$args = array(
617
'key' => 'defaultSizes_'.$parent_key.'_'.$entity['title'],
618
);
619
- foreach ($entity as $child_key=>$value) {
620
- if($child_key!='title') {
621
$args[$child_key] = $value;
622
}
623
}
624
- self::dimensions($args);
625
}
626
echo '</div>';
627
echo '</div>';
@@ -629,17 +750,17 @@ class RTMediaFormHandler {
629
630
echo '</div>';
631
$options = $rtmedia->options;
632
- $render_video_thumb =array(
633
- 'title' => __('Number of thumbnails to generate on video upload','rtmedia'),
634
- 'callback' => array('RTMediaFormHandler', 'number'),
635
- 'args' => array(
636
- 'key' => 'general_videothumbs',
637
- 'value' => $options['general_videothumbs'],
638
- 'class' => array('rtmedia-setting-text-box'),
639
- 'desc' => __(' If you choose more than 1 thumbnail, your users will be able to change thumbnail by going to video "edit" section.','rtmedia'),
640
- 'min' => 1
641
- )
642
- );
643
?>
644
<div class="postbox metabox-holder">
645
<h3 class="hndle"><span>Encoding Settings</span></h3>
@@ -649,130 +770,155 @@ class RTMediaFormHandler {
649
<?php echo $render_video_thumb['title']; ?>
650
</div>
651
<div class="columns large-3">
652
- <?php call_user_func($render_video_thumb['callback'], $render_video_thumb['args']); ?>
653
- <span data-tooltip class="has-tip" title="<?php echo (isset($render_video_thumb['args']['desc'])) ? $render_video_thumb['args']['desc'] : "NA"; ?>"><i class="rtmicon-info-circle"></i></span>
654
</div>
655
</div>
656
<?php
657
}
658
659
- public static function custom_css_content() {
660
-
661
- global $rtmedia;
662
- $options = self::extract_settings('styles', $rtmedia->options);
663
- $render_data = self::custom_css_render_options($options);
664
- ?>
665
- <div class="postbox metabox-holder">
666
- <h3 class="hndle"><span>Custom CSS settings</span></h3>
667
- </div>
668
- <?php
669
- echo '<div class="large-12">';
670
- foreach ($render_data as $option) { ?>
671
-
672
- <div class="row section">
673
- <?php if( $option['args']['key'] == "styles_custom"){ ?>
674
- <div class="columns large-12 rtm-custom-css">
675
- <strong class="<?php echo $option['args']['key'];?>"><?php echo $option['title']; ?></strong>
676
- <?php call_user_func($option['callback'], $option['args']); ?>
677
- <div><?php _e("If you want to add some custom CSS code to the plugin and don't want to modify any files, then it's a good place to enter your code at this field.");?></div>
678
- </div>
679
- <?php } else { ?>
680
- <div class="columns large-6">
681
<strong class="<?php echo $option['args']['key'];?>"><?php echo $option['title']; ?></strong>
682
</div>
683
- <div class="columns large-6">
684
- <?php call_user_func($option['callback'], $option['args']); ?>
685
- <span data-tooltip class="has-tip" title="<?php echo (isset($option['args']['desc'])) ? $option['args']['desc'] : "NA"; ?>"><i class="rtmicon-info-circle"></i></span>
686
- </div>
687
- <?php } ?>
688
</div>
689
- <?php }
690
- echo '</div>';
691
692
- }
693
694
- static function custom_css_render_options($options) {
695
- global $rtmedia;
696
697
- $render = array(
698
- 'disable_styles' => array(
699
- 'title' => __("rtMedia default styles","rtmedia"),
700
- 'callback' => array("RTMediaFormHandler", "checkbox"),
701
'args' => array(
702
'id' => 'rtmedia-disable-styles',
703
'key' => 'styles_enabled',
704
'value' => $options['styles_enabled'],
705
- 'desc' => __('Load default rtMedia styles. You need to write your own style for rtMedia if you disable it.','rtmedia')
706
- )
707
- ),
708
- 'custom_styles' => array(
709
- 'title' => __("Paste your CSS code","rtmedia"),
710
- 'callback' => array("RTMediaFormHandler", "textarea"),
711
'args' => array(
712
'id' => 'rtmedia-custom-css',
713
'key' => 'styles_custom',
714
'value' => stripcslashes( $options['styles_custom'] ),
715
- 'desc' => __('Custom rtMedia CSS container','rtmedia')
716
- )
717
- )
718
- );
719
720
- return $render;
721
- }
722
-
723
- static function privacy_render_options($options) {
724
725
global $rtmedia;
726
727
$render = array(
728
'enable' => array(
729
- 'title' => __("Enable privacy","rtmedia"),
730
- 'callback' => array("RTMediaFormHandler", "checkbox"),
731
'args' => array(
732
'id' => 'rtmedia-privacy-enable',
733
'key' => 'privacy_enabled',
734
'value' => $options['privacy_enabled'],
735
- 'desc' => __('Enable privacy in rtMedia','rtmedia')
736
)
737
),
738
'default' => array(
739
- 'title' => __("Default privacy","rtmedia"),
740
- 'callback' => array("RTMediaFormHandler","radio"),
741
'args' => array(
742
'key' => 'privacy_default',
743
'radios' => $rtmedia->privacy_settings['levels'],
744
'default' => $options['privacy_default'],
745
- 'desc' => __('Set default privacy for media','rtmedia')
746
),
747
),
748
'user_override' => array(
749
- 'title' => __("Allow users to set privacy for their content","rtmedia"),
750
- 'callback' => array("RTMediaFormHandler", "checkbox"),
751
'args' => array(
752
'key' => 'privacy_userOverride',
753
'value' => $options['privacy_userOverride'],
754
- 'desc' => __('If you choose this, user will be able to change privacy of their own uploads.','rtmedia')
755
),
756
- 'after_content' => __('For group uploads, BuddyPress groups privacy is used.','rtmedia')
757
)
758
);
759
760
return $render;
761
}
762
763
public static function privacy_content() {
764
-
765
global $rtmedia;
766
- $options = self::extract_settings('privacy', $rtmedia->options);
767
768
- $render_data = self::privacy_render_options($options);
769
?>
770
<div class="postbox metabox-holder">
771
<h3 class="hndle"><span>Privacy Settings</span></h3>
772
</div>
773
<?php
774
echo '<div class="large-12">';
775
- foreach ($render_data as $key=>$privacy) {
776
echo '<div class="row section">';
777
?>
778
<div class="columns large-6">
@@ -780,17 +926,18 @@ class RTMediaFormHandler {
780
</div>
781
<?php
782
echo '<div class="columns large-6">';
783
- if($key != "enable")
784
- call_user_func($privacy['callback'], array_merge_recursive($privacy['args'], array('class' => array("privacy-driven-disable"))));
785
- else
786
- call_user_func($privacy['callback'], $privacy['args']);
787
?>
788
- <span data-tooltip class="has-tip" title="<?php echo (isset($privacy['args']['desc'])) ? $privacy['args']['desc'] : "NA"; ?>"><i class="rtmicon-info-circle"></i></span>
789
<?php
790
echo '</div>';
791
echo '</div>';
792
793
- if( isset( $privacy['after_content'] ) ) {
794
?>
795
<div class="row">
796
<div class="columns large-12">
@@ -805,46 +952,51 @@ class RTMediaFormHandler {
805
echo '</div>';
806
}
807
808
- static function buddypress_render_options($options) {
809
-
810
-
811
$render = array(
812
'rtmedia-enable-on-profile' => array(
813
- 'title' => __('Enable media in profile','rtmedia'),
814
- 'callback' => array('RTMediaFormHandler', 'checkbox'),
815
'args' => array(
816
'key' => 'buddypress_enableOnProfile',
817
'value' => $options['buddypress_enableOnProfile'],
818
- 'desc' => __('Enable Media on BuddyPress Profile','rtmedia')
819
)
820
),
821
'rtmedia-enable-on-group' => array(
822
- 'title' => __('Enable media in group','rtmedia'),
823
- 'callback' => array('RTMediaFormHandler', 'checkbox'),
824
'args' => array(
825
'key' => 'buddypress_enableOnGroup',
826
'value' => $options['buddypress_enableOnGroup'],
827
- 'desc' => __('Enable Media on BuddyPress Groups','rtmedia')
828
)
829
),
830
'rtmedia-enable-on-activity' => array(
831
- 'title' => __('Allow upload from activity stream','rtmedia'),
832
- 'callback' => array('RTMediaFormHandler', 'checkbox'),
833
'args' => array(
834
'key' => 'buddypress_enableOnActivity',
835
'value' => $options['buddypress_enableOnActivity'],
836
- 'desc' => __('Allow upload using status update box present on activity stream page','rtmedia'),
837
'id' => "rtmedia-bp-enable-activity"
838
)
839
),
840
'rtmedia-activity-feed-limit' => array(
841
- 'title' => __('Number of media items to show in activity stream', 'rtmedia'),
842
- 'callback' => array('RTMediaFormHandler', 'number'),
843
'args' => array(
844
'key' => 'buddypress_limitOnActivity',
845
'value' => $options['buddypress_limitOnActivity'],
846
- 'desc' => __('With bulk uploads activity stream may get flooded. You can control maximum number of medias/files per activity. This limit will not affect the actual number of uplaods. Only display. <em>0</em> means unlimited.', 'rtmedia'),
847
- 'class' => array('rtmedia-setting-text-box rtmedia-bp-activity-setting'),
848
'min' => 0
849
)
850
)
@@ -853,25 +1005,31 @@ class RTMediaFormHandler {
853
return $render;
854
}
855
856
public static function buddypress_content() {
857
-
858
global $rtmedia;
859
- $options = self::extract_settings('buddypress', $rtmedia->options);
860
?>
861
<div class="postbox metabox-holder">
862
<h3 class="hndle"><span>Integration With BuddyPress Features</span></h3>
863
<?php
864
- $render_data = self::buddypress_render_options($options);
865
866
echo '<div class="large-12">';
867
- foreach ($render_data as $option) { ?>
868
<div class="row section">
869
<div class="columns large-9">
870
<?php echo $option['title']; ?>
871
</div>
872
<div class="columns large-3">
873
- <?php call_user_func($option['callback'], $option['args']); ?>
874
- <span data-tooltip class="has-tip" title="<?php echo (isset($option['args']['desc'])) ? $option['args']['desc'] : "NA"; ?>"><i class="rtmicon-info-circle"></i></span>
875
</div>
876
</div>
877
<?php }
@@ -883,27 +1041,27 @@ class RTMediaFormHandler {
883
<?php
884
$options = $rtmedia->options;
885
$render_options = array(
886
- 'general_enableAlbums' => array(
887
- 'title' => __('Organize media into albums','rtmedia'),
888
- 'callback' => array('RTMediaFormHandler', 'checkbox'),
889
'args' => array(
890
'id' => 'rtmedia-album-enable',
891
'key' => 'general_enableAlbums',
892
'value' => $options['general_enableAlbums'],
893
- 'desc' => __('This will add \'album\' tab to BuddyPress profile and group depending on ^above^ settings.','rtmedia')
894
)
895
- ),
896
);
897
- $render_options = apply_filters('rtmedia_album_control_setting',$render_options, $options);
898
- foreach ($render_options as $tab => $option) {
899
?>
900
<div class="row section">
901
<div class="columns large-9">
902
<?php echo $option['title']; ?>
903
</div>
904
<div class="columns large-3">
905
- <?php call_user_func($option['callback'], $option['args']); ?>
906
- <span data-tooltip class="has-tip" title="<?php echo (isset($option['args']['desc'])) ? $option['args']['desc'] : "NA"; ?>"><i class="rtmicon-info-circle"></i></span>
907
</div>
908
</div>
909
<?php
@@ -911,44 +1069,60 @@ class RTMediaFormHandler {
911
?>
912
</div>
913
<?php
914
- do_action('rtmedia_buddypress_setting_content');
915
}
916
917
- public static function rtForm_settings_tabs_content($page, $sub_tabs) {
918
- // $rtmedia_admin_ui_handler = "<div class='section-container auto' data-options='deep_linking: true' data-section=''>";
919
- //echo "<div class='clearfix rtm-settings-tab-container'>";
920
- $rtmedia_admin_ui_handler = "<div class='clearfix rtm-settings-tab-container horizontal-tabs'><dl class='tabs' data-tab>";
921
- $rtmedia_admin_ui_handler = apply_filters("rtmedia_admin_ui_handler_filter",$rtmedia_admin_ui_handler);
922
- echo $rtmedia_admin_ui_handler ;
923
- $i = 1;
924
- $sub_tabs = apply_filters("rtmedia_pro_settings_tabs_content",$sub_tabs);
925
- ksort($sub_tabs);
926
- foreach ($sub_tabs as $tab) {
927
- $active_class = '';
928
- if( $i == 1){ $active_class = 'active';} $i++;
929
- if ( isset ( $tab[ 'icon' ] ) && ! empty ( $tab[ 'icon' ] ) )
930
- $icon = '<i class="' . $tab[ 'icon' ] . '"></i>';
931
- echo '<dd class="' . $active_class . '"><a id="tab-' . substr ( $tab[ 'href' ], 1 ) . '" title="' . $tab[ 'title' ] . '" href="' . $tab[ 'href' ] . '" class="rtmedia-tab-title ' . sanitize_title ( $tab[ 'name' ] ) . '">' . $icon . $tab[ 'name' ] . '</a></dd>';
932
}
933
- echo "</dl>";
934
?>
935
936
<?php
937
$rtmedia_admin_tab_content_handler = "<div class='tabs-content'>";
938
- $rtmedia_admin_tab_content_handler = apply_filters("rtmedia_admin_tab_content_handler",$rtmedia_admin_tab_content_handler);
939
echo $rtmedia_admin_tab_content_handler;
940
$k = 1;
941
- foreach ($sub_tabs as $tab) {
942
$active_class = '';
943
- if( $k == 1){ $active_class = ' active';} $k++;
944
- if ( isset ( $tab[ 'icon' ] ) && ! empty ( $tab[ 'icon' ] ) )
945
$icon = '<i class="' . $tab[ 'icon' ] . '"></i>';
946
- $tab_without_hash = explode("#", $tab[ 'href' ]);
947
$tab_without_hash = $tab_without_hash[1];
948
echo '<div class="content' . $active_class .'" id="' . $tab_without_hash . '">';
949
- call_user_func($tab['callback'], $page);
950
echo '</div>';
951
- }
952
echo "</div>";
953
?>
954
</div>
@@ -956,24 +1130,34 @@ class RTMediaFormHandler {
956
<?php
957
}
958
959
- public static function rtForm_do_settings_fields($page, $section) {
960
global $wp_settings_fields;
961
962
- if (!isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]))
963
return;
964
965
- foreach ((array) $wp_settings_fields[$page][$section] as $field) {
966
echo '<div class="row">';
967
echo '<div class="large-11 columns">';
968
969
- if (isset($field['args']['label_for']) && !empty($field['args']['label_for']))
970
- call_user_func($field['callback'], array_merge($field['args'], array('label' => $field['args']['label_for'])));
971
- else if (isset($field['title']) && !empty($field['title']))
972
- call_user_func($field['callback'], array_merge($field['args'], array('label' => $field['title'])));
973
- else
974
- call_user_func($field['callback'], $field['args']);
975
echo '</div>';
976
echo '</div>';
977
}
978
}
979
- }
12
*/
13
class RTMediaFormHandler {
14
15
+ public static function selectBox( $args ) {
16
global $rtmedia;
17
$options = $rtmedia->options;
18
$defaults = array(
22
'show_desc' => false,
23
'selects' => array()
24
);
25
+ $args = wp_parse_args( $args, $defaults );
26
+ extract( $args );
27
28
+ if ( ! empty( $key ) ){
29
$args['name'] = 'rtmedia-options[' . $key . ']';
30
}
31
32
$args['rtForm_options'] = array();
33
+ foreach ( $selects as $value => $key ) {
34
$args['rtForm_options'][] = array(
35
$key => $value,
36
+ 'selected' => ( $default == $value ) ? true : false
37
);
38
}
39
40
$chkObj = new rtForm();
41
+ echo $chkObj->get_select( $args );
42
}
43
44
+ /**
45
+ * Show rtmedia textarea in admin options.
46
+ *
47
+ * @access static
48
+ * @param array $args
49
+ * @param bool $echo
50
+ * @return string $chkObj->get_textarea( $args )
51
+ */
52
+ public static function textarea( $args, $echo = true ) {
53
global $rtmedia;
54
$options = $rtmedia->options;
55
$defaults = array(
56
+ 'id' => '',
57
'key' => '',
58
'desc' => '',
59
'show_desc' => false
60
);
61
+ $args = wp_parse_args( $args, $defaults );
62
+ extract( $args );
63
64
+ if ( ! isset( $value ) ){
65
+ trigger_error( __( 'Pleas